diff --git a/CMakeLists.txt b/CMakeLists.txt index 9829219..f67a6b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,10 @@ cmake_minimum_required(VERSION 3.5) #execute_process(COMMAND bin/prebuild.sh) add_compile_definitions(ESP$ENV{ESP_FAM}) add_compile_definitions(IDF_VERSION=$ENV{IDF_VERSION}) +add_compile_definitions(WFC_TARGET=$ENV{WFC_TARGET}) add_compile_definitions(FWCFG="$ENV{FWCFG}") add_link_options(LINKER:SHELL:"-gc-sections,--defsym,LDTIMESTAMP=$ENV{TIMESTAMP}") -#set(FWCFG $ENV{FWCFG}) # ignored - for whatever reason... -#add_compile_definitions(FWCFG="$ENV{FWCFG}") set(PROJECT_VER $ENV{VER}) # ignored - for whatever reason... set(INCLUDE_DIRS components/logging drv/dht drv/bme280 drv/ws8212b) set(EXTRA_COMPONENT_DIRS drv/button drv/dht drv/display drv/hc-sr04 diff --git a/ChangeLog b/ChangeLog index fdeb6ad..6a56441 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +R2312: +====== +- fix DS18B20 negative values +- fix ESP32-C3 1-wire regression +- fix for SSD1306 font rendering +- SSD130x code unification +- enable core temperature support on C3,S2,S3 +- update atriumcfg config to include all configurations +- added support for rendering PNM icons (PBM, PGM, PPM) + R2311: ====== - added driver foc.config_init_high()r BQ25601D charging IC diff --git a/Makefile.gmake b/Makefile.gmake index 13c978a..f55b766 100644 --- a/Makefile.gmake +++ b/Makefile.gmake @@ -64,14 +64,16 @@ ROMFS_FILE =$(ROMFS_LST:%.lst=%.romfs) ROMFS_FILES =$(shell cat $(ROMFS_LST) 2>/dev/null) ROMFS_ADDR =$(CONFIG_ROMFS_ADDR) IDF_VER :=$(shell cd $(IDF_PATH); git describe --tags 2>/dev/null | sed 's/\.//;s/v//;s/-.*//;s/\..*//') -CPPFLAGS =-DIDF_VERSION=$(IDF_VER) -D$(CHIP) -DFWCFG=\"$(PROJECT)\" -I$(BUILD_DIR_BASE)/config +# shell call to remove "" +WFC_TARGET =$(shell echo $(CONFIG_WFC_TARGET)) +CPPFLAGS =-DIDF_VERSION=$(IDF_VER) -D$(CHIP) -DFWCFG=\"$(PROJECT)\" -DWFC_TARGET=$(WFC_TARGET) -I$(BUILD_DIR_BASE)/config BUILD_DIR_BASE =$(PWD)/build.$(PROJECT) PROJECT_ROOT =$(PWD) WFCINC =$(WFCDIR)/include PROJECT_VER =$(shell bin/mkversion.sh) MEMFILES =$(shell cd data; ls -1 man/*.man) ROMFS_PARTITION =storage -CFG_CXX =tools/atriumcfg.cpp tools/hwcfg.cpp tools/swcfg.cpp tools/wfccore.cpp +CFG_CXX =tools/atriumcfg.cpp components/wfc/hwcfg_pc.cpp components/wfc/swcfg_pc.cpp components/wfc/wfccore_pc.cpp PATH :=$(PATH_$(CHIP)):$(PATH) IDF_PYTHON_ENV_PATH =$(IDF_PYTHON_ENV_PATH_$(CHIP)) @@ -81,7 +83,7 @@ endif .PHONY: prepare settings -export BUILD_DIR_BASE CHIP CPPFLAGS PROJECT_NAME IDF_PATH IDF_VER PATH PTABLE PROJECT_ROOT PROJECT SDKCONFIG WFC WFCDIR ESPTOOL_ALL_FLASH_ARGS CXXFLAGS PROJECT_VER MEMFILES CONFIG_INTEGRATED_HELP +export BUILD_DIR_BASE CHIP CPPFLAGS PROJECT_NAME IDF_PATH IDF_VER PATH PTABLE PROJECT_ROOT PROJECT SDKCONFIG WFC WFCDIR ESPTOOL_ALL_FLASH_ARGS CXXFLAGS PROJECT_VER MEMFILES CONFIG_INTEGRATED_HELP WFC_TARGET romfs/%.romfs: prepare bin/mkromfs -c data -o $@ $(ROMFS_FILES) version.txt @@ -181,7 +183,7 @@ build.$(PROJECT)/spiffs.bin: $(ROMFS_FILES:%=data/%) atriumcfg: bin/atriumcfg$(EXEEXT) bin/atriumcfg$(EXEEXT): $(CFG_CXX) tools/version.h tools/pcconfig.h - g++ -g -Imain -Icomponents/streams $(CFG_CXX) -leditline -lmd -o $@ + g++ -g -DWFC_TARGET=pc -Imain -Icomponents/wfc -Itools $(CFG_CXX) -ledit -lmd -o $@ always: diff --git a/bin/genmemfiles.sh b/bin/genmemfiles.sh index 0ec4064..ab42439 100755 --- a/bin/genmemfiles.sh +++ b/bin/genmemfiles.sh @@ -38,11 +38,12 @@ cat > $MEMFILES_H << EOF #define MEMFILES_H #ifdef CONFIG_IDF_TARGET_ESP8266 -#define ROMSTR __attribute__((section(".irom0.text.romstr"))) +#define ROMSTR __attribute__((section(".flash.text"))) #else #define ROMSTR #endif +#ifdef CONFIG_INTEGRATED_HELP EOF cat > $CMAKELISTS << EOF @@ -55,26 +56,42 @@ for i in $MEMFILES; do filename=`basename "$i"` fn_nodot=`echo $filename | sed 's/\./_/g'` cpp_file=`printf "%s.cpp" $fn_nodot` - if [ "$CONFIG_INTEGRATED_HELP" = "y" ]; then - size=`stat --printf='%s' $i` - printf "extern const char ROMSTR $fn_nodot""[];\n#define $fn_nodot""_len $size\n" >> $MEMFILES_H - test ! -e "$ldir/$cpp_file" -o "$file" -nt "$ldir/$cpp_file" - if [ "$?" == "0" ]; then - echo updating $ldir/$cpp_file - pushd `dirname $i` - xxd -i $filename "$ldir/$cpp_file" - popd > /dev/null - sed -i 's/unsigned char /#include "memfiles.h"\nconst char ROMSTR /;s/]/]/;s/^unsigned //;s/}/ ,0x00}/;s/int .*;//' "$ldir/$cpp_file" - fi - echo " $filename" | sed 's/.man/_man.cpp/' >> $CMAKELISTS - else - echo "#define $fn_nodot 0" >> $MEMFILES_H - rm -f "$ldir/$cpp_file" + size=`stat --printf='%s' $i` + printf "extern const char ROMSTR $fn_nodot""[];\n#define $fn_nodot""_len $size\n" >> $MEMFILES_H + test ! -e "$ldir/$cpp_file" -o "$file" -nt "$ldir/$cpp_file" + if [ "$?" == "0" ]; then + echo updating $ldir/$cpp_file + cat << EOHEADER > "$ldir/$cpp_file" +#include +#include "memfiles.h" + +#ifdef CONFIG_INTEGRATED_HELP +EOHEADER + pushd `dirname $i` + xxd -i "$filename" >> "$ldir/$cpp_file" + popd > /dev/null + sed -i 's/unsigned char/const char ROMSTR/;s/]/]/;s/^unsigned //;s/}/ ,0x00}/;s/int .*;//' "$ldir/$cpp_file" + cat << EOFOOTER >> "$ldir/$cpp_file" +#else +#define $fn_nodot 0 +#endif +EOFOOTER fi + echo " $filename" | sed 's/.man/_man.cpp/' >> $CMAKELISTS + shift +done + +printf "\n#else // no CONFIG_INTEGRATED_HELP\n\n" >> $MEMFILES_H + +for i in $MEMFILES; do + file="$i" + filename=`basename "$i"` + fn_nodot=`echo $filename | sed 's/\./_/g'` + printf "#define $fn_nodot 0\n#define ${fn_nodot}_len 0\n" >> $MEMFILES_H shift done -printf "\n#endif" >> $MEMFILES_H +printf "\n\n#endif // CONFIG_INTEGRATED_HELP\n\n#endif\n" >> $MEMFILES_H printf ")\nregister_component()" >> $CMAKELISTS if [ -e "$ldir/memfiles.h" ]; then diff --git a/bin/link_wfc.sh b/bin/link_wfc.sh deleted file mode 100755 index d2bda98..0000000 --- a/bin/link_wfc.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# -# Copyright (C) 2021, Thomas Maier-Komor -# Atrium Firmware Package for ESP -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -function checkage() { - if [ $dirty -eq 0 ]; then - if [ components/wfc/$1.cpp -ot $2.wfc ]; then - #echo components/wfc/$1.cpp may be outdated - dirty=1 - elif [ components/wfc/$1.h -ot $2.wfc ]; then - #echo components/wfc/$1.h may be outdated - dirty=1 - fi - fi -} - -if [ -f $SDKCONFIG ]; then - TARGET=`grep CONFIG_WFC_TARGET "$SDKCONFIG" | sed 's/.*="//;s/"//'` -elif [ -f "projects/$PROJECT" ]; then - TARGET=`grep CONFIG_WFC_TARGET "projects/$PROJECT" | sed 's/.*="//;s/"//'` -fi - -if [ "$TARGET" == "" ]; then - TARGET=$CHIP -fi -echo sym-linking wfc generated sources for target $TARGET, project $PROJECT - -if [ ! -f components/wfc/hwcfg_$TARGET.cpp ]; then - echo unsupported target $TARGET - exit 1 -fi - -dirty=0 - -checkage hwcfg_$TARGET hwcfg -checkage swcfg_$TARGET swcfg -checkage wfccore_$TARGET swcfg -checkage wfccore_$TARGET hwcfg - -if [ $dirty -ne 0 ]; then - if [ -d .hg ]; then - which hg > /dev/null - if [ $? -eq 0 ]; then - hgst=`hg status -m *.wfc` - if [ $? -eq 0 -a "$hgst" == "" ]; then - dirty=0 - echo hg says wfc files are clean - fi - fi - fi - if [ -d .git ]; then - which git > /dev/null - if [ $? -ne 0 ]; then - git diff-index --quiet HEAD *.wfc - if [ $? -eq 0 ]; then - dirty=0 - echo git says wfc files are clean - fi - fi - fi - if [ $dirty -ne 0 ]; then - echo Warning: WFC generated files may be outdated! - fi -else - echo WFC generated files are up-to-date -fi - -ln -f -s ../components/wfc/hwcfg_$TARGET.cpp main/hwcfg.cpp -ln -f -s ../components/wfc/hwcfg_$TARGET.h main/hwcfg.h -ln -f -s ../components/wfc/swcfg_$TARGET.cpp main/swcfg.cpp -ln -f -s ../components/wfc/swcfg_$TARGET.h main/swcfg.h -ln -f -s ../components/wfc/wfccore_$TARGET.cpp main/wfccore.cpp -ln -f -s ../components/wfc/wfccore_$TARGET.h main/wfccore.h diff --git a/bin/prebuild.sh b/bin/prebuild.sh index 1f8d966..bce5154 100755 --- a/bin/prebuild.sh +++ b/bin/prebuild.sh @@ -44,4 +44,3 @@ ln -s -f build.$PROJECT build || exit 1 export COMPONENT_PATH=`pwd`/main bash bin/mkversion.sh main/versions.h || exit 1 bash bin/genmemfiles.sh || exit 1 -bash bin/link_wfc.sh || exit 1 diff --git a/components/env/env.h b/components/env/env.h index 9834c83..e25d8ed 100644 --- a/components/env/env.h +++ b/components/env/env.h @@ -85,6 +85,12 @@ class EnvElement EnvObject *getParent() const { return m_parent; } + bool skip() const + { return m_skip; } + + void setSkip(bool s = true) + { m_skip = s; } + protected: explicit EnvElement(const char *n, const char *dim = 0); @@ -92,6 +98,7 @@ class EnvElement char *m_dim; friend class EnvObject; EnvObject *m_parent = 0; + bool m_skip = false; private: EnvElement(const EnvElement &); // intentionally not supported diff --git a/components/streams/CMakeLists.txt b/components/streams/CMakeLists.txt index a60887b..541b288 100644 --- a/components/streams/CMakeLists.txt +++ b/components/streams/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register( - SRCS astream.cpp mstream.cpp stream.cpp strstream.cpp estring.cpp + SRCS astream.cpp mstream.cpp stream.cpp strstream.cpp estring.cpp support.cpp INCLUDE_DIRS . ) diff --git a/main/support.cpp b/components/streams/support.cpp similarity index 100% rename from main/support.cpp rename to components/streams/support.cpp diff --git a/main/support.h b/components/streams/support.h similarity index 100% rename from main/support.h rename to components/streams/support.h diff --git a/components/wfc/CMakeLists.txt b/components/wfc/CMakeLists.txt new file mode 100644 index 0000000..79df822 --- /dev/null +++ b/components/wfc/CMakeLists.txt @@ -0,0 +1,5 @@ +idf_component_register( + SRCS hwcfg_$ENV{WFC_TARGET}.cpp swcfg_$ENV{WFC_TARGET}.cpp wfccore_$ENV{WFC_TARGET}.cpp + INCLUDE_DIRS . ../streams + REQUIRES streams +) diff --git a/components/wfc/component.mk b/components/wfc/component.mk new file mode 100644 index 0000000..79310af --- /dev/null +++ b/components/wfc/component.mk @@ -0,0 +1,2 @@ +COMPONENT_ADD_INCLUDEDIRS=. +COMPONENT_OBJS = hwcfg_$(WFC_TARGET).o swcfg_$(WFC_TARGET).o wfccore_$(WFC_TARGET).o diff --git a/components/wfc/hwcfg_esp32.cpp b/components/wfc/hwcfg_esp32.cpp index 0cc87bb..89c0ce7 100644 --- a/components/wfc/hwcfg_esp32.cpp +++ b/components/wfc/hwcfg_esp32.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -95,9 +96,9 @@ #include #include #include -#include "hwcfg.h" +#include "hwcfg_esp32.h" -#include "wfccore.h" +#include "wfccore_esp32.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -5841,7 +5842,9 @@ void AdcConfig::clear() m_adc_name.clear(); m_adc1_bits = 0; m_adc2_bits = 0; + #ifdef CONFIG_IDF_TARGET_ESP32 m_hall_name.clear(); + #endif // CONFIG_IDF_TARGET_ESP32 m_channels.clear(); p_validbits = 0; } @@ -5853,7 +5856,9 @@ void AdcConfig::toASCII(stream &o, size_t indent) const ascii_string(o,indent,m_adc_name.data(),m_adc_name.size(),"adc_name"); ascii_numeric(o, indent, "adc1_bits", (unsigned) m_adc1_bits); ascii_numeric(o, indent, "adc2_bits", (unsigned) m_adc2_bits); + #ifdef CONFIG_IDF_TARGET_ESP32 ascii_string(o,indent,m_hall_name.data(),m_hall_name.size(),"hall_name"); + #endif // CONFIG_IDF_TARGET_ESP32 ascii_indent(o,indent); size_t s_channels = m_channels.size(); o << "channels[" << s_channels << "] = {"; @@ -5913,6 +5918,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) set_adc2_bits(v); } break; + #ifdef CONFIG_IDF_TARGET_ESP32 case 0x32: // hall_name id 6, type estring, coding byte[] { varint_t v; @@ -5924,6 +5930,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) a += v; } break; + #endif // CONFIG_IDF_TARGET_ESP32 case 0x3a: // channels id 7, type AdcChannel, coding byte[] { varint_t v; @@ -6002,6 +6009,7 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const } // 'mode' is unused. Therefore no data will be written. // 'clk_div' is unused. Therefore no data will be written. + #ifdef CONFIG_IDF_TARGET_ESP32 // has hall_name? if (!m_hall_name.empty()) { // 'hall_name': id=6, encoding=lenpfx, tag=0x32 @@ -6016,6 +6024,7 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const memcpy(a,m_hall_name.data(),hall_name_s); a += hall_name_s; } + #endif // CONFIG_IDF_TARGET_ESP32 for (const auto &x : m_channels) { // 'channels': id=7, encoding=lenpfx, tag=0x3a if (a >= e) @@ -6050,10 +6059,12 @@ void AdcConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"adc2_bits"); json << (unsigned) m_adc2_bits; } + #ifdef CONFIG_IDF_TARGET_ESP32 if (has_hall_name()) { fsep = json_indent(json,indLvl,fsep,"hall_name"); json_cstr(json,m_hall_name.c_str()); } + #endif // CONFIG_IDF_TARGET_ESP32 if (size_t s = m_channels.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -6100,11 +6111,13 @@ size_t AdcConfig::calcSize() const } // unused optional uint8 mode, id 4 // unused optional uint8 clk_div, id 5 + #ifdef CONFIG_IDF_TARGET_ESP32 // optional string hall_name, id 6 if (!m_hall_name.empty()) { size_t hall_name_s = m_hall_name.size(); r += hall_name_s + wiresize(hall_name_s) + 1 /* tag(hall_name) 0x30 */; } + #endif // CONFIG_IDF_TARGET_ESP32 // repeated AdcChannel channels, id 7 // repeated message channels for (size_t x = 0, y = m_channels.size(); x < y; ++x) { @@ -6125,8 +6138,10 @@ bool AdcConfig::operator != (const AdcConfig &r) const return true; if (has_adc2_bits() && (m_adc2_bits != r.m_adc2_bits)) return true; + #ifdef CONFIG_IDF_TARGET_ESP32 if (has_hall_name() && (m_hall_name != r.m_hall_name)) return true; + #endif // CONFIG_IDF_TARGET_ESP32 if (m_channels != r.m_channels) return true; return false; @@ -6177,6 +6192,7 @@ int AdcConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } + #ifdef CONFIG_IDF_TARGET_ESP32 if (0 == strcmp(name,"hall_name")) { if (value == 0) { clear_hall_name(); @@ -6186,6 +6202,7 @@ int AdcConfig::setByName(const char *name, const char *value) int r = m_hall_name.size(); return r; } + #endif // CONFIG_IDF_TARGET_ESP32 if (0 == memcmp(name,"channels",8)) { if ((name[8] == 0) && (value == 0)) { clear_channels(); @@ -6553,6 +6570,7 @@ void DisplayConfig::clear() m_options = 0; m_maxx = 0; m_maxy = 1; + m_skip_env.clear(); p_validbits = 0; } @@ -6569,6 +6587,18 @@ void DisplayConfig::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "options", m_options); ascii_numeric(o, indent, "maxx", m_maxx); ascii_numeric(o, indent, "maxy", m_maxy); + ascii_indent(o,indent); + size_t s_skip_env = m_skip_env.size(); + o << "skip_env[" << s_skip_env << "] = {"; + ++indent; + for (size_t i = 0, e = s_skip_env; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + ascii_string(o,indent,m_skip_env[i].data(),m_skip_env[i].size(),0); + } + --indent; + ascii_indent(o,indent); + o << '}'; --indent; ascii_indent(o,indent); o << '}'; @@ -6625,12 +6655,23 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) set_maxy(v); } break; + case 0x2a: // skip_env id 5, type estring, coding byte[] + { + varint_t v; + int n = read_varint(a,e-a,&v); + a += n; + if ((n <= 0) || ((a+v) > e)) + return -341; + m_skip_env.emplace_back((const char*)a,v); + a += v; + } + break; default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -341; + return -342; a += s; break; } @@ -6638,7 +6679,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -342; + return -343; return a-(const uint8_t *)b; } @@ -6651,45 +6692,58 @@ ssize_t DisplayConfig::toMemory(uint8_t *b, ssize_t s) const if (m_type != dt_none) { // 'type': id=1, encoding=varint, tag=0x8 if (a >= e) - return -343; + return -344; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -344; + return -345; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -345; + return -346; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -346; + return -347; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -347; + return -348; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -348; + return -349; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -349; + return -350; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -350; + return -351; + a += n; + } + for (const auto &x : m_skip_env) { + // 'skip_env': id=5, encoding=lenpfx, tag=0x2a + if (a >= e) + return -352; + *a++ = 0x2a; + ssize_t skip_env_s = x.size(); + n = write_varint(a,e-a,skip_env_s); a += n; + if ((n <= 0) || ((e-a) < skip_env_s)) + return -353; + memcpy(a,x.data(),skip_env_s); + a += skip_env_s; } assert(a <= e); return a-b; @@ -6721,6 +6775,24 @@ void DisplayConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"maxy"); json << m_maxy; } + if (size_t s = m_skip_env.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"skip_env\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + json_cstr(json,m_skip_env[i].c_str()); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -6750,6 +6822,15 @@ size_t DisplayConfig::calcSize() const if (0 != (p_validbits & ((uint8_t)1U << 2))) { r += wiresize((varint_t)m_maxy) + 1 /* tag(maxy) 0x20 */; } + // repeated string skip_env, id 5 + if (!m_skip_env.empty()) { + // skip_env: repeated estring + for (size_t x = 0, y = m_skip_env.size(); x < y; ++x) { + size_t s = m_skip_env[x].size(); + r += wiresize(s); + r += s + 1 /* tag(skip_env) 0x28 */; + } + } return r; } @@ -6765,6 +6846,8 @@ bool DisplayConfig::operator != (const DisplayConfig &r) const return true; if (has_maxy() && (m_maxy != r.m_maxy)) return true; + if (m_skip_env != r.m_skip_env) + return true; return false; } @@ -6792,7 +6875,7 @@ int DisplayConfig::setByName(const char *name, const char *value) disp_t v; size_t r = parse_ascii_disp_t(&v,value); if (r == 0) - return -351; + return -354; set_type(v); return r; } @@ -6826,7 +6909,37 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -352; + if (0 == memcmp(name,"skip_env",8)) { + if ((name[8] == 0) && (value == 0)) { + clear_skip_env(); + return 0; + } else if (name[8] == '[') { + char *idxe; + unsigned long x; + if ((name[9] == '+') && (name[10] == ']')) { + x = m_skip_env.size(); + m_skip_env.resize(x+1); + idxe = (char*)(name + 10); + if (value == 0) + return 0; + } else { + x = strtoul(name+9,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+9))) + return -355; + if (m_skip_env.size() <= x) + return -356; + if ((idxe[1] == 0) && (value == 0)) { + m_skip_env.erase(m_skip_env.begin()+x); + return 0; + } + } + if (idxe[1] != 0) + return -357; + m_skip_env[x] = value; + return m_skip_env[x].size(); + } + } + return -358; } Message *DisplayConfig::p_getMember(const char *s, unsigned n) @@ -6879,7 +6992,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -353; + return -359; a += fn; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -6887,7 +7000,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -354; + return -360; a += n; set_drv((spidrv_t) v); } @@ -6897,7 +7010,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -355; + return -361; a += n; set_cs(varint_sint(v)); } @@ -6907,7 +7020,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -356; + return -362; a += n; set_intr(varint_sint(v)); } @@ -6917,7 +7030,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -357; + return -363; a += n; set_reset(varint_sint(v)); } @@ -6927,7 +7040,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -358; + return -364; a += n; set_cd(varint_sint(v)); } @@ -6937,7 +7050,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -359; + return -365; a += n; set_freq(v); } @@ -6947,7 +7060,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -360; + return -366; a += s; break; } @@ -6955,7 +7068,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -361; + return -367; return a-(const uint8_t *)b; } @@ -6968,66 +7081,66 @@ ssize_t SpiDeviceConfig::toMemory(uint8_t *b, ssize_t s) const if (m_drv != spidrv_invalid) { // 'drv': id=1, encoding=varint, tag=0x8 if (a >= e) - return -362; + return -368; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -363; + return -369; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -364; + return -370; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -365; + return -371; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -366; + return -372; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -367; + return -373; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -368; + return -374; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -369; + return -375; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -370; + return -376; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -371; + return -377; a += n; } // has freq? if (m_freq != 0) { // 'freq': id=6, encoding=varint, tag=0x30 if (a >= e) - return -372; + return -378; *a++ = 0x30; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -373; + return -379; a += n; } assert(a <= e); @@ -7149,7 +7262,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) spidrv_t v; size_t r = parse_ascii_spidrv_t(&v,value); if (r == 0) - return -374; + return -380; set_drv(v); return r; } @@ -7193,7 +7306,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_u32(&m_freq,value); return r; } - return -375; + return -381; } Message *SpiDeviceConfig::p_getMember(const char *s, unsigned n) @@ -7282,7 +7395,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -376; + return -382; a += fn; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -7290,7 +7403,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -377; + return -383; a += n; set_host(varint_sint(v)); } @@ -7300,7 +7413,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -378; + return -384; a += n; set_mosi(varint_sint(v)); } @@ -7310,7 +7423,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -379; + return -385; a += n; set_miso(varint_sint(v)); } @@ -7320,7 +7433,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -380; + return -386; a += n; set_sclk(varint_sint(v)); } @@ -7330,7 +7443,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -381; + return -387; a += n; set_wp(varint_sint(v)); } @@ -7340,7 +7453,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -382; + return -388; a += n; set_hold(varint_sint(v)); } @@ -7350,7 +7463,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -383; + return -389; a += n; set_options((spiopt_t) v); } @@ -7360,7 +7473,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -384; + return -390; a += n; set_dma(varint_sint(v)); } @@ -7371,14 +7484,14 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -385; + return -391; m_devices.emplace_back(); if (v != 0) { n = m_devices.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -386; + return -392; a += v; } } @@ -7388,7 +7501,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -387; + return -393; a += s; break; } @@ -7396,7 +7509,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -388; + return -394; return a-(const uint8_t *)b; } @@ -7409,100 +7522,100 @@ ssize_t SpiBusConfig::toMemory(uint8_t *b, ssize_t s) const if (m_host != -1) { // 'host': id=1, encoding=varint, tag=0x8 if (a >= e) - return -389; + return -395; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -390; + return -396; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -391; + return -397; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -392; + return -398; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -393; + return -399; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -394; + return -400; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -395; + return -401; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -396; + return -402; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -397; + return -403; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -398; + return -404; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -399; + return -405; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -400; + return -406; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -401; + return -407; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -402; + return -408; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -403; + return -409; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -404; + return -410; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -405; + return -411; *a++ = 0x4a; ssize_t devices_ws = x.calcSize(); n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -406; + return -412; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -7733,7 +7846,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) return eptr - value; } if (*name++ != '.') { - return -407; + return -413; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; int r = parse_ascii_bool(&tmp,value); @@ -7802,20 +7915,20 @@ int SpiBusConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -408; + return -414; if (m_devices.size() <= x) - return -409; + return -415; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -410; + return -416; return m_devices[x].setByName(idxe+2,value); } } - return -411; + return -417; } Message *SpiBusConfig::p_getMember(const char *s, unsigned n) @@ -7865,7 +7978,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -412; + return -418; a += fn; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] @@ -7874,7 +7987,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -413; + return -419; m_name.assign((const char*)a,v); a += v; } @@ -7884,7 +7997,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -414; + return -420; a += n; set_base(v); } @@ -7894,7 +8007,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -415; + return -421; a += n; set_numio(v); } @@ -7904,7 +8017,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -416; + return -422; a += n; set_int_a(varint_sint(v)); } @@ -7914,7 +8027,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -417; + return -423; a += n; set_int_b(varint_sint(v)); } @@ -7924,7 +8037,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -418; + return -424; a += s; break; } @@ -7932,7 +8045,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -419; + return -425; return a-(const uint8_t *)b; } @@ -7945,13 +8058,13 @@ ssize_t GpioCluster::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -420; + return -426; *a++ = 0xa; ssize_t name_s = m_name.size(); n = write_varint(a,e-a,name_s); a += n; if ((n <= 0) || ((e-a) < name_s)) - return -421; + return -427; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -7959,44 +8072,44 @@ ssize_t GpioCluster::toMemory(uint8_t *b, ssize_t s) const if (m_base != 0) { // 'base': id=2, encoding=varint, tag=0x10 if (a >= e) - return -422; + return -428; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -423; + return -429; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -424; + return -430; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -425; + return -431; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -426; + return -432; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -427; + return -433; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -428; + return -434; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -429; + return -435; a += n; } assert(a <= e); @@ -8136,7 +8249,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -430; + return -436; } Message *GpioCluster::p_getMember(const char *s, unsigned n) @@ -8178,7 +8291,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -431; + return -437; a += fn; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -8186,7 +8299,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -432; + return -438; a += n; set_sel(varint_sint(v)); } @@ -8196,7 +8309,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -433; + return -439; a += n; set_cf(varint_sint(v)); } @@ -8206,7 +8319,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -434; + return -440; a += n; set_cf1(varint_sint(v)); } @@ -8216,7 +8329,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -435; + return -441; a += s; break; } @@ -8224,7 +8337,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -436; + return -442; return a-(const uint8_t *)b; } @@ -8237,33 +8350,33 @@ ssize_t Hlw8012Config::toMemory(uint8_t *b, ssize_t s) const if (m_sel != -1) { // 'sel': id=2, encoding=varint, tag=0x10 if (a >= e) - return -437; + return -443; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -438; + return -444; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -439; + return -445; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -440; + return -446; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -441; + return -447; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -442; + return -448; a += n; } assert(a <= e); @@ -8365,7 +8478,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -443; + return -449; } Message *Hlw8012Config::p_getMember(const char *s, unsigned n) @@ -8413,7 +8526,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -444; + return -450; a += fn; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -8421,7 +8534,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -445; + return -451; a += n; set_dio0(varint_sint(v)); } @@ -8431,7 +8544,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -446; + return -452; a += n; set_dio1(varint_sint(v)); } @@ -8441,7 +8554,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -447; + return -453; a += n; set_dio2(varint_sint(v)); } @@ -8451,7 +8564,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -448; + return -454; a += n; set_dio3(varint_sint(v)); } @@ -8461,7 +8574,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -449; + return -455; a += n; set_dio4(varint_sint(v)); } @@ -8471,7 +8584,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -450; + return -456; a += n; set_dio5(varint_sint(v)); } @@ -8481,7 +8594,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -451; + return -457; a += s; break; } @@ -8489,7 +8602,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -452; + return -458; return a-(const uint8_t *)b; } @@ -8502,66 +8615,66 @@ ssize_t SX1276Config::toMemory(uint8_t *b, ssize_t s) const if (m_dio0 != -1) { // 'dio0': id=1, encoding=varint, tag=0x8 if (a >= e) - return -453; + return -459; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -454; + return -460; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -455; + return -461; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -456; + return -462; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -457; + return -463; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -458; + return -464; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -459; + return -465; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -460; + return -466; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -461; + return -467; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -462; + return -468; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -463; + return -469; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -464; + return -470; a += n; } assert(a <= e); @@ -8717,7 +8830,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -465; + return -471; } Message *SX1276Config::p_getMember(const char *s, unsigned n) @@ -8758,7 +8871,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -466; + return -472; a += fn; switch (fid) { case 0x8: // freq id 1, type uint32_t, coding varint @@ -8766,7 +8879,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -467; + return -473; a += n; set_freq(v); } @@ -8776,7 +8889,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -468; + return -474; a += n; set_duration(v); } @@ -8786,7 +8899,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -469; + return -475; a += s; break; } @@ -8794,7 +8907,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -470; + return -476; return a-(const uint8_t *)b; } @@ -8807,22 +8920,22 @@ ssize_t Tone::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'freq': id=1, encoding=varint, tag=0x8 if (a >= e) - return -471; + return -477; *a++ = 0x8; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -472; + return -478; a += n; } // has duration? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'duration': id=2, encoding=varint, tag=0x10 if (a >= e) - return -473; + return -479; *a++ = 0x10; n = write_varint(a,e-a,m_duration); if (n <= 0) - return -474; + return -480; a += n; } assert(a <= e); @@ -8912,7 +9025,7 @@ int Tone::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } - return -475; + return -481; } Message *Tone::p_getMember(const char *s, unsigned n) @@ -8963,7 +9076,7 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -476; + return -482; a += fn; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] @@ -8972,14 +9085,14 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -477; + return -483; m_name.assign((const char*)a,v); a += v; } break; case 0x14: // tones id 2, type uint16_t, coding 16bit if ((a+1) >= e) - return -478; + return -484; m_tones.push_back((uint16_t) read_u16(a)); a += 2; break; @@ -8988,7 +9101,7 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -479; + return -485; a += s; break; } @@ -8996,7 +9109,7 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -480; + return -486; return a-(const uint8_t *)b; } @@ -9009,23 +9122,23 @@ ssize_t Melody::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -481; + return -487; *a++ = 0xa; ssize_t name_s = m_name.size(); n = write_varint(a,e-a,name_s); a += n; if ((n <= 0) || ((e-a) < name_s)) - return -482; + return -488; memcpy(a,m_name.data(),name_s); a += name_s; } for (auto x : m_tones) { // 'tones': id=2, encoding=16bit, tag=0x14 if (3 > (e-a)) - return -483; + return -489; *a++ = 0x14; if ((e-a) < 2) - return -484; + return -490; write_u16(a,x); a += 2; } @@ -9135,20 +9248,20 @@ int Melody::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -485; + return -491; if (m_tones.size() <= x) - return -486; + return -492; if ((idxe[1] == 0) && (value == 0)) { m_tones.erase(m_tones.begin()+x); return 0; } } if (idxe[1] != 0) - return -487; + return -493; return parse_ascii_u16(&m_tones[x],value); } } - return -488; + return -494; } Message *Melody::p_getMember(const char *s, unsigned n) @@ -9199,7 +9312,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -489; + return -495; a += fn; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -9207,7 +9320,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -490; + return -496; a += n; set_gpio(varint_sint(v)); } @@ -9218,14 +9331,14 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -491; + return -497; m_melodies.emplace_back(); if (v != 0) { n = m_melodies.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -492; + return -498; a += v; } } @@ -9235,7 +9348,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -493; + return -499; a += s; break; } @@ -9243,7 +9356,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -494; + return -500; return a-(const uint8_t *)b; } @@ -9256,23 +9369,23 @@ ssize_t BuzzerConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -495; + return -501; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -496; + return -502; a += n; } for (const auto &x : m_melodies) { // 'melodies': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -497; + return -503; *a++ = 0x12; ssize_t melodies_ws = x.calcSize(); n = write_varint(a,e-a,melodies_ws); a += n; if ((n <= 0) || (melodies_ws > (e-a))) - return -498; + return -504; n = x.toMemory(a,e-a); a += n; assert(n == melodies_ws); @@ -9383,20 +9496,20 @@ int BuzzerConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -499; + return -505; if (m_melodies.size() <= x) - return -500; + return -506; if ((idxe[1] == 0) && (value == 0)) { m_melodies.erase(m_melodies.begin()+x); return 0; } } if (idxe[1] != '.') - return -501; + return -507; return m_melodies[x].setByName(idxe+2,value); } } - return -502; + return -508; } Message *BuzzerConfig::p_getMember(const char *s, unsigned n) @@ -9687,12 +9800,12 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -503; + return -509; a += fn; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit if ((a+3) >= e) - return -504; + return -510; set_magic((uint32_t) read_u32(a)); a += 4; break; @@ -9702,13 +9815,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -505; + return -511; if (v != 0) { n = m_system.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -506; + return -512; a += v; } } @@ -9720,14 +9833,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -507; + return -513; m_uart.emplace_back(); if (v != 0) { n = m_uart.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -508; + return -514; a += v; } } @@ -9738,13 +9851,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -509; + return -515; if (v != 0) { n = m_adc.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -510; + return -516; a += v; } } @@ -9757,13 +9870,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -511; + return -517; if (v != 0) { n = m_touchpad.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -512; + return -518; a += v; } } @@ -9777,14 +9890,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -513; + return -519; m_tp_channel.emplace_back(); if (v != 0) { n = m_tp_channel.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -514; + return -520; a += v; } } @@ -9796,14 +9909,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -515; + return -521; m_gpios.emplace_back(); if (v != 0) { n = m_gpios.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -516; + return -522; a += v; } } @@ -9815,14 +9928,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -517; + return -523; m_spibus.emplace_back(); if (v != 0) { n = m_spibus.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -518; + return -524; a += v; } } @@ -9835,14 +9948,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -519; + return -525; m_button.emplace_back(); if (v != 0) { n = m_button.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -520; + return -526; a += v; } } @@ -9855,14 +9968,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -521; + return -527; m_relay.emplace_back(); if (v != 0) { n = m_relay.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -522; + return -528; a += v; } } @@ -9875,14 +9988,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -523; + return -529; m_led.emplace_back(); if (v != 0) { n = m_led.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -524; + return -530; a += v; } } @@ -9895,13 +10008,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -525; + return -531; if (v != 0) { n = m_buzzer.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -526; + return -532; a += v; } } @@ -9915,13 +10028,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -527; + return -533; if (v != 0) { n = m_hlw8012.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -528; + return -534; a += v; } } @@ -9935,13 +10048,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -529; + return -535; if (v != 0) { n = m_max7219.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -530; + return -536; a += v; } } @@ -9955,13 +10068,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -531; + return -537; if (v != 0) { n = m_tlc5947.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -532; + return -538; a += v; } } @@ -9975,14 +10088,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -533; + return -539; m_ws2812b.emplace_back(); if (v != 0) { n = m_ws2812b.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -534; + return -540; a += v; } } @@ -9995,13 +10108,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -535; + return -541; if (v != 0) { n = m_dht.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -536; + return -542; a += v; } } @@ -10015,14 +10128,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -537; + return -543; m_i2c.emplace_back(); if (v != 0) { n = m_i2c.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -538; + return -544; a += v; } } @@ -10035,14 +10148,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -539; + return -545; m_hcsr04.emplace_back(); if (v != 0) { n = m_hcsr04.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -540; + return -546; a += v; } } @@ -10055,13 +10168,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -541; + return -547; if (v != 0) { n = m_onewire.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -542; + return -548; a += v; } } @@ -10075,13 +10188,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -543; + return -549; if (v != 0) { n = m_sx1276.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -544; + return -550; a += v; } } @@ -10095,14 +10208,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -545; + return -551; m_iocluster.emplace_back(); if (v != 0) { n = m_iocluster.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -546; + return -552; a += v; } } @@ -10115,13 +10228,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -547; + return -553; if (v != 0) { n = m_display.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -548; + return -554; a += v; } } @@ -10133,7 +10246,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -549; + return -555; a += s; break; } @@ -10141,7 +10254,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -550; + return -556; return a-(const uint8_t *)b; } @@ -10154,10 +10267,10 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -551; + return -557; *a++ = 0x5; if ((e-a) < 4) - return -552; + return -558; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -10165,13 +10278,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 1))) { // 'system': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -553; + return -559; *a++ = 0xa; ssize_t system_ws = m_system.calcSize(); n = write_varint(a,e-a,system_ws); a += n; if ((n <= 0) || (system_ws > (e-a))) - return -554; + return -560; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -10179,13 +10292,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_uart) { // 'uart': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -555; + return -561; *a++ = 0x1a; ssize_t uart_ws = x.calcSize(); n = write_varint(a,e-a,uart_ws); a += n; if ((n <= 0) || (uart_ws > (e-a))) - return -556; + return -562; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -10194,13 +10307,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 2))) { // 'adc': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -557; + return -563; *a++ = 0x22; ssize_t adc_ws = m_adc.calcSize(); n = write_varint(a,e-a,adc_ws); a += n; if ((n <= 0) || (adc_ws > (e-a))) - return -558; + return -564; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -10210,13 +10323,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'touchpad': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -559; + return -565; *a++ = 0x2a; ssize_t touchpad_ws = m_touchpad.calcSize(); n = write_varint(a,e-a,touchpad_ws); a += n; if ((n <= 0) || (touchpad_ws > (e-a))) - return -560; + return -566; n = m_touchpad.toMemory(a,e-a); a += n; assert(n == touchpad_ws); @@ -10226,13 +10339,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_tp_channel) { // 'tp_channel': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -561; + return -567; *a++ = 0x32; ssize_t tp_channel_ws = x.calcSize(); n = write_varint(a,e-a,tp_channel_ws); a += n; if ((n <= 0) || (tp_channel_ws > (e-a))) - return -562; + return -568; n = x.toMemory(a,e-a); a += n; assert(n == tp_channel_ws); @@ -10241,13 +10354,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpios) { // 'gpios': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -563; + return -569; *a++ = 0x3a; ssize_t gpios_ws = x.calcSize(); n = write_varint(a,e-a,gpios_ws); a += n; if ((n <= 0) || (gpios_ws > (e-a))) - return -564; + return -570; n = x.toMemory(a,e-a); a += n; assert(n == gpios_ws); @@ -10256,13 +10369,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_spibus) { // 'spibus': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -565; + return -571; *a++ = 0x42; ssize_t spibus_ws = x.calcSize(); n = write_varint(a,e-a,spibus_ws); a += n; if ((n <= 0) || (spibus_ws > (e-a))) - return -566; + return -572; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -10272,14 +10385,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_button) { // 'button': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -567; + return -573; *a++ = 0x82; *a++ = 0x1; ssize_t button_ws = x.calcSize(); n = write_varint(a,e-a,button_ws); a += n; if ((n <= 0) || (button_ws > (e-a))) - return -568; + return -574; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -10289,14 +10402,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_relay) { // 'relay': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -569; + return -575; *a++ = 0x8a; *a++ = 0x1; ssize_t relay_ws = x.calcSize(); n = write_varint(a,e-a,relay_ws); a += n; if ((n <= 0) || (relay_ws > (e-a))) - return -570; + return -576; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -10306,14 +10419,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_led) { // 'led': id=18, encoding=lenpfx, tag=0x92 if (2 > (e-a)) - return -571; + return -577; *a++ = 0x92; *a++ = 0x1; ssize_t led_ws = x.calcSize(); n = write_varint(a,e-a,led_ws); a += n; if ((n <= 0) || (led_ws > (e-a))) - return -572; + return -578; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -10324,14 +10437,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'buzzer': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -573; + return -579; *a++ = 0x9a; *a++ = 0x1; ssize_t buzzer_ws = m_buzzer.calcSize(); n = write_varint(a,e-a,buzzer_ws); a += n; if ((n <= 0) || (buzzer_ws > (e-a))) - return -574; + return -580; n = m_buzzer.toMemory(a,e-a); a += n; assert(n == buzzer_ws); @@ -10342,14 +10455,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -575; + return -581; *a++ = 0xa2; *a++ = 0x1; ssize_t hlw8012_ws = m_hlw8012.calcSize(); n = write_varint(a,e-a,hlw8012_ws); a += n; if ((n <= 0) || (hlw8012_ws > (e-a))) - return -576; + return -582; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -10360,14 +10473,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 if (2 > (e-a)) - return -577; + return -583; *a++ = 0x82; *a++ = 0x2; ssize_t max7219_ws = m_max7219.calcSize(); n = write_varint(a,e-a,max7219_ws); a += n; if ((n <= 0) || (max7219_ws > (e-a))) - return -578; + return -584; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -10378,14 +10491,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -579; + return -585; *a++ = 0x8a; *a++ = 0x2; ssize_t tlc5947_ws = m_tlc5947.calcSize(); n = write_varint(a,e-a,tlc5947_ws); a += n; if ((n <= 0) || (tlc5947_ws > (e-a))) - return -580; + return -586; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); @@ -10395,14 +10508,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -581; + return -587; *a++ = 0x92; *a++ = 0x2; ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -582; + return -588; n = x.toMemory(a,e-a); a += n; assert(n == ws2812b_ws); @@ -10413,14 +10526,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -583; + return -589; *a++ = 0x9a; *a++ = 0x2; ssize_t dht_ws = m_dht.calcSize(); n = write_varint(a,e-a,dht_ws); a += n; if ((n <= 0) || (dht_ws > (e-a))) - return -584; + return -590; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -10430,14 +10543,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_i2c) { // 'i2c': id=36, encoding=lenpfx, tag=0x122 if (2 > (e-a)) - return -585; + return -591; *a++ = 0xa2; *a++ = 0x2; ssize_t i2c_ws = x.calcSize(); n = write_varint(a,e-a,i2c_ws); a += n; if ((n <= 0) || (i2c_ws > (e-a))) - return -586; + return -592; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -10447,14 +10560,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_hcsr04) { // 'hcsr04': id=37, encoding=lenpfx, tag=0x12a if (2 > (e-a)) - return -587; + return -593; *a++ = 0xaa; *a++ = 0x2; ssize_t hcsr04_ws = x.calcSize(); n = write_varint(a,e-a,hcsr04_ws); a += n; if ((n <= 0) || (hcsr04_ws > (e-a))) - return -588; + return -594; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -10465,14 +10578,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -589; + return -595; *a++ = 0xb2; *a++ = 0x2; ssize_t onewire_ws = m_onewire.calcSize(); n = write_varint(a,e-a,onewire_ws); a += n; if ((n <= 0) || (onewire_ws > (e-a))) - return -590; + return -596; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -10483,14 +10596,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -591; + return -597; *a++ = 0xba; *a++ = 0x2; ssize_t sx1276_ws = m_sx1276.calcSize(); n = write_varint(a,e-a,sx1276_ws); a += n; if ((n <= 0) || (sx1276_ws > (e-a))) - return -592; + return -598; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -10500,14 +10613,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_iocluster) { // 'iocluster': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) - return -593; + return -599; *a++ = 0xc2; *a++ = 0x2; ssize_t iocluster_ws = x.calcSize(); n = write_varint(a,e-a,iocluster_ws); a += n; if ((n <= 0) || (iocluster_ws > (e-a))) - return -594; + return -600; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -10518,14 +10631,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 11))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -595; + return -601; *a++ = 0x92; *a++ = 0x3; ssize_t display_ws = m_display.calcSize(); n = write_varint(a,e-a,display_ws); a += n; if ((n <= 0) || (display_ws > (e-a))) - return -596; + return -602; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -11149,16 +11262,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+5,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+5))) - return -597; + return -603; if (m_uart.size() <= x) - return -598; + return -604; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -599; + return -605; return m_uart[x].setByName(idxe+2,value); } } @@ -11199,16 +11312,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -600; + return -606; if (m_tp_channel.size() <= x) - return -601; + return -607; if ((idxe[1] == 0) && (value == 0)) { m_tp_channel.erase(m_tp_channel.begin()+x); return 0; } } if (idxe[1] != '.') - return -602; + return -608; return m_tp_channel[x].setByName(idxe+2,value); } } @@ -11229,16 +11342,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -603; + return -609; if (m_gpios.size() <= x) - return -604; + return -610; if ((idxe[1] == 0) && (value == 0)) { m_gpios.erase(m_gpios.begin()+x); return 0; } } if (idxe[1] != '.') - return -605; + return -611; return m_gpios[x].setByName(idxe+2,value); } } @@ -11259,16 +11372,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -606; + return -612; if (m_spibus.size() <= x) - return -607; + return -613; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -608; + return -614; return m_spibus[x].setByName(idxe+2,value); } } @@ -11290,16 +11403,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -609; + return -615; if (m_button.size() <= x) - return -610; + return -616; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -611; + return -617; return m_button[x].setByName(idxe+2,value); } } @@ -11321,16 +11434,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -612; + return -618; if (m_relay.size() <= x) - return -613; + return -619; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -614; + return -620; return m_relay[x].setByName(idxe+2,value); } } @@ -11352,16 +11465,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -615; + return -621; if (m_led.size() <= x) - return -616; + return -622; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -617; + return -623; return m_led[x].setByName(idxe+2,value); } } @@ -11427,16 +11540,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -618; + return -624; if (m_ws2812b.size() <= x) - return -619; + return -625; if ((idxe[1] == 0) && (value == 0)) { m_ws2812b.erase(m_ws2812b.begin()+x); return 0; } } if (idxe[1] != '.') - return -620; + return -626; return m_ws2812b[x].setByName(idxe+2,value); } } @@ -11469,16 +11582,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -621; + return -627; if (m_i2c.size() <= x) - return -622; + return -628; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -623; + return -629; return m_i2c[x].setByName(idxe+2,value); } } @@ -11500,16 +11613,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -624; + return -630; if (m_hcsr04.size() <= x) - return -625; + return -631; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -626; + return -632; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -11553,16 +11666,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -627; + return -633; if (m_iocluster.size() <= x) - return -628; + return -634; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -629; + return -635; return m_iocluster[x].setByName(idxe+2,value); } } @@ -11578,7 +11691,7 @@ int HardwareConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_DISPLAY - return -630; + return -636; } Message *HardwareConfig::p_getMember(const char *s, unsigned n) diff --git a/components/wfc/hwcfg_esp32.h b/components/wfc/hwcfg_esp32.h index 6e55cc3..592e469 100644 --- a/components/wfc/hwcfg_esp32.h +++ b/components/wfc/hwcfg_esp32.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -92,8 +93,8 @@ * asserts, comments, genlib, gnux */ -#ifndef HWCFG_H -#define HWCFG_H +#ifndef HWCFG_ESP32_H +#define HWCFG_ESP32_H #include #define OUTPUT_TO_ASCII 1 @@ -125,7 +126,7 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_esp32.h" /* wfc support functions not needed */ typedef uint32_t varint_t; @@ -3264,6 +3265,7 @@ class AdcConfig : public Message // unused optional uint8 mode, id 4 // unused optional uint8 clk_div, id 5 + #ifdef CONFIG_IDF_TARGET_ESP32 // optional string hall_name, id 6 /*! * Function for querying if hall_name has been set. @@ -3289,6 +3291,7 @@ class AdcConfig : public Message * @return pointer to member variable of hall_name. */ estring *mutable_hall_name(); + #endif // CONFIG_IDF_TARGET_ESP32 // repeated AdcChannel channels, id 7 //! Function get const-access to the elements of channels. @@ -3320,8 +3323,10 @@ class AdcConfig : public Message Message *p_getMember(const char *s, unsigned n, unsigned i); //! string adc_name, id 1 estring m_adc_name; + #ifdef CONFIG_IDF_TARGET_ESP32 //! string hall_name, id 6 estring m_hall_name; + #endif // CONFIG_IDF_TARGET_ESP32 //! uint8 adc1_bits, id 2 uint8_t m_adc1_bits = 0; //! uint8 adc2_bits, id 3 @@ -3644,10 +3649,38 @@ class DisplayConfig : public Message */ uint32_t *mutable_maxy(); + // repeated string skip_env, id 5 + //! Function get const-access to the elements of skip_env. + const std::vector &skip_env() const; + //! Function to get the number of elements in skip_env. + size_t skip_env_size() const; + /*! + * Function to append a element to skip_env. + * @return point to newly added element. + */ + void add_skip_env(const estring &v); + //! Function to append an element to skip_env initialized by a C-string. + void add_skip_env(const char*); + //! Function to reset skip_env to its default/unset value. + void clear_skip_env(); + //! Get value of element x of skip_env. + const estring &skip_env(unsigned x) const; + //! Set skip_env using a constant reference + void set_skip_env(unsigned x, const estring &v); + /*! + * Provide mutable access to skip_env. + * @return pointer to member variable of skip_env. + */ + estring *mutable_skip_env(unsigned x); + //! Function to get mutable access to all elements of skip_env. + std::vector *mutable_skip_env(); + protected: Message *p_getMember(const char *s, unsigned n); Message *p_getMember(const char *s, unsigned n, unsigned i); + //! string skip_env, id 5 + std::vector m_skip_env; //! disp_t type, id 1 disp_t m_type = dt_none; //! unsigned options, id 2 @@ -8888,6 +8921,7 @@ inline void AdcConfig::set_adc2_bits(uint8_t v) +#ifdef CONFIG_IDF_TARGET_ESP32 inline const estring &AdcConfig::hall_name() const { return m_hall_name; @@ -8927,6 +8961,7 @@ inline void AdcConfig::set_hall_name(const estring &v) m_hall_name = v; } +#endif // CONFIG_IDF_TARGET_ESP32 inline const AdcChannel &AdcConfig::channels(unsigned x) const @@ -9174,7 +9209,8 @@ inline size_t DisplayConfig::getMaxSize() // optional unsigned options, id 2 has maximum size 6 // optional unsigned maxx, id 3 has maximum size 6 // optional unsigned maxy, id 4 has maximum size 6 - return 20; + // repeated string skip_env, id 5 has unlimited size + return SIZE_MAX; } inline disp_t DisplayConfig::type() const @@ -9319,6 +9355,60 @@ inline void DisplayConfig::set_maxy(uint32_t v) +inline const estring &DisplayConfig::skip_env(unsigned x) const +{ + return m_skip_env[x]; +} + +inline const std::vector &DisplayConfig::skip_env() const +{ + return m_skip_env; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void DisplayConfig::clear_skip_env() +{ + m_skip_env.clear(); +} + +inline estring *DisplayConfig::mutable_skip_env(unsigned x) +{ + if (x >= m_skip_env.size()) + m_skip_env.resize(x+1); + return &m_skip_env[x]; +} + +inline std::vector *DisplayConfig::mutable_skip_env() +{ + return &m_skip_env; +} + +inline void DisplayConfig::add_skip_env(const estring &v) +{ + m_skip_env.push_back(v); +} + +inline void DisplayConfig::add_skip_env(const char *s) +{ + m_skip_env.push_back(s); +} + +inline void DisplayConfig::set_skip_env(unsigned x, const estring &v) +{ + assert(x < m_skip_env.size()); + m_skip_env[x] = v; +} + +inline size_t DisplayConfig::skip_env_size() const +{ + return m_skip_env.size(); +} + + + inline size_t SpiDeviceConfig::getMaxSize() { // optional spidrv_t drv, id 1 has maximum size 2 @@ -10681,7 +10771,7 @@ inline size_t HardwareConfig::getMaxSize() // optional OneWireConfig onewire, id 38 has maximum size 10 // optional SX1276Config sx1276, id 39 has maximum size 20 // repeated GpioCluster iocluster, id 40 has unlimited size - // optional DisplayConfig display, id 50 has maximum size 22 + // optional DisplayConfig display, id 50 has maximum size 21 return SIZE_MAX; } diff --git a/components/wfc/hwcfg_esp8266.cpp b/components/wfc/hwcfg_esp8266.cpp index 9306645..009986c 100644 --- a/components/wfc/hwcfg_esp8266.cpp +++ b/components/wfc/hwcfg_esp8266.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -95,9 +96,9 @@ #include #include #include -#include "hwcfg.h" +#include "hwcfg_esp8266.h" -#include "wfccore.h" +#include "wfccore_esp8266.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -5019,7 +5020,9 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const return -230; a += n; } + #ifdef CONFIG_IDF_TARGET_ESP32 // 'hall_name' is unused. Therefore no data will be written. + #endif // CONFIG_IDF_TARGET_ESP32 // 'channels' is unused. Therefore no data will be written. assert(a <= e); return a-b; @@ -5069,7 +5072,9 @@ size_t AdcConfig::calcSize() const if (has_clk_div()) { r += wiresize((varint_t)m_clk_div) + 1 /* tag(clk_div) 0x28 */; } + #ifdef CONFIG_IDF_TARGET_ESP32 // unused optional string hall_name, id 6 + #endif // CONFIG_IDF_TARGET_ESP32 // unused repeated AdcChannel channels, id 7 return r; } @@ -5416,6 +5421,7 @@ void DisplayConfig::clear() m_options = 0; m_maxx = 0; m_maxy = 1; + m_skip_env.clear(); p_validbits = 0; } @@ -5432,6 +5438,18 @@ void DisplayConfig::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "options", m_options); ascii_numeric(o, indent, "maxx", m_maxx); ascii_numeric(o, indent, "maxy", m_maxy); + ascii_indent(o,indent); + size_t s_skip_env = m_skip_env.size(); + o << "skip_env[" << s_skip_env << "] = {"; + ++indent; + for (size_t i = 0, e = s_skip_env; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + ascii_string(o,indent,m_skip_env[i].data(),m_skip_env[i].size(),0); + } + --indent; + ascii_indent(o,indent); + o << '}'; --indent; ascii_indent(o,indent); o << '}'; @@ -5461,18 +5479,25 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) case 0x20: // maxy id 4, type uint32_t, coding varint set_maxy((uint32_t)ud.u32); break; + case 0x2a: // skip_env id 5, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -245; + } + m_skip_env.emplace_back((const char*)a,ud.vi); + a += ud.vi; + break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data a += ud.vi; if (a > e) - return -245; + return -246; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -246; + return -247; return a-(const uint8_t *)b; } @@ -5485,44 +5510,54 @@ ssize_t DisplayConfig::toMemory(uint8_t *b, ssize_t s) const if (m_type != dt_none) { // 'type': id=1, encoding=varint, tag=0x8 if (a >= e) - return -247; + return -248; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -248; + return -249; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -249; + return -250; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -250; + return -251; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -251; + return -252; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -252; + return -253; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -253; + return -254; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -254; + return -255; + a += n; + } + for (const auto &x : m_skip_env) { + // 'skip_env': id=5, encoding=lenpfx, tag=0x2a + if (a >= e) + return -256; + *a++ = 0x2a; + n = encode_bytes(x,a,e); + if (n < 0) + return -257; a += n; } assert(a <= e); @@ -5555,6 +5590,24 @@ void DisplayConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"maxy"); to_decstr(json,m_maxy); } + if (size_t s = m_skip_env.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"skip_env\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + json_cstr(json,m_skip_env[i].c_str()); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -5584,6 +5637,15 @@ size_t DisplayConfig::calcSize() const if (has_maxy()) { r += wiresize((varint_t)m_maxy) + 1 /* tag(maxy) 0x20 */; } + // repeated string skip_env, id 5 + if (!m_skip_env.empty()) { + // skip_env: repeated estring + for (size_t x = 0, y = m_skip_env.size(); x < y; ++x) { + size_t s = m_skip_env[x].size(); + r += wiresize(s); + r += s + 1 /* tag(skip_env) 0x28 */; + } + } return r; } @@ -5599,6 +5661,8 @@ bool DisplayConfig::operator == (const DisplayConfig &r) const return false; if (has_maxy() && (!(m_maxy == r.m_maxy))) return false; + if (!(m_skip_env == r.m_skip_env)) + return false; return true; } @@ -5620,7 +5684,7 @@ int DisplayConfig::setByName(const char *name, const char *value) disp_t v; size_t r = parse_ascii_disp_t(&v,value); if (r == 0) - return -255; + return -258; set_type(v); return r; } @@ -5654,7 +5718,37 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -256; + if (0 == memcmp(name,"skip_env",8)) { + if ((name[8] == 0) && (value == 0)) { + clear_skip_env(); + return 0; + } else if (name[8] == '[') { + char *idxe; + unsigned long x; + if ((name[9] == '+') && (name[10] == ']')) { + x = m_skip_env.size(); + m_skip_env.resize(x+1); + idxe = (char*)(name + 10); + if (value == 0) + return 0; + } else { + x = strtoul(name+9,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+9))) + return -259; + if (m_skip_env.size() <= x) + return -260; + if ((idxe[1] == 0) && (value == 0)) { + m_skip_env.erase(m_skip_env.begin()+x); + return 0; + } + } + if (idxe[1] != 0) + return -261; + m_skip_env[x] = value; + return m_skip_env[x].size(); + } + } + return -262; } SpiDeviceConfig::SpiDeviceConfig() @@ -5700,7 +5794,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -257; + return -263; a += x; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -5726,13 +5820,13 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -258; + return -264; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -259; + return -265; return a-(const uint8_t *)b; } @@ -5745,66 +5839,66 @@ ssize_t SpiDeviceConfig::toMemory(uint8_t *b, ssize_t s) const if (m_drv != spidrv_invalid) { // 'drv': id=1, encoding=varint, tag=0x8 if (a >= e) - return -260; + return -266; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -261; + return -267; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -262; + return -268; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -263; + return -269; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -264; + return -270; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -265; + return -271; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -266; + return -272; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -267; + return -273; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -268; + return -274; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -269; + return -275; a += n; } // has freq? if (m_freq != 0) { // 'freq': id=6, encoding=varint, tag=0x30 if (a >= e) - return -270; + return -276; *a++ = 0x30; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -271; + return -277; a += n; } assert(a <= e); @@ -5920,7 +6014,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) spidrv_t v; size_t r = parse_ascii_spidrv_t(&v,value); if (r == 0) - return -272; + return -278; set_drv(v); return r; } @@ -5964,7 +6058,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_u32(&m_freq,value); return r; } - return -273; + return -279; } SpiBusConfig::SpiBusConfig() @@ -6046,7 +6140,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -274; + return -280; a += x; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -6079,7 +6173,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) int n; n = m_devices.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -275; + return -281; a += ud.vi; } break; @@ -6088,13 +6182,13 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -276; + return -282; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -277; + return -283; return a-(const uint8_t *)b; } @@ -6107,100 +6201,100 @@ ssize_t SpiBusConfig::toMemory(uint8_t *b, ssize_t s) const if (m_host != -1) { // 'host': id=1, encoding=varint, tag=0x8 if (a >= e) - return -278; + return -284; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -279; + return -285; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -280; + return -286; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -281; + return -287; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -282; + return -288; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -283; + return -289; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -284; + return -290; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -285; + return -291; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -286; + return -292; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -287; + return -293; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -288; + return -294; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -289; + return -295; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -290; + return -296; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -291; + return -297; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -292; + return -298; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -293; + return -299; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -294; + return -300; *a++ = 0x4a; ssize_t devices_ws = x.calcSize(); n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -295; + return -301; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -6425,7 +6519,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) return eptr - value; } if (*name++ != '.') { - return -296; + return -302; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; int r = parse_ascii_bool(&tmp,value); @@ -6494,20 +6588,20 @@ int SpiBusConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -297; + return -303; if (m_devices.size() <= x) - return -298; + return -304; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -299; + return -305; return m_devices[x].setByName(idxe+2,value); } } - return -300; + return -306; } Message *SpiBusConfig::p_getMember(const char *s, unsigned n, unsigned x) @@ -6556,12 +6650,12 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -301; + return -307; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -302; + return -308; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -6583,13 +6677,13 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -303; + return -309; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -304; + return -310; return a-(const uint8_t *)b; } @@ -6602,55 +6696,55 @@ ssize_t GpioCluster::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -305; + return -311; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -306; + return -312; a += n; } // has base? if (m_base != 0) { // 'base': id=2, encoding=varint, tag=0x10 if (a >= e) - return -307; + return -313; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -308; + return -314; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -309; + return -315; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -310; + return -316; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -311; + return -317; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -312; + return -318; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -313; + return -319; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -314; + return -320; a += n; } assert(a <= e); @@ -6784,7 +6878,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -315; + return -321; } Hlw8012Config::Hlw8012Config() @@ -6819,7 +6913,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -316; + return -322; a += x; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -6836,13 +6930,13 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -317; + return -323; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -318; + return -324; return a-(const uint8_t *)b; } @@ -6855,33 +6949,33 @@ ssize_t Hlw8012Config::toMemory(uint8_t *b, ssize_t s) const if (m_sel != -1) { // 'sel': id=2, encoding=varint, tag=0x10 if (a >= e) - return -319; + return -325; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -320; + return -326; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -321; + return -327; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -322; + return -328; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -323; + return -329; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -324; + return -330; a += n; } assert(a <= e); @@ -6977,7 +7071,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -325; + return -331; } SX1276Config::SX1276Config() @@ -7018,7 +7112,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -326; + return -332; a += x; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -7044,13 +7138,13 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -327; + return -333; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -328; + return -334; return a-(const uint8_t *)b; } @@ -7063,66 +7157,66 @@ ssize_t SX1276Config::toMemory(uint8_t *b, ssize_t s) const if (m_dio0 != -1) { // 'dio0': id=1, encoding=varint, tag=0x8 if (a >= e) - return -329; + return -335; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -330; + return -336; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -331; + return -337; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -332; + return -338; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -333; + return -339; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -334; + return -340; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -335; + return -341; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -336; + return -342; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -337; + return -343; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -338; + return -344; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -339; + return -345; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -340; + return -346; a += n; } assert(a <= e); @@ -7272,7 +7366,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -341; + return -347; } Tone::Tone() @@ -7306,7 +7400,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -342; + return -348; a += x; switch (fid) { case 0x8: // freq id 1, type uint32_t, coding varint @@ -7320,13 +7414,13 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -343; + return -349; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -344; + return -350; return a-(const uint8_t *)b; } @@ -7339,22 +7433,22 @@ ssize_t Tone::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'freq': id=1, encoding=varint, tag=0x8 if (a >= e) - return -345; + return -351; *a++ = 0x8; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -346; + return -352; a += n; } // has duration? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'duration': id=2, encoding=varint, tag=0x10 if (a >= e) - return -347; + return -353; *a++ = 0x10; n = write_varint(a,e-a,m_duration); if (n <= 0) - return -348; + return -354; a += n; } assert(a <= e); @@ -7438,7 +7532,7 @@ int Tone::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } - return -349; + return -355; } Melody::Melody() @@ -7482,12 +7576,12 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -350; + return -356; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -351; + return -357; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -7500,13 +7594,13 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -352; + return -358; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -353; + return -359; return a-(const uint8_t *)b; } @@ -7519,20 +7613,20 @@ ssize_t Melody::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -354; + return -360; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -355; + return -361; a += n; } for (auto x : m_tones) { // 'tones': id=2, encoding=16bit, tag=0x14 if (3 > (e-a)) - return -356; + return -362; *a++ = 0x14; if ((e-a) < 2) - return -357; + return -363; write_u16(a,x); a += 2; } @@ -7636,20 +7730,20 @@ int Melody::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -358; + return -364; if (m_tones.size() <= x) - return -359; + return -365; if ((idxe[1] == 0) && (value == 0)) { m_tones.erase(m_tones.begin()+x); return 0; } } if (idxe[1] != 0) - return -360; + return -366; return parse_ascii_u16(&m_tones[x],value); } } - return -361; + return -367; } BuzzerConfig::BuzzerConfig() @@ -7693,7 +7787,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -362; + return -368; a += x; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -7705,7 +7799,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) int n; n = m_melodies.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -363; + return -369; a += ud.vi; } break; @@ -7714,13 +7808,13 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -364; + return -370; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -365; + return -371; return a-(const uint8_t *)b; } @@ -7733,23 +7827,23 @@ ssize_t BuzzerConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -366; + return -372; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -367; + return -373; a += n; } for (const auto &x : m_melodies) { // 'melodies': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -368; + return -374; *a++ = 0x12; ssize_t melodies_ws = x.calcSize(); n = write_varint(a,e-a,melodies_ws); a += n; if ((n <= 0) || (melodies_ws > (e-a))) - return -369; + return -375; n = x.toMemory(a,e-a); a += n; assert(n == melodies_ws); @@ -7854,20 +7948,20 @@ int BuzzerConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -370; + return -376; if (m_melodies.size() <= x) - return -371; + return -377; if ((idxe[1] == 0) && (value == 0)) { m_melodies.erase(m_melodies.begin()+x); return 0; } } if (idxe[1] != '.') - return -372; + return -378; return m_melodies[x].setByName(idxe+2,value); } } - return -373; + return -379; } Message *BuzzerConfig::p_getMember(const char *s, unsigned n, unsigned x) @@ -8120,7 +8214,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -374; + return -380; a += x; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit @@ -8131,7 +8225,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_system.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -375; + return -381; a += ud.vi; } p_validbits |= ((uint16_t)1U << 1); @@ -8141,7 +8235,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_adc.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -376; + return -382; a += ud.vi; } p_validbits |= ((uint16_t)1U << 2); @@ -8152,7 +8246,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_gpios.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -377; + return -383; a += ud.vi; } break; @@ -8163,7 +8257,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_spibus.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -378; + return -384; a += ud.vi; } break; @@ -8175,7 +8269,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_button.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -379; + return -385; a += ud.vi; } break; @@ -8187,7 +8281,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_relay.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -380; + return -386; a += ud.vi; } break; @@ -8199,7 +8293,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_led.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -381; + return -387; a += ud.vi; } break; @@ -8210,7 +8304,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_buzzer.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -382; + return -388; a += ud.vi; } p_validbits |= ((uint16_t)1U << 3); @@ -8222,7 +8316,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_hlw8012.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -383; + return -389; a += ud.vi; } p_validbits |= ((uint16_t)1U << 4); @@ -8234,7 +8328,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_max7219.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -384; + return -390; a += ud.vi; } p_validbits |= ((uint16_t)1U << 5); @@ -8246,7 +8340,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_tlc5947.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -385; + return -391; a += ud.vi; } p_validbits |= ((uint16_t)1U << 6); @@ -8259,7 +8353,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_ws2812b.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -386; + return -392; a += ud.vi; } break; @@ -8270,7 +8364,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_dht.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -387; + return -393; a += ud.vi; } p_validbits |= ((uint16_t)1U << 7); @@ -8283,7 +8377,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_i2c.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -388; + return -394; a += ud.vi; } break; @@ -8295,7 +8389,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_hcsr04.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -389; + return -395; a += ud.vi; } break; @@ -8306,7 +8400,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_onewire.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -390; + return -396; a += ud.vi; } p_validbits |= ((uint16_t)1U << 8); @@ -8318,7 +8412,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_sx1276.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -391; + return -397; a += ud.vi; } p_validbits |= ((uint16_t)1U << 9); @@ -8331,7 +8425,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_iocluster.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -392; + return -398; a += ud.vi; } break; @@ -8342,7 +8436,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_display.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -393; + return -399; a += ud.vi; } p_validbits |= ((uint16_t)1U << 10); @@ -8353,13 +8447,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -394; + return -400; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -395; + return -401; return a-(const uint8_t *)b; } @@ -8372,10 +8466,10 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -396; + return -402; *a++ = 0x5; if ((e-a) < 4) - return -397; + return -403; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -8383,13 +8477,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 1))) { // 'system': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -398; + return -404; *a++ = 0xa; ssize_t system_ws = m_system.calcSize(); n = write_varint(a,e-a,system_ws); a += n; if ((n <= 0) || (system_ws > (e-a))) - return -399; + return -405; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -8399,13 +8493,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 2))) { // 'adc': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -400; + return -406; *a++ = 0x22; ssize_t adc_ws = m_adc.calcSize(); n = write_varint(a,e-a,adc_ws); a += n; if ((n <= 0) || (adc_ws > (e-a))) - return -401; + return -407; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -8419,13 +8513,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpios) { // 'gpios': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -402; + return -408; *a++ = 0x3a; ssize_t gpios_ws = x.calcSize(); n = write_varint(a,e-a,gpios_ws); a += n; if ((n <= 0) || (gpios_ws > (e-a))) - return -403; + return -409; n = x.toMemory(a,e-a); a += n; assert(n == gpios_ws); @@ -8434,13 +8528,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_spibus) { // 'spibus': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -404; + return -410; *a++ = 0x42; ssize_t spibus_ws = x.calcSize(); n = write_varint(a,e-a,spibus_ws); a += n; if ((n <= 0) || (spibus_ws > (e-a))) - return -405; + return -411; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -8450,14 +8544,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_button) { // 'button': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -406; + return -412; *a++ = 0x82; *a++ = 0x1; ssize_t button_ws = x.calcSize(); n = write_varint(a,e-a,button_ws); a += n; if ((n <= 0) || (button_ws > (e-a))) - return -407; + return -413; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -8467,14 +8561,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_relay) { // 'relay': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -408; + return -414; *a++ = 0x8a; *a++ = 0x1; ssize_t relay_ws = x.calcSize(); n = write_varint(a,e-a,relay_ws); a += n; if ((n <= 0) || (relay_ws > (e-a))) - return -409; + return -415; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -8484,14 +8578,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_led) { // 'led': id=18, encoding=lenpfx, tag=0x92 if (2 > (e-a)) - return -410; + return -416; *a++ = 0x92; *a++ = 0x1; ssize_t led_ws = x.calcSize(); n = write_varint(a,e-a,led_ws); a += n; if ((n <= 0) || (led_ws > (e-a))) - return -411; + return -417; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -8502,14 +8596,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'buzzer': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -412; + return -418; *a++ = 0x9a; *a++ = 0x1; ssize_t buzzer_ws = m_buzzer.calcSize(); n = write_varint(a,e-a,buzzer_ws); a += n; if ((n <= 0) || (buzzer_ws > (e-a))) - return -413; + return -419; n = m_buzzer.toMemory(a,e-a); a += n; assert(n == buzzer_ws); @@ -8520,14 +8614,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -414; + return -420; *a++ = 0xa2; *a++ = 0x1; ssize_t hlw8012_ws = m_hlw8012.calcSize(); n = write_varint(a,e-a,hlw8012_ws); a += n; if ((n <= 0) || (hlw8012_ws > (e-a))) - return -415; + return -421; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -8538,14 +8632,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 if (2 > (e-a)) - return -416; + return -422; *a++ = 0x82; *a++ = 0x2; ssize_t max7219_ws = m_max7219.calcSize(); n = write_varint(a,e-a,max7219_ws); a += n; if ((n <= 0) || (max7219_ws > (e-a))) - return -417; + return -423; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -8556,14 +8650,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -418; + return -424; *a++ = 0x8a; *a++ = 0x2; ssize_t tlc5947_ws = m_tlc5947.calcSize(); n = write_varint(a,e-a,tlc5947_ws); a += n; if ((n <= 0) || (tlc5947_ws > (e-a))) - return -419; + return -425; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); @@ -8573,14 +8667,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -420; + return -426; *a++ = 0x92; *a++ = 0x2; ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -421; + return -427; n = x.toMemory(a,e-a); a += n; assert(n == ws2812b_ws); @@ -8591,14 +8685,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -422; + return -428; *a++ = 0x9a; *a++ = 0x2; ssize_t dht_ws = m_dht.calcSize(); n = write_varint(a,e-a,dht_ws); a += n; if ((n <= 0) || (dht_ws > (e-a))) - return -423; + return -429; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -8608,14 +8702,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_i2c) { // 'i2c': id=36, encoding=lenpfx, tag=0x122 if (2 > (e-a)) - return -424; + return -430; *a++ = 0xa2; *a++ = 0x2; ssize_t i2c_ws = x.calcSize(); n = write_varint(a,e-a,i2c_ws); a += n; if ((n <= 0) || (i2c_ws > (e-a))) - return -425; + return -431; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -8625,14 +8719,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_hcsr04) { // 'hcsr04': id=37, encoding=lenpfx, tag=0x12a if (2 > (e-a)) - return -426; + return -432; *a++ = 0xaa; *a++ = 0x2; ssize_t hcsr04_ws = x.calcSize(); n = write_varint(a,e-a,hcsr04_ws); a += n; if ((n <= 0) || (hcsr04_ws > (e-a))) - return -427; + return -433; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -8643,14 +8737,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -428; + return -434; *a++ = 0xb2; *a++ = 0x2; ssize_t onewire_ws = m_onewire.calcSize(); n = write_varint(a,e-a,onewire_ws); a += n; if ((n <= 0) || (onewire_ws > (e-a))) - return -429; + return -435; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -8661,14 +8755,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -430; + return -436; *a++ = 0xba; *a++ = 0x2; ssize_t sx1276_ws = m_sx1276.calcSize(); n = write_varint(a,e-a,sx1276_ws); a += n; if ((n <= 0) || (sx1276_ws > (e-a))) - return -431; + return -437; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -8678,14 +8772,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_iocluster) { // 'iocluster': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) - return -432; + return -438; *a++ = 0xc2; *a++ = 0x2; ssize_t iocluster_ws = x.calcSize(); n = write_varint(a,e-a,iocluster_ws); a += n; if ((n <= 0) || (iocluster_ws > (e-a))) - return -433; + return -439; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -8696,14 +8790,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -434; + return -440; *a++ = 0x92; *a++ = 0x3; ssize_t display_ws = m_display.calcSize(); n = write_varint(a,e-a,display_ws); a += n; if ((n <= 0) || (display_ws > (e-a))) - return -435; + return -441; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -9260,16 +9354,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -436; + return -442; if (m_gpios.size() <= x) - return -437; + return -443; if ((idxe[1] == 0) && (value == 0)) { m_gpios.erase(m_gpios.begin()+x); return 0; } } if (idxe[1] != '.') - return -438; + return -444; return m_gpios[x].setByName(idxe+2,value); } } @@ -9290,16 +9384,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -439; + return -445; if (m_spibus.size() <= x) - return -440; + return -446; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -441; + return -447; return m_spibus[x].setByName(idxe+2,value); } } @@ -9321,16 +9415,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -442; + return -448; if (m_button.size() <= x) - return -443; + return -449; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -444; + return -450; return m_button[x].setByName(idxe+2,value); } } @@ -9352,16 +9446,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -445; + return -451; if (m_relay.size() <= x) - return -446; + return -452; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -447; + return -453; return m_relay[x].setByName(idxe+2,value); } } @@ -9383,16 +9477,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -448; + return -454; if (m_led.size() <= x) - return -449; + return -455; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -450; + return -456; return m_led[x].setByName(idxe+2,value); } } @@ -9458,16 +9552,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -451; + return -457; if (m_ws2812b.size() <= x) - return -452; + return -458; if ((idxe[1] == 0) && (value == 0)) { m_ws2812b.erase(m_ws2812b.begin()+x); return 0; } } if (idxe[1] != '.') - return -453; + return -459; return m_ws2812b[x].setByName(idxe+2,value); } } @@ -9500,16 +9594,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -454; + return -460; if (m_i2c.size() <= x) - return -455; + return -461; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -456; + return -462; return m_i2c[x].setByName(idxe+2,value); } } @@ -9531,16 +9625,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -457; + return -463; if (m_hcsr04.size() <= x) - return -458; + return -464; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -459; + return -465; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -9584,16 +9678,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -460; + return -466; if (m_iocluster.size() <= x) - return -461; + return -467; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -462; + return -468; return m_iocluster[x].setByName(idxe+2,value); } } @@ -9609,7 +9703,7 @@ int HardwareConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_DISPLAY - return -463; + return -469; } Message *HardwareConfig::p_getMember(const char *s, unsigned n) diff --git a/components/wfc/hwcfg_esp8266.h b/components/wfc/hwcfg_esp8266.h index f7c0615..6b3ed93 100644 --- a/components/wfc/hwcfg_esp8266.h +++ b/components/wfc/hwcfg_esp8266.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -92,8 +93,8 @@ * asserts, comments, genlib, gnux */ -#ifndef HWCFG_H -#define HWCFG_H +#ifndef HWCFG_ESP8266_H +#define HWCFG_ESP8266_H #include #define OUTPUT_TO_ASCII 1 @@ -125,7 +126,7 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_esp8266.h" /* wfc support functions not needed */ typedef _ssize_t ssize_t; @@ -3057,7 +3058,9 @@ class AdcConfig : public Message */ uint8_t *mutable_clk_div(); + #ifdef CONFIG_IDF_TARGET_ESP32 // unused optional string hall_name, id 6 + #endif // CONFIG_IDF_TARGET_ESP32 // unused repeated AdcChannel channels, id 7 protected: @@ -3373,8 +3376,36 @@ class DisplayConfig : public Message */ uint32_t *mutable_maxy(); + // repeated string skip_env, id 5 + //! Function get const-access to the elements of skip_env. + const std::vector &skip_env() const; + //! Function to get the number of elements in skip_env. + size_t skip_env_size() const; + /*! + * Function to append a element to skip_env. + * @return point to newly added element. + */ + void add_skip_env(const estring &v); + //! Function to append an element to skip_env initialized by a C-string. + void add_skip_env(const char*); + //! Function to reset skip_env to its default/unset value. + void clear_skip_env(); + //! Get value of element x of skip_env. + const estring &skip_env(unsigned x) const; + //! Set skip_env using a constant reference + void set_skip_env(unsigned x, const estring &v); + /*! + * Provide mutable access to skip_env. + * @return pointer to member variable of skip_env. + */ + estring *mutable_skip_env(unsigned x); + //! Function to get mutable access to all elements of skip_env. + std::vector *mutable_skip_env(); + protected: + //! string skip_env, id 5 + std::vector m_skip_env; //! disp_t type, id 1 disp_t m_type = dt_none; //! unsigned options, id 2 @@ -8489,7 +8520,8 @@ inline size_t DisplayConfig::getMaxSize() // optional unsigned options, id 2 has maximum size 6 // optional unsigned maxx, id 3 has maximum size 6 // optional unsigned maxy, id 4 has maximum size 6 - return 20; + // repeated string skip_env, id 5 has unlimited size + return SIZE_MAX; } inline disp_t DisplayConfig::type() const @@ -8634,6 +8666,60 @@ inline void DisplayConfig::set_maxy(uint32_t v) +inline const estring &DisplayConfig::skip_env(unsigned x) const +{ + return m_skip_env[x]; +} + +inline const std::vector &DisplayConfig::skip_env() const +{ + return m_skip_env; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void DisplayConfig::clear_skip_env() +{ + m_skip_env.clear(); +} + +inline estring *DisplayConfig::mutable_skip_env(unsigned x) +{ + if (x >= m_skip_env.size()) + m_skip_env.resize(x+1); + return &m_skip_env[x]; +} + +inline std::vector *DisplayConfig::mutable_skip_env() +{ + return &m_skip_env; +} + +inline void DisplayConfig::add_skip_env(const estring &v) +{ + m_skip_env.push_back(v); +} + +inline void DisplayConfig::add_skip_env(const char *s) +{ + m_skip_env.push_back(s); +} + +inline void DisplayConfig::set_skip_env(unsigned x, const estring &v) +{ + assert(x < m_skip_env.size()); + m_skip_env[x] = v; +} + +inline size_t DisplayConfig::skip_env_size() const +{ + return m_skip_env.size(); +} + + + inline size_t SpiDeviceConfig::getMaxSize() { // optional spidrv_t drv, id 1 has maximum size 2 @@ -9996,7 +10082,7 @@ inline size_t HardwareConfig::getMaxSize() // optional OneWireConfig onewire, id 38 has maximum size 10 // optional SX1276Config sx1276, id 39 has maximum size 20 // repeated GpioCluster iocluster, id 40 has unlimited size - // optional DisplayConfig display, id 50 has maximum size 22 + // optional DisplayConfig display, id 50 has maximum size 21 return SIZE_MAX; } diff --git a/components/wfc/hwcfg_esp8285.cpp b/components/wfc/hwcfg_esp8285.cpp index ec9a987..16a72e3 100644 --- a/components/wfc/hwcfg_esp8285.cpp +++ b/components/wfc/hwcfg_esp8285.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -97,9 +98,9 @@ #include #include #include -#include "hwcfg.h" +#include "hwcfg_esp8285.h" -#include "wfccore.h" +#include "wfccore_esp8285.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -5021,7 +5022,9 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const return -230; a += n; } + #ifdef CONFIG_IDF_TARGET_ESP32 // 'hall_name' is unused. Therefore no data will be written. + #endif // CONFIG_IDF_TARGET_ESP32 // 'channels' is unused. Therefore no data will be written. assert(a <= e); return a-b; @@ -5071,7 +5074,9 @@ size_t AdcConfig::calcSize() const if (has_clk_div()) { r += wiresize((varint_t)m_clk_div) + 1 /* tag(clk_div) 0x28 */; } + #ifdef CONFIG_IDF_TARGET_ESP32 // unused optional string hall_name, id 6 + #endif // CONFIG_IDF_TARGET_ESP32 // unused repeated AdcChannel channels, id 7 return r; } @@ -5418,6 +5423,7 @@ void DisplayConfig::clear() m_options = 0; m_maxx = 0; m_maxy = 1; + m_skip_env.clear(); p_validbits = 0; } @@ -5434,6 +5440,18 @@ void DisplayConfig::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "options", m_options); ascii_numeric(o, indent, "maxx", m_maxx); ascii_numeric(o, indent, "maxy", m_maxy); + ascii_indent(o,indent); + size_t s_skip_env = m_skip_env.size(); + o << "skip_env[" << s_skip_env << "] = {"; + ++indent; + for (size_t i = 0, e = s_skip_env; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + ascii_string(o,indent,m_skip_env[i].data(),m_skip_env[i].size(),0); + } + --indent; + ascii_indent(o,indent); + o << '}'; --indent; ascii_indent(o,indent); o << '}'; @@ -5463,18 +5481,25 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) case 0x20: // maxy id 4, type uint32_t, coding varint set_maxy((uint32_t)ud.u32); break; + case 0x2a: // skip_env id 5, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -245; + } + m_skip_env.emplace_back((const char*)a,ud.vi); + a += ud.vi; + break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data a += ud.vi; if (a > e) - return -245; + return -246; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -246; + return -247; return a-(const uint8_t *)b; } @@ -5487,44 +5512,54 @@ ssize_t DisplayConfig::toMemory(uint8_t *b, ssize_t s) const if (m_type != dt_none) { // 'type': id=1, encoding=varint, tag=0x8 if (a >= e) - return -247; + return -248; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -248; + return -249; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -249; + return -250; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -250; + return -251; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -251; + return -252; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -252; + return -253; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -253; + return -254; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -254; + return -255; + a += n; + } + for (const auto &x : m_skip_env) { + // 'skip_env': id=5, encoding=lenpfx, tag=0x2a + if (a >= e) + return -256; + *a++ = 0x2a; + n = encode_bytes(x,a,e); + if (n < 0) + return -257; a += n; } assert(a <= e); @@ -5557,6 +5592,24 @@ void DisplayConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"maxy"); to_decstr(json,m_maxy); } + if (size_t s = m_skip_env.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"skip_env\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + json_cstr(json,m_skip_env[i].c_str()); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -5586,6 +5639,15 @@ size_t DisplayConfig::calcSize() const if (has_maxy()) { r += wiresize((varint_t)m_maxy) + 1 /* tag(maxy) 0x20 */; } + // repeated string skip_env, id 5 + if (!m_skip_env.empty()) { + // skip_env: repeated estring + for (size_t x = 0, y = m_skip_env.size(); x < y; ++x) { + size_t s = m_skip_env[x].size(); + r += wiresize(s); + r += s + 1 /* tag(skip_env) 0x28 */; + } + } return r; } @@ -5601,6 +5663,8 @@ bool DisplayConfig::operator == (const DisplayConfig &r) const return false; if (has_maxy() && (!(m_maxy == r.m_maxy))) return false; + if (!(m_skip_env == r.m_skip_env)) + return false; return true; } @@ -5622,7 +5686,7 @@ int DisplayConfig::setByName(const char *name, const char *value) disp_t v; size_t r = parse_ascii_disp_t(&v,value); if (r == 0) - return -255; + return -258; set_type(v); return r; } @@ -5656,7 +5720,37 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -256; + if (0 == memcmp(name,"skip_env",8)) { + if ((name[8] == 0) && (value == 0)) { + clear_skip_env(); + return 0; + } else if (name[8] == '[') { + char *idxe; + unsigned long x; + if ((name[9] == '+') && (name[10] == ']')) { + x = m_skip_env.size(); + m_skip_env.resize(x+1); + idxe = (char*)(name + 10); + if (value == 0) + return 0; + } else { + x = strtoul(name+9,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+9))) + return -259; + if (m_skip_env.size() <= x) + return -260; + if ((idxe[1] == 0) && (value == 0)) { + m_skip_env.erase(m_skip_env.begin()+x); + return 0; + } + } + if (idxe[1] != 0) + return -261; + m_skip_env[x] = value; + return m_skip_env[x].size(); + } + } + return -262; } SpiDeviceConfig::SpiDeviceConfig() @@ -5702,7 +5796,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -257; + return -263; a += x; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -5728,13 +5822,13 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -258; + return -264; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -259; + return -265; return a-(const uint8_t *)b; } @@ -5747,66 +5841,66 @@ ssize_t SpiDeviceConfig::toMemory(uint8_t *b, ssize_t s) const if (m_drv != spidrv_invalid) { // 'drv': id=1, encoding=varint, tag=0x8 if (a >= e) - return -260; + return -266; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -261; + return -267; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -262; + return -268; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -263; + return -269; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -264; + return -270; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -265; + return -271; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -266; + return -272; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -267; + return -273; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -268; + return -274; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -269; + return -275; a += n; } // has freq? if (m_freq != 0) { // 'freq': id=6, encoding=varint, tag=0x30 if (a >= e) - return -270; + return -276; *a++ = 0x30; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -271; + return -277; a += n; } assert(a <= e); @@ -5922,7 +6016,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) spidrv_t v; size_t r = parse_ascii_spidrv_t(&v,value); if (r == 0) - return -272; + return -278; set_drv(v); return r; } @@ -5966,7 +6060,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_u32(&m_freq,value); return r; } - return -273; + return -279; } SpiBusConfig::SpiBusConfig() @@ -6048,7 +6142,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -274; + return -280; a += x; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -6081,7 +6175,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) int n; n = m_devices.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -275; + return -281; a += ud.vi; } break; @@ -6090,13 +6184,13 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -276; + return -282; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -277; + return -283; return a-(const uint8_t *)b; } @@ -6109,100 +6203,100 @@ ssize_t SpiBusConfig::toMemory(uint8_t *b, ssize_t s) const if (m_host != -1) { // 'host': id=1, encoding=varint, tag=0x8 if (a >= e) - return -278; + return -284; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -279; + return -285; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -280; + return -286; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -281; + return -287; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -282; + return -288; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -283; + return -289; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -284; + return -290; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -285; + return -291; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -286; + return -292; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -287; + return -293; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -288; + return -294; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -289; + return -295; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -290; + return -296; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -291; + return -297; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -292; + return -298; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -293; + return -299; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -294; + return -300; *a++ = 0x4a; ssize_t devices_ws = x.calcSize(); n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -295; + return -301; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -6427,7 +6521,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) return eptr - value; } if (*name++ != '.') { - return -296; + return -302; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; int r = parse_ascii_bool(&tmp,value); @@ -6496,20 +6590,20 @@ int SpiBusConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -297; + return -303; if (m_devices.size() <= x) - return -298; + return -304; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -299; + return -305; return m_devices[x].setByName(idxe+2,value); } } - return -300; + return -306; } GpioCluster::GpioCluster() @@ -6548,12 +6642,12 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -301; + return -307; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -302; + return -308; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -6575,13 +6669,13 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -303; + return -309; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -304; + return -310; return a-(const uint8_t *)b; } @@ -6594,55 +6688,55 @@ ssize_t GpioCluster::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -305; + return -311; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -306; + return -312; a += n; } // has base? if (m_base != 0) { // 'base': id=2, encoding=varint, tag=0x10 if (a >= e) - return -307; + return -313; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -308; + return -314; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -309; + return -315; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -310; + return -316; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -311; + return -317; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -312; + return -318; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -313; + return -319; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -314; + return -320; a += n; } assert(a <= e); @@ -6776,7 +6870,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -315; + return -321; } Hlw8012Config::Hlw8012Config() @@ -6811,7 +6905,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -316; + return -322; a += x; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -6828,13 +6922,13 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -317; + return -323; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -318; + return -324; return a-(const uint8_t *)b; } @@ -6847,33 +6941,33 @@ ssize_t Hlw8012Config::toMemory(uint8_t *b, ssize_t s) const if (m_sel != -1) { // 'sel': id=2, encoding=varint, tag=0x10 if (a >= e) - return -319; + return -325; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -320; + return -326; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -321; + return -327; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -322; + return -328; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -323; + return -329; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -324; + return -330; a += n; } assert(a <= e); @@ -6969,7 +7063,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -325; + return -331; } SX1276Config::SX1276Config() @@ -7010,7 +7104,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -326; + return -332; a += x; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -7036,13 +7130,13 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -327; + return -333; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -328; + return -334; return a-(const uint8_t *)b; } @@ -7055,66 +7149,66 @@ ssize_t SX1276Config::toMemory(uint8_t *b, ssize_t s) const if (m_dio0 != -1) { // 'dio0': id=1, encoding=varint, tag=0x8 if (a >= e) - return -329; + return -335; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -330; + return -336; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -331; + return -337; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -332; + return -338; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -333; + return -339; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -334; + return -340; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -335; + return -341; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -336; + return -342; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -337; + return -343; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -338; + return -344; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -339; + return -345; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -340; + return -346; a += n; } assert(a <= e); @@ -7264,7 +7358,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -341; + return -347; } Tone::Tone() @@ -7298,7 +7392,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -342; + return -348; a += x; switch (fid) { case 0x8: // freq id 1, type uint32_t, coding varint @@ -7312,13 +7406,13 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -343; + return -349; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -344; + return -350; return a-(const uint8_t *)b; } @@ -7331,22 +7425,22 @@ ssize_t Tone::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'freq': id=1, encoding=varint, tag=0x8 if (a >= e) - return -345; + return -351; *a++ = 0x8; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -346; + return -352; a += n; } // has duration? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'duration': id=2, encoding=varint, tag=0x10 if (a >= e) - return -347; + return -353; *a++ = 0x10; n = write_varint(a,e-a,m_duration); if (n <= 0) - return -348; + return -354; a += n; } assert(a <= e); @@ -7430,7 +7524,7 @@ int Tone::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } - return -349; + return -355; } Melody::Melody() @@ -7474,12 +7568,12 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -350; + return -356; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -351; + return -357; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -7492,13 +7586,13 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -352; + return -358; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -353; + return -359; return a-(const uint8_t *)b; } @@ -7511,20 +7605,20 @@ ssize_t Melody::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -354; + return -360; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -355; + return -361; a += n; } for (auto x : m_tones) { // 'tones': id=2, encoding=16bit, tag=0x14 if (3 > (e-a)) - return -356; + return -362; *a++ = 0x14; if ((e-a) < 2) - return -357; + return -363; write_u16(a,x); a += 2; } @@ -7628,20 +7722,20 @@ int Melody::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -358; + return -364; if (m_tones.size() <= x) - return -359; + return -365; if ((idxe[1] == 0) && (value == 0)) { m_tones.erase(m_tones.begin()+x); return 0; } } if (idxe[1] != 0) - return -360; + return -366; return parse_ascii_u16(&m_tones[x],value); } } - return -361; + return -367; } BuzzerConfig::BuzzerConfig() @@ -7685,7 +7779,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -362; + return -368; a += x; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -7697,7 +7791,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) int n; n = m_melodies.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -363; + return -369; a += ud.vi; } break; @@ -7706,13 +7800,13 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -364; + return -370; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -365; + return -371; return a-(const uint8_t *)b; } @@ -7725,23 +7819,23 @@ ssize_t BuzzerConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -366; + return -372; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -367; + return -373; a += n; } for (const auto &x : m_melodies) { // 'melodies': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -368; + return -374; *a++ = 0x12; ssize_t melodies_ws = x.calcSize(); n = write_varint(a,e-a,melodies_ws); a += n; if ((n <= 0) || (melodies_ws > (e-a))) - return -369; + return -375; n = x.toMemory(a,e-a); a += n; assert(n == melodies_ws); @@ -7846,20 +7940,20 @@ int BuzzerConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -370; + return -376; if (m_melodies.size() <= x) - return -371; + return -377; if ((idxe[1] == 0) && (value == 0)) { m_melodies.erase(m_melodies.begin()+x); return 0; } } if (idxe[1] != '.') - return -372; + return -378; return m_melodies[x].setByName(idxe+2,value); } } - return -373; + return -379; } HardwareConfig::HardwareConfig() @@ -8102,7 +8196,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -374; + return -380; a += x; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit @@ -8113,7 +8207,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_system.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -375; + return -381; a += ud.vi; } p_validbits |= ((uint16_t)1U << 1); @@ -8123,7 +8217,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_adc.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -376; + return -382; a += ud.vi; } p_validbits |= ((uint16_t)1U << 2); @@ -8134,7 +8228,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_gpios.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -377; + return -383; a += ud.vi; } break; @@ -8145,7 +8239,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_spibus.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -378; + return -384; a += ud.vi; } break; @@ -8157,7 +8251,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_button.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -379; + return -385; a += ud.vi; } break; @@ -8169,7 +8263,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_relay.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -380; + return -386; a += ud.vi; } break; @@ -8181,7 +8275,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_led.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -381; + return -387; a += ud.vi; } break; @@ -8192,7 +8286,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_buzzer.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -382; + return -388; a += ud.vi; } p_validbits |= ((uint16_t)1U << 3); @@ -8204,7 +8298,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_hlw8012.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -383; + return -389; a += ud.vi; } p_validbits |= ((uint16_t)1U << 4); @@ -8216,7 +8310,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_max7219.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -384; + return -390; a += ud.vi; } p_validbits |= ((uint16_t)1U << 5); @@ -8228,7 +8322,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_tlc5947.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -385; + return -391; a += ud.vi; } p_validbits |= ((uint16_t)1U << 6); @@ -8241,7 +8335,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_ws2812b.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -386; + return -392; a += ud.vi; } break; @@ -8252,7 +8346,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_dht.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -387; + return -393; a += ud.vi; } p_validbits |= ((uint16_t)1U << 7); @@ -8265,7 +8359,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_i2c.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -388; + return -394; a += ud.vi; } break; @@ -8277,7 +8371,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_hcsr04.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -389; + return -395; a += ud.vi; } break; @@ -8288,7 +8382,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_onewire.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -390; + return -396; a += ud.vi; } p_validbits |= ((uint16_t)1U << 8); @@ -8300,7 +8394,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_sx1276.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -391; + return -397; a += ud.vi; } p_validbits |= ((uint16_t)1U << 9); @@ -8313,7 +8407,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_iocluster.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -392; + return -398; a += ud.vi; } break; @@ -8324,7 +8418,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_display.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -393; + return -399; a += ud.vi; } p_validbits |= ((uint16_t)1U << 10); @@ -8335,13 +8429,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -394; + return -400; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -395; + return -401; return a-(const uint8_t *)b; } @@ -8354,10 +8448,10 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -396; + return -402; *a++ = 0x5; if ((e-a) < 4) - return -397; + return -403; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -8365,13 +8459,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 1))) { // 'system': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -398; + return -404; *a++ = 0xa; ssize_t system_ws = m_system.calcSize(); n = write_varint(a,e-a,system_ws); a += n; if ((n <= 0) || (system_ws > (e-a))) - return -399; + return -405; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -8381,13 +8475,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 2))) { // 'adc': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -400; + return -406; *a++ = 0x22; ssize_t adc_ws = m_adc.calcSize(); n = write_varint(a,e-a,adc_ws); a += n; if ((n <= 0) || (adc_ws > (e-a))) - return -401; + return -407; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -8401,13 +8495,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpios) { // 'gpios': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -402; + return -408; *a++ = 0x3a; ssize_t gpios_ws = x.calcSize(); n = write_varint(a,e-a,gpios_ws); a += n; if ((n <= 0) || (gpios_ws > (e-a))) - return -403; + return -409; n = x.toMemory(a,e-a); a += n; assert(n == gpios_ws); @@ -8416,13 +8510,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_spibus) { // 'spibus': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -404; + return -410; *a++ = 0x42; ssize_t spibus_ws = x.calcSize(); n = write_varint(a,e-a,spibus_ws); a += n; if ((n <= 0) || (spibus_ws > (e-a))) - return -405; + return -411; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -8432,14 +8526,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_button) { // 'button': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -406; + return -412; *a++ = 0x82; *a++ = 0x1; ssize_t button_ws = x.calcSize(); n = write_varint(a,e-a,button_ws); a += n; if ((n <= 0) || (button_ws > (e-a))) - return -407; + return -413; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -8449,14 +8543,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_relay) { // 'relay': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -408; + return -414; *a++ = 0x8a; *a++ = 0x1; ssize_t relay_ws = x.calcSize(); n = write_varint(a,e-a,relay_ws); a += n; if ((n <= 0) || (relay_ws > (e-a))) - return -409; + return -415; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -8466,14 +8560,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_led) { // 'led': id=18, encoding=lenpfx, tag=0x92 if (2 > (e-a)) - return -410; + return -416; *a++ = 0x92; *a++ = 0x1; ssize_t led_ws = x.calcSize(); n = write_varint(a,e-a,led_ws); a += n; if ((n <= 0) || (led_ws > (e-a))) - return -411; + return -417; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -8484,14 +8578,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'buzzer': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -412; + return -418; *a++ = 0x9a; *a++ = 0x1; ssize_t buzzer_ws = m_buzzer.calcSize(); n = write_varint(a,e-a,buzzer_ws); a += n; if ((n <= 0) || (buzzer_ws > (e-a))) - return -413; + return -419; n = m_buzzer.toMemory(a,e-a); a += n; assert(n == buzzer_ws); @@ -8502,14 +8596,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -414; + return -420; *a++ = 0xa2; *a++ = 0x1; ssize_t hlw8012_ws = m_hlw8012.calcSize(); n = write_varint(a,e-a,hlw8012_ws); a += n; if ((n <= 0) || (hlw8012_ws > (e-a))) - return -415; + return -421; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -8520,14 +8614,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 if (2 > (e-a)) - return -416; + return -422; *a++ = 0x82; *a++ = 0x2; ssize_t max7219_ws = m_max7219.calcSize(); n = write_varint(a,e-a,max7219_ws); a += n; if ((n <= 0) || (max7219_ws > (e-a))) - return -417; + return -423; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -8538,14 +8632,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -418; + return -424; *a++ = 0x8a; *a++ = 0x2; ssize_t tlc5947_ws = m_tlc5947.calcSize(); n = write_varint(a,e-a,tlc5947_ws); a += n; if ((n <= 0) || (tlc5947_ws > (e-a))) - return -419; + return -425; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); @@ -8555,14 +8649,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -420; + return -426; *a++ = 0x92; *a++ = 0x2; ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -421; + return -427; n = x.toMemory(a,e-a); a += n; assert(n == ws2812b_ws); @@ -8573,14 +8667,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -422; + return -428; *a++ = 0x9a; *a++ = 0x2; ssize_t dht_ws = m_dht.calcSize(); n = write_varint(a,e-a,dht_ws); a += n; if ((n <= 0) || (dht_ws > (e-a))) - return -423; + return -429; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -8590,14 +8684,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_i2c) { // 'i2c': id=36, encoding=lenpfx, tag=0x122 if (2 > (e-a)) - return -424; + return -430; *a++ = 0xa2; *a++ = 0x2; ssize_t i2c_ws = x.calcSize(); n = write_varint(a,e-a,i2c_ws); a += n; if ((n <= 0) || (i2c_ws > (e-a))) - return -425; + return -431; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -8607,14 +8701,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_hcsr04) { // 'hcsr04': id=37, encoding=lenpfx, tag=0x12a if (2 > (e-a)) - return -426; + return -432; *a++ = 0xaa; *a++ = 0x2; ssize_t hcsr04_ws = x.calcSize(); n = write_varint(a,e-a,hcsr04_ws); a += n; if ((n <= 0) || (hcsr04_ws > (e-a))) - return -427; + return -433; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -8625,14 +8719,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -428; + return -434; *a++ = 0xb2; *a++ = 0x2; ssize_t onewire_ws = m_onewire.calcSize(); n = write_varint(a,e-a,onewire_ws); a += n; if ((n <= 0) || (onewire_ws > (e-a))) - return -429; + return -435; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -8643,14 +8737,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -430; + return -436; *a++ = 0xba; *a++ = 0x2; ssize_t sx1276_ws = m_sx1276.calcSize(); n = write_varint(a,e-a,sx1276_ws); a += n; if ((n <= 0) || (sx1276_ws > (e-a))) - return -431; + return -437; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -8660,14 +8754,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_iocluster) { // 'iocluster': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) - return -432; + return -438; *a++ = 0xc2; *a++ = 0x2; ssize_t iocluster_ws = x.calcSize(); n = write_varint(a,e-a,iocluster_ws); a += n; if ((n <= 0) || (iocluster_ws > (e-a))) - return -433; + return -439; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -8678,14 +8772,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -434; + return -440; *a++ = 0x92; *a++ = 0x3; ssize_t display_ws = m_display.calcSize(); n = write_varint(a,e-a,display_ws); a += n; if ((n <= 0) || (display_ws > (e-a))) - return -435; + return -441; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -9242,16 +9336,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -436; + return -442; if (m_gpios.size() <= x) - return -437; + return -443; if ((idxe[1] == 0) && (value == 0)) { m_gpios.erase(m_gpios.begin()+x); return 0; } } if (idxe[1] != '.') - return -438; + return -444; return m_gpios[x].setByName(idxe+2,value); } } @@ -9272,16 +9366,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -439; + return -445; if (m_spibus.size() <= x) - return -440; + return -446; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -441; + return -447; return m_spibus[x].setByName(idxe+2,value); } } @@ -9303,16 +9397,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -442; + return -448; if (m_button.size() <= x) - return -443; + return -449; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -444; + return -450; return m_button[x].setByName(idxe+2,value); } } @@ -9334,16 +9428,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -445; + return -451; if (m_relay.size() <= x) - return -446; + return -452; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -447; + return -453; return m_relay[x].setByName(idxe+2,value); } } @@ -9365,16 +9459,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -448; + return -454; if (m_led.size() <= x) - return -449; + return -455; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -450; + return -456; return m_led[x].setByName(idxe+2,value); } } @@ -9440,16 +9534,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -451; + return -457; if (m_ws2812b.size() <= x) - return -452; + return -458; if ((idxe[1] == 0) && (value == 0)) { m_ws2812b.erase(m_ws2812b.begin()+x); return 0; } } if (idxe[1] != '.') - return -453; + return -459; return m_ws2812b[x].setByName(idxe+2,value); } } @@ -9482,16 +9576,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -454; + return -460; if (m_i2c.size() <= x) - return -455; + return -461; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -456; + return -462; return m_i2c[x].setByName(idxe+2,value); } } @@ -9513,16 +9607,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -457; + return -463; if (m_hcsr04.size() <= x) - return -458; + return -464; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -459; + return -465; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -9566,16 +9660,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -460; + return -466; if (m_iocluster.size() <= x) - return -461; + return -467; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -462; + return -468; return m_iocluster[x].setByName(idxe+2,value); } } @@ -9591,6 +9685,6 @@ int HardwareConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_DISPLAY - return -463; + return -469; } diff --git a/components/wfc/hwcfg_esp8285.h b/components/wfc/hwcfg_esp8285.h index d366de6..bef2308 100644 --- a/components/wfc/hwcfg_esp8285.h +++ b/components/wfc/hwcfg_esp8285.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -94,8 +95,8 @@ * asserts, comments, genlib, gnux */ -#ifndef HWCFG_H -#define HWCFG_H +#ifndef HWCFG_ESP8285_H +#define HWCFG_ESP8285_H #include #define OUTPUT_TO_ASCII 1 @@ -126,7 +127,7 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_esp8285.h" /* wfc support functions not needed */ typedef _ssize_t ssize_t; @@ -3058,7 +3059,9 @@ class AdcConfig */ uint8_t *mutable_clk_div(); + #ifdef CONFIG_IDF_TARGET_ESP32 // unused optional string hall_name, id 6 + #endif // CONFIG_IDF_TARGET_ESP32 // unused repeated AdcChannel channels, id 7 protected: @@ -3374,8 +3377,36 @@ class DisplayConfig */ uint32_t *mutable_maxy(); + // repeated string skip_env, id 5 + //! Function get const-access to the elements of skip_env. + const std::vector &skip_env() const; + //! Function to get the number of elements in skip_env. + size_t skip_env_size() const; + /*! + * Function to append a element to skip_env. + * @return point to newly added element. + */ + void add_skip_env(const estring &v); + //! Function to append an element to skip_env initialized by a C-string. + void add_skip_env(const char*); + //! Function to reset skip_env to its default/unset value. + void clear_skip_env(); + //! Get value of element x of skip_env. + const estring &skip_env(unsigned x) const; + //! Set skip_env using a constant reference + void set_skip_env(unsigned x, const estring &v); + /*! + * Provide mutable access to skip_env. + * @return pointer to member variable of skip_env. + */ + estring *mutable_skip_env(unsigned x); + //! Function to get mutable access to all elements of skip_env. + std::vector *mutable_skip_env(); + protected: + //! string skip_env, id 5 + std::vector m_skip_env; //! disp_t type, id 1 disp_t m_type = dt_none; //! unsigned options, id 2 @@ -8486,7 +8517,8 @@ inline size_t DisplayConfig::getMaxSize() // optional unsigned options, id 2 has maximum size 6 // optional unsigned maxx, id 3 has maximum size 6 // optional unsigned maxy, id 4 has maximum size 6 - return 20; + // repeated string skip_env, id 5 has unlimited size + return SIZE_MAX; } inline disp_t DisplayConfig::type() const @@ -8631,6 +8663,60 @@ inline void DisplayConfig::set_maxy(uint32_t v) +inline const estring &DisplayConfig::skip_env(unsigned x) const +{ + return m_skip_env[x]; +} + +inline const std::vector &DisplayConfig::skip_env() const +{ + return m_skip_env; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void DisplayConfig::clear_skip_env() +{ + m_skip_env.clear(); +} + +inline estring *DisplayConfig::mutable_skip_env(unsigned x) +{ + if (x >= m_skip_env.size()) + m_skip_env.resize(x+1); + return &m_skip_env[x]; +} + +inline std::vector *DisplayConfig::mutable_skip_env() +{ + return &m_skip_env; +} + +inline void DisplayConfig::add_skip_env(const estring &v) +{ + m_skip_env.push_back(v); +} + +inline void DisplayConfig::add_skip_env(const char *s) +{ + m_skip_env.push_back(s); +} + +inline void DisplayConfig::set_skip_env(unsigned x, const estring &v) +{ + assert(x < m_skip_env.size()); + m_skip_env[x] = v; +} + +inline size_t DisplayConfig::skip_env_size() const +{ + return m_skip_env.size(); +} + + + inline size_t SpiDeviceConfig::getMaxSize() { // optional spidrv_t drv, id 1 has maximum size 2 @@ -9993,7 +10079,7 @@ inline size_t HardwareConfig::getMaxSize() // optional OneWireConfig onewire, id 38 has maximum size 10 // optional SX1276Config sx1276, id 39 has maximum size 20 // repeated GpioCluster iocluster, id 40 has unlimited size - // optional DisplayConfig display, id 50 has maximum size 22 + // optional DisplayConfig display, id 50 has maximum size 21 return SIZE_MAX; } diff --git a/components/wfc/hwcfg_pc.cpp b/components/wfc/hwcfg_pc.cpp index 3b0ed3c..42f6125 100644 --- a/components/wfc/hwcfg_pc.cpp +++ b/components/wfc/hwcfg_pc.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,7 @@ * options from commandline: * * options from pc: + * cfgdefs : "all" * Optimize : "speed" * toASCII : "toASCII" * toSink : "" @@ -94,9 +95,9 @@ #include #include #include -#include "hwcfg.h" +#include "hwcfg_pc.h" -#include "wfccore.h" +#include "wfccore_pc.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -357,18 +358,10 @@ void SystemConfig::clear() m_console_tx = 0; m_model_name.clear(); m_model_number.clear(); - #ifdef CONFIG_USB_DIAGLOG m_usb_diag = true; - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE m_usb_con = true; - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB m_cc1_gpio = -1; - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB m_cc2_gpio = -1; - #endif // CONFIG_ESP_PHY_ENABLE_USB p_validbits = 0; } @@ -384,18 +377,10 @@ void SystemConfig::toASCII(std::ostream &o, size_t indent) const ascii_numeric(o, indent, "console_tx", (signed) m_console_tx); ascii_string(o,indent,m_model_name.data(),m_model_name.size(),"model_name"); ascii_string(o,indent,m_model_number.data(),m_model_number.size(),"model_number"); - #ifdef CONFIG_USB_DIAGLOG ascii_bool(o, indent, "usb_diag", m_usb_diag); - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE ascii_bool(o, indent, "usb_con", m_usb_con); - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB ascii_numeric(o, indent, "cc1_gpio", (signed) m_cc1_gpio); - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB ascii_numeric(o, indent, "cc2_gpio", (signed) m_cc2_gpio); - #endif // CONFIG_ESP_PHY_ENABLE_USB --indent; ascii_indent(o,indent); o << '}'; @@ -497,21 +482,16 @@ ssize_t SystemConfig::fromMemory(const void *b, ssize_t s) a += v; } break; - #ifdef CONFIG_USB_DIAGLOG case 0x4b: // usb_diag id 9, type bool, coding 8bit if (a >= e) return -10; set_usb_diag(*a++); break; - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE case 0x53: // usb_con id 10, type bool, coding 8bit if (a >= e) return -11; set_usb_con(*a++); break; - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB case 0x58: // cc1_gpio id 11, type int8_t, coding signed varint { varint_t v; @@ -522,8 +502,6 @@ ssize_t SystemConfig::fromMemory(const void *b, ssize_t s) set_cc1_gpio(varint_sint(v)); } break; - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB case 0x60: // cc2_gpio id 12, type int8_t, coding signed varint { varint_t v; @@ -534,7 +512,6 @@ ssize_t SystemConfig::fromMemory(const void *b, ssize_t s) set_cc2_gpio(varint_sint(v)); } break; - #endif // CONFIG_ESP_PHY_ENABLE_USB default: // unknown field (option unknown=skip) { @@ -660,7 +637,6 @@ ssize_t SystemConfig::toMemory(uint8_t *b, ssize_t s) const memcpy(a,m_model_number.data(),model_number_s); a += model_number_s; } - #ifdef CONFIG_USB_DIAGLOG // has usb_diag? if (m_usb_diag != true) { // 'usb_diag': id=9, encoding=8bit, tag=0x4b @@ -669,8 +645,6 @@ ssize_t SystemConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x4b; *a++ = m_usb_diag; } - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE // has usb_con? if (m_usb_con != true) { // 'usb_con': id=10, encoding=8bit, tag=0x53 @@ -679,8 +653,6 @@ ssize_t SystemConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x53; *a++ = m_usb_con; } - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB // has cc1_gpio? if (m_cc1_gpio != -1) { // 'cc1_gpio': id=11, encoding=varint, tag=0x58 @@ -692,8 +664,6 @@ ssize_t SystemConfig::toMemory(uint8_t *b, ssize_t s) const return -35; a += n; } - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB // has cc2_gpio? if (m_cc2_gpio != -1) { // 'cc2_gpio': id=12, encoding=varint, tag=0x60 @@ -705,7 +675,6 @@ ssize_t SystemConfig::toMemory(uint8_t *b, ssize_t s) const return -37; a += n; } - #endif // CONFIG_ESP_PHY_ENABLE_USB assert(a <= e); return a-b; } @@ -762,34 +731,26 @@ void SystemConfig::toWire(void (*put)(uint8_t)) const send_varint(put,model_number_s); send_bytes(put,(const uint8_t*) m_model_number.data(),model_number_s); } - #ifdef CONFIG_USB_DIAGLOG if (m_usb_diag != true) { // 'usb_diag': id=9, encoding=8bit, tag=0x4b put(0x4b); // 'usb_diag': id=9 put(m_usb_diag); } - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE if (m_usb_con != true) { // 'usb_con': id=10, encoding=8bit, tag=0x53 put(0x53); // 'usb_con': id=10 put(m_usb_con); } - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (m_cc1_gpio != -1) { // 'cc1_gpio': id=11, encoding=varint, tag=0x58 put(0x58); // 'cc1_gpio': id=11 send_varint(put,sint_varint(m_cc1_gpio)); } - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (m_cc2_gpio != -1) { // 'cc2_gpio': id=12, encoding=varint, tag=0x60 put(0x60); // 'cc2_gpio': id=12 send_varint(put,sint_varint(m_cc2_gpio)); } - #endif // CONFIG_ESP_PHY_ENABLE_USB } void SystemConfig::toString(std::string &put) const @@ -844,34 +805,26 @@ void SystemConfig::toString(std::string &put) const send_varint(put,model_number_s); put.append((const char *)(const uint8_t*) m_model_number.data(),model_number_s); } - #ifdef CONFIG_USB_DIAGLOG if (m_usb_diag != true) { // 'usb_diag': id=9, encoding=8bit, tag=0x4b put.push_back(0x4b); // 'usb_diag': id=9 put.push_back(m_usb_diag); } - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE if (m_usb_con != true) { // 'usb_con': id=10, encoding=8bit, tag=0x53 put.push_back(0x53); // 'usb_con': id=10 put.push_back(m_usb_con); } - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (m_cc1_gpio != -1) { // 'cc1_gpio': id=11, encoding=varint, tag=0x58 put.push_back(0x58); // 'cc1_gpio': id=11 send_varint(put,sint_varint(m_cc1_gpio)); } - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (m_cc2_gpio != -1) { // 'cc2_gpio': id=12, encoding=varint, tag=0x60 put.push_back(0x60); // 'cc2_gpio': id=12 send_varint(put,sint_varint(m_cc2_gpio)); } - #endif // CONFIG_ESP_PHY_ENABLE_USB } void SystemConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -910,30 +863,22 @@ void SystemConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"model_number"); json_cstr(json,m_model_number.c_str()); } - #ifdef CONFIG_USB_DIAGLOG if (has_usb_diag()) { fsep = json_indent(json,indLvl,fsep,"usb_diag"); json << (m_usb_diag ? "true" : "false"); } - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE if (has_usb_con()) { fsep = json_indent(json,indLvl,fsep,"usb_con"); json << (m_usb_con ? "true" : "false"); } - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (has_cc1_gpio()) { fsep = json_indent(json,indLvl,fsep,"cc1_gpio"); json << (int) m_cc1_gpio; } - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (has_cc2_gpio()) { fsep = json_indent(json,indLvl,fsep,"cc2_gpio"); json << (int) m_cc2_gpio; } - #endif // CONFIG_ESP_PHY_ENABLE_USB if (fsep == '{') json.put('{'); json.put('\n'); @@ -984,30 +929,22 @@ size_t SystemConfig::calcSize() const size_t model_number_s = m_model_number.size(); r += model_number_s + wiresize(model_number_s) + 1 /* tag(model_number) 0x40 */; } - #ifdef CONFIG_USB_DIAGLOG // optional bool usb_diag, id 9 if (m_usb_diag != true) { r += 2; } - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE // optional bool usb_con, id 10 if (m_usb_con != true) { r += 2; } - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB // optional sint8 cc1_gpio, id 11 if (m_cc1_gpio != -1) { r += wiresize_s((varint_t)m_cc1_gpio) + 1 /* tag(cc1_gpio) 0x58 */; } - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB // optional sint8 cc2_gpio, id 12 if (m_cc2_gpio != -1) { r += wiresize_s((varint_t)m_cc2_gpio) + 1 /* tag(cc2_gpio) 0x60 */; } - #endif // CONFIG_ESP_PHY_ENABLE_USB return r; } @@ -1031,22 +968,14 @@ bool SystemConfig::operator != (const SystemConfig &r) const return true; if (has_model_number() && (m_model_number != r.m_model_number)) return true; - #ifdef CONFIG_USB_DIAGLOG if (has_usb_diag() && (m_usb_diag != r.m_usb_diag)) return true; - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE if (has_usb_con() && (m_usb_con != r.m_usb_con)) return true; - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (has_cc1_gpio() && (m_cc1_gpio != r.m_cc1_gpio)) return true; - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (has_cc2_gpio() && (m_cc2_gpio != r.m_cc2_gpio)) return true; - #endif // CONFIG_ESP_PHY_ENABLE_USB return false; } @@ -1139,7 +1068,6 @@ int SystemConfig::setByName(const char *name, const char *value) int r = m_model_number.size(); return r; } - #ifdef CONFIG_USB_DIAGLOG if (0 == strcmp(name,"usb_diag")) { if (value == 0) { clear_usb_diag(); @@ -1148,8 +1076,6 @@ int SystemConfig::setByName(const char *name, const char *value) int r = parse_ascii_bool(&m_usb_diag,value); return r; } - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE if (0 == strcmp(name,"usb_con")) { if (value == 0) { clear_usb_con(); @@ -1158,8 +1084,6 @@ int SystemConfig::setByName(const char *name, const char *value) int r = parse_ascii_bool(&m_usb_con,value); return r; } - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (0 == strcmp(name,"cc1_gpio")) { if (value == 0) { clear_cc1_gpio(); @@ -1168,8 +1092,6 @@ int SystemConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cc1_gpio,value); return r; } - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB if (0 == strcmp(name,"cc2_gpio")) { if (value == 0) { clear_cc2_gpio(); @@ -1178,7 +1100,6 @@ int SystemConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cc2_gpio,value); return r; } - #endif // CONFIG_ESP_PHY_ENABLE_USB return -38; } @@ -1948,12 +1869,8 @@ void ButtonConfig::clear() m_gpio = -1; m_presslvl = 0; m_pull_mode = pull_none; - #ifdef CONFIG_ROTARYENCODER m_clk = -1; - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER m_dt = -1; - #endif // CONFIG_ROTARYENCODER } void ButtonConfig::toASCII(std::ostream &o, size_t indent) const @@ -1972,12 +1889,8 @@ void ButtonConfig::toASCII(std::ostream &o, size_t indent) const o << ".up"; o << (pull_mode_up() ? " = true;" : " = false;"); --indent; - #ifdef CONFIG_ROTARYENCODER ascii_numeric(o, indent, "clk", (signed) m_clk); - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER ascii_numeric(o, indent, "dt", (signed) m_dt); - #endif // CONFIG_ROTARYENCODER --indent; ascii_indent(o,indent); o << '}'; @@ -2030,7 +1943,6 @@ ssize_t ButtonConfig::fromMemory(const void *b, ssize_t s) set_pull_mode((pull_mode_t) v); } break; - #ifdef CONFIG_ROTARYENCODER case 0x28: // clk id 5, type int8_t, coding signed varint { varint_t v; @@ -2041,8 +1953,6 @@ ssize_t ButtonConfig::fromMemory(const void *b, ssize_t s) set_clk(varint_sint(v)); } break; - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER case 0x30: // dt id 6, type int8_t, coding signed varint { varint_t v; @@ -2053,7 +1963,6 @@ ssize_t ButtonConfig::fromMemory(const void *b, ssize_t s) set_dt(varint_sint(v)); } break; - #endif // CONFIG_ROTARYENCODER default: // unknown field (option unknown=skip) { @@ -2120,7 +2029,6 @@ ssize_t ButtonConfig::toMemory(uint8_t *b, ssize_t s) const return -90; a += n; } - #ifdef CONFIG_ROTARYENCODER // has clk? if (m_clk != -1) { // 'clk': id=5, encoding=varint, tag=0x28 @@ -2132,8 +2040,6 @@ ssize_t ButtonConfig::toMemory(uint8_t *b, ssize_t s) const return -92; a += n; } - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER // has dt? if (m_dt != -1) { // 'dt': id=6, encoding=varint, tag=0x30 @@ -2145,7 +2051,6 @@ ssize_t ButtonConfig::toMemory(uint8_t *b, ssize_t s) const return -94; a += n; } - #endif // CONFIG_ROTARYENCODER assert(a <= e); return a-b; } @@ -2174,20 +2079,16 @@ void ButtonConfig::toWire(void (*put)(uint8_t)) const put(0x20); // 'pull_mode': id=4 send_varint(put,m_pull_mode); } - #ifdef CONFIG_ROTARYENCODER if (m_clk != -1) { // 'clk': id=5, encoding=varint, tag=0x28 put(0x28); // 'clk': id=5 send_varint(put,sint_varint(m_clk)); } - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER if (m_dt != -1) { // 'dt': id=6, encoding=varint, tag=0x30 put(0x30); // 'dt': id=6 send_varint(put,sint_varint(m_dt)); } - #endif // CONFIG_ROTARYENCODER } void ButtonConfig::toString(std::string &put) const @@ -2214,20 +2115,16 @@ void ButtonConfig::toString(std::string &put) const put.push_back(0x20); // 'pull_mode': id=4 send_varint(put,m_pull_mode); } - #ifdef CONFIG_ROTARYENCODER if (m_clk != -1) { // 'clk': id=5, encoding=varint, tag=0x28 put.push_back(0x28); // 'clk': id=5 send_varint(put,sint_varint(m_clk)); } - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER if (m_dt != -1) { // 'dt': id=6, encoding=varint, tag=0x30 put.push_back(0x30); // 'dt': id=6 send_varint(put,sint_varint(m_dt)); } - #endif // CONFIG_ROTARYENCODER } void ButtonConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -2250,18 +2147,14 @@ void ButtonConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"pull_mode"); json << (unsigned) m_pull_mode; } - #ifdef CONFIG_ROTARYENCODER if (has_clk()) { fsep = json_indent(json,indLvl,fsep,"clk"); json << (int) m_clk; } - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER if (has_dt()) { fsep = json_indent(json,indLvl,fsep,"dt"); json << (int) m_dt; } - #endif // CONFIG_ROTARYENCODER if (fsep == '{') json.put('{'); json.put('\n'); @@ -2292,18 +2185,14 @@ size_t ButtonConfig::calcSize() const if (m_pull_mode != pull_none) { r += wiresize((varint_t)m_pull_mode) + 1 /* tag(pull_mode) 0x20 */; } - #ifdef CONFIG_ROTARYENCODER // optional sint8 clk, id 5 if (m_clk != -1) { r += wiresize_s((varint_t)m_clk) + 1 /* tag(clk) 0x28 */; } - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER // optional sint8 dt, id 6 if (m_dt != -1) { r += wiresize_s((varint_t)m_dt) + 1 /* tag(dt) 0x30 */; } - #endif // CONFIG_ROTARYENCODER return r; } @@ -2317,14 +2206,10 @@ bool ButtonConfig::operator != (const ButtonConfig &r) const return true; if (has_pull_mode() && (m_pull_mode != r.m_pull_mode)) return true; - #ifdef CONFIG_ROTARYENCODER if (has_clk() && (m_clk != r.m_clk)) return true; - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER if (has_dt() && (m_dt != r.m_dt)) return true; - #endif // CONFIG_ROTARYENCODER return false; } @@ -2398,7 +2283,6 @@ int ButtonConfig::setByName(const char *name, const char *value) return r; } } - #ifdef CONFIG_ROTARYENCODER if (0 == strcmp(name,"clk")) { if (value == 0) { clear_clk(); @@ -2407,8 +2291,6 @@ int ButtonConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_clk,value); return r; } - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER if (0 == strcmp(name,"dt")) { if (value == 0) { clear_dt(); @@ -2417,7 +2299,6 @@ int ButtonConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dt,value); return r; } - #endif // CONFIG_ROTARYENCODER return -96; } @@ -4175,9 +4056,7 @@ void I2CConfig::clear() m_scl = -1; m_freq = 100000; m_xpullup = false; - #ifdef CONFIG_I2C_XDEV m_devices.clear(); - #endif // CONFIG_I2C_XDEV p_validbits = 0; } @@ -4190,7 +4069,6 @@ void I2CConfig::toASCII(std::ostream &o, size_t indent) const ascii_numeric(o, indent, "scl", (signed) m_scl); ascii_numeric(o, indent, "freq", m_freq); ascii_bool(o, indent, "xpullup", m_xpullup); - #ifdef CONFIG_I2C_XDEV ascii_indent(o,indent); size_t s_devices = m_devices.size(); o << "devices[" << s_devices << "] = {"; @@ -4217,7 +4095,6 @@ void I2CConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_I2C_XDEV --indent; ascii_indent(o,indent); o << '}'; @@ -4279,7 +4156,6 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) return -186; set_xpullup(*a++); break; - #ifdef CONFIG_I2C_XDEV case 0x32: { // devices id 6, packed i2cdev_t[] coding 2 varint_t v; int n = read_varint(a,e-a,&v); // length of packed @@ -4296,7 +4172,6 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) m_devices.push_back((i2cdev_t)v); } while (a < ae); } break; - #endif // CONFIG_I2C_XDEV default: // unknown field (option unknown=skip) { @@ -4371,7 +4246,6 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x2b; *a++ = m_xpullup; } - #ifdef CONFIG_I2C_XDEV if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 if (a >= e) @@ -4387,7 +4261,6 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const for (size_t x = 0; x != devices_ne; ++x) a += write_varint(a,e-a,m_devices[x]); } - #endif // CONFIG_I2C_XDEV assert(a <= e); return a-b; } @@ -4419,7 +4292,6 @@ void I2CConfig::toWire(void (*put)(uint8_t)) const put(0x2b); // 'xpullup': id=5 put(m_xpullup); } - #ifdef CONFIG_I2C_XDEV if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 put(0x32); // 'devices': id=6 @@ -4430,7 +4302,6 @@ void I2CConfig::toWire(void (*put)(uint8_t)) const for (size_t x = 0; x != devices_ne; ++x) send_varint(put,m_devices[x]); } - #endif // CONFIG_I2C_XDEV } void I2CConfig::toString(std::string &put) const @@ -4460,7 +4331,6 @@ void I2CConfig::toString(std::string &put) const put.push_back(0x2b); // 'xpullup': id=5 put.push_back(m_xpullup); } - #ifdef CONFIG_I2C_XDEV if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 put.push_back(0x32); // 'devices': id=6 @@ -4471,7 +4341,6 @@ void I2CConfig::toString(std::string &put) const for (size_t x = 0; x != devices_ne; ++x) send_varint(put,m_devices[x]); } - #endif // CONFIG_I2C_XDEV } void I2CConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -4498,7 +4367,6 @@ void I2CConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"xpullup"); json << (m_xpullup ? "true" : "false"); } - #ifdef CONFIG_I2C_XDEV if (size_t s = m_devices.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -4517,7 +4385,6 @@ void I2CConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_I2C_XDEV if (fsep == '{') json.put('{'); json.put('\n'); @@ -4551,7 +4418,6 @@ size_t I2CConfig::calcSize() const if (m_xpullup != false) { r += 2; } - #ifdef CONFIG_I2C_XDEV // repeated i2cdev_t devices, id 6 if (!m_devices.empty()) { // devices: packed repeated i2cdev_t @@ -4560,7 +4426,6 @@ size_t I2CConfig::calcSize() const devices_dl += wiresize((varint_t)m_devices[x]); r += devices_dl + wiresize(devices_dl) /* data length */ + 1 /* tag(devices) 0x30 */; } - #endif // CONFIG_I2C_XDEV return r; } @@ -4578,10 +4443,8 @@ bool I2CConfig::operator != (const I2CConfig &r) const return true; if (has_xpullup() && (m_xpullup != r.m_xpullup)) return true; - #ifdef CONFIG_I2C_XDEV if (m_devices != r.m_devices) return true; - #endif // CONFIG_I2C_XDEV return false; } @@ -4645,7 +4508,6 @@ int I2CConfig::setByName(const char *name, const char *value) int r = parse_ascii_bool(&m_xpullup,value); return r; } - #ifdef CONFIG_I2C_XDEV if (0 == memcmp(name,"devices",7)) { if ((name[7] == 0) && (value == 0)) { clear_devices(); @@ -4700,7 +4562,6 @@ int I2CConfig::setByName(const char *name, const char *value) return -205; } } - #endif // CONFIG_I2C_XDEV return -206; } @@ -7515,6 +7376,7 @@ void DisplayConfig::clear() m_options = 0; m_maxx = 0; m_maxy = 1; + m_skip_env.clear(); p_validbits = 0; } @@ -7531,6 +7393,18 @@ void DisplayConfig::toASCII(std::ostream &o, size_t indent) const ascii_numeric(o, indent, "options", m_options); ascii_numeric(o, indent, "maxx", m_maxx); ascii_numeric(o, indent, "maxy", m_maxy); + ascii_indent(o,indent); + size_t s_skip_env = m_skip_env.size(); + o << "skip_env[" << s_skip_env << "] = {"; + ++indent; + for (size_t i = 0, e = s_skip_env; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + ascii_string(o,indent,m_skip_env[i].data(),m_skip_env[i].size(),0); + } + --indent; + ascii_indent(o,indent); + o << '}'; --indent; ascii_indent(o,indent); o << '}'; @@ -7587,12 +7461,23 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) set_maxy(v); } break; + case 0x2a: // skip_env id 5, type std::string, coding byte[] + { + varint_t v; + int n = read_varint(a,e-a,&v); + a += n; + if ((n <= 0) || ((a+v) > e)) + return -347; + m_skip_env.emplace_back((const char*)a,v); + a += v; + } + break; default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -347; + return -348; a += s; break; } @@ -7600,7 +7485,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -348; + return -349; return a-(const uint8_t *)b; } @@ -7613,46 +7498,59 @@ ssize_t DisplayConfig::toMemory(uint8_t *b, ssize_t s) const if (m_type != dt_none) { // 'type': id=1, encoding=varint, tag=0x8 if (a >= e) - return -349; + return -350; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -350; + return -351; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -351; + return -352; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -352; + return -353; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -353; + return -354; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -354; + return -355; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -355; + return -356; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -356; + return -357; a += n; } + for (const auto &x : m_skip_env) { + // 'skip_env': id=5, encoding=lenpfx, tag=0x2a + if (a >= e) + return -358; + *a++ = 0x2a; + ssize_t skip_env_s = x.size(); + n = write_varint(a,e-a,skip_env_s); + a += n; + if ((n <= 0) || ((e-a) < skip_env_s)) + return -359; + memcpy(a,x.data(),skip_env_s); + a += skip_env_s; + } assert(a <= e); return a-b; } @@ -7679,6 +7577,13 @@ void DisplayConfig::toWire(void (*put)(uint8_t)) const put(0x20); // 'maxy': id=4 send_varint(put,m_maxy); } + for (size_t x = 0, y = m_skip_env.size(); x != y; ++x) { + // 'skip_env': id=5, encoding=lenpfx, tag=0x2a + put(0x2a); // 'skip_env': id=5 + size_t skip_env_s = m_skip_env[x].size(); + send_varint(put,skip_env_s); + send_bytes(put,(const uint8_t*) m_skip_env[x].data(),skip_env_s); + } } void DisplayConfig::toString(std::string &put) const @@ -7703,6 +7608,13 @@ void DisplayConfig::toString(std::string &put) const put.push_back(0x20); // 'maxy': id=4 send_varint(put,m_maxy); } + for (size_t x = 0, y = m_skip_env.size(); x != y; ++x) { + // 'skip_env': id=5, encoding=lenpfx, tag=0x2a + put.push_back(0x2a); // 'skip_env': id=5 + size_t skip_env_s = m_skip_env[x].size(); + send_varint(put,skip_env_s); + put.append((const char *)(const uint8_t*) m_skip_env[x].data(),skip_env_s); + } } void DisplayConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -7731,6 +7643,24 @@ void DisplayConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"maxy"); json << m_maxy; } + if (size_t s = m_skip_env.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"skip_env\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + json_cstr(json,m_skip_env[i].c_str()); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -7760,6 +7690,15 @@ size_t DisplayConfig::calcSize() const if (0 != (p_validbits & ((uint8_t)1U << 2))) { r += wiresize((varint_t)m_maxy) + 1 /* tag(maxy) 0x20 */; } + // repeated string skip_env, id 5 + if (!m_skip_env.empty()) { + // skip_env: repeated std::string + for (size_t x = 0, y = m_skip_env.size(); x < y; ++x) { + size_t s = m_skip_env[x].size(); + r += wiresize(s); + r += s + 1 /* tag(skip_env) 0x28 */; + } + } return r; } @@ -7775,6 +7714,8 @@ bool DisplayConfig::operator != (const DisplayConfig &r) const return true; if (has_maxy() && (m_maxy != r.m_maxy)) return true; + if (m_skip_env != r.m_skip_env) + return true; return false; } @@ -7802,7 +7743,7 @@ int DisplayConfig::setByName(const char *name, const char *value) disp_t v; size_t r = parse_ascii_disp_t(&v,value); if (r == 0) - return -357; + return -360; set_type(v); return r; } @@ -7836,7 +7777,37 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -358; + if (0 == memcmp(name,"skip_env",8)) { + if ((name[8] == 0) && (value == 0)) { + clear_skip_env(); + return 0; + } else if (name[8] == '[') { + char *idxe; + unsigned long x; + if ((name[9] == '+') && (name[10] == ']')) { + x = m_skip_env.size(); + m_skip_env.resize(x+1); + idxe = (char*)(name + 10); + if (value == 0) + return 0; + } else { + x = strtoul(name+9,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+9))) + return -361; + if (m_skip_env.size() <= x) + return -362; + if ((idxe[1] == 0) && (value == 0)) { + m_skip_env.erase(m_skip_env.begin()+x); + return 0; + } + } + if (idxe[1] != 0) + return -363; + m_skip_env[x] = value; + return m_skip_env[x].size(); + } + } + return -364; } Message *DisplayConfig::p_getMember(const char *s, unsigned n) @@ -7889,7 +7860,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -359; + return -365; a += fn; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -7897,7 +7868,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -360; + return -366; a += n; set_drv((spidrv_t) v); } @@ -7907,7 +7878,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -361; + return -367; a += n; set_cs(varint_sint(v)); } @@ -7917,7 +7888,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -362; + return -368; a += n; set_intr(varint_sint(v)); } @@ -7927,7 +7898,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -363; + return -369; a += n; set_reset(varint_sint(v)); } @@ -7937,7 +7908,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -364; + return -370; a += n; set_cd(varint_sint(v)); } @@ -7947,7 +7918,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -365; + return -371; a += n; set_freq(v); } @@ -7957,7 +7928,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -366; + return -372; a += s; break; } @@ -7965,7 +7936,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -367; + return -373; return a-(const uint8_t *)b; } @@ -7978,66 +7949,66 @@ ssize_t SpiDeviceConfig::toMemory(uint8_t *b, ssize_t s) const if (m_drv != spidrv_invalid) { // 'drv': id=1, encoding=varint, tag=0x8 if (a >= e) - return -368; + return -374; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -369; + return -375; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -370; + return -376; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -371; + return -377; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -372; + return -378; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -373; + return -379; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -374; + return -380; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -375; + return -381; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -376; + return -382; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -377; + return -383; a += n; } // has freq? if (m_freq != 0) { // 'freq': id=6, encoding=varint, tag=0x30 if (a >= e) - return -378; + return -384; *a++ = 0x30; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -379; + return -385; a += n; } assert(a <= e); @@ -8227,7 +8198,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) spidrv_t v; size_t r = parse_ascii_spidrv_t(&v,value); if (r == 0) - return -380; + return -386; set_drv(v); return r; } @@ -8271,7 +8242,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_u64(&m_freq,value); return r; } - return -381; + return -387; } Message *SpiDeviceConfig::p_getMember(const char *s, unsigned n) @@ -8360,7 +8331,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -382; + return -388; a += fn; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -8368,7 +8339,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -383; + return -389; a += n; set_host(varint_sint(v)); } @@ -8378,7 +8349,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -384; + return -390; a += n; set_mosi(varint_sint(v)); } @@ -8388,7 +8359,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -385; + return -391; a += n; set_miso(varint_sint(v)); } @@ -8398,7 +8369,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -386; + return -392; a += n; set_sclk(varint_sint(v)); } @@ -8408,7 +8379,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -387; + return -393; a += n; set_wp(varint_sint(v)); } @@ -8418,7 +8389,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -388; + return -394; a += n; set_hold(varint_sint(v)); } @@ -8428,7 +8399,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -389; + return -395; a += n; set_options((spiopt_t) v); } @@ -8438,7 +8409,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -390; + return -396; a += n; set_dma(varint_sint(v)); } @@ -8449,14 +8420,14 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -391; + return -397; m_devices.emplace_back(); if (v != 0) { n = m_devices.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -392; + return -398; a += v; } } @@ -8466,7 +8437,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -393; + return -399; a += s; break; } @@ -8474,7 +8445,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -394; + return -400; return a-(const uint8_t *)b; } @@ -8487,100 +8458,100 @@ ssize_t SpiBusConfig::toMemory(uint8_t *b, ssize_t s) const if (m_host != -1) { // 'host': id=1, encoding=varint, tag=0x8 if (a >= e) - return -395; + return -401; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -396; + return -402; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -397; + return -403; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -398; + return -404; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -399; + return -405; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -400; + return -406; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -401; + return -407; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -402; + return -408; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -403; + return -409; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -404; + return -410; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -405; + return -411; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -406; + return -412; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -407; + return -413; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -408; + return -414; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -409; + return -415; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -410; + return -416; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -411; + return -417; *a++ = 0x4a; ssize_t devices_ws = x.calcSize(); n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -412; + return -418; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -8911,7 +8882,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) return eptr - value; } if (*name++ != '.') { - return -413; + return -419; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; int r = parse_ascii_bool(&tmp,value); @@ -8980,20 +8951,20 @@ int SpiBusConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -414; + return -420; if (m_devices.size() <= x) - return -415; + return -421; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -416; + return -422; return m_devices[x].setByName(idxe+2,value); } } - return -417; + return -423; } Message *SpiBusConfig::p_getMember(const char *s, unsigned n) @@ -9043,7 +9014,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -418; + return -424; a += fn; switch (fid) { case 0xa: // name id 1, type std::string, coding byte[] @@ -9052,7 +9023,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -419; + return -425; m_name.assign((const char*)a,v); a += v; } @@ -9062,7 +9033,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -420; + return -426; a += n; set_base(v); } @@ -9072,7 +9043,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -421; + return -427; a += n; set_numio(v); } @@ -9082,7 +9053,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -422; + return -428; a += n; set_int_a(varint_sint(v)); } @@ -9092,7 +9063,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -423; + return -429; a += n; set_int_b(varint_sint(v)); } @@ -9102,7 +9073,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -424; + return -430; a += s; break; } @@ -9110,7 +9081,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -425; + return -431; return a-(const uint8_t *)b; } @@ -9123,13 +9094,13 @@ ssize_t GpioCluster::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -426; + return -432; *a++ = 0xa; ssize_t name_s = m_name.size(); n = write_varint(a,e-a,name_s); a += n; if ((n <= 0) || ((e-a) < name_s)) - return -427; + return -433; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -9137,44 +9108,44 @@ ssize_t GpioCluster::toMemory(uint8_t *b, ssize_t s) const if (m_base != 0) { // 'base': id=2, encoding=varint, tag=0x10 if (a >= e) - return -428; + return -434; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -429; + return -435; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -430; + return -436; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -431; + return -437; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -432; + return -438; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -433; + return -439; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -434; + return -440; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -435; + return -441; a += n; } assert(a <= e); @@ -9376,7 +9347,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -436; + return -442; } Message *GpioCluster::p_getMember(const char *s, unsigned n) @@ -9418,7 +9389,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -437; + return -443; a += fn; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -9426,7 +9397,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -438; + return -444; a += n; set_sel(varint_sint(v)); } @@ -9436,7 +9407,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -439; + return -445; a += n; set_cf(varint_sint(v)); } @@ -9446,7 +9417,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -440; + return -446; a += n; set_cf1(varint_sint(v)); } @@ -9456,7 +9427,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -441; + return -447; a += s; break; } @@ -9464,7 +9435,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -442; + return -448; return a-(const uint8_t *)b; } @@ -9477,33 +9448,33 @@ ssize_t Hlw8012Config::toMemory(uint8_t *b, ssize_t s) const if (m_sel != -1) { // 'sel': id=2, encoding=varint, tag=0x10 if (a >= e) - return -443; + return -449; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -444; + return -450; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -445; + return -451; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -446; + return -452; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -447; + return -453; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -448; + return -454; a += n; } assert(a <= e); @@ -9643,7 +9614,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -449; + return -455; } Message *Hlw8012Config::p_getMember(const char *s, unsigned n) @@ -9691,7 +9662,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -450; + return -456; a += fn; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -9699,7 +9670,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -451; + return -457; a += n; set_dio0(varint_sint(v)); } @@ -9709,7 +9680,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -452; + return -458; a += n; set_dio1(varint_sint(v)); } @@ -9719,7 +9690,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -453; + return -459; a += n; set_dio2(varint_sint(v)); } @@ -9729,7 +9700,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -454; + return -460; a += n; set_dio3(varint_sint(v)); } @@ -9739,7 +9710,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -455; + return -461; a += n; set_dio4(varint_sint(v)); } @@ -9749,7 +9720,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -456; + return -462; a += n; set_dio5(varint_sint(v)); } @@ -9759,7 +9730,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -457; + return -463; a += s; break; } @@ -9767,7 +9738,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -458; + return -464; return a-(const uint8_t *)b; } @@ -9780,66 +9751,66 @@ ssize_t SX1276Config::toMemory(uint8_t *b, ssize_t s) const if (m_dio0 != -1) { // 'dio0': id=1, encoding=varint, tag=0x8 if (a >= e) - return -459; + return -465; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -460; + return -466; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -461; + return -467; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -462; + return -468; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -463; + return -469; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -464; + return -470; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -465; + return -471; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -466; + return -472; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -467; + return -473; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -468; + return -474; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -469; + return -475; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -470; + return -476; a += n; } assert(a <= e); @@ -10063,7 +10034,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -471; + return -477; } Message *SX1276Config::p_getMember(const char *s, unsigned n) @@ -10104,7 +10075,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -472; + return -478; a += fn; switch (fid) { case 0x8: // freq id 1, type uint64_t, coding varint @@ -10112,7 +10083,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -473; + return -479; a += n; set_freq(v); } @@ -10122,7 +10093,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -474; + return -480; a += n; set_duration(v); } @@ -10132,7 +10103,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -475; + return -481; a += s; break; } @@ -10140,7 +10111,7 @@ ssize_t Tone::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -476; + return -482; return a-(const uint8_t *)b; } @@ -10153,22 +10124,22 @@ ssize_t Tone::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'freq': id=1, encoding=varint, tag=0x8 if (a >= e) - return -477; + return -483; *a++ = 0x8; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -478; + return -484; a += n; } // has duration? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'duration': id=2, encoding=varint, tag=0x10 if (a >= e) - return -479; + return -485; *a++ = 0x10; n = write_varint(a,e-a,m_duration); if (n <= 0) - return -480; + return -486; a += n; } assert(a <= e); @@ -10286,7 +10257,7 @@ int Tone::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } - return -481; + return -487; } Message *Tone::p_getMember(const char *s, unsigned n) @@ -10337,7 +10308,7 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -482; + return -488; a += fn; switch (fid) { case 0xa: // name id 1, type std::string, coding byte[] @@ -10346,14 +10317,14 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -483; + return -489; m_name.assign((const char*)a,v); a += v; } break; case 0x14: // tones id 2, type uint16_t, coding 16bit if ((a+1) >= e) - return -484; + return -490; m_tones.push_back((uint16_t) read_u16(a)); a += 2; break; @@ -10362,7 +10333,7 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -485; + return -491; a += s; break; } @@ -10370,7 +10341,7 @@ ssize_t Melody::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -486; + return -492; return a-(const uint8_t *)b; } @@ -10383,23 +10354,23 @@ ssize_t Melody::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -487; + return -493; *a++ = 0xa; ssize_t name_s = m_name.size(); n = write_varint(a,e-a,name_s); a += n; if ((n <= 0) || ((e-a) < name_s)) - return -488; + return -494; memcpy(a,m_name.data(),name_s); a += name_s; } for (auto x : m_tones) { // 'tones': id=2, encoding=16bit, tag=0x14 if (3 > (e-a)) - return -489; + return -495; *a++ = 0x14; if ((e-a) < 2) - return -490; + return -496; write_u16(a,x); a += 2; } @@ -10541,20 +10512,20 @@ int Melody::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -491; + return -497; if (m_tones.size() <= x) - return -492; + return -498; if ((idxe[1] == 0) && (value == 0)) { m_tones.erase(m_tones.begin()+x); return 0; } } if (idxe[1] != 0) - return -493; + return -499; return parse_ascii_u16(&m_tones[x],value); } } - return -494; + return -500; } Message *Melody::p_getMember(const char *s, unsigned n) @@ -10605,7 +10576,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -495; + return -501; a += fn; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -10613,7 +10584,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -496; + return -502; a += n; set_gpio(varint_sint(v)); } @@ -10624,14 +10595,14 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -497; + return -503; m_melodies.emplace_back(); if (v != 0) { n = m_melodies.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -498; + return -504; a += v; } } @@ -10641,7 +10612,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -499; + return -505; a += s; break; } @@ -10649,7 +10620,7 @@ ssize_t BuzzerConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -500; + return -506; return a-(const uint8_t *)b; } @@ -10662,23 +10633,23 @@ ssize_t BuzzerConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -501; + return -507; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -502; + return -508; a += n; } for (const auto &x : m_melodies) { // 'melodies': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -503; + return -509; *a++ = 0x12; ssize_t melodies_ws = x.calcSize(); n = write_varint(a,e-a,melodies_ws); a += n; if ((n <= 0) || (melodies_ws > (e-a))) - return -504; + return -510; n = x.toMemory(a,e-a); a += n; assert(n == melodies_ws); @@ -10819,20 +10790,20 @@ int BuzzerConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -505; + return -511; if (m_melodies.size() <= x) - return -506; + return -512; if ((idxe[1] == 0) && (value == 0)) { m_melodies.erase(m_melodies.begin()+x); return 0; } } if (idxe[1] != '.') - return -507; + return -513; return m_melodies[x].setByName(idxe+2,value); } } - return -508; + return -514; } Message *BuzzerConfig::p_getMember(const char *s, unsigned n) @@ -10857,61 +10828,25 @@ void HardwareConfig::clear() m_system.clear(); m_uart.clear(); m_adc.clear(); - #ifdef CONFIG_TOUCHPAD m_touchpad.clear(); - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD m_tp_channel.clear(); - #endif // CONFIG_TOUCHPAD m_gpios.clear(); - #ifdef CONFIG_SPI m_spibus.clear(); - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON m_button.clear(); - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY m_relay.clear(); - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS m_led.clear(); - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER m_buzzer.clear(); - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 m_hlw8012.clear(); - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 m_max7219.clear(); - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 m_tlc5947.clear(); - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS m_ws2812b.clear(); - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT m_dht.clear(); - #endif // CONFIG_DHT - #ifdef CONFIG_I2C m_i2c.clear(); - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 m_hcsr04.clear(); - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE m_onewire.clear(); - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 m_sx1276.clear(); - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS m_iocluster.clear(); - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY m_display.clear(); - #endif // CONFIG_DISPLAY p_validbits = 0; } @@ -10936,11 +10871,8 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const o << '}'; ascii_indent(o,indent,"adc"); m_adc.toASCII(o,indent); - #ifdef CONFIG_TOUCHPAD ascii_indent(o,indent,"touchpad"); m_touchpad.toASCII(o,indent); - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD ascii_indent(o,indent); size_t s_tp_channel = m_tp_channel.size(); o << "tp_channel[" << s_tp_channel << "] = {"; @@ -10953,7 +10885,6 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_TOUCHPAD ascii_indent(o,indent); size_t s_gpios = m_gpios.size(); o << "gpios[" << s_gpios << "] = {"; @@ -10966,7 +10897,6 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #ifdef CONFIG_SPI ascii_indent(o,indent); size_t s_spibus = m_spibus.size(); o << "spibus[" << s_spibus << "] = {"; @@ -10979,8 +10909,6 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON ascii_indent(o,indent); size_t s_button = m_button.size(); o << "button[" << s_button << "] = {"; @@ -10993,8 +10921,6 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY ascii_indent(o,indent); size_t s_relay = m_relay.size(); o << "relay[" << s_relay << "] = {"; @@ -11007,8 +10933,6 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS ascii_indent(o,indent); size_t s_led = m_led.size(); o << "led[" << s_led << "] = {"; @@ -11021,24 +10945,14 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER ascii_indent(o,indent,"buzzer"); m_buzzer.toASCII(o,indent); - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 ascii_indent(o,indent,"hlw8012"); m_hlw8012.toASCII(o,indent); - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 ascii_indent(o,indent,"max7219"); m_max7219.toASCII(o,indent); - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 ascii_indent(o,indent,"tlc5947"); m_tlc5947.toASCII(o,indent); - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS ascii_indent(o,indent); size_t s_ws2812b = m_ws2812b.size(); o << "ws2812b[" << s_ws2812b << "] = {"; @@ -11051,12 +10965,8 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT ascii_indent(o,indent,"dht"); m_dht.toASCII(o,indent); - #endif // CONFIG_DHT - #ifdef CONFIG_I2C ascii_indent(o,indent); size_t s_i2c = m_i2c.size(); o << "i2c[" << s_i2c << "] = {"; @@ -11069,8 +10979,6 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 ascii_indent(o,indent); size_t s_hcsr04 = m_hcsr04.size(); o << "hcsr04[" << s_hcsr04 << "] = {"; @@ -11083,16 +10991,10 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE ascii_indent(o,indent,"onewire"); m_onewire.toASCII(o,indent); - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 ascii_indent(o,indent,"sx1276"); m_sx1276.toASCII(o,indent); - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS ascii_indent(o,indent); size_t s_iocluster = m_iocluster.size(); o << "iocluster[" << s_iocluster << "] = {"; @@ -11105,11 +11007,8 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY ascii_indent(o,indent,"display"); m_display.toASCII(o,indent); - #endif // CONFIG_DISPLAY --indent; ascii_indent(o,indent); o << '}'; @@ -11123,12 +11022,12 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -509; + return -515; a += fn; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit if ((a+3) >= e) - return -510; + return -516; set_magic((uint32_t) read_u32(a)); a += 4; break; @@ -11138,13 +11037,13 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -511; + return -517; if (v != 0) { n = m_system.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -512; + return -518; a += v; } } @@ -11156,14 +11055,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -513; + return -519; m_uart.emplace_back(); if (v != 0) { n = m_uart.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -514; + return -520; a += v; } } @@ -11174,402 +11073,366 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -515; + return -521; if (v != 0) { n = m_adc.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -516; + return -522; a += v; } } p_validbits |= ((uint16_t)1U << 2); break; - #ifdef CONFIG_TOUCHPAD case 0x2a: // touchpad id 5, type TouchpadConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -517; + return -523; if (v != 0) { n = m_touchpad.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -518; + return -524; a += v; } } p_validbits |= ((uint16_t)1U << 3); break; - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD case 0x32: // tp_channel id 6, type TouchChannelConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -519; + return -525; m_tp_channel.emplace_back(); if (v != 0) { n = m_tp_channel.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -520; + return -526; a += v; } } break; - #endif // CONFIG_TOUCHPAD case 0x3a: // gpios id 7, type GpioConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -521; + return -527; m_gpios.emplace_back(); if (v != 0) { n = m_gpios.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -522; + return -528; a += v; } } break; - #ifdef CONFIG_SPI case 0x42: // spibus id 8, type SpiBusConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -523; + return -529; m_spibus.emplace_back(); if (v != 0) { n = m_spibus.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -524; + return -530; a += v; } } break; - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON case 0x82: // button id 16, type ButtonConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -525; + return -531; m_button.emplace_back(); if (v != 0) { n = m_button.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -526; + return -532; a += v; } } break; - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY case 0x8a: // relay id 17, type RelayConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -527; + return -533; m_relay.emplace_back(); if (v != 0) { n = m_relay.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -528; + return -534; a += v; } } break; - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS case 0x92: // led id 18, type LedConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -529; + return -535; m_led.emplace_back(); if (v != 0) { n = m_led.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -530; + return -536; a += v; } } break; - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER case 0x9a: // buzzer id 19, type BuzzerConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -531; + return -537; if (v != 0) { n = m_buzzer.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -532; + return -538; a += v; } } p_validbits |= ((uint16_t)1U << 4); break; - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 case 0xa2: // hlw8012 id 20, type Hlw8012Config, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -533; + return -539; if (v != 0) { n = m_hlw8012.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -534; + return -540; a += v; } } p_validbits |= ((uint16_t)1U << 5); break; - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 case 0x102: // max7219 id 32, type Max7219Config, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -535; + return -541; if (v != 0) { n = m_max7219.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -536; + return -542; a += v; } } p_validbits |= ((uint16_t)1U << 6); break; - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 case 0x10a: // tlc5947 id 33, type Tlc5947Config, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -537; + return -543; if (v != 0) { n = m_tlc5947.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -538; + return -544; a += v; } } p_validbits |= ((uint16_t)1U << 7); break; - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS case 0x112: // ws2812b id 34, type Ws2812bConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -539; + return -545; m_ws2812b.emplace_back(); if (v != 0) { n = m_ws2812b.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -540; + return -546; a += v; } } break; - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT case 0x11a: // dht id 35, type DhtConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -541; + return -547; if (v != 0) { n = m_dht.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -542; + return -548; a += v; } } p_validbits |= ((uint16_t)1U << 8); break; - #endif // CONFIG_DHT - #ifdef CONFIG_I2C case 0x122: // i2c id 36, type I2CConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -543; + return -549; m_i2c.emplace_back(); if (v != 0) { n = m_i2c.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -544; + return -550; a += v; } } break; - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 case 0x12a: // hcsr04 id 37, type HcSr04Config, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -545; + return -551; m_hcsr04.emplace_back(); if (v != 0) { n = m_hcsr04.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -546; + return -552; a += v; } } break; - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE case 0x132: // onewire id 38, type OneWireConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -547; + return -553; if (v != 0) { n = m_onewire.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -548; + return -554; a += v; } } p_validbits |= ((uint16_t)1U << 9); break; - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 case 0x13a: // sx1276 id 39, type SX1276Config, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -549; + return -555; if (v != 0) { n = m_sx1276.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -550; + return -556; a += v; } } p_validbits |= ((uint16_t)1U << 10); break; - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS case 0x142: // iocluster id 40, type GpioCluster, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -551; + return -557; m_iocluster.emplace_back(); if (v != 0) { n = m_iocluster.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -552; + return -558; a += v; } } break; - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY case 0x192: // display id 50, type DisplayConfig, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -553; + return -559; if (v != 0) { n = m_display.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -554; + return -560; a += v; } } p_validbits |= ((uint16_t)1U << 11); break; - #endif // CONFIG_DISPLAY default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -555; + return -561; a += s; break; } @@ -11577,7 +11440,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -556; + return -562; return a-(const uint8_t *)b; } @@ -11590,10 +11453,10 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -557; + return -563; *a++ = 0x5; if ((e-a) < 4) - return -558; + return -564; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -11601,13 +11464,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 1))) { // 'system': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -559; + return -565; *a++ = 0xa; ssize_t system_ws = m_system.calcSize(); n = write_varint(a,e-a,system_ws); a += n; if ((n <= 0) || (system_ws > (e-a))) - return -560; + return -566; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -11615,13 +11478,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_uart) { // 'uart': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -561; + return -567; *a++ = 0x1a; ssize_t uart_ws = x.calcSize(); n = write_varint(a,e-a,uart_ws); a += n; if ((n <= 0) || (uart_ws > (e-a))) - return -562; + return -568; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -11630,343 +11493,307 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 2))) { // 'adc': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -563; + return -569; *a++ = 0x22; ssize_t adc_ws = m_adc.calcSize(); n = write_varint(a,e-a,adc_ws); a += n; if ((n <= 0) || (adc_ws > (e-a))) - return -564; + return -570; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); } - #ifdef CONFIG_TOUCHPAD // has touchpad? if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'touchpad': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -565; + return -571; *a++ = 0x2a; ssize_t touchpad_ws = m_touchpad.calcSize(); n = write_varint(a,e-a,touchpad_ws); a += n; if ((n <= 0) || (touchpad_ws > (e-a))) - return -566; + return -572; n = m_touchpad.toMemory(a,e-a); a += n; assert(n == touchpad_ws); } - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD for (const auto &x : m_tp_channel) { // 'tp_channel': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -567; + return -573; *a++ = 0x32; ssize_t tp_channel_ws = x.calcSize(); n = write_varint(a,e-a,tp_channel_ws); a += n; if ((n <= 0) || (tp_channel_ws > (e-a))) - return -568; + return -574; n = x.toMemory(a,e-a); a += n; assert(n == tp_channel_ws); } - #endif // CONFIG_TOUCHPAD for (const auto &x : m_gpios) { // 'gpios': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -569; + return -575; *a++ = 0x3a; ssize_t gpios_ws = x.calcSize(); n = write_varint(a,e-a,gpios_ws); a += n; if ((n <= 0) || (gpios_ws > (e-a))) - return -570; + return -576; n = x.toMemory(a,e-a); a += n; assert(n == gpios_ws); } - #ifdef CONFIG_SPI for (const auto &x : m_spibus) { // 'spibus': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -571; + return -577; *a++ = 0x42; ssize_t spibus_ws = x.calcSize(); n = write_varint(a,e-a,spibus_ws); a += n; if ((n <= 0) || (spibus_ws > (e-a))) - return -572; + return -578; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON for (const auto &x : m_button) { // 'button': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -573; + return -579; *a++ = 0x82; *a++ = 0x1; ssize_t button_ws = x.calcSize(); n = write_varint(a,e-a,button_ws); a += n; if ((n <= 0) || (button_ws > (e-a))) - return -574; + return -580; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY for (const auto &x : m_relay) { // 'relay': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -575; + return -581; *a++ = 0x8a; *a++ = 0x1; ssize_t relay_ws = x.calcSize(); n = write_varint(a,e-a,relay_ws); a += n; if ((n <= 0) || (relay_ws > (e-a))) - return -576; + return -582; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS for (const auto &x : m_led) { // 'led': id=18, encoding=lenpfx, tag=0x92 if (2 > (e-a)) - return -577; + return -583; *a++ = 0x92; *a++ = 0x1; ssize_t led_ws = x.calcSize(); n = write_varint(a,e-a,led_ws); a += n; if ((n <= 0) || (led_ws > (e-a))) - return -578; + return -584; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); } - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER // has buzzer? if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'buzzer': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -579; + return -585; *a++ = 0x9a; *a++ = 0x1; ssize_t buzzer_ws = m_buzzer.calcSize(); n = write_varint(a,e-a,buzzer_ws); a += n; if ((n <= 0) || (buzzer_ws > (e-a))) - return -580; + return -586; n = m_buzzer.toMemory(a,e-a); a += n; assert(n == buzzer_ws); } - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 // has hlw8012? if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -581; + return -587; *a++ = 0xa2; *a++ = 0x1; ssize_t hlw8012_ws = m_hlw8012.calcSize(); n = write_varint(a,e-a,hlw8012_ws); a += n; if ((n <= 0) || (hlw8012_ws > (e-a))) - return -582; + return -588; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); } - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 // has max7219? if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 if (2 > (e-a)) - return -583; + return -589; *a++ = 0x82; *a++ = 0x2; ssize_t max7219_ws = m_max7219.calcSize(); n = write_varint(a,e-a,max7219_ws); a += n; if ((n <= 0) || (max7219_ws > (e-a))) - return -584; + return -590; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); } - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 // has tlc5947? if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -585; + return -591; *a++ = 0x8a; *a++ = 0x2; ssize_t tlc5947_ws = m_tlc5947.calcSize(); n = write_varint(a,e-a,tlc5947_ws); a += n; if ((n <= 0) || (tlc5947_ws > (e-a))) - return -586; + return -592; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); } - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -587; + return -593; *a++ = 0x92; *a++ = 0x2; ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -588; + return -594; n = x.toMemory(a,e-a); a += n; assert(n == ws2812b_ws); } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT // has dht? if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -589; + return -595; *a++ = 0x9a; *a++ = 0x2; ssize_t dht_ws = m_dht.calcSize(); n = write_varint(a,e-a,dht_ws); a += n; if ((n <= 0) || (dht_ws > (e-a))) - return -590; + return -596; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); } - #endif // CONFIG_DHT - #ifdef CONFIG_I2C for (const auto &x : m_i2c) { // 'i2c': id=36, encoding=lenpfx, tag=0x122 if (2 > (e-a)) - return -591; + return -597; *a++ = 0xa2; *a++ = 0x2; ssize_t i2c_ws = x.calcSize(); n = write_varint(a,e-a,i2c_ws); a += n; if ((n <= 0) || (i2c_ws > (e-a))) - return -592; + return -598; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 for (const auto &x : m_hcsr04) { // 'hcsr04': id=37, encoding=lenpfx, tag=0x12a if (2 > (e-a)) - return -593; + return -599; *a++ = 0xaa; *a++ = 0x2; ssize_t hcsr04_ws = x.calcSize(); n = write_varint(a,e-a,hcsr04_ws); a += n; if ((n <= 0) || (hcsr04_ws > (e-a))) - return -594; + return -600; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE // has onewire? if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -595; + return -601; *a++ = 0xb2; *a++ = 0x2; ssize_t onewire_ws = m_onewire.calcSize(); n = write_varint(a,e-a,onewire_ws); a += n; if ((n <= 0) || (onewire_ws > (e-a))) - return -596; + return -602; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); } - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 // has sx1276? if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -597; + return -603; *a++ = 0xba; *a++ = 0x2; ssize_t sx1276_ws = m_sx1276.calcSize(); n = write_varint(a,e-a,sx1276_ws); a += n; if ((n <= 0) || (sx1276_ws > (e-a))) - return -598; + return -604; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); } - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS for (const auto &x : m_iocluster) { // 'iocluster': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) - return -599; + return -605; *a++ = 0xc2; *a++ = 0x2; ssize_t iocluster_ws = x.calcSize(); n = write_varint(a,e-a,iocluster_ws); a += n; if ((n <= 0) || (iocluster_ws > (e-a))) - return -600; + return -606; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); } - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY // has display? if (0 != (p_validbits & ((uint16_t)1U << 11))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -601; + return -607; *a++ = 0x92; *a++ = 0x3; ssize_t display_ws = m_display.calcSize(); n = write_varint(a,e-a,display_ws); a += n; if ((n <= 0) || (display_ws > (e-a))) - return -602; + return -608; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); } - #endif // CONFIG_DISPLAY assert(a <= e); return a-b; } @@ -11996,37 +11823,30 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_adc.calcSize()); m_adc.toWire(put); } - #ifdef CONFIG_TOUCHPAD if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'touchpad': id=5, encoding=lenpfx, tag=0x2a put(0x2a); // 'touchpad': id=5 send_varint(put,m_touchpad.calcSize()); m_touchpad.toWire(put); } - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD for (size_t x = 0, y = m_tp_channel.size(); x != y; ++x) { // 'tp_channel': id=6, encoding=lenpfx, tag=0x32 put(0x32); // 'tp_channel': id=6 send_varint(put,m_tp_channel[x].calcSize()); m_tp_channel[x].toWire(put); } - #endif // CONFIG_TOUCHPAD for (size_t x = 0, y = m_gpios.size(); x != y; ++x) { // 'gpios': id=7, encoding=lenpfx, tag=0x3a put(0x3a); // 'gpios': id=7 send_varint(put,m_gpios[x].calcSize()); m_gpios[x].toWire(put); } - #ifdef CONFIG_SPI for (size_t x = 0, y = m_spibus.size(); x != y; ++x) { // 'spibus': id=8, encoding=lenpfx, tag=0x42 put(0x42); // 'spibus': id=8 send_varint(put,m_spibus[x].calcSize()); m_spibus[x].toWire(put); } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON for (size_t x = 0, y = m_button.size(); x != y; ++x) { // 'button': id=16, encoding=lenpfx, tag=0x82 put(0x82); @@ -12034,8 +11854,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_button[x].calcSize()); m_button[x].toWire(put); } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY for (size_t x = 0, y = m_relay.size(); x != y; ++x) { // 'relay': id=17, encoding=lenpfx, tag=0x8a put(0x8a); @@ -12043,8 +11861,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_relay[x].calcSize()); m_relay[x].toWire(put); } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS for (size_t x = 0, y = m_led.size(); x != y; ++x) { // 'led': id=18, encoding=lenpfx, tag=0x92 put(0x92); @@ -12052,8 +11868,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_led[x].calcSize()); m_led[x].toWire(put); } - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'buzzer': id=19, encoding=lenpfx, tag=0x9a put(0x9a); @@ -12061,8 +11875,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_buzzer.calcSize()); m_buzzer.toWire(put); } - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 put(0xa2); @@ -12070,8 +11882,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_hlw8012.calcSize()); m_hlw8012.toWire(put); } - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 put(0x82); @@ -12079,8 +11889,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_max7219.calcSize()); m_max7219.toWire(put); } - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a put(0x8a); @@ -12088,8 +11896,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_tlc5947.calcSize()); m_tlc5947.toWire(put); } - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS for (size_t x = 0, y = m_ws2812b.size(); x != y; ++x) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 put(0x92); @@ -12097,8 +11903,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_ws2812b[x].calcSize()); m_ws2812b[x].toWire(put); } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a put(0x9a); @@ -12106,8 +11910,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_dht.calcSize()); m_dht.toWire(put); } - #endif // CONFIG_DHT - #ifdef CONFIG_I2C for (size_t x = 0, y = m_i2c.size(); x != y; ++x) { // 'i2c': id=36, encoding=lenpfx, tag=0x122 put(0xa2); @@ -12115,8 +11917,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_i2c[x].calcSize()); m_i2c[x].toWire(put); } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 for (size_t x = 0, y = m_hcsr04.size(); x != y; ++x) { // 'hcsr04': id=37, encoding=lenpfx, tag=0x12a put(0xaa); @@ -12124,8 +11924,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_hcsr04[x].calcSize()); m_hcsr04[x].toWire(put); } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 put(0xb2); @@ -12133,8 +11931,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_onewire.calcSize()); m_onewire.toWire(put); } - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a put(0xba); @@ -12142,8 +11938,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_sx1276.calcSize()); m_sx1276.toWire(put); } - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS for (size_t x = 0, y = m_iocluster.size(); x != y; ++x) { // 'iocluster': id=40, encoding=lenpfx, tag=0x142 put(0xc2); @@ -12151,8 +11945,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_iocluster[x].calcSize()); m_iocluster[x].toWire(put); } - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY if (0 != (p_validbits & ((uint16_t)1U << 11))) { // 'display': id=50, encoding=lenpfx, tag=0x192 put(0x92); @@ -12160,7 +11952,6 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_display.calcSize()); m_display.toWire(put); } - #endif // CONFIG_DISPLAY } void HardwareConfig::toString(std::string &put) const @@ -12188,37 +11979,30 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_adc.calcSize()); m_adc.toString(put); } - #ifdef CONFIG_TOUCHPAD if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'touchpad': id=5, encoding=lenpfx, tag=0x2a put.push_back(0x2a); // 'touchpad': id=5 send_varint(put,m_touchpad.calcSize()); m_touchpad.toString(put); } - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD for (size_t x = 0, y = m_tp_channel.size(); x != y; ++x) { // 'tp_channel': id=6, encoding=lenpfx, tag=0x32 put.push_back(0x32); // 'tp_channel': id=6 send_varint(put,m_tp_channel[x].calcSize()); m_tp_channel[x].toString(put); } - #endif // CONFIG_TOUCHPAD for (size_t x = 0, y = m_gpios.size(); x != y; ++x) { // 'gpios': id=7, encoding=lenpfx, tag=0x3a put.push_back(0x3a); // 'gpios': id=7 send_varint(put,m_gpios[x].calcSize()); m_gpios[x].toString(put); } - #ifdef CONFIG_SPI for (size_t x = 0, y = m_spibus.size(); x != y; ++x) { // 'spibus': id=8, encoding=lenpfx, tag=0x42 put.push_back(0x42); // 'spibus': id=8 send_varint(put,m_spibus[x].calcSize()); m_spibus[x].toString(put); } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON for (size_t x = 0, y = m_button.size(); x != y; ++x) { // 'button': id=16, encoding=lenpfx, tag=0x82 put.push_back(0x82); @@ -12226,8 +12010,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_button[x].calcSize()); m_button[x].toString(put); } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY for (size_t x = 0, y = m_relay.size(); x != y; ++x) { // 'relay': id=17, encoding=lenpfx, tag=0x8a put.push_back(0x8a); @@ -12235,8 +12017,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_relay[x].calcSize()); m_relay[x].toString(put); } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS for (size_t x = 0, y = m_led.size(); x != y; ++x) { // 'led': id=18, encoding=lenpfx, tag=0x92 put.push_back(0x92); @@ -12244,8 +12024,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_led[x].calcSize()); m_led[x].toString(put); } - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'buzzer': id=19, encoding=lenpfx, tag=0x9a put.push_back(0x9a); @@ -12253,8 +12031,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_buzzer.calcSize()); m_buzzer.toString(put); } - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 put.push_back(0xa2); @@ -12262,8 +12038,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_hlw8012.calcSize()); m_hlw8012.toString(put); } - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 put.push_back(0x82); @@ -12271,8 +12045,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_max7219.calcSize()); m_max7219.toString(put); } - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a put.push_back(0x8a); @@ -12280,8 +12052,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_tlc5947.calcSize()); m_tlc5947.toString(put); } - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS for (size_t x = 0, y = m_ws2812b.size(); x != y; ++x) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 put.push_back(0x92); @@ -12289,8 +12059,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_ws2812b[x].calcSize()); m_ws2812b[x].toString(put); } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a put.push_back(0x9a); @@ -12298,8 +12066,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_dht.calcSize()); m_dht.toString(put); } - #endif // CONFIG_DHT - #ifdef CONFIG_I2C for (size_t x = 0, y = m_i2c.size(); x != y; ++x) { // 'i2c': id=36, encoding=lenpfx, tag=0x122 put.push_back(0xa2); @@ -12307,8 +12073,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_i2c[x].calcSize()); m_i2c[x].toString(put); } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 for (size_t x = 0, y = m_hcsr04.size(); x != y; ++x) { // 'hcsr04': id=37, encoding=lenpfx, tag=0x12a put.push_back(0xaa); @@ -12316,8 +12080,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_hcsr04[x].calcSize()); m_hcsr04[x].toString(put); } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 put.push_back(0xb2); @@ -12325,8 +12087,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_onewire.calcSize()); m_onewire.toString(put); } - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a put.push_back(0xba); @@ -12334,8 +12094,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_sx1276.calcSize()); m_sx1276.toString(put); } - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS for (size_t x = 0, y = m_iocluster.size(); x != y; ++x) { // 'iocluster': id=40, encoding=lenpfx, tag=0x142 put.push_back(0xc2); @@ -12343,8 +12101,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_iocluster[x].calcSize()); m_iocluster[x].toString(put); } - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY if (0 != (p_validbits & ((uint16_t)1U << 11))) { // 'display': id=50, encoding=lenpfx, tag=0x192 put.push_back(0x92); @@ -12352,7 +12108,6 @@ void HardwareConfig::toString(std::string &put) const send_varint(put,m_display.calcSize()); m_display.toString(put); } - #endif // CONFIG_DISPLAY } void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -12389,13 +12144,10 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"adc"); m_adc.toJSON(json,indLvl); } - #ifdef CONFIG_TOUCHPAD if (has_touchpad()) { fsep = json_indent(json,indLvl,fsep,"touchpad"); m_touchpad.toJSON(json,indLvl); } - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD if (size_t s = m_tp_channel.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12414,7 +12166,6 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_TOUCHPAD if (size_t s = m_gpios.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12433,7 +12184,6 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #ifdef CONFIG_SPI if (size_t s = m_spibus.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12452,8 +12202,6 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON if (size_t s = m_button.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12472,8 +12220,6 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY if (size_t s = m_relay.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12492,8 +12238,6 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS if (size_t s = m_led.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12512,32 +12256,22 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER if (has_buzzer()) { fsep = json_indent(json,indLvl,fsep,"buzzer"); m_buzzer.toJSON(json,indLvl); } - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 if (has_hlw8012()) { fsep = json_indent(json,indLvl,fsep,"hlw8012"); m_hlw8012.toJSON(json,indLvl); } - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 if (has_max7219()) { fsep = json_indent(json,indLvl,fsep,"max7219"); m_max7219.toJSON(json,indLvl); } - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 if (has_tlc5947()) { fsep = json_indent(json,indLvl,fsep,"tlc5947"); m_tlc5947.toJSON(json,indLvl); } - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS if (size_t s = m_ws2812b.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12556,14 +12290,10 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT if (has_dht()) { fsep = json_indent(json,indLvl,fsep,"dht"); m_dht.toJSON(json,indLvl); } - #endif // CONFIG_DHT - #ifdef CONFIG_I2C if (size_t s = m_i2c.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12582,8 +12312,6 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 if (size_t s = m_hcsr04.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12602,20 +12330,14 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE if (has_onewire()) { fsep = json_indent(json,indLvl,fsep,"onewire"); m_onewire.toJSON(json,indLvl); } - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 if (has_sx1276()) { fsep = json_indent(json,indLvl,fsep,"sx1276"); m_sx1276.toJSON(json,indLvl); } - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS if (size_t s = m_iocluster.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -12634,13 +12356,10 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY if (has_display()) { fsep = json_indent(json,indLvl,fsep,"display"); m_display.toJSON(json,indLvl); } - #endif // CONFIG_DISPLAY if (fsep == '{') json.put('{'); json.put('\n'); @@ -12675,14 +12394,11 @@ size_t HardwareConfig::calcSize() const size_t adc_s = m_adc.calcSize(); r += adc_s + wiresize(adc_s) + 1 /* tag(adc) 0x20 */; } - #ifdef CONFIG_TOUCHPAD // optional TouchpadConfig touchpad, id 5 if (0 != (p_validbits & ((uint16_t)1U << 3))) { size_t touchpad_s = m_touchpad.calcSize(); r += touchpad_s + wiresize(touchpad_s) + 1 /* tag(touchpad) 0x28 */; } - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD // repeated TouchChannelConfig tp_channel, id 6 // repeated message tp_channel for (size_t x = 0, y = m_tp_channel.size(); x < y; ++x) { @@ -12690,7 +12406,6 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(tp_channel) 0x30 */; } - #endif // CONFIG_TOUCHPAD // repeated GpioConfig gpios, id 7 // repeated message gpios for (size_t x = 0, y = m_gpios.size(); x < y; ++x) { @@ -12698,7 +12413,6 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(gpios) 0x38 */; } - #ifdef CONFIG_SPI // repeated SpiBusConfig spibus, id 8 // repeated message spibus for (size_t x = 0, y = m_spibus.size(); x < y; ++x) { @@ -12706,8 +12420,6 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(spibus) 0x40 */; } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON // repeated ButtonConfig button, id 16 // repeated message button for (size_t x = 0, y = m_button.size(); x < y; ++x) { @@ -12715,8 +12427,6 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(button) 0x80 */; } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY // repeated RelayConfig relay, id 17 // repeated message relay for (size_t x = 0, y = m_relay.size(); x < y; ++x) { @@ -12724,8 +12434,6 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(relay) 0x88 */; } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS // repeated LedConfig led, id 18 // repeated message led for (size_t x = 0, y = m_led.size(); x < y; ++x) { @@ -12733,36 +12441,26 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(led) 0x90 */; } - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER // optional BuzzerConfig buzzer, id 19 if (0 != (p_validbits & ((uint16_t)1U << 4))) { size_t buzzer_s = m_buzzer.calcSize(); r += buzzer_s + wiresize(buzzer_s) + 2 /* tag(buzzer) 0x98 */; } - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 // optional Hlw8012Config hlw8012, id 20 if (0 != (p_validbits & ((uint16_t)1U << 5))) { size_t hlw8012_s = m_hlw8012.calcSize(); r += hlw8012_s + wiresize(hlw8012_s) + 2 /* tag(hlw8012) 0xa0 */; } - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 // optional Max7219Config max7219, id 32 if (0 != (p_validbits & ((uint16_t)1U << 6))) { size_t max7219_s = m_max7219.calcSize(); r += max7219_s + wiresize(max7219_s) + 2 /* tag(max7219) 0x100 */; } - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 // optional Tlc5947Config tlc5947, id 33 if (0 != (p_validbits & ((uint16_t)1U << 7))) { size_t tlc5947_s = m_tlc5947.calcSize(); r += tlc5947_s + wiresize(tlc5947_s) + 2 /* tag(tlc5947) 0x108 */; } - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS // repeated Ws2812bConfig ws2812b, id 34 // repeated message ws2812b for (size_t x = 0, y = m_ws2812b.size(); x < y; ++x) { @@ -12770,15 +12468,11 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(ws2812b) 0x110 */; } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT // optional DhtConfig dht, id 35 if (0 != (p_validbits & ((uint16_t)1U << 8))) { size_t dht_s = m_dht.calcSize(); r += dht_s + wiresize(dht_s) + 2 /* tag(dht) 0x118 */; } - #endif // CONFIG_DHT - #ifdef CONFIG_I2C // repeated I2CConfig i2c, id 36 // repeated message i2c for (size_t x = 0, y = m_i2c.size(); x < y; ++x) { @@ -12786,8 +12480,6 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(i2c) 0x120 */; } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 // repeated HcSr04Config hcsr04, id 37 // repeated message hcsr04 for (size_t x = 0, y = m_hcsr04.size(); x < y; ++x) { @@ -12795,22 +12487,16 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(hcsr04) 0x128 */; } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE // optional OneWireConfig onewire, id 38 if (0 != (p_validbits & ((uint16_t)1U << 9))) { size_t onewire_s = m_onewire.calcSize(); r += onewire_s + wiresize(onewire_s) + 2 /* tag(onewire) 0x130 */; } - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 // optional SX1276Config sx1276, id 39 if (0 != (p_validbits & ((uint16_t)1U << 10))) { size_t sx1276_s = m_sx1276.calcSize(); r += sx1276_s + wiresize(sx1276_s) + 2 /* tag(sx1276) 0x138 */; } - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS // repeated GpioCluster iocluster, id 40 // repeated message iocluster for (size_t x = 0, y = m_iocluster.size(); x < y; ++x) { @@ -12818,14 +12504,11 @@ size_t HardwareConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(iocluster) 0x140 */; } - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY // optional DisplayConfig display, id 50 if (0 != (p_validbits & ((uint16_t)1U << 11))) { size_t display_s = m_display.calcSize(); r += display_s + wiresize(display_s) + 2 /* tag(display) 0x190 */; } - #endif // CONFIG_DISPLAY return r; } @@ -12841,80 +12524,44 @@ bool HardwareConfig::operator != (const HardwareConfig &r) const return true; if (has_adc() && (m_adc != r.m_adc)) return true; - #ifdef CONFIG_TOUCHPAD if (has_touchpad() && (m_touchpad != r.m_touchpad)) return true; - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD if (m_tp_channel != r.m_tp_channel) return true; - #endif // CONFIG_TOUCHPAD if (m_gpios != r.m_gpios) return true; - #ifdef CONFIG_SPI if (m_spibus != r.m_spibus) return true; - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON if (m_button != r.m_button) return true; - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY if (m_relay != r.m_relay) return true; - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS if (m_led != r.m_led) return true; - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER if (has_buzzer() && (m_buzzer != r.m_buzzer)) return true; - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 if (has_hlw8012() && (m_hlw8012 != r.m_hlw8012)) return true; - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 if (has_max7219() && (m_max7219 != r.m_max7219)) return true; - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 if (has_tlc5947() && (m_tlc5947 != r.m_tlc5947)) return true; - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS if (m_ws2812b != r.m_ws2812b) return true; - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT if (has_dht() && (m_dht != r.m_dht)) return true; - #endif // CONFIG_DHT - #ifdef CONFIG_I2C if (m_i2c != r.m_i2c) return true; - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 if (m_hcsr04 != r.m_hcsr04) return true; - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE if (has_onewire() && (m_onewire != r.m_onewire)) return true; - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 if (has_sx1276() && (m_sx1276 != r.m_sx1276)) return true; - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS if (m_iocluster != r.m_iocluster) return true; - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY if (has_display() && (m_display != r.m_display)) return true; - #endif // CONFIG_DISPLAY return false; } @@ -12969,16 +12616,16 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+5,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+5))) - return -603; + return -609; if (m_uart.size() <= x) - return -604; + return -610; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -605; + return -611; return m_uart[x].setByName(idxe+2,value); } } @@ -12991,7 +12638,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_adc.setByName(name+4,value); } } - #ifdef CONFIG_TOUCHPAD if (0 == memcmp(name,"touchpad",8)) { if ((name[8] == 0) && (value == 0)) { clear_touchpad(); @@ -13001,8 +12647,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_touchpad.setByName(name+9,value); } } - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD if (0 == memcmp(name,"tp_channel",10)) { if ((name[10] == 0) && (value == 0)) { clear_tp_channel(); @@ -13019,20 +12663,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -606; + return -612; if (m_tp_channel.size() <= x) - return -607; + return -613; if ((idxe[1] == 0) && (value == 0)) { m_tp_channel.erase(m_tp_channel.begin()+x); return 0; } } if (idxe[1] != '.') - return -608; + return -614; return m_tp_channel[x].setByName(idxe+2,value); } } - #endif // CONFIG_TOUCHPAD if (0 == memcmp(name,"gpios",5)) { if ((name[5] == 0) && (value == 0)) { clear_gpios(); @@ -13049,20 +12692,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -609; + return -615; if (m_gpios.size() <= x) - return -610; + return -616; if ((idxe[1] == 0) && (value == 0)) { m_gpios.erase(m_gpios.begin()+x); return 0; } } if (idxe[1] != '.') - return -611; + return -617; return m_gpios[x].setByName(idxe+2,value); } } - #ifdef CONFIG_SPI if (0 == memcmp(name,"spibus",6)) { if ((name[6] == 0) && (value == 0)) { clear_spibus(); @@ -13079,21 +12721,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -612; + return -618; if (m_spibus.size() <= x) - return -613; + return -619; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -614; + return -620; return m_spibus[x].setByName(idxe+2,value); } } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON if (0 == memcmp(name,"button",6)) { if ((name[6] == 0) && (value == 0)) { clear_button(); @@ -13110,21 +12750,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -615; + return -621; if (m_button.size() <= x) - return -616; + return -622; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -617; + return -623; return m_button[x].setByName(idxe+2,value); } } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY if (0 == memcmp(name,"relay",5)) { if ((name[5] == 0) && (value == 0)) { clear_relay(); @@ -13141,21 +12779,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -618; + return -624; if (m_relay.size() <= x) - return -619; + return -625; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -620; + return -626; return m_relay[x].setByName(idxe+2,value); } } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS if (0 == memcmp(name,"led",3)) { if ((name[3] == 0) && (value == 0)) { clear_led(); @@ -13172,21 +12808,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -621; + return -627; if (m_led.size() <= x) - return -622; + return -628; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -623; + return -629; return m_led[x].setByName(idxe+2,value); } } - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER if (0 == memcmp(name,"buzzer",6)) { if ((name[6] == 0) && (value == 0)) { clear_buzzer(); @@ -13196,8 +12830,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_buzzer.setByName(name+7,value); } } - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 if (0 == memcmp(name,"hlw8012",7)) { if ((name[7] == 0) && (value == 0)) { clear_hlw8012(); @@ -13207,8 +12839,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_hlw8012.setByName(name+8,value); } } - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 if (0 == memcmp(name,"max7219",7)) { if ((name[7] == 0) && (value == 0)) { clear_max7219(); @@ -13218,8 +12848,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_max7219.setByName(name+8,value); } } - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 if (0 == memcmp(name,"tlc5947",7)) { if ((name[7] == 0) && (value == 0)) { clear_tlc5947(); @@ -13229,8 +12857,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_tlc5947.setByName(name+8,value); } } - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS if (0 == memcmp(name,"ws2812b",7)) { if ((name[7] == 0) && (value == 0)) { clear_ws2812b(); @@ -13247,21 +12873,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+8,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+8))) - return -624; + return -630; if (m_ws2812b.size() <= x) - return -625; + return -631; if ((idxe[1] == 0) && (value == 0)) { m_ws2812b.erase(m_ws2812b.begin()+x); return 0; } } if (idxe[1] != '.') - return -626; + return -632; return m_ws2812b[x].setByName(idxe+2,value); } } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT if (0 == memcmp(name,"dht",3)) { if ((name[3] == 0) && (value == 0)) { clear_dht(); @@ -13271,8 +12895,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_dht.setByName(name+4,value); } } - #endif // CONFIG_DHT - #ifdef CONFIG_I2C if (0 == memcmp(name,"i2c",3)) { if ((name[3] == 0) && (value == 0)) { clear_i2c(); @@ -13289,21 +12911,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+4,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+4))) - return -627; + return -633; if (m_i2c.size() <= x) - return -628; + return -634; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -629; + return -635; return m_i2c[x].setByName(idxe+2,value); } } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 if (0 == memcmp(name,"hcsr04",6)) { if ((name[6] == 0) && (value == 0)) { clear_hcsr04(); @@ -13320,21 +12940,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -630; + return -636; if (m_hcsr04.size() <= x) - return -631; + return -637; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -632; + return -638; return m_hcsr04[x].setByName(idxe+2,value); } } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE if (0 == memcmp(name,"onewire",7)) { if ((name[7] == 0) && (value == 0)) { clear_onewire(); @@ -13344,8 +12962,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_onewire.setByName(name+8,value); } } - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 if (0 == memcmp(name,"sx1276",6)) { if ((name[6] == 0) && (value == 0)) { clear_sx1276(); @@ -13355,8 +12971,6 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_sx1276.setByName(name+7,value); } } - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS if (0 == memcmp(name,"iocluster",9)) { if ((name[9] == 0) && (value == 0)) { clear_iocluster(); @@ -13373,21 +12987,19 @@ int HardwareConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -633; + return -639; if (m_iocluster.size() <= x) - return -634; + return -640; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -635; + return -641; return m_iocluster[x].setByName(idxe+2,value); } } - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY if (0 == memcmp(name,"display",7)) { if ((name[7] == 0) && (value == 0)) { clear_display(); @@ -13397,8 +13009,7 @@ int HardwareConfig::setByName(const char *name, const char *value) return m_display.setByName(name+8,value); } } - #endif // CONFIG_DISPLAY - return -636; + return -642; } Message *HardwareConfig::p_getMember(const char *s, unsigned n) @@ -13408,42 +13019,24 @@ Message *HardwareConfig::p_getMember(const char *s, unsigned n) return &m_system; if ((n == 3) && (0 == memcmp("adc",s,3))) return &m_adc; - #ifdef CONFIG_TOUCHPAD if ((n == 8) && (0 == memcmp("touchpad",s,8))) return &m_touchpad; - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_BUZZER if ((n == 6) && (0 == memcmp("buzzer",s,6))) return &m_buzzer; - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 if ((n == 7) && (0 == memcmp("hlw8012",s,7))) return &m_hlw8012; - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 if ((n == 7) && (0 == memcmp("max7219",s,7))) return &m_max7219; - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 if ((n == 7) && (0 == memcmp("tlc5947",s,7))) return &m_tlc5947; - #endif // CONFIG_TLC5947 - #ifdef CONFIG_DHT if ((n == 3) && (0 == memcmp("dht",s,3))) return &m_dht; - #endif // CONFIG_DHT - #ifdef CONFIG_ONEWIRE if ((n == 7) && (0 == memcmp("onewire",s,7))) return &m_onewire; - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 if ((n == 6) && (0 == memcmp("sx1276",s,6))) return &m_sx1276; - #endif // CONFIG_SX1276 - #ifdef CONFIG_DISPLAY if ((n == 7) && (0 == memcmp("display",s,7))) return &m_display; - #endif // CONFIG_DISPLAY return 0; } @@ -13453,54 +13046,36 @@ Message *HardwareConfig::p_getMember(const char *s, unsigned n, unsigned x) if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - #ifdef CONFIG_TOUCHPAD } else if ((n == 10) && (0 == memcmp("tp_channel",s,10))) { if (x < m_tp_channel.size()) return &m_tp_channel[x]; - #endif // CONFIG_TOUCHPAD } else if ((n == 5) && (0 == memcmp("gpios",s,5))) { if (x < m_gpios.size()) return &m_gpios[x]; - #ifdef CONFIG_SPI } else if ((n == 6) && (0 == memcmp("spibus",s,6))) { if (x < m_spibus.size()) return &m_spibus[x]; - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON } else if ((n == 6) && (0 == memcmp("button",s,6))) { if (x < m_button.size()) return &m_button[x]; - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY } else if ((n == 5) && (0 == memcmp("relay",s,5))) { if (x < m_relay.size()) return &m_relay[x]; - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS } else if ((n == 3) && (0 == memcmp("led",s,3))) { if (x < m_led.size()) return &m_led[x]; - #endif // CONFIG_LEDS - #ifdef CONFIG_RGBLEDS } else if ((n == 7) && (0 == memcmp("ws2812b",s,7))) { if (x < m_ws2812b.size()) return &m_ws2812b[x]; - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_I2C } else if ((n == 3) && (0 == memcmp("i2c",s,3))) { if (x < m_i2c.size()) return &m_i2c[x]; - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 } else if ((n == 6) && (0 == memcmp("hcsr04",s,6))) { if (x < m_hcsr04.size()) return &m_hcsr04[x]; - #endif // CONFIG_HCSR04 - #ifdef CONFIG_IOEXTENDERS } else if ((n == 9) && (0 == memcmp("iocluster",s,9))) { if (x < m_iocluster.size()) return &m_iocluster[x]; - #endif // CONFIG_IOEXTENDERS } return 0; } diff --git a/components/wfc/hwcfg_pc.h b/components/wfc/hwcfg_pc.h index 4469836..b131c25 100644 --- a/components/wfc/hwcfg_pc.h +++ b/components/wfc/hwcfg_pc.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,7 @@ * options from commandline: * * options from pc: + * cfgdefs : "all" * Optimize : "speed" * toASCII : "toASCII" * toSink : "" @@ -90,8 +91,8 @@ * asserts, comments, genlib, gnux, withEqual, withUnequal */ -#ifndef HWCFG_H -#define HWCFG_H +#ifndef HWCFG_PC_H +#define HWCFG_PC_H #include #define OUTPUT_TO_ASCII 1 @@ -106,7 +107,6 @@ #include /* user requested header files */ -#include "pcconfig.h" #include "support.h" #ifdef WFC_ENDIAN #if WFC_ENDIAN != 0 @@ -127,7 +127,7 @@ #define HAVE_ENUM_MAP 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_pc.h" /* wfc support functions not needed */ typedef uint64_t varint_t; @@ -479,7 +479,6 @@ class SystemConfig : public Message */ std::string *mutable_model_number(); - #ifdef CONFIG_USB_DIAGLOG // optional bool usb_diag, id 9 /*! * Function for querying if usb_diag has been set. @@ -497,9 +496,7 @@ class SystemConfig : public Message * @return pointer to member variable of usb_diag. */ bool *mutable_usb_diag(); - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE // optional bool usb_con, id 10 /*! * Function for querying if usb_con has been set. @@ -517,9 +514,7 @@ class SystemConfig : public Message * @return pointer to member variable of usb_con. */ bool *mutable_usb_con(); - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB // optional sint8 cc1_gpio, id 11 /*! * Function for querying if cc1_gpio has been set. @@ -537,9 +532,7 @@ class SystemConfig : public Message * @return pointer to member variable of cc1_gpio. */ int8_t *mutable_cc1_gpio(); - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB // optional sint8 cc2_gpio, id 12 /*! * Function for querying if cc2_gpio has been set. @@ -557,7 +550,6 @@ class SystemConfig : public Message * @return pointer to member variable of cc2_gpio. */ int8_t *mutable_cc2_gpio(); - #endif // CONFIG_ESP_PHY_ENABLE_USB protected: @@ -579,22 +571,14 @@ class SystemConfig : public Message std::string m_model_name; //! string model_number, id 8 std::string m_model_number; - #ifdef CONFIG_USB_DIAGLOG //! bool usb_diag, id 9 bool m_usb_diag = true; - #endif // CONFIG_USB_DIAGLOG - #ifdef CONFIG_USB_CONSOLE //! bool usb_con, id 10 bool m_usb_con = true; - #endif // CONFIG_USB_CONSOLE - #ifdef CONFIG_ESP_PHY_ENABLE_USB //! sint8 cc1_gpio, id 11 int8_t m_cc1_gpio = -1; - #endif // CONFIG_ESP_PHY_ENABLE_USB - #ifdef CONFIG_ESP_PHY_ENABLE_USB //! sint8 cc2_gpio, id 12 int8_t m_cc2_gpio = -1; - #endif // CONFIG_ESP_PHY_ENABLE_USB private: uint8_t p_validbits = 0; @@ -1148,7 +1132,6 @@ class ButtonConfig : public Message */ pull_mode_t *mutable_pull_mode(); - #ifdef CONFIG_ROTARYENCODER // optional sint8 clk, id 5 /*! * Function for querying if clk has been set. @@ -1166,9 +1149,7 @@ class ButtonConfig : public Message * @return pointer to member variable of clk. */ int8_t *mutable_clk(); - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER // optional sint8 dt, id 6 /*! * Function for querying if dt has been set. @@ -1186,7 +1167,6 @@ class ButtonConfig : public Message * @return pointer to member variable of dt. */ int8_t *mutable_dt(); - #endif // CONFIG_ROTARYENCODER protected: @@ -1200,14 +1180,10 @@ class ButtonConfig : public Message bool m_presslvl = 0; //! pull_mode_t pull_mode, id 4 pull_mode_t m_pull_mode = pull_none; - #ifdef CONFIG_ROTARYENCODER //! sint8 clk, id 5 int8_t m_clk = -1; - #endif // CONFIG_ROTARYENCODER - #ifdef CONFIG_ROTARYENCODER //! sint8 dt, id 6 int8_t m_dt = -1; - #endif // CONFIG_ROTARYENCODER }; @@ -2257,7 +2233,6 @@ class I2CConfig : public Message */ bool *mutable_xpullup(); - #ifdef CONFIG_I2C_XDEV // repeated i2cdev_t devices, id 6 //! Function get const-access to the elements of devices. const std::vector &devices() const; @@ -2293,7 +2268,6 @@ class I2CConfig : public Message i2cdev_t *mutable_devices(unsigned x); //! Function to get mutable access to all elements of devices. std::vector *mutable_devices(); - #endif // CONFIG_I2C_XDEV protected: @@ -2309,10 +2283,8 @@ class I2CConfig : public Message uint64_t m_freq = 100000; //! bool xpullup, id 5 bool m_xpullup = false; - #ifdef CONFIG_I2C_XDEV //! i2cdev_t devices, id 6 std::vector m_devices; - #endif // CONFIG_I2C_XDEV private: uint8_t p_validbits = 0; @@ -3846,6 +3818,32 @@ class DisplayConfig : public Message */ uint64_t *mutable_maxy(); + // repeated string skip_env, id 5 + //! Function get const-access to the elements of skip_env. + const std::vector &skip_env() const; + //! Function to get the number of elements in skip_env. + size_t skip_env_size() const; + /*! + * Function to append a element to skip_env. + * @return point to newly added element. + */ + void add_skip_env(const std::string &v); + //! Function to append an element to skip_env initialized by a C-string. + void add_skip_env(const char*); + //! Function to reset skip_env to its default/unset value. + void clear_skip_env(); + //! Get value of element x of skip_env. + const std::string &skip_env(unsigned x) const; + //! Set skip_env using a constant reference + void set_skip_env(unsigned x, const std::string &v); + /*! + * Provide mutable access to skip_env. + * @return pointer to member variable of skip_env. + */ + std::string *mutable_skip_env(unsigned x); + //! Function to get mutable access to all elements of skip_env. + std::vector *mutable_skip_env(); + protected: Message *p_getMember(const char *s, unsigned n); @@ -3858,6 +3856,8 @@ class DisplayConfig : public Message uint64_t m_maxx = 0; //! unsigned maxy, id 4 uint64_t m_maxy = 1; + //! string skip_env, id 5 + std::vector m_skip_env; private: uint8_t p_validbits = 0; @@ -5471,7 +5471,6 @@ class HardwareConfig : public Message */ AdcConfig *mutable_adc(); - #ifdef CONFIG_TOUCHPAD // optional TouchpadConfig touchpad, id 5 /*! * Function for querying if touchpad has been set. @@ -5495,9 +5494,7 @@ class HardwareConfig : public Message * @return pointer to member variable of touchpad. */ TouchpadConfig *mutable_touchpad(); - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD // repeated TouchChannelConfig tp_channel, id 6 //! Function get const-access to the elements of tp_channel. const std::vector &tp_channel() const; @@ -5521,7 +5518,6 @@ class HardwareConfig : public Message TouchChannelConfig *mutable_tp_channel(unsigned x); //! Function to get mutable access to all elements of tp_channel. std::vector *mutable_tp_channel(); - #endif // CONFIG_TOUCHPAD // repeated GpioConfig gpios, id 7 //! Function get const-access to the elements of gpios. @@ -5547,7 +5543,6 @@ class HardwareConfig : public Message //! Function to get mutable access to all elements of gpios. std::vector *mutable_gpios(); - #ifdef CONFIG_SPI // repeated SpiBusConfig spibus, id 8 //! Function get const-access to the elements of spibus. const std::vector &spibus() const; @@ -5571,9 +5566,7 @@ class HardwareConfig : public Message SpiBusConfig *mutable_spibus(unsigned x); //! Function to get mutable access to all elements of spibus. std::vector *mutable_spibus(); - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON // repeated ButtonConfig button, id 16 //! Function get const-access to the elements of button. const std::vector &button() const; @@ -5597,9 +5590,7 @@ class HardwareConfig : public Message ButtonConfig *mutable_button(unsigned x); //! Function to get mutable access to all elements of button. std::vector *mutable_button(); - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY // repeated RelayConfig relay, id 17 //! Function get const-access to the elements of relay. const std::vector &relay() const; @@ -5623,9 +5614,7 @@ class HardwareConfig : public Message RelayConfig *mutable_relay(unsigned x); //! Function to get mutable access to all elements of relay. std::vector *mutable_relay(); - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS // repeated LedConfig led, id 18 //! Function get const-access to the elements of led. const std::vector &led() const; @@ -5649,9 +5638,7 @@ class HardwareConfig : public Message LedConfig *mutable_led(unsigned x); //! Function to get mutable access to all elements of led. std::vector *mutable_led(); - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER // optional BuzzerConfig buzzer, id 19 /*! * Function for querying if buzzer has been set. @@ -5675,9 +5662,7 @@ class HardwareConfig : public Message * @return pointer to member variable of buzzer. */ BuzzerConfig *mutable_buzzer(); - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 // optional Hlw8012Config hlw8012, id 20 /*! * Function for querying if hlw8012 has been set. @@ -5701,9 +5686,7 @@ class HardwareConfig : public Message * @return pointer to member variable of hlw8012. */ Hlw8012Config *mutable_hlw8012(); - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 // optional Max7219Config max7219, id 32 /*! * Function for querying if max7219 has been set. @@ -5727,9 +5710,7 @@ class HardwareConfig : public Message * @return pointer to member variable of max7219. */ Max7219Config *mutable_max7219(); - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 // optional Tlc5947Config tlc5947, id 33 /*! * Function for querying if tlc5947 has been set. @@ -5753,9 +5734,7 @@ class HardwareConfig : public Message * @return pointer to member variable of tlc5947. */ Tlc5947Config *mutable_tlc5947(); - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS // repeated Ws2812bConfig ws2812b, id 34 //! Function get const-access to the elements of ws2812b. const std::vector &ws2812b() const; @@ -5779,9 +5758,7 @@ class HardwareConfig : public Message Ws2812bConfig *mutable_ws2812b(unsigned x); //! Function to get mutable access to all elements of ws2812b. std::vector *mutable_ws2812b(); - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT // optional DhtConfig dht, id 35 /*! * Function for querying if dht has been set. @@ -5805,9 +5782,7 @@ class HardwareConfig : public Message * @return pointer to member variable of dht. */ DhtConfig *mutable_dht(); - #endif // CONFIG_DHT - #ifdef CONFIG_I2C // repeated I2CConfig i2c, id 36 //! Function get const-access to the elements of i2c. const std::vector &i2c() const; @@ -5831,9 +5806,7 @@ class HardwareConfig : public Message I2CConfig *mutable_i2c(unsigned x); //! Function to get mutable access to all elements of i2c. std::vector *mutable_i2c(); - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 // repeated HcSr04Config hcsr04, id 37 //! Function get const-access to the elements of hcsr04. const std::vector &hcsr04() const; @@ -5857,9 +5830,7 @@ class HardwareConfig : public Message HcSr04Config *mutable_hcsr04(unsigned x); //! Function to get mutable access to all elements of hcsr04. std::vector *mutable_hcsr04(); - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE // optional OneWireConfig onewire, id 38 /*! * Function for querying if onewire has been set. @@ -5883,9 +5854,7 @@ class HardwareConfig : public Message * @return pointer to member variable of onewire. */ OneWireConfig *mutable_onewire(); - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 // optional SX1276Config sx1276, id 39 /*! * Function for querying if sx1276 has been set. @@ -5909,9 +5878,7 @@ class HardwareConfig : public Message * @return pointer to member variable of sx1276. */ SX1276Config *mutable_sx1276(); - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS // repeated GpioCluster iocluster, id 40 //! Function get const-access to the elements of iocluster. const std::vector &iocluster() const; @@ -5935,9 +5902,7 @@ class HardwareConfig : public Message GpioCluster *mutable_iocluster(unsigned x); //! Function to get mutable access to all elements of iocluster. std::vector *mutable_iocluster(); - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY // optional DisplayConfig display, id 50 /*! * Function for querying if display has been set. @@ -5961,7 +5926,6 @@ class HardwareConfig : public Message * @return pointer to member variable of display. */ DisplayConfig *mutable_display(); - #endif // CONFIG_DISPLAY protected: @@ -5975,80 +5939,44 @@ class HardwareConfig : public Message std::vector m_uart; //! AdcConfig adc, id 4 AdcConfig m_adc; - #ifdef CONFIG_TOUCHPAD //! TouchpadConfig touchpad, id 5 TouchpadConfig m_touchpad; - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD //! TouchChannelConfig tp_channel, id 6 std::vector m_tp_channel; - #endif // CONFIG_TOUCHPAD //! GpioConfig gpios, id 7 std::vector m_gpios; - #ifdef CONFIG_SPI //! SpiBusConfig spibus, id 8 std::vector m_spibus; - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON //! ButtonConfig button, id 16 std::vector m_button; - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY //! RelayConfig relay, id 17 std::vector m_relay; - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS //! LedConfig led, id 18 std::vector m_led; - #endif // CONFIG_LEDS - #ifdef CONFIG_BUZZER //! BuzzerConfig buzzer, id 19 BuzzerConfig m_buzzer; - #endif // CONFIG_BUZZER - #ifdef CONFIG_HLW8012 //! Hlw8012Config hlw8012, id 20 Hlw8012Config m_hlw8012; - #endif // CONFIG_HLW8012 - #ifdef CONFIG_MAX7219 //! Max7219Config max7219, id 32 Max7219Config m_max7219; - #endif // CONFIG_MAX7219 - #ifdef CONFIG_TLC5947 //! Tlc5947Config tlc5947, id 33 Tlc5947Config m_tlc5947; - #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS //! Ws2812bConfig ws2812b, id 34 std::vector m_ws2812b; - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_DHT //! DhtConfig dht, id 35 DhtConfig m_dht; - #endif // CONFIG_DHT - #ifdef CONFIG_I2C //! I2CConfig i2c, id 36 std::vector m_i2c; - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 //! HcSr04Config hcsr04, id 37 std::vector m_hcsr04; - #endif // CONFIG_HCSR04 - #ifdef CONFIG_ONEWIRE //! OneWireConfig onewire, id 38 OneWireConfig m_onewire; - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_SX1276 //! SX1276Config sx1276, id 39 SX1276Config m_sx1276; - #endif // CONFIG_SX1276 - #ifdef CONFIG_IOEXTENDERS //! GpioCluster iocluster, id 40 std::vector m_iocluster; - #endif // CONFIG_IOEXTENDERS - #ifdef CONFIG_DISPLAY //! DisplayConfig display, id 50 DisplayConfig m_display; - #endif // CONFIG_DISPLAY private: uint16_t p_validbits = 0; @@ -6382,7 +6310,6 @@ inline void SystemConfig::set_model_number(const std::string &v) -#ifdef CONFIG_USB_DIAGLOG inline bool SystemConfig::usb_diag() const { return m_usb_diag; @@ -6412,10 +6339,8 @@ inline void SystemConfig::set_usb_diag(bool v) m_usb_diag = v; } -#endif // CONFIG_USB_DIAGLOG -#ifdef CONFIG_USB_CONSOLE inline bool SystemConfig::usb_con() const { return m_usb_con; @@ -6445,10 +6370,8 @@ inline void SystemConfig::set_usb_con(bool v) m_usb_con = v; } -#endif // CONFIG_USB_CONSOLE -#ifdef CONFIG_ESP_PHY_ENABLE_USB inline int8_t SystemConfig::cc1_gpio() const { return m_cc1_gpio; @@ -6478,10 +6401,8 @@ inline void SystemConfig::set_cc1_gpio(int8_t v) m_cc1_gpio = v; } -#endif // CONFIG_ESP_PHY_ENABLE_USB -#ifdef CONFIG_ESP_PHY_ENABLE_USB inline int8_t SystemConfig::cc2_gpio() const { return m_cc2_gpio; @@ -6511,7 +6432,6 @@ inline void SystemConfig::set_cc2_gpio(int8_t v) m_cc2_gpio = v; } -#endif // CONFIG_ESP_PHY_ENABLE_USB inline size_t TouchpadConfig::getMaxSize() @@ -7045,7 +6965,6 @@ inline void ButtonConfig::set_pull_mode(pull_mode_t v) -#ifdef CONFIG_ROTARYENCODER inline int8_t ButtonConfig::clk() const { return m_clk; @@ -7075,10 +6994,8 @@ inline void ButtonConfig::set_clk(int8_t v) m_clk = v; } -#endif // CONFIG_ROTARYENCODER -#ifdef CONFIG_ROTARYENCODER inline int8_t ButtonConfig::dt() const { return m_dt; @@ -7108,7 +7025,6 @@ inline void ButtonConfig::set_dt(int8_t v) m_dt = v; } -#endif // CONFIG_ROTARYENCODER inline size_t RelayConfig::getMaxSize() @@ -8067,7 +7983,6 @@ inline void I2CConfig::set_xpullup(bool v) -#ifdef CONFIG_I2C_XDEV inline i2cdev_t I2CConfig::devices(unsigned x) const { return m_devices[x]; @@ -8148,7 +8063,6 @@ inline size_t I2CConfig::devices_size() const return m_devices.size(); } -#endif // CONFIG_I2C_XDEV inline size_t HcSr04Config::getMaxSize() @@ -9531,7 +9445,8 @@ inline size_t DisplayConfig::getMaxSize() // optional unsigned options, id 2 has maximum size 11 // optional unsigned maxx, id 3 has maximum size 11 // optional unsigned maxy, id 4 has maximum size 11 - return 35; + // repeated string skip_env, id 5 has unlimited size + return SIZE_MAX; } inline disp_t DisplayConfig::type() const @@ -9676,6 +9591,60 @@ inline void DisplayConfig::set_maxy(uint64_t v) +inline const std::string &DisplayConfig::skip_env(unsigned x) const +{ + return m_skip_env[x]; +} + +inline const std::vector &DisplayConfig::skip_env() const +{ + return m_skip_env; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void DisplayConfig::clear_skip_env() +{ + m_skip_env.clear(); +} + +inline std::string *DisplayConfig::mutable_skip_env(unsigned x) +{ + if (x >= m_skip_env.size()) + m_skip_env.resize(x+1); + return &m_skip_env[x]; +} + +inline std::vector *DisplayConfig::mutable_skip_env() +{ + return &m_skip_env; +} + +inline void DisplayConfig::add_skip_env(const std::string &v) +{ + m_skip_env.push_back(v); +} + +inline void DisplayConfig::add_skip_env(const char *s) +{ + m_skip_env.push_back(s); +} + +inline void DisplayConfig::set_skip_env(unsigned x, const std::string &v) +{ + assert(x < m_skip_env.size()); + m_skip_env[x] = v; +} + +inline size_t DisplayConfig::skip_env_size() const +{ + return m_skip_env.size(); +} + + + inline size_t SpiDeviceConfig::getMaxSize() { // optional spidrv_t drv, id 1 has maximum size 2 @@ -11038,7 +11007,7 @@ inline size_t HardwareConfig::getMaxSize() // optional OneWireConfig onewire, id 38 has maximum size 10 // optional SX1276Config sx1276, id 39 has maximum size 20 // repeated GpioCluster iocluster, id 40 has unlimited size - // optional DisplayConfig display, id 50 has maximum size 37 + // optional DisplayConfig display, id 50 has maximum size 36 return SIZE_MAX; } @@ -11215,7 +11184,6 @@ inline void HardwareConfig::set_adc(const AdcConfig &v) -#ifdef CONFIG_TOUCHPAD inline const TouchpadConfig &HardwareConfig::touchpad() const { return m_touchpad; @@ -11257,10 +11225,8 @@ inline void HardwareConfig::set_touchpad(const TouchpadConfig &v) p_validbits |= ((uint16_t)1U << 3); } -#endif // CONFIG_TOUCHPAD -#ifdef CONFIG_TOUCHPAD inline const TouchChannelConfig &HardwareConfig::tp_channel(unsigned x) const { return m_tp_channel[x]; @@ -11309,7 +11275,6 @@ inline size_t HardwareConfig::tp_channel_size() const return m_tp_channel.size(); } -#endif // CONFIG_TOUCHPAD inline const GpioConfig &HardwareConfig::gpios(unsigned x) const @@ -11362,7 +11327,6 @@ inline size_t HardwareConfig::gpios_size() const -#ifdef CONFIG_SPI inline const SpiBusConfig &HardwareConfig::spibus(unsigned x) const { return m_spibus[x]; @@ -11411,10 +11375,8 @@ inline size_t HardwareConfig::spibus_size() const return m_spibus.size(); } -#endif // CONFIG_SPI -#ifdef CONFIG_BUTTON inline const ButtonConfig &HardwareConfig::button(unsigned x) const { return m_button[x]; @@ -11463,10 +11425,8 @@ inline size_t HardwareConfig::button_size() const return m_button.size(); } -#endif // CONFIG_BUTTON -#ifdef CONFIG_RELAY inline const RelayConfig &HardwareConfig::relay(unsigned x) const { return m_relay[x]; @@ -11515,10 +11475,8 @@ inline size_t HardwareConfig::relay_size() const return m_relay.size(); } -#endif // CONFIG_RELAY -#ifdef CONFIG_LEDS inline const LedConfig &HardwareConfig::led(unsigned x) const { return m_led[x]; @@ -11567,10 +11525,8 @@ inline size_t HardwareConfig::led_size() const return m_led.size(); } -#endif // CONFIG_LEDS -#ifdef CONFIG_BUZZER inline const BuzzerConfig &HardwareConfig::buzzer() const { return m_buzzer; @@ -11612,10 +11568,8 @@ inline void HardwareConfig::set_buzzer(const BuzzerConfig &v) p_validbits |= ((uint16_t)1U << 4); } -#endif // CONFIG_BUZZER -#ifdef CONFIG_HLW8012 inline const Hlw8012Config &HardwareConfig::hlw8012() const { return m_hlw8012; @@ -11657,10 +11611,8 @@ inline void HardwareConfig::set_hlw8012(const Hlw8012Config &v) p_validbits |= ((uint16_t)1U << 5); } -#endif // CONFIG_HLW8012 -#ifdef CONFIG_MAX7219 inline const Max7219Config &HardwareConfig::max7219() const { return m_max7219; @@ -11702,10 +11654,8 @@ inline void HardwareConfig::set_max7219(const Max7219Config &v) p_validbits |= ((uint16_t)1U << 6); } -#endif // CONFIG_MAX7219 -#ifdef CONFIG_TLC5947 inline const Tlc5947Config &HardwareConfig::tlc5947() const { return m_tlc5947; @@ -11747,10 +11697,8 @@ inline void HardwareConfig::set_tlc5947(const Tlc5947Config &v) p_validbits |= ((uint16_t)1U << 7); } -#endif // CONFIG_TLC5947 -#ifdef CONFIG_RGBLEDS inline const Ws2812bConfig &HardwareConfig::ws2812b(unsigned x) const { return m_ws2812b[x]; @@ -11799,10 +11747,8 @@ inline size_t HardwareConfig::ws2812b_size() const return m_ws2812b.size(); } -#endif // CONFIG_RGBLEDS -#ifdef CONFIG_DHT inline const DhtConfig &HardwareConfig::dht() const { return m_dht; @@ -11844,10 +11790,8 @@ inline void HardwareConfig::set_dht(const DhtConfig &v) p_validbits |= ((uint16_t)1U << 8); } -#endif // CONFIG_DHT -#ifdef CONFIG_I2C inline const I2CConfig &HardwareConfig::i2c(unsigned x) const { return m_i2c[x]; @@ -11896,10 +11840,8 @@ inline size_t HardwareConfig::i2c_size() const return m_i2c.size(); } -#endif // CONFIG_I2C -#ifdef CONFIG_HCSR04 inline const HcSr04Config &HardwareConfig::hcsr04(unsigned x) const { return m_hcsr04[x]; @@ -11948,10 +11890,8 @@ inline size_t HardwareConfig::hcsr04_size() const return m_hcsr04.size(); } -#endif // CONFIG_HCSR04 -#ifdef CONFIG_ONEWIRE inline const OneWireConfig &HardwareConfig::onewire() const { return m_onewire; @@ -11993,10 +11933,8 @@ inline void HardwareConfig::set_onewire(const OneWireConfig &v) p_validbits |= ((uint16_t)1U << 9); } -#endif // CONFIG_ONEWIRE -#ifdef CONFIG_SX1276 inline const SX1276Config &HardwareConfig::sx1276() const { return m_sx1276; @@ -12038,10 +11976,8 @@ inline void HardwareConfig::set_sx1276(const SX1276Config &v) p_validbits |= ((uint16_t)1U << 10); } -#endif // CONFIG_SX1276 -#ifdef CONFIG_IOEXTENDERS inline const GpioCluster &HardwareConfig::iocluster(unsigned x) const { return m_iocluster[x]; @@ -12090,10 +12026,8 @@ inline size_t HardwareConfig::iocluster_size() const return m_iocluster.size(); } -#endif // CONFIG_IOEXTENDERS -#ifdef CONFIG_DISPLAY inline const DisplayConfig &HardwareConfig::display() const { return m_display; @@ -12135,7 +12069,6 @@ inline void HardwareConfig::set_display(const DisplayConfig &v) p_validbits |= ((uint16_t)1U << 11); } -#endif // CONFIG_DISPLAY #endif diff --git a/components/wfc/swcfg_esp32.cpp b/components/wfc/swcfg_esp32.cpp index a1be974..278057d 100644 --- a/components/wfc/swcfg_esp32.cpp +++ b/components/wfc/swcfg_esp32.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -95,9 +96,9 @@ #include #include #include -#include "swcfg.h" +#include "swcfg_esp32.h" -#include "wfccore.h" +#include "wfccore_esp32.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -8690,16 +8691,6 @@ Message *NodeConfig::p_getMember(const char *s, unsigned n, unsigned x) } else if ((n == 9) && (0 == memcmp("timefuses",s,9))) { if (x < m_timefuses.size()) return &m_timefuses[x]; - #ifdef CONFIG_SIGNAL_PROC - } else if ((n == 7) && (0 == memcmp("signals",s,7))) { - if (x < m_signals.size()) - return &m_signals[x]; - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - } else if ((n == 9) && (0 == memcmp("functions",s,9))) { - if (x < m_functions.size()) - return &m_functions[x]; - #endif // CONFIG_SIGNAL_PROC #ifdef CONFIG_STATEMACHINES } else if ((n == 10) && (0 == memcmp("statemachs",s,10))) { if (x < m_statemachs.size()) diff --git a/components/wfc/swcfg_esp32.h b/components/wfc/swcfg_esp32.h index af25939..58b04df 100644 --- a/components/wfc/swcfg_esp32.h +++ b/components/wfc/swcfg_esp32.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -92,8 +93,8 @@ * asserts, comments, genlib, gnux */ -#ifndef SWCFG_H -#define SWCFG_H +#ifndef SWCFG_ESP32_H +#define SWCFG_ESP32_H #include #define OUTPUT_TO_ASCII 1 @@ -126,7 +127,7 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_esp32.h" /* wfc support functions not needed */ typedef uint32_t varint_t; diff --git a/components/wfc/swcfg_esp8266.cpp b/components/wfc/swcfg_esp8266.cpp index 192976f..4fabfba 100644 --- a/components/wfc/swcfg_esp8266.cpp +++ b/components/wfc/swcfg_esp8266.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -95,9 +96,9 @@ #include #include #include -#include "swcfg.h" +#include "swcfg_esp8266.h" -#include "wfccore.h" +#include "wfccore_esp8266.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -7784,16 +7785,6 @@ Message *NodeConfig::p_getMember(const char *s, unsigned n, unsigned x) } else if ((n == 9) && (0 == memcmp("timefuses",s,9))) { if (x < m_timefuses.size()) return &m_timefuses[x]; - #ifdef CONFIG_SIGNAL_PROC - } else if ((n == 7) && (0 == memcmp("signals",s,7))) { - if (x < m_signals.size()) - return &m_signals[x]; - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - } else if ((n == 9) && (0 == memcmp("functions",s,9))) { - if (x < m_functions.size()) - return &m_functions[x]; - #endif // CONFIG_SIGNAL_PROC #ifdef CONFIG_STATEMACHINES } else if ((n == 10) && (0 == memcmp("statemachs",s,10))) { if (x < m_statemachs.size()) diff --git a/components/wfc/swcfg_esp8266.h b/components/wfc/swcfg_esp8266.h index 080ace1..2ba6a92 100644 --- a/components/wfc/swcfg_esp8266.h +++ b/components/wfc/swcfg_esp8266.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -92,8 +93,8 @@ * asserts, comments, genlib, gnux */ -#ifndef SWCFG_H -#define SWCFG_H +#ifndef SWCFG_ESP8266_H +#define SWCFG_ESP8266_H #include #define OUTPUT_TO_ASCII 1 @@ -126,7 +127,7 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_esp8266.h" /* wfc support functions not needed */ typedef _ssize_t ssize_t; diff --git a/components/wfc/swcfg_esp8285.cpp b/components/wfc/swcfg_esp8285.cpp index 71e5c35..1d15845 100644 --- a/components/wfc/swcfg_esp8285.cpp +++ b/components/wfc/swcfg_esp8285.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -97,9 +98,9 @@ #include #include #include -#include "swcfg.h" +#include "swcfg_esp8285.h" -#include "wfccore.h" +#include "wfccore_esp8285.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian diff --git a/components/wfc/swcfg_esp8285.h b/components/wfc/swcfg_esp8285.h index f991221..8b9cb23 100644 --- a/components/wfc/swcfg_esp8285.h +++ b/components/wfc/swcfg_esp8285.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -94,8 +95,8 @@ * asserts, comments, genlib, gnux */ -#ifndef SWCFG_H -#define SWCFG_H +#ifndef SWCFG_ESP8285_H +#define SWCFG_ESP8285_H #include #define OUTPUT_TO_ASCII 1 @@ -127,7 +128,7 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_esp8285.h" /* wfc support functions not needed */ typedef _ssize_t ssize_t; diff --git a/components/wfc/swcfg_pc.cpp b/components/wfc/swcfg_pc.cpp index d1f6514..7b504be 100644 --- a/components/wfc/swcfg_pc.cpp +++ b/components/wfc/swcfg_pc.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,7 @@ * options from commandline: * * options from pc: + * cfgdefs : "all" * Optimize : "speed" * toASCII : "toASCII" * toSink : "" @@ -94,9 +95,9 @@ #include #include #include -#include "swcfg.h" +#include "swcfg_pc.h" -#include "wfccore.h" +#include "wfccore_pc.h" #if !defined(WFC_ENDIAN) || (WFC_ENDIAN != 0) #error wfc: incompatible settings concerning endian @@ -6652,13 +6653,9 @@ void NodeConfig::clear() m_syslog_host.clear(); m_sntp_server.clear(); m_timezone.clear(); - #ifdef CONFIG_MQTT m_mqtt.clear(); - #endif // CONFIG_MQTT m_dmesg_size = 2048; - #ifdef CONFIG_INFLUX m_influx.clear(); - #endif // CONFIG_INFLUX m_station2ap_time = 0; m_domainname.clear(); m_holidays.clear(); @@ -6666,40 +6663,24 @@ void NodeConfig::clear() m_actions_enable = 1; m_triggers.clear(); m_uart.clear(); - #ifdef CONFIG_TERMSERV m_terminal.clear(); - #endif // CONFIG_TERMSERV m_udp_ctrl_port = 12719; m_debugs.clear(); - #ifdef CONFIG_FTP m_ftpd.clear(); - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP m_httpd.clear(); - #endif // CONFIG_HTTP m_otasrv.clear(); m_timefuses.clear(); - #ifdef CONFIG_STATEMACHINES m_statemachs.clear(); - #endif // CONFIG_STATEMACHINES m_max_on_time = 0; m_threshold_off = 0; m_threshold_on = 0; m_dim_step = 0; m_lightctrl = 0; m_pwm_freq = 0; - #ifdef CONFIG_APP_PARAMS m_app_params.clear(); - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS m_thresholds.clear(); - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA m_luafiles.clear(); - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE m_owdevices.clear(); - #endif // CONFIG_ONEWIRE p_validbits = 0; } @@ -6730,15 +6711,11 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const ascii_string(o,indent,m_syslog_host.data(),m_syslog_host.size(),"syslog_host"); ascii_string(o,indent,m_sntp_server.data(),m_sntp_server.size(),"sntp_server"); ascii_string(o,indent,m_timezone.data(),m_timezone.size(),"timezone"); - #ifdef CONFIG_MQTT ascii_indent(o,indent,"mqtt"); m_mqtt.toASCII(o,indent); - #endif // CONFIG_MQTT ascii_numeric(o, indent, "dmesg_size", m_dmesg_size); - #ifdef CONFIG_INFLUX ascii_indent(o,indent,"influx"); m_influx.toASCII(o,indent); - #endif // CONFIG_INFLUX ascii_numeric(o, indent, "station2ap_time", m_station2ap_time); ascii_string(o,indent,m_domainname.data(),m_domainname.size(),"domainname"); ascii_indent(o,indent); @@ -6790,7 +6767,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #ifdef CONFIG_TERMSERV ascii_indent(o,indent); size_t s_terminal = m_terminal.size(); o << "terminal[" << s_terminal << "] = {"; @@ -6803,7 +6779,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_TERMSERV ascii_numeric(o, indent, "udp_ctrl_port", m_udp_ctrl_port); ascii_indent(o,indent); size_t s_debugs = m_debugs.size(); @@ -6817,14 +6792,10 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #ifdef CONFIG_FTP ascii_indent(o,indent,"ftpd"); m_ftpd.toASCII(o,indent); - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP ascii_indent(o,indent,"httpd"); m_httpd.toASCII(o,indent); - #endif // CONFIG_HTTP ascii_string(o,indent,m_otasrv.data(),m_otasrv.size(),"otasrv"); ascii_indent(o,indent); size_t s_timefuses = m_timefuses.size(); @@ -6838,7 +6809,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #ifdef CONFIG_STATEMACHINES ascii_indent(o,indent); size_t s_statemachs = m_statemachs.size(); o << "statemachs[" << s_statemachs << "] = {"; @@ -6851,14 +6821,12 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_STATEMACHINES ascii_numeric(o, indent, "max_on_time", m_max_on_time); ascii_numeric(o, indent, "threshold_off", m_threshold_off); ascii_numeric(o, indent, "threshold_on", m_threshold_on); ascii_numeric(o, indent, "dim_step", m_dim_step); ascii_bool(o, indent, "lightctrl", m_lightctrl); ascii_numeric(o, indent, "pwm_freq", m_pwm_freq); - #ifdef CONFIG_APP_PARAMS ascii_indent(o,indent); size_t s_app_params = m_app_params.size(); o << "app_params[" << s_app_params << "] = {"; @@ -6871,8 +6839,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS ascii_indent(o,indent); size_t s_thresholds = m_thresholds.size(); o << "thresholds[" << s_thresholds << "] = {"; @@ -6885,8 +6851,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA ascii_indent(o,indent); size_t s_luafiles = m_luafiles.size(); o << "luafiles[" << s_luafiles << "] = {"; @@ -6899,8 +6863,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE ascii_indent(o,indent); size_t s_owdevices = m_owdevices.size(); o << "owdevices[" << s_owdevices << "] = {"; @@ -6913,7 +6875,6 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - #endif // CONFIG_ONEWIRE --indent; ascii_indent(o,indent); o << '}'; @@ -7048,7 +7009,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) a += v; } break; - #ifdef CONFIG_MQTT case 0x52: // mqtt id 10, type MQTT, coding byte[] { varint_t v; @@ -7067,14 +7027,12 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } p_validbits |= ((uint32_t)1U << 4); break; - #endif // CONFIG_MQTT case 0x5c: // dmesg_size id 11, type uint16_t, coding 16bit if ((a+1) >= e) return -304; set_dmesg_size((uint16_t) read_u16(a)); a += 2; break; - #ifdef CONFIG_INFLUX case 0x62: // influx id 12, type Influx, coding byte[] { varint_t v; @@ -7093,7 +7051,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } p_validbits |= ((uint32_t)1U << 6); break; - #endif // CONFIG_INFLUX case 0x68: // station2ap_time id 13, type uint64_t, coding varint { varint_t v; @@ -7197,7 +7154,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #ifdef CONFIG_TERMSERV case 0xaa: // terminal id 21, type TerminalConfig, coding byte[] { varint_t v; @@ -7216,7 +7172,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #endif // CONFIG_TERMSERV case 0xb4: // udp_ctrl_port id 22, type uint16_t, coding 16bit if ((a+1) >= e) return -320; @@ -7234,7 +7189,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) a += v; } break; - #ifdef CONFIG_FTP case 0xc2: // ftpd id 24, type FtpHttpConfig, coding byte[] { varint_t v; @@ -7253,8 +7207,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } p_validbits |= ((uint32_t)1U << 10); break; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP case 0xca: // httpd id 25, type FtpHttpConfig, coding byte[] { varint_t v; @@ -7273,7 +7225,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } p_validbits |= ((uint32_t)1U << 11); break; - #endif // CONFIG_HTTP case 0xd2: // otasrv id 26, type std::string, coding byte[] { varint_t v; @@ -7303,7 +7254,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #ifdef CONFIG_STATEMACHINES case 0x10a: // statemachs id 33, type StateMachineConfig, coding byte[] { varint_t v; @@ -7322,7 +7272,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #endif // CONFIG_STATEMACHINES case 0x110: // max_on_time id 34, type uint64_t, coding varint { varint_t v; @@ -7378,7 +7327,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) set_pwm_freq(v); } break; - #ifdef CONFIG_APP_PARAMS case 0x142: // app_params id 40, type AppParam, coding byte[] { varint_t v; @@ -7397,8 +7345,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS case 0x14a: // thresholds id 41, type ThresholdConfig, coding byte[] { varint_t v; @@ -7417,8 +7363,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA case 0x152: // luafiles id 42, type std::string, coding byte[] { varint_t v; @@ -7430,8 +7374,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) a += v; } break; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE case 0x192: // owdevices id 50, type OwDeviceConfig, coding byte[] { varint_t v; @@ -7450,7 +7392,6 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } } break; - #endif // CONFIG_ONEWIRE default: // unknown field (option unknown=skip) { @@ -7608,7 +7549,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const memcpy(a,m_timezone.data(),timezone_s); a += timezone_s; } - #ifdef CONFIG_MQTT // has mqtt? if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 @@ -7624,7 +7564,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == mqtt_ws); } - #endif // CONFIG_MQTT // has dmesg_size? if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c @@ -7634,7 +7573,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const write_u16(a,m_dmesg_size); a += 2; } - #ifdef CONFIG_INFLUX // has influx? if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 @@ -7650,7 +7588,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == influx_ws); } - #endif // CONFIG_INFLUX // has station2ap_time? if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 @@ -7748,7 +7685,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == uart_ws); } - #ifdef CONFIG_TERMSERV for (const auto &x : m_terminal) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa if (2 > (e-a)) @@ -7764,7 +7700,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == terminal_ws); } - #endif // CONFIG_TERMSERV // has udp_ctrl_port? if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 @@ -7789,7 +7724,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const memcpy(a,x.data(),debugs_s); a += debugs_s; } - #ifdef CONFIG_FTP // has ftpd? if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 @@ -7806,8 +7740,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == ftpd_ws); } - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP // has httpd? if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca @@ -7824,7 +7756,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == httpd_ws); } - #endif // CONFIG_HTTP // has otasrv? if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 @@ -7855,13 +7786,8 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == timefuses_ws); } - #ifdef CONFIG_SIGNAL_PROC // 'signals' is obsolete. Therefore no data will be written. - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC // 'functions' is obsolete. Therefore no data will be written. - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES for (const auto &x : m_statemachs) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) @@ -7877,7 +7803,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == statemachs_ws); } - #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // 'threshold_off' is deprecated. Therefore no data will be written. // 'threshold_on' is deprecated. Therefore no data will be written. @@ -7914,7 +7839,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const return -404; a += n; } - #ifdef CONFIG_APP_PARAMS for (const auto &x : m_app_params) { // 'app_params': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) @@ -7930,8 +7854,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == app_params_ws); } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS for (const auto &x : m_thresholds) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a if (2 > (e-a)) @@ -7947,8 +7869,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == thresholds_ws); } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA for (const auto &x : m_luafiles) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 if (2 > (e-a)) @@ -7963,8 +7883,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const memcpy(a,x.data(),luafiles_s); a += luafiles_s; } - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE for (const auto &x : m_owdevices) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) @@ -7980,7 +7898,6 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == owdevices_ws); } - #endif // CONFIG_ONEWIRE assert(a <= e); return a-b; } @@ -8051,27 +7968,23 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,timezone_s); send_bytes(put,(const uint8_t*) m_timezone.data(),timezone_s); } - #ifdef CONFIG_MQTT if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 put(0x52); // 'mqtt': id=10 send_varint(put,m_mqtt.calcSize()); m_mqtt.toWire(put); } - #endif // CONFIG_MQTT if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c put(0x5c); // 'dmesg_size': id=11 send_u16(put,m_dmesg_size); } - #ifdef CONFIG_INFLUX if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 put(0x62); // 'influx': id=12 send_varint(put,m_influx.calcSize()); m_influx.toWire(put); } - #endif // CONFIG_INFLUX if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 put(0x68); // 'station2ap_time': id=13 @@ -8118,7 +8031,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_uart[x].calcSize()); m_uart[x].toWire(put); } - #ifdef CONFIG_TERMSERV for (size_t x = 0, y = m_terminal.size(); x != y; ++x) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa put(0xaa); @@ -8126,7 +8038,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_terminal[x].calcSize()); m_terminal[x].toWire(put); } - #endif // CONFIG_TERMSERV if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 put(0xb4); @@ -8141,7 +8052,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,debugs_s); send_bytes(put,(const uint8_t*) m_debugs[x].data(),debugs_s); } - #ifdef CONFIG_FTP if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 put(0xc2); @@ -8149,8 +8059,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_ftpd.calcSize()); m_ftpd.toWire(put); } - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca put(0xca); @@ -8158,7 +8066,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_httpd.calcSize()); m_httpd.toWire(put); } - #endif // CONFIG_HTTP if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 put(0xd2); @@ -8176,7 +8083,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const } // 'signals' is deprecated. Therefore no data will be written. // 'functions' is deprecated. Therefore no data will be written. - #ifdef CONFIG_STATEMACHINES for (size_t x = 0, y = m_statemachs.size(); x != y; ++x) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a put(0x8a); @@ -8184,7 +8090,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_statemachs[x].calcSize()); m_statemachs[x].toWire(put); } - #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // 'threshold_off' is deprecated. Therefore no data will be written. // 'threshold_on' is deprecated. Therefore no data will be written. @@ -8206,7 +8111,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const put(0x2); send_varint(put,m_pwm_freq); } - #ifdef CONFIG_APP_PARAMS for (size_t x = 0, y = m_app_params.size(); x != y; ++x) { // 'app_params': id=40, encoding=lenpfx, tag=0x142 put(0xc2); @@ -8214,8 +8118,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_app_params[x].calcSize()); m_app_params[x].toWire(put); } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS for (size_t x = 0, y = m_thresholds.size(); x != y; ++x) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a put(0xca); @@ -8223,8 +8125,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_thresholds[x].calcSize()); m_thresholds[x].toWire(put); } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA for (size_t x = 0, y = m_luafiles.size(); x != y; ++x) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 put(0xd2); @@ -8233,8 +8133,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,luafiles_s); send_bytes(put,(const uint8_t*) m_luafiles[x].data(),luafiles_s); } - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE for (size_t x = 0, y = m_owdevices.size(); x != y; ++x) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 put(0x92); @@ -8242,7 +8140,6 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_owdevices[x].calcSize()); m_owdevices[x].toWire(put); } - #endif // CONFIG_ONEWIRE } void NodeConfig::toString(std::string &put) const @@ -8311,27 +8208,23 @@ void NodeConfig::toString(std::string &put) const send_varint(put,timezone_s); put.append((const char *)(const uint8_t*) m_timezone.data(),timezone_s); } - #ifdef CONFIG_MQTT if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 put.push_back(0x52); // 'mqtt': id=10 send_varint(put,m_mqtt.calcSize()); m_mqtt.toString(put); } - #endif // CONFIG_MQTT if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c put.push_back(0x5c); // 'dmesg_size': id=11 send_u16(put,m_dmesg_size); } - #ifdef CONFIG_INFLUX if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 put.push_back(0x62); // 'influx': id=12 send_varint(put,m_influx.calcSize()); m_influx.toString(put); } - #endif // CONFIG_INFLUX if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 put.push_back(0x68); // 'station2ap_time': id=13 @@ -8378,7 +8271,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_uart[x].calcSize()); m_uart[x].toString(put); } - #ifdef CONFIG_TERMSERV for (size_t x = 0, y = m_terminal.size(); x != y; ++x) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa put.push_back(0xaa); @@ -8386,7 +8278,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_terminal[x].calcSize()); m_terminal[x].toString(put); } - #endif // CONFIG_TERMSERV if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 put.push_back(0xb4); @@ -8401,7 +8292,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,debugs_s); put.append((const char *)(const uint8_t*) m_debugs[x].data(),debugs_s); } - #ifdef CONFIG_FTP if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 put.push_back(0xc2); @@ -8409,8 +8299,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_ftpd.calcSize()); m_ftpd.toString(put); } - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca put.push_back(0xca); @@ -8418,7 +8306,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_httpd.calcSize()); m_httpd.toString(put); } - #endif // CONFIG_HTTP if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 put.push_back(0xd2); @@ -8436,7 +8323,6 @@ void NodeConfig::toString(std::string &put) const } // 'signals' is deprecated. Therefore no data will be written. // 'functions' is deprecated. Therefore no data will be written. - #ifdef CONFIG_STATEMACHINES for (size_t x = 0, y = m_statemachs.size(); x != y; ++x) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a put.push_back(0x8a); @@ -8444,7 +8330,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_statemachs[x].calcSize()); m_statemachs[x].toString(put); } - #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // 'threshold_off' is deprecated. Therefore no data will be written. // 'threshold_on' is deprecated. Therefore no data will be written. @@ -8466,7 +8351,6 @@ void NodeConfig::toString(std::string &put) const put.push_back(0x2); send_varint(put,m_pwm_freq); } - #ifdef CONFIG_APP_PARAMS for (size_t x = 0, y = m_app_params.size(); x != y; ++x) { // 'app_params': id=40, encoding=lenpfx, tag=0x142 put.push_back(0xc2); @@ -8474,8 +8358,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_app_params[x].calcSize()); m_app_params[x].toString(put); } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS for (size_t x = 0, y = m_thresholds.size(); x != y; ++x) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a put.push_back(0xca); @@ -8483,8 +8365,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_thresholds[x].calcSize()); m_thresholds[x].toString(put); } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA for (size_t x = 0, y = m_luafiles.size(); x != y; ++x) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 put.push_back(0xd2); @@ -8493,8 +8373,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,luafiles_s); put.append((const char *)(const uint8_t*) m_luafiles[x].data(),luafiles_s); } - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE for (size_t x = 0, y = m_owdevices.size(); x != y; ++x) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 put.push_back(0x92); @@ -8502,7 +8380,6 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_owdevices[x].calcSize()); m_owdevices[x].toString(put); } - #endif // CONFIG_ONEWIRE } void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -8563,22 +8440,18 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"timezone"); json_cstr(json,m_timezone.c_str()); } - #ifdef CONFIG_MQTT if (has_mqtt()) { fsep = json_indent(json,indLvl,fsep,"mqtt"); m_mqtt.toJSON(json,indLvl); } - #endif // CONFIG_MQTT if (has_dmesg_size()) { fsep = json_indent(json,indLvl,fsep,"dmesg_size"); json << m_dmesg_size; } - #ifdef CONFIG_INFLUX if (has_influx()) { fsep = json_indent(json,indLvl,fsep,"influx"); m_influx.toJSON(json,indLvl); } - #endif // CONFIG_INFLUX if (has_station2ap_time()) { fsep = json_indent(json,indLvl,fsep,"station2ap_time"); json << m_station2ap_time; @@ -8663,7 +8536,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #ifdef CONFIG_TERMSERV if (size_t s = m_terminal.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -8682,7 +8554,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_TERMSERV if (has_udp_ctrl_port()) { fsep = json_indent(json,indLvl,fsep,"udp_ctrl_port"); json << m_udp_ctrl_port; @@ -8705,18 +8576,14 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #ifdef CONFIG_FTP if (has_ftpd()) { fsep = json_indent(json,indLvl,fsep,"ftpd"); m_ftpd.toJSON(json,indLvl); } - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP if (has_httpd()) { fsep = json_indent(json,indLvl,fsep,"httpd"); m_httpd.toJSON(json,indLvl); } - #endif // CONFIG_HTTP if (has_otasrv()) { fsep = json_indent(json,indLvl,fsep,"otasrv"); json_cstr(json,m_otasrv.c_str()); @@ -8739,7 +8606,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #ifdef CONFIG_STATEMACHINES if (size_t s = m_statemachs.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -8758,7 +8624,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_STATEMACHINES if (has_max_on_time()) { fsep = json_indent(json,indLvl,fsep,"max_on_time"); json << m_max_on_time; @@ -8783,7 +8648,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"pwm_freq"); json << m_pwm_freq; } - #ifdef CONFIG_APP_PARAMS if (size_t s = m_app_params.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -8802,8 +8666,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS if (size_t s = m_thresholds.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -8822,8 +8684,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA if (size_t s = m_luafiles.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -8842,8 +8702,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE if (size_t s = m_owdevices.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -8862,7 +8720,6 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - #endif // CONFIG_ONEWIRE if (fsep == '{') json.put('{'); json.put('\n'); @@ -8928,24 +8785,20 @@ size_t NodeConfig::calcSize() const size_t timezone_s = m_timezone.size(); r += timezone_s + wiresize(timezone_s) + 1 /* tag(timezone) 0x48 */; } - #ifdef CONFIG_MQTT // optional MQTT mqtt, id 10 if (0 != (p_validbits & ((uint32_t)1U << 4))) { size_t mqtt_s = m_mqtt.calcSize(); r += mqtt_s + wiresize(mqtt_s) + 1 /* tag(mqtt) 0x50 */; } - #endif // CONFIG_MQTT // optional fixed16 dmesg_size, id 11 if (0 != (p_validbits & ((uint32_t)1U << 5))) { r += 3; } - #ifdef CONFIG_INFLUX // optional Influx influx, id 12 if (0 != (p_validbits & ((uint32_t)1U << 6))) { size_t influx_s = m_influx.calcSize(); r += influx_s + wiresize(influx_s) + 1 /* tag(influx) 0x60 */; } - #endif // CONFIG_INFLUX // optional unsigned station2ap_time, id 13 if (0 != (p_validbits & ((uint32_t)1U << 7))) { r += wiresize((varint_t)m_station2ap_time) + 1 /* tag(station2ap_time) 0x68 */; @@ -8987,7 +8840,6 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(uart) 0xa0 */; } - #ifdef CONFIG_TERMSERV // repeated TerminalConfig terminal, id 21 // repeated message terminal for (size_t x = 0, y = m_terminal.size(); x < y; ++x) { @@ -8995,7 +8847,6 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(terminal) 0xa8 */; } - #endif // CONFIG_TERMSERV // optional fixed16 udp_ctrl_port, id 22 if (0 != (p_validbits & ((uint32_t)1U << 9))) { r += 4; @@ -9009,20 +8860,16 @@ size_t NodeConfig::calcSize() const r += s + 2 /* tag(debugs) 0xb8 */; } } - #ifdef CONFIG_FTP // optional FtpHttpConfig ftpd, id 24 if (0 != (p_validbits & ((uint32_t)1U << 10))) { size_t ftpd_s = m_ftpd.calcSize(); r += ftpd_s + wiresize(ftpd_s) + 2 /* tag(ftpd) 0xc0 */; } - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP // optional FtpHttpConfig httpd, id 25 if (0 != (p_validbits & ((uint32_t)1U << 11))) { size_t httpd_s = m_httpd.calcSize(); r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } - #endif // CONFIG_HTTP // optional string otasrv, id 26 if (!m_otasrv.empty()) { size_t otasrv_s = m_otasrv.size(); @@ -9035,13 +8882,8 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(timefuses) 0xf0 */; } - #ifdef CONFIG_SIGNAL_PROC // obsolete repeated SignalConfig signals, id 31 - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC // obsolete repeated FunctionConfig functions, id 32 - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES // repeated StateMachineConfig statemachs, id 33 // repeated message statemachs for (size_t x = 0, y = m_statemachs.size(); x < y; ++x) { @@ -9049,7 +8891,6 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(statemachs) 0x108 */; } - #endif // CONFIG_STATEMACHINES // deprecated optional unsigned max_on_time, id 34 // deprecated optional unsigned threshold_off, id 35 // deprecated optional unsigned threshold_on, id 36 @@ -9065,7 +8906,6 @@ size_t NodeConfig::calcSize() const if (0 != (p_validbits & ((uint32_t)1U << 16))) { r += wiresize((varint_t)m_pwm_freq) + 2 /* tag(pwm_freq) 0x138 */; } - #ifdef CONFIG_APP_PARAMS // repeated AppParam app_params, id 40 // repeated message app_params for (size_t x = 0, y = m_app_params.size(); x < y; ++x) { @@ -9073,8 +8913,6 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(app_params) 0x140 */; } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS // repeated ThresholdConfig thresholds, id 41 // repeated message thresholds for (size_t x = 0, y = m_thresholds.size(); x < y; ++x) { @@ -9082,8 +8920,6 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(thresholds) 0x148 */; } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA // repeated string luafiles, id 42 if (!m_luafiles.empty()) { // luafiles: repeated std::string @@ -9093,8 +8929,6 @@ size_t NodeConfig::calcSize() const r += s + 2 /* tag(luafiles) 0x150 */; } } - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE // repeated OwDeviceConfig owdevices, id 50 // repeated message owdevices for (size_t x = 0, y = m_owdevices.size(); x < y; ++x) { @@ -9102,7 +8936,6 @@ size_t NodeConfig::calcSize() const r += wiresize(s); r += s + 2 /* tag(owdevices) 0x190 */; } - #endif // CONFIG_ONEWIRE return r; } @@ -9130,16 +8963,12 @@ bool NodeConfig::operator != (const NodeConfig &r) const return true; if (has_timezone() && (m_timezone != r.m_timezone)) return true; - #ifdef CONFIG_MQTT if (has_mqtt() && (m_mqtt != r.m_mqtt)) return true; - #endif // CONFIG_MQTT if (has_dmesg_size() && (m_dmesg_size != r.m_dmesg_size)) return true; - #ifdef CONFIG_INFLUX if (has_influx() && (m_influx != r.m_influx)) return true; - #endif // CONFIG_INFLUX if (has_station2ap_time() && (m_station2ap_time != r.m_station2ap_time)) return true; if (has_domainname() && (m_domainname != r.m_domainname)) @@ -9154,30 +8983,22 @@ bool NodeConfig::operator != (const NodeConfig &r) const return true; if (m_uart != r.m_uart) return true; - #ifdef CONFIG_TERMSERV if (m_terminal != r.m_terminal) return true; - #endif // CONFIG_TERMSERV if (has_udp_ctrl_port() && (m_udp_ctrl_port != r.m_udp_ctrl_port)) return true; if (m_debugs != r.m_debugs) return true; - #ifdef CONFIG_FTP if (has_ftpd() && (m_ftpd != r.m_ftpd)) return true; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP if (has_httpd() && (m_httpd != r.m_httpd)) return true; - #endif // CONFIG_HTTP if (has_otasrv() && (m_otasrv != r.m_otasrv)) return true; if (m_timefuses != r.m_timefuses) return true; - #ifdef CONFIG_STATEMACHINES if (m_statemachs != r.m_statemachs) return true; - #endif // CONFIG_STATEMACHINES if (has_max_on_time() && (m_max_on_time != r.m_max_on_time)) return true; if (has_threshold_off() && (m_threshold_off != r.m_threshold_off)) @@ -9190,22 +9011,14 @@ bool NodeConfig::operator != (const NodeConfig &r) const return true; if (has_pwm_freq() && (m_pwm_freq != r.m_pwm_freq)) return true; - #ifdef CONFIG_APP_PARAMS if (m_app_params != r.m_app_params) return true; - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS if (m_thresholds != r.m_thresholds) return true; - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA if (m_luafiles != r.m_luafiles) return true; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE if (m_owdevices != r.m_owdevices) return true; - #endif // CONFIG_ONEWIRE return false; } @@ -9337,7 +9150,6 @@ int NodeConfig::setByName(const char *name, const char *value) int r = m_timezone.size(); return r; } - #ifdef CONFIG_MQTT if (0 == memcmp(name,"mqtt",4)) { if ((name[4] == 0) && (value == 0)) { clear_mqtt(); @@ -9347,7 +9159,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_mqtt.setByName(name+5,value); } } - #endif // CONFIG_MQTT if (0 == strcmp(name,"dmesg_size")) { if (value == 0) { clear_dmesg_size(); @@ -9358,7 +9169,6 @@ int NodeConfig::setByName(const char *name, const char *value) p_validbits |= ((uint32_t)1U << 5); return r; } - #ifdef CONFIG_INFLUX if (0 == memcmp(name,"influx",6)) { if ((name[6] == 0) && (value == 0)) { clear_influx(); @@ -9368,7 +9178,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_influx.setByName(name+7,value); } } - #endif // CONFIG_INFLUX if (0 == strcmp(name,"station2ap_time")) { if (value == 0) { clear_station2ap_time(); @@ -9514,7 +9323,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_uart[x].setByName(idxe+2,value); } } - #ifdef CONFIG_TERMSERV if (0 == memcmp(name,"terminal",8)) { if ((name[8] == 0) && (value == 0)) { clear_terminal(); @@ -9544,7 +9352,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_terminal[x].setByName(idxe+2,value); } } - #endif // CONFIG_TERMSERV if (0 == strcmp(name,"udp_ctrl_port")) { if (value == 0) { clear_udp_ctrl_port(); @@ -9585,7 +9392,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_debugs[x].size(); } } - #ifdef CONFIG_FTP if (0 == memcmp(name,"ftpd",4)) { if ((name[4] == 0) && (value == 0)) { clear_ftpd(); @@ -9595,8 +9401,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_ftpd.setByName(name+5,value); } } - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP if (0 == memcmp(name,"httpd",5)) { if ((name[5] == 0) && (value == 0)) { clear_httpd(); @@ -9606,7 +9410,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_httpd.setByName(name+6,value); } } - #endif // CONFIG_HTTP if (0 == strcmp(name,"otasrv")) { if (value == 0) { clear_otasrv(); @@ -9645,7 +9448,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_timefuses[x].setByName(idxe+2,value); } } - #ifdef CONFIG_STATEMACHINES if (0 == memcmp(name,"statemachs",10)) { if ((name[10] == 0) && (value == 0)) { clear_statemachs(); @@ -9675,7 +9477,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_statemachs[x].setByName(idxe+2,value); } } - #endif // CONFIG_STATEMACHINES if (0 == strcmp(name,"max_on_time")) { if (value == 0) { clear_max_on_time(); @@ -9734,7 +9535,6 @@ int NodeConfig::setByName(const char *name, const char *value) p_validbits |= ((uint32_t)1U << 16); return r; } - #ifdef CONFIG_APP_PARAMS if (0 == memcmp(name,"app_params",10)) { if ((name[10] == 0) && (value == 0)) { clear_app_params(); @@ -9764,8 +9564,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_app_params[x].setByName(idxe+2,value); } } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS if (0 == memcmp(name,"thresholds",10)) { if ((name[10] == 0) && (value == 0)) { clear_thresholds(); @@ -9795,8 +9593,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_thresholds[x].setByName(idxe+2,value); } } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA if (0 == memcmp(name,"luafiles",8)) { if ((name[8] == 0) && (value == 0)) { clear_luafiles(); @@ -9827,8 +9623,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_luafiles[x].size(); } } - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE if (0 == memcmp(name,"owdevices",9)) { if ((name[9] == 0) && (value == 0)) { clear_owdevices(); @@ -9858,7 +9652,6 @@ int NodeConfig::setByName(const char *name, const char *value) return m_owdevices[x].setByName(idxe+2,value); } } - #endif // CONFIG_ONEWIRE return -452; } @@ -9869,22 +9662,14 @@ Message *NodeConfig::p_getMember(const char *s, unsigned n) return &m_station; if ((n == 6) && (0 == memcmp("softap",s,6))) return &m_softap; - #ifdef CONFIG_MQTT if ((n == 4) && (0 == memcmp("mqtt",s,4))) return &m_mqtt; - #endif // CONFIG_MQTT - #ifdef CONFIG_INFLUX if ((n == 6) && (0 == memcmp("influx",s,6))) return &m_influx; - #endif // CONFIG_INFLUX - #ifdef CONFIG_FTP if ((n == 4) && (0 == memcmp("ftpd",s,4))) return &m_ftpd; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP if ((n == 5) && (0 == memcmp("httpd",s,5))) return &m_httpd; - #endif // CONFIG_HTTP return 0; } @@ -9903,44 +9688,24 @@ Message *NodeConfig::p_getMember(const char *s, unsigned n, unsigned x) } else if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - #ifdef CONFIG_TERMSERV } else if ((n == 8) && (0 == memcmp("terminal",s,8))) { if (x < m_terminal.size()) return &m_terminal[x]; - #endif // CONFIG_TERMSERV } else if ((n == 9) && (0 == memcmp("timefuses",s,9))) { if (x < m_timefuses.size()) return &m_timefuses[x]; - #ifdef CONFIG_SIGNAL_PROC - } else if ((n == 7) && (0 == memcmp("signals",s,7))) { - if (x < m_signals.size()) - return &m_signals[x]; - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - } else if ((n == 9) && (0 == memcmp("functions",s,9))) { - if (x < m_functions.size()) - return &m_functions[x]; - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES } else if ((n == 10) && (0 == memcmp("statemachs",s,10))) { if (x < m_statemachs.size()) return &m_statemachs[x]; - #endif // CONFIG_STATEMACHINES - #ifdef CONFIG_APP_PARAMS } else if ((n == 10) && (0 == memcmp("app_params",s,10))) { if (x < m_app_params.size()) return &m_app_params[x]; - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS } else if ((n == 10) && (0 == memcmp("thresholds",s,10))) { if (x < m_thresholds.size()) return &m_thresholds[x]; - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_ONEWIRE } else if ((n == 9) && (0 == memcmp("owdevices",s,9))) { if (x < m_owdevices.size()) return &m_owdevices[x]; - #endif // CONFIG_ONEWIRE } return 0; } diff --git a/components/wfc/swcfg_pc.h b/components/wfc/swcfg_pc.h index 3fe5261..31688e7 100644 --- a/components/wfc/swcfg_pc.h +++ b/components/wfc/swcfg_pc.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,7 @@ * options from commandline: * * options from pc: + * cfgdefs : "all" * Optimize : "speed" * toASCII : "toASCII" * toSink : "" @@ -90,8 +91,8 @@ * asserts, comments, genlib, gnux, withEqual, withUnequal */ -#ifndef SWCFG_H -#define SWCFG_H +#ifndef SWCFG_PC_H +#define SWCFG_PC_H #include #define OUTPUT_TO_ASCII 1 @@ -106,7 +107,6 @@ #include /* user requested header files */ -#include "pcconfig.h" #include "support.h" #ifdef WFC_ENDIAN #if WFC_ENDIAN != 0 @@ -127,7 +127,7 @@ #define HAVE_ENUM_MAP 1 #define HAVE_ENUM_NAMES 1 -#include "wfccore.h" +#include "wfccore_pc.h" /* wfc support functions not needed */ typedef uint64_t varint_t; @@ -3722,7 +3722,6 @@ class NodeConfig : public Message */ std::string *mutable_timezone(); - #ifdef CONFIG_MQTT // optional MQTT mqtt, id 10 /*! * Function for querying if mqtt has been set. @@ -3746,7 +3745,6 @@ class NodeConfig : public Message * @return pointer to member variable of mqtt. */ MQTT *mutable_mqtt(); - #endif // CONFIG_MQTT // optional fixed16 dmesg_size, id 11 /*! @@ -3766,7 +3764,6 @@ class NodeConfig : public Message */ uint16_t *mutable_dmesg_size(); - #ifdef CONFIG_INFLUX // optional Influx influx, id 12 /*! * Function for querying if influx has been set. @@ -3790,7 +3787,6 @@ class NodeConfig : public Message * @return pointer to member variable of influx. */ Influx *mutable_influx(); - #endif // CONFIG_INFLUX // optional unsigned station2ap_time, id 13 /*! @@ -3950,7 +3946,6 @@ class NodeConfig : public Message //! Function to get mutable access to all elements of uart. std::vector *mutable_uart(); - #ifdef CONFIG_TERMSERV // repeated TerminalConfig terminal, id 21 //! Function get const-access to the elements of terminal. const std::vector &terminal() const; @@ -3974,7 +3969,6 @@ class NodeConfig : public Message TerminalConfig *mutable_terminal(unsigned x); //! Function to get mutable access to all elements of terminal. std::vector *mutable_terminal(); - #endif // CONFIG_TERMSERV // optional fixed16 udp_ctrl_port, id 22 /*! @@ -4020,7 +4014,6 @@ class NodeConfig : public Message //! Function to get mutable access to all elements of debugs. std::vector *mutable_debugs(); - #ifdef CONFIG_FTP // optional FtpHttpConfig ftpd, id 24 /*! * Function for querying if ftpd has been set. @@ -4044,9 +4037,7 @@ class NodeConfig : public Message * @return pointer to member variable of ftpd. */ FtpHttpConfig *mutable_ftpd(); - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP // optional FtpHttpConfig httpd, id 25 /*! * Function for querying if httpd has been set. @@ -4070,7 +4061,6 @@ class NodeConfig : public Message * @return pointer to member variable of httpd. */ FtpHttpConfig *mutable_httpd(); - #endif // CONFIG_HTTP // optional string otasrv, id 26 /*! @@ -4122,13 +4112,8 @@ class NodeConfig : public Message //! Function to get mutable access to all elements of timefuses. std::vector *mutable_timefuses(); - #ifdef CONFIG_SIGNAL_PROC // obsolete repeated SignalConfig signals, id 31 - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC // obsolete repeated FunctionConfig functions, id 32 - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES // repeated StateMachineConfig statemachs, id 33 //! Function get const-access to the elements of statemachs. const std::vector &statemachs() const; @@ -4152,7 +4137,6 @@ class NodeConfig : public Message StateMachineConfig *mutable_statemachs(unsigned x); //! Function to get mutable access to all elements of statemachs. std::vector *mutable_statemachs(); - #endif // CONFIG_STATEMACHINES // deprecated optional unsigned max_on_time, id 34 /*! @@ -4241,7 +4225,6 @@ class NodeConfig : public Message */ uint64_t *mutable_pwm_freq(); - #ifdef CONFIG_APP_PARAMS // repeated AppParam app_params, id 40 //! Function get const-access to the elements of app_params. const std::vector &app_params() const; @@ -4265,9 +4248,7 @@ class NodeConfig : public Message AppParam *mutable_app_params(unsigned x); //! Function to get mutable access to all elements of app_params. std::vector *mutable_app_params(); - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS // repeated ThresholdConfig thresholds, id 41 //! Function get const-access to the elements of thresholds. const std::vector &thresholds() const; @@ -4291,9 +4272,7 @@ class NodeConfig : public Message ThresholdConfig *mutable_thresholds(unsigned x); //! Function to get mutable access to all elements of thresholds. std::vector *mutable_thresholds(); - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA // repeated string luafiles, id 42 //! Function get const-access to the elements of luafiles. const std::vector &luafiles() const; @@ -4319,9 +4298,7 @@ class NodeConfig : public Message std::string *mutable_luafiles(unsigned x); //! Function to get mutable access to all elements of luafiles. std::vector *mutable_luafiles(); - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE // repeated OwDeviceConfig owdevices, id 50 //! Function get const-access to the elements of owdevices. const std::vector &owdevices() const; @@ -4345,7 +4322,6 @@ class NodeConfig : public Message OwDeviceConfig *mutable_owdevices(unsigned x); //! Function to get mutable access to all elements of owdevices. std::vector *mutable_owdevices(); - #endif // CONFIG_ONEWIRE protected: @@ -4366,10 +4342,8 @@ class NodeConfig : public Message std::string m_pass_hash; //! string otasrv, id 26 std::string m_otasrv; - #ifdef CONFIG_LUA //! string luafiles, id 42 std::vector m_luafiles; - #endif // CONFIG_LUA //! string dns_server, id 6 std::vector m_dns_server; //! string syslog_host, id 7 @@ -4406,36 +4380,22 @@ class NodeConfig : public Message uint16_t m_udp_ctrl_port = 12719; //! bool lightctrl, id 38 bool m_lightctrl = 0; - #ifdef CONFIG_ONEWIRE //! OwDeviceConfig owdevices, id 50 std::vector m_owdevices; - #endif // CONFIG_ONEWIRE - #ifdef CONFIG_APP_PARAMS //! AppParam app_params, id 40 std::vector m_app_params; - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS //! ThresholdConfig thresholds, id 41 std::vector m_thresholds; - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_STATEMACHINES //! StateMachineConfig statemachs, id 33 std::vector m_statemachs; - #endif // CONFIG_STATEMACHINES //! EventTimer timefuses, id 30 std::vector m_timefuses; - #ifdef CONFIG_HTTP //! FtpHttpConfig httpd, id 25 FtpHttpConfig m_httpd; - #endif // CONFIG_HTTP - #ifdef CONFIG_FTP //! FtpHttpConfig ftpd, id 24 FtpHttpConfig m_ftpd; - #endif // CONFIG_FTP - #ifdef CONFIG_TERMSERV //! TerminalConfig terminal, id 21 std::vector m_terminal; - #endif // CONFIG_TERMSERV //! UartSettings uart, id 20 std::vector m_uart; //! Trigger triggers, id 19 @@ -4444,14 +4404,10 @@ class NodeConfig : public Message std::vector m_at_actions; //! Date holidays, id 16 std::vector m_holidays; - #ifdef CONFIG_INFLUX //! Influx influx, id 12 Influx m_influx; - #endif // CONFIG_INFLUX - #ifdef CONFIG_MQTT //! MQTT mqtt, id 10 MQTT m_mqtt; - #endif // CONFIG_MQTT //! WifiConfig softap, id 5 WifiConfig m_softap; //! WifiConfig station, id 4 @@ -7798,7 +7754,6 @@ inline void NodeConfig::set_timezone(const std::string &v) -#ifdef CONFIG_MQTT inline const MQTT &NodeConfig::mqtt() const { return m_mqtt; @@ -7840,7 +7795,6 @@ inline void NodeConfig::set_mqtt(const MQTT &v) p_validbits |= ((uint32_t)1U << 4); } -#endif // CONFIG_MQTT inline uint16_t NodeConfig::dmesg_size() const @@ -7880,7 +7834,6 @@ inline void NodeConfig::set_dmesg_size(uint16_t v) -#ifdef CONFIG_INFLUX inline const Influx &NodeConfig::influx() const { return m_influx; @@ -7922,7 +7875,6 @@ inline void NodeConfig::set_influx(const Influx &v) p_validbits |= ((uint32_t)1U << 6); } -#endif // CONFIG_INFLUX inline uint64_t NodeConfig::station2ap_time() const @@ -8240,7 +8192,6 @@ inline size_t NodeConfig::uart_size() const -#ifdef CONFIG_TERMSERV inline const TerminalConfig &NodeConfig::terminal(unsigned x) const { return m_terminal[x]; @@ -8289,7 +8240,6 @@ inline size_t NodeConfig::terminal_size() const return m_terminal.size(); } -#endif // CONFIG_TERMSERV inline uint16_t NodeConfig::udp_ctrl_port() const @@ -8383,7 +8333,6 @@ inline size_t NodeConfig::debugs_size() const -#ifdef CONFIG_FTP inline const FtpHttpConfig &NodeConfig::ftpd() const { return m_ftpd; @@ -8425,10 +8374,8 @@ inline void NodeConfig::set_ftpd(const FtpHttpConfig &v) p_validbits |= ((uint32_t)1U << 10); } -#endif // CONFIG_FTP -#ifdef CONFIG_HTTP inline const FtpHttpConfig &NodeConfig::httpd() const { return m_httpd; @@ -8470,7 +8417,6 @@ inline void NodeConfig::set_httpd(const FtpHttpConfig &v) p_validbits |= ((uint32_t)1U << 11); } -#endif // CONFIG_HTTP inline const std::string &NodeConfig::otasrv() const @@ -8564,7 +8510,6 @@ inline size_t NodeConfig::timefuses_size() const -#ifdef CONFIG_STATEMACHINES inline const StateMachineConfig &NodeConfig::statemachs(unsigned x) const { return m_statemachs[x]; @@ -8613,7 +8558,6 @@ inline size_t NodeConfig::statemachs_size() const return m_statemachs.size(); } -#endif // CONFIG_STATEMACHINES inline uint64_t NodeConfig::max_on_time() const @@ -8809,7 +8753,6 @@ inline void NodeConfig::set_pwm_freq(uint64_t v) -#ifdef CONFIG_APP_PARAMS inline const AppParam &NodeConfig::app_params(unsigned x) const { return m_app_params[x]; @@ -8858,10 +8801,8 @@ inline size_t NodeConfig::app_params_size() const return m_app_params.size(); } -#endif // CONFIG_APP_PARAMS -#ifdef CONFIG_THRESHOLDS inline const ThresholdConfig &NodeConfig::thresholds(unsigned x) const { return m_thresholds[x]; @@ -8910,10 +8851,8 @@ inline size_t NodeConfig::thresholds_size() const return m_thresholds.size(); } -#endif // CONFIG_THRESHOLDS -#ifdef CONFIG_LUA inline const std::string &NodeConfig::luafiles(unsigned x) const { return m_luafiles[x]; @@ -8966,10 +8905,8 @@ inline size_t NodeConfig::luafiles_size() const return m_luafiles.size(); } -#endif // CONFIG_LUA -#ifdef CONFIG_ONEWIRE inline const OwDeviceConfig &NodeConfig::owdevices(unsigned x) const { return m_owdevices[x]; @@ -9018,7 +8955,6 @@ inline size_t NodeConfig::owdevices_size() const return m_owdevices.size(); } -#endif // CONFIG_ONEWIRE #endif diff --git a/components/wfc/wfccore_esp32.cpp b/components/wfc/wfccore_esp32.cpp index 0a20aa1..5afd1f0 100644 --- a/components/wfc/wfccore_esp32.cpp +++ b/components/wfc/wfccore_esp32.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -92,7 +93,7 @@ * asserts, comments, genlib, gnux */ -#include "wfccore.h" +#include "wfccore_esp32.h" #include #include diff --git a/components/wfc/wfccore_esp32.h b/components/wfc/wfccore_esp32.h index 3bb2fba..eba5016 100644 --- a/components/wfc/wfccore_esp32.h +++ b/components/wfc/wfccore_esp32.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,6 +59,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -108,8 +109,8 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#ifndef _WFCCORE_H -#define _WFCCORE_H +#ifndef _WFCCORE_ESP32_H +#define _WFCCORE_ESP32_H #include diff --git a/components/wfc/wfccore_esp8266.cpp b/components/wfc/wfccore_esp8266.cpp index bab7969..c508af5 100644 --- a/components/wfc/wfccore_esp8266.cpp +++ b/components/wfc/wfccore_esp8266.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -92,7 +93,7 @@ * asserts, comments, genlib, gnux */ -#include "wfccore.h" +#include "wfccore_esp8266.h" #include #include diff --git a/components/wfc/wfccore_esp8266.h b/components/wfc/wfccore_esp8266.h index b4c218c..557d850 100644 --- a/components/wfc/wfccore_esp8266.h +++ b/components/wfc/wfccore_esp8266.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -108,8 +109,8 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#ifndef _WFCCORE_H -#define _WFCCORE_H +#ifndef _WFCCORE_ESP8266_H +#define _WFCCORE_ESP8266_H #include diff --git a/components/wfc/wfccore_esp8285.cpp b/components/wfc/wfccore_esp8285.cpp index d4af54b..becf1cd 100644 --- a/components/wfc/wfccore_esp8285.cpp +++ b/components/wfc/wfccore_esp8285.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -94,7 +95,7 @@ * asserts, comments, genlib, gnux */ -#include "wfccore.h" +#include "wfccore_esp8285.h" #include #include diff --git a/components/wfc/wfccore_esp8285.h b/components/wfc/wfccore_esp8285.h index 846c3e3..f6b4d66 100644 --- a/components/wfc/wfccore_esp8285.h +++ b/components/wfc/wfccore_esp8285.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ * ascii_string : "ascii_string" * author : "" * calcSize : "calcSize" + * cfgdefs : "" * ClearName : "clear" * ClearPrefix : "clear_" * copyright : "" @@ -109,8 +110,8 @@ #define ON_ERROR_CANCEL 1 #define HAVE_ENUM_NAMES 1 -#ifndef _WFCCORE_H -#define _WFCCORE_H +#ifndef _WFCCORE_ESP8285_H +#define _WFCCORE_ESP8285_H #include diff --git a/components/wfc/wfccore_pc.cpp b/components/wfc/wfccore_pc.cpp index 5d016ce..0923913 100644 --- a/components/wfc/wfccore_pc.cpp +++ b/components/wfc/wfccore_pc.cpp @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ * wfclib : "extern" * * options from pc: + * cfgdefs : "all" * Optimize : "speed" * toASCII : "toASCII" * toSink : "" @@ -88,7 +89,7 @@ * asserts, comments, genlib, gnux, withEqual, withUnequal */ -#include "wfccore.h" +#include "wfccore_pc.h" #include #include diff --git a/components/wfc/wfccore_pc.h b/components/wfc/wfccore_pc.h index 0ebea6d..99c1368 100644 --- a/components/wfc/wfccore_pc.h +++ b/components/wfc/wfccore_pc.h @@ -1,7 +1,7 @@ /**************************************************************************** * * Code generated by Wire-Format-Compiler (WFC) - * WFC Version: P2304.3 (hg:459/5fefa02bc543) + * WFC Version: P2304.4 (hg:460/3a4ad1ac493b) * WFC is Copyright 2015-2023, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-11-26, 14:29:43 (CET). + * Code generated on 2023-12-23, 20:23:21 (CET). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ * wfclib : "extern" * * options from pc: + * cfgdefs : "all" * Optimize : "speed" * toASCII : "toASCII" * toSink : "" @@ -107,8 +108,8 @@ #define HAVE_ENUM_MAP 1 #define HAVE_ENUM_NAMES 1 -#ifndef _WFCCORE_H -#define _WFCCORE_H +#ifndef _WFCCORE_PC_H +#define _WFCCORE_PC_H #include @@ -120,7 +121,6 @@ #include #include /* user requested header files */ -#include "pcconfig.h" #include "support.h" #include #include diff --git a/drv/display/component.mk b/drv/display/component.mk index abefd1e..8c712da 100644 --- a/drv/display/component.mk +++ b/drv/display/component.mk @@ -1,2 +1,2 @@ COMPONENT_ADD_INCLUDEDIRS=. - +COMPONENT_PRIV_INCLUDEDIRS=../../main diff --git a/drv/display/display.cpp b/drv/display/display.cpp index 624f28f..ddfbdc5 100644 --- a/drv/display/display.cpp +++ b/drv/display/display.cpp @@ -19,12 +19,19 @@ #include "display.h" #include "log.h" #include "profiling.h" +#include "romfs.h" +#include #include - +#include +//#include +#include +#include #define TAG MODULE_DISP +using namespace std; + static const uint8_t Circle[] = { 0b1000, @@ -492,6 +499,230 @@ void MatrixDisplay::drawBitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, c } +static int32_t grayScale(int32_t col, uint8_t a) +{ + if (a == 0) + return 0; + if (a == 0xff) + return col; + uint8_t r = col & 0xff, g = (col >> 8) & 0xff, b = (col >> 16) & 0xff; + while ((a & 0x80) == 0) { + r >>= 1; + g >>= 1; + b >>= 1; + a <<= 1; + } + return (b << 16) | (g << 8) | r; +} + + +void MatrixDisplay::drawPgm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg) +{ + log_dbug(TAG,"draw pgm %ux%u@%u,%u",w,h,x0,y); + uint16_t ye = y+h, xe = x0+w; + while (y < ye) { + for (uint16_t x = x0; x < xe; ++x) { + uint8_t g = *data; + if (0xff == g) + setPixel(x,y,fg); + else if (g) + setPixel(x,y,grayScale(fg,g)); + ++data; + } + ++y; + } +} + + +void MatrixDisplay::drawPbm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg) +{ + log_dbug(TAG,"draw pbm %ux%u@%u,%u",w,h,x0,y); + uint8_t byte = *data; + unsigned off = 0; + uint16_t ye = y+h; + while (y < ye) { + for (uint16_t x = x0; x < x0+w; ++x) { + if (byte&0x80) + setPixel(x,y,fg); + byte <<= 1; + ++off; + if ((off & 7) == 0) { + ++data; + byte = *data; + } + } + if (off&7) { + ++data; + byte = *data; + off = 0; + } + ++y; + } + //drawBitmap(x0,y,w,h,data,fg,-1); +} + + +void MatrixDisplay::drawPpm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data) +{ + log_dbug(TAG,"draw ppm %ux%u@%u,%u",w,h,x0,y); + uint16_t ye = y+h; + while (y < ye) { + for (uint16_t x = x0; x < x0+w; ++x) { + uint32_t col = *data++; + col |= (*data++) << 8; + col |= (*data++) << 16; + setPixel(x,y,rgb24_to_native(col)); + } + ++y; + } +} + + +// OLED bitmap with 8 bit vertical, arranged horizontal +void MatrixDisplay::drawObm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg) +{ + uint8_t byte = *data; + unsigned off = 0; + uint16_t ye = y+h; + while (y < ye) { + for (uint16_t x = x0; x < x0+w; ++x) { + if (byte&1) + setPixel(x,y,fg); + byte >>= 1; + ++off; + if ((off & 7) == 0) + byte = *data++; + } + y += 8; + } +} + + +void MatrixDisplay::drawIcon(uint16_t x0, uint16_t y0, const char *fn, int32_t fg) +{ + if (Image *i = openIcon(fn)) { + log_dbug(TAG,"draw icon %s",fn); + switch (i->type) { + case img_pbm: + drawPbm(x0,y0,i->w,i->h,i->data,fg); + break; + case img_pgm: + drawPgm(x0,y0,i->w,i->h,i->data,fg); + break; + case img_ppm: + drawPpm(x0,y0,i->w,i->h,i->data); + break; + case img_obm: + drawObm(x0,y0,i->w,i->h,i->data,fg); + break; + default: + return; + } + } else { + log_warn(TAG,"failed to open icon %s",fn); + } +} + + +Image *MatrixDisplay::importImage(const char *fn, uint8_t *data, size_t s) +{ + if (data[0] == 'P') { + unsigned typ, w, h, n0, depth = 0, n1 = 0; + int c = sscanf((char*)data+1,"%u%u%u%n%u%n",&typ,&w,&h,&n0,&depth,&n1); + if (3 > c) { + log_warn(TAG,"invalid format of %s",fn); + return 0; + } + Image i; + i.w = w; + i.h = h; + if (typ == 4) { + log_dbug(TAG,"%s is PBM",fn); + if ((w*h) > ((s-2-n0)<<3)) { + log_warn(TAG,"data in %s is truncated",fn); + return 0; + } + i.data = data+n0+2; + i.type = img_pbm; + } else if (typ == 9) { + log_dbug(TAG,"%s is OBM",fn); + i.data = data+2+n0; + i.type = img_obm; + } else if (4 > c) { + log_warn(TAG,"invalid format of %s",fn); + return 0; + } else if (typ == 5) { + if (depth != 255) { + log_warn(TAG,"unsupported color depth"); + return 0; + } + if (w*h > s-2-n1) { + log_warn(TAG,"data in %s is truncated",fn); + return 0; + } + i.data = data+s-(w*h); + log_dbug(TAG,"%s is PGM",fn); + i.type = img_pgm; + } else if (typ == 6) { + if (depth != 255) { + log_warn(TAG,"unsupported color depth"); + return 0; + } + if (w*h*3 > s-2-n1) { + log_warn(TAG,"data in %s is truncated",fn); + return 0; + } + i.data = data+s-(w*h*3); + log_dbug(TAG,"%s is PPM",fn); + i.type = img_ppm; + } else { + log_warn(TAG,"unsupported format of %s",fn); + return 0; + } + auto x = m_images.insert(make_pair(strdup(fn),i)); + return &x.first->second; + } + return 0; +} + + +Image *MatrixDisplay::openIcon(const char *fn) +{ + auto x = m_images.find(fn); + if (x != m_images.end()) + return &x->second; +#if defined CONFIG_ROMFS && defined ESP32 + int rfd = romfs_open(fn); + if (rfd != -1) { + if (uint8_t *data = (uint8_t *) romfs_mmap(rfd)) + return importImage(fn,data,romfs_size_fd(rfd)); + } +#endif + int fd = open(fn,O_RDONLY); + if (fd == -1) { + log_warn(TAG,"unable to open %s",fn); + return 0; + } + struct stat st; + if (-1 == fstat(fd,&st)) { + log_warn(TAG,"failed to stat %s",fn); + return 0; + } + if (uint8_t *data = (uint8_t *) malloc(st.st_size)) { + int n = read(fd,data,st.st_size); + if (n == st.st_size) { + close(fd); + return importImage(fn,data,st.st_size); + } + log_warn(TAG,"failed to read %s",fn); + } else { + log_warn(TAG,"unable alloc for %s",fn); + } + close(fd); + return 0; +} + + uint8_t charToGlyph(char c) { switch ((unsigned char) c) { diff --git a/drv/display/display.h b/drv/display/display.h index ad190c9..63e37ee 100644 --- a/drv/display/display.h +++ b/drv/display/display.h @@ -21,6 +21,8 @@ #include "ledcluster.h" #include "fonts.h" +#include "support.h" +#include class MatrixDisplay; class SegmentDisplay; @@ -38,6 +40,22 @@ typedef enum colorspace_e #define COLOR_DEFAULT -1 #define COLOR_NONE -2 +typedef enum image_e +{ + img_invalid = 0, + img_pgm, // portable graymap + img_pbm, // portable bitmap + img_ppm, // portable bixmap + img_obm, // oled bitmap +} image_t; + +struct Image +{ + uint16_t w,h; + uint8_t *data; + image_t type; +}; + uint8_t charToGlyph(char c); color_t color_get(const char *); @@ -206,6 +224,7 @@ struct MatrixDisplay : public TextDisplay virtual void drawVLine(uint16_t x0, uint16_t y0, uint16_t len, int32_t col = -1); virtual unsigned drawText(uint16_t x, uint16_t y, const char *txt, int n = -1, int32_t fg = -1, int32_t bg = -1); virtual unsigned drawChar(uint16_t x, uint16_t y, char c, int32_t fg, int32_t bg); + virtual void drawIcon(uint16_t x0, uint16_t y0, const char *fn, int32_t fg); unsigned textWidth(const char *, int font = -1); @@ -237,12 +256,21 @@ struct MatrixDisplay : public TextDisplay void clear() override; void write(const char *txt, int n = -1) override; + virtual int32_t rgb24_to_native(uint32_t rgb) const + { return rgb; } + #if 0 // TODO void setClipping(uint16_t xl, uint16_t xh, uint16_t yl, uint16_t yh) { m_clxl = xl; m_clxh = xh; m_clyl = yl; m_clyh = yh; } #endif protected: + Image *openIcon(const char *fn); + virtual void drawPbm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg); + virtual void drawPgm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg); + virtual void drawPpm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data); + virtual void drawObm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg); + Image *importImage(const char *fn, uint8_t *data, size_t s); // int writeChar(uint16_t x, uint16_t y, char c); #if 0 // TODO @@ -250,6 +278,7 @@ struct MatrixDisplay : public TextDisplay uint16_t m_clxl = 0, m_clxh = 0xffff, m_clyl = 0, m_clyh = 0xffff; #endif Font *m_font = 0; + std::map m_images; colorspace_t m_colorspace; int32_t m_colfg, m_colbg; }; diff --git a/drv/display/fonts.c b/drv/display/fonts.c index 215ea79..107f214 100644 --- a/drv/display/fonts.c +++ b/drv/display/fonts.c @@ -5992,7 +5992,7 @@ const GFXglyph SansLight16Glyphs[] = { { 975, 2, 17, 10, 4, 0 }, // '|' { 980, 6, 15, 7, 1, 1 }, // '}' { 992, 8, 2, 10, 0, 6 }, // '~' - { 994, 8, 4, 8, 2, 0 }, // '' + { 994, 8, 4, 8, 0, 0 }, // '' }; const uint8_t SansLight16_BCM[] = { @@ -6355,7 +6355,7 @@ const uint8_t SansLight16_BCM[] = { // '~' (0x7e) 8x2, offset 992-994, at +0/-7 0x56, 0x6a, - // '' (0x7f) 8x4, offset 994-998, at +2/-13 + // '' (0x7f) 8x4, offset 994-998, at +0/-13 0x00, 0x96, 0x69, 0x00, }; @@ -6719,7 +6719,7 @@ const uint8_t SansLight16_RM[] = { // '~' (0x7e) 8x2, offset 992-994, at +0/-7 0x71, 0x8e, - // '' (0x7f) 8x4, offset 994-998, at +2/-13 + // '' (0x7f) 8x4, offset 994-998, at +0/-13 0x18, 0x24, 0x24, 0x18, }; diff --git a/drv/display/opensanslight-16.h b/drv/display/opensanslight-16.h index 2212ee2..6c8a81f 100644 --- a/drv/display/opensanslight-16.h +++ b/drv/display/opensanslight-16.h @@ -200,7 +200,7 @@ const GFXglyph SansLight16Glyphs[] = { { 975, 2, 17, 10, 4, -13 }, // '|' { 980, 6, 15, 7, 1, -12 }, // '}' { 992, 8, 2, 10, 0, -7 }, // ~ - { 994, 8, 4, 8, 2, -13 }, // degree + { 994, 8, 4, 8, 0, -13 }, // degree }; GFXfont SansLight16 = {"SansLight16", diff --git a/drv/display/ssd130x.cpp b/drv/display/ssd130x.cpp index 9fa4b6b..28f90c6 100644 --- a/drv/display/ssd130x.cpp +++ b/drv/display/ssd130x.cpp @@ -264,111 +264,6 @@ int SSD130X::drawByte(uint8_t x, uint8_t y, uint8_t b) } -#if 0 -void SSD130X::drawChar(char c) -{ - if (c == '\r') { - m_posx = 0; - } else if (c == '\n') { - m_posx = 0; - m_posy += fontHeight(); - } else { - m_posx += drawChar(m_posx, m_posy, c, 1, 0); - } -} - - -unsigned SSD130X::drawChar(uint16_t x, uint16_t y, char c, int32_t fg, int32_t bg) -{ - PROFILE_FUNCTION(); - switch ((unsigned char) c) { - case '\r': -// m_posx = 0; - return 0; - case '\n': -// m_posx = 0; -// m_posy += fontHeight(); - return 0; - case 0xb0: //176: // '°' - c = 127; - break; - case 196: // 'Ä' - c = 129; - break; - case 220: // 'Ü' - c = 128; - break; - case 214: // 'Ö' - c = 133; - break; - case 223: // 'ß' - c = 134; - break; - case 228: // 'ä' - c = 128; - break; - case 246: // 'ö' - c = 130; - break; - case 252: // 'ü' - c = 132; - break; - default: - break; - } - /* - if (m_font == -1) { - if (c < 32) - return 1; - uint16_t idx = (c - 32)*6; - if (idx >= SizeofFont6x8) - return 1; - for (int c = 0; c < 6; ++c) - drawByte(x++, m_posy, Font6x8[idx+c]); - return 6; - } else if (m_font == -2) { - if (c < 32) - return 1; - uint16_t idx = (c - 32)*6; - if (idx >= SizeofFont6x8) - return 1; - for (int c = 0; c < 6; ++c) { - uint16_t w = scaleDouble(Font6x8[idx+c]); - drawByte(x, m_posy, w & 0xff); - drawByte(x, m_posy+8, w >> 8); - ++x; - drawByte(x, m_posy, w & 0xff); - drawByte(x, m_posy+8, w >> 8); - ++x; - } - return 12; - } - const Font *font = Fonts+(int)m_font; - if ((font < Fonts) || (font >= Fonts+(int)font_numfonts)) { - log_dbug(TAG,"invalid font"); - return 1; - } - */ - if ((c < m_font->first) || (c > m_font->last)) { - log_dbug(TAG,"undefined char"); - return 1; - } - uint8_t ch = c - m_font->first; - const uint8_t *off = m_font->BCMbitmap + m_font->glyph[ch].bitmapOffset; - uint8_t w = m_font->glyph[ch].width; - uint8_t h = m_font->glyph[ch].height; - int8_t dx = m_font->glyph[ch].xOffset; - int8_t dy = m_font->glyph[ch].yOffset; - uint16_t a = m_font->glyph[ch].xAdvance; - log_dbug(TAG,"drawChar(%u,%u,'%c') with %ux%u",x,y,c,w,h); -// log_info(TAG,"%d/%d %+d/%+d, adv %u len %u",(int)w,(int)h,(int)dx,(int)dy,a,l); - clearRect(x,y,a,m_font->yAdvance); - drawBitmapNative(x+dx,y+dy,w,h,off); - return a; -} -#endif - - unsigned SSD130X::drawChar(uint16_t x, uint16_t y, char c, int32_t fg, int32_t bg) { PROFILE_FUNCTION(); @@ -387,7 +282,7 @@ unsigned SSD130X::drawChar(uint16_t x, uint16_t y, char c, int32_t fg, int32_t b int8_t dy = m_font->glyph[ch].yOffset; uint8_t a = m_font->glyph[ch].xAdvance; log_dbug(TAG,"drawChar(%d,%d,'%c',%d,%d) = %u",x,y,c,fg,bg,a); -// log_info(TAG,"%d/%d %+d/%+d, adv %u char '%c'",(int)w,(int)h,(int)dx,(int)dy,a,c); +// log_dbug(TAG,"%d/%d %+d/%+d, adv %u char '%c'",(int)w,(int)h,(int)dx,(int)dy,a,c); if (bg != -2) fillRect(x,y,a,m_font->yAdvance,bg); drawBitmap(x+dx,y+dy,w,h,data,fg,bg); @@ -498,11 +393,14 @@ void SSD130X::drawBitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const u uint16_t b0 = (uint16_t)byte << shl; m_disp[off] |= (uint8_t)(b0&0xff); uint8_t b1 = (uint8_t)(b0 >> 8); - if (b1) + if (b1) { m_disp[off+m_width] |= b1; + ++pg; + m_dirty |= 1<add(m_temp); - root->add(m_press); + root->add(&m_temp); + root->add(&m_press); cyclic_add_task(m_name,BMP280::cyclic,this,0); action_add(concat(m_name,"!sample"),trigger,(void*)this,"BMP280 sample data"); } @@ -141,7 +141,7 @@ void BMP280::attach(EnvObject *root) void BME280::attach(EnvObject *root) { BMP280::attach(root); - root->add(m_humid); + root->add(&m_humid); } @@ -254,14 +254,14 @@ const char *BME280::exeCmd(Terminal &term, int argc, const char **args) void BMP280::handle_error() { - m_temp->set(NAN); - m_press->set(NAN); + m_temp.set(NAN); + m_press.set(NAN); } void BME280::handle_error() { - m_humid->set(NAN); + m_humid.set(NAN); BMP280::handle_error(); } @@ -324,7 +324,7 @@ float BMP280::calc_press(int32_t adc_P, int32_t t_fine) var1 = ((var1 * var1 * (int64_t)P3)>>8) + ((var1 * (int64_t)P2)<<12); var1 = (((((int64_t)1)<<47)+var1))*((int64_t)P1)>>33; if (var1 == 0) { - m_press = 0; + m_press.set(NAN); log_dbug(TAG,"press: div by 0"); return NAN; // avoid exception caused by division by zero } @@ -374,8 +374,8 @@ int BMP280::read() int32_t t_fine = calc_tfine(data); float t = (float)((t_fine * 5 + 128) >> 8) / 100.0; float p = calc_press((data[0] << 12) | (data[1] << 4) | (data[2] >> 4), t_fine); - m_temp->set(t); - m_press->set(p); + m_temp.set(t); + m_press.set(p); #ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO log_dbug(TAG,"t=%G, p=%G",t,p); #else @@ -411,11 +411,11 @@ int BME280::read() return r; int32_t t_fine = calc_tfine(data); float t = (float)((t_fine * 5 + 128) >> 8) / 100.0; - m_temp->set(t); + m_temp.set(t); float p = calc_press((data[0] << 12) | (data[1] << 4) | (data[2] >> 4), t_fine); - m_press->set(p); + m_press.set(p); float h = calc_humid((data[6] << 8) | data[7], t_fine); - m_humid->set(h); + m_humid.set(h); #ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO log_dbug(TAG,"t=%G, p=%G, h=%G",t,p,h); #else @@ -496,12 +496,17 @@ int BME280::init() #ifdef CONFIG_BME680 +BME680::BME680(uint8_t port, uint8_t addr) +: I2CDevice(port,addr,drvName()) +, m_temp("temperature","\u00b0C","%41f") +, m_press("pressure","hPa","%4.1f") +, m_humid("humidity","%","%4.1f") +, m_gas("gasresistance","kOhm","%4.1f") +{ } + + int BME680::init() { - m_temp = new EnvNumber("temperature","\u00b0C","%4.1f"); - m_press = new EnvNumber("pressure","hPa","%4.1f"); - m_humid = new EnvNumber("humidity","%","%4.1f"); - m_gas = new EnvNumber("gasresistance","kOhm","%4.1f"); bzero(&m_dev,sizeof(m_dev)); m_dev.bus = m_bus; m_dev.addr = m_addr; @@ -531,10 +536,10 @@ unsigned BME680::cyclic(void *arg) case st_read: return dev->read(); case st_error: - dev->m_temp->set(NAN); - dev->m_press->set(NAN); - dev->m_humid->set(NAN); - dev->m_gas->set(NAN); + dev->m_temp.set(NAN); + dev->m_press.set(NAN); + dev->m_humid.set(NAN); + dev->m_gas.set(NAN); dev->m_state = st_idle; return 1000; default: @@ -564,10 +569,6 @@ unsigned BME680::sample() unsigned BME680::read() { - if (m_temp == 0) { - log_dbug(TAG,"read on non-attached device"); - return 50; - } uint8_t status = 0; int r = i2c_w1rd(m_bus,m_addr,0x1d,&status,1); if (r != 0) { @@ -585,32 +586,32 @@ unsigned BME680::read() return 20; } #ifdef BME680_FLOAT_POINT_COMPENSATION - m_temp->set(data.temperature); - m_press->set(data.pressure); - m_humid->set(data.humidity); + m_temp.set(data.temperature); + m_press.set(data.pressure); + m_humid.set(data.humidity); #else - m_temp->set((float)data.temperature/100.0); - m_press->set((float)data.pressure/100.0); - m_humid->set((float)data.humidity/1000.0); + m_temp.set((float)data.temperature/100.0); + m_press.set((float)data.pressure/100.0); + m_humid.set((float)data.humidity/1000.0); #endif #ifdef CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO - log_dbug(TAG,"t=%G, p=%G, h=%G",m_temp->get(),m_press->get(),m_humid->get()); + log_dbug(TAG,"t=%G, p=%G, h=%G",m_temp.get(),m_press.get(),m_humid.get()); #else if (log_module_enabled(TAG)) { char t[8],p[8],h[8]; - float_to_str(t,m_temp->get()); - float_to_str(p,m_press->get()); - float_to_str(h,m_humid->get()); + float_to_str(t,m_temp.get()); + float_to_str(p,m_press.get()); + float_to_str(h,m_humid.get()); log_dbug(TAG,"t=%s,p=%s,h=%s",t,p,h); } #endif m_state = st_idle; if (data.status & BME680_GASM_VALID_MSK) { log_dbug(TAG,"r=%d", data.gas_resistance); - m_gas->set((float)data.gas_resistance/1000.0); + m_gas.set((float)data.gas_resistance/1000.0); } else { log_dbug(TAG,"gas invalid"); - m_gas->set(NAN); + m_gas.set(NAN); } return 50; } @@ -618,10 +619,10 @@ unsigned BME680::read() void BME680::attach(EnvObject *root) { - root->add(m_temp); - root->add(m_press); - root->add(m_humid); - root->add(m_gas); + root->add(&m_temp); + root->add(&m_press); + root->add(&m_humid); + root->add(&m_gas); cyclic_add_task(m_name,cyclic,this,0); action_add(concat(m_name,"!sample"),trigger,(void*)this,"BME680 sample data"); } diff --git a/drv/i2c/bmx.h b/drv/i2c/bmx.h index deaf47b..009d234 100644 --- a/drv/i2c/bmx.h +++ b/drv/i2c/bmx.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022, Thomas Maier-Komor + * Copyright (C) 2018-2023, Thomas Maier-Komor * Atrium Firmware Package for ESP * * This program is free software: you can redistribute it and/or modify @@ -19,10 +19,9 @@ #ifndef BMXDRV_H #define BMXDRV_H -#include "i2cdrv.h" #include "bme680.h" - -class EnvNumber; +#include "env.h" +#include "i2cdrv.h" struct BMP280 : public I2CDevice @@ -48,7 +47,7 @@ struct BMP280 : public I2CDevice virtual void handle_error(); static unsigned cyclic(void *); - EnvNumber *m_temp = 0, *m_press = 0; + EnvNumber m_temp, m_press; uint16_t T1 = 0; int16_t T2 = 0, T3 = 0; uint16_t P1 = 0; @@ -86,7 +85,7 @@ struct BME280 : public BMP280 int read(); void handle_error(); - EnvNumber *m_humid = 0; + EnvNumber m_humid; int16_t H2 = 0, H4 = 0, H5 = 0; int8_t H3 = 0, H6 = 0; }; @@ -94,9 +93,7 @@ struct BME280 : public BMP280 struct BME680 : public I2CDevice { - BME680(uint8_t port, uint8_t addr) - : I2CDevice(port,addr,drvName()) - { } + BME680(uint8_t port, uint8_t addr); const char *drvName() const { return "bme680"; } @@ -110,7 +107,7 @@ struct BME680 : public I2CDevice static unsigned cyclic(void *); static void trigger(void *); - EnvNumber *m_temp = 0, *m_press = 0, *m_humid = 0, *m_gas = 0; + EnvNumber m_temp, m_press, m_humid, m_gas; bme680_dev m_dev; typedef enum { st_idle, st_sample, st_read, st_error } state_t; state_t m_state = st_idle; diff --git a/drv/i2c/ssd1306.cpp b/drv/i2c/ssd1306.cpp index e7f84b8..d9fcb9b 100644 --- a/drv/i2c/ssd1306.cpp +++ b/drv/i2c/ssd1306.cpp @@ -170,187 +170,6 @@ void SSD1306::flush() } -int SSD1306::readByte(uint8_t x, uint8_t y, uint8_t *b) -{ - if ((x >= m_width) || (y >= m_height)) { - log_dbug(TAG,"off display %u,%u",x,y); - return 1; - } - uint8_t shift = y & 7; - uint8_t pg = y >> 3; - uint16_t idx = pg * m_width + x; - uint8_t b0 = m_disp[idx]; - if (shift) { - b0 >>= shift; - idx += m_width; - if (idx < (m_width*m_height)) { - uint8_t b1 = m_disp[idx]; - b1 <<= (8-shift); - b0 |= b1; - } - } - *b = b0; - return 0; -} - - -int SSD1306::drawMasked(uint8_t x, uint8_t y, uint8_t b, uint8_t m) -{ - uint8_t o; - if (readByte(x,y,&o)) - return 1; - o &= ~m; - o |= (b & m); - return drawByte(x,y,o); -} - - -/* -static uint16_t scaleDouble(uint8_t byte) -{ - uint16_t r = 0; - uint16_t m = 1; - for (uint8_t b = 0; b < 8; ++b) { - if (byte & (1<> 3; - unsigned off = pg * m_width + x; - uint8_t shl = y & 7; - uint16_t b0 = (uint16_t)b << shl; - uint8_t b1 = (uint8_t)(b0 >> 8); - if (b1) - m_disp[off+m_width] |= b1; - m_disp[off] |= (uint8_t)(b0&0xff); -// log_dbug(TAG,"drawBits %x at %u",b0,off); - return 0; -} - - -int SSD1306::drawByte(uint8_t x, uint8_t y, uint8_t b) -{ - uint8_t pg = y >> 3; - uint16_t idx = pg * m_width + x; - if ((x >= m_width) || (y >= m_height)) { - log_dbug(TAG,"off display %u,%u=%u pg=%u",(unsigned)x,(unsigned)y,(unsigned)idx,(unsigned)pg); - return 1; - } - uint8_t shift = y & 7; - if (shift != 0) { - uint16_t idx2 = idx + m_width; - if (idx2 >= (m_width*m_height)) - return 1; - m_dirty |= 1<<(pg+1); - uint16_t w = (uint16_t) b << shift; - uint16_t m = 0xff << shift; - m = ~m; - uint8_t b0 = (m_disp[idx] & m) | (w & 0xFF); - if (b0 != m_disp[idx]) { - m_disp[idx] = b0; - m_dirty |= 1<> 8)) | (w >> 8); - idx = idx2; - } - if (m_disp[idx] != b) { - m_dirty |= 1<> 3; - uint8_t byte = data[b]; - unsigned bitst = off & 7; - uint8_t got = 8-bitst; - byte >>= bitst; - if (got < numb) - byte |= data[b+1] << got; -// log_dbug(TAG,"getBits(%u,%u): %x",off,numb,byte); - return byte; -} - - -void SSD1306::drawBitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *data, int32_t fg, int32_t bg) -{ - static const uint8_t masks[] = {0x1,0x3,0x7,0xf,0x1f,0x3f,0x7f}; - unsigned len = w*h; - uint16_t bitoff = 0; - log_dbug(TAG,"SSD1306::drawBitmap(%u,%u,%u,%u) %u/%u",x,y,w,h,len,len/8); - for (uint8_t x0 = x; x0 < x+w; ++x0) { - uint8_t yoff = y; - uint8_t numb = h; - while (numb) { -// log_dbug(TAG,"numb=%u",numb); - uint8_t byte = getBits(data,bitoff,numb); - if (numb >= 8) { -// log_dbug(TAG,"byte %x at %u/%u",byte,x0,y+yoff); - if (byte) - drawByte(x0,yoff,byte); - numb -= 8; - yoff += 8; - bitoff += 8; - } else { - byte &= masks[numb-1]; - if (byte) { -// drawBits(x0,yoff,byte,numb); - uint8_t pg = yoff >> 3; - unsigned off = pg * m_width + x0; - uint8_t shl = yoff & 7; - uint16_t b0 = (uint16_t)byte << shl; - m_disp[off] |= (uint8_t)(b0&0xff); - uint8_t b1 = (uint8_t)(b0 >> 8); - if (b1) - m_disp[off+m_width] |= b1; - } - bitoff += numb; - break; - } - } - } -// return 0; -} - - - SSD1306 *SSD1306::create(uint8_t bus, uint8_t addr) { addr <<= 1; diff --git a/drv/i2c/ssd1306.h b/drv/i2c/ssd1306.h index 433e811..522cd49 100644 --- a/drv/i2c/ssd1306.h +++ b/drv/i2c/ssd1306.h @@ -35,7 +35,7 @@ class SSD1306 : public SSD130X, public I2CDevice static SSD1306 *create(uint8_t bus, uint8_t addr); int init(uint8_t maxx, uint8_t maxy, uint8_t options); - void drawBitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *data, int32_t fg, int32_t bg) override; +// void drawBitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *data, int32_t fg, int32_t bg) override; void flush() override; int setBrightness(uint8_t contrast) override; @@ -52,11 +52,11 @@ class SSD1306 : public SSD130X, public I2CDevice { return 255; } private: - int drawByte(uint8_t x, uint8_t y, uint8_t b); - int drawBits(uint8_t x, uint8_t y, uint8_t b, uint8_t n); - int drawChar(char c); - int readByte(uint8_t x, uint8_t y, uint8_t *b); - int drawMasked(uint8_t x, uint8_t y, uint8_t b, uint8_t m); +// int drawByte(uint8_t x, uint8_t y, uint8_t b); +// int drawBits(uint8_t x, uint8_t y, uint8_t b, uint8_t n); +// int drawChar(char c); +// int readByte(uint8_t x, uint8_t y, uint8_t *b); +// int drawMasked(uint8_t x, uint8_t y, uint8_t b, uint8_t m); static SSD1306 *Instance; }; diff --git a/drv/onewire/ds18b20.cpp b/drv/onewire/ds18b20.cpp index 5322544..f724b0a 100644 --- a/drv/onewire/ds18b20.cpp +++ b/drv/onewire/ds18b20.cpp @@ -97,14 +97,15 @@ DS18B20::DS18B20(uint64_t id, const char *name) ready = true; } } - if (!ready) + if (ready) { + action_add(concat(name,"!sample"),sample,this,"trigger DS18B20 convertion/sampling"); + action_add(concat(name,"!setres9b"),set_res9b,this,"set conversion resolution to 9bit"); + action_add(concat(name,"!setres10b"),set_res10b,this,"set conversion resolution to 10bit"); + action_add(concat(name,"!setres11b"),set_res11b,this,"set conversion resolution to 11bit"); + action_add(concat(name,"!setres12b"),set_res12b,this,"set conversion resolution to 12bit"); + } else { log_warn(TAG,"device %s is not ready",name); - action_add(concat(name,"!sample"),sample,this,"trigger DS18B20 convertion/sampling"); - action_add(concat(name,"!setres9b"),set_res9b,this,"set conversion resolution to 9bit"); - action_add(concat(name,"!setres10b"),set_res10b,this,"set conversion resolution to 10bit"); - action_add(concat(name,"!setres11b"),set_res11b,this,"set conversion resolution to 11bit"); - action_add(concat(name,"!setres12b"),set_res12b,this,"set conversion resolution to 12bit"); - cyclic_add_task(name,cyclic,this,0); + } } @@ -178,7 +179,7 @@ void DS18B20::read() if (v != 0x7fff) { reset = false; float f = v; - if (sp[1] & 0x80) + if (sp[1] & 0xf8) f *= -1; f *= 0.0625; if (m_json) @@ -208,6 +209,7 @@ void DS18B20::set_resolution(res_t r) void DS18B20::attach(EnvObject *o) { + cyclic_add_task(m_name,cyclic,this,0); if (m_json == 0) m_json = o->add(m_name,NAN,"\u00b0C"); } diff --git a/drv/onewire/onewire.cpp b/drv/onewire/onewire.cpp index 8b26b32..0c3860e 100644 --- a/drv/onewire/onewire.cpp +++ b/drv/onewire/onewire.cpp @@ -27,7 +27,6 @@ #include #include #include -//#include #include #include diff --git a/drv/relay/relay.cpp b/drv/relay/relay.cpp index 0556572..1638ec9 100644 --- a/drv/relay/relay.cpp +++ b/drv/relay/relay.cpp @@ -59,7 +59,7 @@ static void relay_toggle(void *R) } -Relay::Relay(const char *name, xio_t gpio, uint32_t minitv, bool onlvl) +Relay::Relay(const char *name, xio_t gpio, uint32_t minitv, bool onlvl, bool initv, bool pers) : m_next(Relays) , m_name(name) , m_envon("on",0.0) @@ -78,6 +78,15 @@ Relay::Relay(const char *name, xio_t gpio, uint32_t minitv, bool onlvl) action_add(concat(name,"!off"),relay_turn_off,this,"turn off"); action_add(concat(name,"!toggle"),relay_toggle,this,"toggle relay"); Relays = this; + if (pers) { + initv = nvm_read_u8(m_name,initv); + xio_unhold(m_gpio); + } + m_state = initv; + xio_set_lvl(m_gpio,(m_state^m_onlvl)?xio_lvl_0:xio_lvl_1); + if (pers) { + xio_hold(m_gpio); + } } @@ -91,7 +100,7 @@ void Relay::attach(class EnvObject *root) } -Relay *Relay::create(const char *name, xio_t gpio, uint32_t minitv, bool onlvl) +Relay *Relay::create(const char *name, xio_t gpio, uint32_t minitv, bool onlvl, bool initv, bool pers) { if (0 == Mtx) Mtx = xSemaphoreCreateMutex(); @@ -102,7 +111,7 @@ Relay *Relay::create(const char *name, xio_t gpio, uint32_t minitv, bool onlvl) log_warn(TAG,"config %s at %u failed",name,gpio); return 0; } - Relays = new Relay(name,gpio,minitv,onlvl); + Relays = new Relay(name,gpio,minitv,onlvl,initv,pers); xSemaphoreGive(Mtx); return Relays; } @@ -173,9 +182,14 @@ void Relay::sync() // state=off, onlvl=high, !(s^o) = 0 // state=on, onlvl=low, !(s^o) = 0 // state=off, onlvl=low, !(s^o) = 1 + if (m_persistent) { + xio_unhold(m_gpio); + } xio_set_lvl(m_gpio,(m_state^m_onlvl)?xio_lvl_0:xio_lvl_1); - if (m_persistent) + if (m_persistent) { + xio_hold(m_gpio); nvm_store_u8(m_name,m_state); + } char ltime[40]; localtimestr(ltime); if (m_state) { diff --git a/drv/relay/relay.h b/drv/relay/relay.h index 33cd925..ffe19b0 100644 --- a/drv/relay/relay.h +++ b/drv/relay/relay.h @@ -31,7 +31,7 @@ class Relay { public: - static Relay *create(const char *, xio_t gpio, uint32_t minitv, bool onlvl); + static Relay *create(const char *, xio_t gpio, uint32_t minitv, bool onlvl, bool init, bool pers); void attach(class EnvObject *); void set(bool); @@ -74,7 +74,7 @@ class Relay private: - Relay(const char *, xio_t gpio, uint32_t minitv, bool onlvl); + Relay(const char *, xio_t gpio, uint32_t minitv, bool onlvl, bool init, bool pers); static void timerCallback(TimerHandle_t h); void sync(); @@ -89,7 +89,7 @@ class Relay , m_minitv = 0; // minimum toggle interval xio_t m_gpio; event_t m_onev = 0, m_offev = 0, m_changedev = 0; - bool m_state = false, m_set = false, m_persistent = false, m_onlvl; + uint8_t m_state = 2, m_set = 0, m_persistent = false, m_onlvl; }; #endif diff --git a/drv/spi/ili9341.cpp b/drv/spi/ili9341.cpp index 12c41b7..e2c2eb7 100644 --- a/drv/spi/ili9341.cpp +++ b/drv/spi/ili9341.cpp @@ -556,7 +556,64 @@ void ILI9341::drawBitmap(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const u ++idx; } } +} + + +/* +void ILI9341::drawPgm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg) +{ + uint16_t ye = y+h, xe = x0+w; + while (y < ye) { + for (uint16_t x = x0; x < xe; ++x) { + uint8_t g = *data; + if (0xff == g) + setPixel(x,y,fg); + else if (g) + setPixel(x,y,grayScale(fg,g)); + ++data; + } + ++y; + } +} +*/ + + +int32_t ILI9341::rgb24_to_native(uint32_t rgb) const +{ +// blue : 0xfe00 +// red : 0x00f0 +// green: 0x000f + uint8_t r = rgb >> 20, g = (rgb >> 12) & 0xf, b = (rgb >> 1) & 0x7f; + uint32_t x = (r << 4) | g | (b << 9); +// con_printf("%06x => %04x\n",rgb,x); + return x; +} + +void ILI9341::drawPpm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data) +{ + log_dbug(TAG,"draw ppm %ux%u@%u,%u",w,h,x0,y); + uint16_t ye = y+h; + while (y < ye) { + for (uint16_t x = x0; x < x0+w; ++x) { +#if 0 + uint32_t col = *data << 16; + ++data; + col |= *data << 8; + ++data; + col |= *data; + ++data; + setPixel(x,y,rgb24_to_native(col)); +#else + uint8_t r = (*data++) >> 4; + uint8_t g = (*data++) >> 4; + uint8_t b = (*data++) & 0x7f; + uint32_t col = (r << 4) | g | (b << 9); + setPixel(x,y,col); +#endif + } + ++y; + } } @@ -611,7 +668,7 @@ int32_t ILI9341::getColor(color_t c) const case BLACK: return 0x0000; case BLUE: return 0xfc00; case RED: return 0x03c0; - case GREEN: return 0x007f; + case GREEN: return 0x003f; // case PURPLE: return 0xffc0; case YELLOW: return 0x03ff; case CYAN: return 0xfc7f; diff --git a/drv/spi/ili9341.h b/drv/spi/ili9341.h index 02b5e70..8d27389 100644 --- a/drv/spi/ili9341.h +++ b/drv/spi/ili9341.h @@ -69,12 +69,17 @@ class ILI9341 : public MatrixDisplay, public SpiDevice static ILI9341 *getInstance() { return Instance; } + int32_t rgb24_to_native(uint32_t rgb) const override; + void drawHLine(uint16_t x, uint16_t y, uint16_t n, int32_t col = -1) override; void drawVLine(uint16_t x, uint16_t y, uint16_t n, int32_t col = -1) override; // unsigned drawText(uint16_t x, uint16_t y, const char *txt, int n, int32_t fg, int32_t bg) override; int setupOffScreen(uint16_t x, uint16_t y, uint16_t w, uint16_t h, int32_t bg) override; void commitOffScreen() override; + protected: + void drawPpm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data) override; + private: ILI9341(uint8_t cs, uint8_t cd, int8_t r, SemaphoreHandle_t sem, spi_device_handle_t hdl); @@ -97,6 +102,7 @@ class ILI9341 : public MatrixDisplay, public SpiDevice void checkPowerMode(); unsigned drawChars(const char *at, const char *e, int32_t fg, int32_t bg); void drawBitmapOffScr(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *data, int32_t fg, int32_t bg); + //void drawPgm(uint16_t x0, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, int32_t fg) override; static int readRegs(spi_device_handle_t hdl, uint8_t reg, uint8_t num, uint8_t *data, SemaphoreHandle_t); spi_transaction_t *getTransaction(preop_t); diff --git a/drv/xio/esp32-c3_io.cpp b/drv/xio/esp32-c3_io.cpp index c8f17eb..cead61d 100644 --- a/drv/xio/esp32-c3_io.cpp +++ b/drv/xio/esp32-c3_io.cpp @@ -28,8 +28,9 @@ #include #include -#define TAG MODULE_GPIO +#define COREIO0_NUMIO 22 +#define TAG MODULE_GPIO struct CoreIO : public XioCluster { @@ -45,6 +46,8 @@ struct CoreIO : public XioCluster // int intr_disable(uint8_t) override; int config(uint8_t io, xio_cfg_t) override; int set_lvl(uint8_t io, xio_lvl_t v) override; + int hold(uint8_t io) override; + int unhold(uint8_t io) override; const char *getName() const override; unsigned numIOs() const override; }; @@ -61,14 +64,14 @@ const char *CoreIO::getName() const unsigned CoreIO::numIOs() const { - return 22; + return COREIO0_NUMIO; } int CoreIO::config(uint8_t num, xio_cfg_t cfg) { log_dbug(TAG,"config %u,0x%x",num,cfg); - if (num >= 22) { + if (num >= COREIO0_NUMIO) { log_warn(TAG,"invalid gpio%u",num); return -EINVAL; } @@ -126,14 +129,14 @@ int CoreIO::config(uint8_t num, xio_cfg_t cfg) log_dbug(TAG,"input %u",num); } else if (cfg.cfg_io == xio_cfg_io_out) { gpio_pad_select_gpio(num); -// PIN_INPUT_DISABLE(GPIO_PIN_MUX_REG[num]); + PIN_INPUT_DISABLE(GPIO_PIN_MUX_REG[num]); GPIO.enable_w1ts.val = (1 << num); gpio_matrix_out(num, SIG_GPIO_OUT_IDX, false, false); GPIO.pin[num].pad_driver = 0; log_dbug(TAG,"output %u",num); } else if (cfg.cfg_io == xio_cfg_io_od) { gpio_pad_select_gpio(num); -// PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[num]); + PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[num]); GPIO.enable_w1ts.val = (1 << num); gpio_matrix_out(num, SIG_GPIO_OUT_IDX, false, false); GPIO.pin[num].pad_driver = 1; @@ -211,7 +214,7 @@ int CoreIO::config(uint8_t num, xio_cfg_t cfg) int CoreIO::get_dir(uint8_t num) const { - if (num >= 22) + if (num >= COREIO0_NUMIO) return -1; if (GPIO.pin[num].pad_driver) return xio_cfg_io_od; @@ -223,7 +226,7 @@ int CoreIO::get_dir(uint8_t num) const int CoreIO::get_lvl(uint8_t num) { - if (num < 22) { + if (num < COREIO0_NUMIO) { if (GPIO.enable.val & (1 << num)) return (GPIO.out.val >> num) & 0x1; else @@ -235,7 +238,7 @@ int CoreIO::get_lvl(uint8_t num) int CoreIO::get_out(uint8_t num) { - if (num < 22) { + if (num < COREIO0_NUMIO) { if (((GPIO.enable.val >> num) & 1) == 0) return xio_lvl_hiz; return (GPIO.out.val >> num) & 1; @@ -246,7 +249,7 @@ int CoreIO::get_out(uint8_t num) int CoreIO::set_hi(uint8_t num) { - if (num < 22) { + if (num < COREIO0_NUMIO) { uint32_t b = 1 << num; GPIO.out_w1ts.val = b; GPIO.enable_w1ts.val = b; @@ -258,7 +261,7 @@ int CoreIO::set_hi(uint8_t num) int CoreIO::set_hiz(uint8_t num) { - if (num < 22) { + if (num < COREIO0_NUMIO) { uint32_t b = 1 << num; GPIO.out_w1tc.val = b; GPIO.enable_w1tc.val = b; @@ -270,7 +273,7 @@ int CoreIO::set_hiz(uint8_t num) int CoreIO::set_lo(uint8_t num) { - if (num < 22) { + if (num < COREIO0_NUMIO) { uint32_t b = 1 << num; GPIO.out_w1tc.val = b; GPIO.enable_w1ts.val = b; @@ -282,7 +285,7 @@ int CoreIO::set_lo(uint8_t num) int CoreIO::set_lvl(uint8_t num, xio_lvl_t l) { - if (num < 22) { + if (num < COREIO0_NUMIO) { uint32_t b = 1 << num; if (l == xio_lvl_0) { GPIO.out_w1tc.val = b; @@ -302,6 +305,26 @@ int CoreIO::set_lvl(uint8_t num, xio_lvl_t l) } +int CoreIO::hold(uint8_t num) +{ + if (num < COREIO0_NUMIO) { + gpio_pad_hold(num); + return 0; + } + return -EINVAL; +} + + +int CoreIO::unhold(uint8_t num) +{ + if (num < COREIO0_NUMIO) { + gpio_pad_unhold(num); + return 0; + } + return -EINVAL; +} + + int CoreIO::setm(uint32_t v, uint32_t m) { if ((v ^ m) & v) @@ -314,7 +337,7 @@ int CoreIO::setm(uint32_t v, uint32_t m) int CoreIO::set_intr(uint8_t gpio, xio_intrhdlr_t hdlr, void *arg) { - if (gpio >= 22) { + if (gpio >= COREIO0_NUMIO) { log_warn(TAG,"set intr: invalid gpio%u",gpio); return -EINVAL; } @@ -330,7 +353,7 @@ int CoreIO::set_intr(uint8_t gpio, xio_intrhdlr_t hdlr, void *arg) #if 0 int CoreIO::intr_enable(uint8_t gpio) { - if (gpio >= 22) { + if (gpio >= COREIO0_NUMIO) { log_warn(TAG,"enable intr: invalid gpio%u",gpio); return -EINVAL; } @@ -345,7 +368,7 @@ int CoreIO::intr_enable(uint8_t gpio) int CoreIO::intr_disable(uint8_t gpio) { - if (gpio >= 22) { + if (gpio >= COREIO0_NUMIO) { log_warn(TAG,"disable intr: invalid gpio%u",gpio); return -EINVAL; } @@ -361,7 +384,7 @@ int CoreIO::intr_disable(uint8_t gpio) int coreio_config(uint8_t num, xio_cfg_t cfg) { - if (num < 22) + if (num < COREIO0_NUMIO) return GpioCluster.config(num,cfg); return -1; } @@ -369,7 +392,7 @@ int coreio_config(uint8_t num, xio_cfg_t cfg) int coreio_lvl_get(uint8_t num) { - if (num < 22) + if (num < COREIO0_NUMIO) return GpioCluster.get_lvl(num); return -1; } @@ -377,7 +400,7 @@ int coreio_lvl_get(uint8_t num) int coreio_lvl_hi(uint8_t num) { - if (num < 22) + if (num < COREIO0_NUMIO) return GpioCluster.set_hi(num); return -1; } @@ -385,7 +408,7 @@ int coreio_lvl_hi(uint8_t num) int coreio_lvl_lo(uint8_t num) { - if (num < 22) + if (num < COREIO0_NUMIO) return GpioCluster.set_lo(num); return -1; } @@ -393,7 +416,7 @@ int coreio_lvl_lo(uint8_t num) int coreio_lvl_set(uint8_t num, xio_lvl_t l) { - if (num < 22) + if (num < COREIO0_NUMIO) return GpioCluster.set_lvl(num,l); return -1; } diff --git a/drv/xio/esp32_io.cpp b/drv/xio/esp32_io.cpp index 71fd190..90396fc 100644 --- a/drv/xio/esp32_io.cpp +++ b/drv/xio/esp32_io.cpp @@ -26,12 +26,26 @@ #include "soc/gpio_periph.h" #include #include +#include #if IDF_VERSION >= 50 #define gpio_pad_select_gpio(...) #define gpio_matrix_out(...) #endif +#define COREIO0_NUMIO 32 +#if defined CONFIG_IDF_TARGET_ESP32 + #define COREIO1_NUMIO 8 +#elif defined CONFIG_IDF_TARGET_ESP32S2 + #define COREIO1_NUMIO 15 +#elif defined CONFIG_IDF_TARGET_ESP32S3 + #define COREIO1_NUMIO 17 +//#elif defined CONFIG_IDF_TARGET_ESP32C6 +// #define COREIO1_NUMIO 17 +#else +#error unknown device +#endif + #define TAG MODULE_GPIO @@ -49,6 +63,8 @@ struct CoreIO0 : public XioCluster // int intr_disable(uint8_t) override; int config(uint8_t io, xio_cfg_t) override; int set_lvl(uint8_t io, xio_lvl_t v) override; + int hold(uint8_t io) override; + int unhold(uint8_t io) override; const char *getName() const override; unsigned numIOs() const override; }; @@ -68,20 +84,10 @@ struct CoreIO1 : public XioCluster // int intr_disable(uint8_t) override; int config(uint8_t io, xio_cfg_t) override; int set_lvl(uint8_t io, xio_lvl_t v) override; + int hold(uint8_t io) override; + int unhold(uint8_t io) override; const char *getName() const override; unsigned numIOs() const override; -#define COREIO0_NUMIO 32 -#if defined CONFIG_IDF_TARGET_ESP32 - #define COREIO1_NUMIO 8 -#elif defined CONFIG_IDF_TARGET_ESP32S2 - #define COREIO1_NUMIO 15 -#elif defined CONFIG_IDF_TARGET_ESP32S3 - #define COREIO1_NUMIO 17 -//#elif defined CONFIG_IDF_TARGET_ESP32C6 -// #define COREIO1_NUMIO 17 -#else -#error unknown device -#endif }; @@ -399,7 +405,10 @@ int CoreIO1::get_dir(uint8_t num) const int CoreIO0::get_lvl(uint8_t num) { if (num < COREIO0_NUMIO) { - return (GPIO.in >> num) & 0x1; + if (GPIO.enable & (1 << num)) + return (GPIO.out >> num) & 0x1; + else + return (GPIO.in >> num) & 0x1; } return -EINVAL; } @@ -548,6 +557,46 @@ int CoreIO1::set_lvl(uint8_t num, xio_lvl_t l) } +int CoreIO0::hold(uint8_t num) +{ + if (num < COREIO0_NUMIO) { + gpio_pad_hold(num); + return 0; + } + return -EINVAL; +} + + +int CoreIO1::hold(uint8_t num) +{ + if (num < COREIO1_NUMIO) { + gpio_pad_hold(num+COREIO0_NUMIO); + return 0; + } + return -EINVAL; +} + + +int CoreIO0::unhold(uint8_t num) +{ + if (num < COREIO0_NUMIO) { + gpio_pad_unhold(num); + return 0; + } + return -EINVAL; +} + + +int CoreIO1::unhold(uint8_t num) +{ + if (num < COREIO1_NUMIO) { + gpio_pad_unhold(num+COREIO0_NUMIO); + return 0; + } + return -EINVAL; +} + + int CoreIO0::setm(uint32_t v, uint32_t m) { if ((v ^ m) & v) @@ -576,7 +625,7 @@ int CoreIO0::set_intr(uint8_t gpio, xio_intrhdlr_t hdlr, void *arg) log_warn(TAG,"set intr: invalid gpio%u",gpio); return -EINVAL; } - if (esp_err_t e = gpio_isr_handler_add((gpio_num_t)gpio,hdlr,(void*)arg)) { + if (esp_err_t e = gpio_isr_handler_add((gpio_num_t)gpio,hdlr,arg)) { log_warn(TAG,"add isr handler to gpio%u: %s",gpio,esp_err_to_name(e)); return e; } @@ -667,9 +716,9 @@ int CoreIO1::intr_disable(uint8_t gpio) int coreio_config(uint8_t num, xio_cfg_t cfg) { - if (num < 32) + if (num < COREIO0_NUMIO) return GpioCluster0.config(num,cfg); - num -= 32; + num -= COREIO0_NUMIO; if (num < COREIO1_NUMIO) return GpioCluster1.config(num,cfg); return -1; @@ -678,9 +727,9 @@ int coreio_config(uint8_t num, xio_cfg_t cfg) int coreio_lvl_get(uint8_t num) { - if (num < 32) + if (num < COREIO0_NUMIO) return GpioCluster0.get_lvl(num); - num -= 32; + num -= COREIO0_NUMIO; if (num < COREIO1_NUMIO) return GpioCluster1.get_lvl(num); return -1; @@ -689,9 +738,9 @@ int coreio_lvl_get(uint8_t num) int coreio_lvl_hi(uint8_t num) { - if (num < 32) + if (num < COREIO0_NUMIO) return GpioCluster0.set_hi(num); - num -= 32; + num -= COREIO0_NUMIO; if (num < COREIO1_NUMIO) return GpioCluster1.set_hi(num); return -1; @@ -700,9 +749,9 @@ int coreio_lvl_hi(uint8_t num) int coreio_lvl_lo(uint8_t num) { - if (num < 32) + if (num < COREIO0_NUMIO) return GpioCluster0.set_lo(num); - num -=32; + num -= COREIO0_NUMIO; if (num < COREIO1_NUMIO) return GpioCluster1.set_lo(num); return -1; @@ -711,9 +760,9 @@ int coreio_lvl_lo(uint8_t num) int coreio_lvl_set(uint8_t num, xio_lvl_t l) { - if (num < 32) + if (num < COREIO0_NUMIO) return GpioCluster0.set_lvl(num,l); - num -= 32; + num -= COREIO0_NUMIO; if (num < COREIO1_NUMIO) return GpioCluster1.set_lvl(num,l); return -1; diff --git a/drv/xio/xio.cpp b/drv/xio/xio.cpp index 55e3fd2..b7c951a 100644 --- a/drv/xio/xio.cpp +++ b/drv/xio/xio.cpp @@ -197,6 +197,26 @@ int xio_set_lvl(xio_t x, xio_lvl_t l) } +int xio_hold(xio_t x) +{ +// log_dbug(TAG,"set_lo %u",x); + if (XioCluster *c = XioCluster::getCluster(x)) + return c->hold(x-c->getBase()); + log_warn(TAG,"hold: invalid io %u",x); + return -1; +} + + +int xio_unhold(xio_t x) +{ +// log_dbug(TAG,"set_lo %u",x); + if (XioCluster *c = XioCluster::getCluster(x)) + return c->unhold(x-c->getBase()); + log_warn(TAG,"unhold: invalid io %u",x); + return -1; +} + + int xio_set_intr(xio_t x, xio_intrhdlr_t h, void *arg) { log_dbug(TAG,"set intr xio%u",x); diff --git a/drv/xio/xio.h b/drv/xio/xio.h index 64bbdc0..2d8a7f4 100644 --- a/drv/xio/xio.h +++ b/drv/xio/xio.h @@ -173,6 +173,12 @@ struct XioCluster virtual int set_intr_b(xio_t) { return -1; } + virtual int hold(uint8_t io) + { return -1; } + + virtual int unhold(uint8_t io) + { return -1; } + // virtual int intr_enable(uint8_t) // { return -1; } @@ -224,6 +230,8 @@ int xio_set_hi(xio_t x); int xio_set_lo(xio_t x); int xio_set_lvl(xio_t x, xio_lvl_t l); int xio_set_intr(xio_t x, xio_intrhdlr_t h, void *arg); +int xio_hold(xio_t x); +int xio_unhold(xio_t x); //int xio_intr_enable(xio_t x); //int xio_intr_disable(xio_t x); event_t xio_get_fallev(xio_t x); @@ -248,6 +256,8 @@ event_t xio_get_riseev(xio_t x); #define xio_intr_disable gpio_intr_disable #define xio_get_fallev(x) 0 #define xio_get_riseev(x) 0 +#define xio_hold(x) {} +#define xio_unhold(x) {} int xio_config(xio_t x, xio_cfg_t c); #endif // CONFIG_IOEXTENDERS diff --git a/hwcfg.wfc b/hwcfg.wfc index 6494010..7d0adf4 100644 --- a/hwcfg.wfc +++ b/hwcfg.wfc @@ -30,10 +30,11 @@ option pc : common { toSink=""; toASCII=toASCII; optimize=speed; - header="pcconfig.h"; + //header="pcconfig.h"; header="support.h"; enumnames=true; enummap=true; + cfgdefs=all; } option esp : common { @@ -356,7 +357,7 @@ message AdcConfig uint8 clk_div = 5; // esp8266 only // name of hall sensor - string hall_name = 6; + string hall_name = 6 [ ifdef=CONFIG_IDF_TARGET_ESP32 ]; repeated AdcChannel channels = 7; } @@ -421,6 +422,7 @@ message DisplayConfig unsigned options = 2 [ default = 0 ]; unsigned maxx = 3; unsigned maxy = 4 [ default = 1 ]; + repeated string skip_env = 5; } diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index a4b0dba..69d488c 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -14,7 +14,6 @@ idf_component_register( globals.cpp gpios.cpp httpd.cpp - hwcfg.cpp HttpReq.cpp HttpResp.cpp HttpServer.cpp @@ -37,8 +36,6 @@ idf_component_register( spi.cpp startup.cpp statemach.cpp - support.cpp - swcfg.cpp syslog.cpp telnet.cpp touchpads.cpp @@ -46,7 +43,6 @@ idf_component_register( udpctrl.cpp usb.cpp webcam.cpp - wfccore.cpp wifi.cpp REQUIRES @@ -54,4 +50,4 @@ idf_component_register( hc-sr04 hlw8012 i2c logging lua max7219 memfiles onewire relay spi timefuse tlc5947 wpa_supplicant ws8212b espcoredump vfs spi_flash esp_hw_support esp_adc esp_netif esp_rom esp_rom - esp_wifi mbedtls) + esp_wifi mbedtls wfc) diff --git a/main/Kconfig b/main/Kconfig index e7db213..12bdbf1 100644 --- a/main/Kconfig +++ b/main/Kconfig @@ -247,8 +247,8 @@ config GPIOS config CORETEMP bool "core temperature sensor" + depends on SOC_TEMP_SENSOR_SUPPORTED default false - depends on DEVEL help Core temperature sensor support is buggy in the IDF. Workarounds are applied, but may cause build failures. diff --git a/main/adc.cpp b/main/adc.cpp index 28e5acd..6dbd59a 100644 --- a/main/adc.cpp +++ b/main/adc.cpp @@ -35,7 +35,7 @@ #include #ifdef CONFIG_CORETEMP #include -#include +//#include #include #include #endif @@ -195,6 +195,114 @@ typedef adc_bitwidth_t adc_bits_width_t; static adc_bits_width_t U2Width = DEFAULT_ADC_WIDTH; #endif + +static void adc_sample_cb(void *arg) +{ + AdcSignal *s = (AdcSignal*)arg; + int sample = 0; + assert(s); +#if IDF_VERSION >= 50 + int raw; + if (esp_err_t e = adc_oneshot_read(s->hdl, s->channel, &raw)) { + log_warn(TAG,"reading ADC%u,%u: %s",s->unit,s->channel,esp_err_to_name(e)); + return; + } + sample = raw; +#else + if (s->unit == 1) { + sample = adc1_get_raw((adc1_channel_t)s->channel); + } else if (s->unit == 2) { + if (esp_err_t e = adc2_get_raw((adc2_channel_t)s->channel,U2Width,&sample)) { + log_warn(TAG,"error reading adc2, channel %u, bits %u: %s",s->channel,U2Width,esp_err_to_name(e)); + return; + } + } +#endif + if (s->ringbuf) { + s->ringbuf->put(sample); + float a = s->ringbuf->avg(); + log_dbug(TAG,"sample %s: %u, average %f, sum %u",s->name(),sample,a,s->ringbuf->sum()); + s->set(a); + } else { + log_dbug(TAG,"sample %s: %u",s->name(),sample); + s->set(sample); + } +} + + +static AdcSignal *getAdc(const char *arg) +{ + char *e; + long l = strtol(arg,&e,0); + if (e == arg) { + unsigned x = 0; + AdcSignal *s = Adcs[x]; + while (s && strcmp(s->name(),arg)) { + ++x; + if (x == NumAdc) + return 0; + s = Adcs[x]; + } + return s; + } else if ((l < 0) || (l >= NumAdc)) { + return 0; + } + return Adcs[l]; +} + + +#ifdef CONFIG_LUA +static int luax_adc_get_raw(lua_State *L) +{ + // adc_get(name) + const char *name = luaL_checkstring(L,1); + AdcSignal *adc = getAdc(name); + if (adc == 0) { + lua_pushliteral(L,"Invalid argument #1."); + lua_error(L); + } + lua_pushnumber(L,adc->raw.get()); + return 1; +} + + +static int luax_adc_get_volt(lua_State *L) +{ + // adc_get(name) + const char *name = luaL_checkstring(L,1); + AdcSignal *adc = getAdc(name); + if (adc == 0) { + lua_pushliteral(L,"Invalid argument #1."); + lua_error(L); + } + lua_pushnumber(L,adc->volt.get()); + return 1; +} + + +static int luax_adc_sample(lua_State *L) +{ + // adc_get(name) + const char *name = luaL_checkstring(L,1); + AdcSignal *adc = getAdc(name); + if (adc == 0) { + lua_pushliteral(L,"Invalid argument #1."); + lua_error(L); + } + adc_sample_cb(adc); + return 0; +} + + +static LuaFn Functions[] = { + { "adc_get_raw", luax_adc_get_raw, "get raw value of last ADC sample (name)" }, + { "adc_get_volt", luax_adc_get_volt, "get voltage value from last ADC sample (name)" }, + { "adc_get_sample", luax_adc_sample, "get a sample from ADC (name)" }, + { 0, 0, 0 } +}; +#endif + + //#if IDF_VERSION < 50 && defined CONFIG_IDF_TARGET_ESP32 #if defined CONFIG_IDF_TARGET_ESP32 @@ -253,40 +361,6 @@ const char *hall(Terminal &term, int argc, const char *args[]) #endif // CONFIG_IDF_TARGET_ESP32 -static void adc_sample_cb(void *arg) -{ - AdcSignal *s = (AdcSignal*)arg; - int sample = 0; - assert(s); -#if IDF_VERSION >= 50 - int raw; - if (esp_err_t e = adc_oneshot_read(s->hdl, s->channel, &raw)) { - log_warn(TAG,"reading ADC%u,%u: %s",s->unit,s->channel,esp_err_to_name(e)); - return; - } - sample = raw; -#else - if (s->unit == 1) { - sample = adc1_get_raw((adc1_channel_t)s->channel); - } else if (s->unit == 2) { - if (esp_err_t e = adc2_get_raw((adc2_channel_t)s->channel,U2Width,&sample)) { - log_warn(TAG,"error reading adc2, channel %u, bits %u: %s",s->channel,U2Width,esp_err_to_name(e)); - return; - } - } -#endif - if (s->ringbuf) { - s->ringbuf->put(sample); - float a = s->ringbuf->avg(); - log_dbug(TAG,"sample %s: %u, average %f, sum %u",s->name(),sample,a,s->ringbuf->sum()); - s->set(a); - } else { - log_dbug(TAG,"sample %s: %u",s->name(),sample); - s->set(sample); - } -} - - static unsigned adc_cyclic_cb(void *arg) { AdcSignal *s = (AdcSignal*)arg; @@ -313,58 +387,15 @@ struct temperature_sensor_obj_t { #endif // SOC_TEMPERATURE_SENSOR_INTR_SUPPORT }; -static int8_t s_temperature_regval_2_celsius(temperature_sensor_handle_t tsens, uint8_t regval) -{ - return TEMPERATURE_SENSOR_LL_ADC_FACTOR * regval - TEMPERATURE_SENSOR_LL_DAC_FACTOR * tsens->tsens_attribute->offset - TEMPERATURE_SENSOR_LL_OFFSET_FACTOR; -} -// END of import from IDF private header for BUG workaround - -#if 0 -// IDF BUG workaround by NoNullptr from github -static inline uint32_t temperature_sensor_ll_get_raw_value_bugfix(void) -{ - if (!SENS.sar_peri_clk_gate_conf.tsens_clk_en || - !SENS.sar_tctrl2.tsens_xpd_force || - !SENS.sar_tctrl.tsens_power_up_force || - !SENS.sar_tctrl.tsens_power_up || - !SENS.sar_tctrl.tsens_dump_out - ) { -s: SENS.sar_peri_clk_gate_conf.tsens_clk_en = true; - SENS.sar_tctrl2.tsens_xpd_force = true; - SENS.sar_tctrl.tsens_power_up_force = true; - SENS.sar_tctrl.tsens_power_up = true; - vTaskDelay(pdMS_TO_TICKS(10)); - } - SENS.sar_tctrl.tsens_dump_out = 1; - while (!SENS.sar_tctrl.tsens_ready) { - if (!SENS.sar_peri_clk_gate_conf.tsens_clk_en || - !SENS.sar_tctrl2.tsens_xpd_force || - !SENS.sar_tctrl.tsens_power_up_force || - !SENS.sar_tctrl.tsens_power_up || - !SENS.sar_tctrl.tsens_dump_out - ) { - goto s; - } - } - SENS.sar_tctrl.tsens_dump_out = 0; - return SENS.sar_tctrl.tsens_out; -} -#endif static unsigned temp_cyclic(void *arg) { PROFILE_FUNCTION(); -#if 0 // IDF still buggy? - uint32_t raw = temperature_sensor_ll_get_raw_value_bugfix(); - EnvNumber *t = (EnvNumber *) arg; - t->set(s_temperature_regval_2_celsius(TSensHdl,raw)); -#else float celsius; if (0 == temperature_sensor_get_celsius(TSensHdl,&celsius)) { EnvNumber *t = (EnvNumber *) arg; t->set(celsius); } -#endif return 200; } @@ -380,11 +411,7 @@ void temp_sensor_setup() } -#elif defined CONFIG_IDF_TARGET_ESP32C3 -// S2 support seems to be broken -// S3 had trouble, too - what config is causing this issue? -//#if defined CONFIG_IDF_TARGET_ESP32S2 || defined CONFIG_IDF_TARGET_ESP32S3 || defined CONFIG_IDF_TARGET_ESP32C3 -//#if defined CONFIG_IDF_TARGET_ESP32S3 || defined CONFIG_IDF_TARGET_ESP32C3 +#elif defined CONFIG_IDF_TARGET_ESP32S2 || defined CONFIG_IDF_TARGET_ESP32S3 || defined CONFIG_IDF_TARGET_ESP32C3 static unsigned temp_cyclic(void *arg) { float celsius; @@ -412,27 +439,6 @@ void temp_sensor_setup() #endif // CONFIG_CORETEMP -static AdcSignal *getAdc(const char *arg) -{ - char *e; - long l = strtol(arg,&e,0); - if (e == arg) { - unsigned x = 0; - AdcSignal *s = Adcs[x]; - while (s && strcmp(s->name(),arg)) { - ++x; - if (x == NumAdc) - return 0; - s = Adcs[x]; - } - return s; - } else if ((l < 0) || (l >= NumAdc)) { - return 0; - } - return Adcs[l]; -} - - static const char *adc_print(Terminal &t, const char *arg) { if (Adcs == 0) @@ -517,6 +523,9 @@ adc_oneshot_unit_handle_t adc_get_unit_handle(adc_unit_t unit) void adc_setup() { +#ifdef CONFIG_LUA + xlua_add_funcs("adc",Functions); +#endif #ifdef CONFIG_CORETEMP temp_sensor_setup(); #endif @@ -692,58 +701,6 @@ static const char *adc_sample(Terminal &term) } -#ifdef CONFIG_LUA -static int luax_adc_get_raw(lua_State *L) -{ - // adc_get(name) - const char *name = luaL_checkstring(L,1); - AdcSignal *adc = getAdc(name); - if (adc == 0) { - lua_pushliteral(L,"Invalid argument #1."); - lua_error(L); - } - lua_pushnumber(L,adc->raw.get()); - return 1; -} - - -static int luax_adc_get_volt(lua_State *L) -{ - // adc_get(name) - const char *name = luaL_checkstring(L,1); - AdcSignal *adc = getAdc(name); - if (adc == 0) { - lua_pushliteral(L,"Invalid argument #1."); - lua_error(L); - } - lua_pushnumber(L,adc->volt.get()); - return 1; -} - - -static int luax_adc_sample(lua_State *L) -{ - // adc_get(name) - const char *name = luaL_checkstring(L,1); - AdcSignal *adc = getAdc(name); - if (adc == 0) { - lua_pushliteral(L,"Invalid argument #1."); - lua_error(L); - } - adc_sample_cb(adc); - return 0; -} - - -static LuaFn Functions[] = { - { "adc_get_raw", luax_adc_get_raw, "get raw value of last ADC sample (name)" }, - { "adc_get_volt", luax_adc_get_volt, "get voltage value from last ADC sample (name)" }, - { "adc_get_sample", luax_adc_sample, "get a sample from ADC (name)" }, - { 0, 0, 0 } -}; -#endif - - int adc_setup() { if (!HWConf.has_adc()) diff --git a/main/hwcfg.h b/main/hwcfg.h new file mode 100644 index 0000000..9afa707 --- /dev/null +++ b/main/hwcfg.h @@ -0,0 +1,4 @@ +#define MKSTR(s) #s +#define MKHFILE(a,b) MKSTR(a##b.h) +#define HWCFGH(y) MKHFILE(hwcfg_,y) +#include HWCFGH(WFC_TARGET) diff --git a/main/relays.cpp b/main/relays.cpp index 6847314..c57c290 100644 --- a/main/relays.cpp +++ b/main/relays.cpp @@ -204,15 +204,12 @@ void relay_setup() } #endif - if (Relay *r = Relay::create(n,(xio_t)gpio,itv,c.config_active_high())) { + bool p = c.config_persistent(); + bool iv = c.config_init_on(); + if (Relay *r = Relay::create(n,(xio_t)gpio,itv,c.config_active_high(),iv,p)) { #ifdef CONFIG_MQTT r->setCallback(relay_callback); #endif - bool iv = c.config_init_on(); - if (c.config_persistent()) { - r->setPersistent(true); - iv = nvm_read_u8(n,iv); - } r->attach(RTData); log_info(TAG,"relay '%s' at gpio%d init %d",n,gpio,(int)iv); r->set(iv); diff --git a/main/romfs.cpp b/main/romfs.cpp index eb29c2d..bba54da 100644 --- a/main/romfs.cpp +++ b/main/romfs.cpp @@ -18,6 +18,8 @@ #include +#ifdef CONFIG_ROMFS + #include "romfs.h" #include @@ -43,8 +45,6 @@ #endif -#ifdef CONFIG_ROMFS - // flash ROM entry generated by mkrom typedef struct RomEntry16 @@ -134,7 +134,7 @@ const char *romfs_name(int i) } -#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S2 || defined CONFIG_IDF_TARGET_ESP32S3 +#ifdef ESP32 void *romfs_mmap(int i) { if ((i < 0) || (i >= NumEntries)) diff --git a/main/screen.cpp b/main/screen.cpp index 052cd78..17b9d7f 100644 --- a/main/screen.cpp +++ b/main/screen.cpp @@ -569,6 +569,25 @@ static const LuaFn Functions[] = { { 0, 0, 0 } }; + +int luax_fb_drawicon(lua_State *L) +{ + if (MatrixDisplay *md = Ctx->disp->toMatrixDisplay()) { + const char *fn = luaL_checkstring(L,1); + int x = luaL_checkinteger(L,2); + int y = luaL_checkinteger(L,3); + int col = 0; + if (lua_isinteger(L,4)) + col = lua_tointeger(L,4); + md->drawIcon(x,y,fn,col); + return 0; + } + lua_pushliteral(L,"fb_drawicon: no display."); + lua_error(L); + return 0; +} + + static int luax_fb_setbgcol(lua_State *L) { if (MatrixDisplay *md = Ctx->disp->toMatrixDisplay()) { @@ -744,6 +763,49 @@ static int luax_fb_fillrect(lua_State *L) } +static int luax_fb_flush(lua_State *L) +{ + if (MatrixDisplay *md = Ctx->disp->toMatrixDisplay()) { + md->flush(); + return 0; + } + lua_pushliteral(L,"fb_drawrect: no display."); + lua_error(L); + return 0; +} + + +static int luax_fb_offscreen(lua_State *L) +{ + if (MatrixDisplay *md = Ctx->disp->toMatrixDisplay()) { + int x = luaL_checkinteger(L,1); + int y = luaL_checkinteger(L,2); + int w = luaL_checkinteger(L,3); + int h = luaL_checkinteger(L,4); + int bg = -1; + if (lua_isinteger(L,5)) + bg = lua_tointeger(L,5); + md->setupOffScreen(x,y,w,h,bg); + return 0; + } + lua_pushliteral(L,"fb_drawrect: no display."); + lua_error(L); + return 0; +} + + +static int luax_fb_commit(lua_State *L) +{ + if (MatrixDisplay *md = Ctx->disp->toMatrixDisplay()) { + md->commitOffScreen(); + return 0; + } + lua_pushliteral(L,"fb_drawrect: no display."); + lua_error(L); + return 0; +} + + static const LuaFn FbFunctions[] = { { "fb_drawrect", luax_fb_drawrect, "draw rectangle" }, { "fb_drawtext", luax_fb_drawtext, "draw text string" }, @@ -754,6 +816,10 @@ static const LuaFn FbFunctions[] = { { "fb_setbgcol", luax_fb_setbgcol, "set background color" }, { "fb_setfgcol", luax_fb_setfgcol, "set foreground color" }, { "fb_setfont", luax_fb_setfont, "set font" }, + { "fb_drawicon", luax_fb_drawicon, "draw icon" }, + { "fb_flush", luax_fb_flush, "flush to display" }, + { "fb_offscreen", luax_fb_offscreen, "setup off-screen area" }, + { "fb_commit", luax_fb_commit, "commit off-screen area" }, { 0, 0, 0 }, }; diff --git a/main/shell.cpp b/main/shell.cpp index 7c92bf6..f7bb406 100644 --- a/main/shell.cpp +++ b/main/shell.cpp @@ -1404,6 +1404,8 @@ static const char *wifi(Terminal &term, int argc, const char *args[]) return "Invalid argument #1."; if (ESP_OK != esp_wifi_set_mode(m)) { term.println("error changing wifi mode"); + } else if (m == WIFI_MODE_NULL) { + esp_wifi_stop(); } return 0; } @@ -2699,8 +2701,10 @@ const char *shellexe(Terminal &term, char *cmd) return 0; log_info(TAG,"on %s execute '%s'",term.type(),cmd); char *args[8]; + /* space trimming is done in shell() while ((*cmd == ' ') || (*cmd == '\t')) ++cmd; + */ #ifdef CONFIG_LUA if ((0 == memcmp("lua",cmd,3)) && ((cmd[3] == ' ') || (cmd[3] == '\t'))) return xlua_exe(term,cmd+4); @@ -2824,11 +2828,11 @@ void shell(Terminal &term, bool prompt) if ((r < 0) || ((r == 4) && !memcmp(at,"exit",4))) return; const char *msg = 0; - if (com[0] == '#') { + if (at[0] == '#') { } else if (r > 0) { term.println(); - com[r] = 0; - msg = shellexe(term,com); + at[r] = 0; + msg = shellexe(term,at); if (msg == 0) msg = "OK."; } diff --git a/main/swcfg.h b/main/swcfg.h new file mode 100644 index 0000000..3154c74 --- /dev/null +++ b/main/swcfg.h @@ -0,0 +1,4 @@ +#define MKSTR(s) #s +#define MKHFILE(a,b) MKSTR(a##b.h) +#define SWCFGH(y) MKHFILE(swcfg_,y) +#include SWCFGH(WFC_TARGET) diff --git a/mkatrium.sh b/mkatrium.sh index 8fad72e..b6f3fd1 100755 --- a/mkatrium.sh +++ b/mkatrium.sh @@ -91,7 +91,6 @@ fi eval `python3 $IDF_PATH/tools/idf_tools.py export` -bash bin/link_wfc.sh || exit 1 bin/genmemfiles.sh || exit 1 bin/mkversion.sh main/versions.h || exit 1 @@ -107,16 +106,14 @@ elif [ "$CONFIG_IDF_TARGET_ESP32C6" == "y" ]; then IDF_TARGET=esp32c6 fi +export WFC_TARGET=$CONFIG_WFC_TARGET +export CONFIG_WFC_TARGET ATRIUM_VER=`cat "$BUILD_DIR/version.txt"` export TIMESTAMP=`date +%s` if [ "$2" != "" ]; then - #$IDF_PY -B "$BUILD_DIR" -DIDF_TARGET=$IDF_TARGET -DSDKCONFIG=$SDKCONFIG -DFWCFG="$FWCFG" "-DPROJECT_VER=$ATRIUM_VER" $2 $IDF_PY -B "$BUILD_DIR" -DIDF_TARGET=$IDF_TARGET -DSDKCONFIG=$SDKCONFIG "-DPROJECT_VER=$ATRIUM_VER" $2 - #$IDF_PY -B "$BUILD_DIR" $2 else - #$IDF_PY -B "$BUILD_DIR" -DIDF_TARGET=$IDF_TARGET -DSDKCONFIG=$SDKCONFIG -DFWCFG="$FWCFG" "-DPROJECT_VER=$ATRIUM_VER" build $IDF_PY -B "$BUILD_DIR" -DIDF_TARGET=$IDF_TARGET -DSDKCONFIG=$SDKCONFIG "-DPROJECT_VER=$ATRIUM_VER" build - #$IDF_PY -B "$BUILD_DIR" build fi diff --git a/projects/esp32-c3_4m b/projects/esp32-c3_4m index 1cd4540..082d2e8 100644 --- a/projects/esp32-c3_4m +++ b/projects/esp32-c3_4m @@ -881,7 +881,7 @@ CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set # CONFIG_ESP_WIFI_FTM_ENABLE is not set -# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set +CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE=y # CONFIG_ESP_WIFI_GCMP_SUPPORT is not set # CONFIG_ESP_WIFI_GMAC_SUPPORT is not set CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y @@ -1642,6 +1642,7 @@ CONFIG_USB_HOST_FS=y CONFIG_USB_DIAGLOG=y CONFIG_USB_CONSOLE=y CONFIG_GPIOS=y +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32-c6_4m b/projects/esp32-c6_4m index ce1110d..d847190 100644 --- a/projects/esp32-c6_4m +++ b/projects/esp32-c6_4m @@ -1756,6 +1756,7 @@ CONFIG_USB_HOST_FS=y # CONFIG_USB_DIAGLOG is not set CONFIG_USB_CONSOLE=y CONFIG_GPIOS=y +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32-s2_4m b/projects/esp32-s2_4m index 5736cff..39d5c21 100644 --- a/projects/esp32-s2_4m +++ b/projects/esp32-s2_4m @@ -1038,7 +1038,7 @@ CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1 CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y # CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is not set -# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y # end of Kernel # @@ -1055,6 +1055,8 @@ CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y CONFIG_FREERTOS_CORETIMER_0=y # CONFIG_FREERTOS_CORETIMER_1 is not set CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y +CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER=y +# CONFIG_FREERTOS_RUN_TIME_STATS_USING_CPU_CLK is not set # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set # CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set @@ -1698,6 +1700,7 @@ CONFIG_USB_HOST_FS=y # hardware support # CONFIG_GPIOS=y +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32-s3_4m b/projects/esp32-s3_4m index 826e037..8317bb6 100644 --- a/projects/esp32-s3_4m +++ b/projects/esp32-s3_4m @@ -1842,6 +1842,7 @@ CONFIG_USB_HOST_FS=y CONFIG_USB_DIAGLOG=y CONFIG_USB_CONSOLE=y CONFIG_GPIOS=y +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32-s3_4m_dev b/projects/esp32-s3_4m_dev index 58f96f7..a022b95 100644 --- a/projects/esp32-s3_4m_dev +++ b/projects/esp32-s3_4m_dev @@ -1842,7 +1842,7 @@ CONFIG_USB_HOST_FS=y CONFIG_USB_DIAGLOG=y CONFIG_USB_CONSOLE=y CONFIG_GPIOS=y -# CONFIG_CORETEMP is not set +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32-s3_8m b/projects/esp32-s3_8m index 3351907..ffa6105 100644 --- a/projects/esp32-s3_8m +++ b/projects/esp32-s3_8m @@ -1848,6 +1848,7 @@ CONFIG_USB_HOST_FS=y CONFIG_USB_DIAGLOG=y CONFIG_USB_CONSOLE=y CONFIG_GPIOS=y +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32-s3_8m_dev b/projects/esp32-s3_8m_dev index c7d10cf..86f7a9d 100644 --- a/projects/esp32-s3_8m_dev +++ b/projects/esp32-s3_8m_dev @@ -1848,7 +1848,7 @@ CONFIG_USB_HOST_FS=y CONFIG_USB_DIAGLOG=y CONFIG_USB_CONSOLE=y CONFIG_GPIOS=y -# CONFIG_CORETEMP is not set +CONFIG_CORETEMP=y CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32_4m_dev b/projects/esp32_4m_dev index 7263a04..f46a838 100644 --- a/projects/esp32_4m_dev +++ b/projects/esp32_4m_dev @@ -1627,7 +1627,6 @@ CONFIG_ROMFS_VFS_NUMFDS=4 # hardware support # CONFIG_GPIOS=y -# CONFIG_CORETEMP is not set CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/projects/esp32_8m_full b/projects/esp32_8m_full index 8c6bedf..b6836b8 100644 --- a/projects/esp32_8m_full +++ b/projects/esp32_8m_full @@ -1738,7 +1738,6 @@ CONFIG_ROMFS_VFS_NUMFDS=4 # hardware support # CONFIG_GPIOS=y -# CONFIG_CORETEMP is not set CONFIG_IOEXTENDERS=y CONFIG_LEDS=y CONFIG_BUTTON=y diff --git a/ptables/esp32_4m-ptable.csv b/ptables/esp32_4m-ptable.csv index b43a5a3..bf56432 100644 --- a/ptables/esp32_4m-ptable.csv +++ b/ptables/esp32_4m-ptable.csv @@ -4,7 +4,7 @@ nvs, data, nvs, 0x9000, 0x4000 otadata, data, ota, 0xd000, 0x2000 phy_init, data, phy, 0xf000, 0x1000 coredump, data, coredump,0x10000, 0x10000 -romfs , data, 0x88, 0x20000, 0x10000 -storage, data, fat, 0x30000, 0xd0000 +romfs , data, 0x88, 0x20000, 0x20000 +storage, data, fat, 0x40000, 0xc0000 ota_0, app, ota_0, 0x100000,0x180000 ota_1, app, ota_1, 0x280000,0x180000 diff --git a/swcfg.wfc b/swcfg.wfc index 77ba6aa..e537f3e 100644 --- a/swcfg.wfc +++ b/swcfg.wfc @@ -31,10 +31,11 @@ option pc : common { toSink=""; toASCII=toASCII; optimize=speed; - header="pcconfig.h"; + //header="pcconfig.h"; header="support.h"; enumnames=true; enummap=true; + cfgdefs=all; } option esp : common { diff --git a/tools/atriumcfg.cpp b/tools/atriumcfg.cpp index 32c5bfa..3a56730 100644 --- a/tools/atriumcfg.cpp +++ b/tools/atriumcfg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022, Thomas Maier-Komor + * Copyright (C) 2020-2023, Thomas Maier-Komor * Atrium Firmware Package for ESP * * This program is free software: you can redistribute it and/or modify @@ -16,24 +16,6 @@ * along with this program. If not, see . */ -#define CONFIG_BUTTON -#define CONFIG_DHT -#define CONFIG_DISPLAY -#define CONFIG_HCSR04 -#define CONFIG_I2C -#define CONFIG_LEDSTRIP -#define CONFIG_MAX7219 -#define CONFIG_NIGHTSKY -#define CONFIG_ONEWIRE -#define CONFIG_RELAY - -#define CONFIG_APP_PARAMS -#define CONFIG_FTP -#define CONFIG_HTTP -#define CONFIG_INFLUX -#define CONFIG_MQTT -#define CONFIG_SIGNAL_PROC - #include "hwcfg.h" #include "swcfg.h" #include "version.h" @@ -1295,7 +1277,9 @@ int main(int argc, char **argv) //rl_attempted_completion_function = completion_function; for (;;) { char *line = readline("> "); - if ((line == 0) || (line[0] == '#')) + if (line == 0) + break; + if ((line[0] == 0) || (line[0] == '#')) continue; add_history(line); char *cmd = strtok(line," \t"); diff --git a/tools/hwcfg.cpp b/tools/hwcfg.cpp deleted file mode 120000 index 62e0c95..0000000 --- a/tools/hwcfg.cpp +++ /dev/null @@ -1 +0,0 @@ -../components/wfc/hwcfg_pc.cpp \ No newline at end of file diff --git a/tools/hwcfg.h b/tools/hwcfg.h deleted file mode 120000 index 22037de..0000000 --- a/tools/hwcfg.h +++ /dev/null @@ -1 +0,0 @@ -../components/wfc/hwcfg_pc.h \ No newline at end of file diff --git a/tools/mkromfs.cpp b/tools/mkromfs.cpp index 9f9dc65..5f34dd7 100644 --- a/tools/mkromfs.cpp +++ b/tools/mkromfs.cpp @@ -439,7 +439,7 @@ int main(int argc, char *argv[]) printf("warning: ignoring duplicate entry name '%s' (file %s)\n",ename,fname); continue; } - check_exit(strlen(ename)>(M32 ? 15 : 11),"filename '%s' is too long\n",ename); + check_exit(strlen(ename)>(M32 ? 23 : 11),"filename '%s' is too long\n",ename); } unsigned idx = 0; for (auto x : entries) { diff --git a/tools/swcfg.cpp b/tools/swcfg.cpp deleted file mode 120000 index 4327eee..0000000 --- a/tools/swcfg.cpp +++ /dev/null @@ -1 +0,0 @@ -../components/wfc/swcfg_pc.cpp \ No newline at end of file diff --git a/tools/swcfg.h b/tools/swcfg.h deleted file mode 120000 index ed32af7..0000000 --- a/tools/swcfg.h +++ /dev/null @@ -1 +0,0 @@ -../components/wfc/swcfg_pc.h \ No newline at end of file diff --git a/tools/wfccore.cpp b/tools/wfccore.cpp deleted file mode 120000 index 6717b29..0000000 --- a/tools/wfccore.cpp +++ /dev/null @@ -1 +0,0 @@ -../components/wfc/wfccore_pc.cpp \ No newline at end of file diff --git a/tools/wfccore.h b/tools/wfccore.h deleted file mode 120000 index 1f6327c..0000000 --- a/tools/wfccore.h +++ /dev/null @@ -1 +0,0 @@ -../components/wfc/wfccore_pc.h \ No newline at end of file