diff --git a/.gitmodules b/.gitmodules index 054baa12d4..096d71a318 100644 --- a/.gitmodules +++ b/.gitmodules @@ -45,3 +45,7 @@ path = Sming/Libraries/Adafruit_SSD1306 url = https://github.com/adafruit/Adafruit_SSD1306.git ignore = dirty +[submodule "Sming/third-party/lwip2"] + path = Sming/third-party/lwip2 + url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git + ignore = dirty \ No newline at end of file diff --git a/Sming/Makefile b/Sming/Makefile index 1cfb9db6d2..55e72549c5 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -201,7 +201,18 @@ ENABLE_CUSTOM_LWIP ?= 1 ENABLE_ESPCONN ?= 0 ifeq ($(ENABLE_CUSTOM_LWIP), 1) THIRD_PARTY_DATA += third-party/esp-open-lwip/Makefile.open + EXTRA_INCDIR += system/esp-lwip EXTRA_INCDIR += third-party/esp-open-lwip/include + LIBLWIP = lwip_open + lwip_extra = 1 +endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + THIRD_PARTY_DATA += third-party/lwip2/Makefile.sming + EXTRA_INCDIR += third-party/lwip2/include + LIBLWIP = lwip2 + lwip_extra = 1 +endif +ifeq ($(lwip_extra),1) EXTRA_CFLAGS_LWIP = -I../../system/include -I../../Wiring ENABLE_LWIPDEBUG ?= 0 ifeq ($(ENABLE_LWIPDEBUG), 1) @@ -210,8 +221,6 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1) ifeq ($(ENABLE_ESPCONN), 1) LIBLWIP = lwip_full - else - LIBLWIP = lwip_open endif CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a endif @@ -384,6 +393,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1) $(USER_LIBDIR)/liblwip_%.a: third-party/esp-open-lwip/Makefile.open $(Q) $(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" all endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) +$(USER_LIBDIR)/liblwip%.a: third-party/lwip2/Makefile.sming + $(Q) $(MAKE) -C third-party/lwip2/ -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" all +endif spiffy: spiffy/spiffy @@ -429,6 +442,9 @@ endif ifeq ($(ENABLE_CUSTOM_LWIP), 1) $(Q) -$(MAKE) -C third-party/esp-open-lwip/ -f Makefile.open ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" clean endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + $(Q) -$(MAKE) -C third-party/lwip2/ -f Makefile.sming ENABLE_ESPCONN=$(ENABLE_ESPCONN) SDK_BASE="$(SDK_BASE)" USER_LIBDIR="$(SMING_HOME)/$(USER_LIBDIR)/" CFLAGS_EXTRA="$(EXTRA_CFLAGS_LWIP)" clean +endif test: Basic_Blink Basic_rBoot Basic_Ssl Basic_HwPWM diff --git a/Sming/Makefile-project.mk b/Sming/Makefile-project.mk index 52090080b9..27db97e744 100644 --- a/Sming/Makefile-project.mk +++ b/Sming/Makefile-project.mk @@ -177,6 +177,9 @@ ENABLE_CUSTOM_LWIP ?= 1 ifeq ($(ENABLE_CUSTOM_LWIP), 1) LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip/include endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + LWIP_INCDIR = $(SMING_HOME)/third-party/lwip2/include +endif EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include \ $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/Libraries/Adafruit_GFX \ @@ -200,6 +203,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1) endif CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + LIBLWIP = lwip2 + CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip2.a +endif LIBPWM = pwm @@ -461,6 +468,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1) $(USER_LIBDIR)/liblwip_%.a: $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=1 ENABLE_ESPCONN=$(ENABLE_ESPCONN) endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) +$(USER_LIBDIR)/liblwip%.a: + $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=2 ENABLE_ESPCONN=$(ENABLE_ESPCONN) +endif checkdirs: $(BUILD_DIR) $(FW_BASE) $(CUSTOM_TARGETS) diff --git a/Sming/Makefile-rboot.mk b/Sming/Makefile-rboot.mk index 32ab0599c3..7fc90f6f62 100644 --- a/Sming/Makefile-rboot.mk +++ b/Sming/Makefile-rboot.mk @@ -185,6 +185,9 @@ ENABLE_CUSTOM_LWIP ?= 1 ifeq ($(ENABLE_CUSTOM_LWIP), 1) LWIP_INCDIR = $(SMING_HOME)/third-party/esp-open-lwip/include endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + LWIP_INCDIR = $(SMING_HOME)/third-party/lwip2/include +endif EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME)/system/include \ $(SMING_HOME)/Wiring $(SMING_HOME)/Libraries $(SMING_HOME)/Libraries/Adafruit_GFX \ @@ -249,6 +252,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1) endif CUSTOM_TARGETS += $(USER_LIBDIR)/lib$(LIBLWIP).a endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + LIBLWIP = lwip2 + CUSTOM_TARGETS += $(USER_LIBDIR)/liblwip2.a +endif LIBPWM = pwm @@ -280,6 +287,9 @@ endif ifeq ($(ENABLE_CUSTOM_LWIP), 1) EXTRA_INCDIR += third-party/esp-open-lwip/include endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) + EXTRA_INCDIR += third-party/lwip2/include +endif # we will use global WiFi settings from Eclipse Environment Variables, if possible @@ -511,6 +521,10 @@ ifeq ($(ENABLE_CUSTOM_LWIP), 1) $(USER_LIBDIR)/liblwip_%.a: $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=1 ENABLE_ESPCONN=$(ENABLE_ESPCONN) endif +ifeq ($(ENABLE_CUSTOM_LWIP), 2) +$(USER_LIBDIR)/liblwip%.a: + $(Q) $(MAKE) -C $(SMING_HOME) compiler/lib/$(notdir $@) ENABLE_CUSTOM_LWIP=2 ENABLE_ESPCONN=$(ENABLE_ESPCONN) +endif checkdirs: $(BUILD_DIR) $(FW_BASE) $(CUSTOM_TARGETS) diff --git a/Sming/Services/CommandProcessing/CommandHandler.cpp b/Sming/Services/CommandProcessing/CommandHandler.cpp index f7c0ad6154..c9c5b8f573 100644 --- a/Sming/Services/CommandProcessing/CommandHandler.cpp +++ b/Sming/Services/CommandProcessing/CommandHandler.cpp @@ -8,6 +8,10 @@ #include "CommandHandler.h" #include "CommandDelegate.h" +#ifndef LWIP_HASH_STR +#define LWIP_HASH_STR "" +#endif + CommandHandler::CommandHandler() { registeredCommands = new HashMap; @@ -138,6 +142,7 @@ void CommandHandler::procesStatusCommand(String commandLine, CommandOutput* comm commandOutput->printf("ESP SDK version : "); commandOutput->print(system_get_sdk_version()); commandOutput->printf("\r\n"); + commandOutput->printf("lwIP version : %d.%d.%d(%s)\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION, LWIP_HASH_STR); commandOutput->printf("Time = "); commandOutput->printf(SystemClock.getSystemTimeString().c_str()); commandOutput->printf("\r\n"); diff --git a/Sming/SmingCore/Network/NtpClient.cpp b/Sming/SmingCore/Network/NtpClient.cpp index 21599470a0..ad9358d674 100644 --- a/Sming/SmingCore/Network/NtpClient.cpp +++ b/Sming/SmingCore/Network/NtpClient.cpp @@ -52,7 +52,11 @@ void NtpClient::requestTime() return; } +#if LWIP_VERSION_MAJOR == 1 struct ip_addr resolvedIp; +#else + ip_addr_t resolvedIp; +#endif int result = dns_gethostbyname(this->server.c_str(), &resolvedIp, staticDnsResponse, (void*) this); @@ -174,7 +178,11 @@ void NtpClient::onReceive(pbuf *buf, IPAddress remoteIP, uint16_t remotePort) } } +#if LWIP_VERSION_MAJOR == 1 void NtpClient::staticDnsResponse(const char *name, struct ip_addr *ip, void *arg) +#else +void NtpClient::staticDnsResponse(const char *name, const ip_addr_t *ip, void *arg) +#endif { // DNS has been resolved diff --git a/Sming/SmingCore/Network/NtpClient.h b/Sming/SmingCore/Network/NtpClient.h index 57357553e1..ba1edf973b 100644 --- a/Sming/SmingCore/Network/NtpClient.h +++ b/Sming/SmingCore/Network/NtpClient.h @@ -106,7 +106,11 @@ class NtpClient : protected UdpConnection * @param arg Pointer to the NTP client object that made the DNS request * @note This function is called when a DNS query is serviced */ +#if LWIP_VERSION_MAJOR == 1 static void staticDnsResponse(const char *name, struct ip_addr *ip, void *arg); +#else + static void staticDnsResponse(const char *name, const ip_addr_t *ip, void *arg); +#endif }; /** @} */ diff --git a/Sming/SmingCore/Network/TcpConnection.cpp b/Sming/SmingCore/Network/TcpConnection.cpp index f29399a53e..ce8b342bb2 100644 --- a/Sming/SmingCore/Network/TcpConnection.cpp +++ b/Sming/SmingCore/Network/TcpConnection.cpp @@ -671,7 +671,11 @@ void TcpConnection::staticOnError(void *arg, err_t err) //debugf("irom0_0_seg :irom0_0_phdr diff --git a/Sming/system/include/arch/cc.h b/Sming/system/esp-lwip/arch/cc.h similarity index 100% rename from Sming/system/include/arch/cc.h rename to Sming/system/esp-lwip/arch/cc.h diff --git a/Sming/system/include/arch/perf.h b/Sming/system/esp-lwip/arch/perf.h similarity index 100% rename from Sming/system/include/arch/perf.h rename to Sming/system/esp-lwip/arch/perf.h diff --git a/Sming/system/include/arch/sys_arch.h b/Sming/system/esp-lwip/arch/sys_arch.h similarity index 100% rename from Sming/system/include/arch/sys_arch.h rename to Sming/system/esp-lwip/arch/sys_arch.h diff --git a/Sming/system/include/lwip/api.h b/Sming/system/esp-lwip/lwip/api.h similarity index 100% rename from Sming/system/include/lwip/api.h rename to Sming/system/esp-lwip/lwip/api.h diff --git a/Sming/system/include/lwip/api_msg.h b/Sming/system/esp-lwip/lwip/api_msg.h similarity index 100% rename from Sming/system/include/lwip/api_msg.h rename to Sming/system/esp-lwip/lwip/api_msg.h diff --git a/Sming/system/include/lwip/app/dhcpserver.h b/Sming/system/esp-lwip/lwip/app/dhcpserver.h similarity index 100% rename from Sming/system/include/lwip/app/dhcpserver.h rename to Sming/system/esp-lwip/lwip/app/dhcpserver.h diff --git a/Sming/system/include/lwip/app/espconn.h b/Sming/system/esp-lwip/lwip/app/espconn.h similarity index 100% rename from Sming/system/include/lwip/app/espconn.h rename to Sming/system/esp-lwip/lwip/app/espconn.h diff --git a/Sming/system/include/lwip/app/espconn_tcp.h b/Sming/system/esp-lwip/lwip/app/espconn_tcp.h similarity index 100% rename from Sming/system/include/lwip/app/espconn_tcp.h rename to Sming/system/esp-lwip/lwip/app/espconn_tcp.h diff --git a/Sming/system/include/lwip/app/espconn_udp.h b/Sming/system/esp-lwip/lwip/app/espconn_udp.h similarity index 100% rename from Sming/system/include/lwip/app/espconn_udp.h rename to Sming/system/esp-lwip/lwip/app/espconn_udp.h diff --git a/Sming/system/include/lwip/app/ping.h b/Sming/system/esp-lwip/lwip/app/ping.h similarity index 100% rename from Sming/system/include/lwip/app/ping.h rename to Sming/system/esp-lwip/lwip/app/ping.h diff --git a/Sming/system/include/lwip/arch.h b/Sming/system/esp-lwip/lwip/arch.h similarity index 100% rename from Sming/system/include/lwip/arch.h rename to Sming/system/esp-lwip/lwip/arch.h diff --git a/Sming/system/include/lwip/autoip.h b/Sming/system/esp-lwip/lwip/autoip.h similarity index 100% rename from Sming/system/include/lwip/autoip.h rename to Sming/system/esp-lwip/lwip/autoip.h diff --git a/Sming/system/include/lwip/debug.h b/Sming/system/esp-lwip/lwip/debug.h similarity index 100% rename from Sming/system/include/lwip/debug.h rename to Sming/system/esp-lwip/lwip/debug.h diff --git a/Sming/system/include/lwip/def.h b/Sming/system/esp-lwip/lwip/def.h similarity index 100% rename from Sming/system/include/lwip/def.h rename to Sming/system/esp-lwip/lwip/def.h diff --git a/Sming/system/include/lwip/dhcp.h b/Sming/system/esp-lwip/lwip/dhcp.h similarity index 100% rename from Sming/system/include/lwip/dhcp.h rename to Sming/system/esp-lwip/lwip/dhcp.h diff --git a/Sming/system/include/lwip/dns.h b/Sming/system/esp-lwip/lwip/dns.h similarity index 100% rename from Sming/system/include/lwip/dns.h rename to Sming/system/esp-lwip/lwip/dns.h diff --git a/Sming/system/include/lwip/err.h b/Sming/system/esp-lwip/lwip/err.h similarity index 100% rename from Sming/system/include/lwip/err.h rename to Sming/system/esp-lwip/lwip/err.h diff --git a/Sming/system/include/lwip/icmp.h b/Sming/system/esp-lwip/lwip/icmp.h similarity index 100% rename from Sming/system/include/lwip/icmp.h rename to Sming/system/esp-lwip/lwip/icmp.h diff --git a/Sming/system/include/lwip/igmp.h b/Sming/system/esp-lwip/lwip/igmp.h similarity index 100% rename from Sming/system/include/lwip/igmp.h rename to Sming/system/esp-lwip/lwip/igmp.h diff --git a/Sming/system/include/lwip/inet.h b/Sming/system/esp-lwip/lwip/inet.h similarity index 100% rename from Sming/system/include/lwip/inet.h rename to Sming/system/esp-lwip/lwip/inet.h diff --git a/Sming/system/include/lwip/inet_chksum.h b/Sming/system/esp-lwip/lwip/inet_chksum.h similarity index 100% rename from Sming/system/include/lwip/inet_chksum.h rename to Sming/system/esp-lwip/lwip/inet_chksum.h diff --git a/Sming/system/include/lwip/init.h b/Sming/system/esp-lwip/lwip/init.h similarity index 100% rename from Sming/system/include/lwip/init.h rename to Sming/system/esp-lwip/lwip/init.h diff --git a/Sming/system/include/lwip/ip.h b/Sming/system/esp-lwip/lwip/ip.h similarity index 100% rename from Sming/system/include/lwip/ip.h rename to Sming/system/esp-lwip/lwip/ip.h diff --git a/Sming/system/include/lwip/ip_addr.h b/Sming/system/esp-lwip/lwip/ip_addr.h similarity index 100% rename from Sming/system/include/lwip/ip_addr.h rename to Sming/system/esp-lwip/lwip/ip_addr.h diff --git a/Sming/system/include/lwip/ip_frag.h b/Sming/system/esp-lwip/lwip/ip_frag.h similarity index 100% rename from Sming/system/include/lwip/ip_frag.h rename to Sming/system/esp-lwip/lwip/ip_frag.h diff --git a/Sming/system/include/lwip/mem.h b/Sming/system/esp-lwip/lwip/mem.h similarity index 100% rename from Sming/system/include/lwip/mem.h rename to Sming/system/esp-lwip/lwip/mem.h diff --git a/Sming/system/include/lwip/memp.h b/Sming/system/esp-lwip/lwip/memp.h similarity index 100% rename from Sming/system/include/lwip/memp.h rename to Sming/system/esp-lwip/lwip/memp.h diff --git a/Sming/system/include/lwip/memp_std.h b/Sming/system/esp-lwip/lwip/memp_std.h similarity index 100% rename from Sming/system/include/lwip/memp_std.h rename to Sming/system/esp-lwip/lwip/memp_std.h diff --git a/Sming/system/include/lwip/netbuf.h b/Sming/system/esp-lwip/lwip/netbuf.h similarity index 100% rename from Sming/system/include/lwip/netbuf.h rename to Sming/system/esp-lwip/lwip/netbuf.h diff --git a/Sming/system/include/lwip/netdb.h b/Sming/system/esp-lwip/lwip/netdb.h similarity index 100% rename from Sming/system/include/lwip/netdb.h rename to Sming/system/esp-lwip/lwip/netdb.h diff --git a/Sming/system/include/lwip/netif.h b/Sming/system/esp-lwip/lwip/netif.h similarity index 100% rename from Sming/system/include/lwip/netif.h rename to Sming/system/esp-lwip/lwip/netif.h diff --git a/Sming/system/include/lwip/netifapi.h b/Sming/system/esp-lwip/lwip/netifapi.h similarity index 100% rename from Sming/system/include/lwip/netifapi.h rename to Sming/system/esp-lwip/lwip/netifapi.h diff --git a/Sming/system/include/lwip/opt.h b/Sming/system/esp-lwip/lwip/opt.h similarity index 100% rename from Sming/system/include/lwip/opt.h rename to Sming/system/esp-lwip/lwip/opt.h diff --git a/Sming/system/include/lwip/pbuf.h b/Sming/system/esp-lwip/lwip/pbuf.h similarity index 100% rename from Sming/system/include/lwip/pbuf.h rename to Sming/system/esp-lwip/lwip/pbuf.h diff --git a/Sming/system/include/lwip/raw.h b/Sming/system/esp-lwip/lwip/raw.h similarity index 100% rename from Sming/system/include/lwip/raw.h rename to Sming/system/esp-lwip/lwip/raw.h diff --git a/Sming/system/include/lwip/sio.h b/Sming/system/esp-lwip/lwip/sio.h similarity index 100% rename from Sming/system/include/lwip/sio.h rename to Sming/system/esp-lwip/lwip/sio.h diff --git a/Sming/system/include/lwip/snmp.h b/Sming/system/esp-lwip/lwip/snmp.h similarity index 100% rename from Sming/system/include/lwip/snmp.h rename to Sming/system/esp-lwip/lwip/snmp.h diff --git a/Sming/system/include/lwip/snmp_asn1.h b/Sming/system/esp-lwip/lwip/snmp_asn1.h similarity index 100% rename from Sming/system/include/lwip/snmp_asn1.h rename to Sming/system/esp-lwip/lwip/snmp_asn1.h diff --git a/Sming/system/include/lwip/snmp_msg.h b/Sming/system/esp-lwip/lwip/snmp_msg.h similarity index 100% rename from Sming/system/include/lwip/snmp_msg.h rename to Sming/system/esp-lwip/lwip/snmp_msg.h diff --git a/Sming/system/include/lwip/snmp_structs.h b/Sming/system/esp-lwip/lwip/snmp_structs.h similarity index 100% rename from Sming/system/include/lwip/snmp_structs.h rename to Sming/system/esp-lwip/lwip/snmp_structs.h diff --git a/Sming/system/include/lwip/sockets.h b/Sming/system/esp-lwip/lwip/sockets.h similarity index 100% rename from Sming/system/include/lwip/sockets.h rename to Sming/system/esp-lwip/lwip/sockets.h diff --git a/Sming/system/include/lwip/stats.h b/Sming/system/esp-lwip/lwip/stats.h similarity index 100% rename from Sming/system/include/lwip/stats.h rename to Sming/system/esp-lwip/lwip/stats.h diff --git a/Sming/system/include/lwip/sys.h b/Sming/system/esp-lwip/lwip/sys.h similarity index 100% rename from Sming/system/include/lwip/sys.h rename to Sming/system/esp-lwip/lwip/sys.h diff --git a/Sming/system/include/lwip/tcp.h b/Sming/system/esp-lwip/lwip/tcp.h similarity index 100% rename from Sming/system/include/lwip/tcp.h rename to Sming/system/esp-lwip/lwip/tcp.h diff --git a/Sming/system/include/lwip/tcp_impl.h b/Sming/system/esp-lwip/lwip/tcp_impl.h similarity index 100% rename from Sming/system/include/lwip/tcp_impl.h rename to Sming/system/esp-lwip/lwip/tcp_impl.h diff --git a/Sming/system/include/lwip/tcpip.h b/Sming/system/esp-lwip/lwip/tcpip.h similarity index 100% rename from Sming/system/include/lwip/tcpip.h rename to Sming/system/esp-lwip/lwip/tcpip.h diff --git a/Sming/system/include/lwip/timers.h b/Sming/system/esp-lwip/lwip/timers.h similarity index 100% rename from Sming/system/include/lwip/timers.h rename to Sming/system/esp-lwip/lwip/timers.h diff --git a/Sming/system/include/lwip/udp.h b/Sming/system/esp-lwip/lwip/udp.h similarity index 100% rename from Sming/system/include/lwip/udp.h rename to Sming/system/esp-lwip/lwip/udp.h diff --git a/Sming/system/include/lwipopts.h b/Sming/system/esp-lwip/lwipopts.h similarity index 100% rename from Sming/system/include/lwipopts.h rename to Sming/system/esp-lwip/lwipopts.h diff --git a/Sming/third-party/lwip2 b/Sming/third-party/lwip2 new file mode 160000 index 0000000000..80c63d8387 --- /dev/null +++ b/Sming/third-party/lwip2 @@ -0,0 +1 @@ +Subproject commit 80c63d83876e8baadd579bdc058218fb6eca7785