Skip to content

Commit 52df2f8

Browse files
cpopppfalcon
authored andcommitted
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.
1 parent 2bf9661 commit 52df2f8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

esp8266/modnetwork.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
342342
cfg.ap.channel = mp_obj_get_int(kwargs->table[i].value);
343343
break;
344344
}
345+
case QS(MP_QSTR_dhcp_hostname): {
346+
req_if = STATION_IF;
347+
if (self->if_id == STATION_IF) {
348+
const char *s = mp_obj_str_get_str(kwargs->table[i].value);
349+
wifi_station_set_hostname((char*)s);
350+
}
351+
break;
352+
}
345353
default:
346354
goto unknown;
347355
}
@@ -395,6 +403,12 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
395403
req_if = SOFTAP_IF;
396404
val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel);
397405
break;
406+
case QS(MP_QSTR_dhcp_hostname): {
407+
req_if = STATION_IF;
408+
char* s = wifi_station_get_hostname();
409+
val = mp_obj_new_str(s, strlen(s), false);
410+
break;
411+
}
398412
default:
399413
goto unknown;
400414
}

0 commit comments

Comments
 (0)