Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266: receive is able to handle device busy indication #9871

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions components/wifi/esp8266-driver/ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
bool done = _parser.send("AT+CIPRECVDATA=%d,%lu", id, amount)
&& _parser.recv("OK\n");
if (!done) {
tr_debug("data request failed");
}

_sock_i[id].tcp_data = NULL;
_sock_active_id = -1;

if (!done) {
goto BUSY;
}

// 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 > (int32_t)amount) {
Expand All @@ -764,6 +766,18 @@ int32_t ESP8266::_recv_tcp_passive(int id, void *data, uint32_t amount, uint32_t

_smutex.unlock();
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)
Expand Down