From 2aa4a280d80a4441de6addfc6cde964242279e15 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 16:44:53 +0200 Subject: [PATCH 1/7] LPWAN: rename AIOT_CONFIG_INTERVAL_RETRY_DELAY_ms to AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms --- src/AIoTC_Config.h | 5 ++++- src/ArduinoIoTCloudLPWAN.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index a34793180..aa28c2d16 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -142,7 +142,10 @@ * CONSTANTS ******************************************************************************/ -#define AIOT_CONFIG_INTERVAL_RETRY_DELAY_ms (10000UL) +#if defined(HAS_LORA) + #define AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms (10000UL) +#endif + #define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL) #define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL) #define AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms (2000UL) diff --git a/src/ArduinoIoTCloudLPWAN.cpp b/src/ArduinoIoTCloudLPWAN.cpp index 0f213e0a5..3c6a74daf 100644 --- a/src/ArduinoIoTCloudLPWAN.cpp +++ b/src/ArduinoIoTCloudLPWAN.cpp @@ -50,7 +50,7 @@ ArduinoIoTCloudLPWAN::ArduinoIoTCloudLPWAN() : _state{State::ConnectPhy} , _retryEnable{false} , _maxNumRetry{5} -, _intervalRetry{AIOT_CONFIG_INTERVAL_RETRY_DELAY_ms} +, _intervalRetry{AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms} , _thing_property_container() , _last_checked_property_index{0} { From 1cdc310c08f3dad5180b183af754eaba31ad7947 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 16:46:09 +0200 Subject: [PATCH 2/7] Config: remove RP2040 OTA defines --- src/AIoTC_Config.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index aa28c2d16..a0d11ff53 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -158,9 +158,6 @@ #define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL) #define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL) -#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 "2.0.3" #endif /* ARDUINO_AIOTC_CONFIG_H_ */ From 6e646c5975de6f9ad0c061a22b5eacc7eeff2d5a Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 16:48:06 +0200 Subject: [PATCH 3/7] Config: remove THING_TOPICS unused defines --- src/AIoTC_Config.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index a0d11ff53..4329fefbc 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -153,8 +153,6 @@ #define AIOT_CONFIG_DEVICE_TOPIC_MAX_RETRY_CNT (10UL) #define AIOT_CONFIG_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (20000UL) #define AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (1280000UL) -#define AIOT_CONFIG_THING_TOPICS_SUBSCRIBE_RETRY_DELAY_ms (1000UL) -#define AIOT_CONFIG_THING_TOPICS_SUBSCRIBE_MAX_RETRY_CNT (10UL) #define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL) #define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL) From 91860fcdc616adb4818093a7d5b1a15f5d2a07af Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 17:22:30 +0200 Subject: [PATCH 4/7] Config: rename AIOT_CONFIG_DEVICE_TOPIC_ to AIOT_CONFIG_THING_ID_REQUEST_ --- src/AIoTC_Config.h | 8 +++++--- src/ArduinoIoTCloudDevice.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index 4329fefbc..32d837373 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -148,9 +148,11 @@ #define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL) #define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL) -#define AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms (2000UL) -#define AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms (32000UL) -#define AIOT_CONFIG_DEVICE_TOPIC_MAX_RETRY_CNT (10UL) + +#define AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms (2000UL) +#define AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms (32000UL) +#define AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT (10UL) + #define AIOT_CONFIG_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (20000UL) #define AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (1280000UL) #define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL) diff --git a/src/ArduinoIoTCloudDevice.cpp b/src/ArduinoIoTCloudDevice.cpp index 53fcb74d5..5645a067a 100644 --- a/src/ArduinoIoTCloudDevice.cpp +++ b/src/ArduinoIoTCloudDevice.cpp @@ -33,8 +33,8 @@ _registered(false) { } void ArduinoCloudDevice::begin() { - _attachAttempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms, - AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms); + _attachAttempt.begin(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms, + AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms); } void ArduinoCloudDevice::update() { @@ -93,8 +93,8 @@ void ArduinoCloudDevice::handleMessage(Message *m) { ArduinoCloudDevice::State ArduinoCloudDevice::handleInit() { /* Reset attempt struct for the nex retry after disconnection */ - _attachAttempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms, - AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms); + _attachAttempt.begin(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms, + AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms); _attached = false; _registered = false; @@ -120,7 +120,7 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() { ArduinoCloudDevice::State ArduinoCloudDevice::handleConnected() { /* Max retry than disconnect */ - if (_attachAttempt.getRetryCount() > AIOT_CONFIG_DEVICE_TOPIC_MAX_RETRY_CNT) { + if (_attachAttempt.getRetryCount() > AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT) { return State::Disconnected; } From fa89e5b268ac9ed36932ff59236bef8906bed4e0 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 17:23:18 +0200 Subject: [PATCH 5/7] ArduinoIoTCloudTCP: remove wrong connection_attempt reconfiguration --- src/ArduinoIoTCloudTCP.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index f2a1b6fc1..dcab5ae7d 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -284,9 +284,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker() /* Subscribe to message topic to receive commands */ _mqttClient.subscribe(_messageTopicIn); - /* Reconfigure timers for next state */ - _connection_attempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms, AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms); - DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort); return State::Connected; } From 79c3c03ee1f2e7bd3d89b33b3dacb44cd6a66013 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 17:56:11 +0200 Subject: [PATCH 6/7] Config: usa a multiplier to handle thing id request retries for detached by user devices --- src/AIoTC_Config.h | 5 +++-- src/ArduinoIoTCloudDevice.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index 32d837373..8653047e7 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -153,8 +153,9 @@ #define AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms (32000UL) #define AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT (10UL) -#define AIOT_CONFIG_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (20000UL) -#define AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (1280000UL) +#define AIOT_CONFIG_DEVICE_REGISTERED_RETRY_DELAY_k (10UL) +#define AIOT_CONFIG_MAX_DEVICE_REGISTERED_RETRY_DELAY_k (4UL) + #define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL) #define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL) diff --git a/src/ArduinoIoTCloudDevice.cpp b/src/ArduinoIoTCloudDevice.cpp index 5645a067a..3e67fda10 100644 --- a/src/ArduinoIoTCloudDevice.cpp +++ b/src/ArduinoIoTCloudDevice.cpp @@ -130,8 +130,10 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleConnected() { * counter, but recompute delay. * Wait: 4s -> 80s -> 160s -> 320s -> 640s -> 1280s -> 1280s ... */ - _attachAttempt.reconfigure(AIOT_CONFIG_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms, - AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms); + _attachAttempt.reconfigure(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms * + AIOT_CONFIG_DEVICE_REGISTERED_RETRY_DELAY_k, + AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms * + AIOT_CONFIG_MAX_DEVICE_REGISTERED_RETRY_DELAY_k); } return State::SendCapabilities; } From 8e347b35493cc51a82cc134e7a6a458656248a45 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 15 Jul 2024 17:58:13 +0200 Subject: [PATCH 7/7] Config: wrap TCP constants inside HAS_TCP --- src/AIoTC_Config.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index 8653047e7..d7a1bf8f0 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -146,18 +146,20 @@ #define AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms (10000UL) #endif -#define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL) -#define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL) +#if defined(HAS_TCP) + #define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL) + #define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL) -#define AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms (2000UL) -#define AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms (32000UL) -#define AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT (10UL) + #define AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms (2000UL) + #define AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms (32000UL) + #define AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT (10UL) -#define AIOT_CONFIG_DEVICE_REGISTERED_RETRY_DELAY_k (10UL) -#define AIOT_CONFIG_MAX_DEVICE_REGISTERED_RETRY_DELAY_k (4UL) + #define AIOT_CONFIG_DEVICE_REGISTERED_RETRY_DELAY_k (10UL) + #define AIOT_CONFIG_MAX_DEVICE_REGISTERED_RETRY_DELAY_k (4UL) -#define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL) -#define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL) + #define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL) + #define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL) +#endif #define AIOT_CONFIG_LIB_VERSION "2.0.3"