@@ -53,7 +53,7 @@ ESP32::ESP32(PinName en, PinName io0, PinName tx, PinName rx, bool debug,
5353 : _p_wifi_en(NULL ), _p_wifi_io0(NULL ), _init_end_common(false ), _init_end_wifi(false )
5454 , _serial(tx, rx, ESP32_DEFAULT_BAUD_RATE), _parser(&_serial, " \r\n " )
5555 , _packets(0 ), _packets_end(&_packets)
56- , _id_bits(0 ), _id_bits_close( 0 ), _server_act(false )
56+ , _id_bits(0 ), _server_act(false )
5757 , _wifi_status(STATUS_DISCONNECTED)
5858 , _wifi_status_cb(NULL ), _at_version(0 )
5959#if defined(TARGET_ESP32AT_BLE)
@@ -316,7 +316,6 @@ void ESP32::socket_handler(bool connect, int id)
316316 }
317317 } else {
318318 _id_bits &= ~(1 << id);
319- _id_bits_close |= (1 << id);
320319 if (_server_act) {
321320 for (size_t i = 0 ; i < _accept_id.size (); i++) {
322321 if (id == _accept_id[i]) {
@@ -356,15 +355,6 @@ bool ESP32::accept(int * p_id)
356355 }
357356 }
358357
359- if (ret) {
360- for (int i = 0 ; i < 50 ; i++) {
361- if ((_id_bits_close & (1 << *p_id)) == 0 ) {
362- break ;
363- }
364- ThisThread::sleep_for (10 );
365- }
366- }
367-
368358 return ret;
369359}
370360
@@ -744,8 +734,7 @@ bool ESP32::send(int id, const void *data, uint32_t amount)
744734 // May take a second try if device is busy
745735 while (error_cnt < 2 ) {
746736 _smutex.lock ();
747- if (((_id_bits & (1 << id)) == 0 )
748- || ((_id_bits_close & (1 << id)) != 0 )) {
737+ if ((_id_bits & (1 << id)) == 0 ) {
749738 _smutex.unlock ();
750739 return false ;
751740 }
@@ -857,7 +846,7 @@ int32_t ESP32::recv(int id, void *data, uint32_t amount, uint32_t timeout)
857846
858847 if (idx > 0 ) {
859848 return idx;
860- } else if ((( _id_bits & (1 << id)) == 0 ) || ((_id_bits_close & ( 1 << id)) != 0 ) ) {
849+ } else if ((_id_bits & (1 << id)) == 0 ) {
861850 return 0 ;
862851 } else {
863852 _cbs[id].Notified = 0 ;
@@ -891,9 +880,7 @@ bool ESP32::close(int id, bool wait_close)
891880 if (wait_close) {
892881 _smutex.lock ();
893882 for (int j = 0 ; j < 2 ; j++) {
894- if (((_id_bits & (1 << id)) == 0 )
895- || ((_id_bits_close & (1 << id)) != 0 )) {
896- _id_bits_close &= ~(1 << id);
883+ if ((_id_bits & (1 << id)) == 0 ) {
897884 _ids[id] = false ;
898885 _clear_socket_packets (id);
899886 _smutex.unlock ();
@@ -911,7 +898,6 @@ bool ESP32::close(int id, bool wait_close)
911898 for (unsigned i = 0 ; i < 2 ; i++) {
912899 _smutex.lock ();
913900 if ((_id_bits & (1 << id)) == 0 ) {
914- _id_bits_close &= ~(1 << id);
915901 _ids[id] = false ;
916902 _clear_socket_packets (id);
917903 _smutex.unlock ();
@@ -923,7 +909,6 @@ bool ESP32::close(int id, bool wait_close)
923909 && _parser.recv (" OK" )) {
924910 setTimeout ();
925911 _clear_socket_packets (id);
926- _id_bits_close &= ~(1 << id);
927912 _ids[id] = false ;
928913 _smutex.unlock ();
929914 return true ;
0 commit comments