diff --git a/libraries/WiFi/src/WiFiAP.cpp b/libraries/WiFi/src/WiFiAP.cpp index 1f8af585..dd850471 100644 --- a/libraries/WiFi/src/WiFiAP.cpp +++ b/libraries/WiFi/src/WiFiAP.cpp @@ -137,6 +137,21 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel, return true; } +/** + * Return the current SSID associated with the network + * @return SSID + */ +String WiFiAPClass::softAPSSID() const +{ + if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ + return String(); + } + wifi_config_t info; + if(!esp_wifi_get_config(WIFI_IF_AP, &info)) { + return String(reinterpret_cast(info.ap.ssid)); + } + return String(); +} /** * Configure access point @@ -189,7 +204,7 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff) wifi_config_t conf; if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ - return ESP_ERR_INVALID_STATE; + return false; } *conf.ap.ssid = 0; diff --git a/libraries/WiFi/src/WiFiAP.h b/libraries/WiFi/src/WiFiAP.h index f1533cc3..b8fbaccc 100644 --- a/libraries/WiFi/src/WiFiAP.h +++ b/libraries/WiFi/src/WiFiAP.h @@ -58,6 +58,8 @@ public: uint8_t* softAPmacAddress(uint8_t* mac); String softAPmacAddress(void); + String softAPSSID(void) const; + protected: };