1. check enabled before scan; 2. make start-station() the single control point for esp_wifi_set_mode()
This commit is contained in:
parent
672d0e27a3
commit
1f6cd496c7
@ -564,10 +564,6 @@ msgstr ""
|
|||||||
msgid "Can only alarm on two low pins from deep sleep."
|
msgid "Can only alarm on two low pins from deep sleep."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ports/esp32s2/common-hal/wifi/Radio.c
|
|
||||||
msgid "Can't connect when wifi is not enabled"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: ports/nrf/common-hal/_bleio/Characteristic.c
|
#: ports/nrf/common-hal/_bleio/Characteristic.c
|
||||||
msgid "Can't set CCCD on local Characteristic"
|
msgid "Can't set CCCD on local Characteristic"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -3910,6 +3906,10 @@ msgstr ""
|
|||||||
msgid "width must be greater than zero"
|
msgid "width must be greater than zero"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: ports/esp32s2/common-hal/wifi/Radio.c
|
||||||
|
msgid "wifi is not enabled"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: shared-bindings/_bleio/Adapter.c
|
#: shared-bindings/_bleio/Adapter.c
|
||||||
msgid "window must be <= interval"
|
msgid "window must be <= interval"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -72,7 +72,7 @@ void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) {
|
|||||||
}
|
}
|
||||||
if (!self->started && enabled) {
|
if (!self->started && enabled) {
|
||||||
// esp_wifi_start() would default to soft-AP, thus setting it to station
|
// esp_wifi_start() would default to soft-AP, thus setting it to station
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
start_station(self);
|
||||||
ESP_ERROR_CHECK(esp_wifi_start());
|
ESP_ERROR_CHECK(esp_wifi_start());
|
||||||
self->started = true;
|
self->started = true;
|
||||||
return;
|
return;
|
||||||
@ -89,7 +89,9 @@ mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) {
|
|||||||
if (self->current_scan != NULL) {
|
if (self->current_scan != NULL) {
|
||||||
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));
|
mp_raise_RuntimeError(translate("Already scanning for wifi networks"));
|
||||||
}
|
}
|
||||||
// check enabled
|
if (!common_hal_wifi_radio_get_enabled(self)) {
|
||||||
|
mp_raise_RuntimeError(translate("wifi is not enabled"));
|
||||||
|
}
|
||||||
start_station(self);
|
start_station(self);
|
||||||
|
|
||||||
wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t);
|
wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t);
|
||||||
@ -127,7 +129,7 @@ void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *host
|
|||||||
|
|
||||||
wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t* bssid, size_t bssid_len) {
|
wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t* bssid, size_t bssid_len) {
|
||||||
if (!common_hal_wifi_radio_get_enabled(self)) {
|
if (!common_hal_wifi_radio_get_enabled(self)) {
|
||||||
mp_raise_RuntimeError(translate("Can't connect when wifi is not enabled"));
|
mp_raise_RuntimeError(translate("wifi is not enabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
EventBits_t bits;
|
EventBits_t bits;
|
||||||
|
Loading…
Reference in New Issue
Block a user