Merge pull request #3791 from dhalbert/radio-set-enabled
allow radio.enabled to be settable
This commit is contained in:
commit
a7ec4a0489
@ -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 },
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user