Skip to content

BUG: softAPdisconnect fails #3793

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

Closed
tablatronix opened this issue Nov 4, 2017 · 4 comments
Closed

BUG: softAPdisconnect fails #3793

tablatronix opened this issue Nov 4, 2017 · 4 comments

Comments

@tablatronix
Copy link
Contributor

tablatronix commented Nov 4, 2017

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
@tablatronix
Copy link
Contributor Author

I have more advanced examples that dump all the config structs also

@tablatronix
Copy link
Contributor Author

tablatronix commented Nov 4, 2017

also ret from wifi_softap_set_config gets overwritten if wifioff is true.

bool ESP8266WiFiAPClass::softAPdisconnect(bool wifioff) {
...
    if(wifioff) {
        ret = WiFi.enableAP(false);
    }
...
}

tablatronix added a commit to tablatronix/Arduino that referenced this issue Nov 4, 2017
wifi_softap_set_config always fails, password cannot be 0 unless authmode is open, no documentation found, trial and error.
@tablatronix
Copy link
Contributor Author

It appears that wifi_softap_set_config always fails if password is not 8 chars, It cannot be 0 unless authmode is open, no documentation found describing this, but trial and error found it to work now.

@tablatronix tablatronix changed the title sofAPdisconnect fails BUG: softAPdisconnect fails Nov 4, 2017
@tablatronix
Copy link
Contributor Author

tablatronix commented Nov 4, 2017

PR #3794

This does not fix

softAPdisconnect ret from wifi_softap_set_config gets overwritten if wifioff is true.

That should probably be discussed , maybe bail if ret = false after config section, do not proceed to wifioff, this bug obscured the prior for a very long time.

suggest change

    if(ret && wifioff) {
        ret = WiFi.enableAP(false);
    }

#3795

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant