summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266
diff options
context:
space:
mode:
authorChris Popp <christopherpopp@yahoo.com>2016-10-30 16:57:49 +0000
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-11-09 00:33:13 +0300
commit52df2f889e3315a4ced5a81e80efbb138182cd1b (patch)
treee3e6e9bedd49b5df7f60a9295d17a3fa8cd96e5b /esp8266
parent2bf96612d2c7e3139bf404bb246a0ce08ab26813 (diff)
downloadmicropython-52df2f889e3315a4ced5a81e80efbb138182cd1b.tar.gz
micropython-52df2f889e3315a4ced5a81e80efbb138182cd1b.zip
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.
Diffstat (limited to 'esp8266')
-rw-r--r--esp8266/modnetwork.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/esp8266/modnetwork.c b/esp8266/modnetwork.c
index a48edcfa2d..1d8a02bc9b 100644
--- a/esp8266/modnetwork.c
+++ b/esp8266/modnetwork.c
@@ -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;
}