-->
Page 5 of 5

Re: How do you REALLY change the host name?

PostPosted: Mon Dec 12, 2016 4:21 am
by tonus@gmx.us
@JimDrew

In this order like this:
WiFi.hostname("BeMyGuest");
WiFi.begin(ssid, pass);


Only cast something if you know what you are doing!
Compiler warnings are there to WARN you, but you are the boss....

String routername = "Testing123"; // routername is of type String
// you intended: char *ourname=routername.c_str();
char* ourname = &routername[0]; // ourname points to the first element of the ARRAY routername???
wifi_station_set_hostname(ourname); /sets hostname to somewhat in the bitbucket

You intended this:
WiFi.hostname("Testing123"); // best to do after intstantiating and before anything else
WiFi.begin(ssid, pass); // here the WiFi starts talking to your router and may give its name "Testing123" to the router

Re: How do you REALLY change the host name?

PostPosted: Sat Mar 11, 2017 8:30 am
by anitech_pro
befor WiFi.begin(), write WiFi.hostname("Name");
It worked for me. :D

Re: How do you REALLY change the host name?

PostPosted: Sun Apr 21, 2019 8:24 am
by daleschultz
using wifi_station_set_hostname() does not work for me either.

NodeMCU still uses its default hostname.