43
43
* CONSTANTS
44
44
******************************************************************************/
45
45
46
- #ifdef BACKOFF
47
- static size_t const BACKOFF_BASE_MS = 60000 ; // 1 minute
48
- static uint32_t const BACKOFF_MAX_MS = 3600000 ; // 1 hour
49
- #endif
50
46
static size_t const CBOR_NOTE_MSG_MAX_SIZE = 255 ;
51
47
static size_t const DEFAULT_READ_INTERVAL_MS = 1000 ; // 1 second
52
- static size_t const FAILSAFE_READ_INTERVAL_MS = 10000 ; // 10 seconds
48
+ static size_t const FAILSAFE_READ_INTERVAL_MS = 15000 ; // 15 seconds
53
49
54
50
/* *****************************************************************************
55
51
* LOCAL MODULE FUNCTIONS
@@ -76,10 +72,6 @@ ArduinoIoTCloudNotecard::ArduinoIoTCloudNotecard()
76
72
,_message_stream(std::bind(&ArduinoIoTCloudNotecard::sendMessage, this , std::placeholders::_1))
77
73
,_thing(&_message_stream)
78
74
,_device(&_message_stream)
79
- #ifdef BACKOFF
80
- ,_backoff_multiplier{1 }
81
- ,_last_failed_attach_request_ms{0 }
82
- #endif
83
75
,_notecard_last_read_ms{static_cast <uint32_t >(-DEFAULT_READ_INTERVAL_MS)}
84
76
,_notecard_read_interval_ms{DEFAULT_READ_INTERVAL_MS}
85
77
,_interrupt_pin{-1 }
@@ -120,7 +112,6 @@ int ArduinoIoTCloudNotecard::begin(ConnectionHandler &connection_, int interrupt
120
112
return 0 ; // (false -> failure)
121
113
}
122
114
123
- // TODO: Remove if not needed
124
115
// Pull the Arduino IoT Cloud Device ID from the Notecard
125
116
setDeviceId (notecard_connection->getDeviceId ());
126
117
@@ -153,7 +144,6 @@ void ArduinoIoTCloudNotecard::printDebugInfo()
153
144
NetworkConnectionState conn_state = _connection->check ();
154
145
DEBUG_INFO (" ***** Arduino IoT Cloud Notecard - configuration info *****" );
155
146
DEBUG_INFO (" Notecard UID: %s" , reinterpret_cast <NotecardConnectionHandler *>(_connection)->getNotecardUid ().c_str ());
156
- // TODO: Remove if not needed
157
147
DEBUG_INFO (" Arduino Device ID: %s" , getDeviceId ().c_str ());
158
148
if (NetworkConnectionState::CONNECTED == conn_state)
159
149
{
@@ -221,20 +211,6 @@ ArduinoIoTCloudNotecard::State ArduinoIoTCloudNotecard::handle_Connected()
221
211
/* Poll Notecard for new messages */
222
212
pollNotecard ();
223
213
224
- #ifdef BACKOFF
225
- /* Respect back-off */
226
- if (_last_failed_attach_request_ms) {
227
- const uint32_t backoff_ms = (BACKOFF_BASE_MS * _backoff_multiplier);
228
- if ((::millis () - _last_failed_attach_request_ms) < backoff_ms) {
229
- return State::Connected;
230
- } else {
231
- DEBUG_DEBUG (" ArduinoIoTCloudNotecard::%s back-off expired." , __FUNCTION__);
232
- _backoff_multiplier <<= (BACKOFF_MAX_MS > backoff_ms);
233
- _last_failed_attach_request_ms = 0 ;
234
- }
235
- }
236
- #endif
237
-
238
214
/* Call CloudDevice process to get configuration */
239
215
_device.update ();
240
216
@@ -401,23 +377,14 @@ void ArduinoIoTCloudNotecard::processCommand(const uint8_t *buf, size_t len)
401
377
String new_thing_id = String (command.thingUpdateCmd .params .thing_id );
402
378
403
379
if (!new_thing_id.length ()) {
404
- #ifdef BACKOFF
405
- _last_failed_attach_request_ms = ::millis ();
406
- DEBUG_DEBUG (" ArduinoIoTCloudNotecard::%s received null Thing ID (current back-off: %u minute%s)." , __FUNCTION__, _backoff_multiplier, ((_backoff_multiplier == 1 ) ? " " : " s" ));
407
- #endif
380
+ DEBUG_DEBUG (" ArduinoIoTCloudNotecard::%s received null Thing ID." , __FUNCTION__);
408
381
_thing_id = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ;
409
382
410
383
/* Send message to device state machine to inform we have received a null thing-id */
411
384
Message message;
412
385
message = { DeviceRegisteredCmdId };
413
386
_device.handleMessage (&message);
414
387
} else {
415
- #ifdef BACKOFF
416
- DEBUG_VERBOSE (" ArduinoIoTCloudNotecard::%s resetting back-off variables" , __FUNCTION__);
417
- /* Reset back-off variables */
418
- _backoff_multiplier = 1 ;
419
- _last_failed_attach_request_ms = 0 ;
420
- #endif
421
388
if (_device.isAttached () && _thing_id != new_thing_id) {
422
389
DEBUG_DEBUG (" ArduinoIoTCloudNotecard::%s detaching Thing ID: %s" , __FUNCTION__, _thing_id.c_str ());
423
390
detachThing ();
0 commit comments