Skip to content

Commit 51c2a14

Browse files
authored
more lwIP physical interfaces (#6680)
This commit adds W5500 W5100 and ENC28j60 drivers from @njh with credits They are available in libraries/ An example is added in W5500 examples directory plus: * Extract dhcp server from lwip2 and add it to the core as a class. It must always be present, it is linked and can be called by fw on boot. So it cannot be stored in a library. * ethernet: static or dhcp works * PPPServer: example * bring WiFi.config() to the lwIP generic interface (argument reorder common function) * move hostname() from WiFI-STA to generic interface * remove non readable characters from dhcp-server comments * dhcp-server: magic_cookie is part of bootp rfc * fixes from d-a-v/W5500lwIP#17 * enable lwip_hook_dhcp_parse_option() * +ethernet tcp client example in w5500 library examples
1 parent 35d22ed commit 51c2a14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+8114
-157
lines changed
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
lwIPDhcpServer-NonOS.cpp - DHCP server wrapper
3+
4+
Copyright (c) 2020 esp8266 arduino. All rights reserved.
5+
This file is part of the esp8266 core for Arduino environment.
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public
18+
License along with this library; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
*/
21+
22+
// STARTS/STOPS DHCP SERVER ON WIFI AP INTERFACE
23+
// these functions must exists as-is with "C" interface,
24+
// nonos-sdk calls them at boot time and later
25+
26+
#include <lwip/init.h> // LWIP_VERSION
27+
28+
#include <lwip/netif.h>
29+
#include "LwipDhcpServer.h"
30+
31+
extern netif netif_git[2];
32+
33+
// global DHCP instance for softAP interface
34+
DhcpServer dhcpSoftAP(&netif_git[SOFTAP_IF]);
35+
36+
extern "C"
37+
{
38+
39+
void dhcps_start(struct ip_info *info, netif* apnetif)
40+
{
41+
// apnetif is esp interface, replaced by lwip2's
42+
// netif_git[SOFTAP_IF] interface in constructor
43+
(void)apnetif;
44+
45+
#if 0
46+
// can't use C++ now, global ctors are not initialized yet
47+
dhcpSoftAP.begin(info);
48+
#else
49+
(void)info;
50+
// initial version: emulate nonos-sdk in DhcpServer class before
51+
// trying to change legacy behavor
52+
// `fw_has_started_softap_dhcps` will be read in DhcpServer::DhcpServer
53+
// which is called when c++ ctors are initialized, specifically
54+
// dhcpSoftAP intialized with AP interface number above.
55+
fw_has_started_softap_dhcps = 1;
56+
#endif
57+
}
58+
59+
void dhcps_stop()
60+
{
61+
dhcpSoftAP.end();
62+
}
63+
64+
} // extern "C"

0 commit comments

Comments
 (0)