@@ -139,32 +139,34 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) {
139
139
// This is a workaround as ESP32 WiFi libs don't currently
140
140
// auto-reassociate.
141
141
system_event_sta_disconnected_t * disconn = & event -> event_info .disconnected ;
142
- ESP_LOGI ( "wifi" , "STA_DISCONNECTED, reason:%d" , disconn -> reason ) ;
142
+ char * message = "" ;
143
143
switch (disconn -> reason ) {
144
144
case WIFI_REASON_BEACON_TIMEOUT :
145
- mp_printf (MP_PYTHON_PRINTER , "beacon timeout\n" );
146
145
// AP has dropped out; try to reconnect.
146
+ message = "\nbeacon timeout" ;
147
147
break ;
148
148
case WIFI_REASON_NO_AP_FOUND :
149
- mp_printf (MP_PYTHON_PRINTER , "no AP found\n" );
150
149
// AP may not exist, or it may have momentarily dropped out; try to reconnect.
150
+ message = "\nno AP found" ;
151
151
break ;
152
152
case WIFI_REASON_AUTH_FAIL :
153
- mp_printf ( MP_PYTHON_PRINTER , "authentication failed\n" ) ;
153
+ message = "\nauthentication failed" ;
154
154
wifi_sta_connected = false;
155
155
break ;
156
156
default :
157
157
// Let other errors through and try to reconnect.
158
158
break ;
159
159
}
160
+ ESP_LOGI ("wifi" , "STA_DISCONNECTED, reason:%d%s" , disconn -> reason , message );
161
+
160
162
if (wifi_sta_connected ) {
161
163
wifi_mode_t mode ;
162
164
if (esp_wifi_get_mode (& mode ) == ESP_OK ) {
163
165
if (mode & WIFI_MODE_STA ) {
164
166
// STA is active so attempt to reconnect.
165
167
esp_err_t e = esp_wifi_connect ();
166
168
if (e != ESP_OK ) {
167
- mp_printf ( MP_PYTHON_PRINTER , "error attempting to reconnect: 0x%04x" , e );
169
+ ESP_LOGI ( "wifi" , "error attempting to reconnect: 0x%04x" , e );
168
170
}
169
171
}
170
172
}
0 commit comments