Skip to content

Commit f815a7c

Browse files
committed
Add WiFi.softAPSSID()
Fixes: #4922
1 parent 23f6e81 commit f815a7c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

libraries/WiFi/src/WiFiAP.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ bool WiFiAPClass::softAP(const char* ssid, const char* passphrase, int channel,
137137
return true;
138138
}
139139

140+
/**
141+
* Return the current SSID associated with the network
142+
* @return SSID
143+
*/
144+
String WiFiAPClass::softAPSSID() const
145+
{
146+
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
147+
return String();
148+
}
149+
wifi_config_t info;
150+
if(!esp_wifi_get_config(WIFI_IF_AP, &info)) {
151+
return String(reinterpret_cast<char*>(info.ap.ssid));
152+
}
153+
return String();
154+
}
140155

141156
/**
142157
* Configure access point
@@ -189,7 +204,7 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff)
189204
wifi_config_t conf;
190205

191206
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
192-
return ESP_ERR_INVALID_STATE;
207+
return false;
193208
}
194209

195210
*conf.ap.ssid = 0;

libraries/WiFi/src/WiFiAP.h

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class WiFiAPClass
5858
uint8_t* softAPmacAddress(uint8_t* mac);
5959
String softAPmacAddress(void);
6060

61+
String softAPSSID(void) const;
62+
6163
protected:
6264

6365
};

0 commit comments

Comments
 (0)