Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7a37684

Browse filesBrowse 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
Copy full SHA for 7a37684

File tree

Expand file treeCollapse file tree

3 files changed

+26
-7
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+26
-7
lines changed

‎docs/source/api/wifi.rst

Copy file name to clipboardExpand all lines: docs/source/api/wifi.rst
+9Lines changed: 9 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiAP.cpp
+16-7Lines changed: 16 additions & 7 deletions
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

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiAP.h
+1Lines changed: 1 addition & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.