Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions libraries/WiFi/src/WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions libraries/WiFi/src/WiFiAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class WiFiAPClass
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();
Expand Down
1 change: 0 additions & 1 deletion libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,6 @@ int32_t WiFiGenericClass::channel(void)
return primaryChan;
}


/**
* store WiFi config in SDK flash area
* @param persistent
Expand Down
20 changes: 20 additions & 0 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class WiFiSTAClass
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);
Expand Down