Skip to content

Commit 7be4729

Browse files
Add ESP8266 compat functions for AP mode (#777)
Fixes #767
1 parent d019f31 commit 7be4729

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

libraries/WiFi/src/WiFiClass.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,57 @@ class WiFiClass {
9191
uint8_t beginAP(const char *ssid, const char* passphrase);
9292
uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel);
9393

94+
// ESP8266 compatible calls
95+
bool softAP(const char* ssid, const char* psk = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4) {
96+
(void) ssid_hidden;
97+
(void) max_connection;
98+
return beginAP(ssid, psk, channel) == WL_CONNECTED;
99+
}
100+
101+
bool softAP(const String& ssid, const String& psk = "", int channel = 1, int ssid_hidden = 0, int max_connection = 4) {
102+
(void) ssid_hidden;
103+
(void) max_connection;
104+
if (psk != "") {
105+
return beginAP(ssid.c_str(), psk.c_str(), channel) == WL_CONNECTED;
106+
} else {
107+
return beginAP(ssid.c_str(), channel) == WL_CONNECTED;
108+
}
109+
}
110+
111+
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
112+
config(local_ip, gateway, subnet);
113+
return true;
114+
}
115+
116+
bool softAPdisconnect(bool wifioff = false) {
117+
(void) wifioff;
118+
end();
119+
return true;
120+
}
121+
122+
uint8_t softAPgetStationNum();
123+
124+
IPAddress softAPIP() {
125+
return localIP();
126+
}
127+
128+
uint8_t* softAPmacAddress(uint8_t* mac) {
129+
return macAddress(mac);
130+
}
131+
132+
String softAPmacAddress(void) {
133+
uint8_t mac[8];
134+
macAddress(mac);
135+
char buff[32];
136+
sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
137+
return String(buff);
138+
}
139+
140+
String softAPSSID() {
141+
return String(SSID());
142+
}
143+
144+
94145
// TODO - EAP is not supported by the driver. Maybe some way of user-level wap-supplicant in the future?
95146
//uint8_t beginEnterprise(const char* ssid, const char* username, const char* password);
96147
//uint8_t beginEnterprise(const char* ssid, const char* username, const char* password, const char* identity);

0 commit comments

Comments
 (0)