5050//|
5151STATIC mp_obj_t wifi_radio_get_enabled (mp_obj_t self ) {
5252 return mp_obj_new_bool (common_hal_wifi_radio_get_enabled (self ));
53-
5453}
5554MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_get_enabled_obj , wifi_radio_get_enabled );
5655
@@ -102,11 +101,16 @@ STATIC mp_obj_t wifi_radio_stop_scanning_networks(mp_obj_t self_in) {
102101}
103102STATIC MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_stop_scanning_networks_obj , wifi_radio_stop_scanning_networks );
104103
105- //| def set_hostname(self, hostname: ReadableBuffer) -> None:
106- //| """Sets hostname for wifi interface. When the hostname is altered after interface started/connected
107- //| the changes would only be reflected once the interface restarts/reconnects."""
108- //| ...
104+ //| hostname: ReadableBuffer
105+ //| """Hostname for wifi interface. When the hostname is altered after interface started/connected
106+ //| the changes would only be reflected once the interface restarts/reconnects."""
109107//|
108+ STATIC mp_obj_t wifi_radio_get_hostname (mp_obj_t self_in ) {
109+ wifi_radio_obj_t * self = MP_OBJ_TO_PTR (self_in );
110+ return common_hal_wifi_radio_get_hostname (self );
111+ }
112+ MP_DEFINE_CONST_FUN_OBJ_1 (wifi_radio_get_hostname_obj , wifi_radio_get_hostname );
113+
110114STATIC mp_obj_t wifi_radio_set_hostname (mp_obj_t self_in , mp_obj_t hostname_in ) {
111115 mp_buffer_info_t hostname ;
112116 mp_get_buffer_raise (hostname_in , & hostname , MP_BUFFER_READ );
@@ -122,6 +126,13 @@ STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in)
122126}
123127MP_DEFINE_CONST_FUN_OBJ_2 (wifi_radio_set_hostname_obj , wifi_radio_set_hostname );
124128
129+ const mp_obj_property_t wifi_radio_hostname_obj = {
130+ .base .type = & mp_type_property ,
131+ .proxy = {(mp_obj_t )& wifi_radio_get_hostname_obj ,
132+ (mp_obj_t )& wifi_radio_set_hostname_obj ,
133+ (mp_obj_t )& mp_const_none_obj },
134+ };
135+
125136//| def connect(self, ssid: ReadableBuffer, password: ReadableBuffer = b"", *, channel: Optional[int] = 0, timeout: Optional[float] = None) -> bool:
126137//| """Connects to the given ssid and waits for an ip address. Reconnections are handled
127138//| automatically once one connection succeeds."""
@@ -236,7 +247,7 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
236247 { MP_ROM_QSTR (MP_QSTR_start_scanning_networks ), MP_ROM_PTR (& wifi_radio_start_scanning_networks_obj ) },
237248 { MP_ROM_QSTR (MP_QSTR_stop_scanning_networks ), MP_ROM_PTR (& wifi_radio_stop_scanning_networks_obj ) },
238249
239- { MP_ROM_QSTR (MP_QSTR_set_hostname ), MP_ROM_PTR (& wifi_radio_set_hostname_obj ) },
250+ { MP_ROM_QSTR (MP_QSTR_hostname ), MP_ROM_PTR (& wifi_radio_hostname_obj ) },
240251
241252 { MP_ROM_QSTR (MP_QSTR_connect ), MP_ROM_PTR (& wifi_radio_connect_obj ) },
242253 // { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
0 commit comments