mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-29 05:21:37 +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:
@ -143,6 +143,7 @@ MOCK_CPP_FILES_EMU := $(MOCK_CPP_FILES_COMMON) \
|
||||
ArduinoMainUdp.cpp \
|
||||
ArduinoMainSpiffs.cpp \
|
||||
ArduinoMainLittlefs.cpp \
|
||||
DhcpServer.cpp \
|
||||
user_interface.cpp \
|
||||
)
|
||||
|
||||
|
80
tests/host/common/DhcpServer.cpp
Normal file
80
tests/host/common/DhcpServer.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include <LwipDhcpServer.h>
|
||||
#include <LwipDhcpServer-NonOS.h>
|
||||
|
||||
DhcpServer& getNonOSDhcpServer()
|
||||
{
|
||||
static DhcpServer instance(nullptr);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool DhcpServer::set_dhcps_lease(struct dhcps_lease* please)
|
||||
{
|
||||
(void)please;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DhcpServer::set_dhcps_lease_time(uint32 minute)
|
||||
{
|
||||
(void)minute;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DhcpServer::set_dhcps_offer_option(uint8 level, void* optarg)
|
||||
{
|
||||
(void)level;
|
||||
(void)optarg;
|
||||
return false;
|
||||
}
|
||||
|
||||
void DhcpServer::end() { }
|
||||
|
||||
bool DhcpServer::begin()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DhcpServer::DhcpServer(netif*) { }
|
||||
|
||||
DhcpServer::~DhcpServer()
|
||||
{
|
||||
end();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <user_interface.h>
|
||||
|
||||
bool wifi_softap_dhcps_start(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
enum dhcp_status wifi_softap_dhcps_status(void)
|
||||
{
|
||||
return DHCP_STARTED;
|
||||
}
|
||||
|
||||
bool wifi_softap_dhcps_stop(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_set_dhcps_lease(struct dhcps_lease* please)
|
||||
{
|
||||
(void)please;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_set_dhcps_lease_time(uint32 minute)
|
||||
{
|
||||
(void)minute;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_set_dhcps_offer_option(uint8 level, void* optarg)
|
||||
{
|
||||
(void)level;
|
||||
(void)optarg;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -41,47 +41,6 @@
|
||||
|
||||
#include "MocklwIP.h"
|
||||
|
||||
#include <LwipDhcpServer.h>
|
||||
|
||||
bool DhcpServer::set_dhcps_lease(struct dhcps_lease* please)
|
||||
{
|
||||
(void)please;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DhcpServer::set_dhcps_lease_time(uint32 minute)
|
||||
{
|
||||
(void)minute;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DhcpServer::set_dhcps_offer_option(uint8 level, void* optarg)
|
||||
{
|
||||
(void)level;
|
||||
(void)optarg;
|
||||
return false;
|
||||
}
|
||||
|
||||
void DhcpServer::end() { }
|
||||
|
||||
bool DhcpServer::begin(struct ip_info* info)
|
||||
{
|
||||
(void)info;
|
||||
return false;
|
||||
}
|
||||
|
||||
DhcpServer::DhcpServer(netif* netif)
|
||||
{
|
||||
(void)netif;
|
||||
}
|
||||
|
||||
DhcpServer::~DhcpServer()
|
||||
{
|
||||
end();
|
||||
}
|
||||
|
||||
DhcpServer dhcpSoftAP(nullptr);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <user_interface.h>
|
||||
@ -400,21 +359,6 @@ extern "C"
|
||||
(void)max_tpw;
|
||||
}
|
||||
|
||||
bool wifi_softap_dhcps_start(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
enum dhcp_status wifi_softap_dhcps_status(void)
|
||||
{
|
||||
return DHCP_STARTED;
|
||||
}
|
||||
|
||||
bool wifi_softap_dhcps_stop(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_get_config(struct softap_config* config)
|
||||
{
|
||||
strcpy((char*)config->ssid, "apssid");
|
||||
@ -450,25 +394,6 @@ extern "C"
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_set_dhcps_lease(struct dhcps_lease* please)
|
||||
{
|
||||
(void)please;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_set_dhcps_lease_time(uint32 minute)
|
||||
{
|
||||
(void)minute;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_softap_set_dhcps_offer_option(uint8 level, void* optarg)
|
||||
{
|
||||
(void)level;
|
||||
(void)optarg;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wifi_station_scan(struct scan_config* config, scan_done_cb_t cb)
|
||||
{
|
||||
(void)config;
|
||||
|
Reference in New Issue
Block a user