Skip to content

Commit 1b922ed

Browse files
authored
Added broadcastIP method to WiFiSTA class (#7899)
1 parent 2406fe8 commit 1b922ed

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,18 @@ IPAddress ESP8266WiFiSTAClass::dnsIP(uint8_t dns_no) {
504504
return IPAddress(dns_getserver(dns_no));
505505
}
506506

507+
/**
508+
* Get the broadcast ip address.
509+
* @return IPAddress Bradcast IP
510+
*/
511+
IPAddress ESP8266WiFiSTAClass::broadcastIP()
512+
{
513+
struct ip_info ip;
514+
wifi_get_ip_info(STATION_IF, &ip);
515+
516+
return IPAddress(ip.ip.addr | ~(ip.netmask.addr));
517+
}
518+
507519
/**
508520
* Return Connection status.
509521
* @return one of the value defined in wl_status_t

Diff for: libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ESP8266WiFiSTAClass: public LwipIntf {
7070
IPAddress gatewayIP();
7171
IPAddress dnsIP(uint8_t dns_no = 0);
7272

73+
IPAddress broadcastIP();
7374
// STA WiFi info
7475
wl_status_t status();
7576
String SSID() const;

0 commit comments

Comments
 (0)