@@ -59,6 +59,7 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
59
59
_parser.oob (" WIFI " , callback (this , &ESP8266::_oob_connection_status));
60
60
_parser.oob (" UNLINK" , callback (this , &ESP8266::_oob_socket_close_err));
61
61
_parser.oob (" ALREADY CONNECTED" , callback (this , &ESP8266::_oob_conn_already));
62
+ _parser.oob (" ERROR" , callback (this , &ESP8266::_oob_err));
62
63
63
64
for (int i= 0 ; i < SOCKET_COUNT; i++) {
64
65
_sock_i[i].open = false ;
@@ -418,6 +419,10 @@ nsapi_error_t ESP8266::open_udp(int id, const char* addr, int port, int local_po
418
419
" ESP8266::_open_udp: device refused to close socket" );
419
420
}
420
421
}
422
+ if (_error) {
423
+ _error = false ;
424
+ done = false ;
425
+ }
421
426
continue ;
422
427
}
423
428
_sock_i[id].open = true ;
@@ -460,6 +465,10 @@ nsapi_error_t ESP8266::open_tcp(int id, const char* addr, int port, int keepaliv
460
465
" ESP8266::_open_tcp: device refused to close socket" );
461
466
}
462
467
}
468
+ if (_error) {
469
+ _error = false ;
470
+ done = false ;
471
+ }
463
472
continue ;
464
473
}
465
474
_sock_i[id].open = true ;
@@ -491,14 +500,19 @@ nsapi_error_t ESP8266::send(int id, const void *data, uint32_t amount)
491
500
set_timeout (ESP8266_SEND_TIMEOUT);
492
501
if (_parser.send (" AT+CIPSEND=%d,%lu" , id, amount)
493
502
&& _parser.recv (" >" )
494
- && _parser.write ((char *)data, (int )amount) >= 0 ) {
503
+ && _parser.write ((char *)data, (int )amount) >= 0
504
+ && _parser.recv (" SEND OK" )) {
495
505
// No flow control, data overrun is possible
496
506
if (_serial_rts == NC) {
497
507
while (_parser.process_oob ()); // Drain USART receive register
498
508
}
499
509
_smutex.unlock ();
500
510
return NSAPI_ERROR_OK;
501
511
}
512
+ if (_error) {
513
+ _error = false ;
514
+ }
515
+
502
516
set_timeout ();
503
517
_smutex.unlock ();
504
518
}
@@ -824,12 +838,18 @@ void ESP8266::_oob_conn_already()
824
838
_parser.abort ();
825
839
}
826
840
841
+ void ESP8266::_oob_err ()
842
+ {
843
+ _error = true ;
844
+ _parser.abort ();
845
+ }
846
+
827
847
void ESP8266::_oob_socket_close_err ()
828
848
{
829
- if (_parser.recv (" ERROR\n " )) {
830
- _closed = true ; // Not possible to pinpoint to a certain socket
831
- _parser.abort ();
849
+ if (_error) {
850
+ _error = false ;
832
851
}
852
+ _closed = true ; // Not possible to pinpoint to a certain socket
833
853
}
834
854
835
855
void ESP8266::_oob_socket0_closed ()
0 commit comments