From 57fa6bece8fb841de10aaa6e96ced59749e6c566 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 3 Dec 2020 21:27:35 -0500 Subject: [PATCH 1/2] allow radio.enabled to be settable --- shared-bindings/wifi/Radio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 991abd4f12b6..d9d7dd5b53c5 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -55,10 +55,19 @@ STATIC mp_obj_t wifi_radio_get_enabled(mp_obj_t self) { } MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_enabled_obj, wifi_radio_get_enabled); +static mp_obj_t wifi_radio_set_enabled(mp_obj_t self, mp_obj_t value) { + const bool enabled = mp_obj_is_true(value); + + common_hal_wifi_radio_set_enabled(self, enabled); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_enabled_obj, wifi_radio_set_enabled); + const mp_obj_property_t wifi_radio_enabled_obj = { .base.type = &mp_type_property, .proxy = { (mp_obj_t)&wifi_radio_get_enabled_obj, - (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&wifi_radio_set_enabled_obj, (mp_obj_t)&mp_const_none_obj }, }; From 2f0e676fcba318bbfcd39e6c50e75d6aeb739ac6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 3 Dec 2020 22:05:02 -0500 Subject: [PATCH 2/2] update doc per review --- shared-bindings/wifi/Radio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index d9d7dd5b53c5..edbd9fd2ffd3 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -48,7 +48,9 @@ //| //| enabled: bool -//| """True when the wifi radio is enabled.""" +//| """``True`` when the wifi radio is enabled. +//| If you set the value to ``False``, any open sockets will be closed. +//| """ //| STATIC mp_obj_t wifi_radio_get_enabled(mp_obj_t self) { return mp_obj_new_bool(common_hal_wifi_radio_get_enabled(self));