-
Notifications
You must be signed in to change notification settings - Fork 13.3k
SoftAP interface is not accessible when STA connection is not established #1661
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
I am having the same issue :( . Please update if you have found a workaround. |
I ran into this problem when using the SDK directly (no Arduino) - what I found was that if the STA interface was configured to connect but the access point it was trying to connect to was unavailable (or the password was wrong) the AP interface would become unstable. I fixed this by using a timer after enabling the STA interface that would check after 10 seconds and disable it if it hadn't connected. I'm not sure if this is a known issue or not but this fixed the stability issues my users were seeing. Here's a quick snippet to show what I now do in Arduino for this:
|
I think this is kind of expected behaviour. When the ESP is trying to connect to an AP, it scans all channels. Since SoftAP shares the same radio, it is disabled for the duration of the scan, as it should not hop between channels. I don't know if Espressif has this documented anywhere though. |
@igrr I think you're right, although it doesn't seem to get interrupted when doing a network scan, just when trying (and failing) to join an STA. I think this post is the closest we get to documentation: |
I am having the same issue, I tried Ticker trick as well, but when i am switching back to AP_STA, ESP web server did not respond (Tried restating server as well). what i did till now:
done...! I am not sure , how ESP is able to connect HTTP, even if it is in AP mode, only by changing STA IP to AP IP.... Also, Scanning n/w will take little time. Please suggest any other method to keep track my n/w whether it is up? |
seems its same problem #1624 |
This is known behavior, and as explained above, it is due to the ESP having a single radio shared between STA and SoftAP. If the Station part is to be used together with the SoftAP, the best practice is to force the SoftAP to the same channel as the AP that the Station is trying to connect to, and only then go and connect. |
it is written in esp_softap.h: |
Have any ideas for this problem ? Thanks |
with example code below, it acts as wifi client to connects to a wifi ap "testAP", and obtain a dhcp ip e.g. 192.168.43.52 from the wifi ap. at the same time, the esp8266 has it own ip, e.g. 192.168.4.1.
we can use web browser to access the 192.168.43.52 and to turn on/off led on esp8266 board.
at the same time, we use another pc to connect to esp8266_AP 192.168.4.1 and obtain a dhcp ip, e.g. 192.168.4.3, and use web browser to access 192.168.4.1 to turn on/off led on esp8266 board.
however, when the 192.168.43.* wifi connection is not established, accessing 192.168.4.1 is very difficult, ping to 192.168.4.1 shows many time-out and only rarely successful ping response. accessing 192.168.4.1 with web browser is failed
could anyone advise when is the cause that when 192.168.43.* wifi connection is not established, 192.168.4.* shows very poor connection performance and the 192.168.4.1 web server is hardly not accessible.
thank you.
include ESP8266WiFi.h #anchor removed as it didn't show up
include WiFiClient.h
include ESP8266WebServer.h
include ESP8266mDNS.h
const char* ssid = "testAP";
const char* password = "12345678";
MDNSResponder mdns;
ESP8266WebServer server(80);
const int led = 13;
void handleRoot() {
server.send(200, "text/plain",
"hello from esp8266!) \n/on: to tuen LED ON \n/off: to tuen LED OFF \n");
}
void handleNotFound(){
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}
void setup(void){
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (mdns.begin("esp8266", WiFi.localIP())) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on("/on", {
digitalWrite(BUILTIN_LED, LOW);
server.send(200, "text/plain", "LED ON");
});
server.on("/off", {
digitalWrite(BUILTIN_LED, HIGH);
server.send(200, "text/plain", "LED OFF");
});
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
//delay a moment,
//for terminal to receive inf, such as IP address
delay(1000);
Serial.end();
pinMode(BUILTIN_LED, OUTPUT);
}
void loop(void){
server.handleClient();
}
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: