Skip to content

Commit 4cc06c2

Browse files
committed
Add method to configure softAP IP address
fix #76
1 parent a5662ff commit 4cc06c2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int chan
141141
ETS_UART_INTR_ENABLE();
142142
}
143143

144+
void ESP8266WiFiClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
145+
{
146+
struct ip_info info;
147+
info.ip.addr = static_cast<uint32_t>(local_ip);
148+
info.gw.addr = static_cast<uint32_t>(gateway);
149+
info.netmask.addr = static_cast<uint32_t>(subnet);
150+
wifi_softap_dhcps_stop();
151+
wifi_set_ip_info(SOFTAP_IF, &info);
152+
wifi_softap_dhcps_start();
153+
}
144154

145155
uint8_t* ESP8266WiFiClass::macAddress(uint8_t* mac)
146156
{

libraries/ESP8266WiFi/src/ESP8266WiFi.h

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ class ESP8266WiFiClass
8282
*/
8383
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
8484

85+
/* Configure access point
86+
*
87+
* param local_ip: access point IP
88+
* param gateway: gateway IP
89+
* param subnet: subnet mask
90+
*/
91+
void softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
92+
8593
/*
8694
* Disconnect from the network
8795
*

0 commit comments

Comments
 (0)