From 9a9e850623b6a29684233c90a266b798a223239f Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Sat, 25 Dec 2021 11:30:45 +0100 Subject: [PATCH] Updates. --- .gitmodules | 1 - .../Esp32/Components/esp32/sdk/config/debug | 29 +++ .../Esp32/Components/esp32/sdk/config/release | 22 ++ .../Esp32/Components/spi_flash/flashmem.cpp | 1 - Sming/Arch/Esp32/Core/Interrupts.cpp | 3 - Sming/Arch/Esp32/Tools/install.sh | 0 Sming/Arch/Esp32/app.mk | 5 - .../driver/include/driver/os_timer.h | 6 - Sming/Arch/Esp8266/build.mk | 4 - Sming/Arch/Host/build.mk | 4 - Sming/Libraries/simpleRPC/component.mk | 6 - .../Libraries/simpleRPC/include/simpleRPC/.cs | 0 .../simpleRPC/include/simpleRPC/parser.h | 63 ------ Sming/Libraries/simpleRPC/simpleRPC | 1 - Sming/Libraries/simpleRPC/simpleRPC.patch | 65 ------ Sming/Libraries/simpleRPC/src/.cs | 0 Sming/Libraries/simpleRPC/src/parser.cpp | 195 ---------------- Sming/build.mk | 11 - Sming/project.mk | 3 - samples/Basic_Ethernet/.cproject | 151 ------------- samples/Basic_Ethernet/.project | 28 --- samples/Basic_Ota/app/application.cpp | 210 ++++++++++++++++++ samples/Basic_Storage/basic_storage_2m.hw | 28 --- samples/HttpServer_Plugins/.cproject | 151 ------------- samples/HttpServer_Plugins/.project | 28 --- tests/HostTests/Arch/Host/Hosted.cpp | 155 ------------- tests/HostTests/Arch/Host/TcpClient.cpp | 102 --------- tests/HostTests/modules/Stream.cpp | 13 -- 28 files changed, 261 insertions(+), 1024 deletions(-) create mode 100644 Sming/Arch/Esp32/Components/esp32/sdk/config/debug create mode 100644 Sming/Arch/Esp32/Components/esp32/sdk/config/release mode change 100644 => 100755 Sming/Arch/Esp32/Tools/install.sh delete mode 100644 Sming/Libraries/simpleRPC/component.mk delete mode 100644 Sming/Libraries/simpleRPC/include/simpleRPC/.cs delete mode 100644 Sming/Libraries/simpleRPC/include/simpleRPC/parser.h delete mode 160000 Sming/Libraries/simpleRPC/simpleRPC delete mode 100644 Sming/Libraries/simpleRPC/simpleRPC.patch delete mode 100644 Sming/Libraries/simpleRPC/src/.cs delete mode 100644 Sming/Libraries/simpleRPC/src/parser.cpp delete mode 100644 samples/Basic_Ethernet/.cproject delete mode 100644 samples/Basic_Ethernet/.project create mode 100644 samples/Basic_Ota/app/application.cpp delete mode 100644 samples/Basic_Storage/basic_storage_2m.hw delete mode 100644 samples/HttpServer_Plugins/.cproject delete mode 100644 samples/HttpServer_Plugins/.project delete mode 100644 tests/HostTests/Arch/Host/Hosted.cpp delete mode 100644 tests/HostTests/Arch/Host/TcpClient.cpp diff --git a/.gitmodules b/.gitmodules index f617104431..f2d502425f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -369,4 +369,3 @@ # END OF .gitmodules # ################################################################################################# - diff --git a/Sming/Arch/Esp32/Components/esp32/sdk/config/debug b/Sming/Arch/Esp32/Components/esp32/sdk/config/debug new file mode 100644 index 0000000000..c74a1e37de --- /dev/null +++ b/Sming/Arch/Esp32/Components/esp32/sdk/config/debug @@ -0,0 +1,29 @@ +# +# DEBUG +# + +# The bootloader logs all type of messages +CONFIG_BOOTLOADER_LOG_LEVEL_NONE= +CONFIG_BOOTLOADER_LOG_LEVEL_ERROR= +CONFIG_BOOTLOADER_LOG_LEVEL_WARN= +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= +CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= +CONFIG_BOOTLOADER_LOG_LEVEL=3 + +# ESP-IDF logs all type of messages +CONFIG_LOG_DEFAULT_LEVEL_NONE= +CONFIG_LOG_DEFAULT_LEVEL_ERROR= +CONFIG_LOG_DEFAULT_LEVEL_WARN= +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +CONFIG_LOG_DEFAULT_LEVEL_DEBUG= +CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= +CONFIG_LOG_DEFAULT_LEVEL=3 + +# Sets watchpoint index 1 (the second of two) at the end of any task stack. This is the most accurate way to debug task stack overflows. +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y + +# Used by TaskStat class to track task usage +CONFIG_FREERTOS_USE_TRACE_FACILITY=y +CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y +CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y diff --git a/Sming/Arch/Esp32/Components/esp32/sdk/config/release b/Sming/Arch/Esp32/Components/esp32/sdk/config/release new file mode 100644 index 0000000000..f130372a9e --- /dev/null +++ b/Sming/Arch/Esp32/Components/esp32/sdk/config/release @@ -0,0 +1,22 @@ +# +# RELEASE +# + +# The bootloader logs only errors +CONFIG_BOOTLOADER_LOG_LEVEL_NONE= +CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y +CONFIG_BOOTLOADER_LOG_LEVEL_WARN= +CONFIG_BOOTLOADER_LOG_LEVEL_INFO= +CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG= +CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE= +CONFIG_BOOTLOADER_LOG_LEVEL=1 + +# ESP-IDF logs only errors +CONFIG_LOG_DEFAULT_LEVEL_NONE= +CONFIG_LOG_DEFAULT_LEVEL_ERROR=y +CONFIG_LOG_DEFAULT_LEVEL_WARN= +CONFIG_LOG_DEFAULT_LEVEL_INFO= +CONFIG_LOG_DEFAULT_LEVEL_DEBUG= +CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= +CONFIG_LOG_DEFAULT_LEVEL=1 + diff --git a/Sming/Arch/Esp32/Components/spi_flash/flashmem.cpp b/Sming/Arch/Esp32/Components/spi_flash/flashmem.cpp index 7bb869775f..982cd85036 100644 --- a/Sming/Arch/Esp32/Components/spi_flash/flashmem.cpp +++ b/Sming/Arch/Esp32/Components/spi_flash/flashmem.cpp @@ -8,7 +8,6 @@ * ****/ -#include #include #include #include diff --git a/Sming/Arch/Esp32/Core/Interrupts.cpp b/Sming/Arch/Esp32/Core/Interrupts.cpp index 3deac44c4d..280addb4bf 100644 --- a/Sming/Arch/Esp32/Core/Interrupts.cpp +++ b/Sming/Arch/Esp32/Core/Interrupts.cpp @@ -15,9 +15,6 @@ #include #include -#define gpio_drive_cap_t uint32_t -#include - constexpr unsigned MAX_INTERRUPTS = 40; static intr_handle_t interruptHandle = nullptr; diff --git a/Sming/Arch/Esp32/Tools/install.sh b/Sming/Arch/Esp32/Tools/install.sh old mode 100644 new mode 100755 diff --git a/Sming/Arch/Esp32/app.mk b/Sming/Arch/Esp32/app.mk index 05846d47a8..a2ffcaa001 100644 --- a/Sming/Arch/Esp32/app.mk +++ b/Sming/Arch/Esp32/app.mk @@ -24,10 +24,5 @@ ifeq ($(CHIP_REV_MIN),) CHIP_REV_MIN := 0 endif -CHIP_REV_MIN := $(CONFIG_$(call ToUpper,$(ESP_VARIANT))_REV_MIN) -ifeq ($(CHIP_REV_MIN),) -CHIP_REV_MIN := 0 -endif - $(TARGET_BIN): $(TARGET_OUT) $(Q) $(ESPTOOL_CMDLINE) elf2image --min-rev $(CHIP_REV_MIN) --elf-sha256-offset 0xb0 $(flashimageoptions) -o $@ $< diff --git a/Sming/Arch/Esp8266/Components/driver/include/driver/os_timer.h b/Sming/Arch/Esp8266/Components/driver/include/driver/os_timer.h index 7598a8821e..57f45b0896 100644 --- a/Sming/Arch/Esp8266/Components/driver/include/driver/os_timer.h +++ b/Sming/Arch/Esp8266/Components/driver/include/driver/os_timer.h @@ -16,12 +16,6 @@ #include -// Disarmed -#define OS_TIMER_DEFAULT() \ - { \ - .timer_next = (os_timer_t*)-1, \ - } - // Disarmed #define OS_TIMER_DEFAULT() \ { \ diff --git a/Sming/Arch/Esp8266/build.mk b/Sming/Arch/Esp8266/build.mk index 707eb8483e..a094406823 100644 --- a/Sming/Arch/Esp8266/build.mk +++ b/Sming/Arch/Esp8266/build.mk @@ -4,10 +4,6 @@ # ############## -ifdef ESP_VARIANT -override ESP_VARIANT := -endif - CPPFLAGS += -DARCH_ESP8266 CXXFLAGS += -fno-threadsafe-statics diff --git a/Sming/Arch/Host/build.mk b/Sming/Arch/Host/build.mk index 90b27d0569..171b724b81 100644 --- a/Sming/Arch/Host/build.mk +++ b/Sming/Arch/Host/build.mk @@ -4,10 +4,6 @@ # ############## -ifdef ESP_VARIANT -override ESP_VARIANT := -endif - CPPFLAGS += -DARCH_HOST TOOLSPEC := diff --git a/Sming/Libraries/simpleRPC/component.mk b/Sming/Libraries/simpleRPC/component.mk deleted file mode 100644 index 4fd217ca80..0000000000 --- a/Sming/Libraries/simpleRPC/component.mk +++ /dev/null @@ -1,6 +0,0 @@ -COMPONENT_SUBMODULES += simpleRPC - -SIMPLE_RPC_ROOT := $(COMPONENT_PATH)/simpleRPC - -COMPONENT_SRCDIRS := $(SIMPLE_RPC_ROOT)/src $(COMPONENT_PATH)/src -COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) $(COMPONENT_PATH)/include diff --git a/Sming/Libraries/simpleRPC/include/simpleRPC/.cs b/Sming/Libraries/simpleRPC/include/simpleRPC/.cs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Sming/Libraries/simpleRPC/include/simpleRPC/parser.h b/Sming/Libraries/simpleRPC/include/simpleRPC/parser.h deleted file mode 100644 index a1ce2e336e..0000000000 --- a/Sming/Libraries/simpleRPC/include/simpleRPC/parser.h +++ /dev/null @@ -1,63 +0,0 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * parser.h - * - * @author 2021 Slavey Karadzhov - * - * - ****/ - -#pragma once - -#include - -namespace simpleRPC -{ -enum class ParserResult { finished = 0, more, error }; - -enum class ParserState { - ready = 0, - header_s, - header_si, - header_sim, - header_simp, - header_simpl, - header_simple, - header_simpleR, - header_simpleRP, - header_simpleRPC, - header_end, - version_major, - version_minor, - version_patch, - ness, - type, - type_end, - start_methods, - extract_method_start, - extract_method_name, - extract_method, - extract_method_end, - end_methods, - finished -}; - -struct ParserSettings { - using SimpleMethod = Delegate; - using CharMethod = Delegate; - - SimpleMethod startMethods; - SimpleMethod startMethod; - CharMethod methodName; - SimpleMethod endMethod; - SimpleMethod endMethods; - ParserState state = ParserState::ready; -}; - -ParserResult parse(ParserSettings& settings, const char* buffer, size_t length); - -} // namespace simpleRPC diff --git a/Sming/Libraries/simpleRPC/simpleRPC b/Sming/Libraries/simpleRPC/simpleRPC deleted file mode 160000 index 5696f34c42..0000000000 --- a/Sming/Libraries/simpleRPC/simpleRPC +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5696f34c429c4e87721ebdb191b21c2ea0f23791 diff --git a/Sming/Libraries/simpleRPC/simpleRPC.patch b/Sming/Libraries/simpleRPC/simpleRPC.patch deleted file mode 100644 index ba6edc8500..0000000000 --- a/Sming/Libraries/simpleRPC/simpleRPC.patch +++ /dev/null @@ -1,65 +0,0 @@ -diff --git a/src/read.tcc b/src/read.tcc -index 2e5810f..513d691 100644 ---- a/src/read.tcc -+++ b/src/read.tcc -@@ -3,7 +3,6 @@ - - #include "defs.h" - #include "tuple.tcc" --#include "vector.tcc" - - //! \defgroup read - -diff --git a/src/signature.tcc b/src/signature.tcc -index 00f5eb1..f3a675d 100644 ---- a/src/signature.tcc -+++ b/src/signature.tcc -@@ -25,7 +25,7 @@ void _parameterTypes(Stream& io, void (*f_)(H, Tail...)) { - * `rpcTypeOf()` to encode its type. The first parameter type `H` is removed - * from function pointer `*f_` in the recursive call. - */ -- H data; -+ H data{}; - - rpcPrint(io, ' '); - rpcTypeOf(io, data); -@@ -49,13 +49,13 @@ void _parameterTypes(Stream& io, void (*f_)(H&, Tail...)) { - */ - template - void signature(Stream& io, R (*f)(FArgs...)) { -- /* -+ /* - * A dummy function pointer is prepared, referred to as `f_` in the template - * functions above, which will be used to isolate parameter types. The return - * type of this function pointer is removed to avoid unneeded template - * expansion. - */ -- R data; -+ R data{}; - - rpcTypeOf(io, data); - rpcPrint(io, ':'); -diff --git a/src/types.tcc b/src/types.tcc -index 651fb38..8a7cfa5 100644 ---- a/src/types.tcc -+++ b/src/types.tcc -@@ -3,7 +3,6 @@ - - #include "print.tcc" - #include "tuple.tcc" --#include "vector.tcc" - - //! \defgroup types - -diff --git a/src/write.tcc b/src/write.tcc -index d51cdd1..abf1e7b 100644 ---- a/src/write.tcc -+++ b/src/write.tcc -@@ -3,7 +3,6 @@ - - #include "print.tcc" - #include "tuple.tcc" --#include "vector.tcc" - - //! \defgroup write - diff --git a/Sming/Libraries/simpleRPC/src/.cs b/Sming/Libraries/simpleRPC/src/.cs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Sming/Libraries/simpleRPC/src/parser.cpp b/Sming/Libraries/simpleRPC/src/parser.cpp deleted file mode 100644 index 7be4f8183c..0000000000 --- a/Sming/Libraries/simpleRPC/src/parser.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**** - * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. - * Created 2015 by Skurydin Alexey - * http://github.com/SmingHub/Sming - * All files of the Sming Core are provided under the LGPL v3 license. - * - * parser.cpp - * - * @author 2021 Slavey Karadzhov - * - * - ****/ - -#include "../include/simpleRPC/parser.h" - -namespace simpleRPC -{ -#define EXPECT(X, NEW_STATE) \ - { \ - if(ch != X) { \ - hasError = true; \ - goto ERROR; \ - } \ - state = NEW_STATE; \ - break; \ - } - -#define SKIP_UNTIL(X, NEW_STATE) \ - { \ - if(ch != X) { \ - break; \ - } \ - state = NEW_STATE; \ - } - -ParserResult parse(ParserSettings& settings, const char* buffer, size_t length) -{ - auto& state = settings.state; - /* - * See: https://simplerpc.readthedocs.io/en/latest/protocol.html# -00000000 ff . - 00000000 73 s - 00000001 69 i - 00000002 6d m - 00000003 70 p - 00000004 6c l - 00000005 65 e - 00000006 52 R - 00000007 50 P - 00000008 43 C - 00000009 00 . - 0000000A 03 00 00 ... - 3c < - 49 I - 00 . - 3a 20 : - 3a 20 48 20 42 3b 70 69 6e 4d ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - -f ${ProjDirPath}/Makefile - all - true - true - true - - - make - -f ${ProjDirPath}/Makefile - clean - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flash - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flashonefile - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flashinit - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flashboot - true - true - true - - - make - -f ${ProjDirPath}/Makefile - rebuild - true - true - true - - - - - - - - - - - - - - - - - - - - diff --git a/samples/Basic_Ethernet/.project b/samples/Basic_Ethernet/.project deleted file mode 100644 index ded68cb818..0000000000 --- a/samples/Basic_Ethernet/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - Basic_Ethernet - - - SmingFramework - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/samples/Basic_Ota/app/application.cpp b/samples/Basic_Ota/app/application.cpp new file mode 100644 index 0000000000..7d8283b18a --- /dev/null +++ b/samples/Basic_Ota/app/application.cpp @@ -0,0 +1,210 @@ +#include +#include +#include +#include +#include + +// If you want, you can define WiFi settings globally in Eclipse Environment Variables +#ifndef WIFI_SSID +#define WIFI_SSID "PleaseEnterSSID" // Put your SSID and password here +#define WIFI_PWD "PleaseEnterPass" +#endif + +Ota::Network::HttpUpgrader* otaUpdater; +Storage::Partition spiffsPartition; +OtaUpgrader ota; + +Storage::Partition findSpiffsPartition(Storage::Partition partition) +{ + String name = F("spiffs"); + name += ota.getSlot(partition); + auto part = Storage::findPartition(name); + if(!part) { + debug_w("Partition '%s' not found", name.c_str()); + } + return part; +} + +void upgradeCallback(Ota::Network::HttpUpgrader& client, bool result) +{ + Serial.println("In callback..."); + if(result == true) { + // success + ota.end(); + + auto part = ota.getNextBootPartition(); + // set to boot new rom and then reboot + Serial.printf(_F("Firmware updated, rebooting to %s @ ...\r\n"), part.name().c_str()); + ota.setBootPartition(part); + System.restart(); + } else { + ota.abort(); + // fail + Serial.println(_F("Firmware update failed!")); + } +} + +void doUpgrade() +{ + Serial.println(F("Updating...")); + + // need a clean object, otherwise if run before and failed will not run again + if(otaUpdater) { + delete otaUpdater; + } + otaUpdater = new Ota::Network::HttpUpgrader(); + + // select rom slot to flash + auto part = ota.getNextBootPartition(); + +#ifndef RBOOT_TWO_ROMS + // flash rom to position indicated in the rBoot config rom table + otaUpdater->addItem(ROM_0_URL, part); +#else + // flash appropriate ROM + otaUpdater->addItem((ota.getSlot(part) == 0) ? ROM_0_URL : ROM_1_URL, part); +#endif + + ota.begin(part); + + auto spiffsPart = findSpiffsPartition(part); + if(spiffsPart) { + // use user supplied values (defaults for 4mb flash in hardware config) + otaUpdater->addItem(SPIFFS_URL, spiffsPart, new Storage::PartitionStream(spiffsPart)); + } + + // request switch and reboot on success + //otaUpdater->switchToRom(slot); + // and/or set a callback (called on failure or success without switching requested) + otaUpdater->setCallback(upgradeCallback); + + // start update + otaUpdater->start(); +} + +void doSwitch() +{ + auto before = ota.getRunningPartition(); + auto after = ota.getNextBootPartition(); + + Serial.printf(_F("Swapping from %s @ 0x%08x to %s @ 0x%08x.\r\n"), before.name().c_str(), before.address(), + after.name().c_str(), after.address()); + if(ota.setBootPartition(after)) { + Serial.println(F("Restarting...\r\n")); + System.restart(); + } else { + Serial.println(F("Switch failed.")); + } +} + +void showInfo() +{ + Serial.printf(_F("\r\nSDK: v%s\r\n"), system_get_sdk_version()); + Serial.printf(_F("Free Heap: %lu\r\n"), system_get_free_heap_size()); + Serial.printf(_F("CPU Frequency: %lu MHz\r\n"), system_get_cpu_freq()); + Serial.printf(_F("System Chip ID: %lx\r\n"), system_get_chip_id()); + Serial.printf(_F("SPI Flash ID: %lx\r\n"), Storage::spiFlash->getId()); + Serial.printf(_F("SPI Flash Size: %ux\r\n"), Storage::spiFlash->getSize()); + + auto before = ota.getRunningPartition(); + auto after = ota.getNextBootPartition(); + + Serial.printf(_F("Current %s @ 0x%08lx, future %s @ 0x%0l8x\r\n"), before.name().c_str(), before.address(), + after.name().c_str(), after.address()); +} + +void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCharsCount) +{ + int pos = stream.indexOf('\n'); + if(pos > -1) { + char str[pos + 1]; + for(int i = 0; i < pos + 1; i++) { + str[i] = stream.read(); + if(str[i] == '\r' || str[i] == '\n') { + str[i] = '\0'; + } + } + + if(!strcmp(str, "connect")) { + // connect to wifi + WifiStation.config(WIFI_SSID, WIFI_PWD); + WifiStation.enable(true); + WifiStation.connect(); + } else if(!strcmp(str, "ip")) { + Serial.print("ip: "); + Serial.print(WifiStation.getIP()); + Serial.print(" mac: "); + Serial.println(WifiStation.getMacAddress()); + } else if(!strcmp(str, "ota")) { + doUpgrade(); + } else if(!strcmp(str, "switch")) { + doSwitch(); + } else if(!strcmp(str, "restart")) { + System.restart(); + } else if(!strcmp(str, "ls")) { + Directory dir; + if(dir.open()) { + while(dir.next()) { + Serial.print(" "); + Serial.println(dir.stat().name); + } + } + Serial.printf(_F("filecount %u\r\n"), dir.count()); + } else if(!strcmp(str, "cat")) { + Directory dir; + if(dir.open() && dir.next()) { + auto filename = dir.stat().name.c_str(); + Serial.printf("dumping file %s:\r\n", filename); + // We don't know how big the is, so streaming it is safest + FileStream fs; + fs.open(filename); + Serial.copyFrom(&fs); + Serial.println(); + } else { + Serial.println(F("Empty spiffs!")); + } + } else if(!strcmp(str, "info")) { + showInfo(); + } else if(!strcmp(str, "help")) { + Serial.println(); + Serial.println(F("available commands:")); + Serial.println(F(" help - display this message")); + Serial.println(F(" ip - show current ip address")); + Serial.println(F(" connect - connect to wifi")); + Serial.println(F(" restart - restart the device")); + Serial.println(F(" switch - switch to the other rom and reboot")); + Serial.println(F(" ota - perform ota update, switch rom and reboot")); + Serial.println(F(" info - show device info")); + if(spiffsPartition) { + Serial.println(F(" ls - list files in spiffs")); + Serial.println(F(" cat - show first file in spiffs")); + } + Serial.println(); + } else { + Serial.println("unknown command"); + } + } +} + +void init() +{ + Serial.begin(SERIAL_BAUD_RATE); // 115200 by default + Serial.systemDebugOutput(true); // Debug output to serial + + // mount spiffs + auto partition = ota.getRunningPartition(); + spiffsPartition = findSpiffsPartition(partition); + if(spiffsPartition) { + debugf("trying to mount %s @ 0x%08x, length %d", spiffsPartition.name().c_str(), spiffsPartition.address(), + spiffsPartition.size()); + spiffs_mount(spiffsPartition); + } + + WifiAccessPoint.enable(false); + + Serial.printf(_F("\r\nCurrently running %s @ 0x%08lx.\r\n"), partition.name().c_str(), partition.address()); + Serial.println(F("Type 'help' and press enter for instructions.")); + Serial.println(); + + Serial.onDataReceived(serialCallBack); +} diff --git a/samples/Basic_Storage/basic_storage_2m.hw b/samples/Basic_Storage/basic_storage_2m.hw deleted file mode 100644 index bdbae34b1c..0000000000 --- a/samples/Basic_Storage/basic_storage_2m.hw +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "Basic Storage sample (2M)", - "base_config": "basic_storage", - "devices": { - "spiFlash": { - "size": "2M" - } - }, - "partitions": { - "user0": { - "address": "0x000fa000" - }, - "user1": { - "address": "0x000fe000" - }, - "spiffs0": { - "address": "0x00102000" - }, - "spiffs1": { - "address": "0x00182000", - "size": "240K" - }, - "spiffs2": { - "address": "0x001be000", - "size": "216K" - } - } -} \ No newline at end of file diff --git a/samples/HttpServer_Plugins/.cproject b/samples/HttpServer_Plugins/.cproject deleted file mode 100644 index e6469c9e2f..0000000000 --- a/samples/HttpServer_Plugins/.cproject +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - -f ${ProjDirPath}/Makefile - all - true - true - true - - - make - -f ${ProjDirPath}/Makefile - clean - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flash - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flashonefile - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flashinit - true - true - true - - - make - -f ${ProjDirPath}/Makefile - flashboot - true - true - true - - - make - -f ${ProjDirPath}/Makefile - rebuild - true - true - true - - - - - - - - - - - - - - - - - - - - diff --git a/samples/HttpServer_Plugins/.project b/samples/HttpServer_Plugins/.project deleted file mode 100644 index 67c872c77a..0000000000 --- a/samples/HttpServer_Plugins/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - HttpServer_Plugins - - - SmingFramework - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/tests/HostTests/Arch/Host/Hosted.cpp b/tests/HostTests/Arch/Host/Hosted.cpp deleted file mode 100644 index 24d48af805..0000000000 --- a/tests/HostTests/Arch/Host/Hosted.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include - -using namespace simpleRPC; - -static uint32_t plusCommand(uint8_t a, uint16_t b) -{ - return a + b; -}; - -class HostedTest : public TestGroup -{ -public: - using RemoteCommands = HashMap; - - HostedTest() : TestGroup(_F("Hosted")) - { - } - - void execute() override - { - char packet[] = { - 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x50, 0x43, 0x00, 0x03, 0x00, 0x00, 0x3c, 0x49, 0x00, 0x3a, 0x20, - 0x48, 0x20, 0x42, 0x3b, 0x70, 0x69, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x3a, 0x20, 0x53, 0x65, 0x74, 0x73, 0x20, - 0x6d, 0x6f, 0x64, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x70, 0x69, - 0x6e, 0x2e, 0x20, 0x40, 0x70, 0x69, 0x6e, 0x3a, 0x20, 0x50, 0x69, 0x6e, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x2c, 0x20, 0x40, 0x6d, 0x6f, 0x64, 0x65, 0x3a, 0x20, 0x4d, 0x6f, 0x64, 0x65, 0x20, 0x74, 0x79, 0x70, - 0x65, 0x2e, 0x00, 0x42, 0x3a, 0x20, 0x48, 0x3b, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x61, - 0x64, 0x3a, 0x20, 0x52, 0x65, 0x61, 0x64, 0x20, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x70, 0x69, - 0x6e, 0x2e, 0x20, 0x40, 0x70, 0x69, 0x6e, 0x3a, 0x20, 0x50, 0x69, 0x6e, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x2e, 0x20, 0x40, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x3a, 0x20, 0x50, 0x69, 0x6e, 0x20, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x2e, 0x00, 0x3a, 0x20, 0x48, 0x20, 0x42, 0x3b, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, - 0x57, 0x72, 0x69, 0x74, 0x65, 0x3a, 0x20, 0x57, 0x72, 0x69, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x20, - 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x70, 0x69, 0x6e, 0x2e, 0x20, 0x40, 0x70, 0x69, 0x6e, 0x3a, - 0x20, 0x50, 0x69, 0x6e, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x2e, 0x20, 0x40, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x20, 0x50, 0x69, 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x00, 0x00}; - - ParserSettings settings; - settings.startMethods = ParserSettings::SimpleMethod(&HostedTest::startMethods, this); - settings.startMethod = ParserSettings::SimpleMethod(&HostedTest::startMethod, this); - settings.methodName = ParserSettings::CharMethod(&HostedTest::methodName, this); - settings.endMethod = ParserSettings::SimpleMethod(&HostedTest::endMethod, this); - settings.endMethods = ParserSettings::SimpleMethod(&HostedTest::endMethods, this); - settings.state = ParserState::ready; - - TEST_CASE("simpleRPC::parse()") - { - REQUIRE(parse(settings, packet, sizeof(packet)) == ParserResult::finished); - REQUIRE(commands.count() == 3); - REQUIRE(commands["digitalWrite"] == 2); - REQUIRE(commands["pinMode"] != 2); - REQUIRE(commands["pinMode"] == 0); - } - - if(!WifiStation.isConnected()) { - Serial.println("No network, skipping tests"); - return; - } - - // RPC Server - server = new TcpServer(); - server->listen(4031); - server->setTimeOut(USHRT_MAX); // disable connection timeout - server->setKeepAlive(USHRT_MAX); // disable connection timeout - - Hosted::Transport::TcpServerTransport transport(*server); - transport.onData([](Stream& stream) { - // clang-format off - interface(stream, - /* - * Below we are exporting the following remote commands: - * - pinMode - * - digitalRead - * - digitalWrite - * You can add more commands here. For every command you should specify command and text description in the format below. - * For more information read the SimpleRPC interface API: https://simplerpc.readthedocs.io/en/latest/api/interface.html - */ - pinMode, "pinMode: Sets mode of digital pin. @pin: Pin number, @mode: Mode type.", - digitalRead, "digitalRead: Read digital pin. @pin: Pin number. @return: Pin value.", - plusCommand, "plusCommand: Sum two numbers. @a: number one. @b: number two." - ); - // clang-format on - - return true; - }); - - // RCP Client - - client.connect(WifiStation.getIP(), 4031); - Hosted::Transport::TcpClientStream stream(client, 1024); - - Hosted::Client hostedClient(stream); - - TEST_CASE("Client::getRemoteCommands()") - { - REQUIRE(hostedClient.getRemoteCommands() == true); - REQUIRE(hostedClient.getFunctionId("plusCommand") == 2); - } - - TEST_CASE("Client::send and wait()") - { - ElapseTimer timer; - - REQUIRE(hostedClient.send("plusCommand", uint8_t(3), uint16_t(2)) == true); - REQUIRE(hostedClient.wait() == 5); - - debug_i("PlusCommand Roundtrip Time: %s", timer.elapsedTime().toString().c_str()); - } - } - -private: - RemoteCommands commands; - uint8_t methodPosition = 0; - String parsedCommand; - - TcpServer* server{nullptr}; - TcpClient client{false}; - Hosted::Transport::TcpClientStream* stream{nullptr}; - - void startMethods() - { - methodPosition = 0; - commands.clear(); - } - - void startMethod() - { - parsedCommand = ""; - } - - void methodName(char ch) - { - parsedCommand += ch; - } - - void endMethod() - { - commands[parsedCommand] = methodPosition++; - } - - void endMethods() - { - } -}; - -void REGISTER_TEST(Hosted) -{ - registerGroup(); -} diff --git a/tests/HostTests/Arch/Host/TcpClient.cpp b/tests/HostTests/Arch/Host/TcpClient.cpp deleted file mode 100644 index 0a9a9383ef..0000000000 --- a/tests/HostTests/Arch/Host/TcpClient.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include - -#include -#include -#include -#include - -class TcpClientTest : public TestGroup -{ -public: - TcpClientTest() : TestGroup(_F("TcpClient")) - { - } - - void execute() override - { - if(!WifiStation.isConnected()) { - Serial.println("No network, skipping tests"); - return; - } - - constexpr int port = 9876; - String inputData = "This is very long and complex text that will be sent using multiple complicated streams."; - - // Tcp Server - server = new TcpServer( - [this](TcpClient& client, char* data, int size) -> bool { - // on data - return receivedData.concat(data, size); - }, - [this, inputData](TcpClient& client, bool successful) { - // on client close - if(finished) { - return; - } - REQUIRE(successful == true); - REQUIRE(receivedData == inputData); - finished = true; - shutdown(); - }); - server->listen(port); - server->setTimeOut(USHRT_MAX); // disable connection timeout - server->setKeepAlive(USHRT_MAX); // disable connection timeout - - // Tcp Client - bool connected = client.connect(WifiStation.getIP(), port); - debug_d("Connected: %d", connected); - - TEST_CASE("TcpClient::send stream") - { - size_t offset = 0; - - // Send text using bytes - client.send(inputData.c_str(), 5); - offset += 5; - - // send data using more bytes - client.send(inputData.c_str() + offset, 7); - offset += 7; - - // send data as stream - auto stream1 = new MemoryDataStream(); - stream1->write(inputData.c_str() + offset, 3); - client.send(stream1); - offset += 3; - client.commit(); - - // more stream - auto stream2 = new LimitedMemoryStream(4); - stream2->write(reinterpret_cast(inputData.c_str()) + offset, 4); - client.send(stream2); - offset += 4; - - // and finally the rest of the bytes - String rest = inputData.substring(offset); - client.send(rest.c_str(), rest.length()); - client.setTimeOut(1); - - pending(); - } - } - - void shutdown() - { - server->shutdown(); - server = nullptr; - timer.initializeMs<1000>([this]() { complete(); }); - timer.startOnce(); - } - -private: - String receivedData; - TcpServer* server{nullptr}; - TcpClient client{false}; - Timer timer; - volatile bool finished = false; -}; - -void REGISTER_TEST(TcpClient) -{ - registerGroup(); -} diff --git a/tests/HostTests/modules/Stream.cpp b/tests/HostTests/modules/Stream.cpp index cedb08312b..65782a1030 100644 --- a/tests/HostTests/modules/Stream.cpp +++ b/tests/HostTests/modules/Stream.cpp @@ -98,19 +98,6 @@ class StreamTest : public TestGroup REQUIRE(FS_OUTPUT == s); } - TEST_CASE("ChunkedStream / StreamTransformer") - { - DEFINE_FSTR_LOCAL(FS_INPUT, "Some test data"); - DEFINE_FSTR_LOCAL(FS_OUTPUT, "e\r\nSome test data\r\n0\r\n\r\n"); - ChunkedStream chunked(new FlashMemoryStream(FS_INPUT)); - MemoryDataStream output; - output.copyFrom(&chunked); - String s; - REQUIRE(output.moveString(s)); - m_printHex("OUTPUT", s.c_str(), s.length()); - REQUIRE(FS_OUTPUT == s); - } - TEST_CASE("MultipartStream / MultiStream") { unsigned itemIndex{0};