Change hostname.

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
markxr
Posts: 62
Joined: Wed Jun 01, 2016 3:41 pm

Re: Change hostname.

Post by markxr » Thu Sep 08, 2016 5:35 pm

The obvious thing to do is to add a new keyword argument to sta.config(... ) - it already has keyword arguments for other parameters.

The function is esp_config in modnetwork.c. It's just a matter of adding a new case: in the argument checking and calling that function wifi_station_set_hostname. Seems easy enough.

User avatar
mogul
Posts: 1
Joined: Sun Apr 16, 2017 8:56 pm

Re: Change hostname.

Post by mogul » Sun Apr 16, 2017 9:04 pm

A year later I came across the same problem, and now it is straight forward to change hostname.

wlan.config(dhcp_hostname="foo-bar-baz")

MCHobby
Posts: 10
Joined: Mon Jan 26, 2015 2:05 pm

Re: Change hostname.

Post by MCHobby » Mon Sep 18, 2017 8:33 pm

Hi,
I'm using ESP8266 under MicroPython.
I had use the default ESP8266 hostname from WebRepl and find this really convenient when using the network DHCP. I'm using the modem-router from the Internet Provider.
Using "ws://ESP_xxxx:8266" with WebRepl is really a dream.

However, from time to time this Hostname purely disappears from the network :-(
What the hell to find the new IP for WebRepl(ing).

I have seen in this thread https://www.tapatalk.com/topic/182447-m ... n-hostname explaining that ESP8266 reboot would not republish the hostname to the DHCP server (from the last SSID/Password stored in the ESP)
So I tried to connect a wrong network then back to the right network to resend the ESP hostname with DHCP register.
Unfortunately it doesn't work as expected.

I did identify the

Code: Select all

wlan.config(dhcp_hostname="foo-bar-baz")
now available in MicroPython sysname='esp8266' release='2.0.0(5a875ba)', version='v1.9.1-8-g7213e78d on 2017-06-12' but cannot get it to push the hostname to the DHCP/DNS server.

Is there an appropriate sequence of instruction to follows ?
Is this depending on my own computer resolve names? (using Linux Mint/Ubuntu/Debian, he resolve properly the name of the other computer on the network).

Any suggestion would be welcome. I'm puzzled.

Post Reply