Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull Core/Network out into separate Component #2316

Merged
merged 7 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions Sming/Arch/Esp32/Components/sming-arch/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ COMPONENT_DEPENDS := \
gdbstub \
esptool

#
DISABLE_WIFI ?= 0
ifeq ($(DISABLE_WIFI),1)
GLOBAL_CFLAGS += -DDISABLE_WIFI=1
endif

# => Platform WiFi
COMPONENT_VARS := \
ENABLE_WPS \
ENABLE_SMART_CONFIG \
DISABLE_WIFI


# ELF and BIN files
DEBUG_VARS += TARGET_BIN
TARGET_OUT = $(BUILD_BASE)/$(APP_NAME).out
Expand Down
2 changes: 1 addition & 1 deletion Sming/Arch/Esp32/Components/spi_flash/include/flashmem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#pragma warning "Please update to #include <esp_spi_flash.h>"
#pragma GCC warning "Please update to #include <esp_spi_flash.h>"
#include "esp_spi_flash.h"
5 changes: 5 additions & 0 deletions Sming/Arch/Esp8266/Components/esp8266/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ FLASH_INIT_DATA_VCC = $(SDK_BASE)/bin/esp_init_data_vdd_default.bin

CUSTOM_TARGETS += $(FLASH_INIT_DATA) $(FLASH_INIT_DATA_VCC)

# => LWIP basic support required by SDK
ifeq ($(DISABLE_WIFI),1)
COMPONENT_DEPENDS += esp-lwip
endif

# => 'Internal' SDK - for SDK Version 3+ as submodule in Sming repository
# SDK_BASE just needs to point into our repo as it's overridden with the correct submodule path
# This provides backward-compatiblity, so $(SMING)/third-party/ESP8266_NONOS_SDK) still works
Expand Down
10 changes: 7 additions & 3 deletions Sming/Arch/Esp8266/Components/sming-arch/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ Default: OFF. In order to use SDK 3.0.0 or newer please follow the instructions
No-WiFi build
-------------

.. envvar:: DISABLE_WIFI
.. note::

This is an EXPERIMENTAL feature. Not all hardware functions may be available.

If a project does not require WiFi (or networking) then setting the :envvar:`DISABLE_WIFI` variable
will reduce code size and RAM usage significantly.
It does this using an un-official :component-esp8266:`esp_no_wifi` Component.

If a project does not require WiFi (or networking) bulding with this option enabled reduces code size
and memory usage signficantly. It does this using an un-official :component-esp8266:`esp_no_wifi` Component.


Custom LWIP
Expand Down
18 changes: 0 additions & 18 deletions Sming/Arch/Esp8266/Components/sming-arch/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,14 @@ COMPONENT_DEPENDS := \
gdbstub \
spi_flash

# => Platform WiFi
COMPONENT_VARS := \
ENABLE_WPS \
ENABLE_SMART_CONFIG

#
RELINK_VARS += DISABLE_WIFI
DISABLE_WIFI ?= 0
ifeq ($(DISABLE_WIFI),1)
COMPONENT_DEPENDS += esp_no_wifi
GLOBAL_CFLAGS += -DDISABLE_WIFI=1
else
COMPONENT_DEPENDS += esp_wifi
endif

# => LWIP
COMPONENT_VARS += ENABLE_CUSTOM_LWIP
ENABLE_CUSTOM_LWIP ?= 1
ifeq ($(ENABLE_CUSTOM_LWIP), 0)
COMPONENT_DEPENDS += esp-lwip
else ifeq ($(ENABLE_CUSTOM_LWIP), 1)
COMPONENT_DEPENDS += esp-open-lwip
else ifeq ($(ENABLE_CUSTOM_LWIP), 2)
COMPONENT_DEPENDS += lwip2
endif

# rBoot creates ROM images from one or both of these targets
TARGET_OUT_0 := $(BUILD_BASE)/$(APP_NAME)_0.out
TARGET_OUT_1 := $(BUILD_BASE)/$(APP_NAME)_1.out
2 changes: 1 addition & 1 deletion Sming/Arch/Esp8266/Components/spi_flash/include/flashmem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#pragma warning "Please update to #include <esp_spi_flash.h>"
#pragma GCC warning "Please update to #include <esp_spi_flash.h>"
#include "esp_spi_flash.h"
10 changes: 9 additions & 1 deletion Sming/Arch/Host/Components/hostlib/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ ifeq ($(UNAME),Windows)
EXTRA_LIBS += wsock32
endif

COMPONENT_DEPENDS := esp_wifi lwip driver spi_flash
COMPONENT_DEPENDS := \
driver \
spi_flash

ifneq ($(DISABLE_WIFI),1)
COMPONENT_DEPENDS += \
esp_wifi \
lwip
endif

COMPONENT_INCDIRS := include
COMPONENT_SRCDIRS := .
Expand Down
39 changes: 31 additions & 8 deletions Sming/Arch/Host/Components/hostlib/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <BitManipulations.h>
#include <driver/os_timer.h>
#include <esp_tasks.h>
#include <host_lwip.h>
#include <stdlib.h>
#include "include/hostlib/init.h"
#include "include/hostlib/emu.h"
Expand All @@ -40,12 +39,16 @@
#include <Platform/System.h>
#include <Platform/Timers.h>

static int exitCode = 0;
static bool done = false;
static bool lwip_initialised = false;
#ifndef DISABLE_WIFI
#include <host_lwip.h>
extern void host_wifi_lwip_init_complete();
static bool lwip_initialised;
#endif

static int exitCode;
static bool done;
static OneShotElapseTimer<NanoTime::Milliseconds> lwipServiceTimer;

extern void host_wifi_lwip_init_complete();
extern void host_init_bootloader();

static void cleanup()
Expand All @@ -54,7 +57,9 @@ static void cleanup()
host_flashmem_cleanup();
CUartServer::shutdown();
sockets_finalise();
#ifndef DISABLE_WIFI
host_lwip_shutdown();
#endif
host_debug_i("Goodbye!");
}

Expand Down Expand Up @@ -112,10 +117,12 @@ void host_main_loop()
{
host_service_tasks();
host_service_timers();
if (lwip_initialised && lwipServiceTimer.expired()) {
#ifndef DISABLE_WIFI
if(lwip_initialised && lwipServiceTimer.expired()) {
host_lwip_service();
lwipServiceTimer.start();
}
#endif
system_soft_wdt_feed();
}

Expand All @@ -130,7 +137,9 @@ int main(int argc, char* argv[])
bool enable_network;
UartServerConfig uart;
FlashmemConfig flash;
#ifndef DISABLE_WIFI
struct lwip_param lwip;
#endif
} config = {
.pause = -1,
.exitpause = -1,
Expand All @@ -147,11 +156,13 @@ int main(int argc, char* argv[])
.createSize = 0,

},
#ifndef DISABLE_WIFI
.lwip =
{
.ifname = nullptr,
.ipaddr = nullptr,
},
#endif
};

option_tag_t opt;
Expand All @@ -170,6 +181,13 @@ int main(int argc, char* argv[])
config.uart.portBase = atoi(arg);
break;

#ifdef DISABLE_WIFI
case opt_ifname:
case opt_ipaddr:
case opt_gateway:
case opt_netmask:
break;
#else
case opt_ifname:
config.lwip.ifname = arg;
break;
Expand All @@ -185,6 +203,7 @@ int main(int argc, char* argv[])
case opt_netmask:
config.lwip.netmask = arg;
break;
#endif

case opt_pause:
config.pause = arg ? atoi(arg) : 0;
Expand Down Expand Up @@ -214,7 +233,8 @@ int main(int argc, char* argv[])
host_debug_level = atoi(arg);
break;

default:;
case opt_none:
break;
}
}

Expand Down Expand Up @@ -245,7 +265,7 @@ int main(int argc, char* argv[])
sockets_initialise();
CUartServer::startup(config.uart);


#ifndef DISABLE_WIFI
if(config.enable_network) {
lwip_initialised = host_lwip_init(&config.lwip);
if(lwip_initialised) {
Expand All @@ -254,6 +274,7 @@ int main(int argc, char* argv[])
} else {
host_debug_i("Network initialisation skipped as requested");
}
#endif

host_debug_i("If required, you may start terminal application(s) now");
pause(config.pause);
Expand All @@ -264,7 +285,9 @@ int main(int argc, char* argv[])

host_init();

#ifndef DISABLE_WIFI
lwipServiceTimer.reset<LWIP_SERVICE_INTERVAL>();
#endif
while(!done) {
host_main_loop();
}
Expand Down
8 changes: 0 additions & 8 deletions Sming/Arch/Host/Components/sming-arch/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ COMPONENT_INCDIRS := \
COMPONENT_DEPENDS := \
driver \
esp_hal \
esp_wifi \
gdbstub \
heap \
hostlib \
libc \
lwip \
spi_flash \
vflash \
rboot


ifneq ($(ENABLE_HOSTED),)
COMPONENT_DEPENDS += Hosted-Lib
endif

# => Platform WiFi
COMPONENT_VARS := \
ENABLE_WPS \
ENABLE_SMART_CONFIG
2 changes: 1 addition & 1 deletion Sming/Arch/Host/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For Linux, you may require the ``gcc-multilib`` and ``g++-multilib``
packages to build 32-bit executables on a 64-bit OS.

For Windows, make sure your ``MinGW`` distro is up to date.
See :doc:`/getting-started/windows` for further details.
See :doc:`/getting-started/windows/index` for further details.

Building
--------
Expand Down
2 changes: 2 additions & 0 deletions Sming/Arch/Host/System/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include <stringconversion.h>

// Network base API
#ifndef DISABLE_WIFI
#include <lwip/init.h>
#include <lwip/debug.h>
#include <lwip/stats.h>
#include <lwip/tcp.h>
#include <lwip/udp.h>
#include <lwip/dns.h>
#endif

#endif /* __USER_CONFIG_H__ */
19 changes: 19 additions & 0 deletions Sming/Components/Network/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Networking Support
==================

Contains core networking protocol support classes.

.. toctree::
:glob:
:maxdepth: 1

*

Other networking libraries:

- :library:`GoogleCast`
- :library:`MDNS`
- :library:`SSDP`
- :component:`ssl`
- :library:`UPnP`
- :library:`UPnP-Schema`
60 changes: 60 additions & 0 deletions Sming/Components/Network/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
COMPONENT_SRCDIRS := \
src \
$(call ListAllSubDirs,$(COMPONENT_PATH)/src) \
$(call ListAllSubDirs,$(COMPONENT_PATH)/Arch/$(SMING_ARCH))

COMPONENT_INCDIRS := src

COMPONENT_DOXYGEN_INPUT := src

COMPONENT_DEPENDS := \
ssl \
http-parser \
libb64 \
ws_parser \
mqtt-codec \
libyuarel

# => WPS
COMPONENT_VARS += ENABLE_WPS
ifeq ($(ENABLE_WPS), 1)
GLOBAL_CFLAGS += -DENABLE_WPS=1
endif

# => Smart Config
COMPONENT_VARS += ENABLE_SMART_CONFIG
ifeq ($(ENABLE_SMART_CONFIG),1)
GLOBAL_CFLAGS += -DENABLE_SMART_CONFIG=1
endif

# => HTTP server
COMPONENT_VARS += HTTP_SERVER_EXPOSE_NAME
HTTP_SERVER_EXPOSE_NAME ?= 1
GLOBAL_CFLAGS += -DHTTP_SERVER_EXPOSE_NAME=$(HTTP_SERVER_EXPOSE_NAME)

COMPONENT_VARS += HTTP_SERVER_EXPOSE_VERSION
HTTP_SERVER_EXPOSE_VERSION ?= 0
GLOBAL_CFLAGS += -DHTTP_SERVER_EXPOSE_VERSION=$(HTTP_SERVER_EXPOSE_VERSION)



# => LWIP
COMPONENT_VARS += ENABLE_CUSTOM_LWIP
ifeq ($(SMING_ARCH),Esp8266)

ENABLE_CUSTOM_LWIP ?= 1
ifeq ($(ENABLE_CUSTOM_LWIP), 0)
COMPONENT_DEPENDS += esp-lwip
else ifeq ($(ENABLE_CUSTOM_LWIP), 1)
COMPONENT_DEPENDS += esp-open-lwip
else ifeq ($(ENABLE_CUSTOM_LWIP), 2)
COMPONENT_DEPENDS += lwip2
endif

else ifeq ($(SMING_ARCH),Host)

COMPONENT_DEPENDS += \
esp_wifi \
lwip

endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*
****/

#include "MultipartStream.h"
#include "MemoryDataStream.h"
#include <Data/Stream/MultipartStream.h>
#include <Data/Stream/MemoryDataStream.h>

IDataSourceStream* MultipartStream::getNextStream()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#pragma once

#include "MemoryDataStream.h"
#include <Data/Stream/MemoryDataStream.h>
#include "Network/Http/HttpParams.h"

/**
Expand Down
File renamed without changes.
File renamed without changes.
Loading