You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Switching from AP to STA and directly connecting to STA is not working if the router is in WPA-PSK/WEP?
Dots everywhere.
Basic explanation of the code:
The ESP8266 check if there is a known connection <--if auth is passed immediately at the beginning it still keeps showing dots
If there isn't, starts an AP mode and open a UDP sockect
It waits for SSID and PW to be populated
After population it tries to connect to the given network <-- auth is correct but it keeps showing dots
A wifi scan from the module and a compare with SSID retrieved from UDP returns true, hence the SSID is correctly found. I'm trying both with WEP and WPA-PSK
Settings in IDE
Module: NodeMCU ESP8266 Module
CPU Frequency: 80Mhz
Sketch
#include<ESP8266WiFi.h>
#include<WiFiUdp.h>
WiFiUDP UDPTestServer;
unsignedint UDPPort = 1337;
byte packetBuffer[256];
String SSID = "";
String PW = "";
String TOKEN = "asdasd";
bool sent = false;
bool initStatus = true;
voidsetup() {
Serial.begin(115200);
delay(1000);
Serial.printf("\nTry connecting to WiFi with SSID '%s'\n", WiFi.SSID().c_str());
WiFi.mode(WIFI_STA);
WiFi.begin(WiFi.SSID().c_str(), WiFi.psk().c_str()); // reading data from EPROM, last saved credentials/* Sometimes it doesn't connect and it keeps . . . . . . . . . . . . indefinitely if (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }*/if (WiFi.status() == WL_CONNECTED) {
Serial.printf("Connected successfully to SSID '%s'\n", WiFi.SSID().c_str());
} else {
WifiAuthAndTokenExchange();
}
UDPTestServer.begin(UDPPort);
}
boolWifiAuthAndTokenExchange() {
Serial.printf("\nCannot connect, starting AP mode\n");
WiFi.disconnect();
WiFi.mode(WIFI_AP);
boolean result = WiFi.softAP("Test", "Test");
UDPTestServer.begin(UDPPort);
Serial.printf("UDP Server started\n");
//wait for UDP to populate SSID and PWwhile (SSID.length() <= 0 || PW.length() <= 0 || TOKEN.length() <= 0) {
// Serial.printf("Waiting for Auth..\n");handleUDPServer();
// Serial.printf("SSID '%s', PW '%s', TOKEN '%s'", SSID.c_str(), PW.c_str(), TOKEN.c_str());delay(10);
}
Serial.printf("Auth received\n");
UDPTestServer.stop();
Serial.printf("UDP Server stopped\n");
WiFi.mode(WIFI_STA);
WiFi.begin(SSID.c_str(), PW.c_str());
Serial.printf("Try connecting to WiFi with SSID '%s'\n", SSID.c_str());
WiFi.printDiag(Serial);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
voidloop() {
if (WiFi.status() != WL_CONNECTED) {
//reset micro
}
handleUDPServer();
if (!sent && !initStatus) {
sendNotificationToDevice();
Serial.println("Sent");
sent = true;
}
}
voidsendNotificationToDevice() {
//....
}
The text was updated successfully, but these errors were encountered:
This issue is old. A lot has changed since it was reported, including fixes that are relevant.
Closing.
If you think the problem still exists, please open a new issue and follow the issue template instructions.
Basic Infos
Hardware
Hardware: Amica NodeMCU ESP8266
Description
Switching from AP to STA and directly connecting to STA is not working if the router is in WPA-PSK/WEP?
Dots everywhere.
Basic explanation of the code:
A wifi scan from the module and a compare with SSID retrieved from UDP returns true, hence the SSID is correctly found. I'm trying both with WEP and WPA-PSK
Settings in IDE
Module: NodeMCU ESP8266 Module
CPU Frequency: 80Mhz
Sketch
The text was updated successfully, but these errors were encountered: