Skip to content

Commit 71a0015

Browse files
committed
Add hostname setting
1 parent c6d3163 commit 71a0015

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ports/raspberrypi/common-hal/wifi/Radio.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) {
8181
}
8282

8383
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
84-
ro_attribute(MP_QSTR_hostname);
84+
self->hostname = mp_obj_new_str(hostname, strlen(hostname));
85+
hostname = mp_obj_str_get_str(self->hostname);
86+
netif_set_hostname(NETIF_STA, hostname);
87+
netif_set_hostname(NETIF_AP, hostname);
8588
}
8689

8790
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {

ports/raspberrypi/common-hal/wifi/Radio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
typedef struct {
3535
mp_obj_base_t base;
36+
mp_obj_t hostname;
3637
wifi_scannednetworks_obj_t *current_scan;
3738
} wifi_radio_obj_t;
3839

0 commit comments

Comments
 (0)