-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WifiMulti does not support Static IP #1202
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
Same problem here |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
This stale issue has been automatically closed. Thank you for your contributions. |
Is now any support for static IP? |
should be after
or after
|
rethink implementation overall
Example of working with WifiMulti and staticIP |
If gateway varies among different wifi APs then how can a device use static IP? I tested with 4 hotspot and two of them have same address |
I have the same issue. This issue should not have been closed. I had a simple-minded go at this, putting an on_SSID_selected(ssid) callback before WiFi.begin() in ESP8266WiFiMulti. The user can set the callback, and then invoke a suitable WiFi.config inside the callback. It seems to work. Here is the patch. In my scenario (IoT sensor), I look at both the SSID and the MAC to determine the IP. There is a lot of flexibility. |
I am using ESP32 Arduino websocket using WifiMulti. There is example using Static IP ((https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientStaticIP/WiFiClientStaticIP.ino) I copied below:
#include <WiFi.h>
const char* ssid = "your_network_name";
const char* password = "your_network_password";
const char* host = "example.com";
const char* url = "/index.html";
IPAddress local_IP(192, 168, 31, 115);
IPAddress gateway(192, 168, 31, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
void setup()
{
Serial.begin(115200);
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected!");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.print("ESP Mac Address: ");
Serial.println(WiFi.macAddress());
Serial.print("Subnet Mask: ");
Serial.println(WiFi.subnetMask());
Serial.print("Gateway IP: ");
Serial.println(WiFi.gatewayIP());
Serial.print("DNS: ");
Serial.println(WiFi.dnsIP());
}
/******************************/
My problem is with my project using WiFiMulti which is not supporting Static IP
WiFiMulti.addAP(SSID, pass);
Serial.print("Wait for WiFi... ");
while(WiFiMulti.run() != WL_CONNECTED) {
Serial.print(". ");
delay(500);
}
The text was updated successfully, but these errors were encountered: