Unverified Commit ac1c0012 authored by Gonzalo Brusco's avatar Gonzalo Brusco Committed by GitHub

Added WiFi Bandwidth Setting Methods for AP and STA modes. (#7619)

* Added Bandwith setting method

* Separted AP and STA on it's own class each

* Missing WiFi

* Rename for consistency

---------
Co-authored-by: default avatarMe No Dev <me-no-dev@users.noreply.github.com>
parent 990e3d5b
......@@ -235,6 +235,25 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff)
return ret;
}
/**
* Sets the working bandwidth of the AP mode
* @param m wifi_bandwidth_t
*/
bool WiFiAPClass::softAPbandwidth(wifi_bandwidth_t bandwidth) {
if(!WiFi.enableAP(true)) {
log_e("AP enable failed!");
return false;
}
esp_err_t err;
err = esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_AP, bandwidth);
if(err){
log_e("Could not set AP bandwidth!");
return false;
}
return true;
}
/**
* Get the count of the Station / client that are connected to the softAP interface
......
......@@ -45,6 +45,8 @@ public:
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dhcp_lease_start = (uint32_t) 0);
bool softAPdisconnect(bool wifioff = false);
bool softAPbandwidth(wifi_bandwidth_t bandwidth);
uint8_t softAPgetStationNum();
IPAddress softAPIP();
......
......@@ -1225,7 +1225,6 @@ int32_t WiFiGenericClass::channel(void)
return primaryChan;
}
/**
* store WiFi config in SDK flash area
* @param persistent
......
......@@ -431,6 +431,26 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
return err == ESP_OK;
}
/**
* Sets the working bandwidth of the STA mode
* @param m wifi_bandwidth_t
*/
bool WiFiSTAClass::bandwidth(wifi_bandwidth_t bandwidth) {
if(!WiFi.enableSTA(true)) {
log_e("STA enable failed!");
return false;
}
esp_err_t err;
err = esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_STA, bandwidth);
if(err){
log_e("Could not set STA bandwidth!");
return false;
}
return true;
}
/**
* Change DNS server for static IP configuration
* @param dns1 Static DNS server 1
......
......@@ -58,6 +58,8 @@ public:
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
bool setDNS(IPAddress dns1, IPAddress dns2 = (uint32_t)0x00000000); // sets DNS IP for all network interfaces
bool bandwidth(wifi_bandwidth_t bandwidth);
bool reconnect();
bool disconnect(bool wifioff = false, bool eraseap = false);
bool eraseAP(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment