Skip to content

Commit 4a9f865

Browse files
author
Veijo Pesonen
committed
[ESP8266] Fixes AT-layer socket_open-functions
When a socket open fails it musn't be treated as fatal error. Returning a device error which is then handled by an application is the correct solution
1 parent c27dabe commit 4a9f865

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ nsapi_error_t ESP8266::open_udp(int id, const char *addr, int port, int local_po
472472
_sock_already = false; // To be raised again by OOB msg
473473
done = close(id);
474474
if (!done) {
475-
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CLOSE_FAILED), \
476-
"ESP8266::_open_udp: device refused to close socket");
475+
break;
477476
}
478477
}
479478
if (_error) {
@@ -491,9 +490,7 @@ nsapi_error_t ESP8266::open_udp(int id, const char *addr, int port, int local_po
491490

492491
_smutex.unlock();
493492

494-
if (done) {
495-
tr_debug("UDP socket %d opened", id);
496-
}
493+
tr_debug("UDP socket %d opened: %s", id, (_sock_i[id].open ? "true" : "false"));
497494

498495
return done ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
499496
}
@@ -526,8 +523,7 @@ nsapi_error_t ESP8266::open_tcp(int id, const char *addr, int port, int keepaliv
526523
_sock_already = false; // To be raised again by OOB msg
527524
done = close(id);
528525
if (!done) {
529-
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CLOSE_FAILED), \
530-
"ESP8266::_open_tcp: device refused to close socket");
526+
break;
531527
}
532528
}
533529
if (_error) {
@@ -545,9 +541,7 @@ nsapi_error_t ESP8266::open_tcp(int id, const char *addr, int port, int keepaliv
545541

546542
_smutex.unlock();
547543

548-
if (done) {
549-
tr_debug("TCP socket %d opened", id);
550-
}
544+
tr_debug("TCP socket %d opened: %s", id, (_sock_i[id].open ? "true" : "false"));
551545

552546
return done ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
553547
}

0 commit comments

Comments
 (0)