So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By rimula-x
#95911 I want to write a program to change hostname or IP address by getting value from http request or API
For example, http://<ip>/?hostname=abc123
Then device will change its hostname to abc123 and display abc123 in serial.
My problem is I code like this ....
---------------
if( server.hasArg("hostname") ){
String newHostname = server.arg("hostname").c_str();
WiFi.hostname(newHostname.c_str());
server.send(200, "text/plain", "Hostname changed to: " + String(WiFi.hostname()));
---------------
The result is .... the new hostname value can show on web page, but the real hostname still not changed.
( I can't ping it.)

I have no idea what going on or How to fix it.
BTW, I can create web server and receive fixed values such as on/off.