mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Revert "Added support for user-supplied DHCP range, with basic sanity checks (#3562)"
This reverts commit bdf2296a7d521ec876f15f3491b6690fff6abbb7.
This commit is contained in:
parent
35d5fabe33
commit
eb891cd6e4
@ -179,10 +179,8 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
|
|||||||
* @param local_ip access point IP
|
* @param local_ip access point IP
|
||||||
* @param gateway gateway IP
|
* @param gateway gateway IP
|
||||||
* @param subnet subnet mask
|
* @param subnet subnet mask
|
||||||
* @param dhcp_start first IP assigned by DHCP
|
|
||||||
* @param dhcp_end last IP assigned by DHCP
|
|
||||||
*/
|
*/
|
||||||
bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dhcp_start, IPAddress dhcp_end) {
|
bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
|
||||||
DEBUG_WIFI("[APConfig] local_ip: %s gateway: %s subnet: %s\n", local_ip.toString().c_str(), gateway.toString().c_str(), subnet.toString().c_str());
|
DEBUG_WIFI("[APConfig] local_ip: %s gateway: %s subnet: %s\n", local_ip.toString().c_str(), gateway.toString().c_str(), subnet.toString().c_str());
|
||||||
if(!WiFi.enableAP(true)) {
|
if(!WiFi.enableAP(true)) {
|
||||||
// enable AP failed
|
// enable AP failed
|
||||||
@ -206,29 +204,15 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct dhcps_lease dhcp_lease;
|
struct dhcps_lease dhcp_lease;
|
||||||
|
IPAddress ip = local_ip;
|
||||||
uint32_t net_addr = info.ip.addr & info.netmask.addr;
|
ip[3] += 99;
|
||||||
uint32_t bcast_addr = net_addr | !info.netmask.addr;
|
dhcp_lease.start_ip.addr = static_cast<uint32_t>(ip);
|
||||||
|
|
||||||
// Assign user-supplied range, checking its validity
|
|
||||||
IPAddress ip = (static_cast<uint32_t>(dhcp_start) & !info.netmask.addr) | net_addr;
|
|
||||||
|
|
||||||
dhcp_lease.start_ip.addr = ip;
|
|
||||||
if(ip != net_addr && ip != bcast_addr && ip != info.ip.addr && ip != info.gw.addr) {
|
|
||||||
DEBUG_WIFI("[APConfig] DHCP IP start: %s\n", ip.toString().c_str());
|
DEBUG_WIFI("[APConfig] DHCP IP start: %s\n", ip.toString().c_str());
|
||||||
} else {
|
|
||||||
dhcp_lease.start_ip.addr=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ip = (static_cast<uint32_t>(dhcp_end) & !info.netmask.addr) | net_addr;
|
ip[3] += 100;
|
||||||
dhcp_lease.end_ip.addr = static_cast<uint32_t>(ip);
|
dhcp_lease.end_ip.addr = static_cast<uint32_t>(ip);
|
||||||
if(ip != net_addr && ip != bcast_addr && ip != info.ip.addr && ip != info.gw.addr) {
|
|
||||||
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", ip.toString().c_str());
|
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", ip.toString().c_str());
|
||||||
} else {
|
|
||||||
dhcp_lease.end_ip.addr=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dhcp_lease.start_ip.addr && dhcp_lease.end_ip.addr) {
|
|
||||||
if(!wifi_softap_set_dhcps_lease(&dhcp_lease)) {
|
if(!wifi_softap_set_dhcps_lease(&dhcp_lease)) {
|
||||||
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
|
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
@ -250,9 +234,6 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
|
|||||||
DEBUG_WIFI("[APConfig] wifi_softap_dhcps_start failed!\n");
|
DEBUG_WIFI("[APConfig] wifi_softap_dhcps_start failed!\n");
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DEBUG_WIFI("[APConfig] DHCP daemon not started (range error or user request)\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// check config
|
// check config
|
||||||
if(wifi_get_ip_info(SOFTAP_IF, &info)) {
|
if(wifi_get_ip_info(SOFTAP_IF, &info)) {
|
||||||
@ -273,25 +254,6 @@ bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPA
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure access point
|
|
||||||
* @param local_ip access point IP
|
|
||||||
* @param gateway gateway IP
|
|
||||||
* @param subnet subnet mask
|
|
||||||
*/
|
|
||||||
bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
|
|
||||||
IPAddress dhcp_start;
|
|
||||||
IPAddress dhcp_end;
|
|
||||||
|
|
||||||
// calculate dhcp_start and DHCP_end as done in the old code
|
|
||||||
dhcp_start = local_ip;
|
|
||||||
dhcp_start[3] += 99;
|
|
||||||
dhcp_end = dhcp_start;
|
|
||||||
dhcp_end[3] += 100;
|
|
||||||
|
|
||||||
softAPConfig(local_ip, gateway, subnet, dhcp_start, dhcp_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect from the network (close AP)
|
* Disconnect from the network (close AP)
|
||||||
|
@ -37,7 +37,6 @@ class ESP8266WiFiAPClass {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
|
bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
|
||||||
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dhcp_start, IPAddress dhcp_end);
|
|
||||||
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
|
bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
|
||||||
bool softAPdisconnect(bool wifioff = false);
|
bool softAPdisconnect(bool wifioff = false);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user