Skip to content

Soft-AP: get subnet mask #8358

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 1 commit into from
Jul 17, 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
9 changes: 9 additions & 0 deletions docs/source/api/wifi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ Get the softAP subnet CIDR.
uint8_t softAPSubnetCIDR();
softAPSubnetMask
****************

Get the softAP subnet mask.

.. code-block:: arduino
IPAddress softAPSubnetMask();
softAPenableIpV6
****************

Expand Down
23 changes: 16 additions & 7 deletions libraries/WiFi/src/WiFiAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,20 +304,29 @@ IPAddress WiFiAPClass::softAPNetworkID()
}

/**
* Get the softAP subnet CIDR.
* @return uint8_t softAP subnetCIDR
* Get the softAP subnet mask.
* @return IPAddress subnetMask
*/
uint8_t WiFiAPClass::softAPSubnetCIDR()
IPAddress WiFiAPClass::softAPSubnetMask()
{
esp_netif_ip_info_t ip;
esp_netif_ip_info_t ip;
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
return IPAddress();
}
if(esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_AP), &ip) != ESP_OK){
log_e("Netif Get IP Failed!");
return IPAddress();
log_e("Netif Get IP Failed!");
return IPAddress();
}
return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr));
return IPAddress(ip.netmask.addr);
}

/**
* Get the softAP subnet CIDR.
* @return uint8_t softAP subnetCIDR
*/
uint8_t WiFiAPClass::softAPSubnetCIDR()
{
return WiFiGenericClass::calculateSubnetCIDR(softAPSubnetMask());
}

/**
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class WiFiAPClass

IPAddress softAPBroadcastIP();
IPAddress softAPNetworkID();
IPAddress softAPSubnetMask();
uint8_t softAPSubnetCIDR();

bool softAPenableIpV6();
Expand Down