Report
1 year, 11 months ago.

mbed 5 network sockets return code -3012.

The page for network sockets https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/communication/network_sockets/ says that you can get error return codes from -3001 to -3011 but I keep getting -3012. The only other code I can get is -3001. My program is fairly standard, I'm just trying to setup up a to connection between a board and my laptop using an esp8266. It generally works, but I'm just trying to improve it's stability (i.e. getting it to reconnect if there is a problem). However when I do something like close the socket on my computer, or turn off the WiFi network, i get exactly the same code: -3012. Is it because esp8266 has bad error handling or something? I've kind of just accepted that all i can get is -3001 and for all other errors it returns -3012, but I can't actually find anything on the internet to support this. I won't post all my code as there is several hundred lines, but the important thing is that is works, and then if turn off the WiFi it returns -3012, whereas i think it should return -3004.

Thanks.

Comment on this question

1 Answer

1 year, 11 months ago.

It looks like those return codes have been updated, and the doc needs to be updated to reflect these changes - https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/nsapi_types.h#L37.

It looks like a DEVICE_ERROR can be returned if the device fails to start, or if the firmware for the board is incompatible with the driver - https://github.com/ARMmbed/esp8266-driver/blob/master/ESP8266Interface.cpp#L61-L70.

When you construct the ESP8266Interface, can you try to turn debugging on? https://github.com/ARMmbed/esp8266-driver/blob/master/ESP8266Interface.cpp#L31 It is the third parameter in the constructor. You should be able to see more about what is going on at the time of failure.


To post an answer, please log in.