Skip to content

Commit 03ce89c

Browse files
robgee86andreagilardoni
authored andcommitted
Add update timezone command support
1 parent 1e79944 commit 03ce89c

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/ArduinoIoTCloudTCP.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
421421
}
422422
break;
423423

424+
case CommandId::TimezoneCommandDownId:
425+
{
426+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] timezone update received", __FUNCTION__, millis());
427+
_thing.handleMessage((Message*)&command);
428+
}
429+
break;
430+
424431
case CommandId::LastValuesUpdateCmdId:
425432
{
426433
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] last values received", __FUNCTION__, millis());

src/ArduinoIoTCloudThing.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,20 @@ void ArduinoCloudThing::update() {
6969
}
7070

7171
/* Handle external events */
72-
switch (_command) {
72+
switch (_command.c.id) {
7373
case LastValuesUpdateCmdId:
7474
if (_state == State::RequestLastValues) {
7575
DEBUG_VERBOSE("CloudThing::%s Thing is synced", __FUNCTION__);
7676
nextState = State::Connected;
7777
}
7878
break;
7979

80+
/* We have received a timezone update */
81+
case TimezoneCommandDownId:
82+
TimeService.setTimeZoneData(_command.timezoneCommandDown.params.offset,
83+
_command.timezoneCommandDown.params.until);
84+
break;
85+
8086
/* We have received a reset command */
8187
case ResetCmdId:
8288
nextState = State::Init;
@@ -86,7 +92,7 @@ void ArduinoCloudThing::update() {
8692
break;
8793
}
8894

89-
_command = UnknownCmdId;
95+
_command.c.id = UnknownCmdId;
9096
_state = nextState;
9197
}
9298

@@ -95,9 +101,9 @@ int ArduinoCloudThing::connected() {
95101
}
96102

97103
void ArduinoCloudThing::handleMessage(Message* m) {
98-
_command = UnknownCmdId;
104+
_command.c.id = UnknownCmdId;
99105
if (m != nullptr) {
100-
_command = m->id;
106+
memcpy(&_command, m, sizeof(CommandDown));
101107
}
102108
}
103109

src/ArduinoIoTCloudThing.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ArduinoCloudThing : public CloudProcess {
5151
};
5252

5353
State _state;
54-
CommandId _command;
54+
CommandDown _command;
5555
TimedAttempt _syncAttempt;
5656
PropertyContainer _propertyContainer;
5757
unsigned int _propertyContainerIndex;

0 commit comments

Comments
 (0)