1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Add parameter to set channel in softAP mode

This commit is contained in:
Ivan Grokhotkov 2015-02-03 12:30:08 +03:00
parent 076977dbeb
commit be7a068be1
2 changed files with 10 additions and 4 deletions

View File

@ -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<char*>(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<scan_done_cb_t>(&ESP8266WiFiClass::_scanDone));
esp_yield();
return ESP8266WiFiClass::_scanCount;

View File

@ -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