mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #9871 from VeijoPesonen/bugfix-esp8266-recv_busy
ESP8266: receive is able to handle device busy indicationpull/9899/head
commit
b5878b164d
|
|
@ -736,12 +736,14 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
|
||||||
// NOTE: documentation v3.0 says '+CIPRECVDATA:<data_len>,' but it's not how the FW responds...
|
// NOTE: documentation v3.0 says '+CIPRECVDATA:<data_len>,' but it's not how the FW responds...
|
||||||
bool done = _parser.send("AT+CIPRECVDATA=%d,%lu", id, amount)
|
bool done = _parser.send("AT+CIPRECVDATA=%d,%lu", id, amount)
|
||||||
&& _parser.recv("OK\n");
|
&& _parser.recv("OK\n");
|
||||||
if (!done) {
|
|
||||||
tr_debug("data request failed");
|
|
||||||
}
|
|
||||||
_sock_i[id].tcp_data = NULL;
|
_sock_i[id].tcp_data = NULL;
|
||||||
_sock_active_id = -1;
|
_sock_active_id = -1;
|
||||||
|
|
||||||
|
if (!done) {
|
||||||
|
goto BUSY;
|
||||||
|
}
|
||||||
|
|
||||||
// update internal variable tcp_data_avbl to reflect the remaining data
|
// update internal variable tcp_data_avbl to reflect the remaining data
|
||||||
if (_sock_i[id].tcp_data_rcvd > 0) {
|
if (_sock_i[id].tcp_data_rcvd > 0) {
|
||||||
if (_sock_i[id].tcp_data_rcvd > (int32_t)amount) {
|
if (_sock_i[id].tcp_data_rcvd > (int32_t)amount) {
|
||||||
|
|
@ -764,6 +766,18 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t
|
||||||
|
|
||||||
_smutex.unlock();
|
_smutex.unlock();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
BUSY:
|
||||||
|
_process_oob(ESP8266_RECV_TIMEOUT, true);
|
||||||
|
if (_busy) {
|
||||||
|
tr_debug("_recv_tcp_passive(): modem busy");
|
||||||
|
ret = NSAPI_ERROR_WOULD_BLOCK;
|
||||||
|
} else {
|
||||||
|
tr_error("_recv_tcp_passive(): unknown state");
|
||||||
|
ret = NSAPI_ERROR_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
_smutex.unlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ESP8266::recv_tcp(int id, void *data, uint32_t amount, uint32_t timeout)
|
int32_t ESP8266::recv_tcp(int id, void *data, uint32_t amount, uint32_t timeout)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue