Skip to content

Commit

Permalink
Merge pull request #3791 from dhalbert/radio-set-enabled
Browse files Browse the repository at this point in the history
allow radio.enabled to be settable
  • Loading branch information
tannewt committed Dec 4, 2020
2 parents fb90f51 + 2f0e676 commit a7ec4a0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions shared-bindings/wifi/Radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,28 @@
//|

//| 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));
}
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 },
};

Expand Down

0 comments on commit a7ec4a0

Please sign in to comment.