kopia lustrzana https://github.com/micropython/micropython
espnow: ESP8266: Add auto_connect & reconnects option to WLAN.config().
Adds: - WLAN.config(auto_connect=False) to stop the ESP8266 from automatically connecting to wifi networks after bootup. - WLAN.config(reconnects=X) to limit the number of times to attempt to reconnect after becoming disconnected from a wifi access point.pull/9460/head
rodzic
1093dea709
commit
02a6882056
|
@ -423,6 +423,20 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
|
|||
wifi_set_sleep_type(mp_obj_get_int(kwargs->table[i].value));
|
||||
break;
|
||||
}
|
||||
case MP_QSTR_auto_connect: {
|
||||
wifi_station_set_auto_connect(mp_obj_is_true(kwargs->table[i].value));
|
||||
break;
|
||||
}
|
||||
case MP_QSTR_reconnects: {
|
||||
req_if = STATION_IF;
|
||||
if (self->if_id == STATION_IF) {
|
||||
int reconnects = mp_obj_get_int(kwargs->table[i].value);
|
||||
// parameter reconnects == -1 means to retry forever.
|
||||
wifi_station_set_reconnect_policy((reconnects != 0));
|
||||
wifi_station_dhcpc_set_maxtry((reconnects == -1) ? 255 : reconnects);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
goto unknown;
|
||||
}
|
||||
|
@ -494,6 +508,10 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
|
|||
val = MP_OBJ_NEW_SMALL_INT(wifi_get_sleep_type());
|
||||
break;
|
||||
}
|
||||
case MP_QSTR_auto_connect: {
|
||||
val = mp_obj_new_bool(wifi_station_get_auto_connect());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
goto unknown;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue