Added config option to set dhcp_hostname#24
Conversation
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.
There was a problem hiding this comment.
Bear in mind that arguments to config are platform-specific. For example the Pyboard D does not support the dhcp_hostname config arg - this code will throw an exception on this platform.
I think the solution should be generalised. I suggest that the config dict should have an optional config_args entry which is a dict of arguments for config. Thus in your case the dict would have
'config_args' : {'dhcp_hostname':'my_hostname'},and the MQTT_base constructor would have
if 'config_args' in config:
self._sta_if.config(**config_args)This allows for future platform-specific arguments. Please could you try and test something along those lines and re-submit the PR. If you don't want to do this please let me know and I will implement it.
|
I wil implement the changes/extension you propose. I'll look into it probably on the weekend. |
|
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. |
|
Setting the hostname in station mode works well. Your router might need a while to recognize the new 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.