Skip to content

Commit 819161c

Browse files
committed
add GET_PROVISIONING_SKETCH_VERSION command
1 parent ec5c8f9 commit 819161c

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

examples/utility/Provisioning_2.0/ClaimingHandler.cpp

+22-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "utility/HCI.h"
1414
#include <Arduino_HEX.h>
1515

16+
extern const char *SKETCH_VERSION;
17+
1618
ClaimingHandlerClass::ClaimingHandlerClass():
1719
_uhwid {nullptr},
1820
_state {ClaimingHandlerStates::END},
@@ -45,6 +47,10 @@ bool ClaimingHandlerClass::begin(SecureElement &secureElement, String &uhwid, Cl
4547
return false;
4648
}
4749

50+
if(!_agentManager.addRequestHandler(RequestType::GET_PROVISIONING_SKETCH_VERSION, getProvSketchVersionRequestCb)) {
51+
return false;
52+
}
53+
4854
if (!_agentManager.addReturnTimestampCallback(setTimestamp)) {
4955
return false;
5056
}
@@ -76,9 +82,10 @@ void ClaimingHandlerClass::poll() {
7682
_agentManager.update();
7783

7884
switch (_receivedEvent) {
79-
case ClaimingReqEvents::GET_ID: getIdReqHandler (); break;
80-
case ClaimingReqEvents::RESET: resetStoredCredReqHandler (); break;
81-
case ClaimingReqEvents::GET_BLE_MAC_ADDRESS: getBLEMacAddressReqHandler(); break;
85+
case ClaimingReqEvents::GET_ID: getIdReqHandler (); break;
86+
case ClaimingReqEvents::RESET: resetStoredCredReqHandler (); break;
87+
case ClaimingReqEvents::GET_BLE_MAC_ADDRESS: getBLEMacAddressReqHandler (); break;
88+
case ClaimingReqEvents::GET_PROV_SKETCH_VERSION: getProvSketchVersionReqHandler(); break;
8289
}
8390
_receivedEvent = ClaimingReqEvents::NONE;
8491
return;
@@ -149,6 +156,13 @@ void ClaimingHandlerClass::getBLEMacAddressReqHandler() {
149156
_agentManager.sendMsg(outputMsg);
150157
}
151158

159+
void ClaimingHandlerClass::getProvSketchVersionReqHandler() {
160+
ProvisioningOutputMessage outputMsg;
161+
outputMsg.type = MessageOutputType::PROV_SKETCH_VERSION;
162+
outputMsg.m.provSketchVersion = SKETCH_VERSION;
163+
_agentManager.sendMsg(outputMsg);
164+
}
165+
152166
void ClaimingHandlerClass::getIdRequestCb() {
153167
DEBUG_VERBOSE("CH Get ID request received");
154168
_receivedEvent = ClaimingReqEvents::GET_ID;
@@ -167,6 +181,11 @@ void ClaimingHandlerClass::getBLEMacAddressRequestCb() {
167181
_receivedEvent = ClaimingReqEvents::GET_BLE_MAC_ADDRESS;
168182
}
169183

184+
void ClaimingHandlerClass::getProvSketchVersionRequestCb() {
185+
DEBUG_VERBOSE("CH Get provisioning sketch version request received");
186+
_receivedEvent = ClaimingReqEvents::GET_PROV_SKETCH_VERSION;
187+
}
188+
170189
bool ClaimingHandlerClass::sendStatus(StatusMessage msg) {
171190
ProvisioningOutputMessage statusMsg = { MessageOutputType::STATUS, { msg } };
172191
return _agentManager.sendMsg(statusMsg);

examples/utility/Provisioning_2.0/ClaimingHandler.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class ClaimingHandlerClass {
2828
enum class ClaimingReqEvents { NONE,
2929
GET_ID,
3030
RESET,
31-
GET_BLE_MAC_ADDRESS };
31+
GET_BLE_MAC_ADDRESS,
32+
GET_PROV_SKETCH_VERSION};
3233
static inline ClaimingReqEvents _receivedEvent;
3334
ClaimingHandlerStates _state;
3435
AgentsManagerClass &_agentManager;
@@ -41,10 +42,12 @@ class ClaimingHandlerClass {
4142
void getIdReqHandler();
4243
void resetStoredCredReqHandler();
4344
void getBLEMacAddressReqHandler();
45+
void getProvSketchVersionReqHandler();
4446
ClearStoredCredentialsHandler _clearStoredCredentials;
4547
/* Callbacks for receiving commands */
4648
static void getIdRequestCb();
4749
static void setTimestamp(uint64_t ts);
4850
static void resetStoredCredRequestCb();
4951
static void getBLEMacAddressRequestCb();
52+
static void getProvSketchVersionRequestCb();
5053
};

examples/utility/Provisioning_2.0/Provisioning_2.0.ino

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <utility/SElementArduinoCloudCertificate.h>
1616
#include "Utility/LEDFeedback/LEDFeedback.h"
1717

18+
const char *SKETCH_VERSION = "0.1.0";
19+
1820
enum class DeviceState {
1921
HARDWARE_CHECK,
2022
BEGIN,

0 commit comments

Comments
 (0)