Skip to content

Commit 7a37684

Browse files
authored
Soft-AP: get subnet mask (espressif#8358)
In WiFiSTA you can ask for the subnet mask, but not in WiFiAP. Only the CIDR is reported. Therefor the missing method is added to have the same features in softAP as well.
1 parent 289c2a1 commit 7a37684

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

docs/source/api/wifi.rst

+9
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ Get the softAP subnet CIDR.
222222
223223
uint8_t softAPSubnetCIDR();
224224
225+
softAPSubnetMask
226+
****************
227+
228+
Get the softAP subnet mask.
229+
230+
.. code-block:: arduino
231+
232+
IPAddress softAPSubnetMask();
233+
225234
softAPenableIpV6
226235
****************
227236

libraries/WiFi/src/WiFiAP.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,29 @@ IPAddress WiFiAPClass::softAPNetworkID()
304304
}
305305

306306
/**
307-
* Get the softAP subnet CIDR.
308-
* @return uint8_t softAP subnetCIDR
307+
* Get the softAP subnet mask.
308+
* @return IPAddress subnetMask
309309
*/
310-
uint8_t WiFiAPClass::softAPSubnetCIDR()
310+
IPAddress WiFiAPClass::softAPSubnetMask()
311311
{
312-
esp_netif_ip_info_t ip;
312+
esp_netif_ip_info_t ip;
313313
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
314314
return IPAddress();
315315
}
316316
if(esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_AP), &ip) != ESP_OK){
317-
log_e("Netif Get IP Failed!");
318-
return IPAddress();
317+
log_e("Netif Get IP Failed!");
318+
return IPAddress();
319319
}
320-
return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr));
320+
return IPAddress(ip.netmask.addr);
321+
}
322+
323+
/**
324+
* Get the softAP subnet CIDR.
325+
* @return uint8_t softAP subnetCIDR
326+
*/
327+
uint8_t WiFiAPClass::softAPSubnetCIDR()
328+
{
329+
return WiFiGenericClass::calculateSubnetCIDR(softAPSubnetMask());
321330
}
322331

323332
/**

libraries/WiFi/src/WiFiAP.h

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class WiFiAPClass
5151

5252
IPAddress softAPBroadcastIP();
5353
IPAddress softAPNetworkID();
54+
IPAddress softAPSubnetMask();
5455
uint8_t softAPSubnetCIDR();
5556

5657
bool softAPenableIpV6();

0 commit comments

Comments
 (0)