@@ -53,7 +53,7 @@ ESP32::ESP32(PinName en, PinName io0, PinName tx, PinName rx, bool debug,
53
53
: _p_wifi_en(NULL ), _p_wifi_io0(NULL ), _init_end_common(false ), _init_end_wifi(false )
54
54
, _serial(tx, rx, ESP32_DEFAULT_BAUD_RATE), _parser(&_serial, " \r\n " )
55
55
, _packets(0 ), _packets_end(&_packets)
56
- , _id_bits(0 ), _id_bits_close( 0 ), _server_act(false )
56
+ , _id_bits(0 ), _server_act(false )
57
57
, _wifi_status(STATUS_DISCONNECTED)
58
58
, _wifi_status_cb(NULL ), _at_version(0 )
59
59
#if defined(TARGET_ESP32AT_BLE)
@@ -316,7 +316,6 @@ void ESP32::socket_handler(bool connect, int id)
316
316
}
317
317
} else {
318
318
_id_bits &= ~(1 << id);
319
- _id_bits_close |= (1 << id);
320
319
if (_server_act) {
321
320
for (size_t i = 0 ; i < _accept_id.size (); i++) {
322
321
if (id == _accept_id[i]) {
@@ -356,15 +355,6 @@ bool ESP32::accept(int * p_id)
356
355
}
357
356
}
358
357
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
-
368
358
return ret;
369
359
}
370
360
@@ -744,8 +734,7 @@ bool ESP32::send(int id, const void *data, uint32_t amount)
744
734
// May take a second try if device is busy
745
735
while (error_cnt < 2 ) {
746
736
_smutex.lock ();
747
- if (((_id_bits & (1 << id)) == 0 )
748
- || ((_id_bits_close & (1 << id)) != 0 )) {
737
+ if ((_id_bits & (1 << id)) == 0 ) {
749
738
_smutex.unlock ();
750
739
return false ;
751
740
}
@@ -857,7 +846,7 @@ int32_t ESP32::recv(int id, void *data, uint32_t amount, uint32_t timeout)
857
846
858
847
if (idx > 0 ) {
859
848
return idx;
860
- } else if ((( _id_bits & (1 << id)) == 0 ) || ((_id_bits_close & ( 1 << id)) != 0 ) ) {
849
+ } else if ((_id_bits & (1 << id)) == 0 ) {
861
850
return 0 ;
862
851
} else {
863
852
_cbs[id].Notified = 0 ;
@@ -891,9 +880,7 @@ bool ESP32::close(int id, bool wait_close)
891
880
if (wait_close) {
892
881
_smutex.lock ();
893
882
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 ) {
897
884
_ids[id] = false ;
898
885
_clear_socket_packets (id);
899
886
_smutex.unlock ();
@@ -911,7 +898,6 @@ bool ESP32::close(int id, bool wait_close)
911
898
for (unsigned i = 0 ; i < 2 ; i++) {
912
899
_smutex.lock ();
913
900
if ((_id_bits & (1 << id)) == 0 ) {
914
- _id_bits_close &= ~(1 << id);
915
901
_ids[id] = false ;
916
902
_clear_socket_packets (id);
917
903
_smutex.unlock ();
@@ -923,7 +909,6 @@ bool ESP32::close(int id, bool wait_close)
923
909
&& _parser.recv (" OK" )) {
924
910
setTimeout ();
925
911
_clear_socket_packets (id);
926
- _id_bits_close &= ~(1 << id);
927
912
_ids[id] = false ;
928
913
_smutex.unlock ();
929
914
return true ;
0 commit comments