From c3ce9f5d45c6eef653ae570c17f796419ccc1175 Mon Sep 17 00:00:00 2001 From: msinn Date: Sun, 13 Oct 2019 20:52:40 +0200 Subject: [PATCH] Added config option to set dhcp_hostname As a standard the WLAN object in network registers ESP32 micro-controller with the hostname 'espressif' when getting an ip adress from the dhcp server. This commit adds the attribute 'hostname' to the config dict. When 'hostname' is configured, it is handed as 'dchp_hostname' to the sta_if configuration. This way, each ESP32 microcontroller can set it's individual dns entry. --- mqtt_as/mqtt_as.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mqtt_as/mqtt_as.py b/mqtt_as/mqtt_as.py index 849c3fd..6a2b6e6 100644 --- a/mqtt_as/mqtt_as.py +++ b/mqtt_as/mqtt_as.py @@ -44,6 +44,7 @@ async def eliza(*_): # e.g. via set_wifi_handler(coro): see test program config = { 'client_id' : hexlify(unique_id()), + 'hostname' : None, 'server' : None, 'port' : 0, 'user' : '', @@ -132,6 +133,8 @@ def __init__(self, config): self._sock = None self._sta_if = network.WLAN(network.STA_IF) self._sta_if.active(True) + if self.hostname: + self._sta_if.config(dhcp_hostname=self.hostname) self.pid = 0 self.rcv_pid = 0