Skip to content

Commit

Permalink
Add WiFi.softAPSSID()
Browse files Browse the repository at this point in the history
Fixes: #4922
  • Loading branch information
me-no-dev committed Mar 10, 2021
1 parent 23f6e81 commit f815a7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion libraries/WiFi/src/WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(info.ap.ssid));
}
return String();
}

/**
* Configure access point
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions libraries/WiFi/src/WiFiAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class WiFiAPClass
uint8_t* softAPmacAddress(uint8_t* mac);
String softAPmacAddress(void);

String softAPSSID(void) const;

protected:

};
Expand Down

0 comments on commit f815a7c

Please sign in to comment.