ESP32: dhcp_hostname is read-only on non-WLAN interfaces
Hi there!
On a network.WLAN interface, I can set .config(dhcp_hostname='galactica'). However, on a LAN interface, I cannot:
>>> import network
>>> l = network.LAN()
>>> l.config('dhcp_hostname')
'espressif'
>>> l.config(dhcp_hostname='galactica')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unknown config param
I was trying to do this on an Olimex ESP32-POE board, i.e. phy_type=network.PHY_LAN8720, but as far as I understand, the exact interface doesn’t matter since this config option will simply be passed to the ESP32’s DHCP client.
Would be cool if I could set a hostname also for a wired board! Thanks in advance for looking into this.
[ESP32] DHCP Hostname not working correctly
I can't put my finger on which version this stopped working or if it's just my code that's the issue.
def ConnectNetwork(NetworkName, Password):
import network
wlan = network.WLAN()
wlan.active(True)
wlan.config(dhcp_hostname="testname")
wlan.ifconfig(('192.168.0.210', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
if not wlan.isconnected():
print('connecting to network...')
wlan.connect(NetworkName, Password)
print('Network Config:', wlan.ifconfig())
print('DHCP Hostname:', wlan.config('dhcp_hostname'))
ConnectNetwork("SSID", "Password")
When the device is connected to my router it is showing as UNKNOWN name. I am unable to ping the device using its name. Sometimes the name does show up on the router but disappears quickly after.
I have tested this in another home with a different board (same model) and a different router/network. Same things seem to happen.
This is part of some larger code, but pulled this snippet out for testing this issue. I have attempted to use different MicroPython versions below...
- esp32-bluetooth.bin (latest)
- esp32-20190504-v1.10-323-g906fb89fd.bin
- esp32-20180511-v1.9.4.bin
I have also tried removing this line but the same issue happens.
wlan.ifconfig(('192.168.0.210', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
Thanks in advance!