peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
575 stars 126 forks source link

Added config option to set dhcp_hostname #24

Open msinn opened 4 years ago

msinn commented 4 years ago

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.

msinn commented 4 years ago

I wil implement the changes/extension you propose. I'll look into it probably on the weekend.

peterhinch commented 4 years ago

As a matter of interest does setting the hostname have any effect in station mode? I can't see any difference here, but perhaps that's my router/dhcp server being uninformative.

I look forward to your updated PR in due course.

kevinkk525 commented 4 years ago

Setting the hostname in station mode works well. Your router might need a while to recognize the new hostname. I use this feature often lately so the hostname matches ubinascii.hexlify(machine.unique_id()).