Commit 52df2f88 authored by Chris Popp's avatar Chris Popp Committed by Paul Sokolovsky

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
......@@ -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);
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:
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
req_if = SOFTAP_IF;
val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel);
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:
goto unknown;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment