From 1ea82b6dcc7dd5f0ad051db414ff91d8f04d20e0 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Tue, 28 Jun 2022 16:38:45 +0300 Subject: [PATCH] esp32,esp8266: Rename WLAN dhcp_hostname config to hostname. But retain old name for backwards compatibility. --- docs/library/network.WLAN.rst | 2 +- ports/esp32/network_wlan.c | 2 ++ ports/esp8266/modnetwork.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/library/network.WLAN.rst b/docs/library/network.WLAN.rst index bc416d1c2e..c673194700 100644 --- a/docs/library/network.WLAN.rst +++ b/docs/library/network.WLAN.rst @@ -130,7 +130,7 @@ Methods hidden Whether SSID is hidden (boolean) security Security protocol supported (enumeration, see module constants) key Access key (string) - dhcp_hostname The DHCP hostname to use + hostname The hostname that will be sent to DHCP (STA interfaces) and mDNS (if supported, both STA and AP) reconnects Number of reconnect attempts to make (integer, 0=none, -1=unlimited) txpower Maximum transmit power in dBm (integer or float) ============= =========== diff --git a/ports/esp32/network_wlan.c b/ports/esp32/network_wlan.c index 48b398c8f0..9b2200e4ff 100644 --- a/ports/esp32/network_wlan.c +++ b/ports/esp32/network_wlan.c @@ -452,6 +452,7 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_ cfg.ap.channel = mp_obj_get_int(kwargs->table[i].value); break; } + case MP_QSTR_hostname: case MP_QSTR_dhcp_hostname: { const char *s = mp_obj_str_get_str(kwargs->table[i].value); esp_exceptions(tcpip_adapter_set_hostname(self->if_id, s)); @@ -538,6 +539,7 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_ req_if = WIFI_IF_AP; val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel); break; + case MP_QSTR_hostname: case MP_QSTR_dhcp_hostname: { const char *s; esp_exceptions(tcpip_adapter_get_hostname(self->if_id, &s)); diff --git a/ports/esp8266/modnetwork.c b/ports/esp8266/modnetwork.c index e32a0ff0c9..dbc12f74d4 100644 --- a/ports/esp8266/modnetwork.c +++ b/ports/esp8266/modnetwork.c @@ -397,6 +397,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs cfg.ap.channel = mp_obj_get_int(kwargs->table[i].value); break; } + case MP_QSTR_hostname: case MP_QSTR_dhcp_hostname: { req_if = STATION_IF; if (self->if_id == STATION_IF) { @@ -461,6 +462,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs req_if = SOFTAP_IF; val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel); break; + case MP_QSTR_hostname: case MP_QSTR_dhcp_hostname: { req_if = STATION_IF; char *s = wifi_station_get_hostname();