Skip to content
Snippets Groups Projects
Commit 52df2f88 authored by Chris Popp's avatar Chris Popp Committed by Paul Sokolovsky
Browse files

esp8266/modnetwork.c: Expose configuration for station DHCP hostname.

The ESP SDK supports configuring the hostname that is
reported when doing a DHCP request in station mode.  This commit
exposes that under network.WLAN(network.STA_IF).config('dhcp_hostname')
as a read/write value similar to other parameters.
parent 2bf96612
No related branches found
No related tags found
No related merge requests found
...@@ -342,6 +342,14 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs ...@@ -342,6 +342,14 @@ 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); cfg.ap.channel = mp_obj_get_int(kwargs->table[i].value);
break; break;
} }
case QS(MP_QSTR_dhcp_hostname): {
req_if = STATION_IF;
if (self->if_id == STATION_IF) {
const char *s = mp_obj_str_get_str(kwargs->table[i].value);
wifi_station_set_hostname((char*)s);
}
break;
}
default: default:
goto unknown; goto unknown;
} }
...@@ -395,6 +403,12 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs ...@@ -395,6 +403,12 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
req_if = SOFTAP_IF; req_if = SOFTAP_IF;
val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel); val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel);
break; break;
case QS(MP_QSTR_dhcp_hostname): {
req_if = STATION_IF;
char* s = wifi_station_get_hostname();
val = mp_obj_new_str(s, strlen(s), false);
break;
}
default: default:
goto unknown; goto unknown;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment