You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use ESP8266 as WiFi station with MBed. It works mostly fine but upon careful inspection, I noticed that ESP8266 will lose connection frequently. If we run constant connection like WebSocket from MBed to a server, we can see from server side that those WebSocket connections usually last 10 minutes, sometimes longer, about 20 ~ 30 minutes. If we repeatedly make HTTP requests via ESP8266, sometimes we see following error:
// MBed's way saying it thinks ESP8266 has lost connection
NSAPI_ERROR_CONNECTION_LOST = -3016, /*!< connection lost */
In the Arduino version, some state that disabling sleep mode can fix the problem. esp8266/Arduino#5083
But disabling sleep mode in MBed doesn't seem to help:
nsapi_error_t ESP8266::connect(const char *ap, const char *passPhrase)
{
nsapi_error_t ret = NSAPI_ERROR_OK;
_smutex.lock();
set_timeout(ESP8266_CONNECT_TIMEOUT);
bool res = _parser.send("AT+CWJAP_CUR=\"%s\",\"%s\"", ap, passPhrase);
if (!res || !_parser.recv("OK\n")) {
if (_fail) {
if (_connect_error == 1) {
ret = NSAPI_ERROR_CONNECTION_TIMEOUT;
} else if (_connect_error == 2) {
ret = NSAPI_ERROR_AUTH_FAILURE;
} else if (_connect_error == 3) {
ret = NSAPI_ERROR_NO_SSID;
} else {
ret = NSAPI_ERROR_NO_CONNECTION;
}
_fail = false;
_connect_error = 0;
}
}
// Added lines to ensure sleep mode is turned off upon connect()
res = _parser.send("AT+SLEEP=0");
if (!res || !_parser.recv("OK\n")) {
printf("%d: ESP8266 set sleep mode failed\r\n", time(nullptr));
} else {
printf("%d: ESP8266 sleep mode set to 0\r\n", time(nullptr));
}
set_timeout();
_smutex.unlock();
return ret;
}
Disabling sleep mode will increase system power consumption by 30mA, but ESP8266 still keeps losing connection.
Can anybody offer some pointers on how to customize firmware to fix the problem? We tried stock firmware 1.7.4 and 1.7.3, problem exists in both version.
Thanks.
The text was updated successfully, but these errors were encountered:
Hi,
We use ESP8266 as WiFi station with MBed. It works mostly fine but upon careful inspection, I noticed that ESP8266 will lose connection frequently. If we run constant connection like WebSocket from MBed to a server, we can see from server side that those WebSocket connections usually last 10 minutes, sometimes longer, about 20 ~ 30 minutes. If we repeatedly make HTTP requests via ESP8266, sometimes we see following error:
In the Arduino version, some state that disabling sleep mode can fix the problem.
esp8266/Arduino#5083
But disabling sleep mode in MBed doesn't seem to help:
Disabling sleep mode will increase system power consumption by 30mA, but ESP8266 still keeps losing connection.
Can anybody offer some pointers on how to customize firmware to fix the problem? We tried stock firmware 1.7.4 and 1.7.3, problem exists in both version.
Thanks.
The text was updated successfully, but these errors were encountered: