Skip to content

Commit 6bd9a44

Browse files
committed
rename MessageTypeCodes to StatusMessage
1 parent dd5718f commit 6bd9a44

File tree

9 files changed

+51
-53
lines changed

9 files changed

+51
-53
lines changed

examples/auto-retry/provisioning.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bool Provisioning::poll() {
8585
_reqCompleted = true;
8686
} else {
8787
Serial.println("Error: timestamp not provided");
88-
ProvisioningOutputMessage msg = { MessageOutputType::STATUS, { MessageTypeCodes::ERROR } };
88+
ProvisioningOutputMessage msg = { MessageOutputType::STATUS, { StatusMessage::ERROR } };
8989
_agentManager->sendMsg(msg);
9090
}
9191
}

examples/provisioning/ClaimingHandler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void ClaimingHandlerClass::getIdReqHandler() {
6666
Serial.println(*_uhwid);
6767
if (*_uhwid == "") {
6868
DEBUG_ERROR("ClaimingHandlerClass::%s Error: UHWID not found", __FUNCTION__);
69-
sendStatus(MessageTypeCodes::ERROR);
69+
sendStatus(StatusMessage::ERROR);
7070
return;
7171
}
7272

@@ -75,7 +75,7 @@ void ClaimingHandlerClass::getIdReqHandler() {
7575
Serial.println(token);
7676
if (token == "") {
7777
DEBUG_ERROR("ClaimingHandlerClass::%s Error: token not created", __FUNCTION__);
78-
sendStatus(MessageTypeCodes::ERROR);
78+
sendStatus(StatusMessage::ERROR);
7979
return;
8080
}
8181
byte _uhwidBytes[33];
@@ -92,21 +92,21 @@ void ClaimingHandlerClass::getIdReqHandler() {
9292
_ts = 0;
9393
} else {
9494
DEBUG_DEBUG("ClaimingHandlerClass::%s Error: timestamp not provided" , __FUNCTION__);
95-
sendStatus(MessageTypeCodes::PARAMS_NOT_FOUND);
95+
sendStatus(StatusMessage::PARAMS_NOT_FOUND);
9696
}
9797
}
9898

9999
void ClaimingHandlerClass::resetStoredCredReqHandler() {
100100
if( _clearStoredCredentials == nullptr) {
101-
sendStatus(MessageTypeCodes::ERROR);
101+
sendStatus(StatusMessage::ERROR);
102102
return;
103103
}
104104

105105
if( !_clearStoredCredentials()){
106106
DEBUG_ERROR("ClaimingHandlerClass::%s Error: reset stored credentials failed", __FUNCTION__);
107-
sendStatus(MessageTypeCodes::ERROR);
107+
sendStatus(StatusMessage::ERROR);
108108
} else {
109-
sendStatus(MessageTypeCodes::RESET_COMPLETED);
109+
sendStatus(StatusMessage::RESET_COMPLETED);
110110
}
111111

112112
}

src/ConfiguratorAgents/AgentsConfiguratorManager.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool AgentsConfiguratorManager::end(uint8_t id) {
9292
#endif
9393
_selectedAgent = nullptr;
9494
_statusRequest.reset();
95-
_initStatusMsg = MessageTypeCodes::NONE;
95+
_initStatusMsg = StatusMessage::NONE;
9696
_state = AgentsConfiguratorManagerStates::END;
9797
}
9898

@@ -116,12 +116,12 @@ bool AgentsConfiguratorManager::sendMsg(ProvisioningOutputMessage &msg) {
116116
_statusRequest.reset();
117117
}
118118
_initStatusMsg = msg.m.status;
119-
} else if (msg.m.status == MessageTypeCodes::CONNECTED) {
119+
} else if (msg.m.status == StatusMessage::CONNECTED) {
120120
if (_statusRequest.pending && _statusRequest.key == RequestType::CONNECT) {
121121
_statusRequest.reset();
122122
}
123123
_initStatusMsg = msg.m.status;
124-
} else if (msg.m.status == MessageTypeCodes::RESET_COMPLETED) {
124+
} else if (msg.m.status == StatusMessage::RESET_COMPLETED) {
125125
if (_statusRequest.pending && _statusRequest.key == RequestType::RESET) {
126126
_statusRequest.reset();
127127
}
@@ -211,12 +211,12 @@ AgentsConfiguratorManagerStates AgentsConfiguratorManager::handleInit() {
211211

212212
AgentsConfiguratorManagerStates AgentsConfiguratorManager::handleSendInitialStatus() {
213213
AgentsConfiguratorManagerStates nextState = _state;
214-
if (_initStatusMsg != MessageTypeCodes::NONE) {
214+
if (_initStatusMsg != StatusMessage::NONE) {
215215
if (!sendStatus(_initStatusMsg)) {
216216
DEBUG_WARNING("AgentsConfiguratorManager::%s failed to send initial status", __FUNCTION__);
217217
return nextState;
218218
}
219-
_initStatusMsg = MessageTypeCodes::NONE;
219+
_initStatusMsg = StatusMessage::NONE;
220220
}
221221
nextState = AgentsConfiguratorManagerStates::SEND_NETWORK_OPTIONS;
222222
return nextState;
@@ -295,7 +295,7 @@ void AgentsConfiguratorManager::handleReceivedData() {
295295
void AgentsConfiguratorManager::handleConnectCommand() {
296296
if (_statusRequest.pending) {
297297
DEBUG_DEBUG("AgentsConfiguratorManager::%s received a Connect request while executing another request", __FUNCTION__);
298-
sendStatus(MessageTypeCodes::OTHER_REQUEST_IN_EXECUTION);
298+
sendStatus(StatusMessage::OTHER_REQUEST_IN_EXECUTION);
299299
return;
300300
}
301301

@@ -307,7 +307,7 @@ void AgentsConfiguratorManager::handleConnectCommand() {
307307
void AgentsConfiguratorManager::handleUpdateOptCommand() {
308308
if (_statusRequest.pending) {
309309
DEBUG_DEBUG("AgentsConfiguratorManager::%s received a UpdateConnectivityOptions request while executing another request", __FUNCTION__);
310-
sendStatus(MessageTypeCodes::OTHER_REQUEST_IN_EXECUTION);
310+
sendStatus(StatusMessage::OTHER_REQUEST_IN_EXECUTION);
311311
return;
312312
}
313313

@@ -319,7 +319,7 @@ void AgentsConfiguratorManager::handleUpdateOptCommand() {
319319
void AgentsConfiguratorManager::handleGetIDCommand() {
320320
if (_statusRequest.pending) {
321321
DEBUG_DEBUG("AgentsConfiguratorManager::%s received a GetUnique request while executing another request", __FUNCTION__);
322-
sendStatus(MessageTypeCodes::OTHER_REQUEST_IN_EXECUTION);
322+
sendStatus(StatusMessage::OTHER_REQUEST_IN_EXECUTION);
323323
return;
324324
}
325325

@@ -331,7 +331,7 @@ void AgentsConfiguratorManager::handleGetIDCommand() {
331331
void AgentsConfiguratorManager::handleGetBleMacAddressCommand() {
332332
if (_statusRequest.pending) {
333333
DEBUG_DEBUG("AgentsConfiguratorManager::%s received a GetBleMacAddress request while executing another request", __FUNCTION__);
334-
sendStatus(MessageTypeCodes::OTHER_REQUEST_IN_EXECUTION);
334+
sendStatus(StatusMessage::OTHER_REQUEST_IN_EXECUTION);
335335
return;
336336
}
337337

@@ -361,7 +361,7 @@ void AgentsConfiguratorManager::handleGetBleMacAddressCommand() {
361361
void AgentsConfiguratorManager::handleResetCommand() {
362362
if (_statusRequest.pending) {
363363
DEBUG_DEBUG("AgentsConfiguratorManager::%s received a GetUnique request while executing another request", __FUNCTION__);
364-
sendStatus(MessageTypeCodes::OTHER_REQUEST_IN_EXECUTION);
364+
sendStatus(StatusMessage::OTHER_REQUEST_IN_EXECUTION);
365365
return;
366366
}
367367

@@ -410,7 +410,7 @@ void AgentsConfiguratorManager::callHandler(RequestType type) {
410410

411411
DEBUG_WARNING("AgentsConfiguratorManager::%s %s request received, but handler function is not provided", __FUNCTION__, err.c_str());
412412
_statusRequest.reset();
413-
sendStatus(MessageTypeCodes::INVALID_REQUEST);
413+
sendStatus(StatusMessage::INVALID_REQUEST);
414414
}
415415
}
416416

src/ConfiguratorAgents/AgentsConfiguratorManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AgentsConfiguratorManager {
6868
ConfiguratorAgent *_selectedAgent = nullptr;
6969
uint8_t _instances = 0;
7070
bool _bleAgentEnabled = true;
71-
StatusMessage _initStatusMsg = MessageTypeCodes::NONE;
71+
StatusMessage _initStatusMsg = StatusMessage::NONE;
7272
NetworkOptions _netOptions;
7373
typedef struct {
7474
void reset() {

src/ConfiguratorAgents/MessagesDefinitions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define MAX_UHWID_SIZE 32
1515
#define MAX_JWT_SIZE 268
1616

17-
enum class MessageTypeCodes {
17+
enum class StatusMessage {
1818
NONE = 0,
1919
CONNECTING = 1,
2020
CONNECTED = 2,
@@ -35,8 +35,6 @@ enum class MessageTypeCodes {
3535
ERROR = -255
3636
};
3737

38-
typedef MessageTypeCodes StatusMessage;
39-
4038
enum class RemoteCommands { CONNECT = 1,
4139
GET_ID = 2,
4240
GET_BLE_MAC_ADDRESS = 3,

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/BoardConfigurationProtocol.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ bool BoardConfigurationProtocol::getMsg(ProvisioningInputMessage &msg) {
2929
ProvisioningCommandDown cborMsg;
3030
if (!CBORAdapter::getMsgFromCBOR(data, len, &cborMsg)) {
3131
DEBUG_DEBUG("BoardConfigurationProtocol::%s Invalid message", __FUNCTION__);
32-
sendStatus(MessageTypeCodes::INVALID_PARAMS);
32+
sendStatus(StatusMessage::INVALID_PARAMS);
3333
return false;
3434
}
3535

3636
if (cborMsg.c.id == CommandId::ProvisioningTimestamp) {
3737
uint64_t ts;
3838
if (!CBORAdapter::extractTimestamp(&cborMsg, &ts)) {
3939
DEBUG_DEBUG("BoardConfigurationProtocol::%s Invalid timestamp", __FUNCTION__);
40-
sendStatus(MessageTypeCodes::INVALID_PARAMS);
40+
sendStatus(StatusMessage::INVALID_PARAMS);
4141
return false;
4242
}
4343

@@ -48,7 +48,7 @@ bool BoardConfigurationProtocol::getMsg(ProvisioningInputMessage &msg) {
4848
RemoteCommands cmd;
4949
if (!CBORAdapter::extractCommand(&cborMsg, &cmd)) {
5050
DEBUG_DEBUG("BoardConfigurationProtocol::%s Invalid command", __FUNCTION__);
51-
sendStatus(MessageTypeCodes::INVALID_PARAMS);
51+
sendStatus(StatusMessage::INVALID_PARAMS);
5252
return false;
5353
}
5454

@@ -58,7 +58,7 @@ bool BoardConfigurationProtocol::getMsg(ProvisioningInputMessage &msg) {
5858
msg.type = MessageInputType::NETWORK_SETTINGS;
5959
if (!CBORAdapter::extractNetworkSetting(&cborMsg, &msg.m.netSetting)) {
6060
DEBUG_DEBUG("BoardConfigurationProtocol::%s Invalid network Setting", __FUNCTION__);
61-
sendStatus(MessageTypeCodes::INVALID_PARAMS);
61+
sendStatus(StatusMessage::INVALID_PARAMS);
6262
return false;
6363
}
6464
}

src/ConfiguratorAgents/agents/BoardConfigurationProtocol/CBORAdapter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool CBORAdapter::statusToCBOR(StatusMessage msg, uint8_t *data, size_t *len) {
7171
bool result = false;
7272

7373
switch (msg) {
74-
case MessageTypeCodes::NONE:
74+
case StatusMessage::NONE:
7575
break;
7676
default:
7777
result = adaptStatus(msg, data, len);

0 commit comments

Comments
 (0)