Skip to content

BUG: softAPdisconnect fails #3793

Closed
Closed
@tablatronix

Description

@tablatronix

dup of #2950 from feb 10 2017, this is more concise report of actual problem

Basic Infos

softAPdisconnect seems to not work

Hardware

Hardware: ESP-12e (nodemcu v1)
Core Version: system_get_sdk_version(): 2.1.0(7106d38)

Description

softap then sofapdisconnect, always returns false, ap stays on, and persists also

Sketch

/* Create a WiFi access point and provide a web server on it. */

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "ESPap";
const char *password = "thereisnospoon";
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };

ESP8266WebServer server(80);

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
 * connected to this access point to see it.
 */
void handleRoot() {
    server.send(200, "text/html", "<h1>You are connected</h1>");
}

void espInfo(Stream & consolePort){
    consolePort.print(F("system_get_sdk_version(): "));
    consolePort.println(ESP.getSdkVersion());
    consolePort.print(F("system_get_boot_version(): "));
    consolePort.println(ESP.getBootVersion());    
}

void setup() {
    Serial.begin(115200);
    delay(1000);
    Serial.println();

    espInfo(Serial);

    WiFi.printDiag(Serial);

    // WiFi.persistent(false);

    Serial.print("Configuring access point...");
    /* You can remove the password parameter if you want the AP to be open. */
    WiFi.softAP(ssid, password);

    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);
    
    // server.on("/", handleRoot);
    // server.begin();
    // Serial.println("HTTP server started");

    Serial.println("Waiting for AP disconnect...");
    delay(20000);
    bool ret = WiFi.softAPdisconnect();
    if(!ret) Serial.println("softAPdisconnect failed");

    // delay(2000);
    // ESP.eraseConfig();
    // ESP.reset();
}

void loop() {
  // server.handleClient();
  Serial.println(modes[WiFi.getMode()]);
  delay(1000);
}

Debug Messages

system_get_sdk_version(): 2.1.0(7106d38)
system_get_boot_version(): 31
Mode: AP
PHY mode: N
Channel: 1
AP id: 0
Status: 255
Auto connect: 1
SSID (0): 
Passphrase (0): 
BSSID set: 0
Configuring access point...AP IP address: 192.168.4.1
Waiting for AP disconnect...
softAPdisconnect failed
AP
AP
AP
AP
AP

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions