@@ -69,7 +69,7 @@ void ArduinoCloudThing::update() {
6969 }
7070
7171 /* Handle external events */
72- switch (_command. c . id ) {
72+ switch (_command) {
7373 case LastValuesUpdateCmdId:
7474 if (_state == State::RequestLastValues) {
7575 DEBUG_VERBOSE (" CloudThing::%s Thing is synced" , __FUNCTION__);
@@ -79,8 +79,7 @@ void ArduinoCloudThing::update() {
7979
8080 /* We have received a timezone update */
8181 case TimezoneCommandDownId:
82- TimeService.setTimeZoneData (_command.timezoneCommandDown .params .offset ,
83- _command.timezoneCommandDown .params .until );
82+ TimeService.setTimeZoneData (_utcOffset, _utcOffsetExpireTime);
8483 break ;
8584
8685 /* We have received a reset command */
@@ -92,7 +91,7 @@ void ArduinoCloudThing::update() {
9291 break ;
9392 }
9493
95- _command. c . id = UnknownCmdId;
94+ _command = UnknownCmdId;
9695 _state = nextState;
9796}
9897
@@ -101,9 +100,13 @@ int ArduinoCloudThing::connected() {
101100}
102101
103102void ArduinoCloudThing::handleMessage (Message* m) {
104- _command. c . id = UnknownCmdId;
103+ _command = UnknownCmdId;
105104 if (m != nullptr ) {
106- memcpy (&_command, m, sizeof (CommandDown));
105+ _command = m->id ;
106+ if (_command == TimezoneCommandDownId) {
107+ _utcOffset = reinterpret_cast <TimezoneCommandDown*>(m)->params .offset ;
108+ _utcOffsetExpireTime = reinterpret_cast <TimezoneCommandDown*>(m)->params .until ;
109+ }
107110 }
108111}
109112
0 commit comments