Skip to content

Commit 25e6583

Browse files
authored
Merge pull request #487 from pennam/const-cleanup
Const cleanup
2 parents 91db7a3 + 8e347b3 commit 25e6583

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

src/AIoTC_Config.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,24 @@
142142
* CONSTANTS
143143
******************************************************************************/
144144

145-
#define AIOT_CONFIG_INTERVAL_RETRY_DELAY_ms (10000UL)
146-
#define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL)
147-
#define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL)
148-
#define AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms (2000UL)
149-
#define AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms (32000UL)
150-
#define AIOT_CONFIG_DEVICE_TOPIC_MAX_RETRY_CNT (10UL)
151-
#define AIOT_CONFIG_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (20000UL)
152-
#define AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms (1280000UL)
153-
#define AIOT_CONFIG_THING_TOPICS_SUBSCRIBE_RETRY_DELAY_ms (1000UL)
154-
#define AIOT_CONFIG_THING_TOPICS_SUBSCRIBE_MAX_RETRY_CNT (10UL)
155-
#define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL)
156-
#define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL)
157-
158-
#define AIOT_CONFIG_RP2040_OTA_HTTP_HEADER_RECEIVE_TIMEOUT_ms (10*1000UL)
159-
#define AIOT_CONFIG_RP2040_OTA_HTTP_DATA_RECEIVE_TIMEOUT_ms (4*60*1000UL)
145+
#if defined(HAS_LORA)
146+
#define AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms (10000UL)
147+
#endif
148+
149+
#if defined(HAS_TCP)
150+
#define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL)
151+
#define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL)
152+
153+
#define AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms (2000UL)
154+
#define AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms (32000UL)
155+
#define AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT (10UL)
156+
157+
#define AIOT_CONFIG_DEVICE_REGISTERED_RETRY_DELAY_k (10UL)
158+
#define AIOT_CONFIG_MAX_DEVICE_REGISTERED_RETRY_DELAY_k (4UL)
159+
160+
#define AIOT_CONFIG_TIMEOUT_FOR_LASTVALUES_SYNC_ms (30000UL)
161+
#define AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT (10UL)
162+
#endif
160163

161164
#define AIOT_CONFIG_LIB_VERSION "2.0.3"
162165

src/ArduinoIoTCloudDevice.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ _registered(false) {
3333
}
3434

3535
void ArduinoCloudDevice::begin() {
36-
_attachAttempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms,
37-
AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms);
36+
_attachAttempt.begin(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms,
37+
AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms);
3838
}
3939

4040
void ArduinoCloudDevice::update() {
@@ -95,8 +95,8 @@ void ArduinoCloudDevice::handleMessage(Message *m) {
9595

9696
ArduinoCloudDevice::State ArduinoCloudDevice::handleInit() {
9797
/* Reset attempt struct for the nex retry after disconnection */
98-
_attachAttempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms,
99-
AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms);
98+
_attachAttempt.begin(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms,
99+
AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms);
100100

101101
_attached = false;
102102
_registered = false;
@@ -122,7 +122,7 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() {
122122

123123
ArduinoCloudDevice::State ArduinoCloudDevice::handleConnected() {
124124
/* Max retry than disconnect */
125-
if (_attachAttempt.getRetryCount() > AIOT_CONFIG_DEVICE_TOPIC_MAX_RETRY_CNT) {
125+
if (_attachAttempt.getRetryCount() > AIOT_CONFIG_THING_ID_REQUEST_MAX_RETRY_CNT) {
126126
return State::Disconnected;
127127
}
128128

@@ -132,8 +132,10 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleConnected() {
132132
* counter, but recompute delay.
133133
* Wait: 4s -> 80s -> 160s -> 320s -> 640s -> 1280s -> 1280s ...
134134
*/
135-
_attachAttempt.reconfigure(AIOT_CONFIG_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms,
136-
AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms);
135+
_attachAttempt.reconfigure(AIOT_CONFIG_THING_ID_REQUEST_RETRY_DELAY_ms *
136+
AIOT_CONFIG_DEVICE_REGISTERED_RETRY_DELAY_k,
137+
AIOT_CONFIG_MAX_THING_ID_REQUEST_RETRY_DELAY_ms *
138+
AIOT_CONFIG_MAX_DEVICE_REGISTERED_RETRY_DELAY_k);
137139
}
138140
return State::SendCapabilities;
139141
}

src/ArduinoIoTCloudLPWAN.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ArduinoIoTCloudLPWAN::ArduinoIoTCloudLPWAN()
5050
: _state{State::ConnectPhy}
5151
, _retryEnable{false}
5252
, _maxNumRetry{5}
53-
, _intervalRetry{AIOT_CONFIG_INTERVAL_RETRY_DELAY_ms}
53+
, _intervalRetry{AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms}
5454
, _thing_property_container()
5555
, _last_checked_property_index{0}
5656
{

src/ArduinoIoTCloudTCP.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,6 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
284284
/* Subscribe to message topic to receive commands */
285285
_mqttClient.subscribe(_messageTopicIn);
286286

287-
/* Reconfigure timers for next state */
288-
_connection_attempt.begin(AIOT_CONFIG_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms, AIOT_CONFIG_MAX_DEVICE_TOPIC_SUBSCRIBE_RETRY_DELAY_ms);
289-
290287
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
291288
return State::Connected;
292289
}

0 commit comments

Comments
 (0)