Skip to content

Commit 12beae5

Browse files
committed
CloudDevice: unify update and handleMessage
1 parent 8b6ff40 commit 12beae5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/ArduinoIoTCloudDevice.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ void ArduinoCloudDevice::begin() {
3838
}
3939

4040
void ArduinoCloudDevice::update() {
41+
handleMessage(nullptr);
42+
}
43+
44+
int ArduinoCloudDevice::connected() {
45+
return _state != State::Disconnected ? 1 : 0;
46+
}
47+
48+
void ArduinoCloudDevice::handleMessage(Message *m) {
49+
_command = UnknownCmdId;
50+
if (m != nullptr) {
51+
_command = m->id;
52+
}
53+
4154
/* Run through the state machine. */
4255
State nextState = _state;
4356
switch (_state) {
@@ -80,17 +93,6 @@ void ArduinoCloudDevice::update() {
8093
_state = nextState;
8194
}
8295

83-
int ArduinoCloudDevice::connected() {
84-
return _state != State::Disconnected ? 1 : 0;
85-
}
86-
87-
void ArduinoCloudDevice::handleMessage(Message *m) {
88-
_command = UnknownCmdId;
89-
if (m != nullptr) {
90-
_command = m->id;
91-
}
92-
}
93-
9496
ArduinoCloudDevice::State ArduinoCloudDevice::handleInit() {
9597
/* Reset attempt struct for the nex retry after disconnection */
9698
_attachAttempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms,

0 commit comments

Comments
 (0)