summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2020-10-14 11:11:59 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2020-10-14 11:11:59 +0530
commit18fbff4f57e0c0b25ecaa3e1064c71b7a09f320b (patch)
treea27ef32b644ea4d638e76ffadcd4e75c2b4dbad3 /shared-bindings
parentceb531086ed2e5d1e2ee1f1439820a5145fd981e (diff)
Update wifi hostname method
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/wifi/Radio.c23
-rw-r--r--shared-bindings/wifi/Radio.h1
2 files changed, 18 insertions, 6 deletions
diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c
index 9c774e141..481294463 100644
--- a/shared-bindings/wifi/Radio.c
+++ b/shared-bindings/wifi/Radio.c
@@ -50,7 +50,6 @@
//|
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);
@@ -102,11 +101,16 @@ STATIC mp_obj_t wifi_radio_stop_scanning_networks(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_scanning_networks_obj, wifi_radio_stop_scanning_networks);
-//| def set_hostname(self, hostname: ReadableBuffer) -> None:
-//| """Sets hostname for wifi interface. When the hostname is altered after interface started/connected
-//| the changes would only be reflected once the interface restarts/reconnects."""
-//| ...
+//| hostname: ReadableBuffer
+//| """Hostname for wifi interface. When the hostname is altered after interface started/connected
+//| the changes would only be reflected once the interface restarts/reconnects."""
//|
+STATIC mp_obj_t wifi_radio_get_hostname(mp_obj_t self_in) {
+ wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ return common_hal_wifi_radio_get_hostname(self);
+}
+MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_hostname_obj, wifi_radio_get_hostname);
+
STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) {
mp_buffer_info_t hostname;
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)
}
MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_hostname_obj, wifi_radio_set_hostname);
+const mp_obj_property_t wifi_radio_hostname_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&wifi_radio_get_hostname_obj,
+ (mp_obj_t)&wifi_radio_set_hostname_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
//| def connect(self, ssid: ReadableBuffer, password: ReadableBuffer = b"", *, channel: Optional[int] = 0, timeout: Optional[float] = None) -> bool:
//| """Connects to the given ssid and waits for an ip address. Reconnections are handled
//| automatically once one connection succeeds."""
@@ -236,7 +247,7 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_start_scanning_networks), MP_ROM_PTR(&wifi_radio_start_scanning_networks_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop_scanning_networks), MP_ROM_PTR(&wifi_radio_stop_scanning_networks_obj) },
- { MP_ROM_QSTR(MP_QSTR_set_hostname), MP_ROM_PTR(&wifi_radio_set_hostname_obj) },
+ { MP_ROM_QSTR(MP_QSTR_hostname), MP_ROM_PTR(&wifi_radio_hostname_obj) },
{ MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&wifi_radio_connect_obj) },
// { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
diff --git a/shared-bindings/wifi/Radio.h b/shared-bindings/wifi/Radio.h
index 4226ae2a9..a6a616154 100644
--- a/shared-bindings/wifi/Radio.h
+++ b/shared-bindings/wifi/Radio.h
@@ -45,6 +45,7 @@ typedef enum {
extern bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self);
extern void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled);
+extern mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self);
extern void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname);
extern mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self);