@@ -52,10 +52,13 @@ int ArduinoIoTCloudLPWAN::connected()
5252 return state;
5353}
5454
55- int ArduinoIoTCloudLPWAN::begin (LPWANConnectionHandler& connection)
55+ int ArduinoIoTCloudLPWAN::begin (LPWANConnectionHandler& connection, bool retry )
5656{
5757 _connection = &connection;
5858 _connection->init ();
59+ _retryEnable = retry;
60+ _maxNumRetry = 5 ;
61+ _intervalRetry = 1000 ;
5962 Thing.begin ();
6063 return 1 ;
6164}
@@ -166,18 +169,37 @@ void ArduinoIoTCloudLPWAN::printDebugInfo() {
166169
167170
168171int ArduinoIoTCloudLPWAN::writeProperties (const byte data[], int length) {
169- _connection->write (data, length);
170-
172+ int retcode = _connection->write (data, length);
173+ int i = 0 ;
174+ while (_retryEnable && retcode < 0 && i < _maxNumRetry) {
175+ delay (_intervalRetry);
176+ retcode = _connection->write (data, length);
177+ i++;
178+ }
179+
171180 return 1 ;
172181}
173182
174183int ArduinoIoTCloudLPWAN::writeStdout (const byte data[], int length) {
175- _connection->write (data, length);
184+ int retcode = _connection->write (data, length);
185+ int i = 0 ;
186+ while (_retryEnable && retcode < 0 && i < _maxNumRetry) {
187+ delay (_intervalRetry);
188+ retcode = _connection->write (data, length);
189+ i++;
190+ }
191+
176192 return 1 ;
177193}
178194
179195int ArduinoIoTCloudLPWAN::writeShadowOut (const byte data[], int length) {
180- _connection->write (data, length);
196+ int retcode = _connection->write (data, length);
197+ int i = 0 ;
198+ while (_retryEnable && retcode < 0 && i < _maxNumRetry) {
199+ delay (_intervalRetry);
200+ retcode = _connection->write (data, length);
201+ i++;
202+ }
181203 return 1 ;
182204}
183205
0 commit comments