@@ -69,7 +69,7 @@ void ArduinoCloudThing::update() {
69
69
}
70
70
71
71
/* Handle external events */
72
- switch (_command. c . id ) {
72
+ switch (_command) {
73
73
case LastValuesUpdateCmdId:
74
74
if (_state == State::RequestLastValues) {
75
75
DEBUG_VERBOSE (" CloudThing::%s Thing is synced" , __FUNCTION__);
@@ -79,8 +79,7 @@ void ArduinoCloudThing::update() {
79
79
80
80
/* We have received a timezone update */
81
81
case TimezoneCommandDownId:
82
- TimeService.setTimeZoneData (_command.timezoneCommandDown .params .offset ,
83
- _command.timezoneCommandDown .params .until );
82
+ TimeService.setTimeZoneData (_utcOffset, _utcOffsetExpireTime);
84
83
break ;
85
84
86
85
/* We have received a reset command */
@@ -92,7 +91,7 @@ void ArduinoCloudThing::update() {
92
91
break ;
93
92
}
94
93
95
- _command. c . id = UnknownCmdId;
94
+ _command = UnknownCmdId;
96
95
_state = nextState;
97
96
}
98
97
@@ -101,9 +100,13 @@ int ArduinoCloudThing::connected() {
101
100
}
102
101
103
102
void ArduinoCloudThing::handleMessage (Message* m) {
104
- _command. c . id = UnknownCmdId;
103
+ _command = UnknownCmdId;
105
104
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
+ }
107
110
}
108
111
}
109
112
0 commit comments