Skip to content

Commit

Permalink
Add ESP8266 compat functions for AP mode (#777)
Browse files Browse the repository at this point in the history
Fixes #767
  • Loading branch information
earlephilhower committed Aug 20, 2022
1 parent d019f31 commit 7be4729
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions libraries/WiFi/src/WiFiClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,57 @@ class WiFiClass {
uint8_t beginAP(const char *ssid, const char* passphrase);
uint8_t beginAP(const char *ssid, const char* passphrase, uint8_t channel);

// ESP8266 compatible calls
bool softAP(const char* ssid, const char* psk = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4) {
(void) ssid_hidden;
(void) max_connection;
return beginAP(ssid, psk, channel) == WL_CONNECTED;
}

bool softAP(const String& ssid, const String& psk = "", int channel = 1, int ssid_hidden = 0, int max_connection = 4) {
(void) ssid_hidden;
(void) max_connection;
if (psk != "") {
return beginAP(ssid.c_str(), psk.c_str(), channel) == WL_CONNECTED;
} else {
return beginAP(ssid.c_str(), channel) == WL_CONNECTED;
}
}

bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
config(local_ip, gateway, subnet);
return true;
}

bool softAPdisconnect(bool wifioff = false) {
(void) wifioff;
end();
return true;
}

uint8_t softAPgetStationNum();

IPAddress softAPIP() {
return localIP();
}

uint8_t* softAPmacAddress(uint8_t* mac) {
return macAddress(mac);
}

String softAPmacAddress(void) {
uint8_t mac[8];
macAddress(mac);
char buff[32];
sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
return String(buff);
}

String softAPSSID() {
return String(SSID());
}


// TODO - EAP is not supported by the driver. Maybe some way of user-level wap-supplicant in the future?
//uint8_t beginEnterprise(const char* ssid, const char* username, const char* password);
//uint8_t beginEnterprise(const char* ssid, const char* username, const char* password, const char* identity);
Expand Down

0 comments on commit 7be4729

Please sign in to comment.