From 6818099648c0926f14a423d8d29ea7b0ee2e664a Mon Sep 17 00:00:00 2001 From: Roberto Gazia Date: Mon, 29 Apr 2024 11:21:04 +0200 Subject: [PATCH 1/3] Add update timezone command support --- src/ArduinoIoTCloudTCP.cpp | 7 +++++++ src/ArduinoIoTCloudThing.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 1ffb5b0e7..439cbd80f 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -421,6 +421,13 @@ void ArduinoIoTCloudTCP::handleMessage(int length) } break; + case CommandId::TimezoneCommandDownId: + { + DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] timezone update received", __FUNCTION__, millis()); + _thing.handleMessage((Message*)&command); + } + break; + case CommandId::LastValuesUpdateCmdId: { DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] last values received", __FUNCTION__, millis()); diff --git a/src/ArduinoIoTCloudThing.cpp b/src/ArduinoIoTCloudThing.cpp index 6ea6dd904..3c5602f48 100644 --- a/src/ArduinoIoTCloudThing.cpp +++ b/src/ArduinoIoTCloudThing.cpp @@ -76,6 +76,14 @@ void ArduinoCloudThing::update() { nextState = State::Connected; } break; + + /* We have received a timezone update */ + case TimezoneCommandDownId: + { + TimezoneCommandDown * cmd = (TimezoneCommandDown *)_command; + TimeService.setTimeZoneData(cmd->params.offset, cmd->params.until); + } + break; /* We have received a reset command */ case ResetCmdId: From 2ad2bbdc78bc318af61ab392d2a835be5ab7527d Mon Sep 17 00:00:00 2001 From: Mirko Curtolo Date: Tue, 9 Apr 2024 11:26:34 +0200 Subject: [PATCH 2/3] Set LIB_VERSION to 2.0.0 --- src/AIoTC_Config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index e9c408903..6f0f8c21f 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -157,6 +157,6 @@ #define AIOT_CONFIG_RP2040_OTA_HTTP_HEADER_RECEIVE_TIMEOUT_ms (10*1000UL) #define AIOT_CONFIG_RP2040_OTA_HTTP_DATA_RECEIVE_TIMEOUT_ms (4*60*1000UL) -#define AIOT_CONFIG_LIB_VERSION "1.15.1" +#define AIOT_CONFIG_LIB_VERSION "2.0.0" #endif /* ARDUINO_AIOTC_CONFIG_H_ */ From 326b85f4aa977ec22ab89d8bb2951bb358faae9e Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 8 May 2024 15:34:07 +0200 Subject: [PATCH 3/3] MessageDecoder: add check on thing_id length --- src/cbor/MessageDecoder.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cbor/MessageDecoder.cpp b/src/cbor/MessageDecoder.cpp index 7c3e9a215..299bf7940 100644 --- a/src/cbor/MessageDecoder.cpp +++ b/src/cbor/MessageDecoder.cpp @@ -127,6 +127,13 @@ CBORMessageDecoder::ArrayParserState CBORMessageDecoder::decodeThingUpdateCmd(Cb return ArrayParserState::Error; } + size_t thingIdLen = strlen(thingCommand->params.thing_id); + + // thing_id length normally is 36, or 0 in case of device not attached to any thing + if (!((thingIdLen == sizeof(thingCommand->params.thing_id) -1) || (thingIdLen == 0))) { + return ArrayParserState::Error; + } + return ArrayParserState::LeaveArray; }