-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Hostname changes only after hard reset #5662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Will probably be fixed by #5652 |
@felixgeissler please test pr #5652 and report back here. |
Gonna try that shortly. |
@devyte Couldn't figure out what to do -.- |
If you are using git and command line, you can
After testing,
|
#5652 is merged, you just need to update git master. Feedback is welcome |
2.5.0-beta3 is released and it contains this change. Please retest. |
No feedback in a long while. We just released 2.6.0 now. |
I'm struggling with the same issue with |
@tschaban Did you try calling |
sure
Soft reset is made with ESP.restart(); |
Why do you need to later call The two are similar However if you see the above debug message, there should be something we could try. What's the purpose of this snippet: (is it
|
@d-a-v I've debugged WiFi.hostname() manually to see where it returns false and it returns false once wifi_station_set_hostname() is called within WiFi.hostname(). to your last question. you're right - there is != |
Testing on git master with sketch: #include <ESP8266WiFi.h>
#include <PolledTimeout.h>
#include <coredecls.h>
#ifndef STASSID
#define STASSID "your-ssid"
#define STAPSK "your-password"
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
using esp8266::polledTimeout::oneShotMs;
oneShotMs changeHostName(oneShotMs::neverExpires);
void time_is_set()
{
timeval tv;
gettimeofday(&tv, nullptr);
srandom(tv.tv_usec);
changeHostName.reset(1000);
Serial.printf("time is set\n");
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.print("connecting to ");
Serial.println(ssid);
settimeofday_cb(time_is_set);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
void loop() {
if (changeHostName)
{
String name = "abc";
name += random(100);
bool ok = WiFi.hostname(name.c_str());
Serial.printf("hostname('%s')=%d\n", name.c_str(), ok);
changeHostName.reset(random(10000));
}
} Execution:
On linux console: (trying to type fast)
Notice that at 22:41:09, Closing as working and issue can't be reproduced. |
Faced a strange behavior of
WiFi.hostname()
yesterday. Seems that my hostname only get's set after a hard reset.I did setup a WiFo connection with:
After that I try to connect to the network credentials read from EEPROM. If the connection fails I switch the mode to AP with
WiFi.mode(WIFI_AP);
and starting a captive portal to get new credentials from the user. My ESP then resets and connects to the new network. Unfortunately even though the ESP connects now in STA mode, it won't apply the hostname.Only when I hard reset the device and the ESP connects again to the network the hostname is used.
Any ideas, what have gone wrong?
Full code:
The text was updated successfully, but these errors were encountered: