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: Me No Dev <me-no-dev@users.noreply.github.com>
This commit is contained in:
parent
990e3d5b43
commit
ac1c00121b
5 changed files with 43 additions and 1 deletions
|
|
@ -235,6 +235,25 @@ bool WiFiAPClass::softAPdisconnect(bool wifioff)
|
||||||
return ret;
|
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
|
* 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 softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dhcp_lease_start = (uint32_t) 0);
|
||||||
bool softAPdisconnect(bool wifioff = false);
|
bool softAPdisconnect(bool wifioff = false);
|
||||||
|
|
||||||
|
bool softAPbandwidth(wifi_bandwidth_t bandwidth);
|
||||||
|
|
||||||
uint8_t softAPgetStationNum();
|
uint8_t softAPgetStationNum();
|
||||||
|
|
||||||
IPAddress softAPIP();
|
IPAddress softAPIP();
|
||||||
|
|
|
||||||
|
|
@ -1225,7 +1225,6 @@ int32_t WiFiGenericClass::channel(void)
|
||||||
return primaryChan;
|
return primaryChan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store WiFi config in SDK flash area
|
* store WiFi config in SDK flash area
|
||||||
* @param persistent
|
* @param persistent
|
||||||
|
|
|
||||||
|
|
@ -431,6 +431,26 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
|
||||||
return err == ESP_OK;
|
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
|
* Change DNS server for static IP configuration
|
||||||
* @param dns1 Static DNS server 1
|
* @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 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 setDNS(IPAddress dns1, IPAddress dns2 = (uint32_t)0x00000000); // sets DNS IP for all network interfaces
|
||||||
|
|
||||||
|
bool bandwidth(wifi_bandwidth_t bandwidth);
|
||||||
|
|
||||||
bool reconnect();
|
bool reconnect();
|
||||||
bool disconnect(bool wifioff = false, bool eraseap = false);
|
bool disconnect(bool wifioff = false, bool eraseap = false);
|
||||||
bool eraseAP(void);
|
bool eraseAP(void);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue