raspberrypi: statically allocate storage for hostname
This commit is contained in:
parent
84c7ac4a81
commit
0912889106
@ -92,10 +92,10 @@ mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
|
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
|
||||||
self->hostname = mp_obj_new_str(hostname, strlen(hostname));
|
assert(strlen(hostname) < MP_ARRAY_SIZE(self->hostname));
|
||||||
hostname = mp_obj_str_get_str(self->hostname);
|
memcpy(self->hostname, hostname, strlen(hostname));
|
||||||
netif_set_hostname(NETIF_STA, hostname);
|
netif_set_hostname(NETIF_STA, self->hostname);
|
||||||
netif_set_hostname(NETIF_AP, hostname);
|
netif_set_hostname(NETIF_AP, self->hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
|
mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
mp_obj_t hostname;
|
char hostname[254]; // hostname max is 253 chars, + 1 for trailing NUL
|
||||||
wifi_scannednetworks_obj_t *current_scan;
|
wifi_scannednetworks_obj_t *current_scan;
|
||||||
} wifi_radio_obj_t;
|
} wifi_radio_obj_t;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user