Ich versuche, einen Webserver zugreifen, nachdem ich IP-Adressen auf meinem ESP8266 Arduino Skizze geändert habe, aber es reagiert nicht (aber ein Ping ist).
Die Skizze beginnt im WIFI_AP-Modus (für Gerätetests). Wenn jedoch nach einem asynchronen WiFi-Scan ein Netzwerk erkannt wird, trennt der Rückrufcode das WLAN und erstellt dann eine Verbindung im WIFI_AP_STA-Modus (als sekundärer Netzwerkzugriffspunkt)).Esp8266 Webserver Neustart nach IP geändert
ESP8266WebServer webServer(80);
void myWifiScanCompleted(int networksFound) {
IPAddress ip(192,168,1,2); // fixed IP address of this access point
IPAddress gateway(192,168,1,254);
IPAddress subnet(255,255,255,0);
int count;
int quality;
networkConnection = NET_CONNECT_NONE; // initialise as not found
for(count = 0; count < networksFound; count++) {
quality = getRSSIasQuality(WiFi.RSSI(count));
if(strcmp(WiFi.SSID(count).c_str(), ap_ssid) == 0) {
debug_print("found network %s (%d\%)", ap_ssid, quality);
networkConnection = NET_CONNECT_FOUND;
break;
} else {
debug_print("ignoring network %s (%d\%)", WiFi.SSID(count).c_str(), quality);
}
}
if(networkConnection == NET_CONNECT_FOUND) { // found network = try to connect
// reset any existing connection
webServer.stop();
WiFi.disconnect();
delay(100);
WiFi.mode(WIFI_AP_STA); // need both modes to join the network to get IP address, and then create access point
WiFi.begin(ap_ssid, ap_password);
count = 0;
while (WiFi.status() != WL_CONNECTED) {
toggle_led(); // Blink the LED
if(++count > (15 * 10)) {
debug_print("error connecting to network %s", ap_ssid);
networkConnection = NET_CONNECT_NONE;
break; // failed to connect
}
delay(100);
}
if(networkConnection != NET_CONNECT_NONE) {
networkConnection = NET_CONNECT_CONNECTED; // we've successfully connected to the network, now set up the access point
ip = WiFi.localIP();
gateway = (uint32_t)0;
kev_softAPConfig(ip, gateway, subnet, false); // no DHCP server
if(! kev_softAP(ap_ssid, ap_password, MY_WIFI_CHANNEL, MY_WIFI_HIDDEN, MY_WIFI_MAX_CONNECTIONS)) {
debug_print("create %s softAP failed - performing network reset", ap_ssid);
WiFi.disconnect();
networkConnection = NET_CONNECT_NONE;
} else {
// access point started = restart server
webServer.begin(); // start web server on the new IP address
debug_print("create %s softAP OK", ap_ssid);
}
}
}
}
Die Funktionen kev_softAPConfig() und kev_softAP() sind Versionen der API modifiziert, dass der DHCP-Dienst nicht starten (die bereits im Netzwerk vorhanden ist). Ich habe bewiesen, dass diese Funktionen funktionieren, ich habe gerade die Reihenfolge der Dinge geändert, damit ich Geräte testen kann.
Hat jemand das erreicht, oder bin ich ein Pionier? :-)