Skip to content

Commit 6210805

Browse files
committed
Fix ESP8266 "Link Type" errors after reset
As part of the ESP8266 connect sequence, ESP8266Interface::connect, a software reset is performed. If the ESP8266 had been connected previously then the ESP8266 will sometimes send a "WIFI DISCONNECT" OOB message before performing the software reset. This causes the ESP8266::_oob_connection_status to change its state (_conn_status) from NSAPI_STATUS_DISCONNECTED to NSAPI_STATUS_CONNECTING. This causes ESP8266Interface::_startup, called later in the boot seqeunce, to skip ESP8266::startup. Without this call socket mux mode (CIPMUX=1) is never enabled and all send commands using this format fail with a "Link Type" error. This patch fixes that problem by unconditionally calling ESP8266::startup as part of the ESP8266 connect sequence.
1 parent 463a453 commit 6210805

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

components/wifi/esp8266-driver/ESP8266Interface.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ int ESP8266Interface::connect()
190190
return NSAPI_ERROR_IS_CONNECTED;
191191
}
192192

193-
status = _startup(ESP8266::WIFIMODE_STATION);
194-
if (status != NSAPI_ERROR_OK) {
195-
return status;
196-
}
197-
198193
if (!_esp.dhcp(true, 1)) {
199194
return NSAPI_ERROR_DHCP_FAILURE;
200195
}
@@ -315,11 +310,6 @@ int ESP8266Interface::scan(WiFiAccessPoint *res, unsigned count)
315310
return status;
316311
}
317312

318-
status = _startup(ESP8266::WIFIMODE_STATION);
319-
if (status != NSAPI_ERROR_OK) {
320-
return status;
321-
}
322-
323313
return _esp.scan(res, count);
324314
}
325315

@@ -370,6 +360,9 @@ nsapi_error_t ESP8266Interface::_init(void)
370360
if (!_esp.cond_enable_tcp_passive_mode()) {
371361
return NSAPI_ERROR_DEVICE_ERROR;
372362
}
363+
if (!_esp.startup(ESP8266::WIFIMODE_STATION)) {
364+
return NSAPI_ERROR_DEVICE_ERROR;
365+
}
373366

374367
_initialized = true;
375368
}
@@ -385,16 +378,6 @@ void ESP8266Interface::_hw_reset()
385378
_rst_pin.rst_deassert();
386379
}
387380

388-
nsapi_error_t ESP8266Interface::_startup(const int8_t wifi_mode)
389-
{
390-
if (_conn_stat == NSAPI_STATUS_DISCONNECTED) {
391-
if (!_esp.startup(wifi_mode)) {
392-
return NSAPI_ERROR_DEVICE_ERROR;
393-
}
394-
}
395-
return NSAPI_ERROR_OK;
396-
}
397-
398381
struct esp8266_socket {
399382
int id;
400383
nsapi_protocol_t proto;

components/wifi/esp8266-driver/ESP8266Interface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface {
353353
bool _get_firmware_ok();
354354
nsapi_error_t _init(void);
355355
void _hw_reset();
356-
nsapi_error_t _startup(const int8_t wifi_mode);
357356

358357
//sigio
359358
struct {

0 commit comments

Comments
 (0)