Hi,
I have been trying to get both Ethernet and ESP32/WiFi to work on Mbed-OS 6. When system boots, it will try to connect to internet through Ethernet, if that doesn’t work, then it will try to connect via WiFi/ESP32. Such scheme has been working on Mbed-OS-5 just fine, and a simple test code also works fine on Mbed-OS-6. The problem is such scheme no longer works in our production code when migrated to Mbed-OS-6 from 5.
If I unplug the ethernet cable when system boots, after about 60 seconds, connecting through ethernet will timeout, then system will try to connect via ESP32. At this point in our production code, a -3010 error code will be thrown. This seems to be caused by failure to setup DHCP on ESP32:
int ESP32Interface::connect()
{
if (_ap_ssid[0] == 0) {
return NSAPI_ERROR_NO_SSID;
}
if (!_esp->dhcp(_dhcp, 1)) {
return NSAPI_ERROR_DHCP_FAILURE;
}
if (!_dhcp) {
if (!_esp->set_network(_ip_address.get_ip_address(), _netmask.get_ip_address(), _gateway.get_ip_address())) {
return NSAPI_ERROR_DEVICE_ERROR;
}
}
set_connection_status(NSAPI_STATUS_CONNECTING);
if (!_esp->connect(_ap_ssid, _ap_pass)) {
set_connection_status(NSAPI_STATUS_DISCONNECTED);
return NSAPI_ERROR_NO_CONNECTION;
}
return NSAPI_ERROR_OK;
}
Occasionally system can go pass this step, but it will then throw a -3012 error code:
NSAPI_ERROR_DEVICE_ERROR = -3012, /*!< failure interfacing with the network processor */
If I turn on debug mode when instantiate ESP32 like this:
ESP32Interface wifi(WIFI_RADIO_EN, WIFI_RADIO_BOOT, WIFI_RADIO_TX, WIFI_RADIO_RX, true, /*WIFI_RADIO_RTS*/ NC, /*WIFI_RADIO_CTS*/ NC, 115200);
I usually can only see two character: AT
in console, then system hangs.
This seems to point to failure of UART communication between MCU and ESP32.
Can somebody offer some pointers how to go from here?
Thanks,
ZL