mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Initialize SoftAP DhcpServer object on demand (#8546)
* Initialize SoftAP DhcpServer object on demand Remove dependency on global ctor, and just construct the object when someone asks us to do it. Only dependency right now is netif_git, which is expected to be initialized by the lwip code some time before dhcps_start happens. Removing ip_info from begin(), since we never reference later on. Also removing the specific check for netif id and simplify the ctors. Update tests and recover old nonos-sdk dhcps functions that were not implemented. * nonos helpers have a separate header * wifi ap needs this anyway, simplify sketch includes * missing example * existing name :/ * trying to fix header dependency * restyle * not a c header * no need to init * move dhcp server getter to WiFi more... arduino'ish? we ahve object as namespace, plus everything else related to softAP is there redundant includes, redundant mock impl (out-of-scope here to fix) * ...move things back, still expose as WiFi method * review fix * include -nonos header in wifi lib though * no more lwip include * style * need mock dhcpserver instance
This commit is contained in:
@ -4,7 +4,6 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <LwipDhcpServer.h>
|
||||
|
||||
/* Set these to your desired credentials. */
|
||||
const char *ssid = "ESPap";
|
||||
@ -76,8 +75,9 @@ void setup() {
|
||||
...
|
||||
any client not listed will use next IP address available from the range (here 192.168.0.102 and more)
|
||||
*/
|
||||
dhcpSoftAP.add_dhcps_lease(mac_CAM); // always 192.168.0.100
|
||||
dhcpSoftAP.add_dhcps_lease(mac_PC); // always 192.168.0.101
|
||||
auto &dhcpServer = WiFi.softAPDhcpServer();
|
||||
dhcpServer.add_dhcps_lease(mac_CAM); // always 192.168.0.100
|
||||
dhcpServer.add_dhcps_lease(mac_PC); // always 192.168.0.101
|
||||
/* Start Access Point. You can remove the password parameter if you want the AP to be open. */
|
||||
WiFi.softAP(ssid, password);
|
||||
Serial.print("AP IP address: ");
|
||||
|
Reference in New Issue
Block a user