@@ -61,8 +61,8 @@ ESP8266::ESP8266(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
61
61
_parser.oob (" ALREADY CONNECTED" , callback (this , &ESP8266::_oob_cipstart_already_connected));
62
62
63
63
for (int i= 0 ; i < SOCKET_COUNT; i++) {
64
- _socket_open [i].id = - 1 ;
65
- _socket_open [i].proto = NSAPI_UDP;
64
+ _sinfo [i].open = false ;
65
+ _sinfo [i].proto = NSAPI_UDP;
66
66
}
67
67
}
68
68
@@ -398,7 +398,7 @@ nsapi_error_t ESP8266::open_udp(int id, const char* addr, int port, int local_po
398
398
static const char *type = " UDP" ;
399
399
bool done = false ;
400
400
401
- if (id >= SOCKET_COUNT || _socket_open [id].id == id ) {
401
+ if (id >= SOCKET_COUNT || _sinfo [id].open ) {
402
402
return NSAPI_ERROR_PARAMETER;
403
403
}
404
404
@@ -423,8 +423,8 @@ nsapi_error_t ESP8266::open_udp(int id, const char* addr, int port, int local_po
423
423
}
424
424
continue ;
425
425
}
426
- _socket_open [id].id = id ;
427
- _socket_open [id].proto = NSAPI_UDP;
426
+ _sinfo [id].open = true ;
427
+ _sinfo [id].proto = NSAPI_UDP;
428
428
break ;
429
429
}
430
430
}
@@ -440,7 +440,7 @@ nsapi_error_t ESP8266::open_tcp(int id, const char* addr, int port, int keepaliv
440
440
static const char *type = " TCP" ;
441
441
bool done = false ;
442
442
443
- if (id >= SOCKET_COUNT || _socket_open [id].id == id ) {
443
+ if (id >= SOCKET_COUNT || _sinfo [id].open ) {
444
444
return NSAPI_ERROR_PARAMETER;
445
445
}
446
446
@@ -465,8 +465,8 @@ nsapi_error_t ESP8266::open_tcp(int id, const char* addr, int port, int keepaliv
465
465
}
466
466
continue ;
467
467
}
468
- _socket_open [id].id = id ;
469
- _socket_open [id].proto = NSAPI_TCP;
468
+ _sinfo [id].open = true ;
469
+ _sinfo [id].proto = NSAPI_TCP;
470
470
break ;
471
471
}
472
472
}
@@ -521,8 +521,8 @@ void ESP8266::_packet_handler()
521
521
}
522
522
// In passive mode amount not used...
523
523
if (_tcp_passive
524
- && _socket_open [id].id == id
525
- && _socket_open [id].proto == NSAPI_TCP) {
524
+ && _sinfo [id].open == true
525
+ && _sinfo [id].proto == NSAPI_TCP) {
526
526
if (!_parser.recv (" %d\n " , &amount)) {
527
527
MBED_ERROR (MBED_MAKE_ERROR (MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENODATA), \
528
528
" ESP8266::_packet_handler(): Data length missing" );
@@ -592,7 +592,7 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
592
592
}
593
593
594
594
// Socket closed, doesn't mean there couldn't be data left
595
- if (_socket_open [id].id != id ) {
595
+ if (!_sinfo [id].open ) {
596
596
done = _parser.send (" AT+CIPRECVDATA=%d,%lu" , id, amount)
597
597
&& _parser.recv (" +CIPRECVDATA,%ld:" , &len)
598
598
&& _parser.read ((char *)data, len)
@@ -649,7 +649,7 @@ int32_t ESP8266::recv_tcp(int id, void *data, uint32_t amount, uint32_t timeout)
649
649
}
650
650
}
651
651
}
652
- if (_socket_open [id].id < 0 ) {
652
+ if (!_sinfo [id].open ) {
653
653
_smutex.unlock ();
654
654
return 0 ;
655
655
}
@@ -738,7 +738,7 @@ bool ESP8266::close(int id)
738
738
if (!_parser.recv (" OK\n " )) {
739
739
if (_closed) { // UNLINK ERROR
740
740
_closed = false ;
741
- _socket_open [id].id = - 1 ;
741
+ _sinfo [id].open = false ;
742
742
_clear_socket_packets (id);
743
743
_smutex.unlock ();
744
744
// ESP8266 has a habit that it might close a socket on its own.
@@ -829,27 +829,27 @@ void ESP8266::_oob_socket_close_error()
829
829
830
830
void ESP8266::_oob_socket0_closed_handler ()
831
831
{
832
- _socket_open [0 ].id = - 1 ;
832
+ _sinfo [0 ].open = false ;
833
833
}
834
834
835
835
void ESP8266::_oob_socket1_closed_handler ()
836
836
{
837
- _socket_open [1 ].id = - 1 ;
837
+ _sinfo [1 ].open = false ;
838
838
}
839
839
840
840
void ESP8266::_oob_socket2_closed_handler ()
841
841
{
842
- _socket_open [2 ].id = - 1 ;
842
+ _sinfo [2 ].open = false ;
843
843
}
844
844
845
845
void ESP8266::_oob_socket3_closed_handler ()
846
846
{
847
- _socket_open [3 ].id = - 1 ;
847
+ _sinfo [3 ].open = false ;
848
848
}
849
849
850
850
void ESP8266::_oob_socket4_closed_handler ()
851
851
{
852
- _socket_open [4 ].id = - 1 ;
852
+ _sinfo [4 ].open = false ;
853
853
}
854
854
855
855
void ESP8266::_connection_status_handler ()
0 commit comments