From 31d45a3f3261eb7668c1b96d4bb5cf4e3000198c Mon Sep 17 00:00:00 2001 From: anecdata <16617689+anecdata@users.noreply.github.com> Date: Fri, 12 Nov 2021 16:27:13 -0600 Subject: [PATCH] fix old bug that was masking new bug --- locale/circuitpython.pot | 2 +- ports/espressif/common-hal/wifi/Radio.c | 4 ++-- ports/espressif/common-hal/wifi/__init__.c | 2 +- shared-bindings/wifi/Radio.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 33cd0d2ab9..45f8b9e3e8 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -683,7 +683,7 @@ msgid "Can't set CCCD on local Characteristic" msgstr "" #: ports/espressif/common-hal/wifi/Radio.c -msgid "Can't set MAC address while connected" +msgid "Station must be started" msgstr "" #: shared-bindings/storage/__init__.c shared-bindings/usb_cdc/__init__.c diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 119731bba0..d3feb261f7 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -121,8 +121,8 @@ mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) { } void common_hal_wifi_radio_set_mac_address(wifi_radio_obj_t *self, const uint8_t *mac) { - if (self->sta_mode) { - mp_raise_RuntimeError(translate("Can't set MAC address while connected")); + if (!self->sta_mode) { + mp_raise_RuntimeError(translate("Station must be started")); } if ((mac[0] & 0b1) == 0b1) { mp_raise_RuntimeError(translate("Invalid multicast MAC address")); diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index 469b379dee..cb9b028aba 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -152,7 +152,7 @@ void common_hal_wifi_init(void) { mp_raise_RuntimeError(translate("Failed to init wifi")); } // set station mode to avoid the default SoftAP - esp_wifi_set_mode(WIFI_MODE_STA); + common_hal_wifi_radio_start_station(self); // start wifi common_hal_wifi_radio_set_enabled(self, true); } diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index f5bbb4c210..332188539f 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -118,8 +118,8 @@ const mp_obj_property_t wifi_radio_hostname_obj = { }; //| mac_address: ReadableBuffer -//| """MAC address of the wifi radio station. -//| Can only be set while the Station is not started.""" +//| """MAC address for the station. When the address is altered after interface is connected +//| the changes would only be reflected once the interface reconnects.""" //| STATIC mp_obj_t wifi_radio_get_mac_address(mp_obj_t self_in) { wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in);