-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Static IP not honored in STA mode unless WiFi.config called AFTER WiFi.begin #1138
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
if tested it with this and its working: /*
* test_wifi_config.cpp
*
* Created on: 05.12.2015
*/
#include <ESP8266WiFi.h>
void setup() {
Serial1.begin(921600);
//Serial.setDebugOutput(true);
Serial1.setDebugOutput(true);
Serial1.println();
Serial1.println();
Serial1.println();
Serial1.println("WiFi delete all config...");
// delete all existing WiFi stuff in EEPROM
WiFi.disconnect();
WiFi.softAPdisconnect();
WiFi.mode(WIFI_OFF);
delay(500);
Serial1.println("WiFi set new config...");
// connect static
WiFi.mode(WIFI_STA);
WiFi.config(IPAddress(192,168,1,2),IPAddress(192,168,1,1),IPAddress(255,255,255,0),IPAddress(192,168,1,1));
WiFi.begin("wifi", "passpasspass");
Serial1.println("Connecting ...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial1.print(".");
}
Serial1.println("");
Serial1.println("WiFi connected");
Serial1.println("IP address: ");
Serial1.println(WiFi.localIP());
}
void loop() {
} WiFi connected
IP address:
192.168.1.2 can you post, a simple example to getting the bug? Note: my WiFi network has a other IP range. |
Thanks for checking this. Let me get back to you with a smaller code set and after I try 2.0 (may take a while) |
@drmpf have you found the reason? |
Sorry other bugs of my own making have been keeping me occupied. |
Test procedure
Flash ESP8266
start as AP for web page config do not set staticIP
power cycle
connect to AP using DHCP -> get 10.1.1.7 assigned
power cycle
start as AP for web page config and set static IP 10.1.1.201 saved in EEPROM
power cycle
connect to AP calling WiFi.config(...) then WiFi.begin
print IP -> 10.1.1.7
however if
connect to AP calling WiFi.begin and THEN WiFi.config(...)
print IP -> 10.1.1.201
see http://www.forward.com.au/pfod/CheapWifiShield/ESP2866_01_WiFi_Shield/index.html for sample sketch
Tested on version 1.6.5-947-g39819f0
The text was updated successfully, but these errors were encountered: