Find reasons of inexplicable wifi disconnects?

We encounter numerous inexplicable Wifi disconnects/reconnects concentrated on a minority of all our running devices.
Is there a possibility to ask Mongoose OS for the reason of the just occurred disconnect?

EDIT: assume you’re talking about ESP devices

I forget where I found the list of disconnect ID’s, but I think it was Espressif. You’d need to be able to see logs to check the disconnect code/reason.

I made a couple notes a while back when trying to diagnose a few issues, hope they help.

Reason Code Note
WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT 15 Seems to give this reason when password is wrong on ESP32
WIFI_REASON_NO_AP_FOUND 201 Gives this error when WiFi network is turned off
WIFI_REASON_AUTH_FAIL 202 Some errors with the WiFi network when tring to connect. Eventually connects

Actually, you have to ask the underlying vendor infrastructure, and AFAIK the only one to date is ESP IDF