@@ -156,18 +156,14 @@ void CC1352P7CommDevice::run()
156156 }
157157
158158 // If a modem reset is pending, handle it
159- if (_stateBooleans & RESET_PENDING) {
159+ if (_stateBooleans & RESET_PENDING && _bytesToWrite == 0 ) {
160160 _serial.flushReceiveBuffers ();
161161 _bytesToRead = 0 ;
162162 _bytesToReceive = 0 ;
163- _bytesToWrite = 0 ;
164163 _sendState = sendCipclose;
165164 _replyState = okReply;
166165 _waitForReply = NULL ;
167166 _stateBooleans &= ~RESET_PENDING;
168- if (_connectState >= intermediate) {
169- connect ();
170- }
171167 }
172168
173169 // Buffer data from the modem
@@ -180,8 +176,7 @@ void CC1352P7CommDevice::run()
180176 logStates (_sendState, _replyState);
181177
182178 // Handle error states
183- if (strncmp (_lineBuffer, " ERROR" , 5 ) == 0
184- || (_sendState >= connected && strncmp (_lineBuffer, " SEND FAIL" , 9 ) == 0 )) {
179+ if (strncmp (_lineBuffer, " ERROR" , 5 ) == 0 ) {
185180 _stateBooleans |= RESET_PENDING;
186181 _connectState = generalError;
187182 _waitForReply = NULL ;
@@ -230,7 +225,8 @@ void CC1352P7CommDevice::run()
230225 if (strncmp (_lineBuffer, " +IPD," , 4 ) == 0 ) {
231226 _bytesToReceive = strtol (_lineBuffer + 5 , NULL , 10 );
232227 _stateBooleans |= DATA_PENDING;
233- } else if (strncmp (_lineBuffer, " CLOSED" , 6 ) == 0 ) {
228+ } else if (strncmp (_lineBuffer, " CLOSED" , 6 ) == 0 ||
229+ strncmp (_lineBuffer, " SEND FAIL" , 9 ) == 0 ) {
234230 _stateBooleans &= ~IP_CONNECTED;
235231 }
236232 }
@@ -274,6 +270,8 @@ void CC1352P7CommDevice::run()
274270 break ;
275271
276272 case connecting:
273+ if (handleDisconnect (notConnected))
274+ break ;
277275 _connectState = IPCommDevice::intermediate;
278276 _stateBooleans |= LINE_READ;
279277 _waitForReply = _okStr;
0 commit comments