From be7a068be16bb867bc985a902cd4b24c00340a35 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 3 Feb 2015 12:30:08 +0300 Subject: [PATCH] Add parameter to set channel in softAP mode --- libraries/ESP8266WiFi/src/ESP8266WiFi.cpp | 9 +++++++-- libraries/ESP8266WiFi/src/ESP8266WiFi.h | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp index 7c48bab9e..b6544b86d 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp @@ -108,7 +108,7 @@ void ESP8266WiFiClass::softAP(const char* ssid) } -void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase) +void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int channel) { if (wifi_get_opmode() == WIFI_STA) { @@ -119,7 +119,11 @@ void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase) struct softap_config conf; wifi_softap_get_config(&conf); strcpy(reinterpret_cast(conf.ssid), ssid); - conf.channel = 1; + conf.channel = channel; + conf.ssid_len = strlen(ssid); + conf.ssid_hidden = 0; + conf.max_connection = 4; + conf.beacon_interval = 100; if (!passphrase || strlen(passphrase) == 0) { @@ -266,6 +270,7 @@ int8_t ESP8266WiFiClass::scanNetworks() config.ssid = 0; config.bssid = 0; config.channel = 0; + config.show_hidden = 0; wifi_station_scan(&config, reinterpret_cast(&ESP8266WiFiClass::_scanDone)); esp_yield(); return ESP8266WiFiClass::_scanCount; diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFi.h b/libraries/ESP8266WiFi/src/ESP8266WiFi.h index f41116e48..8f81e7ad5 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFi.h +++ b/libraries/ESP8266WiFi/src/ESP8266WiFi.h @@ -68,9 +68,10 @@ public: /* Set up a WPA2-secured access point * * param ssid: Pointer to the SSID string. - * param ssid: Pointer to passphrase, 8 characters min. + * param passphrase: Pointer to passphrase, 8 characters min. + * param channel: WiFi channel number, 1 - 13. */ - void softAP(const char* ssid, const char* passphrase); + void softAP(const char* ssid, const char* passphrase, int channel = 1); /* Change Ip configuration settings disabling the dhcp client