From 55b1628855a3dd91c7b0b3643b6a655d101f35d4 Mon Sep 17 00:00:00 2001 From: Thomas Maier-Komor Date: Wed, 1 Feb 2023 19:23:19 +0100 Subject: [PATCH] release R2301 --- CMakeLists.txt | 4 + ChangeLog | 14 + Makefile.gmake | 2 +- README.md | 32 +- cfg/rgbcct.cfg | Bin 0 -> 142 bytes cfg/shelly1.cfg | 4 + components/actions/actions.cpp | 54 +- components/actions/actions.h | 3 +- components/env/env.h | 2 +- components/event/event.cpp | 64 +- components/event/event.h | 4 + components/logging/CMakeLists.txt | 2 +- components/logging/logging.c | 2 +- components/logging/modules.c | 81 +- components/logging/modules.h | 66 +- components/netsvc/CMakeLists.txt | 2 +- components/wfc/hwcfg_esp32.cpp | 1170 +++++++++------- components/wfc/hwcfg_esp32.h | 390 +++++- components/wfc/hwcfg_esp8266.cpp | 896 +++++++----- components/wfc/hwcfg_esp8266.h | 390 +++++- components/wfc/hwcfg_esp8285.cpp | 885 +++++++----- components/wfc/hwcfg_esp8285.h | 390 +++++- components/wfc/hwcfg_pc.cpp | 1253 ++++++++++------- components/wfc/hwcfg_pc.h | 390 +++++- components/wfc/swcfg_esp32.cpp | 382 +++--- components/wfc/swcfg_esp32.h | 132 +- components/wfc/swcfg_esp8266.cpp | 343 +++-- components/wfc/swcfg_esp8266.h | 132 +- components/wfc/swcfg_esp8285.cpp | 343 +++-- components/wfc/swcfg_esp8285.h | 132 +- components/wfc/swcfg_pc.cpp | 418 +++--- components/wfc/swcfg_pc.h | 132 +- components/wfc/wfccore_esp32.cpp | 4 +- components/wfc/wfccore_esp32.h | 4 +- components/wfc/wfccore_esp8266.cpp | 4 +- components/wfc/wfccore_esp8266.h | 4 +- components/wfc/wfccore_esp8285.cpp | 4 +- components/wfc/wfccore_esp8285.h | 4 +- components/wfc/wfccore_pc.cpp | 4 +- components/wfc/wfccore_pc.h | 4 +- data/lua/ledstrip.lua | 6 +- data/man/lua.man | 21 +- drv/button/CMakeLists.txt | 2 +- drv/button/button.cpp | 20 + drv/button/button.h | 5 + drv/button/rotenc.cpp | 12 +- drv/hlw8012/CMakeLists.txt | 2 +- drv/hlw8012/hlw8012.h | 2 +- drv/i2c/CMakeLists.txt | 1 + drv/i2c/i2cdrv.cpp | 4 +- drv/i2c/ina2xx.cpp | 22 +- drv/i2c/pcf8574.cpp | 6 +- drv/i2c/tca9555.cpp | 253 ++++ drv/i2c/tca9555.h | 72 + drv/relay/relay.cpp | 24 +- drv/relay/relay.h | 5 +- drv/ws8212b/ws2812b.cpp | 34 +- drv/ws8212b/ws2812b.h | 37 +- hwcfg.wfc | 12 +- main/CMakeLists.txt | 53 +- main/HttpServer.cpp | 14 +- main/Kconfig | 25 +- main/adc.cpp | 242 ++-- main/alarms.h | 2 +- main/buttons.cpp | 9 +- main/console.cpp | 6 +- main/dimmer.cpp | 47 +- main/globals.cpp | 7 +- main/globals.h | 4 +- main/gpios.cpp | 82 +- main/i2c.cpp | 8 +- main/inetd.cpp | 3 +- main/influx.cpp | 13 +- main/leds.cpp | 146 +- main/ledstrip.cpp | 371 ++--- main/luaext.cpp | 114 +- main/luaext.h | 2 + main/lwinetd.cpp | 15 +- main/mqtt.cpp | 29 +- main/ota.cpp | 83 +- main/ota.h | 3 +- main/relays.cpp | 57 +- main/romfs.cpp | 12 +- main/screen.cpp | 68 +- main/screen.h | 50 + main/settings.cpp | 2 +- main/shell.cpp | 40 +- main/startup.cpp | 15 +- main/statemach.cpp | 47 +- main/syslog.cpp | 2 +- main/uarts.cpp | 30 +- main/wifi.cpp | 6 +- mkatrium.sh | 5 + projects/esp32-c3_2m | 11 +- projects/esp32-c3_4m | 2 +- projects/esp32-s2_4m | 3 +- projects/esp32-s3_8m | 5 +- projects/esp32_4m | 137 +- projects/esp32_4m_dev | 1525 +++++++++++++++++++++ projects/esp32_4m_min | 3 +- projects/{esp32_4m_full => esp32_8m_full} | 47 +- projects/esp8266_2m | 457 ++++++ projects/esp8266_4m | 23 +- projects/esp8266_4m_full | 21 +- projects/esp8266_4m_min | 2 +- projects/esp8285 | 2 +- ptables/esp8266_2m-ptable.csv | 8 + startup.txt | 4 +- swcfg.wfc | 2 + tools/atriumcfg.cpp | 41 +- 110 files changed, 9110 insertions(+), 3481 deletions(-) create mode 100644 cfg/rgbcct.cfg create mode 100644 cfg/shelly1.cfg create mode 100644 drv/i2c/tca9555.cpp create mode 100644 drv/i2c/tca9555.h create mode 100644 main/screen.h create mode 100644 projects/esp32_4m_dev rename projects/{esp32_4m_full => esp32_8m_full} (98%) create mode 100644 projects/esp8266_2m create mode 100644 ptables/esp8266_2m-ptable.csv diff --git a/CMakeLists.txt b/CMakeLists.txt index 53946e3..4f8c94a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +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(FWCFG="$ENV{FWCFG}") +#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 675542e..2de48bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +R2301: +====== +- Lua integration enhancements +- fix for cyclic interval timing on ESP32-xx +- fix for ESP8266 GPIO handling with IO-expander +- fix WS2812B always using channel 0 +- updates for atriumcfg tool +- added Lua support for ADC +- added WS2812b multi-bus support +- added TCA9555 driver (IO-expander, DEVEL/alpha-state, untested yet) +- fix for argument event handling +- support ADC digital to physical conversion on ESP32* +- added OTA server config for simplified updates + R2212: ====== - added action gpio!set for more flexible gpio operation diff --git a/Makefile.gmake b/Makefile.gmake index d21f30a..13c978a 100644 --- a/Makefile.gmake +++ b/Makefile.gmake @@ -64,7 +64,7 @@ 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) -I$(BUILD_DIR_BASE)/config +CPPFLAGS =-DIDF_VERSION=$(IDF_VER) -D$(CHIP) -DFWCFG=\"$(PROJECT)\" -I$(BUILD_DIR_BASE)/config BUILD_DIR_BASE =$(PWD)/build.$(PROJECT) PROJECT_ROOT =$(PWD) WFCINC =$(WFCDIR)/include diff --git a/README.md b/README.md index 7b6dc35..8701691 100644 --- a/README.md +++ b/README.md @@ -655,8 +655,8 @@ make bin/atriumcfg bin/atriumcfg ``` -Over-the-Air update: -==================== +Over-the-Air (OTA) updates: +=========================== To build binaries for an OTA update, you have to build your project with target `ota` for ESP8266 to get binaries for the approrpiate partitions. For ESP32 all binaries can be used for any patition with OTA updates. ``` make PROJECT= ota @@ -710,6 +710,34 @@ restore the old configuration using: config restore ``` +OTA server: +----------- +An OTA server should provide firmware images via HTTP at the specified +location. Additionally, the OTA server can be set via in the `otasrv` +config setting, which simplifies the ota update command. If the `otasrv` +variable is set the update command only needs the version, you intend to +update to, and the update command will the pick the coorect file for the +relevant partition ($ext) and firmware configuration (project name, +$fwcfg) as follow: + +``` +$otasrv/$fwcfg/atrium-$version.$ext +``` + +The `otasrv` setting should be of the format: `http://server/path`. +Below should be a subdirectory for the relevant firmware/project +configuration, which in turn includes the firmware file named +`atrium-.`. The extension part is for ESP32 devices +always `.bin`, as the firmware can be stored on any partition. For +ESP8266 family, the filename extension must match the partition name, as +it needs to be linked with the correct addresses. + +To use this, the update command should be executed with the option `-v` +and the relevant version name: +``` +update -v +``` + Interface Stability: -------------------- diff --git a/cfg/rgbcct.cfg b/cfg/rgbcct.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e7eb9fb035d533afcc0c4a60871698ba2485c749 GIT binary patch literal 142 zcmZQQ{WfHs5|ev,arg); - return 0; + l = strlen(name); + char *arg = (char *) malloc(l+1); + arg[l] = 0; + memcpy(arg,name,l); + event_trigger_arg(ActionTriggerEvt,arg); } @@ -196,10 +174,22 @@ void action_iterate(void (*f)(void*,const Action *),void *p) static void action_event_cb(void *arg) { - Action *a = (Action *)arg; - assert(a); - log_dbug(TAG,"action %s",a->name); - a->activate(); + const char *as = (const char *)arg; + size_t al = strlen(as); + char tmp[al+1]; + memcpy(tmp,as,sizeof(tmp)); + char *sp = strchr(tmp,' '); + if (sp) { + *sp = 0; + ++sp; + } + Action *a = action_get(tmp); + if (a == 0) { + log_warn(TAG,"request to execute non-existing action %s",tmp); + } else { + log_dbug(TAG,"action %s",a->name); + a->activate(sp); + } } diff --git a/components/actions/actions.h b/components/actions/actions.h index d472362..7b96a40 100644 --- a/components/actions/actions.h +++ b/components/actions/actions.h @@ -30,7 +30,6 @@ class Action const char *name; const char *text = 0; // descriptive help text uint32_t min = UINT32_MAX, max = 0, sum = 0, num = 0; - unsigned ev; Action(const char *n, void (*f)(void*),void *a, const char *t); Action(const char *n); @@ -52,7 +51,7 @@ const char *action_text(const char *name); Action *action_get(const char *name); int action_activate(const char *name); int action_activate_arg(const char *name, void *arg); -int action_dispatch(const char *name, size_t l); // execute action via event queue +void action_dispatch(const char *name, size_t l); // execute action via event queue int action_exists(const char *name); void action_iterate(void (*)(void*,const Action *),void *); void actions_setup(); diff --git a/components/env/env.h b/components/env/env.h index 96479a3..0f05a98 100644 --- a/components/env/env.h +++ b/components/env/env.h @@ -175,6 +175,7 @@ class EnvString : public EnvElement { public: EnvString(const char *name, const char *v, const char *dim = 0); + ~EnvString(); // deletion is not supported EnvString *toString() { return this; } @@ -188,7 +189,6 @@ class EnvString : public EnvElement { return m_value; } private: - ~EnvString(); // deletion is not supported EnvString(const EnvString &); EnvString &operator = (const EnvString &); char *m_value; diff --git a/components/event/event.cpp b/components/event/event.cpp index 7fb310b..000122a 100644 --- a/components/event/event.cpp +++ b/components/event/event.cpp @@ -36,7 +36,11 @@ using namespace std; struct Event { event_t id; - void *arg; + void *arg = 0; + Event(event_t i = 0, void *a = 0) + : id(i) + , arg(a) + { } }; @@ -141,8 +145,10 @@ int event_trigger_en(trigger_t t, bool en) { event_t e = t >> 16; uint16_t c = t; - if ((e == 0) || (e >= EventHandlers.size()) || (c >= EventHandlers[e].callbacks.size())) + if ((e == 0) || (e >= EventHandlers.size()) || (c >= EventHandlers[e].callbacks.size())) { + log_warn(TAG,"cannot %sable event %d",en?"en":"dis",t); return 1; + } EventHandlers[e].callbacks[c].enabled = en; return 0; } @@ -152,10 +158,15 @@ trigger_t event_callback(const char *event, const char *action) { const char *x = 0; if (event_t e = event_id(event)) { - if (Action *a = action_get(action)) + if (const char *sp = strchr(action,' ')) { + ++sp; + char tmp[sp-action]; + memcpy(tmp,action,sizeof(tmp)); + if (Action *a = action_get(tmp)) + return event_callback_arg(e,a,strdup(sp)); + } else if (Action *a = action_get(action)) return event_callback(e,a); - else - x = action; + x = action; } else { x = event; } @@ -175,7 +186,6 @@ trigger_t event_callback_arg(const char *event, const char *action, const char * } else { x = event; } - assert(x); log_warn(TAG,"callback arg invalid %s",x); return 0; } @@ -255,7 +265,7 @@ void event_trigger(event_t id) log_warn(TAG,"trigger 0"); return; } - struct Event e = {id,0}; + Event e(id); BaseType_t r = xQueueSend(EventsQ,&e,1000); if (r != pdTRUE) { log_dbug(TAG,"lost event %d",id); @@ -267,7 +277,7 @@ void event_trigger(event_t id) void event_trigger_nd(event_t id) // no-debug version for syslog only { - struct Event e = {id,0}; + Event e(id); BaseType_t r = xQueueSend(EventsQ,&e,1000); if (r != pdTRUE) ++Lost; @@ -276,34 +286,37 @@ void event_trigger_nd(event_t id) // no-debug version for syslog only void event_trigger_arg(event_t id, void *arg) { - assert(id != 0); - struct Event e = {id,arg}; - log_dbug(TAG,"trigger %d %p",id,arg); - BaseType_t r = xQueueSend(EventsQ,&e,1000); - if (r != pdTRUE) - ++Lost; + if (id != 0) { + Event e(id,arg); + log_dbug(TAG,"trigger %d %p",id,arg); + BaseType_t r = xQueueSend(EventsQ,&e,1000); + if (r != pdTRUE) + ++Lost; + } } void event_isr_trigger(event_t id) { // ! don't log from ISR - assert(id != 0); - Event e = {id,0}; - BaseType_t r = xQueueSendFromISR(EventsQ,&e,0); - if (r != pdTRUE) - ++Lost; + if (id != 0) { + Event e(id); + BaseType_t r = xQueueSendFromISR(EventsQ,&e,0); + if (r != pdTRUE) + ++Lost; + } } -void event_isr_trigger_arg(event_t id,void *arg) +void event_isr_trigger_arg(event_t id, void *arg) { // ! don't log from ISR - assert(id != 0); - Event e = {id,arg}; - BaseType_t r = xQueueSendFromISR(EventsQ,&e,0); - if (r != pdTRUE) - ++Lost; + if (id != 0) { + Event e(id,arg); + BaseType_t r = xQueueSendFromISR(EventsQ,&e,0); + if (r != pdTRUE) + ++Lost; + } } @@ -321,7 +334,6 @@ static void event_task(void *) #endif for (;;) { Event e; - e.id = 0; BaseType_t r = xQueueReceive(EventsQ,&e,dt); if (Lost) { log_warn(TAG,"lost %u events",(unsigned)Lost); diff --git a/components/event/event.h b/components/event/event.h index ff5284f..93ea367 100644 --- a/components/event/event.h +++ b/components/event/event.h @@ -79,6 +79,10 @@ void event_init(void); int event_trigger_en(trigger_t t, bool en); void event_trigger(event_t e); void event_trigger_nd(event_t id); // no-debug version for syslog only + +// Argument must be malloc()'ed by the caller. +// It will be free()'ed by the event infrastructure, because their might +// be != 1 event consumers... void event_trigger_arg(event_t e, void *); void event_isr_trigger(event_t e); void event_isr_trigger_arg(event_t e, void *); diff --git a/components/logging/CMakeLists.txt b/components/logging/CMakeLists.txt index f65451c..3982294 100644 --- a/components/logging/CMakeLists.txt +++ b/components/logging/CMakeLists.txt @@ -3,6 +3,6 @@ #register_component() idf_component_register( SRCS logging.c modules.c profiling.cpp xlog.cpp - REQUIRES tinyusb netsvc streams term + REQUIRES tinyusb netsvc streams term main INCLUDE_DIRS . ) diff --git a/components/logging/logging.c b/components/logging/logging.c index a03231b..0f97d48 100644 --- a/components/logging/logging.c +++ b/components/logging/logging.c @@ -272,7 +272,7 @@ void log_common(log_level_t l, logmod_t m, const char *f, va_list val) buf[s++] = '\n'; if (LogUart >= 0) { if (pdTRUE != xSemaphoreTake(UartLock,MUTEX_ABORT_TIMEOUT)) - abort_on_mutex(UartLock,__FILE__); + abort_on_mutex(UartLock,__BASE_FILE__); uart_write_bytes((uart_port_t)LogUart,buf,s); if (l <= ll_warn) uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY); diff --git a/components/logging/modules.c b/components/logging/modules.c index 8186274..716aabb 100644 --- a/components/logging/modules.c +++ b/components/logging/modules.c @@ -19,7 +19,7 @@ #include "modules.h" const char ModNames[] = - "\0action\0adc\0alarms\0apds\0bh1750\0bmx\0button\0cam\0ccs811b\0cfg\0con\0cyclic\0dht\0dim\0disp\0ds18b20\0event\0fs\0ftpd\0gpio\0hcsr04\0hd44780u\0hdc1000\0hlw8012\0ht16k33\0http\0i2c\0ina219\0inetd\0influx\0init\0led\0ledc\0ledstrip\0log\0lua\0lwtcp\0max7219\0mcp230xx\0mqtt\0nightsky\0ns\0nvm\0ota\0owb\0pca9685\0pcf8574\0relay\0romfs\0screen\0sgp30\0shell\0si7021\0sm\0sntp\0spi\0ssd130x\0sx1276\0telnet\0ti\0timefuse\0tlc5916\0tlc5947\0tp\0uart\0udns\0udpctrl\0usb\0wlan\0ws2812\0www\0xio\0"; + "\0action\0adc\0alarms\0apds\0bh1750\0bmx\0button\0cam\0ccs811b\0cfg\0con\0cyclic\0dht\0dim\0disp\0ds18b20\0event\0fs\0ftpd\0gpio\0hcsr04\0hd44780u\0hdc1000\0hlw8012\0ht16k33\0http\0i2c\0ina219\0inetd\0influx\0init\0led\0ledc\0log\0lua\0lwtcp\0max7219\0mcp230xx\0mqtt\0nightsky\0ns\0nvm\0ota\0owb\0pca9685\0pcf8574\0relay\0rgbleds\0romfs\0screen\0sgp30\0shell\0si7021\0sm\0sntp\0spi\0ssd130x\0sx1276\0tca9555\0telnet\0ti\0timefuse\0tlc5916\0tlc5947\0tp\0uart\0udns\0udpctrl\0usb\0wlan\0ws2812\0www\0xio\0"; const uint16_t ModNameOff[] = { 0, @@ -56,43 +56,44 @@ const uint16_t ModNameOff[] = { 185, // init 190, // led 194, // ledc - 199, // ledstrip - 208, // log - 212, // lua - 216, // lwtcp - 222, // max7219 - 230, // mcp230xx - 239, // mqtt - 244, // nightsky - 253, // ns - 256, // nvm - 260, // ota - 264, // owb - 268, // pca9685 - 276, // pcf8574 - 284, // relay - 290, // romfs - 296, // screen - 303, // sgp30 - 309, // shell - 315, // si7021 - 322, // sm - 325, // sntp - 330, // spi - 334, // ssd130x - 342, // sx1276 - 349, // telnet - 356, // ti - 359, // timefuse - 368, // tlc5916 - 376, // tlc5947 - 384, // tp - 387, // uart - 392, // udns - 397, // udpctrl - 405, // usb - 409, // wlan - 414, // ws2812 - 421, // www - 425, // xio + 199, // log + 203, // lua + 207, // lwtcp + 213, // max7219 + 221, // mcp230xx + 230, // mqtt + 235, // nightsky + 244, // ns + 247, // nvm + 251, // ota + 255, // owb + 259, // pca9685 + 267, // pcf8574 + 275, // relay + 281, // rgbleds + 289, // romfs + 295, // screen + 302, // sgp30 + 308, // shell + 314, // si7021 + 321, // sm + 324, // sntp + 329, // spi + 333, // ssd130x + 341, // sx1276 + 348, // tca9555 + 356, // telnet + 363, // ti + 366, // timefuse + 375, // tlc5916 + 383, // tlc5947 + 391, // tp + 394, // uart + 399, // udns + 404, // udpctrl + 412, // usb + 416, // wlan + 421, // ws2812 + 428, // www + 432, // xio }; diff --git a/components/logging/modules.h b/components/logging/modules.h index 63653ef..bc2342b 100644 --- a/components/logging/modules.h +++ b/components/logging/modules.h @@ -61,21 +61,21 @@ typedef enum logmod_e { logmod_init = 31, logmod_led = 32, logmod_ledc = 33, - logmod_ledstrip = 34, - logmod_log = 35, - logmod_lua = 36, - logmod_lwtcp = 37, - logmod_max7219 = 38, - logmod_mcp230xx = 39, - logmod_mqtt = 40, - logmod_nightsky = 41, - logmod_ns = 42, - logmod_nvm = 43, - logmod_ota = 44, - logmod_owb = 45, - logmod_pca9685 = 46, - logmod_pcf8574 = 47, - logmod_relay = 48, + logmod_log = 34, + logmod_lua = 35, + logmod_lwtcp = 36, + logmod_max7219 = 37, + logmod_mcp230xx = 38, + logmod_mqtt = 39, + logmod_nightsky = 40, + logmod_ns = 41, + logmod_nvm = 42, + logmod_ota = 43, + logmod_owb = 44, + logmod_pca9685 = 45, + logmod_pcf8574 = 46, + logmod_relay = 47, + logmod_rgbleds = 48, logmod_romfs = 49, logmod_screen = 50, logmod_sgp30 = 51, @@ -86,20 +86,21 @@ typedef enum logmod_e { logmod_spi = 56, logmod_ssd130x = 57, logmod_sx1276 = 58, - logmod_telnet = 59, - logmod_ti = 60, - logmod_timefuse = 61, - logmod_tlc5916 = 62, - logmod_tlc5947 = 63, - logmod_tp = 64, - logmod_uart = 65, - logmod_udns = 66, - logmod_udpctrl = 67, - logmod_usb = 68, - logmod_wlan = 69, - logmod_ws2812 = 70, - logmod_www = 71, - logmod_xio = 72, + logmod_tca9555 = 59, + logmod_telnet = 60, + logmod_ti = 61, + logmod_timefuse = 62, + logmod_tlc5916 = 63, + logmod_tlc5947 = 64, + logmod_tp = 65, + logmod_uart = 66, + logmod_udns = 67, + logmod_udpctrl = 68, + logmod_usb = 69, + logmod_wlan = 70, + logmod_ws2812 = 71, + logmod_www = 72, + logmod_xio = 73, } logmod_t; // module defines @@ -136,7 +137,6 @@ typedef enum logmod_e { #define MODULE_INIT logmod_init #define MODULE_LED logmod_led #define MODULE_LEDC logmod_ledc -#define MODULE_LEDSTRIP logmod_ledstrip #define MODULE_LOG logmod_log #define MODULE_LUA logmod_lua #define MODULE_LWTCP logmod_lwtcp @@ -151,6 +151,7 @@ typedef enum logmod_e { #define MODULE_PCA9685 logmod_pca9685 #define MODULE_PCF8574 logmod_pcf8574 #define MODULE_RELAY logmod_relay +#define MODULE_RGBLEDS logmod_rgbleds #define MODULE_ROMFS logmod_romfs #define MODULE_SCREEN logmod_screen #define MODULE_SGP30 logmod_sgp30 @@ -161,6 +162,7 @@ typedef enum logmod_e { #define MODULE_SPI logmod_spi #define MODULE_SSD130X logmod_ssd130x #define MODULE_SX1276 logmod_sx1276 +#define MODULE_TCA9555 logmod_tca9555 #define MODULE_TELNET logmod_telnet #define MODULE_TI logmod_ti #define MODULE_TIMEFUSE logmod_timefuse @@ -175,8 +177,8 @@ typedef enum logmod_e { #define MODULE_WS2812 logmod_ws2812 #define MODULE_WWW logmod_www #define MODULE_XIO logmod_xio -#define MAX_MODULE_ID 72 -#define NUM_MODULES 73 +#define MAX_MODULE_ID 73 +#define NUM_MODULES 74 #ifdef USE_MODULE #define TAG USE_MODULE diff --git a/components/netsvc/CMakeLists.txt b/components/netsvc/CMakeLists.txt index 4ed96ab..1efecd7 100644 --- a/components/netsvc/CMakeLists.txt +++ b/components/netsvc/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register( SRCS netsvc.c tcpio.c lwtcp.cpp udns.cpp usntp.cpp - INCLUDE_DIRS . + INCLUDE_DIRS . ../../main PRIV_REQUIRES actions cyclic event logging ) diff --git a/components/wfc/hwcfg_esp32.cpp b/components/wfc/hwcfg_esp32.cpp index cda00b8..0b91caf 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -293,6 +293,7 @@ static const char *i2cdrv_t_names[] = { "i2cdrv_pca9685_xclk_pnp", "i2cdrv_pcf8574", "i2cdrv_si7021", + "i2cdrv_tca9555", }; static i2cdrv_t i2cdrv_t_values[] = { @@ -309,6 +310,7 @@ static i2cdrv_t i2cdrv_t_values[] = { i2cdrv_pca9685_xclk_pnp, i2cdrv_pcf8574, i2cdrv_si7021, + i2cdrv_tca9555, }; #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB @@ -329,6 +331,7 @@ size_t parse_ascii_i2cdrv_t(i2cdrv_t *v, const char *s) { "i2cdrv_pca9685_xclk_pnp", i2cdrv_pca9685_xclk_pnp}, { "i2cdrv_pcf8574", i2cdrv_pcf8574}, { "i2cdrv_si7021", i2cdrv_si7021}, + { "i2cdrv_tca9555", i2cdrv_tca9555}, }; #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB char *e; @@ -386,6 +389,8 @@ const char *i2cdrv_t_str(i2cdrv_t e) return "i2cdrv_ina219"; case i2cdrv_si7021: return "i2cdrv_si7021"; + case i2cdrv_tca9555: + return "i2cdrv_tca9555"; } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB #ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB @@ -3228,7 +3233,8 @@ Message *Tlc5947Config::p_getMember(const char *s, const char *e, unsigned x) } Ws2812bConfig::Ws2812bConfig() -: m_gpio(-1) +: m_name() +, m_gpio(-1) , m_ch(-1) , m_nleds(0) { @@ -3239,6 +3245,7 @@ void Ws2812bConfig::clear() m_gpio = -1; m_ch = -1; m_nleds = 0; + m_name.clear(); } void Ws2812bConfig::toASCII(stream &o, size_t indent) const @@ -3248,6 +3255,7 @@ void Ws2812bConfig::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "gpio", (signed) m_gpio); ascii_numeric(o, indent, "ch", (signed) m_ch); ascii_numeric(o, indent, "nleds", (unsigned) m_nleds); + ascii_string(o,indent,m_name.data(),m_name.size(),"name"); --indent; ascii_indent(o,indent); o << '}'; @@ -3294,12 +3302,23 @@ ssize_t Ws2812bConfig::fromMemory(const void *b, ssize_t s) set_nleds(v); } break; + case 0x22: // name id 4, type estring, coding byte[] + { + varint_t v; + int n = read_varint(a,e-a,&v); + a += n; + if ((n <= 0) || ((a+v) > e)) + return -152; + m_name.assign((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 -152; + return -153; a += s; break; } @@ -3307,7 +3326,7 @@ ssize_t Ws2812bConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -153; + return -154; return a-(const uint8_t *)b; } @@ -3320,34 +3339,48 @@ ssize_t Ws2812bConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -154; + return -155; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -155; + return -156; a += n; } // has ch? if (m_ch != -1) { // 'ch': id=2, encoding=varint, tag=0x10 if (a >= e) - return -156; + return -157; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_ch)); if (n <= 0) - return -157; + return -158; a += n; } // has nleds? if (m_nleds != 0) { // 'nleds': id=3, encoding=varint, tag=0x18 if (a >= e) - return -158; + return -159; *a++ = 0x18; n = write_varint(a,e-a,m_nleds); if (n <= 0) - return -159; + return -160; + a += n; + } + // has name? + if (!m_name.empty()) { + // 'name': id=4, encoding=lenpfx, tag=0x22 + if (a >= e) + return -161; + *a++ = 0x22; + 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 -162; + memcpy(a,m_name.data(),name_s); + a += name_s; } assert(a <= e); return a-b; @@ -3369,6 +3402,10 @@ void Ws2812bConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"nleds"); json << (unsigned) m_nleds; } + if (has_name()) { + fsep = json_indent(json,indLvl,fsep,"name"); + json_cstr(json,m_name.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -3394,6 +3431,11 @@ size_t Ws2812bConfig::calcSize() const if (m_nleds != 0) { r += wiresize((varint_t)m_nleds) + 1 /* tag(nleds) 0x18 */; } + // optional string name, id 4 + if (!m_name.empty()) { + size_t name_s = m_name.size(); + r += name_s + wiresize(name_s) + 1 /* tag(name) 0x20 */; + } return r; } @@ -3405,6 +3447,8 @@ bool Ws2812bConfig::operator != (const Ws2812bConfig &r) const return true; if (has_nleds() && (m_nleds != r.m_nleds)) return true; + if (has_name() && (m_name != r.m_name)) + return true; return false; } @@ -3448,7 +3492,16 @@ int Ws2812bConfig::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_nleds,value); return r; } - return -160; + if (0 == strcmp(name,"name")) { + if (value == 0) { + clear_name(); + return 0; + } + m_name = value; + int r = m_name.size(); + return r; + } + return -163; } Message *Ws2812bConfig::p_getMember(const char *s, const char *e) @@ -3497,7 +3550,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -161; + return -164; a += fn; switch (fid) { case 0x8: // model id 1, type dht_model_t, coding varint @@ -3505,7 +3558,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -162; + return -165; a += n; set_model((dht_model_t) v); } @@ -3515,7 +3568,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -163; + return -166; a += n; set_gpio(varint_sint(v)); } @@ -3525,7 +3578,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -164; + return -167; a += s; break; } @@ -3533,7 +3586,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -165; + return -168; return a-(const uint8_t *)b; } @@ -3546,22 +3599,22 @@ ssize_t DhtConfig::toMemory(uint8_t *b, ssize_t s) const if (m_model != DHT_NONE) { // 'model': id=1, encoding=varint, tag=0x8 if (a >= e) - return -166; + return -169; *a++ = 0x8; n = write_varint(a,e-a,m_model); if (n <= 0) - return -167; + return -170; a += n; } // has gpio? if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -168; + return -171; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -169; + return -172; a += n; } assert(a <= e); @@ -3643,7 +3696,7 @@ int DhtConfig::setByName(const char *name, const char *value) dht_model_t v; size_t r = parse_ascii_dht_model_t(&v,value); if (r == 0) - return -170; + return -173; set_model(v); return r; } @@ -3655,7 +3708,7 @@ int DhtConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_gpio,value); return r; } - return -171; + return -174; } Message *DhtConfig::p_getMember(const char *s, const char *e) @@ -3739,7 +3792,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -172; + return -175; a += fn; switch (fid) { case 0x8: // port id 1, type uint8_t, coding varint @@ -3747,7 +3800,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -173; + return -176; a += n; set_port(v); } @@ -3757,7 +3810,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -174; + return -177; a += n; set_sda(varint_sint(v)); } @@ -3767,7 +3820,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -175; + return -178; a += n; set_scl(varint_sint(v)); } @@ -3777,14 +3830,14 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -176; + return -179; a += n; set_freq(v); } break; case 0x2b: // xpullup id 5, type bool, coding 8bit if (a >= e) - return -177; + return -180; set_xpullup(*a++); break; #ifdef CONFIG_I2C_XDEV @@ -3792,14 +3845,14 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); // length of packed if (n <= 0) - return -178; + return -181; a += n; const uint8_t *ae = a + v; do { varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -179; + return -182; a += n; m_devices.push_back((i2cdev_t)v); } while (a < ae); @@ -3810,7 +3863,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -180; + return -183; a += s; break; } @@ -3818,7 +3871,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -181; + return -184; return a-(const uint8_t *)b; } @@ -3831,51 +3884,51 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -182; + return -185; *a++ = 0x8; n = write_varint(a,e-a,m_port); if (n <= 0) - return -183; + return -186; a += n; } // has sda? if (m_sda != -1) { // 'sda': id=2, encoding=varint, tag=0x10 if (a >= e) - return -184; + return -187; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sda)); if (n <= 0) - return -185; + return -188; a += n; } // has scl? if (m_scl != -1) { // 'scl': id=3, encoding=varint, tag=0x18 if (a >= e) - return -186; + return -189; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_scl)); if (n <= 0) - return -187; + return -190; a += n; } // has freq? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'freq': id=4, encoding=varint, tag=0x20 if (a >= e) - return -188; + return -191; *a++ = 0x20; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -189; + return -192; a += n; } // has xpullup? if (m_xpullup != false) { // 'xpullup': id=5, encoding=8bit, tag=0x2b if (2 > (e-a)) - return -190; + return -193; *a++ = 0x2b; *a++ = m_xpullup; } @@ -3883,7 +3936,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -191; + return -194; *a++ = 0x32; ssize_t devices_ws = 0; for (size_t x = 0; x != devices_ne; ++x) @@ -3891,7 +3944,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -192; + return -195; for (size_t x = 0; x != devices_ne; ++x) a += write_varint(a,e-a,m_devices[x]); } @@ -4087,10 +4140,10 @@ int I2CConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -193; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -196; if (m_devices.size() <= x) - return -194; + return -197; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; @@ -4103,7 +4156,7 @@ int I2CConfig::setByName(const char *name, const char *value) return eptr - value; } if (idxe[1] != '.') - return -195; + return -198; idxe += 2; if (!strcmp("addr",idxe)) { if (eptr != value) { @@ -4124,11 +4177,11 @@ int I2CConfig::setByName(const char *name, const char *value) } } } - return -196; + return -199; } } #endif // CONFIG_I2C_XDEV - return -197; + return -200; } Message *I2CConfig::p_getMember(const char *s, const char *e) @@ -4175,7 +4228,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -198; + return -201; a += fn; switch (fid) { case 0x8: // trigger id 1, type int8_t, coding signed varint @@ -4183,7 +4236,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -199; + return -202; a += n; set_trigger(varint_sint(v)); } @@ -4193,7 +4246,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -200; + return -203; a += n; set_echo(varint_sint(v)); } @@ -4204,7 +4257,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -201; + return -204; m_name.assign((const char*)a,v); a += v; } @@ -4214,7 +4267,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -202; + return -205; a += s; break; } @@ -4222,7 +4275,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -203; + return -206; return a-(const uint8_t *)b; } @@ -4235,35 +4288,35 @@ ssize_t HcSr04Config::toMemory(uint8_t *b, ssize_t s) const if (m_trigger != -1) { // 'trigger': id=1, encoding=varint, tag=0x8 if (a >= e) - return -204; + return -207; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_trigger)); if (n <= 0) - return -205; + return -208; a += n; } // has echo? if (m_echo != -1) { // 'echo': id=2, encoding=varint, tag=0x10 if (a >= e) - return -206; + return -209; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_echo)); if (n <= 0) - return -207; + return -210; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -208; + return -211; *a++ = 0x1a; 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 -209; + return -212; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -4368,7 +4421,7 @@ int HcSr04Config::setByName(const char *name, const char *value) int r = m_name.size(); return r; } - return -210; + return -213; } Message *HcSr04Config::p_getMember(const char *s, const char *e) @@ -4428,7 +4481,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -211; + return -214; a += fn; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -4436,7 +4489,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -212; + return -215; a += n; set_gpio(varint_sint(v)); } @@ -4446,7 +4499,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -213; + return -216; a += n; set_config((ledcfg_t) v); } @@ -4457,7 +4510,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -214; + return -217; m_name.assign((const char*)a,v); a += v; } @@ -4467,7 +4520,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -215; + return -218; a += n; set_pwm_ch(varint_sint(v)); } @@ -4477,7 +4530,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -216; + return -219; a += s; break; } @@ -4485,7 +4538,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -217; + return -220; return a-(const uint8_t *)b; } @@ -4498,35 +4551,35 @@ ssize_t LedConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -218; + return -221; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -219; + return -222; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=2, encoding=varint, tag=0x10 if (a >= e) - return -220; + return -223; *a++ = 0x10; n = write_varint(a,e-a,m_config); if (n <= 0) - return -221; + return -224; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -222; + return -225; *a++ = 0x1a; 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 -223; + return -226; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -4534,11 +4587,11 @@ ssize_t LedConfig::toMemory(uint8_t *b, ssize_t s) const if (m_pwm_ch != -1) { // 'pwm_ch': id=4, encoding=varint, tag=0x20 if (a >= e) - return -224; + return -227; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_pwm_ch)); if (n <= 0) - return -225; + return -228; a += n; } assert(a <= e); @@ -4652,7 +4705,7 @@ int LedConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -226; + return -229; } else if (!strcmp(name,"active_high")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -4685,7 +4738,7 @@ int LedConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_pwm_ch,value); return r; } - return -227; + return -230; } Message *LedConfig::p_getMember(const char *s, const char *e) @@ -4732,7 +4785,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -228; + return -231; a += fn; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -4740,14 +4793,14 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -229; + return -232; a += n; set_gpio(varint_sint(v)); } break; case 0x13: // pullup id 2, type bool, coding 8bit if (a >= e) - return -230; + return -233; set_pullup(*a++); break; case 0x18: // power id 3, type int8_t, coding signed varint @@ -4755,7 +4808,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -231; + return -234; a += n; set_power(varint_sint(v)); } @@ -4765,7 +4818,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -232; + return -235; a += s; break; } @@ -4773,7 +4826,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -233; + return -236; return a-(const uint8_t *)b; } @@ -4786,18 +4839,18 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -234; + return -237; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -235; + return -238; a += n; } // has pullup? if (m_pullup != false) { // 'pullup': id=2, encoding=8bit, tag=0x13 if (2 > (e-a)) - return -236; + return -239; *a++ = 0x13; *a++ = m_pullup; } @@ -4805,11 +4858,11 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_power != -1) { // 'power': id=3, encoding=varint, tag=0x18 if (a >= e) - return -237; + return -240; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_power)); if (n <= 0) - return -238; + return -241; a += n; } assert(a <= e); @@ -4911,7 +4964,7 @@ int OneWireConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_power,value); return r; } - return -239; + return -242; } Message *OneWireConfig::p_getMember(const char *s, const char *e) @@ -4964,7 +5017,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -240; + return -243; a += fn; switch (fid) { case 0x8: // port id 1, type int8_t, coding signed varint @@ -4972,7 +5025,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -241; + return -244; a += n; set_port(varint_sint(v)); } @@ -4982,7 +5035,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -242; + return -245; a += n; set_tx_gpio(varint_sint(v)); } @@ -4992,7 +5045,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -243; + return -246; a += n; set_rx_gpio(varint_sint(v)); } @@ -5002,7 +5055,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -244; + return -247; a += n; set_cts_gpio(varint_sint(v)); } @@ -5012,7 +5065,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -245; + return -248; a += n; set_rts_gpio(varint_sint(v)); } @@ -5022,7 +5075,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -246; + return -249; a += s; break; } @@ -5030,7 +5083,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -247; + return -250; return a-(const uint8_t *)b; } @@ -5043,55 +5096,55 @@ ssize_t UartConfig::toMemory(uint8_t *b, ssize_t s) const if (m_port != -1) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -248; + return -251; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_port)); if (n <= 0) - return -249; + return -252; a += n; } // has tx_gpio? if (m_tx_gpio != -1) { // 'tx_gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -250; + return -253; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_tx_gpio)); if (n <= 0) - return -251; + return -254; a += n; } // has rx_gpio? if (m_rx_gpio != -1) { // 'rx_gpio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -252; + return -255; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_rx_gpio)); if (n <= 0) - return -253; + return -256; a += n; } // has cts_gpio? if (m_cts_gpio != -1) { // 'cts_gpio': id=4, encoding=varint, tag=0x20 if (a >= e) - return -254; + return -257; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cts_gpio)); if (n <= 0) - return -255; + return -258; a += n; } // has rts_gpio? if (m_rts_gpio != -1) { // 'rts_gpio': id=5, encoding=varint, tag=0x28 if (a >= e) - return -256; + return -259; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_rts_gpio)); if (n <= 0) - return -257; + return -260; a += n; } assert(a <= e); @@ -5229,7 +5282,7 @@ int UartConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_rts_gpio,value); return r; } - return -258; + return -261; } Message *UartConfig::p_getMember(const char *s, const char *e) @@ -5244,6 +5297,9 @@ Message *UartConfig::p_getMember(const char *s, const char *e, unsigned x) AdcChannel::AdcChannel() : m_name() +, m_dim() +, m_scale(1) +, m_offset(0) , m_interval(0) , m_unit(0) , m_ch(-1) @@ -5261,6 +5317,9 @@ void AdcChannel::clear() m_atten = 0; m_interval = 0; m_window = 0; + m_scale = 1; + m_offset = 0; + m_dim.clear(); p_validbits = 0; } @@ -5274,6 +5333,9 @@ void AdcChannel::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "atten", (unsigned) m_atten); ascii_numeric(o, indent, "interval", m_interval); ascii_numeric(o, indent, "window", (unsigned) m_window); + ascii_numeric(o, indent, "scale", m_scale); + ascii_numeric(o, indent, "offset", m_offset); + ascii_string(o,indent,m_dim.data(),m_dim.size(),"dim"); --indent; ascii_indent(o,indent); o << '}'; @@ -5287,7 +5349,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -259; + return -262; a += fn; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] @@ -5296,7 +5358,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -260; + return -263; m_name.assign((const char*)a,v); a += v; } @@ -5306,7 +5368,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -261; + return -264; a += n; set_unit(v); } @@ -5316,7 +5378,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -262; + return -265; a += n; set_ch(varint_sint(v)); } @@ -5326,7 +5388,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -263; + return -266; a += n; set_atten(v); } @@ -5336,7 +5398,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -264; + return -267; a += n; set_interval(v); } @@ -5346,17 +5408,41 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -265; + return -268; a += n; set_window(v); } break; + case 0x45: // scale id 8, type float, coding 32bit + if ((a+3) >= e) + return -269; + set_scale(read_float(a)); + a += 4; + break; + case 0x4d: // offset id 9, type float, coding 32bit + if ((a+3) >= e) + return -270; + set_offset(read_float(a)); + a += 4; + break; + case 0x52: // dim id 10, type estring, coding byte[] + { + varint_t v; + int n = read_varint(a,e-a,&v); + a += n; + if ((n <= 0) || ((a+v) > e)) + return -271; + m_dim.assign((const char*)a,v); + a += v; + } + p_validbits |= ((uint8_t)1U << 3); + break; default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -266; + return -272; a += s; break; } @@ -5364,7 +5450,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -267; + return -273; return a-(const uint8_t *)b; } @@ -5377,13 +5463,13 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -268; + return -274; *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 -269; + return -275; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -5391,57 +5477,93 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const if (m_unit != 0) { // 'unit': id=2, encoding=varint, tag=0x10 if (a >= e) - return -270; + return -276; *a++ = 0x10; n = write_varint(a,e-a,m_unit); if (n <= 0) - return -271; + return -277; a += n; } // has ch? if (m_ch != -1) { // 'ch': id=3, encoding=varint, tag=0x18 if (a >= e) - return -272; + return -278; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_ch)); if (n <= 0) - return -273; + return -279; a += n; } // has atten? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'atten': id=4, encoding=varint, tag=0x20 if (a >= e) - return -274; + return -280; *a++ = 0x20; n = write_varint(a,e-a,m_atten); if (n <= 0) - return -275; + return -281; a += n; } // has interval? if (m_interval != 0) { // 'interval': id=5, encoding=varint, tag=0x28 if (a >= e) - return -276; + return -282; *a++ = 0x28; n = write_varint(a,e-a,m_interval); if (n <= 0) - return -277; + return -283; a += n; } // has window? if (m_window != 0) { // 'window': id=6, encoding=varint, tag=0x30 if (a >= e) - return -278; + return -284; *a++ = 0x30; n = write_varint(a,e-a,m_window); if (n <= 0) - return -279; + return -285; a += n; } + // has scale? + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + // 'scale': id=8, encoding=32bit, tag=0x45 + if (5 > (e-a)) + return -286; + *a++ = 0x45; + if ((e-a) < 4) + return -287; + write_u32(a,mangle_float(m_scale)); + a += 4; + } + // has offset? + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + // 'offset': id=9, encoding=32bit, tag=0x4d + if (5 > (e-a)) + return -288; + *a++ = 0x4d; + if ((e-a) < 4) + return -289; + write_u32(a,mangle_float(m_offset)); + a += 4; + } + // has dim? + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + // 'dim': id=10, encoding=lenpfx, tag=0x52 + if (a >= e) + return -290; + *a++ = 0x52; + ssize_t dim_s = m_dim.size(); + n = write_varint(a,e-a,dim_s); + a += n; + if ((n <= 0) || ((e-a) < dim_s)) + return -291; + memcpy(a,m_dim.data(),dim_s); + a += dim_s; + } assert(a <= e); return a-b; } @@ -5474,6 +5596,18 @@ void AdcChannel::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"window"); json << (unsigned) m_window; } + if (has_scale()) { + fsep = json_indent(json,indLvl,fsep,"scale"); + to_dblstr(json,m_scale); + } + if (has_offset()) { + fsep = json_indent(json,indLvl,fsep,"offset"); + to_dblstr(json,m_offset); + } + if (has_dim()) { + fsep = json_indent(json,indLvl,fsep,"dim"); + json_cstr(json,m_dim.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -5512,6 +5646,19 @@ size_t AdcChannel::calcSize() const if (m_window != 0) { r += wiresize((varint_t)m_window) + 1 /* tag(window) 0x30 */; } + // optional float scale, id 8 + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + r += 5; + } + // optional float offset, id 9 + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + r += 5; + } + // optional string dim, id 10 + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + size_t dim_s = m_dim.size(); + r += dim_s + wiresize(dim_s) + 1 /* tag(dim) 0x50 */; + } return r; } @@ -5531,6 +5678,12 @@ bool AdcChannel::operator != (const AdcChannel &r) const return true; if (has_window() && (m_window != r.m_window)) return true; + if (has_scale() && (m_scale != r.m_scale)) + return true; + if (has_offset() && (m_offset != r.m_offset)) + return true; + if (has_dim() && (m_dim != r.m_dim)) + return true; return false; } @@ -5601,7 +5754,38 @@ int AdcChannel::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_window,value); return r; } - return -280; + if (0 == strcmp(name,"scale")) { + if (value == 0) { + clear_scale(); + return 0; + } + int r = parse_ascii_flt(&m_scale,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 1); + return r; + } + if (0 == strcmp(name,"offset")) { + if (value == 0) { + clear_offset(); + return 0; + } + int r = parse_ascii_flt(&m_offset,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 2); + return r; + } + if (0 == strcmp(name,"dim")) { + if (value == 0) { + clear_dim(); + return 0; + } + m_dim = value; + int r = m_dim.size(); + if (r > 0) + p_validbits |= ((uint8_t)1U << 3); + return r; + } + return -292; } Message *AdcChannel::p_getMember(const char *s, const char *e) @@ -5668,7 +5852,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -281; + return -293; a += fn; switch (fid) { case 0xa: // adc_name id 1, type estring, coding byte[] @@ -5677,7 +5861,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -282; + return -294; m_adc_name.assign((const char*)a,v); a += v; } @@ -5687,7 +5871,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -283; + return -295; a += n; set_adc1_bits(v); } @@ -5697,7 +5881,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -284; + return -296; a += n; set_adc2_bits(v); } @@ -5708,7 +5892,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -285; + return -297; m_hall_name.assign((const char*)a,v); a += v; } @@ -5719,14 +5903,14 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -286; + return -298; m_channels.emplace_back(); if (v != 0) { n = m_channels.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -287; + return -299; a += v; } } @@ -5736,7 +5920,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -288; + return -300; a += s; break; } @@ -5744,7 +5928,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -289; + return -301; return a-(const uint8_t *)b; } @@ -5757,13 +5941,13 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_adc_name.empty()) { // 'adc_name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -290; + return -302; *a++ = 0xa; ssize_t adc_name_s = m_adc_name.size(); n = write_varint(a,e-a,adc_name_s); a += n; if ((n <= 0) || ((e-a) < adc_name_s)) - return -291; + return -303; memcpy(a,m_adc_name.data(),adc_name_s); a += adc_name_s; } @@ -5771,22 +5955,22 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'adc1_bits': id=2, encoding=varint, tag=0x10 if (a >= e) - return -292; + return -304; *a++ = 0x10; n = write_varint(a,e-a,m_adc1_bits); if (n <= 0) - return -293; + return -305; a += n; } // has adc2_bits? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'adc2_bits': id=3, encoding=varint, tag=0x18 if (a >= e) - return -294; + return -306; *a++ = 0x18; n = write_varint(a,e-a,m_adc2_bits); if (n <= 0) - return -295; + return -307; a += n; } // 'mode' is unused. Therefore no data will be written. @@ -5795,26 +5979,26 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_hall_name.empty()) { // 'hall_name': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -296; + return -308; *a++ = 0x32; ssize_t hall_name_s = m_hall_name.size(); n = write_varint(a,e-a,hall_name_s); a += n; if ((n <= 0) || ((e-a) < hall_name_s)) - return -297; + return -309; memcpy(a,m_hall_name.data(),hall_name_s); a += hall_name_s; } for (const auto &x : m_channels) { // 'channels': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -298; + return -310; *a++ = 0x3a; ssize_t channels_ws = x.calcSize(); n = write_varint(a,e-a,channels_ws); a += n; if ((n <= 0) || (channels_ws > (e-a))) - return -299; + return -311; n = x.toMemory(a,e-a); a += n; assert(n == channels_ws); @@ -5990,21 +6174,21 @@ int AdcConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -300; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -312; if (m_channels.size() <= x) - return -301; + return -313; if ((idxe[1] == 0) && (value == 0)) { m_channels.erase(m_channels.begin()+x); return 0; } } if (idxe[1] != '.') - return -302; + return -314; return m_channels[x].setByName(idxe+2,value); } } - return -303; + return -315; } Message *AdcConfig::p_getMember(const char *s, const char *e) @@ -6083,7 +6267,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -304; + return -316; a += fn; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] @@ -6092,7 +6276,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -305; + return -317; m_name.assign((const char*)a,v); a += v; } @@ -6103,7 +6287,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -306; + return -318; a += n; set_gpio(varint_sint(v)); } @@ -6113,7 +6297,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -307; + return -319; a += n; set_config((gpiocfg_t) v); } @@ -6123,7 +6307,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -308; + return -320; a += s; break; } @@ -6131,7 +6315,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -309; + return -321; return a-(const uint8_t *)b; } @@ -6144,13 +6328,13 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -310; + return -322; *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 -311; + return -323; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -6158,22 +6342,22 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -312; + return -324; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -313; + return -325; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) - return -314; + return -326; *a++ = 0x18; n = write_varint(a,e-a,m_config); if (n <= 0) - return -315; + return -327; a += n; } assert(a <= e); @@ -6298,7 +6482,7 @@ int GpioConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -316; + return -328; } else if (!strcmp(name,"mode")) { uint8_t tmp; size_t r = parse_ascii_u8(&tmp,value); @@ -6344,7 +6528,7 @@ int GpioConfig::setByName(const char *name, const char *value) } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB } - return -317; + return -329; } Message *GpioConfig::p_getMember(const char *s, const char *e) @@ -6401,7 +6585,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -318; + return -330; a += fn; switch (fid) { case 0x8: // type id 1, type disp_t, coding varint @@ -6409,7 +6593,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -319; + return -331; a += n; set_type((disp_t) v); } @@ -6419,7 +6603,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -320; + return -332; a += n; set_options(v); } @@ -6429,7 +6613,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -321; + return -333; a += n; set_maxx(v); } @@ -6439,7 +6623,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -322; + return -334; a += n; set_maxy(v); } @@ -6449,7 +6633,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -323; + return -335; a += s; break; } @@ -6457,7 +6641,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -324; + return -336; return a-(const uint8_t *)b; } @@ -6470,44 +6654,44 @@ 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 -325; + return -337; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -326; + return -338; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -327; + return -339; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -328; + return -340; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -329; + return -341; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -330; + return -342; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -331; + return -343; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -332; + return -344; a += n; } assert(a <= e); @@ -6611,7 +6795,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 -333; + return -345; set_type(v); return r; } @@ -6645,7 +6829,7 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -334; + return -346; } Message *DisplayConfig::p_getMember(const char *s, const char *e) @@ -6703,7 +6887,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 -335; + return -347; a += fn; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -6711,7 +6895,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 -336; + return -348; a += n; set_drv((spidrv_t) v); } @@ -6721,7 +6905,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 -337; + return -349; a += n; set_cs(varint_sint(v)); } @@ -6731,7 +6915,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 -338; + return -350; a += n; set_intr(varint_sint(v)); } @@ -6741,7 +6925,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 -339; + return -351; a += n; set_reset(varint_sint(v)); } @@ -6751,7 +6935,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 -340; + return -352; a += n; set_cd(varint_sint(v)); } @@ -6761,7 +6945,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 -341; + return -353; a += s; break; } @@ -6769,7 +6953,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -342; + return -354; return a-(const uint8_t *)b; } @@ -6782,55 +6966,55 @@ 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 -343; + return -355; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -344; + return -356; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -345; + return -357; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -346; + return -358; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -347; + return -359; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -348; + return -360; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -349; + return -361; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -350; + return -362; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -351; + return -363; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -352; + return -364; a += n; } assert(a <= e); @@ -6942,7 +7126,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 -353; + return -365; set_drv(v); return r; } @@ -6978,7 +7162,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cd,value); return r; } - return -354; + return -366; } Message *SpiDeviceConfig::p_getMember(const char *s, const char *e) @@ -7078,7 +7262,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 -355; + return -367; a += fn; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -7086,7 +7270,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 -356; + return -368; a += n; set_host(varint_sint(v)); } @@ -7096,7 +7280,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 -357; + return -369; a += n; set_mosi(varint_sint(v)); } @@ -7106,7 +7290,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 -358; + return -370; a += n; set_miso(varint_sint(v)); } @@ -7116,7 +7300,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 -359; + return -371; a += n; set_sclk(varint_sint(v)); } @@ -7126,7 +7310,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 -360; + return -372; a += n; set_wp(varint_sint(v)); } @@ -7136,7 +7320,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 -361; + return -373; a += n; set_hold(varint_sint(v)); } @@ -7146,7 +7330,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 -362; + return -374; a += n; set_options((spiopt_t) v); } @@ -7156,7 +7340,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 -363; + return -375; a += n; set_dma(varint_sint(v)); } @@ -7167,14 +7351,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 -364; + return -376; 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 -365; + return -377; a += v; } } @@ -7184,7 +7368,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 -366; + return -378; a += s; break; } @@ -7192,7 +7376,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -367; + return -379; return a-(const uint8_t *)b; } @@ -7205,100 +7389,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 -368; + return -380; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -369; + return -381; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -370; + return -382; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -371; + return -383; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -372; + return -384; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -373; + return -385; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -374; + return -386; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -375; + return -387; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -376; + return -388; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -377; + return -389; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -378; + return -390; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -379; + return -391; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -380; + return -392; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -381; + return -393; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -382; + return -394; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -383; + return -395; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -384; + return -396; *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 -385; + return -397; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -7530,7 +7714,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -386; + return -398; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -7599,21 +7783,21 @@ int SpiBusConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -387; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -399; if (m_devices.size() <= x) - return -388; + return -400; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -389; + return -401; return m_devices[x].setByName(idxe+2,value); } } - return -390; + return -402; } Message *SpiBusConfig::p_getMember(const char *s, const char *e) @@ -7671,7 +7855,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 -391; + return -403; a += fn; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] @@ -7680,7 +7864,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 -392; + return -404; m_name.assign((const char*)a,v); a += v; } @@ -7690,7 +7874,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 -393; + return -405; a += n; set_base(v); } @@ -7700,7 +7884,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 -394; + return -406; a += n; set_numio(v); } @@ -7710,7 +7894,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 -395; + return -407; a += n; set_int_a(varint_sint(v)); } @@ -7720,7 +7904,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 -396; + return -408; a += n; set_int_b(varint_sint(v)); } @@ -7730,7 +7914,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 -397; + return -409; a += s; break; } @@ -7738,7 +7922,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -398; + return -410; return a-(const uint8_t *)b; } @@ -7751,13 +7935,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 -399; + return -411; *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 -400; + return -412; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -7765,44 +7949,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 -401; + return -413; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -402; + return -414; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -403; + return -415; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -404; + return -416; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -405; + return -417; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -406; + return -418; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -407; + return -419; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -408; + return -420; a += n; } assert(a <= e); @@ -7942,7 +8126,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -409; + return -421; } Message *GpioCluster::p_getMember(const char *s, const char *e) @@ -7989,7 +8173,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 -410; + return -422; a += fn; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -7997,7 +8181,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 -411; + return -423; a += n; set_sel(varint_sint(v)); } @@ -8007,7 +8191,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 -412; + return -424; a += n; set_cf(varint_sint(v)); } @@ -8017,7 +8201,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 -413; + return -425; a += n; set_cf1(varint_sint(v)); } @@ -8027,7 +8211,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 -414; + return -426; a += s; break; } @@ -8035,7 +8219,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -415; + return -427; return a-(const uint8_t *)b; } @@ -8048,33 +8232,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 -416; + return -428; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -417; + return -429; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -418; + return -430; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -419; + return -431; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -420; + return -432; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -421; + return -433; a += n; } assert(a <= e); @@ -8176,7 +8360,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -422; + return -434; } Message *Hlw8012Config::p_getMember(const char *s, const char *e) @@ -8232,7 +8416,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 -423; + return -435; a += fn; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -8240,7 +8424,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 -424; + return -436; a += n; set_dio0(varint_sint(v)); } @@ -8250,7 +8434,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 -425; + return -437; a += n; set_dio1(varint_sint(v)); } @@ -8260,7 +8444,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 -426; + return -438; a += n; set_dio2(varint_sint(v)); } @@ -8270,7 +8454,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 -427; + return -439; a += n; set_dio3(varint_sint(v)); } @@ -8280,7 +8464,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 -428; + return -440; a += n; set_dio4(varint_sint(v)); } @@ -8290,7 +8474,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 -429; + return -441; a += n; set_dio5(varint_sint(v)); } @@ -8300,7 +8484,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 -430; + return -442; a += s; break; } @@ -8308,7 +8492,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -431; + return -443; return a-(const uint8_t *)b; } @@ -8321,66 +8505,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 -432; + return -444; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -433; + return -445; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -434; + return -446; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -435; + return -447; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -436; + return -448; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -437; + return -449; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -438; + return -450; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -439; + return -451; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -440; + return -452; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -441; + return -453; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -442; + return -454; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -443; + return -455; a += n; } assert(a <= e); @@ -8536,7 +8720,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -444; + return -456; } Message *SX1276Config::p_getMember(const char *s, const char *e) @@ -8770,8 +8954,18 @@ void HardwareConfig::toASCII(stream &o, size_t indent) const m_tlc5947.toASCII(o,indent); #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - ascii_indent(o,indent,"ws2812b"); - m_ws2812b.toASCII(o,indent); + ascii_indent(o,indent); + size_t s_ws2812b = m_ws2812b.size(); + o << "ws2812b[" << s_ws2812b << "] = {"; + ++indent; + for (size_t i = 0, e = s_ws2812b; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + m_ws2812b[i].toASCII(o,indent); + } + --indent; + ascii_indent(o,indent); + o << '}'; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT ascii_indent(o,indent,"dht"); @@ -8844,12 +9038,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 -445; + return -457; a += fn; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit if ((a+3) >= e) - return -446; + return -458; set_magic((uint32_t) read_u32(a)); a += 4; break; @@ -8859,13 +9053,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 -447; + return -459; if (v != 0) { n = m_system.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -448; + return -460; a += v; } } @@ -8877,14 +9071,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 -449; + return -461; 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 -450; + return -462; a += v; } } @@ -8895,13 +9089,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 -451; + return -463; if (v != 0) { n = m_adc.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -452; + return -464; a += v; } } @@ -8914,13 +9108,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 -453; + return -465; if (v != 0) { n = m_touchpad.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -454; + return -466; a += v; } } @@ -8934,14 +9128,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 -455; + return -467; 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 -456; + return -468; a += v; } } @@ -8953,14 +9147,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 -457; + return -469; m_gpio.emplace_back(); if (v != 0) { n = m_gpio.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -458; + return -470; a += v; } } @@ -8972,14 +9166,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 -459; + return -471; 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 -460; + return -472; a += v; } } @@ -8992,14 +9186,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 -461; + return -473; 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 -462; + return -474; a += v; } } @@ -9012,14 +9206,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 -463; + return -475; 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 -464; + return -476; a += v; } } @@ -9032,14 +9226,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 -465; + return -477; 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 -466; + return -478; a += v; } } @@ -9052,13 +9246,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 -467; + return -479; if (v != 0) { n = m_hlw8012.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -468; + return -480; a += v; } } @@ -9072,13 +9266,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 -469; + return -481; if (v != 0) { n = m_max7219.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -470; + return -482; a += v; } } @@ -9092,13 +9286,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 -471; + return -483; if (v != 0) { n = m_tlc5947.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -472; + return -484; a += v; } } @@ -9112,17 +9306,17 @@ 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 -473; + return -485; + m_ws2812b.emplace_back(); if (v != 0) { - n = m_ws2812b.fromMemory((const uint8_t*)a,v); + n = m_ws2812b.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -474; + return -486; a += v; } } - p_validbits |= ((uint16_t)1U << 7); break; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -9132,17 +9326,17 @@ 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 -475; + return -487; if (v != 0) { n = m_dht.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -476; + return -488; a += v; } } - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); break; #endif // CONFIG_DHT #ifdef CONFIG_I2C @@ -9152,14 +9346,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 -477; + return -489; 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 -478; + return -490; a += v; } } @@ -9172,14 +9366,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 -479; + return -491; 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 -480; + return -492; a += v; } } @@ -9192,17 +9386,17 @@ 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 -481; + return -493; if (v != 0) { n = m_onewire.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -482; + return -494; a += v; } } - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); break; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 @@ -9212,17 +9406,17 @@ 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 -483; + return -495; if (v != 0) { n = m_sx1276.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -484; + return -496; a += v; } } - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); break; #endif // CONFIG_SX1276 #ifdef CONFIG_IOEXTENDERS @@ -9232,14 +9426,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 -485; + return -497; 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 -486; + return -498; a += v; } } @@ -9252,17 +9446,17 @@ 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 -487; + return -499; if (v != 0) { n = m_display.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -488; + return -500; a += v; } } - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); break; #endif // CONFIG_DISPLAY default: @@ -9270,7 +9464,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 -489; + return -501; a += s; break; } @@ -9278,7 +9472,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -490; + return -502; return a-(const uint8_t *)b; } @@ -9291,10 +9485,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 -491; + return -503; *a++ = 0x5; if ((e-a) < 4) - return -492; + return -504; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -9302,13 +9496,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 -493; + return -505; *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 -494; + return -506; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -9316,13 +9510,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 -495; + return -507; *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 -496; + return -508; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -9331,13 +9525,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 -497; + return -509; *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 -498; + return -510; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -9347,13 +9541,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 -499; + return -511; *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 -500; + return -512; n = m_touchpad.toMemory(a,e-a); a += n; assert(n == touchpad_ws); @@ -9363,13 +9557,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 -501; + return -513; *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 -502; + return -514; n = x.toMemory(a,e-a); a += n; assert(n == tp_channel_ws); @@ -9378,13 +9572,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpio) { // 'gpio': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -503; + return -515; *a++ = 0x3a; ssize_t gpio_ws = x.calcSize(); n = write_varint(a,e-a,gpio_ws); a += n; if ((n <= 0) || (gpio_ws > (e-a))) - return -504; + return -516; n = x.toMemory(a,e-a); a += n; assert(n == gpio_ws); @@ -9393,13 +9587,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 -505; + return -517; *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 -506; + return -518; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -9409,14 +9603,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 -507; + return -519; *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 -508; + return -520; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -9426,14 +9620,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 -509; + return -521; *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 -510; + return -522; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -9443,14 +9637,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 -511; + return -523; *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 -512; + return -524; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -9461,14 +9655,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 -513; + return -525; *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 -514; + return -526; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -9479,14 +9673,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 -515; + return -527; *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 -516; + return -528; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -9497,50 +9691,49 @@ 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 -517; + return -529; *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 -518; + return -530; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // has ws2812b? - if (0 != (p_validbits & ((uint16_t)1U << 7))) { + for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -519; + return -531; *a++ = 0x92; *a++ = 0x2; - ssize_t ws2812b_ws = m_ws2812b.calcSize(); + ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -520; - n = m_ws2812b.toMemory(a,e-a); + return -532; + 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -521; + return -533; *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 -522; + return -534; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -9550,14 +9743,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 -523; + return -535; *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 -524; + return -536; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -9567,14 +9760,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 -525; + return -537; *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 -526; + return -538; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -9582,17 +9775,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE // has onewire? - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -527; + return -539; *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 -528; + return -540; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -9600,17 +9793,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 // has sx1276? - if (0 != (p_validbits & ((uint16_t)1U << 10))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -529; + return -541; *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 -530; + return -542; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -9620,14 +9813,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 -531; + return -543; *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 -532; + return -544; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -9635,17 +9828,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY // has display? - if (0 != (p_validbits & ((uint16_t)1U << 11))) { + if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -533; + return -545; *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 -534; + return -546; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -9832,9 +10025,23 @@ void HardwareConfig::toJSON(stream &json, unsigned indLvl) const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b()) { - fsep = json_indent(json,indLvl,fsep,"ws2812b"); - m_ws2812b.toJSON(json,indLvl); + if (size_t s = m_ws2812b.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"ws2812b\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + m_ws2812b[i].toJSON(json,indLvl); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); } #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -10036,15 +10243,17 @@ size_t HardwareConfig::calcSize() const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 - if (0 != (p_validbits & ((uint16_t)1U << 7))) { - size_t ws2812b_s = m_ws2812b.calcSize(); - r += ws2812b_s + wiresize(ws2812b_s) + 2 /* tag(ws2812b) 0x110 */; + // repeated Ws2812bConfig ws2812b, id 34 + // repeated message ws2812b + for (size_t x = 0, y = m_ws2812b.size(); x < y; ++x) { + size_t s = m_ws2812b[x].calcSize(); + 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { size_t dht_s = m_dht.calcSize(); r += dht_s + wiresize(dht_s) + 2 /* tag(dht) 0x118 */; } @@ -10069,14 +10278,14 @@ size_t HardwareConfig::calcSize() const #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE // optional OneWireConfig onewire, id 38 - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { size_t sx1276_s = m_sx1276.calcSize(); r += sx1276_s + wiresize(sx1276_s) + 2 /* tag(sx1276) 0x138 */; } @@ -10092,7 +10301,7 @@ size_t HardwareConfig::calcSize() const #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY // optional DisplayConfig display, id 50 - if (0 != (p_validbits & ((uint16_t)1U << 11))) { + if (0 != (p_validbits & ((uint16_t)1U << 10))) { size_t display_s = m_display.calcSize(); r += display_s + wiresize(display_s) + 2 /* tag(display) 0x190 */; } @@ -10151,7 +10360,7 @@ bool HardwareConfig::operator != (const HardwareConfig &r) const return true; #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b() && (m_ws2812b != r.m_ws2812b)) + if (m_ws2812b != r.m_ws2812b) return true; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -10235,17 +10444,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -535; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -547; if (m_uart.size() <= x) - return -536; + return -548; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -537; + return -549; return m_uart[x].setByName(idxe+2,value); } } @@ -10285,17 +10494,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -538; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -550; if (m_tp_channel.size() <= x) - return -539; + return -551; if ((idxe[1] == 0) && (value == 0)) { m_tp_channel.erase(m_tp_channel.begin()+x); return 0; } } if (idxe[1] != '.') - return -540; + return -552; return m_tp_channel[x].setByName(idxe+2,value); } } @@ -10315,17 +10524,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -541; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -553; if (m_gpio.size() <= x) - return -542; + return -554; if ((idxe[1] == 0) && (value == 0)) { m_gpio.erase(m_gpio.begin()+x); return 0; } } if (idxe[1] != '.') - return -543; + return -555; return m_gpio[x].setByName(idxe+2,value); } } @@ -10345,17 +10554,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -544; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -556; if (m_spibus.size() <= x) - return -545; + return -557; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -546; + return -558; return m_spibus[x].setByName(idxe+2,value); } } @@ -10376,17 +10585,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -547; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -559; if (m_button.size() <= x) - return -548; + return -560; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -549; + return -561; return m_button[x].setByName(idxe+2,value); } } @@ -10407,17 +10616,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') - return -550; + if ((idxe[0] != ']') || (idxe == (name+6))) + return -562; if (m_relay.size() <= x) - return -551; + return -563; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -552; + return -564; return m_relay[x].setByName(idxe+2,value); } } @@ -10438,17 +10647,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -553; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -565; if (m_led.size() <= x) - return -554; + return -566; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -555; + return -567; return m_led[x].setByName(idxe+2,value); } } @@ -10491,9 +10700,29 @@ int HardwareConfig::setByName(const char *name, const char *value) if ((name[7] == 0) && (value == 0)) { clear_ws2812b(); return 0; - } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 7); - return m_ws2812b.setByName(name+8,value); + } else if (name[7] == '[') { + char *idxe; + unsigned long x; + if ((name[8] == '+') && (name[9] == ']')) { + x = m_ws2812b.size(); + m_ws2812b.resize(x+1); + idxe = (char*)(name + 9); + if (value == 0) + return 0; + } else { + x = strtoul(name+8,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+8))) + return -568; + if (m_ws2812b.size() <= x) + return -569; + if ((idxe[1] == 0) && (value == 0)) { + m_ws2812b.erase(m_ws2812b.begin()+x); + return 0; + } + } + if (idxe[1] != '.') + return -570; + return m_ws2812b[x].setByName(idxe+2,value); } } #endif // CONFIG_RGBLEDS @@ -10503,7 +10732,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_dht(); return 0; } else if (name[3] == '.') { - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); return m_dht.setByName(name+4,value); } } @@ -10524,17 +10753,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -556; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -571; if (m_i2c.size() <= x) - return -557; + return -572; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -558; + return -573; return m_i2c[x].setByName(idxe+2,value); } } @@ -10555,17 +10784,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -559; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -574; if (m_hcsr04.size() <= x) - return -560; + return -575; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -561; + return -576; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -10576,7 +10805,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_onewire(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); return m_onewire.setByName(name+8,value); } } @@ -10587,7 +10816,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_sx1276(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); return m_sx1276.setByName(name+7,value); } } @@ -10608,17 +10837,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -562; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -577; if (m_iocluster.size() <= x) - return -563; + return -578; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -564; + return -579; return m_iocluster[x].setByName(idxe+2,value); } } @@ -10629,12 +10858,12 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_display(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); return m_display.setByName(name+8,value); } } #endif // CONFIG_DISPLAY - return -565; + return -580; } Message *HardwareConfig::p_getMember(const char *s, const char *e) @@ -10659,10 +10888,6 @@ Message *HardwareConfig::p_getMember(const char *s, const char *e) if (0 == strncmp("tlc5947",s,e-s)) return &m_tlc5947; #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS - if (0 == strncmp("ws2812b",s,e-s)) - return &m_ws2812b; - #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT if (0 == strncmp("dht",s,e-s)) return &m_dht; @@ -10729,6 +10954,13 @@ Message *HardwareConfig::p_getMember(const char *s, const char *e, unsigned x) return 0; } #endif // CONFIG_LEDS + #ifdef CONFIG_RGBLEDS + if (0 == strncmp("ws2812b[",s,e-s)) { + if (x < m_ws2812b.size()) + return &m_ws2812b[x]; + return 0; + } + #endif // CONFIG_RGBLEDS #ifdef CONFIG_I2C if (0 == strncmp("i2c[",s,e-s)) { if (x < m_i2c.size()) diff --git a/components/wfc/hwcfg_esp32.h b/components/wfc/hwcfg_esp32.h index 22e9a6b..634fd60 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -173,6 +173,7 @@ typedef enum { i2cdrv_ht16k33 = 10, i2cdrv_ina219 = 11, i2cdrv_si7021 = 12, + i2cdrv_tca9555 = 13, } i2cdrv_t; //! Function to get an ASCII string from a value of a i2cdrv_t. const char *i2cdrv_t_str(i2cdrv_t e); @@ -1763,10 +1764,38 @@ class Ws2812bConfig : public Message */ uint8_t *mutable_nleds(); + // optional string name, id 4 + /*! + * Function for querying if name has been set. + * @return true if name is set. + */ + bool has_name() const; + //! Function to reset name to its default/unset value. + void clear_name(); + //! Get value of name. + const estring &name() const; + /*! + * Function for setting name using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_name(const void *data, size_t s); + //! Set name using a constant reference + void set_name(const estring &v); + //! Set name using a pointer to a null-terminated C-string. + void set_name(const char *); + /*! + * Provide mutable access to name. + * @return pointer to member variable of name. + */ + estring *mutable_name(); + protected: Message *p_getMember(const char *s, const char *e); Message *p_getMember(const char *s, const char *e, unsigned i); + //! string name, id 4 + estring m_name; //! sint8 gpio, id 1 int8_t m_gpio; //! sint8 ch, id 2 @@ -2890,12 +2919,80 @@ class AdcChannel : public Message */ uint8_t *mutable_window(); + // optional float scale, id 8 + /*! + * Function for querying if scale has been set. + * @return true if scale is set. + */ + bool has_scale() const; + //! Function to reset scale to its default/unset value. + void clear_scale(); + //! Get value of scale. + float scale() const; + //! Set scale using a constant reference + void set_scale(float v); + /*! + * Provide mutable access to scale. + * @return pointer to member variable of scale. + */ + float *mutable_scale(); + + // optional float offset, id 9 + /*! + * Function for querying if offset has been set. + * @return true if offset is set. + */ + bool has_offset() const; + //! Function to reset offset to its default/unset value. + void clear_offset(); + //! Get value of offset. + float offset() const; + //! Set offset using a constant reference + void set_offset(float v); + /*! + * Provide mutable access to offset. + * @return pointer to member variable of offset. + */ + float *mutable_offset(); + + // optional string dim, id 10 + /*! + * Function for querying if dim has been set. + * @return true if dim is set. + */ + bool has_dim() const; + //! Function to reset dim to its default/unset value. + void clear_dim(); + //! Get value of dim. + const estring &dim() const; + /*! + * Function for setting dim using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_dim(const void *data, size_t s); + //! Set dim using a constant reference + void set_dim(const estring &v); + //! Set dim using a pointer to a null-terminated C-string. + void set_dim(const char *); + /*! + * Provide mutable access to dim. + * @return pointer to member variable of dim. + */ + estring *mutable_dim(); + protected: Message *p_getMember(const char *s, const char *e); Message *p_getMember(const char *s, const char *e, unsigned i); //! string name, id 1 estring m_name; + //! string dim, id 10 + estring m_dim; + //! float scale, id 8 + float m_scale; + //! float offset, id 9 + float m_offset; //! uint16 interval, id 5 uint16_t m_interval; //! uint8 unit, id 2 @@ -4809,29 +4906,29 @@ class HardwareConfig : public Message #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 + // repeated Ws2812bConfig ws2812b, id 34 + //! Function get const-access to the elements of ws2812b. + const std::vector &ws2812b() const; + //! Function to get the number of elements in ws2812b. + size_t ws2812b_size() const; /*! - * Function for querying if ws2812b has been set. - * @return true if ws2812b is set. + * Function to append a element to ws2812b. + * @return point to newly added element. */ - bool has_ws2812b() const; + Ws2812bConfig* add_ws2812b(); //! Function to reset ws2812b to its default/unset value. void clear_ws2812b(); - //! Get value of ws2812b. - const Ws2812bConfig &ws2812b() const; - /*! - * Function for setting ws2812b using binary data. - * @param data pointer to binary data - * @param s number of bytes at data pointer - */ - void set_ws2812b(const void *data, size_t s); + //! Get value of element x of ws2812b. + const Ws2812bConfig &ws2812b(unsigned x) const; //! Set ws2812b using a constant reference - void set_ws2812b(const Ws2812bConfig &v); + void set_ws2812b(unsigned x, const Ws2812bConfig &v); /*! * Provide mutable access to ws2812b. * @return pointer to member variable of ws2812b. */ - Ws2812bConfig *mutable_ws2812b(); + 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 @@ -5056,7 +5153,7 @@ class HardwareConfig : public Message #endif // CONFIG_DHT #ifdef CONFIG_RGBLEDS //! Ws2812bConfig ws2812b, id 34 - Ws2812bConfig m_ws2812b; + std::vector m_ws2812b; #endif // CONFIG_RGBLEDS #ifdef CONFIG_TLC5947 //! Tlc5947Config tlc5947, id 33 @@ -6663,7 +6760,8 @@ inline size_t Ws2812bConfig::getMaxSize() // optional sint8 gpio, id 1 has maximum size 3 // optional sint8 ch, id 2 has maximum size 3 // optional uint8 nleds, id 3 has maximum size 3 - return 9; + // optional string name, id 4 has unlimited size + return SIZE_MAX; } inline int8_t Ws2812bConfig::gpio() const @@ -6759,6 +6857,47 @@ inline void Ws2812bConfig::set_nleds(uint8_t v) +inline const estring &Ws2812bConfig::name() const +{ + return m_name; +} + +inline bool Ws2812bConfig::has_name() const +{ + return !m_name.empty(); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void Ws2812bConfig::clear_name() +{ + m_name.clear(); +} + +inline estring *Ws2812bConfig::mutable_name() +{ + return &m_name; +} + +inline void Ws2812bConfig::set_name(const void *data, size_t s) +{ + m_name.assign((const char *)data,s); +} + +inline void Ws2812bConfig::set_name(const char *data) +{ + m_name = data; +} + +inline void Ws2812bConfig::set_name(const estring &v) +{ + m_name = v; +} + + + inline size_t DhtConfig::getMaxSize() { // optional dht_model_t model, id 1 has maximum size 3 @@ -7637,6 +7776,9 @@ inline size_t AdcChannel::getMaxSize() // optional uint8 atten, id 4 has maximum size 3 // optional uint16 interval, id 5 has maximum size 4 // optional uint8 window, id 6 has maximum size 3 + // optional float scale, id 8 has maximum size 5 + // optional float offset, id 9 has maximum size 5 + // optional string dim, id 10 has unlimited size return SIZE_MAX; } @@ -7842,6 +7984,129 @@ inline void AdcChannel::set_window(uint8_t v) +inline float AdcChannel::scale() const +{ + return m_scale; +} + +inline bool AdcChannel::has_scale() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 1)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_scale() +{ + p_validbits &= ~((uint8_t)1U << 1); + m_scale = 1; +} + +inline float *AdcChannel::mutable_scale() +{ + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); + m_scale = 1; + } + return &m_scale; +} + +inline void AdcChannel::set_scale(float v) +{ + m_scale = v; + p_validbits |= ((uint8_t)1U << 1); +} + + + +inline float AdcChannel::offset() const +{ + return m_offset; +} + +inline bool AdcChannel::has_offset() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 2)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_offset() +{ + p_validbits &= ~((uint8_t)1U << 2); + m_offset = 0; +} + +inline float *AdcChannel::mutable_offset() +{ + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); + m_offset = 0; + } + return &m_offset; +} + +inline void AdcChannel::set_offset(float v) +{ + m_offset = v; + p_validbits |= ((uint8_t)1U << 2); +} + + + +inline const estring &AdcChannel::dim() const +{ + return m_dim; +} + +inline bool AdcChannel::has_dim() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 3)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_dim() +{ + p_validbits &= ~((uint8_t)1U << 3); + m_dim.clear(); +} + +inline estring *AdcChannel::mutable_dim() +{ + if (0 == (p_validbits & ((uint8_t)1U << 3))) { + p_validbits |= ((uint8_t)1U << 3); + m_dim.clear(); + } + return &m_dim; +} + +inline void AdcChannel::set_dim(const void *data, size_t s) +{ + m_dim.assign((const char *)data,s); + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const char *data) +{ + m_dim = data; + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const estring &v) +{ + m_dim = v; + p_validbits |= ((uint8_t)1U << 3); +} + + + inline size_t AdcConfig::getMaxSize() { // optional string adc_name, id 1 has unlimited size @@ -9476,7 +9741,7 @@ inline size_t HardwareConfig::getMaxSize() // optional Hlw8012Config hlw8012, id 20 has maximum size 11 // optional Max7219Config max7219, id 32 has maximum size 16 // optional Tlc5947Config tlc5947, id 33 has maximum size 17 - // optional Ws2812bConfig ws2812b, id 34 has maximum size 11 + // repeated Ws2812bConfig ws2812b, id 34 has unlimited size // optional DhtConfig dht, id 35 has maximum size 8 // repeated I2CConfig i2c, id 36 has unlimited size // repeated HcSr04Config hcsr04, id 37 has unlimited size @@ -10151,14 +10416,14 @@ inline void HardwareConfig::set_tlc5947(const Tlc5947Config &v) #ifdef CONFIG_RGBLEDS -inline const Ws2812bConfig &HardwareConfig::ws2812b() const +inline const Ws2812bConfig &HardwareConfig::ws2812b(unsigned x) const { - return m_ws2812b; + return m_ws2812b[x]; } -inline bool HardwareConfig::has_ws2812b() const +inline const std::vector &HardwareConfig::ws2812b() const { - return 0 != (p_validbits & ((uint16_t)1U << 7)); + return m_ws2812b; } /*! @@ -10167,29 +10432,36 @@ inline bool HardwareConfig::has_ws2812b() const */ inline void HardwareConfig::clear_ws2812b() { - p_validbits &= ~((uint16_t)1U << 7); m_ws2812b.clear(); } -inline Ws2812bConfig *HardwareConfig::mutable_ws2812b() +inline Ws2812bConfig *HardwareConfig::mutable_ws2812b(unsigned x) +{ + if (x >= m_ws2812b.size()) + m_ws2812b.resize(x+1); + return &m_ws2812b[x]; +} + +inline std::vector *HardwareConfig::mutable_ws2812b() { - if (0 == (p_validbits & ((uint16_t)1U << 7))) { - p_validbits |= ((uint16_t)1U << 7); - m_ws2812b.clear(); - } return &m_ws2812b; } -inline void HardwareConfig::set_ws2812b(const void *data, size_t s) +inline Ws2812bConfig *HardwareConfig::add_ws2812b() { - m_ws2812b.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 7); + m_ws2812b.resize(m_ws2812b.size()+1); + return &m_ws2812b.back(); } -inline void HardwareConfig::set_ws2812b(const Ws2812bConfig &v) +inline void HardwareConfig::set_ws2812b(unsigned x, const Ws2812bConfig &v) { - m_ws2812b = v; - p_validbits |= ((uint16_t)1U << 7); + assert(x < m_ws2812b.size()); + m_ws2812b[x] = v; +} + +inline size_t HardwareConfig::ws2812b_size() const +{ + return m_ws2812b.size(); } #endif // CONFIG_RGBLEDS @@ -10203,7 +10475,7 @@ inline const DhtConfig &HardwareConfig::dht() const inline bool HardwareConfig::has_dht() const { - return 0 != (p_validbits & ((uint16_t)1U << 8)); + return 0 != (p_validbits & ((uint16_t)1U << 7)); } /*! @@ -10212,14 +10484,14 @@ inline bool HardwareConfig::has_dht() const */ inline void HardwareConfig::clear_dht() { - p_validbits &= ~((uint16_t)1U << 8); + p_validbits &= ~((uint16_t)1U << 7); m_dht.clear(); } inline DhtConfig *HardwareConfig::mutable_dht() { - if (0 == (p_validbits & ((uint16_t)1U << 8))) { - p_validbits |= ((uint16_t)1U << 8); + if (0 == (p_validbits & ((uint16_t)1U << 7))) { + p_validbits |= ((uint16_t)1U << 7); m_dht.clear(); } return &m_dht; @@ -10228,13 +10500,13 @@ inline DhtConfig *HardwareConfig::mutable_dht() inline void HardwareConfig::set_dht(const void *data, size_t s) { m_dht.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } inline void HardwareConfig::set_dht(const DhtConfig &v) { m_dht = v; - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } #endif // CONFIG_DHT @@ -10352,7 +10624,7 @@ inline const OneWireConfig &HardwareConfig::onewire() const inline bool HardwareConfig::has_onewire() const { - return 0 != (p_validbits & ((uint16_t)1U << 9)); + return 0 != (p_validbits & ((uint16_t)1U << 8)); } /*! @@ -10361,14 +10633,14 @@ inline bool HardwareConfig::has_onewire() const */ inline void HardwareConfig::clear_onewire() { - p_validbits &= ~((uint16_t)1U << 9); + p_validbits &= ~((uint16_t)1U << 8); m_onewire.clear(); } inline OneWireConfig *HardwareConfig::mutable_onewire() { - if (0 == (p_validbits & ((uint16_t)1U << 9))) { - p_validbits |= ((uint16_t)1U << 9); + if (0 == (p_validbits & ((uint16_t)1U << 8))) { + p_validbits |= ((uint16_t)1U << 8); m_onewire.clear(); } return &m_onewire; @@ -10377,13 +10649,13 @@ inline OneWireConfig *HardwareConfig::mutable_onewire() inline void HardwareConfig::set_onewire(const void *data, size_t s) { m_onewire.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } inline void HardwareConfig::set_onewire(const OneWireConfig &v) { m_onewire = v; - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } #endif // CONFIG_ONEWIRE @@ -10397,7 +10669,7 @@ inline const SX1276Config &HardwareConfig::sx1276() const inline bool HardwareConfig::has_sx1276() const { - return 0 != (p_validbits & ((uint16_t)1U << 10)); + return 0 != (p_validbits & ((uint16_t)1U << 9)); } /*! @@ -10406,14 +10678,14 @@ inline bool HardwareConfig::has_sx1276() const */ inline void HardwareConfig::clear_sx1276() { - p_validbits &= ~((uint16_t)1U << 10); + p_validbits &= ~((uint16_t)1U << 9); m_sx1276.clear(); } inline SX1276Config *HardwareConfig::mutable_sx1276() { - if (0 == (p_validbits & ((uint16_t)1U << 10))) { - p_validbits |= ((uint16_t)1U << 10); + if (0 == (p_validbits & ((uint16_t)1U << 9))) { + p_validbits |= ((uint16_t)1U << 9); m_sx1276.clear(); } return &m_sx1276; @@ -10422,13 +10694,13 @@ inline SX1276Config *HardwareConfig::mutable_sx1276() inline void HardwareConfig::set_sx1276(const void *data, size_t s) { m_sx1276.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } inline void HardwareConfig::set_sx1276(const SX1276Config &v) { m_sx1276 = v; - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } #endif // CONFIG_SX1276 @@ -10494,7 +10766,7 @@ inline const DisplayConfig &HardwareConfig::display() const inline bool HardwareConfig::has_display() const { - return 0 != (p_validbits & ((uint16_t)1U << 11)); + return 0 != (p_validbits & ((uint16_t)1U << 10)); } /*! @@ -10503,14 +10775,14 @@ inline bool HardwareConfig::has_display() const */ inline void HardwareConfig::clear_display() { - p_validbits &= ~((uint16_t)1U << 11); + p_validbits &= ~((uint16_t)1U << 10); m_display.clear(); } inline DisplayConfig *HardwareConfig::mutable_display() { - if (0 == (p_validbits & ((uint16_t)1U << 11))) { - p_validbits |= ((uint16_t)1U << 11); + if (0 == (p_validbits & ((uint16_t)1U << 10))) { + p_validbits |= ((uint16_t)1U << 10); m_display.clear(); } return &m_display; @@ -10519,13 +10791,13 @@ inline DisplayConfig *HardwareConfig::mutable_display() inline void HardwareConfig::set_display(const void *data, size_t s) { m_display.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); } inline void HardwareConfig::set_display(const DisplayConfig &v) { m_display = v; - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); } #endif // CONFIG_DISPLAY diff --git a/components/wfc/hwcfg_esp8266.cpp b/components/wfc/hwcfg_esp8266.cpp index 32f7481..7b9b4e7 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -293,6 +293,7 @@ static const char *i2cdrv_t_names[] = { "i2cdrv_pca9685_xclk_pnp", "i2cdrv_pcf8574", "i2cdrv_si7021", + "i2cdrv_tca9555", }; static i2cdrv_t i2cdrv_t_values[] = { @@ -309,6 +310,7 @@ static i2cdrv_t i2cdrv_t_values[] = { i2cdrv_pca9685_xclk_pnp, i2cdrv_pcf8574, i2cdrv_si7021, + i2cdrv_tca9555, }; #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB @@ -329,6 +331,7 @@ size_t parse_ascii_i2cdrv_t(i2cdrv_t *v, const char *s) { "i2cdrv_pca9685_xclk_pnp", i2cdrv_pca9685_xclk_pnp}, { "i2cdrv_pcf8574", i2cdrv_pcf8574}, { "i2cdrv_si7021", i2cdrv_si7021}, + { "i2cdrv_tca9555", i2cdrv_tca9555}, }; #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB char *e; @@ -386,6 +389,8 @@ const char *i2cdrv_t_str(i2cdrv_t e) return "i2cdrv_ina219"; case i2cdrv_si7021: return "i2cdrv_si7021"; + case i2cdrv_tca9555: + return "i2cdrv_tca9555"; } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB #ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB @@ -2851,7 +2856,8 @@ int Tlc5947Config::setByName(const char *name, const char *value) } Ws2812bConfig::Ws2812bConfig() -: m_gpio(-1) +: m_name() +, m_gpio(-1) // omitted unused member ch , m_nleds(0) { @@ -2861,6 +2867,7 @@ void Ws2812bConfig::clear() { m_gpio = -1; m_nleds = 0; + m_name.clear(); } void Ws2812bConfig::toASCII(stream &o, size_t indent) const @@ -2869,6 +2876,7 @@ void Ws2812bConfig::toASCII(stream &o, size_t indent) const ++indent; ascii_numeric(o, indent, "gpio", (signed) m_gpio); ascii_numeric(o, indent, "nleds", (unsigned) m_nleds); + ascii_string(o,indent,m_name.data(),m_name.size(),"name"); --indent; ascii_indent(o,indent); o << '}'; @@ -2892,18 +2900,25 @@ ssize_t Ws2812bConfig::fromMemory(const void *b, ssize_t s) case 0x18: // nleds id 3, type uint8_t, coding varint set_nleds((uint8_t)ud.u32); break; + case 0x22: // name id 4, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -116; + } + m_name.assign((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 -116; + return -117; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -117; + return -118; return a-(const uint8_t *)b; } @@ -2916,11 +2931,11 @@ ssize_t Ws2812bConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -118; + return -119; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -119; + return -120; a += n; } // 'ch' is unused. Therefore no data will be written. @@ -2928,11 +2943,22 @@ ssize_t Ws2812bConfig::toMemory(uint8_t *b, ssize_t s) const if (m_nleds != 0) { // 'nleds': id=3, encoding=varint, tag=0x18 if (a >= e) - return -120; + return -121; *a++ = 0x18; n = write_varint(a,e-a,m_nleds); if (n <= 0) - return -121; + return -122; + a += n; + } + // has name? + if (!m_name.empty()) { + // 'name': id=4, encoding=lenpfx, tag=0x22 + if (a >= e) + return -123; + *a++ = 0x22; + n = encode_bytes(m_name,a,e); + if (n < 0) + return -124; a += n; } assert(a <= e); @@ -2951,6 +2977,10 @@ void Ws2812bConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"nleds"); to_decstr(json,(unsigned) m_nleds); } + if (has_name()) { + fsep = json_indent(json,indLvl,fsep,"name"); + json_cstr(json,m_name.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -2973,6 +3003,11 @@ size_t Ws2812bConfig::calcSize() const if (has_nleds()) { r += wiresize((varint_t)m_nleds) + 1 /* tag(nleds) 0x18 */; } + // optional string name, id 4 + if (has_name()) { + size_t name_s = m_name.size(); + r += name_s + wiresize(name_s) + 1 /* tag(name) 0x20 */; + } return r; } @@ -2982,6 +3017,8 @@ bool Ws2812bConfig::operator == (const Ws2812bConfig &r) const return false; if (has_nleds() && (!(m_nleds == r.m_nleds))) return false; + if (has_name() && (!(m_name == r.m_name))) + return false; return true; } @@ -3011,7 +3048,16 @@ int Ws2812bConfig::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_nleds,value); return r; } - return -122; + if (0 == strcmp(name,"name")) { + if (value == 0) { + clear_name(); + return 0; + } + m_name = value; + int r = m_name.size(); + return r; + } + return -125; } DhtConfig::DhtConfig() @@ -3051,7 +3097,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -123; + return -126; a += x; switch (fid) { case 0x8: // model id 1, type dht_model_t, coding varint @@ -3065,13 +3111,13 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -124; + return -127; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -125; + return -128; return a-(const uint8_t *)b; } @@ -3084,22 +3130,22 @@ ssize_t DhtConfig::toMemory(uint8_t *b, ssize_t s) const if (m_model != DHT_NONE) { // 'model': id=1, encoding=varint, tag=0x8 if (a >= e) - return -126; + return -129; *a++ = 0x8; n = write_varint(a,e-a,m_model); if (n <= 0) - return -127; + return -130; a += n; } // has gpio? if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -128; + return -131; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -129; + return -132; a += n; } assert(a <= e); @@ -3175,7 +3221,7 @@ int DhtConfig::setByName(const char *name, const char *value) dht_model_t v; size_t r = parse_ascii_dht_model_t(&v,value); if (r == 0) - return -130; + return -133; set_model(v); return r; } @@ -3187,7 +3233,7 @@ int DhtConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_gpio,value); return r; } - return -131; + return -134; } I2CConfig::I2CConfig() @@ -3260,7 +3306,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -132; + return -135; a += x; switch (fid) { case 0x8: // port id 1, type uint8_t, coding varint @@ -3283,7 +3329,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -133; + return -136; a += n; m_devices.push_back((i2cdev_t)v); } while (a < ae); @@ -3295,13 +3341,13 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -134; + return -137; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -135; + return -138; return a-(const uint8_t *)b; } @@ -3314,33 +3360,33 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -136; + return -139; *a++ = 0x8; n = write_varint(a,e-a,m_port); if (n <= 0) - return -137; + return -140; a += n; } // has sda? if (m_sda != -1) { // 'sda': id=2, encoding=varint, tag=0x10 if (a >= e) - return -138; + return -141; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sda)); if (n <= 0) - return -139; + return -142; a += n; } // has scl? if (m_scl != -1) { // 'scl': id=3, encoding=varint, tag=0x18 if (a >= e) - return -140; + return -143; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_scl)); if (n <= 0) - return -141; + return -144; a += n; } // 'freq' is unused. Therefore no data will be written. @@ -3348,7 +3394,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (m_xpullup != false) { // 'xpullup': id=5, encoding=8bit, tag=0x2b if (2 > (e-a)) - return -142; + return -145; *a++ = 0x2b; *a++ = m_xpullup; } @@ -3356,7 +3402,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -143; + return -146; *a++ = 0x32; ssize_t devices_ws = 0; for (size_t x = 0; x != devices_ne; ++x) @@ -3364,7 +3410,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -144; + return -147; for (size_t x = 0; x != devices_ne; ++x) a += write_varint(a,e-a,m_devices[x]); } @@ -3535,10 +3581,10 @@ int I2CConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -145; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -148; if (m_devices.size() <= x) - return -146; + return -149; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; @@ -3551,7 +3597,7 @@ int I2CConfig::setByName(const char *name, const char *value) return eptr - value; } if (idxe[1] != '.') - return -147; + return -150; idxe += 2; if (!strcmp("addr",idxe)) { if (eptr != value) { @@ -3572,11 +3618,11 @@ int I2CConfig::setByName(const char *name, const char *value) } } } - return -148; + return -151; } } #endif // CONFIG_I2C_XDEV - return -149; + return -152; } HcSr04Config::HcSr04Config() @@ -3614,7 +3660,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -150; + return -153; a += x; switch (fid) { case 0x8: // trigger id 1, type int8_t, coding signed varint @@ -3625,7 +3671,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) break; case 0x1a: // name id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -151; + return -154; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -3635,13 +3681,13 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -152; + return -155; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -153; + return -156; return a-(const uint8_t *)b; } @@ -3654,33 +3700,33 @@ ssize_t HcSr04Config::toMemory(uint8_t *b, ssize_t s) const if (m_trigger != -1) { // 'trigger': id=1, encoding=varint, tag=0x8 if (a >= e) - return -154; + return -157; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_trigger)); if (n <= 0) - return -155; + return -158; a += n; } // has echo? if (m_echo != -1) { // 'echo': id=2, encoding=varint, tag=0x10 if (a >= e) - return -156; + return -159; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_echo)); if (n <= 0) - return -157; + return -160; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -158; + return -161; *a++ = 0x1a; n = encode_bytes(m_name,a,e); if (n < 0) - return -159; + return -162; a += n; } assert(a <= e); @@ -3778,7 +3824,7 @@ int HcSr04Config::setByName(const char *name, const char *value) int r = m_name.size(); return r; } - return -160; + return -163; } LedConfig::LedConfig() @@ -3829,7 +3875,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -161; + return -164; a += x; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -3840,7 +3886,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) break; case 0x1a: // name id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -162; + return -165; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -3853,13 +3899,13 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -163; + return -166; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -164; + return -167; return a-(const uint8_t *)b; } @@ -3872,44 +3918,44 @@ ssize_t LedConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -165; + return -168; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -166; + return -169; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=2, encoding=varint, tag=0x10 if (a >= e) - return -167; + return -170; *a++ = 0x10; n = write_varint(a,e-a,m_config); if (n <= 0) - return -168; + return -171; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -169; + return -172; *a++ = 0x1a; n = encode_bytes(m_name,a,e); if (n < 0) - return -170; + return -173; a += n; } // has pwm_ch? if (m_pwm_ch != -1) { // 'pwm_ch': id=4, encoding=varint, tag=0x20 if (a >= e) - return -171; + return -174; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_pwm_ch)); if (n <= 0) - return -172; + return -175; a += n; } assert(a <= e); @@ -4017,7 +4063,7 @@ int LedConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -173; + return -176; } else if (!strcmp(name,"active_high")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -4050,7 +4096,7 @@ int LedConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_pwm_ch,value); return r; } - return -174; + return -177; } OneWireConfig::OneWireConfig() @@ -4088,7 +4134,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -175; + return -178; a += x; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -4105,13 +4151,13 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -176; + return -179; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -177; + return -180; return a-(const uint8_t *)b; } @@ -4124,18 +4170,18 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -178; + return -181; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -179; + return -182; a += n; } // has pullup? if (m_pullup != false) { // 'pullup': id=2, encoding=8bit, tag=0x13 if (2 > (e-a)) - return -180; + return -183; *a++ = 0x13; *a++ = m_pullup; } @@ -4143,11 +4189,11 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_power != -1) { // 'power': id=3, encoding=varint, tag=0x18 if (a >= e) - return -181; + return -184; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_power)); if (n <= 0) - return -182; + return -185; a += n; } assert(a <= e); @@ -4243,7 +4289,7 @@ int OneWireConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_power,value); return r; } - return -183; + return -186; } UartConfig::UartConfig() @@ -4279,7 +4325,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -184; + return -187; a += x; switch (fid) { case 0x8: // port id 1, type int8_t, coding signed varint @@ -4290,13 +4336,13 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -185; + return -188; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -186; + return -189; return a-(const uint8_t *)b; } @@ -4309,11 +4355,11 @@ ssize_t UartConfig::toMemory(uint8_t *b, ssize_t s) const if (m_port != -1) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -187; + return -190; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_port)); if (n <= 0) - return -188; + return -191; a += n; } // 'tx_gpio' is unused. Therefore no data will be written. @@ -4381,11 +4427,14 @@ int UartConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_port,value); return r; } - return -189; + return -192; } AdcChannel::AdcChannel() : m_name() +, m_dim() +, m_scale(1) +, m_offset(0) , m_interval(0) , m_unit(0) , m_ch(-1) @@ -4403,6 +4452,9 @@ void AdcChannel::clear() m_atten = 0; m_interval = 0; m_window = 0; + m_scale = 1; + m_offset = 0; + m_dim.clear(); p_validbits = 0; } @@ -4416,6 +4468,9 @@ void AdcChannel::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "atten", (unsigned) m_atten); ascii_numeric(o, indent, "interval", m_interval); ascii_numeric(o, indent, "window", (unsigned) m_window); + ascii_numeric(o, indent, "scale", m_scale); + ascii_numeric(o, indent, "offset", m_offset); + ascii_string(o,indent,m_dim.data(),m_dim.size(),"dim"); --indent; ascii_indent(o,indent); o << '}'; @@ -4430,12 +4485,12 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -190; + return -193; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -191; + return -194; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -4455,18 +4510,32 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) case 0x30: // window id 6, type uint8_t, coding varint set_window((uint8_t)ud.u32); break; + case 0x45: // scale id 8, type float, coding 32bit + set_scale(ud.f); + break; + case 0x4d: // offset id 9, type float, coding 32bit + set_offset(ud.f); + break; + case 0x52: // dim id 10, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -195; + } + m_dim.assign((const char*)a,ud.vi); + p_validbits |= ((uint8_t)1U << 3); + a += ud.vi; + break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data a += ud.vi; if (a > e) - return -192; + return -196; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -193; + return -197; return a-(const uint8_t *)b; } @@ -4479,66 +4548,99 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -194; + return -198; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -195; + return -199; a += n; } // has unit? if (m_unit != 0) { // 'unit': id=2, encoding=varint, tag=0x10 if (a >= e) - return -196; + return -200; *a++ = 0x10; n = write_varint(a,e-a,m_unit); if (n <= 0) - return -197; + return -201; a += n; } // has ch? if (m_ch != -1) { // 'ch': id=3, encoding=varint, tag=0x18 if (a >= e) - return -198; + return -202; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_ch)); if (n <= 0) - return -199; + return -203; a += n; } // has atten? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'atten': id=4, encoding=varint, tag=0x20 if (a >= e) - return -200; + return -204; *a++ = 0x20; n = write_varint(a,e-a,m_atten); if (n <= 0) - return -201; + return -205; a += n; } // has interval? if (m_interval != 0) { // 'interval': id=5, encoding=varint, tag=0x28 if (a >= e) - return -202; + return -206; *a++ = 0x28; n = write_varint(a,e-a,m_interval); if (n <= 0) - return -203; + return -207; a += n; } // has window? if (m_window != 0) { // 'window': id=6, encoding=varint, tag=0x30 if (a >= e) - return -204; + return -208; *a++ = 0x30; n = write_varint(a,e-a,m_window); if (n <= 0) - return -205; + return -209; + a += n; + } + // has scale? + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + // 'scale': id=8, encoding=32bit, tag=0x45 + if (5 > (e-a)) + return -210; + *a++ = 0x45; + if ((e-a) < 4) + return -211; + write_u32(a,mangle_float(m_scale)); + a += 4; + } + // has offset? + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + // 'offset': id=9, encoding=32bit, tag=0x4d + if (5 > (e-a)) + return -212; + *a++ = 0x4d; + if ((e-a) < 4) + return -213; + write_u32(a,mangle_float(m_offset)); + a += 4; + } + // has dim? + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + // 'dim': id=10, encoding=lenpfx, tag=0x52 + if (a >= e) + return -214; + *a++ = 0x52; + n = encode_bytes(m_dim,a,e); + if (n < 0) + return -215; a += n; } assert(a <= e); @@ -4573,6 +4675,18 @@ void AdcChannel::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"window"); to_decstr(json,(unsigned) m_window); } + if (has_scale()) { + fsep = json_indent(json,indLvl,fsep,"scale"); + to_dblstr(json,m_scale); + } + if (has_offset()) { + fsep = json_indent(json,indLvl,fsep,"offset"); + to_dblstr(json,m_offset); + } + if (has_dim()) { + fsep = json_indent(json,indLvl,fsep,"dim"); + json_cstr(json,m_dim.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -4611,6 +4725,19 @@ size_t AdcChannel::calcSize() const if (has_window()) { r += wiresize((varint_t)m_window) + 1 /* tag(window) 0x30 */; } + // optional float scale, id 8 + if (has_scale()) { + r += 5; + } + // optional float offset, id 9 + if (has_offset()) { + r += 5; + } + // optional string dim, id 10 + if (has_dim()) { + size_t dim_s = m_dim.size(); + r += dim_s + wiresize(dim_s) + 1 /* tag(dim) 0x50 */; + } return r; } @@ -4630,6 +4757,12 @@ bool AdcChannel::operator == (const AdcChannel &r) const return false; if (has_window() && (!(m_window == r.m_window))) return false; + if (has_scale() && (!(m_scale == r.m_scale))) + return false; + if (has_offset() && (!(m_offset == r.m_offset))) + return false; + if (has_dim() && (!(m_dim == r.m_dim))) + return false; return true; } @@ -4694,7 +4827,38 @@ int AdcChannel::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_window,value); return r; } - return -206; + if (0 == strcmp(name,"scale")) { + if (value == 0) { + clear_scale(); + return 0; + } + int r = parse_ascii_flt(&m_scale,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 1); + return r; + } + if (0 == strcmp(name,"offset")) { + if (value == 0) { + clear_offset(); + return 0; + } + int r = parse_ascii_flt(&m_offset,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 2); + return r; + } + if (0 == strcmp(name,"dim")) { + if (value == 0) { + clear_dim(); + return 0; + } + m_dim = value; + int r = m_dim.size(); + if (r > 0) + p_validbits |= ((uint8_t)1U << 3); + return r; + } + return -216; } AdcConfig::AdcConfig() @@ -4738,12 +4902,12 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -207; + return -217; a += x; switch (fid) { case 0xa: // adc_name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -208; + return -218; } m_adc_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -4759,13 +4923,13 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -209; + return -219; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -210; + return -220; return a-(const uint8_t *)b; } @@ -4778,11 +4942,11 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_adc_name.empty()) { // 'adc_name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -211; + return -221; *a++ = 0xa; n = encode_bytes(m_adc_name,a,e); if (n < 0) - return -212; + return -222; a += n; } // 'adc1_bits' is unused. Therefore no data will be written. @@ -4791,22 +4955,22 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'mode': id=4, encoding=varint, tag=0x20 if (a >= e) - return -213; + return -223; *a++ = 0x20; n = write_varint(a,e-a,m_mode); if (n <= 0) - return -214; + return -224; a += n; } // has clk_div? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'clk_div': id=5, encoding=varint, tag=0x28 if (a >= e) - return -215; + return -225; *a++ = 0x28; n = write_varint(a,e-a,m_clk_div); if (n <= 0) - return -216; + return -226; a += n; } // 'hall_name' is unused. Therefore no data will be written. @@ -4916,7 +5080,7 @@ int AdcConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } - return -217; + return -227; } GpioConfig::GpioConfig() @@ -4981,12 +5145,12 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -218; + return -228; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -219; + return -229; } m_name.assign((const char*)a,ud.vi); p_validbits |= ((uint8_t)1U << 0); @@ -5003,13 +5167,13 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -220; + return -230; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -221; + return -231; return a-(const uint8_t *)b; } @@ -5022,33 +5186,33 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -222; + return -232; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -223; + return -233; a += n; } // has gpio? if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -224; + return -234; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -225; + return -235; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) - return -226; + return -236; *a++ = 0x18; n = write_varint(a,e-a,m_config); if (n <= 0) - return -227; + return -237; a += n; } assert(a <= e); @@ -5167,7 +5331,7 @@ int GpioConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -228; + return -238; } else if (!strcmp(name,"mode")) { uint8_t tmp; size_t r = parse_ascii_u8(&tmp,value); @@ -5213,7 +5377,7 @@ int GpioConfig::setByName(const char *name, const char *value) } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB } - return -229; + return -239; } DisplayConfig::DisplayConfig() @@ -5261,7 +5425,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -230; + return -240; a += x; switch (fid) { case 0x8: // type id 1, type disp_t, coding varint @@ -5281,13 +5445,13 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -231; + return -241; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -232; + return -242; return a-(const uint8_t *)b; } @@ -5300,44 +5464,44 @@ 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 -233; + return -243; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -234; + return -244; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -235; + return -245; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -236; + return -246; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -237; + return -247; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -238; + return -248; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -239; + return -249; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -240; + return -250; a += n; } assert(a <= e); @@ -5435,7 +5599,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 -241; + return -251; set_type(v); return r; } @@ -5469,7 +5633,7 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -242; + return -252; } SpiDeviceConfig::SpiDeviceConfig() @@ -5518,7 +5682,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 -243; + return -253; a += x; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -5541,13 +5705,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 -244; + return -254; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -245; + return -255; return a-(const uint8_t *)b; } @@ -5560,55 +5724,55 @@ 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 -246; + return -256; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -247; + return -257; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -248; + return -258; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -249; + return -259; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -250; + return -260; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -251; + return -261; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -252; + return -262; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -253; + return -263; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -254; + return -264; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -255; + return -265; a += n; } assert(a <= e); @@ -5714,7 +5878,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 -256; + return -266; set_drv(v); return r; } @@ -5750,7 +5914,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cd,value); return r; } - return -257; + return -267; } SpiBusConfig::SpiBusConfig() @@ -5841,7 +6005,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 -258; + return -268; a += x; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -5874,7 +6038,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 -259; + return -269; a += ud.vi; } break; @@ -5883,13 +6047,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 -260; + return -270; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -261; + return -271; return a-(const uint8_t *)b; } @@ -5902,100 +6066,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 -262; + return -272; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -263; + return -273; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -264; + return -274; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -265; + return -275; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -266; + return -276; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -267; + return -277; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -268; + return -278; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -269; + return -279; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -270; + return -280; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -271; + return -281; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -272; + return -282; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -273; + return -283; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -274; + return -284; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -275; + return -285; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -276; + return -286; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -277; + return -287; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -278; + return -288; *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 -279; + return -289; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -6221,7 +6385,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -280; + return -290; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -6290,21 +6454,21 @@ int SpiBusConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -281; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -291; if (m_devices.size() <= x) - return -282; + return -292; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -283; + return -293; return m_devices[x].setByName(idxe+2,value); } } - return -284; + return -294; } Message *SpiBusConfig::p_getMember(const char *s, const char *e, unsigned x) @@ -6358,12 +6522,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 -285; + return -295; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -286; + return -296; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -6385,13 +6549,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 -287; + return -297; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -288; + return -298; return a-(const uint8_t *)b; } @@ -6404,55 +6568,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 -289; + return -299; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -290; + return -300; a += n; } // has base? if (m_base != 0) { // 'base': id=2, encoding=varint, tag=0x10 if (a >= e) - return -291; + return -301; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -292; + return -302; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -293; + return -303; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -294; + return -304; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -295; + return -305; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -296; + return -306; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -297; + return -307; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -298; + return -308; a += n; } assert(a <= e); @@ -6586,7 +6750,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -299; + return -309; } Hlw8012Config::Hlw8012Config() @@ -6624,7 +6788,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 -300; + return -310; a += x; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -6641,13 +6805,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 -301; + return -311; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -302; + return -312; return a-(const uint8_t *)b; } @@ -6660,33 +6824,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 -303; + return -313; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -304; + return -314; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -305; + return -315; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -306; + return -316; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -307; + return -317; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -308; + return -318; a += n; } assert(a <= e); @@ -6782,7 +6946,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -309; + return -319; } SX1276Config::SX1276Config() @@ -6829,7 +6993,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 -310; + return -320; a += x; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -6855,13 +7019,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 -311; + return -321; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -312; + return -322; return a-(const uint8_t *)b; } @@ -6874,66 +7038,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 -313; + return -323; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -314; + return -324; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -315; + return -325; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -316; + return -326; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -317; + return -327; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -318; + return -328; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -319; + return -329; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -320; + return -330; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -321; + return -331; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -322; + return -332; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -323; + return -333; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -324; + return -334; a += n; } assert(a <= e); @@ -7083,7 +7247,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -325; + return -335; } HardwareConfig::HardwareConfig() @@ -7273,8 +7437,18 @@ void HardwareConfig::toASCII(stream &o, size_t indent) const m_tlc5947.toASCII(o,indent); #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - ascii_indent(o,indent,"ws2812b"); - m_ws2812b.toASCII(o,indent); + ascii_indent(o,indent); + size_t s_ws2812b = m_ws2812b.size(); + o << "ws2812b[" << s_ws2812b << "] = {"; + ++indent; + for (size_t i = 0, e = s_ws2812b; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + m_ws2812b[i].toASCII(o,indent); + } + --indent; + ascii_indent(o,indent); + o << '}'; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT ascii_indent(o,indent,"dht"); @@ -7348,7 +7522,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 -326; + return -336; a += x; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit @@ -7359,7 +7533,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 -327; + return -337; a += ud.vi; } p_validbits |= ((uint16_t)1U << 1); @@ -7369,7 +7543,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 -328; + return -338; a += ud.vi; } p_validbits |= ((uint16_t)1U << 2); @@ -7380,7 +7554,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_gpio.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -329; + return -339; a += ud.vi; } break; @@ -7391,7 +7565,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 -330; + return -340; a += ud.vi; } break; @@ -7403,7 +7577,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 -331; + return -341; a += ud.vi; } break; @@ -7415,7 +7589,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 -332; + return -342; a += ud.vi; } break; @@ -7427,7 +7601,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 -333; + return -343; a += ud.vi; } break; @@ -7438,7 +7612,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 -334; + return -344; a += ud.vi; } p_validbits |= ((uint16_t)1U << 3); @@ -7450,7 +7624,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 -335; + return -345; a += ud.vi; } p_validbits |= ((uint16_t)1U << 4); @@ -7462,7 +7636,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 -336; + return -346; a += ud.vi; } p_validbits |= ((uint16_t)1U << 5); @@ -7470,14 +7644,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS case 0x112: // ws2812b id 34, type Ws2812bConfig, coding byte[] + m_ws2812b.emplace_back(); if (((ssize_t)ud.vi > 0) && ((ssize_t)ud.vi <= (e-a))) { int n; - n = m_ws2812b.fromMemory((const uint8_t*)a,ud.vi); + n = m_ws2812b.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -337; + return -347; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 6); break; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -7486,10 +7660,10 @@ 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 -338; + return -348; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); break; #endif // CONFIG_DHT #ifdef CONFIG_I2C @@ -7499,7 +7673,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 -339; + return -349; a += ud.vi; } break; @@ -7511,7 +7685,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 -340; + return -350; a += ud.vi; } break; @@ -7522,10 +7696,10 @@ 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 -341; + return -351; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); break; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 @@ -7534,10 +7708,10 @@ 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 -342; + return -352; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); break; #endif // CONFIG_SX1276 #ifdef CONFIG_IOEXTENDERS @@ -7547,7 +7721,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 -343; + return -353; a += ud.vi; } break; @@ -7558,10 +7732,10 @@ 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 -344; + return -354; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); break; #endif // CONFIG_DISPLAY default: @@ -7569,13 +7743,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 -345; + return -355; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -346; + return -356; return a-(const uint8_t *)b; } @@ -7588,10 +7762,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 -347; + return -357; *a++ = 0x5; if ((e-a) < 4) - return -348; + return -358; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -7599,13 +7773,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 -349; + return -359; *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 -350; + return -360; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -7615,13 +7789,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 -351; + return -361; *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 -352; + return -362; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -7635,13 +7809,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpio) { // 'gpio': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -353; + return -363; *a++ = 0x3a; ssize_t gpio_ws = x.calcSize(); n = write_varint(a,e-a,gpio_ws); a += n; if ((n <= 0) || (gpio_ws > (e-a))) - return -354; + return -364; n = x.toMemory(a,e-a); a += n; assert(n == gpio_ws); @@ -7650,13 +7824,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 -355; + return -365; *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 -356; + return -366; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -7666,14 +7840,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 -357; + return -367; *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 -358; + return -368; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -7683,14 +7857,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 -359; + return -369; *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 -360; + return -370; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -7700,14 +7874,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 -361; + return -371; *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 -362; + return -372; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -7718,14 +7892,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -363; + return -373; *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 -364; + return -374; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -7736,14 +7910,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 if (2 > (e-a)) - return -365; + return -375; *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 -366; + return -376; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -7754,50 +7928,49 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -367; + return -377; *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 -368; + return -378; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // has ws2812b? - if (0 != (p_validbits & ((uint16_t)1U << 6))) { + for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -369; + return -379; *a++ = 0x92; *a++ = 0x2; - ssize_t ws2812b_ws = m_ws2812b.calcSize(); + ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -370; - n = m_ws2812b.toMemory(a,e-a); + return -380; + 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 << 7))) { + if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -371; + return -381; *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 -372; + return -382; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -7807,14 +7980,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 -373; + return -383; *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 -374; + return -384; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -7824,14 +7997,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 -375; + return -385; *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 -376; + return -386; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -7839,17 +8012,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE // has onewire? - if (0 != (p_validbits & ((uint16_t)1U << 8))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -377; + return -387; *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 -378; + return -388; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -7857,17 +8030,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 // has sx1276? - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -379; + return -389; *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 -380; + return -390; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -7877,14 +8050,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 -381; + return -391; *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 -382; + return -392; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -7892,17 +8065,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY // has display? - if (0 != (p_validbits & ((uint16_t)1U << 10))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -383; + return -393; *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 -384; + return -394; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -8045,9 +8218,23 @@ void HardwareConfig::toJSON(stream &json, unsigned indLvl) const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b()) { - fsep = json_indent(json,indLvl,fsep,"ws2812b"); - m_ws2812b.toJSON(json,indLvl); + if (size_t s = m_ws2812b.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"ws2812b\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + m_ws2812b[i].toJSON(json,indLvl); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); } #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -8233,10 +8420,12 @@ size_t HardwareConfig::calcSize() const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 - if (has_ws2812b()) { - size_t ws2812b_s = m_ws2812b.calcSize(); - r += ws2812b_s + wiresize(ws2812b_s) + 2 /* tag(ws2812b) 0x110 */; + // repeated Ws2812bConfig ws2812b, id 34 + // repeated message ws2812b + for (size_t x = 0, y = m_ws2812b.size(); x < y; ++x) { + size_t s = m_ws2812b[x].calcSize(); + r += wiresize(s); + r += s + 2 /* tag(ws2812b) 0x110 */; } #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -8338,7 +8527,7 @@ bool HardwareConfig::operator == (const HardwareConfig &r) const return false; #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b() && (!(m_ws2812b == r.m_ws2812b))) + if (!(m_ws2812b == r.m_ws2812b)) return false; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -8425,17 +8614,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -385; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -395; if (m_gpio.size() <= x) - return -386; + return -396; if ((idxe[1] == 0) && (value == 0)) { m_gpio.erase(m_gpio.begin()+x); return 0; } } if (idxe[1] != '.') - return -387; + return -397; return m_gpio[x].setByName(idxe+2,value); } } @@ -8455,17 +8644,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -388; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -398; if (m_spibus.size() <= x) - return -389; + return -399; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -390; + return -400; return m_spibus[x].setByName(idxe+2,value); } } @@ -8486,17 +8675,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -391; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -401; if (m_button.size() <= x) - return -392; + return -402; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -393; + return -403; return m_button[x].setByName(idxe+2,value); } } @@ -8517,17 +8706,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') - return -394; + if ((idxe[0] != ']') || (idxe == (name+6))) + return -404; if (m_relay.size() <= x) - return -395; + return -405; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -396; + return -406; return m_relay[x].setByName(idxe+2,value); } } @@ -8548,17 +8737,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -397; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -407; if (m_led.size() <= x) - return -398; + return -408; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -399; + return -409; return m_led[x].setByName(idxe+2,value); } } @@ -8601,9 +8790,29 @@ int HardwareConfig::setByName(const char *name, const char *value) if ((name[7] == 0) && (value == 0)) { clear_ws2812b(); return 0; - } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 6); - return m_ws2812b.setByName(name+8,value); + } else if (name[7] == '[') { + char *idxe; + unsigned long x; + if ((name[8] == '+') && (name[9] == ']')) { + x = m_ws2812b.size(); + m_ws2812b.resize(x+1); + idxe = (char*)(name + 9); + if (value == 0) + return 0; + } else { + x = strtoul(name+8,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+8))) + return -410; + if (m_ws2812b.size() <= x) + return -411; + if ((idxe[1] == 0) && (value == 0)) { + m_ws2812b.erase(m_ws2812b.begin()+x); + return 0; + } + } + if (idxe[1] != '.') + return -412; + return m_ws2812b[x].setByName(idxe+2,value); } } #endif // CONFIG_RGBLEDS @@ -8613,7 +8822,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_dht(); return 0; } else if (name[3] == '.') { - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); return m_dht.setByName(name+4,value); } } @@ -8634,17 +8843,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -400; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -413; if (m_i2c.size() <= x) - return -401; + return -414; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -402; + return -415; return m_i2c[x].setByName(idxe+2,value); } } @@ -8665,17 +8874,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -403; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -416; if (m_hcsr04.size() <= x) - return -404; + return -417; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -405; + return -418; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -8686,7 +8895,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_onewire(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); return m_onewire.setByName(name+8,value); } } @@ -8697,7 +8906,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_sx1276(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); return m_sx1276.setByName(name+7,value); } } @@ -8718,17 +8927,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -406; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -419; if (m_iocluster.size() <= x) - return -407; + return -420; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -408; + return -421; return m_iocluster[x].setByName(idxe+2,value); } } @@ -8739,12 +8948,12 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_display(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); return m_display.setByName(name+8,value); } } #endif // CONFIG_DISPLAY - return -409; + return -422; } Message *HardwareConfig::p_getMember(const char *s, const char *e) @@ -8765,10 +8974,6 @@ Message *HardwareConfig::p_getMember(const char *s, const char *e) if (0 == strncmp("tlc5947",s,e-s)) return &m_tlc5947; #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS - if (0 == strncmp("ws2812b",s,e-s)) - return &m_ws2812b; - #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT if (0 == strncmp("dht",s,e-s)) return &m_dht; @@ -8823,6 +9028,13 @@ Message *HardwareConfig::p_getMember(const char *s, const char *e, unsigned x) return 0; } #endif // CONFIG_LEDS + #ifdef CONFIG_RGBLEDS + if (0 == strncmp("ws2812b[",s,e-s)) { + if (x < m_ws2812b.size()) + return &m_ws2812b[x]; + return 0; + } + #endif // CONFIG_RGBLEDS #ifdef CONFIG_I2C if (0 == strncmp("i2c[",s,e-s)) { if (x < m_i2c.size()) diff --git a/components/wfc/hwcfg_esp8266.h b/components/wfc/hwcfg_esp8266.h index 4d192b0..01a2b8d 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -174,6 +174,7 @@ typedef enum { i2cdrv_ht16k33 = 10, i2cdrv_ina219 = 11, i2cdrv_si7021 = 12, + i2cdrv_tca9555 = 13, } i2cdrv_t; //! Function to get an ASCII string from a value of a i2cdrv_t. const char *i2cdrv_t_str(i2cdrv_t e); @@ -1725,8 +1726,36 @@ class Ws2812bConfig : public Message */ uint8_t *mutable_nleds(); + // optional string name, id 4 + /*! + * Function for querying if name has been set. + * @return true if name is set. + */ + bool has_name() const; + //! Function to reset name to its default/unset value. + void clear_name(); + //! Get value of name. + const estring &name() const; + /*! + * Function for setting name using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_name(const void *data, size_t s); + //! Set name using a constant reference + void set_name(const estring &v); + //! Set name using a pointer to a null-terminated C-string. + void set_name(const char *); + /*! + * Provide mutable access to name. + * @return pointer to member variable of name. + */ + estring *mutable_name(); + protected: + //! string name, id 4 + estring m_name; //! sint8 gpio, id 1 int8_t m_gpio; // omitted unused member ch @@ -2740,10 +2769,78 @@ class AdcChannel : public Message */ uint8_t *mutable_window(); + // optional float scale, id 8 + /*! + * Function for querying if scale has been set. + * @return true if scale is set. + */ + bool has_scale() const; + //! Function to reset scale to its default/unset value. + void clear_scale(); + //! Get value of scale. + float scale() const; + //! Set scale using a constant reference + void set_scale(float v); + /*! + * Provide mutable access to scale. + * @return pointer to member variable of scale. + */ + float *mutable_scale(); + + // optional float offset, id 9 + /*! + * Function for querying if offset has been set. + * @return true if offset is set. + */ + bool has_offset() const; + //! Function to reset offset to its default/unset value. + void clear_offset(); + //! Get value of offset. + float offset() const; + //! Set offset using a constant reference + void set_offset(float v); + /*! + * Provide mutable access to offset. + * @return pointer to member variable of offset. + */ + float *mutable_offset(); + + // optional string dim, id 10 + /*! + * Function for querying if dim has been set. + * @return true if dim is set. + */ + bool has_dim() const; + //! Function to reset dim to its default/unset value. + void clear_dim(); + //! Get value of dim. + const estring &dim() const; + /*! + * Function for setting dim using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_dim(const void *data, size_t s); + //! Set dim using a constant reference + void set_dim(const estring &v); + //! Set dim using a pointer to a null-terminated C-string. + void set_dim(const char *); + /*! + * Provide mutable access to dim. + * @return pointer to member variable of dim. + */ + estring *mutable_dim(); + protected: //! string name, id 1 estring m_name; + //! string dim, id 10 + estring m_dim; + //! float scale, id 8 + float m_scale; + //! float offset, id 9 + float m_offset; //! uint16 interval, id 5 uint16_t m_interval; //! uint8 unit, id 2 @@ -4514,29 +4611,29 @@ class HardwareConfig : public Message #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 + // repeated Ws2812bConfig ws2812b, id 34 + //! Function get const-access to the elements of ws2812b. + const std::vector &ws2812b() const; + //! Function to get the number of elements in ws2812b. + size_t ws2812b_size() const; /*! - * Function for querying if ws2812b has been set. - * @return true if ws2812b is set. + * Function to append a element to ws2812b. + * @return point to newly added element. */ - bool has_ws2812b() const; + Ws2812bConfig* add_ws2812b(); //! Function to reset ws2812b to its default/unset value. void clear_ws2812b(); - //! Get value of ws2812b. - const Ws2812bConfig &ws2812b() const; - /*! - * Function for setting ws2812b using binary data. - * @param data pointer to binary data - * @param s number of bytes at data pointer - */ - void set_ws2812b(const void *data, size_t s); + //! Get value of element x of ws2812b. + const Ws2812bConfig &ws2812b(unsigned x) const; //! Set ws2812b using a constant reference - void set_ws2812b(const Ws2812bConfig &v); + void set_ws2812b(unsigned x, const Ws2812bConfig &v); /*! * Provide mutable access to ws2812b. * @return pointer to member variable of ws2812b. */ - Ws2812bConfig *mutable_ws2812b(); + 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 @@ -4761,7 +4858,7 @@ class HardwareConfig : public Message #endif // CONFIG_DHT #ifdef CONFIG_RGBLEDS //! Ws2812bConfig ws2812b, id 34 - Ws2812bConfig m_ws2812b; + std::vector m_ws2812b; #endif // CONFIG_RGBLEDS #ifdef CONFIG_TLC5947 //! Tlc5947Config tlc5947, id 33 @@ -6365,7 +6462,8 @@ inline size_t Ws2812bConfig::getMaxSize() // optional sint8 gpio, id 1 has maximum size 3 // unused optional sint8 ch, id 2 // optional uint8 nleds, id 3 has maximum size 3 - return 6; + // optional string name, id 4 has unlimited size + return SIZE_MAX; } inline int8_t Ws2812bConfig::gpio() const @@ -6430,6 +6528,47 @@ inline void Ws2812bConfig::set_nleds(uint8_t v) +inline const estring &Ws2812bConfig::name() const +{ + return m_name; +} + +inline bool Ws2812bConfig::has_name() const +{ + return !m_name.empty(); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void Ws2812bConfig::clear_name() +{ + m_name.clear(); +} + +inline estring *Ws2812bConfig::mutable_name() +{ + return &m_name; +} + +inline void Ws2812bConfig::set_name(const void *data, size_t s) +{ + m_name.assign((const char *)data,s); +} + +inline void Ws2812bConfig::set_name(const char *data) +{ + m_name = data; +} + +inline void Ws2812bConfig::set_name(const estring &v) +{ + m_name = v; +} + + + inline size_t DhtConfig::getMaxSize() { // optional dht_model_t model, id 1 has maximum size 3 @@ -7147,6 +7286,9 @@ inline size_t AdcChannel::getMaxSize() // optional uint8 atten, id 4 has maximum size 3 // optional uint16 interval, id 5 has maximum size 4 // optional uint8 window, id 6 has maximum size 3 + // optional float scale, id 8 has maximum size 5 + // optional float offset, id 9 has maximum size 5 + // optional string dim, id 10 has unlimited size return SIZE_MAX; } @@ -7352,6 +7494,129 @@ inline void AdcChannel::set_window(uint8_t v) +inline float AdcChannel::scale() const +{ + return m_scale; +} + +inline bool AdcChannel::has_scale() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 1)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_scale() +{ + p_validbits &= ~((uint8_t)1U << 1); + m_scale = 1; +} + +inline float *AdcChannel::mutable_scale() +{ + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); + m_scale = 1; + } + return &m_scale; +} + +inline void AdcChannel::set_scale(float v) +{ + m_scale = v; + p_validbits |= ((uint8_t)1U << 1); +} + + + +inline float AdcChannel::offset() const +{ + return m_offset; +} + +inline bool AdcChannel::has_offset() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 2)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_offset() +{ + p_validbits &= ~((uint8_t)1U << 2); + m_offset = 0; +} + +inline float *AdcChannel::mutable_offset() +{ + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); + m_offset = 0; + } + return &m_offset; +} + +inline void AdcChannel::set_offset(float v) +{ + m_offset = v; + p_validbits |= ((uint8_t)1U << 2); +} + + + +inline const estring &AdcChannel::dim() const +{ + return m_dim; +} + +inline bool AdcChannel::has_dim() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 3)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_dim() +{ + p_validbits &= ~((uint8_t)1U << 3); + m_dim.clear(); +} + +inline estring *AdcChannel::mutable_dim() +{ + if (0 == (p_validbits & ((uint8_t)1U << 3))) { + p_validbits |= ((uint8_t)1U << 3); + m_dim.clear(); + } + return &m_dim; +} + +inline void AdcChannel::set_dim(const void *data, size_t s) +{ + m_dim.assign((const char *)data,s); + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const char *data) +{ + m_dim = data; + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const estring &v) +{ + m_dim = v; + p_validbits |= ((uint8_t)1U << 3); +} + + + inline size_t AdcConfig::getMaxSize() { // optional string adc_name, id 1 has unlimited size @@ -8895,7 +9160,7 @@ inline size_t HardwareConfig::getMaxSize() // optional Hlw8012Config hlw8012, id 20 has maximum size 11 // optional Max7219Config max7219, id 32 has maximum size 16 // optional Tlc5947Config tlc5947, id 33 has maximum size 17 - // optional Ws2812bConfig ws2812b, id 34 has maximum size 11 + // repeated Ws2812bConfig ws2812b, id 34 has unlimited size // optional DhtConfig dht, id 35 has maximum size 8 // repeated I2CConfig i2c, id 36 has unlimited size // repeated HcSr04Config hcsr04, id 37 has unlimited size @@ -9423,14 +9688,14 @@ inline void HardwareConfig::set_tlc5947(const Tlc5947Config &v) #ifdef CONFIG_RGBLEDS -inline const Ws2812bConfig &HardwareConfig::ws2812b() const +inline const Ws2812bConfig &HardwareConfig::ws2812b(unsigned x) const { - return m_ws2812b; + return m_ws2812b[x]; } -inline bool HardwareConfig::has_ws2812b() const +inline const std::vector &HardwareConfig::ws2812b() const { - return 0 != (p_validbits & ((uint16_t)1U << 6)); + return m_ws2812b; } /*! @@ -9439,29 +9704,36 @@ inline bool HardwareConfig::has_ws2812b() const */ inline void HardwareConfig::clear_ws2812b() { - p_validbits &= ~((uint16_t)1U << 6); m_ws2812b.clear(); } -inline Ws2812bConfig *HardwareConfig::mutable_ws2812b() +inline Ws2812bConfig *HardwareConfig::mutable_ws2812b(unsigned x) +{ + if (x >= m_ws2812b.size()) + m_ws2812b.resize(x+1); + return &m_ws2812b[x]; +} + +inline std::vector *HardwareConfig::mutable_ws2812b() { - if (0 == (p_validbits & ((uint16_t)1U << 6))) { - p_validbits |= ((uint16_t)1U << 6); - m_ws2812b.clear(); - } return &m_ws2812b; } -inline void HardwareConfig::set_ws2812b(const void *data, size_t s) +inline Ws2812bConfig *HardwareConfig::add_ws2812b() { - m_ws2812b.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 6); + m_ws2812b.resize(m_ws2812b.size()+1); + return &m_ws2812b.back(); } -inline void HardwareConfig::set_ws2812b(const Ws2812bConfig &v) +inline void HardwareConfig::set_ws2812b(unsigned x, const Ws2812bConfig &v) { - m_ws2812b = v; - p_validbits |= ((uint16_t)1U << 6); + assert(x < m_ws2812b.size()); + m_ws2812b[x] = v; +} + +inline size_t HardwareConfig::ws2812b_size() const +{ + return m_ws2812b.size(); } #endif // CONFIG_RGBLEDS @@ -9475,7 +9747,7 @@ inline const DhtConfig &HardwareConfig::dht() const inline bool HardwareConfig::has_dht() const { - return 0 != (p_validbits & ((uint16_t)1U << 7)); + return 0 != (p_validbits & ((uint16_t)1U << 6)); } /*! @@ -9484,14 +9756,14 @@ inline bool HardwareConfig::has_dht() const */ inline void HardwareConfig::clear_dht() { - p_validbits &= ~((uint16_t)1U << 7); + p_validbits &= ~((uint16_t)1U << 6); m_dht.clear(); } inline DhtConfig *HardwareConfig::mutable_dht() { - if (0 == (p_validbits & ((uint16_t)1U << 7))) { - p_validbits |= ((uint16_t)1U << 7); + if (0 == (p_validbits & ((uint16_t)1U << 6))) { + p_validbits |= ((uint16_t)1U << 6); m_dht.clear(); } return &m_dht; @@ -9500,13 +9772,13 @@ inline DhtConfig *HardwareConfig::mutable_dht() inline void HardwareConfig::set_dht(const void *data, size_t s) { m_dht.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); } inline void HardwareConfig::set_dht(const DhtConfig &v) { m_dht = v; - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); } #endif // CONFIG_DHT @@ -9624,7 +9896,7 @@ inline const OneWireConfig &HardwareConfig::onewire() const inline bool HardwareConfig::has_onewire() const { - return 0 != (p_validbits & ((uint16_t)1U << 8)); + return 0 != (p_validbits & ((uint16_t)1U << 7)); } /*! @@ -9633,14 +9905,14 @@ inline bool HardwareConfig::has_onewire() const */ inline void HardwareConfig::clear_onewire() { - p_validbits &= ~((uint16_t)1U << 8); + p_validbits &= ~((uint16_t)1U << 7); m_onewire.clear(); } inline OneWireConfig *HardwareConfig::mutable_onewire() { - if (0 == (p_validbits & ((uint16_t)1U << 8))) { - p_validbits |= ((uint16_t)1U << 8); + if (0 == (p_validbits & ((uint16_t)1U << 7))) { + p_validbits |= ((uint16_t)1U << 7); m_onewire.clear(); } return &m_onewire; @@ -9649,13 +9921,13 @@ inline OneWireConfig *HardwareConfig::mutable_onewire() inline void HardwareConfig::set_onewire(const void *data, size_t s) { m_onewire.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } inline void HardwareConfig::set_onewire(const OneWireConfig &v) { m_onewire = v; - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } #endif // CONFIG_ONEWIRE @@ -9669,7 +9941,7 @@ inline const SX1276Config &HardwareConfig::sx1276() const inline bool HardwareConfig::has_sx1276() const { - return 0 != (p_validbits & ((uint16_t)1U << 9)); + return 0 != (p_validbits & ((uint16_t)1U << 8)); } /*! @@ -9678,14 +9950,14 @@ inline bool HardwareConfig::has_sx1276() const */ inline void HardwareConfig::clear_sx1276() { - p_validbits &= ~((uint16_t)1U << 9); + p_validbits &= ~((uint16_t)1U << 8); m_sx1276.clear(); } inline SX1276Config *HardwareConfig::mutable_sx1276() { - if (0 == (p_validbits & ((uint16_t)1U << 9))) { - p_validbits |= ((uint16_t)1U << 9); + if (0 == (p_validbits & ((uint16_t)1U << 8))) { + p_validbits |= ((uint16_t)1U << 8); m_sx1276.clear(); } return &m_sx1276; @@ -9694,13 +9966,13 @@ inline SX1276Config *HardwareConfig::mutable_sx1276() inline void HardwareConfig::set_sx1276(const void *data, size_t s) { m_sx1276.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } inline void HardwareConfig::set_sx1276(const SX1276Config &v) { m_sx1276 = v; - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } #endif // CONFIG_SX1276 @@ -9766,7 +10038,7 @@ inline const DisplayConfig &HardwareConfig::display() const inline bool HardwareConfig::has_display() const { - return 0 != (p_validbits & ((uint16_t)1U << 10)); + return 0 != (p_validbits & ((uint16_t)1U << 9)); } /*! @@ -9775,14 +10047,14 @@ inline bool HardwareConfig::has_display() const */ inline void HardwareConfig::clear_display() { - p_validbits &= ~((uint16_t)1U << 10); + p_validbits &= ~((uint16_t)1U << 9); m_display.clear(); } inline DisplayConfig *HardwareConfig::mutable_display() { - if (0 == (p_validbits & ((uint16_t)1U << 10))) { - p_validbits |= ((uint16_t)1U << 10); + if (0 == (p_validbits & ((uint16_t)1U << 9))) { + p_validbits |= ((uint16_t)1U << 9); m_display.clear(); } return &m_display; @@ -9791,13 +10063,13 @@ inline DisplayConfig *HardwareConfig::mutable_display() inline void HardwareConfig::set_display(const void *data, size_t s) { m_display.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } inline void HardwareConfig::set_display(const DisplayConfig &v) { m_display = v; - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } #endif // CONFIG_DISPLAY diff --git a/components/wfc/hwcfg_esp8285.cpp b/components/wfc/hwcfg_esp8285.cpp index 68fec59..3c8b76d 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -295,6 +295,7 @@ static const char *i2cdrv_t_names[] = { "i2cdrv_pca9685_xclk_pnp", "i2cdrv_pcf8574", "i2cdrv_si7021", + "i2cdrv_tca9555", }; static i2cdrv_t i2cdrv_t_values[] = { @@ -311,6 +312,7 @@ static i2cdrv_t i2cdrv_t_values[] = { i2cdrv_pca9685_xclk_pnp, i2cdrv_pcf8574, i2cdrv_si7021, + i2cdrv_tca9555, }; #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB @@ -331,6 +333,7 @@ size_t parse_ascii_i2cdrv_t(i2cdrv_t *v, const char *s) { "i2cdrv_pca9685_xclk_pnp", i2cdrv_pca9685_xclk_pnp}, { "i2cdrv_pcf8574", i2cdrv_pcf8574}, { "i2cdrv_si7021", i2cdrv_si7021}, + { "i2cdrv_tca9555", i2cdrv_tca9555}, }; #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB char *e; @@ -388,6 +391,8 @@ const char *i2cdrv_t_str(i2cdrv_t e) return "i2cdrv_ina219"; case i2cdrv_si7021: return "i2cdrv_si7021"; + case i2cdrv_tca9555: + return "i2cdrv_tca9555"; } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB #ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB @@ -2853,7 +2858,8 @@ int Tlc5947Config::setByName(const char *name, const char *value) } Ws2812bConfig::Ws2812bConfig() -: m_gpio(-1) +: m_name() +, m_gpio(-1) // omitted unused member ch , m_nleds(0) { @@ -2863,6 +2869,7 @@ void Ws2812bConfig::clear() { m_gpio = -1; m_nleds = 0; + m_name.clear(); } void Ws2812bConfig::toASCII(stream &o, size_t indent) const @@ -2871,6 +2878,7 @@ void Ws2812bConfig::toASCII(stream &o, size_t indent) const ++indent; ascii_numeric(o, indent, "gpio", (signed) m_gpio); ascii_numeric(o, indent, "nleds", (unsigned) m_nleds); + ascii_string(o,indent,m_name.data(),m_name.size(),"name"); --indent; ascii_indent(o,indent); o << '}'; @@ -2894,18 +2902,25 @@ ssize_t Ws2812bConfig::fromMemory(const void *b, ssize_t s) case 0x18: // nleds id 3, type uint8_t, coding varint set_nleds((uint8_t)ud.u32); break; + case 0x22: // name id 4, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -116; + } + m_name.assign((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 -116; + return -117; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -117; + return -118; return a-(const uint8_t *)b; } @@ -2918,11 +2933,11 @@ ssize_t Ws2812bConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -118; + return -119; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -119; + return -120; a += n; } // 'ch' is unused. Therefore no data will be written. @@ -2930,11 +2945,22 @@ ssize_t Ws2812bConfig::toMemory(uint8_t *b, ssize_t s) const if (m_nleds != 0) { // 'nleds': id=3, encoding=varint, tag=0x18 if (a >= e) - return -120; + return -121; *a++ = 0x18; n = write_varint(a,e-a,m_nleds); if (n <= 0) - return -121; + return -122; + a += n; + } + // has name? + if (!m_name.empty()) { + // 'name': id=4, encoding=lenpfx, tag=0x22 + if (a >= e) + return -123; + *a++ = 0x22; + n = encode_bytes(m_name,a,e); + if (n < 0) + return -124; a += n; } assert(a <= e); @@ -2953,6 +2979,10 @@ void Ws2812bConfig::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"nleds"); to_decstr(json,(unsigned) m_nleds); } + if (has_name()) { + fsep = json_indent(json,indLvl,fsep,"name"); + json_cstr(json,m_name.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -2975,6 +3005,11 @@ size_t Ws2812bConfig::calcSize() const if (has_nleds()) { r += wiresize((varint_t)m_nleds) + 1 /* tag(nleds) 0x18 */; } + // optional string name, id 4 + if (has_name()) { + size_t name_s = m_name.size(); + r += name_s + wiresize(name_s) + 1 /* tag(name) 0x20 */; + } return r; } @@ -2984,6 +3019,8 @@ bool Ws2812bConfig::operator == (const Ws2812bConfig &r) const return false; if (has_nleds() && (!(m_nleds == r.m_nleds))) return false; + if (has_name() && (!(m_name == r.m_name))) + return false; return true; } @@ -3013,7 +3050,16 @@ int Ws2812bConfig::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_nleds,value); return r; } - return -122; + if (0 == strcmp(name,"name")) { + if (value == 0) { + clear_name(); + return 0; + } + m_name = value; + int r = m_name.size(); + return r; + } + return -125; } DhtConfig::DhtConfig() @@ -3053,7 +3099,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -123; + return -126; a += x; switch (fid) { case 0x8: // model id 1, type dht_model_t, coding varint @@ -3067,13 +3113,13 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -124; + return -127; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -125; + return -128; return a-(const uint8_t *)b; } @@ -3086,22 +3132,22 @@ ssize_t DhtConfig::toMemory(uint8_t *b, ssize_t s) const if (m_model != DHT_NONE) { // 'model': id=1, encoding=varint, tag=0x8 if (a >= e) - return -126; + return -129; *a++ = 0x8; n = write_varint(a,e-a,m_model); if (n <= 0) - return -127; + return -130; a += n; } // has gpio? if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -128; + return -131; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -129; + return -132; a += n; } assert(a <= e); @@ -3177,7 +3223,7 @@ int DhtConfig::setByName(const char *name, const char *value) dht_model_t v; size_t r = parse_ascii_dht_model_t(&v,value); if (r == 0) - return -130; + return -133; set_model(v); return r; } @@ -3189,7 +3235,7 @@ int DhtConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_gpio,value); return r; } - return -131; + return -134; } I2CConfig::I2CConfig() @@ -3262,7 +3308,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -132; + return -135; a += x; switch (fid) { case 0x8: // port id 1, type uint8_t, coding varint @@ -3285,7 +3331,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -133; + return -136; a += n; m_devices.push_back((i2cdev_t)v); } while (a < ae); @@ -3297,13 +3343,13 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -134; + return -137; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -135; + return -138; return a-(const uint8_t *)b; } @@ -3316,33 +3362,33 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -136; + return -139; *a++ = 0x8; n = write_varint(a,e-a,m_port); if (n <= 0) - return -137; + return -140; a += n; } // has sda? if (m_sda != -1) { // 'sda': id=2, encoding=varint, tag=0x10 if (a >= e) - return -138; + return -141; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sda)); if (n <= 0) - return -139; + return -142; a += n; } // has scl? if (m_scl != -1) { // 'scl': id=3, encoding=varint, tag=0x18 if (a >= e) - return -140; + return -143; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_scl)); if (n <= 0) - return -141; + return -144; a += n; } // 'freq' is unused. Therefore no data will be written. @@ -3350,7 +3396,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (m_xpullup != false) { // 'xpullup': id=5, encoding=8bit, tag=0x2b if (2 > (e-a)) - return -142; + return -145; *a++ = 0x2b; *a++ = m_xpullup; } @@ -3358,7 +3404,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -143; + return -146; *a++ = 0x32; ssize_t devices_ws = 0; for (size_t x = 0; x != devices_ne; ++x) @@ -3366,7 +3412,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -144; + return -147; for (size_t x = 0; x != devices_ne; ++x) a += write_varint(a,e-a,m_devices[x]); } @@ -3537,10 +3583,10 @@ int I2CConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -145; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -148; if (m_devices.size() <= x) - return -146; + return -149; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; @@ -3553,7 +3599,7 @@ int I2CConfig::setByName(const char *name, const char *value) return eptr - value; } if (idxe[1] != '.') - return -147; + return -150; idxe += 2; if (!strcmp("addr",idxe)) { if (eptr != value) { @@ -3574,11 +3620,11 @@ int I2CConfig::setByName(const char *name, const char *value) } } } - return -148; + return -151; } } #endif // CONFIG_I2C_XDEV - return -149; + return -152; } HcSr04Config::HcSr04Config() @@ -3616,7 +3662,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -150; + return -153; a += x; switch (fid) { case 0x8: // trigger id 1, type int8_t, coding signed varint @@ -3627,7 +3673,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) break; case 0x1a: // name id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -151; + return -154; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -3637,13 +3683,13 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -152; + return -155; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -153; + return -156; return a-(const uint8_t *)b; } @@ -3656,33 +3702,33 @@ ssize_t HcSr04Config::toMemory(uint8_t *b, ssize_t s) const if (m_trigger != -1) { // 'trigger': id=1, encoding=varint, tag=0x8 if (a >= e) - return -154; + return -157; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_trigger)); if (n <= 0) - return -155; + return -158; a += n; } // has echo? if (m_echo != -1) { // 'echo': id=2, encoding=varint, tag=0x10 if (a >= e) - return -156; + return -159; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_echo)); if (n <= 0) - return -157; + return -160; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -158; + return -161; *a++ = 0x1a; n = encode_bytes(m_name,a,e); if (n < 0) - return -159; + return -162; a += n; } assert(a <= e); @@ -3780,7 +3826,7 @@ int HcSr04Config::setByName(const char *name, const char *value) int r = m_name.size(); return r; } - return -160; + return -163; } LedConfig::LedConfig() @@ -3831,7 +3877,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -161; + return -164; a += x; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -3842,7 +3888,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) break; case 0x1a: // name id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -162; + return -165; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -3855,13 +3901,13 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -163; + return -166; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -164; + return -167; return a-(const uint8_t *)b; } @@ -3874,44 +3920,44 @@ ssize_t LedConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -165; + return -168; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -166; + return -169; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=2, encoding=varint, tag=0x10 if (a >= e) - return -167; + return -170; *a++ = 0x10; n = write_varint(a,e-a,m_config); if (n <= 0) - return -168; + return -171; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -169; + return -172; *a++ = 0x1a; n = encode_bytes(m_name,a,e); if (n < 0) - return -170; + return -173; a += n; } // has pwm_ch? if (m_pwm_ch != -1) { // 'pwm_ch': id=4, encoding=varint, tag=0x20 if (a >= e) - return -171; + return -174; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_pwm_ch)); if (n <= 0) - return -172; + return -175; a += n; } assert(a <= e); @@ -4019,7 +4065,7 @@ int LedConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -173; + return -176; } else if (!strcmp(name,"active_high")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -4052,7 +4098,7 @@ int LedConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_pwm_ch,value); return r; } - return -174; + return -177; } OneWireConfig::OneWireConfig() @@ -4090,7 +4136,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -175; + return -178; a += x; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -4107,13 +4153,13 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -176; + return -179; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -177; + return -180; return a-(const uint8_t *)b; } @@ -4126,18 +4172,18 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -178; + return -181; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -179; + return -182; a += n; } // has pullup? if (m_pullup != false) { // 'pullup': id=2, encoding=8bit, tag=0x13 if (2 > (e-a)) - return -180; + return -183; *a++ = 0x13; *a++ = m_pullup; } @@ -4145,11 +4191,11 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_power != -1) { // 'power': id=3, encoding=varint, tag=0x18 if (a >= e) - return -181; + return -184; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_power)); if (n <= 0) - return -182; + return -185; a += n; } assert(a <= e); @@ -4245,7 +4291,7 @@ int OneWireConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_power,value); return r; } - return -183; + return -186; } UartConfig::UartConfig() @@ -4281,7 +4327,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -184; + return -187; a += x; switch (fid) { case 0x8: // port id 1, type int8_t, coding signed varint @@ -4292,13 +4338,13 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -185; + return -188; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -186; + return -189; return a-(const uint8_t *)b; } @@ -4311,11 +4357,11 @@ ssize_t UartConfig::toMemory(uint8_t *b, ssize_t s) const if (m_port != -1) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -187; + return -190; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_port)); if (n <= 0) - return -188; + return -191; a += n; } // 'tx_gpio' is unused. Therefore no data will be written. @@ -4383,11 +4429,14 @@ int UartConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_port,value); return r; } - return -189; + return -192; } AdcChannel::AdcChannel() : m_name() +, m_dim() +, m_scale(1) +, m_offset(0) , m_interval(0) , m_unit(0) , m_ch(-1) @@ -4405,6 +4454,9 @@ void AdcChannel::clear() m_atten = 0; m_interval = 0; m_window = 0; + m_scale = 1; + m_offset = 0; + m_dim.clear(); p_validbits = 0; } @@ -4418,6 +4470,9 @@ void AdcChannel::toASCII(stream &o, size_t indent) const ascii_numeric(o, indent, "atten", (unsigned) m_atten); ascii_numeric(o, indent, "interval", m_interval); ascii_numeric(o, indent, "window", (unsigned) m_window); + ascii_numeric(o, indent, "scale", m_scale); + ascii_numeric(o, indent, "offset", m_offset); + ascii_string(o,indent,m_dim.data(),m_dim.size(),"dim"); --indent; ascii_indent(o,indent); o << '}'; @@ -4432,12 +4487,12 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -190; + return -193; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -191; + return -194; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -4457,18 +4512,32 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) case 0x30: // window id 6, type uint8_t, coding varint set_window((uint8_t)ud.u32); break; + case 0x45: // scale id 8, type float, coding 32bit + set_scale(ud.f); + break; + case 0x4d: // offset id 9, type float, coding 32bit + set_offset(ud.f); + break; + case 0x52: // dim id 10, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -195; + } + m_dim.assign((const char*)a,ud.vi); + p_validbits |= ((uint8_t)1U << 3); + a += ud.vi; + break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data a += ud.vi; if (a > e) - return -192; + return -196; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -193; + return -197; return a-(const uint8_t *)b; } @@ -4481,66 +4550,99 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -194; + return -198; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -195; + return -199; a += n; } // has unit? if (m_unit != 0) { // 'unit': id=2, encoding=varint, tag=0x10 if (a >= e) - return -196; + return -200; *a++ = 0x10; n = write_varint(a,e-a,m_unit); if (n <= 0) - return -197; + return -201; a += n; } // has ch? if (m_ch != -1) { // 'ch': id=3, encoding=varint, tag=0x18 if (a >= e) - return -198; + return -202; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_ch)); if (n <= 0) - return -199; + return -203; a += n; } // has atten? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'atten': id=4, encoding=varint, tag=0x20 if (a >= e) - return -200; + return -204; *a++ = 0x20; n = write_varint(a,e-a,m_atten); if (n <= 0) - return -201; + return -205; a += n; } // has interval? if (m_interval != 0) { // 'interval': id=5, encoding=varint, tag=0x28 if (a >= e) - return -202; + return -206; *a++ = 0x28; n = write_varint(a,e-a,m_interval); if (n <= 0) - return -203; + return -207; a += n; } // has window? if (m_window != 0) { // 'window': id=6, encoding=varint, tag=0x30 if (a >= e) - return -204; + return -208; *a++ = 0x30; n = write_varint(a,e-a,m_window); if (n <= 0) - return -205; + return -209; + a += n; + } + // has scale? + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + // 'scale': id=8, encoding=32bit, tag=0x45 + if (5 > (e-a)) + return -210; + *a++ = 0x45; + if ((e-a) < 4) + return -211; + write_u32(a,mangle_float(m_scale)); + a += 4; + } + // has offset? + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + // 'offset': id=9, encoding=32bit, tag=0x4d + if (5 > (e-a)) + return -212; + *a++ = 0x4d; + if ((e-a) < 4) + return -213; + write_u32(a,mangle_float(m_offset)); + a += 4; + } + // has dim? + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + // 'dim': id=10, encoding=lenpfx, tag=0x52 + if (a >= e) + return -214; + *a++ = 0x52; + n = encode_bytes(m_dim,a,e); + if (n < 0) + return -215; a += n; } assert(a <= e); @@ -4575,6 +4677,18 @@ void AdcChannel::toJSON(stream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"window"); to_decstr(json,(unsigned) m_window); } + if (has_scale()) { + fsep = json_indent(json,indLvl,fsep,"scale"); + to_dblstr(json,m_scale); + } + if (has_offset()) { + fsep = json_indent(json,indLvl,fsep,"offset"); + to_dblstr(json,m_offset); + } + if (has_dim()) { + fsep = json_indent(json,indLvl,fsep,"dim"); + json_cstr(json,m_dim.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -4613,6 +4727,19 @@ size_t AdcChannel::calcSize() const if (has_window()) { r += wiresize((varint_t)m_window) + 1 /* tag(window) 0x30 */; } + // optional float scale, id 8 + if (has_scale()) { + r += 5; + } + // optional float offset, id 9 + if (has_offset()) { + r += 5; + } + // optional string dim, id 10 + if (has_dim()) { + size_t dim_s = m_dim.size(); + r += dim_s + wiresize(dim_s) + 1 /* tag(dim) 0x50 */; + } return r; } @@ -4632,6 +4759,12 @@ bool AdcChannel::operator == (const AdcChannel &r) const return false; if (has_window() && (!(m_window == r.m_window))) return false; + if (has_scale() && (!(m_scale == r.m_scale))) + return false; + if (has_offset() && (!(m_offset == r.m_offset))) + return false; + if (has_dim() && (!(m_dim == r.m_dim))) + return false; return true; } @@ -4696,7 +4829,38 @@ int AdcChannel::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_window,value); return r; } - return -206; + if (0 == strcmp(name,"scale")) { + if (value == 0) { + clear_scale(); + return 0; + } + int r = parse_ascii_flt(&m_scale,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 1); + return r; + } + if (0 == strcmp(name,"offset")) { + if (value == 0) { + clear_offset(); + return 0; + } + int r = parse_ascii_flt(&m_offset,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 2); + return r; + } + if (0 == strcmp(name,"dim")) { + if (value == 0) { + clear_dim(); + return 0; + } + m_dim = value; + int r = m_dim.size(); + if (r > 0) + p_validbits |= ((uint8_t)1U << 3); + return r; + } + return -216; } AdcConfig::AdcConfig() @@ -4740,12 +4904,12 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -207; + return -217; a += x; switch (fid) { case 0xa: // adc_name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -208; + return -218; } m_adc_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -4761,13 +4925,13 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -209; + return -219; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -210; + return -220; return a-(const uint8_t *)b; } @@ -4780,11 +4944,11 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_adc_name.empty()) { // 'adc_name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -211; + return -221; *a++ = 0xa; n = encode_bytes(m_adc_name,a,e); if (n < 0) - return -212; + return -222; a += n; } // 'adc1_bits' is unused. Therefore no data will be written. @@ -4793,22 +4957,22 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'mode': id=4, encoding=varint, tag=0x20 if (a >= e) - return -213; + return -223; *a++ = 0x20; n = write_varint(a,e-a,m_mode); if (n <= 0) - return -214; + return -224; a += n; } // has clk_div? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'clk_div': id=5, encoding=varint, tag=0x28 if (a >= e) - return -215; + return -225; *a++ = 0x28; n = write_varint(a,e-a,m_clk_div); if (n <= 0) - return -216; + return -226; a += n; } // 'hall_name' is unused. Therefore no data will be written. @@ -4918,7 +5082,7 @@ int AdcConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 1); return r; } - return -217; + return -227; } GpioConfig::GpioConfig() @@ -4983,12 +5147,12 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -218; + return -228; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -219; + return -229; } m_name.assign((const char*)a,ud.vi); p_validbits |= ((uint8_t)1U << 0); @@ -5005,13 +5169,13 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -220; + return -230; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -221; + return -231; return a-(const uint8_t *)b; } @@ -5024,33 +5188,33 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -222; + return -232; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -223; + return -233; a += n; } // has gpio? if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -224; + return -234; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -225; + return -235; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) - return -226; + return -236; *a++ = 0x18; n = write_varint(a,e-a,m_config); if (n <= 0) - return -227; + return -237; a += n; } assert(a <= e); @@ -5169,7 +5333,7 @@ int GpioConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -228; + return -238; } else if (!strcmp(name,"mode")) { uint8_t tmp; size_t r = parse_ascii_u8(&tmp,value); @@ -5215,7 +5379,7 @@ int GpioConfig::setByName(const char *name, const char *value) } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB } - return -229; + return -239; } DisplayConfig::DisplayConfig() @@ -5263,7 +5427,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -230; + return -240; a += x; switch (fid) { case 0x8: // type id 1, type disp_t, coding varint @@ -5283,13 +5447,13 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -231; + return -241; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -232; + return -242; return a-(const uint8_t *)b; } @@ -5302,44 +5466,44 @@ 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 -233; + return -243; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -234; + return -244; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -235; + return -245; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -236; + return -246; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -237; + return -247; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -238; + return -248; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -239; + return -249; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -240; + return -250; a += n; } assert(a <= e); @@ -5437,7 +5601,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 -241; + return -251; set_type(v); return r; } @@ -5471,7 +5635,7 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -242; + return -252; } SpiDeviceConfig::SpiDeviceConfig() @@ -5520,7 +5684,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 -243; + return -253; a += x; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -5543,13 +5707,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 -244; + return -254; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -245; + return -255; return a-(const uint8_t *)b; } @@ -5562,55 +5726,55 @@ 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 -246; + return -256; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -247; + return -257; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -248; + return -258; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -249; + return -259; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -250; + return -260; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -251; + return -261; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -252; + return -262; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -253; + return -263; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -254; + return -264; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -255; + return -265; a += n; } assert(a <= e); @@ -5716,7 +5880,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 -256; + return -266; set_drv(v); return r; } @@ -5752,7 +5916,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cd,value); return r; } - return -257; + return -267; } SpiBusConfig::SpiBusConfig() @@ -5843,7 +6007,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 -258; + return -268; a += x; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -5876,7 +6040,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 -259; + return -269; a += ud.vi; } break; @@ -5885,13 +6049,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 -260; + return -270; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -261; + return -271; return a-(const uint8_t *)b; } @@ -5904,100 +6068,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 -262; + return -272; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -263; + return -273; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -264; + return -274; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -265; + return -275; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -266; + return -276; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -267; + return -277; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -268; + return -278; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -269; + return -279; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -270; + return -280; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -271; + return -281; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -272; + return -282; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -273; + return -283; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -274; + return -284; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -275; + return -285; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -276; + return -286; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -277; + return -287; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -278; + return -288; *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 -279; + return -289; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -6223,7 +6387,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -280; + return -290; } else if (!strcmp(name,"txlsbfirst")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -6292,21 +6456,21 @@ int SpiBusConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -281; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -291; if (m_devices.size() <= x) - return -282; + return -292; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -283; + return -293; return m_devices[x].setByName(idxe+2,value); } } - return -284; + return -294; } GpioCluster::GpioCluster() @@ -6350,12 +6514,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 -285; + return -295; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -286; + return -296; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -6377,13 +6541,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 -287; + return -297; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -288; + return -298; return a-(const uint8_t *)b; } @@ -6396,55 +6560,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 -289; + return -299; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -290; + return -300; a += n; } // has base? if (m_base != 0) { // 'base': id=2, encoding=varint, tag=0x10 if (a >= e) - return -291; + return -301; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -292; + return -302; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -293; + return -303; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -294; + return -304; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -295; + return -305; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -296; + return -306; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -297; + return -307; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -298; + return -308; a += n; } assert(a <= e); @@ -6578,7 +6742,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -299; + return -309; } Hlw8012Config::Hlw8012Config() @@ -6616,7 +6780,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 -300; + return -310; a += x; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -6633,13 +6797,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 -301; + return -311; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -302; + return -312; return a-(const uint8_t *)b; } @@ -6652,33 +6816,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 -303; + return -313; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -304; + return -314; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -305; + return -315; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -306; + return -316; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -307; + return -317; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -308; + return -318; a += n; } assert(a <= e); @@ -6774,7 +6938,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -309; + return -319; } SX1276Config::SX1276Config() @@ -6821,7 +6985,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 -310; + return -320; a += x; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -6847,13 +7011,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 -311; + return -321; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -312; + return -322; return a-(const uint8_t *)b; } @@ -6866,66 +7030,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 -313; + return -323; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -314; + return -324; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -315; + return -325; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -316; + return -326; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -317; + return -327; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -318; + return -328; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -319; + return -329; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -320; + return -330; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -321; + return -331; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -322; + return -332; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -323; + return -333; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -324; + return -334; a += n; } assert(a <= e); @@ -7075,7 +7239,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -325; + return -335; } HardwareConfig::HardwareConfig() @@ -7265,8 +7429,18 @@ void HardwareConfig::toASCII(stream &o, size_t indent) const m_tlc5947.toASCII(o,indent); #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - ascii_indent(o,indent,"ws2812b"); - m_ws2812b.toASCII(o,indent); + ascii_indent(o,indent); + size_t s_ws2812b = m_ws2812b.size(); + o << "ws2812b[" << s_ws2812b << "] = {"; + ++indent; + for (size_t i = 0, e = s_ws2812b; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + m_ws2812b[i].toASCII(o,indent); + } + --indent; + ascii_indent(o,indent); + o << '}'; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT ascii_indent(o,indent,"dht"); @@ -7340,7 +7514,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 -326; + return -336; a += x; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit @@ -7351,7 +7525,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 -327; + return -337; a += ud.vi; } p_validbits |= ((uint16_t)1U << 1); @@ -7361,7 +7535,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 -328; + return -338; a += ud.vi; } p_validbits |= ((uint16_t)1U << 2); @@ -7372,7 +7546,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) int n; n = m_gpio.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -329; + return -339; a += ud.vi; } break; @@ -7383,7 +7557,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 -330; + return -340; a += ud.vi; } break; @@ -7395,7 +7569,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 -331; + return -341; a += ud.vi; } break; @@ -7407,7 +7581,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 -332; + return -342; a += ud.vi; } break; @@ -7419,7 +7593,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 -333; + return -343; a += ud.vi; } break; @@ -7430,7 +7604,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 -334; + return -344; a += ud.vi; } p_validbits |= ((uint16_t)1U << 3); @@ -7442,7 +7616,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 -335; + return -345; a += ud.vi; } p_validbits |= ((uint16_t)1U << 4); @@ -7454,7 +7628,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 -336; + return -346; a += ud.vi; } p_validbits |= ((uint16_t)1U << 5); @@ -7462,14 +7636,14 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS case 0x112: // ws2812b id 34, type Ws2812bConfig, coding byte[] + m_ws2812b.emplace_back(); if (((ssize_t)ud.vi > 0) && ((ssize_t)ud.vi <= (e-a))) { int n; - n = m_ws2812b.fromMemory((const uint8_t*)a,ud.vi); + n = m_ws2812b.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -337; + return -347; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 6); break; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -7478,10 +7652,10 @@ 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 -338; + return -348; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); break; #endif // CONFIG_DHT #ifdef CONFIG_I2C @@ -7491,7 +7665,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 -339; + return -349; a += ud.vi; } break; @@ -7503,7 +7677,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 -340; + return -350; a += ud.vi; } break; @@ -7514,10 +7688,10 @@ 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 -341; + return -351; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); break; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 @@ -7526,10 +7700,10 @@ 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 -342; + return -352; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); break; #endif // CONFIG_SX1276 #ifdef CONFIG_IOEXTENDERS @@ -7539,7 +7713,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 -343; + return -353; a += ud.vi; } break; @@ -7550,10 +7724,10 @@ 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 -344; + return -354; a += ud.vi; } - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); break; #endif // CONFIG_DISPLAY default: @@ -7561,13 +7735,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 -345; + return -355; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -346; + return -356; return a-(const uint8_t *)b; } @@ -7580,10 +7754,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 -347; + return -357; *a++ = 0x5; if ((e-a) < 4) - return -348; + return -358; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -7591,13 +7765,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 -349; + return -359; *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 -350; + return -360; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -7607,13 +7781,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 -351; + return -361; *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 -352; + return -362; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -7627,13 +7801,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpio) { // 'gpio': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -353; + return -363; *a++ = 0x3a; ssize_t gpio_ws = x.calcSize(); n = write_varint(a,e-a,gpio_ws); a += n; if ((n <= 0) || (gpio_ws > (e-a))) - return -354; + return -364; n = x.toMemory(a,e-a); a += n; assert(n == gpio_ws); @@ -7642,13 +7816,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 -355; + return -365; *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 -356; + return -366; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -7658,14 +7832,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 -357; + return -367; *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 -358; + return -368; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -7675,14 +7849,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 -359; + return -369; *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 -360; + return -370; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -7692,14 +7866,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 -361; + return -371; *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 -362; + return -372; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -7710,14 +7884,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 3))) { // 'hlw8012': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -363; + return -373; *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 -364; + return -374; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -7728,14 +7902,14 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 4))) { // 'max7219': id=32, encoding=lenpfx, tag=0x102 if (2 > (e-a)) - return -365; + return -375; *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 -366; + return -376; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -7746,50 +7920,49 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint16_t)1U << 5))) { // 'tlc5947': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -367; + return -377; *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 -368; + return -378; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // has ws2812b? - if (0 != (p_validbits & ((uint16_t)1U << 6))) { + for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -369; + return -379; *a++ = 0x92; *a++ = 0x2; - ssize_t ws2812b_ws = m_ws2812b.calcSize(); + ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -370; - n = m_ws2812b.toMemory(a,e-a); + return -380; + 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 << 7))) { + if (0 != (p_validbits & ((uint16_t)1U << 6))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -371; + return -381; *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 -372; + return -382; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -7799,14 +7972,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 -373; + return -383; *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 -374; + return -384; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -7816,14 +7989,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 -375; + return -385; *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 -376; + return -386; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -7831,17 +8004,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE // has onewire? - if (0 != (p_validbits & ((uint16_t)1U << 8))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -377; + return -387; *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 -378; + return -388; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -7849,17 +8022,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 // has sx1276? - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -379; + return -389; *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 -380; + return -390; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -7869,14 +8042,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 -381; + return -391; *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 -382; + return -392; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -7884,17 +8057,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY // has display? - if (0 != (p_validbits & ((uint16_t)1U << 10))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -383; + return -393; *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 -384; + return -394; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -8037,9 +8210,23 @@ void HardwareConfig::toJSON(stream &json, unsigned indLvl) const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b()) { - fsep = json_indent(json,indLvl,fsep,"ws2812b"); - m_ws2812b.toJSON(json,indLvl); + if (size_t s = m_ws2812b.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"ws2812b\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + m_ws2812b[i].toJSON(json,indLvl); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); } #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -8225,10 +8412,12 @@ size_t HardwareConfig::calcSize() const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 - if (has_ws2812b()) { - size_t ws2812b_s = m_ws2812b.calcSize(); - r += ws2812b_s + wiresize(ws2812b_s) + 2 /* tag(ws2812b) 0x110 */; + // repeated Ws2812bConfig ws2812b, id 34 + // repeated message ws2812b + for (size_t x = 0, y = m_ws2812b.size(); x < y; ++x) { + size_t s = m_ws2812b[x].calcSize(); + r += wiresize(s); + r += s + 2 /* tag(ws2812b) 0x110 */; } #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -8330,7 +8519,7 @@ bool HardwareConfig::operator == (const HardwareConfig &r) const return false; #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b() && (!(m_ws2812b == r.m_ws2812b))) + if (!(m_ws2812b == r.m_ws2812b)) return false; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -8417,17 +8606,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -385; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -395; if (m_gpio.size() <= x) - return -386; + return -396; if ((idxe[1] == 0) && (value == 0)) { m_gpio.erase(m_gpio.begin()+x); return 0; } } if (idxe[1] != '.') - return -387; + return -397; return m_gpio[x].setByName(idxe+2,value); } } @@ -8447,17 +8636,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -388; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -398; if (m_spibus.size() <= x) - return -389; + return -399; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -390; + return -400; return m_spibus[x].setByName(idxe+2,value); } } @@ -8478,17 +8667,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -391; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -401; if (m_button.size() <= x) - return -392; + return -402; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -393; + return -403; return m_button[x].setByName(idxe+2,value); } } @@ -8509,17 +8698,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') - return -394; + if ((idxe[0] != ']') || (idxe == (name+6))) + return -404; if (m_relay.size() <= x) - return -395; + return -405; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -396; + return -406; return m_relay[x].setByName(idxe+2,value); } } @@ -8540,17 +8729,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -397; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -407; if (m_led.size() <= x) - return -398; + return -408; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -399; + return -409; return m_led[x].setByName(idxe+2,value); } } @@ -8593,9 +8782,29 @@ int HardwareConfig::setByName(const char *name, const char *value) if ((name[7] == 0) && (value == 0)) { clear_ws2812b(); return 0; - } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 6); - return m_ws2812b.setByName(name+8,value); + } else if (name[7] == '[') { + char *idxe; + unsigned long x; + if ((name[8] == '+') && (name[9] == ']')) { + x = m_ws2812b.size(); + m_ws2812b.resize(x+1); + idxe = (char*)(name + 9); + if (value == 0) + return 0; + } else { + x = strtoul(name+8,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+8))) + return -410; + if (m_ws2812b.size() <= x) + return -411; + if ((idxe[1] == 0) && (value == 0)) { + m_ws2812b.erase(m_ws2812b.begin()+x); + return 0; + } + } + if (idxe[1] != '.') + return -412; + return m_ws2812b[x].setByName(idxe+2,value); } } #endif // CONFIG_RGBLEDS @@ -8605,7 +8814,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_dht(); return 0; } else if (name[3] == '.') { - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); return m_dht.setByName(name+4,value); } } @@ -8626,17 +8835,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -400; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -413; if (m_i2c.size() <= x) - return -401; + return -414; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -402; + return -415; return m_i2c[x].setByName(idxe+2,value); } } @@ -8657,17 +8866,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -403; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -416; if (m_hcsr04.size() <= x) - return -404; + return -417; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -405; + return -418; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -8678,7 +8887,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_onewire(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); return m_onewire.setByName(name+8,value); } } @@ -8689,7 +8898,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_sx1276(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); return m_sx1276.setByName(name+7,value); } } @@ -8710,17 +8919,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -406; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -419; if (m_iocluster.size() <= x) - return -407; + return -420; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -408; + return -421; return m_iocluster[x].setByName(idxe+2,value); } } @@ -8731,11 +8940,11 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_display(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); return m_display.setByName(name+8,value); } } #endif // CONFIG_DISPLAY - return -409; + return -422; } diff --git a/components/wfc/hwcfg_esp8285.h b/components/wfc/hwcfg_esp8285.h index 39e1456..c9c512e 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -175,6 +175,7 @@ typedef enum { i2cdrv_ht16k33 = 10, i2cdrv_ina219 = 11, i2cdrv_si7021 = 12, + i2cdrv_tca9555 = 13, } i2cdrv_t; //! Function to get an ASCII string from a value of a i2cdrv_t. const char *i2cdrv_t_str(i2cdrv_t e); @@ -1726,8 +1727,36 @@ class Ws2812bConfig */ uint8_t *mutable_nleds(); + // optional string name, id 4 + /*! + * Function for querying if name has been set. + * @return true if name is set. + */ + bool has_name() const; + //! Function to reset name to its default/unset value. + void clear_name(); + //! Get value of name. + const estring &name() const; + /*! + * Function for setting name using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_name(const void *data, size_t s); + //! Set name using a constant reference + void set_name(const estring &v); + //! Set name using a pointer to a null-terminated C-string. + void set_name(const char *); + /*! + * Provide mutable access to name. + * @return pointer to member variable of name. + */ + estring *mutable_name(); + protected: + //! string name, id 4 + estring m_name; //! sint8 gpio, id 1 int8_t m_gpio; // omitted unused member ch @@ -2741,10 +2770,78 @@ class AdcChannel */ uint8_t *mutable_window(); + // optional float scale, id 8 + /*! + * Function for querying if scale has been set. + * @return true if scale is set. + */ + bool has_scale() const; + //! Function to reset scale to its default/unset value. + void clear_scale(); + //! Get value of scale. + float scale() const; + //! Set scale using a constant reference + void set_scale(float v); + /*! + * Provide mutable access to scale. + * @return pointer to member variable of scale. + */ + float *mutable_scale(); + + // optional float offset, id 9 + /*! + * Function for querying if offset has been set. + * @return true if offset is set. + */ + bool has_offset() const; + //! Function to reset offset to its default/unset value. + void clear_offset(); + //! Get value of offset. + float offset() const; + //! Set offset using a constant reference + void set_offset(float v); + /*! + * Provide mutable access to offset. + * @return pointer to member variable of offset. + */ + float *mutable_offset(); + + // optional string dim, id 10 + /*! + * Function for querying if dim has been set. + * @return true if dim is set. + */ + bool has_dim() const; + //! Function to reset dim to its default/unset value. + void clear_dim(); + //! Get value of dim. + const estring &dim() const; + /*! + * Function for setting dim using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_dim(const void *data, size_t s); + //! Set dim using a constant reference + void set_dim(const estring &v); + //! Set dim using a pointer to a null-terminated C-string. + void set_dim(const char *); + /*! + * Provide mutable access to dim. + * @return pointer to member variable of dim. + */ + estring *mutable_dim(); + protected: //! string name, id 1 estring m_name; + //! string dim, id 10 + estring m_dim; + //! float scale, id 8 + float m_scale; + //! float offset, id 9 + float m_offset; //! uint16 interval, id 5 uint16_t m_interval; //! uint8 unit, id 2 @@ -4514,29 +4611,29 @@ class HardwareConfig #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 + // repeated Ws2812bConfig ws2812b, id 34 + //! Function get const-access to the elements of ws2812b. + const std::vector &ws2812b() const; + //! Function to get the number of elements in ws2812b. + size_t ws2812b_size() const; /*! - * Function for querying if ws2812b has been set. - * @return true if ws2812b is set. + * Function to append a element to ws2812b. + * @return point to newly added element. */ - bool has_ws2812b() const; + Ws2812bConfig* add_ws2812b(); //! Function to reset ws2812b to its default/unset value. void clear_ws2812b(); - //! Get value of ws2812b. - const Ws2812bConfig &ws2812b() const; - /*! - * Function for setting ws2812b using binary data. - * @param data pointer to binary data - * @param s number of bytes at data pointer - */ - void set_ws2812b(const void *data, size_t s); + //! Get value of element x of ws2812b. + const Ws2812bConfig &ws2812b(unsigned x) const; //! Set ws2812b using a constant reference - void set_ws2812b(const Ws2812bConfig &v); + void set_ws2812b(unsigned x, const Ws2812bConfig &v); /*! * Provide mutable access to ws2812b. * @return pointer to member variable of ws2812b. */ - Ws2812bConfig *mutable_ws2812b(); + 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 @@ -4759,7 +4856,7 @@ class HardwareConfig #endif // CONFIG_DHT #ifdef CONFIG_RGBLEDS //! Ws2812bConfig ws2812b, id 34 - Ws2812bConfig m_ws2812b; + std::vector m_ws2812b; #endif // CONFIG_RGBLEDS #ifdef CONFIG_TLC5947 //! Tlc5947Config tlc5947, id 33 @@ -6363,7 +6460,8 @@ inline size_t Ws2812bConfig::getMaxSize() // optional sint8 gpio, id 1 has maximum size 3 // unused optional sint8 ch, id 2 // optional uint8 nleds, id 3 has maximum size 3 - return 6; + // optional string name, id 4 has unlimited size + return SIZE_MAX; } inline int8_t Ws2812bConfig::gpio() const @@ -6428,6 +6526,47 @@ inline void Ws2812bConfig::set_nleds(uint8_t v) +inline const estring &Ws2812bConfig::name() const +{ + return m_name; +} + +inline bool Ws2812bConfig::has_name() const +{ + return !m_name.empty(); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void Ws2812bConfig::clear_name() +{ + m_name.clear(); +} + +inline estring *Ws2812bConfig::mutable_name() +{ + return &m_name; +} + +inline void Ws2812bConfig::set_name(const void *data, size_t s) +{ + m_name.assign((const char *)data,s); +} + +inline void Ws2812bConfig::set_name(const char *data) +{ + m_name = data; +} + +inline void Ws2812bConfig::set_name(const estring &v) +{ + m_name = v; +} + + + inline size_t DhtConfig::getMaxSize() { // optional dht_model_t model, id 1 has maximum size 3 @@ -7145,6 +7284,9 @@ inline size_t AdcChannel::getMaxSize() // optional uint8 atten, id 4 has maximum size 3 // optional uint16 interval, id 5 has maximum size 4 // optional uint8 window, id 6 has maximum size 3 + // optional float scale, id 8 has maximum size 5 + // optional float offset, id 9 has maximum size 5 + // optional string dim, id 10 has unlimited size return SIZE_MAX; } @@ -7350,6 +7492,129 @@ inline void AdcChannel::set_window(uint8_t v) +inline float AdcChannel::scale() const +{ + return m_scale; +} + +inline bool AdcChannel::has_scale() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 1)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_scale() +{ + p_validbits &= ~((uint8_t)1U << 1); + m_scale = 1; +} + +inline float *AdcChannel::mutable_scale() +{ + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); + m_scale = 1; + } + return &m_scale; +} + +inline void AdcChannel::set_scale(float v) +{ + m_scale = v; + p_validbits |= ((uint8_t)1U << 1); +} + + + +inline float AdcChannel::offset() const +{ + return m_offset; +} + +inline bool AdcChannel::has_offset() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 2)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_offset() +{ + p_validbits &= ~((uint8_t)1U << 2); + m_offset = 0; +} + +inline float *AdcChannel::mutable_offset() +{ + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); + m_offset = 0; + } + return &m_offset; +} + +inline void AdcChannel::set_offset(float v) +{ + m_offset = v; + p_validbits |= ((uint8_t)1U << 2); +} + + + +inline const estring &AdcChannel::dim() const +{ + return m_dim; +} + +inline bool AdcChannel::has_dim() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 3)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_dim() +{ + p_validbits &= ~((uint8_t)1U << 3); + m_dim.clear(); +} + +inline estring *AdcChannel::mutable_dim() +{ + if (0 == (p_validbits & ((uint8_t)1U << 3))) { + p_validbits |= ((uint8_t)1U << 3); + m_dim.clear(); + } + return &m_dim; +} + +inline void AdcChannel::set_dim(const void *data, size_t s) +{ + m_dim.assign((const char *)data,s); + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const char *data) +{ + m_dim = data; + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const estring &v) +{ + m_dim = v; + p_validbits |= ((uint8_t)1U << 3); +} + + + inline size_t AdcConfig::getMaxSize() { // optional string adc_name, id 1 has unlimited size @@ -8893,7 +9158,7 @@ inline size_t HardwareConfig::getMaxSize() // optional Hlw8012Config hlw8012, id 20 has maximum size 11 // optional Max7219Config max7219, id 32 has maximum size 16 // optional Tlc5947Config tlc5947, id 33 has maximum size 17 - // optional Ws2812bConfig ws2812b, id 34 has maximum size 11 + // repeated Ws2812bConfig ws2812b, id 34 has unlimited size // optional DhtConfig dht, id 35 has maximum size 8 // repeated I2CConfig i2c, id 36 has unlimited size // repeated HcSr04Config hcsr04, id 37 has unlimited size @@ -9421,14 +9686,14 @@ inline void HardwareConfig::set_tlc5947(const Tlc5947Config &v) #ifdef CONFIG_RGBLEDS -inline const Ws2812bConfig &HardwareConfig::ws2812b() const +inline const Ws2812bConfig &HardwareConfig::ws2812b(unsigned x) const { - return m_ws2812b; + return m_ws2812b[x]; } -inline bool HardwareConfig::has_ws2812b() const +inline const std::vector &HardwareConfig::ws2812b() const { - return 0 != (p_validbits & ((uint16_t)1U << 6)); + return m_ws2812b; } /*! @@ -9437,29 +9702,36 @@ inline bool HardwareConfig::has_ws2812b() const */ inline void HardwareConfig::clear_ws2812b() { - p_validbits &= ~((uint16_t)1U << 6); m_ws2812b.clear(); } -inline Ws2812bConfig *HardwareConfig::mutable_ws2812b() +inline Ws2812bConfig *HardwareConfig::mutable_ws2812b(unsigned x) +{ + if (x >= m_ws2812b.size()) + m_ws2812b.resize(x+1); + return &m_ws2812b[x]; +} + +inline std::vector *HardwareConfig::mutable_ws2812b() { - if (0 == (p_validbits & ((uint16_t)1U << 6))) { - p_validbits |= ((uint16_t)1U << 6); - m_ws2812b.clear(); - } return &m_ws2812b; } -inline void HardwareConfig::set_ws2812b(const void *data, size_t s) +inline Ws2812bConfig *HardwareConfig::add_ws2812b() { - m_ws2812b.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 6); + m_ws2812b.resize(m_ws2812b.size()+1); + return &m_ws2812b.back(); } -inline void HardwareConfig::set_ws2812b(const Ws2812bConfig &v) +inline void HardwareConfig::set_ws2812b(unsigned x, const Ws2812bConfig &v) { - m_ws2812b = v; - p_validbits |= ((uint16_t)1U << 6); + assert(x < m_ws2812b.size()); + m_ws2812b[x] = v; +} + +inline size_t HardwareConfig::ws2812b_size() const +{ + return m_ws2812b.size(); } #endif // CONFIG_RGBLEDS @@ -9473,7 +9745,7 @@ inline const DhtConfig &HardwareConfig::dht() const inline bool HardwareConfig::has_dht() const { - return 0 != (p_validbits & ((uint16_t)1U << 7)); + return 0 != (p_validbits & ((uint16_t)1U << 6)); } /*! @@ -9482,14 +9754,14 @@ inline bool HardwareConfig::has_dht() const */ inline void HardwareConfig::clear_dht() { - p_validbits &= ~((uint16_t)1U << 7); + p_validbits &= ~((uint16_t)1U << 6); m_dht.clear(); } inline DhtConfig *HardwareConfig::mutable_dht() { - if (0 == (p_validbits & ((uint16_t)1U << 7))) { - p_validbits |= ((uint16_t)1U << 7); + if (0 == (p_validbits & ((uint16_t)1U << 6))) { + p_validbits |= ((uint16_t)1U << 6); m_dht.clear(); } return &m_dht; @@ -9498,13 +9770,13 @@ inline DhtConfig *HardwareConfig::mutable_dht() inline void HardwareConfig::set_dht(const void *data, size_t s) { m_dht.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); } inline void HardwareConfig::set_dht(const DhtConfig &v) { m_dht = v; - p_validbits |= ((uint16_t)1U << 7); + p_validbits |= ((uint16_t)1U << 6); } #endif // CONFIG_DHT @@ -9622,7 +9894,7 @@ inline const OneWireConfig &HardwareConfig::onewire() const inline bool HardwareConfig::has_onewire() const { - return 0 != (p_validbits & ((uint16_t)1U << 8)); + return 0 != (p_validbits & ((uint16_t)1U << 7)); } /*! @@ -9631,14 +9903,14 @@ inline bool HardwareConfig::has_onewire() const */ inline void HardwareConfig::clear_onewire() { - p_validbits &= ~((uint16_t)1U << 8); + p_validbits &= ~((uint16_t)1U << 7); m_onewire.clear(); } inline OneWireConfig *HardwareConfig::mutable_onewire() { - if (0 == (p_validbits & ((uint16_t)1U << 8))) { - p_validbits |= ((uint16_t)1U << 8); + if (0 == (p_validbits & ((uint16_t)1U << 7))) { + p_validbits |= ((uint16_t)1U << 7); m_onewire.clear(); } return &m_onewire; @@ -9647,13 +9919,13 @@ inline OneWireConfig *HardwareConfig::mutable_onewire() inline void HardwareConfig::set_onewire(const void *data, size_t s) { m_onewire.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } inline void HardwareConfig::set_onewire(const OneWireConfig &v) { m_onewire = v; - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } #endif // CONFIG_ONEWIRE @@ -9667,7 +9939,7 @@ inline const SX1276Config &HardwareConfig::sx1276() const inline bool HardwareConfig::has_sx1276() const { - return 0 != (p_validbits & ((uint16_t)1U << 9)); + return 0 != (p_validbits & ((uint16_t)1U << 8)); } /*! @@ -9676,14 +9948,14 @@ inline bool HardwareConfig::has_sx1276() const */ inline void HardwareConfig::clear_sx1276() { - p_validbits &= ~((uint16_t)1U << 9); + p_validbits &= ~((uint16_t)1U << 8); m_sx1276.clear(); } inline SX1276Config *HardwareConfig::mutable_sx1276() { - if (0 == (p_validbits & ((uint16_t)1U << 9))) { - p_validbits |= ((uint16_t)1U << 9); + if (0 == (p_validbits & ((uint16_t)1U << 8))) { + p_validbits |= ((uint16_t)1U << 8); m_sx1276.clear(); } return &m_sx1276; @@ -9692,13 +9964,13 @@ inline SX1276Config *HardwareConfig::mutable_sx1276() inline void HardwareConfig::set_sx1276(const void *data, size_t s) { m_sx1276.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } inline void HardwareConfig::set_sx1276(const SX1276Config &v) { m_sx1276 = v; - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } #endif // CONFIG_SX1276 @@ -9764,7 +10036,7 @@ inline const DisplayConfig &HardwareConfig::display() const inline bool HardwareConfig::has_display() const { - return 0 != (p_validbits & ((uint16_t)1U << 10)); + return 0 != (p_validbits & ((uint16_t)1U << 9)); } /*! @@ -9773,14 +10045,14 @@ inline bool HardwareConfig::has_display() const */ inline void HardwareConfig::clear_display() { - p_validbits &= ~((uint16_t)1U << 10); + p_validbits &= ~((uint16_t)1U << 9); m_display.clear(); } inline DisplayConfig *HardwareConfig::mutable_display() { - if (0 == (p_validbits & ((uint16_t)1U << 10))) { - p_validbits |= ((uint16_t)1U << 10); + if (0 == (p_validbits & ((uint16_t)1U << 9))) { + p_validbits |= ((uint16_t)1U << 9); m_display.clear(); } return &m_display; @@ -9789,13 +10061,13 @@ inline DisplayConfig *HardwareConfig::mutable_display() inline void HardwareConfig::set_display(const void *data, size_t s) { m_display.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } inline void HardwareConfig::set_display(const DisplayConfig &v) { m_display = v; - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } #endif // CONFIG_DISPLAY diff --git a/components/wfc/hwcfg_pc.cpp b/components/wfc/hwcfg_pc.cpp index e3f0ca3..96cccd0 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -205,6 +205,7 @@ static const char *i2cdrv_t_names[] = { "i2cdrv_pca9685_xclk_pnp", "i2cdrv_pcf8574", "i2cdrv_si7021", + "i2cdrv_tca9555", }; static i2cdrv_t i2cdrv_t_values[] = { @@ -221,6 +222,7 @@ static i2cdrv_t i2cdrv_t_values[] = { i2cdrv_pca9685_xclk_pnp, i2cdrv_pcf8574, i2cdrv_si7021, + i2cdrv_tca9555, }; size_t parse_ascii_i2cdrv_t(i2cdrv_t *v, const char *s) @@ -3478,6 +3480,7 @@ Ws2812bConfig::Ws2812bConfig() : m_gpio(-1) , m_ch(-1) , m_nleds(0) +, m_name() { } @@ -3486,6 +3489,7 @@ void Ws2812bConfig::clear() m_gpio = -1; m_ch = -1; m_nleds = 0; + m_name.clear(); } void Ws2812bConfig::toASCII(std::ostream &o, size_t indent) const @@ -3495,6 +3499,7 @@ void Ws2812bConfig::toASCII(std::ostream &o, size_t indent) const ascii_numeric(o, indent, "gpio", (signed) m_gpio); ascii_numeric(o, indent, "ch", (signed) m_ch); ascii_numeric(o, indent, "nleds", (unsigned) m_nleds); + ascii_string(o,indent,m_name.data(),m_name.size(),"name"); --indent; ascii_indent(o,indent); o << '}'; @@ -3541,12 +3546,23 @@ ssize_t Ws2812bConfig::fromMemory(const void *b, ssize_t s) set_nleds(v); } break; + case 0x22: // name id 4, 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 -152; + m_name.assign((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 -152; + return -153; a += s; break; } @@ -3554,7 +3570,7 @@ ssize_t Ws2812bConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -153; + return -154; return a-(const uint8_t *)b; } @@ -3567,34 +3583,48 @@ ssize_t Ws2812bConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -154; + return -155; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -155; + return -156; a += n; } // has ch? if (m_ch != -1) { // 'ch': id=2, encoding=varint, tag=0x10 if (a >= e) - return -156; + return -157; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_ch)); if (n <= 0) - return -157; + return -158; a += n; } // has nleds? if (m_nleds != 0) { // 'nleds': id=3, encoding=varint, tag=0x18 if (a >= e) - return -158; + return -159; *a++ = 0x18; n = write_varint(a,e-a,m_nleds); if (n <= 0) - return -159; + return -160; + a += n; + } + // has name? + if (!m_name.empty()) { + // 'name': id=4, encoding=lenpfx, tag=0x22 + if (a >= e) + return -161; + *a++ = 0x22; + 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 -162; + memcpy(a,m_name.data(),name_s); + a += name_s; } assert(a <= e); return a-b; @@ -3617,6 +3647,13 @@ void Ws2812bConfig::toWire(void (*put)(uint8_t)) const put(0x18); // 'nleds': id=3 send_varint(put,m_nleds); } + if (!m_name.empty()) { + // 'name': id=4, encoding=lenpfx, tag=0x22 + put(0x22); // 'name': id=4 + size_t name_s = m_name.size(); + send_varint(put,name_s); + send_bytes(put,(const uint8_t*) m_name.data(),name_s); + } } void Ws2812bConfig::toString(std::string &put) const @@ -3636,6 +3673,13 @@ void Ws2812bConfig::toString(std::string &put) const put.push_back(0x18); // 'nleds': id=3 send_varint(put,m_nleds); } + if (!m_name.empty()) { + // 'name': id=4, encoding=lenpfx, tag=0x22 + put.push_back(0x22); // 'name': id=4 + size_t name_s = m_name.size(); + send_varint(put,name_s); + put.append((const char *)(const uint8_t*) m_name.data(),name_s); + } } void Ws2812bConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -3654,6 +3698,10 @@ void Ws2812bConfig::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"nleds"); json << (unsigned) m_nleds; } + if (has_name()) { + fsep = json_indent(json,indLvl,fsep,"name"); + json_cstr(json,m_name.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -3679,6 +3727,11 @@ size_t Ws2812bConfig::calcSize() const if (m_nleds != 0) { r += wiresize((varint_t)m_nleds) + 1 /* tag(nleds) 0x18 */; } + // optional string name, id 4 + if (!m_name.empty()) { + size_t name_s = m_name.size(); + r += name_s + wiresize(name_s) + 1 /* tag(name) 0x20 */; + } return r; } @@ -3690,6 +3743,8 @@ bool Ws2812bConfig::operator != (const Ws2812bConfig &r) const return true; if (has_nleds() && (m_nleds != r.m_nleds)) return true; + if (has_name() && (m_name != r.m_name)) + return true; return false; } @@ -3733,7 +3788,16 @@ int Ws2812bConfig::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_nleds,value); return r; } - return -160; + if (0 == strcmp(name,"name")) { + if (value == 0) { + clear_name(); + return 0; + } + m_name = value; + int r = m_name.size(); + return r; + } + return -163; } Message *Ws2812bConfig::p_getMember(const char *s, const char *e) @@ -3782,7 +3846,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -161; + return -164; a += fn; switch (fid) { case 0x8: // model id 1, type dht_model_t, coding varint @@ -3790,7 +3854,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -162; + return -165; a += n; set_model((dht_model_t) v); } @@ -3800,7 +3864,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -163; + return -166; a += n; set_gpio(varint_sint(v)); } @@ -3810,7 +3874,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -164; + return -167; a += s; break; } @@ -3818,7 +3882,7 @@ ssize_t DhtConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -165; + return -168; return a-(const uint8_t *)b; } @@ -3831,22 +3895,22 @@ ssize_t DhtConfig::toMemory(uint8_t *b, ssize_t s) const if (m_model != DHT_NONE) { // 'model': id=1, encoding=varint, tag=0x8 if (a >= e) - return -166; + return -169; *a++ = 0x8; n = write_varint(a,e-a,m_model); if (n <= 0) - return -167; + return -170; a += n; } // has gpio? if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -168; + return -171; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -169; + return -172; a += n; } assert(a <= e); @@ -3956,7 +4020,7 @@ int DhtConfig::setByName(const char *name, const char *value) dht_model_t v; size_t r = parse_ascii_dht_model_t(&v,value); if (r == 0) - return -170; + return -173; set_model(v); return r; } @@ -3968,7 +4032,7 @@ int DhtConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_gpio,value); return r; } - return -171; + return -174; } Message *DhtConfig::p_getMember(const char *s, const char *e) @@ -4052,7 +4116,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -172; + return -175; a += fn; switch (fid) { case 0x8: // port id 1, type uint8_t, coding varint @@ -4060,7 +4124,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -173; + return -176; a += n; set_port(v); } @@ -4070,7 +4134,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -174; + return -177; a += n; set_sda(varint_sint(v)); } @@ -4080,7 +4144,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -175; + return -178; a += n; set_scl(varint_sint(v)); } @@ -4090,14 +4154,14 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -176; + return -179; a += n; set_freq(v); } break; case 0x2b: // xpullup id 5, type bool, coding 8bit if (a >= e) - return -177; + return -180; set_xpullup(*a++); break; #ifdef CONFIG_I2C_XDEV @@ -4105,14 +4169,14 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); // length of packed if (n <= 0) - return -178; + return -181; a += n; const uint8_t *ae = a + v; do { varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -179; + return -182; a += n; m_devices.push_back((i2cdev_t)v); } while (a < ae); @@ -4123,7 +4187,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -180; + return -183; a += s; break; } @@ -4131,7 +4195,7 @@ ssize_t I2CConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -181; + return -184; return a-(const uint8_t *)b; } @@ -4144,51 +4208,51 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -182; + return -185; *a++ = 0x8; n = write_varint(a,e-a,m_port); if (n <= 0) - return -183; + return -186; a += n; } // has sda? if (m_sda != -1) { // 'sda': id=2, encoding=varint, tag=0x10 if (a >= e) - return -184; + return -187; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sda)); if (n <= 0) - return -185; + return -188; a += n; } // has scl? if (m_scl != -1) { // 'scl': id=3, encoding=varint, tag=0x18 if (a >= e) - return -186; + return -189; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_scl)); if (n <= 0) - return -187; + return -190; a += n; } // has freq? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'freq': id=4, encoding=varint, tag=0x20 if (a >= e) - return -188; + return -191; *a++ = 0x20; n = write_varint(a,e-a,m_freq); if (n <= 0) - return -189; + return -192; a += n; } // has xpullup? if (m_xpullup != false) { // 'xpullup': id=5, encoding=8bit, tag=0x2b if (2 > (e-a)) - return -190; + return -193; *a++ = 0x2b; *a++ = m_xpullup; } @@ -4196,7 +4260,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const if (size_t devices_ne = m_devices.size()) { // 'devices': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -191; + return -194; *a++ = 0x32; ssize_t devices_ws = 0; for (size_t x = 0; x != devices_ne; ++x) @@ -4204,7 +4268,7 @@ ssize_t I2CConfig::toMemory(uint8_t *b, ssize_t s) const n = write_varint(a,e-a,devices_ws); a += n; if ((n <= 0) || (devices_ws > (e-a))) - return -192; + return -195; for (size_t x = 0; x != devices_ne; ++x) a += write_varint(a,e-a,m_devices[x]); } @@ -4482,10 +4546,10 @@ int I2CConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -193; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -196; if (m_devices.size() <= x) - return -194; + return -197; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; @@ -4498,7 +4562,7 @@ int I2CConfig::setByName(const char *name, const char *value) return eptr - value; } if (idxe[1] != '.') - return -195; + return -198; idxe += 2; if (!strcmp("addr",idxe)) { if (eptr != value) { @@ -4512,11 +4576,11 @@ int I2CConfig::setByName(const char *name, const char *value) return 0; } } - return -196; + return -199; } } #endif // CONFIG_I2C_XDEV - return -197; + return -200; } Message *I2CConfig::p_getMember(const char *s, const char *e) @@ -4563,7 +4627,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -198; + return -201; a += fn; switch (fid) { case 0x8: // trigger id 1, type int8_t, coding signed varint @@ -4571,7 +4635,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -199; + return -202; a += n; set_trigger(varint_sint(v)); } @@ -4581,7 +4645,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -200; + return -203; a += n; set_echo(varint_sint(v)); } @@ -4592,7 +4656,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -201; + return -204; m_name.assign((const char*)a,v); a += v; } @@ -4602,7 +4666,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -202; + return -205; a += s; break; } @@ -4610,7 +4674,7 @@ ssize_t HcSr04Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -203; + return -206; return a-(const uint8_t *)b; } @@ -4623,35 +4687,35 @@ ssize_t HcSr04Config::toMemory(uint8_t *b, ssize_t s) const if (m_trigger != -1) { // 'trigger': id=1, encoding=varint, tag=0x8 if (a >= e) - return -204; + return -207; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_trigger)); if (n <= 0) - return -205; + return -208; a += n; } // has echo? if (m_echo != -1) { // 'echo': id=2, encoding=varint, tag=0x10 if (a >= e) - return -206; + return -209; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_echo)); if (n <= 0) - return -207; + return -210; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -208; + return -211; *a++ = 0x1a; 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 -209; + return -212; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -4798,7 +4862,7 @@ int HcSr04Config::setByName(const char *name, const char *value) int r = m_name.size(); return r; } - return -210; + return -213; } Message *HcSr04Config::p_getMember(const char *s, const char *e) @@ -4858,7 +4922,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -211; + return -214; a += fn; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -4866,7 +4930,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -212; + return -215; a += n; set_gpio(varint_sint(v)); } @@ -4876,7 +4940,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -213; + return -216; a += n; set_config((ledcfg_t) v); } @@ -4887,7 +4951,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -214; + return -217; m_name.assign((const char*)a,v); a += v; } @@ -4897,7 +4961,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -215; + return -218; a += n; set_pwm_ch(varint_sint(v)); } @@ -4907,7 +4971,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -216; + return -219; a += s; break; } @@ -4915,7 +4979,7 @@ ssize_t LedConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -217; + return -220; return a-(const uint8_t *)b; } @@ -4928,35 +4992,35 @@ ssize_t LedConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -218; + return -221; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -219; + return -222; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=2, encoding=varint, tag=0x10 if (a >= e) - return -220; + return -223; *a++ = 0x10; n = write_varint(a,e-a,m_config); if (n <= 0) - return -221; + return -224; a += n; } // has name? if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -222; + return -225; *a++ = 0x1a; 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 -223; + return -226; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -4964,11 +5028,11 @@ ssize_t LedConfig::toMemory(uint8_t *b, ssize_t s) const if (m_pwm_ch != -1) { // 'pwm_ch': id=4, encoding=varint, tag=0x20 if (a >= e) - return -224; + return -227; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_pwm_ch)); if (n <= 0) - return -225; + return -228; a += n; } assert(a <= e); @@ -5132,7 +5196,7 @@ int LedConfig::setByName(const char *name, const char *value) set_config_open_drain((bool)ull); return eptr - value; } else { - return -226; + return -229; } } if (0 == strcmp(name,"name")) { @@ -5152,7 +5216,7 @@ int LedConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_pwm_ch,value); return r; } - return -227; + return -230; } Message *LedConfig::p_getMember(const char *s, const char *e) @@ -5199,7 +5263,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -228; + return -231; a += fn; switch (fid) { case 0x8: // gpio id 1, type int8_t, coding signed varint @@ -5207,14 +5271,14 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -229; + return -232; a += n; set_gpio(varint_sint(v)); } break; case 0x13: // pullup id 2, type bool, coding 8bit if (a >= e) - return -230; + return -233; set_pullup(*a++); break; case 0x18: // power id 3, type int8_t, coding signed varint @@ -5222,7 +5286,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -231; + return -234; a += n; set_power(varint_sint(v)); } @@ -5232,7 +5296,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -232; + return -235; a += s; break; } @@ -5240,7 +5304,7 @@ ssize_t OneWireConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -233; + return -236; return a-(const uint8_t *)b; } @@ -5253,18 +5317,18 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=1, encoding=varint, tag=0x8 if (a >= e) - return -234; + return -237; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -235; + return -238; a += n; } // has pullup? if (m_pullup != false) { // 'pullup': id=2, encoding=8bit, tag=0x13 if (2 > (e-a)) - return -236; + return -239; *a++ = 0x13; *a++ = m_pullup; } @@ -5272,11 +5336,11 @@ ssize_t OneWireConfig::toMemory(uint8_t *b, ssize_t s) const if (m_power != -1) { // 'power': id=3, encoding=varint, tag=0x18 if (a >= e) - return -237; + return -240; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_power)); if (n <= 0) - return -238; + return -241; a += n; } assert(a <= e); @@ -5416,7 +5480,7 @@ int OneWireConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_power,value); return r; } - return -239; + return -242; } Message *OneWireConfig::p_getMember(const char *s, const char *e) @@ -5469,7 +5533,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -240; + return -243; a += fn; switch (fid) { case 0x8: // port id 1, type int8_t, coding signed varint @@ -5477,7 +5541,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -241; + return -244; a += n; set_port(varint_sint(v)); } @@ -5487,7 +5551,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -242; + return -245; a += n; set_tx_gpio(varint_sint(v)); } @@ -5497,7 +5561,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -243; + return -246; a += n; set_rx_gpio(varint_sint(v)); } @@ -5507,7 +5571,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -244; + return -247; a += n; set_cts_gpio(varint_sint(v)); } @@ -5517,7 +5581,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -245; + return -248; a += n; set_rts_gpio(varint_sint(v)); } @@ -5527,7 +5591,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -246; + return -249; a += s; break; } @@ -5535,7 +5599,7 @@ ssize_t UartConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -247; + return -250; return a-(const uint8_t *)b; } @@ -5548,55 +5612,55 @@ ssize_t UartConfig::toMemory(uint8_t *b, ssize_t s) const if (m_port != -1) { // 'port': id=1, encoding=varint, tag=0x8 if (a >= e) - return -248; + return -251; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_port)); if (n <= 0) - return -249; + return -252; a += n; } // has tx_gpio? if (m_tx_gpio != -1) { // 'tx_gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -250; + return -253; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_tx_gpio)); if (n <= 0) - return -251; + return -254; a += n; } // has rx_gpio? if (m_rx_gpio != -1) { // 'rx_gpio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -252; + return -255; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_rx_gpio)); if (n <= 0) - return -253; + return -256; a += n; } // has cts_gpio? if (m_cts_gpio != -1) { // 'cts_gpio': id=4, encoding=varint, tag=0x20 if (a >= e) - return -254; + return -257; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cts_gpio)); if (n <= 0) - return -255; + return -258; a += n; } // has rts_gpio? if (m_rts_gpio != -1) { // 'rts_gpio': id=5, encoding=varint, tag=0x28 if (a >= e) - return -256; + return -259; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_rts_gpio)); if (n <= 0) - return -257; + return -260; a += n; } assert(a <= e); @@ -5792,7 +5856,7 @@ int UartConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_rts_gpio,value); return r; } - return -258; + return -261; } Message *UartConfig::p_getMember(const char *s, const char *e) @@ -5812,6 +5876,9 @@ AdcChannel::AdcChannel() , m_atten(0) , m_interval(0) , m_window(0) +, m_scale(1) +, m_offset(0) +, m_dim() , p_validbits(0) { } @@ -5824,6 +5891,9 @@ void AdcChannel::clear() m_atten = 0; m_interval = 0; m_window = 0; + m_scale = 1; + m_offset = 0; + m_dim.clear(); p_validbits = 0; } @@ -5837,6 +5907,9 @@ void AdcChannel::toASCII(std::ostream &o, size_t indent) const ascii_numeric(o, indent, "atten", (unsigned) m_atten); ascii_numeric(o, indent, "interval", m_interval); ascii_numeric(o, indent, "window", (unsigned) m_window); + ascii_numeric(o, indent, "scale", m_scale); + ascii_numeric(o, indent, "offset", m_offset); + ascii_string(o,indent,m_dim.data(),m_dim.size(),"dim"); --indent; ascii_indent(o,indent); o << '}'; @@ -5850,7 +5923,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -259; + return -262; a += fn; switch (fid) { case 0xa: // name id 1, type std::string, coding byte[] @@ -5859,7 +5932,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -260; + return -263; m_name.assign((const char*)a,v); a += v; } @@ -5869,7 +5942,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -261; + return -264; a += n; set_unit(v); } @@ -5879,7 +5952,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -262; + return -265; a += n; set_ch(varint_sint(v)); } @@ -5889,7 +5962,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -263; + return -266; a += n; set_atten(v); } @@ -5899,7 +5972,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -264; + return -267; a += n; set_interval(v); } @@ -5909,17 +5982,41 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -265; + return -268; a += n; set_window(v); } break; + case 0x45: // scale id 8, type float, coding 32bit + if ((a+3) >= e) + return -269; + set_scale(read_float(a)); + a += 4; + break; + case 0x4d: // offset id 9, type float, coding 32bit + if ((a+3) >= e) + return -270; + set_offset(read_float(a)); + a += 4; + break; + case 0x52: // dim id 10, 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 -271; + m_dim.assign((const char*)a,v); + a += v; + } + p_validbits |= ((uint8_t)1U << 3); + break; default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -266; + return -272; a += s; break; } @@ -5927,7 +6024,7 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -267; + return -273; return a-(const uint8_t *)b; } @@ -5940,13 +6037,13 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -268; + return -274; *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 -269; + return -275; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -5954,56 +6051,92 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const if (m_unit != 0) { // 'unit': id=2, encoding=varint, tag=0x10 if (a >= e) - return -270; + return -276; *a++ = 0x10; n = write_varint(a,e-a,m_unit); if (n <= 0) - return -271; + return -277; a += n; } // has ch? if (m_ch != -1) { // 'ch': id=3, encoding=varint, tag=0x18 if (a >= e) - return -272; + return -278; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_ch)); if (n <= 0) - return -273; + return -279; a += n; } // has atten? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'atten': id=4, encoding=varint, tag=0x20 if (a >= e) - return -274; + return -280; *a++ = 0x20; n = write_varint(a,e-a,m_atten); if (n <= 0) - return -275; + return -281; a += n; } // has interval? if (m_interval != 0) { // 'interval': id=5, encoding=varint, tag=0x28 if (a >= e) - return -276; + return -282; *a++ = 0x28; n = write_varint(a,e-a,m_interval); if (n <= 0) - return -277; + return -283; a += n; } // has window? if (m_window != 0) { // 'window': id=6, encoding=varint, tag=0x30 if (a >= e) - return -278; + return -284; *a++ = 0x30; n = write_varint(a,e-a,m_window); if (n <= 0) - return -279; + return -285; + a += n; + } + // has scale? + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + // 'scale': id=8, encoding=32bit, tag=0x45 + if (5 > (e-a)) + return -286; + *a++ = 0x45; + if ((e-a) < 4) + return -287; + write_u32(a,mangle_float(m_scale)); + a += 4; + } + // has offset? + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + // 'offset': id=9, encoding=32bit, tag=0x4d + if (5 > (e-a)) + return -288; + *a++ = 0x4d; + if ((e-a) < 4) + return -289; + write_u32(a,mangle_float(m_offset)); + a += 4; + } + // has dim? + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + // 'dim': id=10, encoding=lenpfx, tag=0x52 + if (a >= e) + return -290; + *a++ = 0x52; + ssize_t dim_s = m_dim.size(); + n = write_varint(a,e-a,dim_s); a += n; + if ((n <= 0) || ((e-a) < dim_s)) + return -291; + memcpy(a,m_dim.data(),dim_s); + a += dim_s; } assert(a <= e); return a-b; @@ -6043,6 +6176,23 @@ void AdcChannel::toWire(void (*put)(uint8_t)) const put(0x30); // 'window': id=6 send_varint(put,m_window); } + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + // 'scale': id=8, encoding=32bit, tag=0x45 + put(0x45); // 'scale': id=8 + send_u32(put,mangle_float(m_scale)); + } + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + // 'offset': id=9, encoding=32bit, tag=0x4d + put(0x4d); // 'offset': id=9 + send_u32(put,mangle_float(m_offset)); + } + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + // 'dim': id=10, encoding=lenpfx, tag=0x52 + put(0x52); // 'dim': id=10 + size_t dim_s = m_dim.size(); + send_varint(put,dim_s); + send_bytes(put,(const uint8_t*) m_dim.data(),dim_s); + } } void AdcChannel::toString(std::string &put) const @@ -6079,6 +6229,23 @@ void AdcChannel::toString(std::string &put) const put.push_back(0x30); // 'window': id=6 send_varint(put,m_window); } + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + // 'scale': id=8, encoding=32bit, tag=0x45 + put.push_back(0x45); // 'scale': id=8 + send_u32(put,mangle_float(m_scale)); + } + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + // 'offset': id=9, encoding=32bit, tag=0x4d + put.push_back(0x4d); // 'offset': id=9 + send_u32(put,mangle_float(m_offset)); + } + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + // 'dim': id=10, encoding=lenpfx, tag=0x52 + put.push_back(0x52); // 'dim': id=10 + size_t dim_s = m_dim.size(); + send_varint(put,dim_s); + put.append((const char *)(const uint8_t*) m_dim.data(),dim_s); + } } void AdcChannel::toJSON(std::ostream &json, unsigned indLvl) const @@ -6109,6 +6276,18 @@ void AdcChannel::toJSON(std::ostream &json, unsigned indLvl) const fsep = json_indent(json,indLvl,fsep,"window"); json << (unsigned) m_window; } + if (has_scale()) { + fsep = json_indent(json,indLvl,fsep,"scale"); + to_dblstr(json,m_scale); + } + if (has_offset()) { + fsep = json_indent(json,indLvl,fsep,"offset"); + to_dblstr(json,m_offset); + } + if (has_dim()) { + fsep = json_indent(json,indLvl,fsep,"dim"); + json_cstr(json,m_dim.c_str()); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -6147,6 +6326,19 @@ size_t AdcChannel::calcSize() const if (m_window != 0) { r += wiresize((varint_t)m_window) + 1 /* tag(window) 0x30 */; } + // optional float scale, id 8 + if (0 != (p_validbits & ((uint8_t)1U << 1))) { + r += 5; + } + // optional float offset, id 9 + if (0 != (p_validbits & ((uint8_t)1U << 2))) { + r += 5; + } + // optional string dim, id 10 + if (0 != (p_validbits & ((uint8_t)1U << 3))) { + size_t dim_s = m_dim.size(); + r += dim_s + wiresize(dim_s) + 1 /* tag(dim) 0x50 */; + } return r; } @@ -6166,6 +6358,12 @@ bool AdcChannel::operator != (const AdcChannel &r) const return true; if (has_window() && (m_window != r.m_window)) return true; + if (has_scale() && (m_scale != r.m_scale)) + return true; + if (has_offset() && (m_offset != r.m_offset)) + return true; + if (has_dim() && (m_dim != r.m_dim)) + return true; return false; } @@ -6236,7 +6434,38 @@ int AdcChannel::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_window,value); return r; } - return -280; + if (0 == strcmp(name,"scale")) { + if (value == 0) { + clear_scale(); + return 0; + } + int r = parse_ascii_flt(&m_scale,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 1); + return r; + } + if (0 == strcmp(name,"offset")) { + if (value == 0) { + clear_offset(); + return 0; + } + int r = parse_ascii_flt(&m_offset,value); + if (r > 0) + p_validbits |= ((uint8_t)1U << 2); + return r; + } + if (0 == strcmp(name,"dim")) { + if (value == 0) { + clear_dim(); + return 0; + } + m_dim = value; + int r = m_dim.size(); + if (r > 0) + p_validbits |= ((uint8_t)1U << 3); + return r; + } + return -292; } Message *AdcChannel::p_getMember(const char *s, const char *e) @@ -6307,7 +6536,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -281; + return -293; a += fn; switch (fid) { case 0xa: // adc_name id 1, type std::string, coding byte[] @@ -6316,7 +6545,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -282; + return -294; m_adc_name.assign((const char*)a,v); a += v; } @@ -6326,7 +6555,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -283; + return -295; a += n; set_adc1_bits(v); } @@ -6336,7 +6565,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -284; + return -296; a += n; set_adc2_bits(v); } @@ -6346,7 +6575,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -285; + return -297; a += n; set_mode(v); } @@ -6356,7 +6585,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -286; + return -298; a += n; set_clk_div(v); } @@ -6367,7 +6596,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -287; + return -299; m_hall_name.assign((const char*)a,v); a += v; } @@ -6378,14 +6607,14 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -288; + return -300; m_channels.emplace_back(); if (v != 0) { n = m_channels.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -289; + return -301; a += v; } } @@ -6395,7 +6624,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -290; + return -302; a += s; break; } @@ -6403,7 +6632,7 @@ ssize_t AdcConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -291; + return -303; return a-(const uint8_t *)b; } @@ -6416,13 +6645,13 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_adc_name.empty()) { // 'adc_name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -292; + return -304; *a++ = 0xa; ssize_t adc_name_s = m_adc_name.size(); n = write_varint(a,e-a,adc_name_s); a += n; if ((n <= 0) || ((e-a) < adc_name_s)) - return -293; + return -305; memcpy(a,m_adc_name.data(),adc_name_s); a += adc_name_s; } @@ -6430,70 +6659,70 @@ ssize_t AdcConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'adc1_bits': id=2, encoding=varint, tag=0x10 if (a >= e) - return -294; + return -306; *a++ = 0x10; n = write_varint(a,e-a,m_adc1_bits); if (n <= 0) - return -295; + return -307; a += n; } // has adc2_bits? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'adc2_bits': id=3, encoding=varint, tag=0x18 if (a >= e) - return -296; + return -308; *a++ = 0x18; n = write_varint(a,e-a,m_adc2_bits); if (n <= 0) - return -297; + return -309; a += n; } // has mode? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'mode': id=4, encoding=varint, tag=0x20 if (a >= e) - return -298; + return -310; *a++ = 0x20; n = write_varint(a,e-a,m_mode); if (n <= 0) - return -299; + return -311; a += n; } // has clk_div? if (0 != (p_validbits & ((uint8_t)1U << 3))) { // 'clk_div': id=5, encoding=varint, tag=0x28 if (a >= e) - return -300; + return -312; *a++ = 0x28; n = write_varint(a,e-a,m_clk_div); if (n <= 0) - return -301; + return -313; a += n; } // has hall_name? if (!m_hall_name.empty()) { // 'hall_name': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -302; + return -314; *a++ = 0x32; ssize_t hall_name_s = m_hall_name.size(); n = write_varint(a,e-a,hall_name_s); a += n; if ((n <= 0) || ((e-a) < hall_name_s)) - return -303; + return -315; memcpy(a,m_hall_name.data(),hall_name_s); a += hall_name_s; } for (const auto &x : m_channels) { // 'channels': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -304; + return -316; *a++ = 0x3a; ssize_t channels_ws = x.calcSize(); n = write_varint(a,e-a,channels_ws); a += n; if ((n <= 0) || (channels_ws > (e-a))) - return -305; + return -317; n = x.toMemory(a,e-a); a += n; assert(n == channels_ws); @@ -6795,21 +7024,21 @@ int AdcConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -306; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -318; if (m_channels.size() <= x) - return -307; + return -319; if ((idxe[1] == 0) && (value == 0)) { m_channels.erase(m_channels.begin()+x); return 0; } } if (idxe[1] != '.') - return -308; + return -320; return m_channels[x].setByName(idxe+2,value); } } - return -309; + return -321; } Message *AdcConfig::p_getMember(const char *s, const char *e) @@ -6888,7 +7117,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -310; + return -322; a += fn; switch (fid) { case 0xa: // name id 1, type std::string, coding byte[] @@ -6897,7 +7126,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -311; + return -323; m_name.assign((const char*)a,v); a += v; } @@ -6908,7 +7137,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -312; + return -324; a += n; set_gpio(varint_sint(v)); } @@ -6918,7 +7147,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -313; + return -325; a += n; set_config((gpiocfg_t) v); } @@ -6928,7 +7157,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -314; + return -326; a += s; break; } @@ -6936,7 +7165,7 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -315; + return -327; return a-(const uint8_t *)b; } @@ -6949,13 +7178,13 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -316; + return -328; *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 -317; + return -329; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -6963,22 +7192,22 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const if (m_gpio != -1) { // 'gpio': id=2, encoding=varint, tag=0x10 if (a >= e) - return -318; + return -330; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_gpio)); if (n <= 0) - return -319; + return -331; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) - return -320; + return -332; *a++ = 0x18; n = write_varint(a,e-a,m_config); if (n <= 0) - return -321; + return -333; a += n; } assert(a <= e); @@ -7143,10 +7372,10 @@ int GpioConfig::setByName(const char *name, const char *value) set_config_cap_freq_r2r((bool)ull); return eptr - value; } else { - return -322; + return -334; } } - return -323; + return -335; } Message *GpioConfig::p_getMember(const char *s, const char *e) @@ -7203,7 +7432,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -324; + return -336; a += fn; switch (fid) { case 0x8: // type id 1, type disp_t, coding varint @@ -7211,7 +7440,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -325; + return -337; a += n; set_type((disp_t) v); } @@ -7221,7 +7450,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -326; + return -338; a += n; set_options(v); } @@ -7231,7 +7460,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -327; + return -339; a += n; set_maxx(v); } @@ -7241,7 +7470,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -328; + return -340; a += n; set_maxy(v); } @@ -7251,7 +7480,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -329; + return -341; a += s; break; } @@ -7259,7 +7488,7 @@ ssize_t DisplayConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -330; + return -342; return a-(const uint8_t *)b; } @@ -7272,44 +7501,44 @@ 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 -331; + return -343; *a++ = 0x8; n = write_varint(a,e-a,m_type); if (n <= 0) - return -332; + return -344; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=2, encoding=varint, tag=0x10 if (a >= e) - return -333; + return -345; *a++ = 0x10; n = write_varint(a,e-a,m_options); if (n <= 0) - return -334; + return -346; a += n; } // has maxx? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'maxx': id=3, encoding=varint, tag=0x18 if (a >= e) - return -335; + return -347; *a++ = 0x18; n = write_varint(a,e-a,m_maxx); if (n <= 0) - return -336; + return -348; a += n; } // has maxy? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'maxy': id=4, encoding=varint, tag=0x20 if (a >= e) - return -337; + return -349; *a++ = 0x20; n = write_varint(a,e-a,m_maxy); if (n <= 0) - return -338; + return -350; a += n; } assert(a <= e); @@ -7461,7 +7690,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 -339; + return -351; set_type(v); return r; } @@ -7495,7 +7724,7 @@ int DisplayConfig::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 2); return r; } - return -340; + return -352; } Message *DisplayConfig::p_getMember(const char *s, const char *e) @@ -7553,7 +7782,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 -341; + return -353; a += fn; switch (fid) { case 0x8: // drv id 1, type spidrv_t, coding varint @@ -7561,7 +7790,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 -342; + return -354; a += n; set_drv((spidrv_t) v); } @@ -7571,7 +7800,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 -343; + return -355; a += n; set_cs(varint_sint(v)); } @@ -7581,7 +7810,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 -344; + return -356; a += n; set_intr(varint_sint(v)); } @@ -7591,7 +7820,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 -345; + return -357; a += n; set_reset(varint_sint(v)); } @@ -7601,7 +7830,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 -346; + return -358; a += n; set_cd(varint_sint(v)); } @@ -7611,7 +7840,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 -347; + return -359; a += s; break; } @@ -7619,7 +7848,7 @@ ssize_t SpiDeviceConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -348; + return -360; return a-(const uint8_t *)b; } @@ -7632,55 +7861,55 @@ 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 -349; + return -361; *a++ = 0x8; n = write_varint(a,e-a,m_drv); if (n <= 0) - return -350; + return -362; a += n; } // has cs? if (m_cs != -1) { // 'cs': id=2, encoding=varint, tag=0x10 if (a >= e) - return -351; + return -363; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_cs)); if (n <= 0) - return -352; + return -364; a += n; } // has intr? if (m_intr != -1) { // 'intr': id=3, encoding=varint, tag=0x18 if (a >= e) - return -353; + return -365; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_intr)); if (n <= 0) - return -354; + return -366; a += n; } // has reset? if (m_reset != -1) { // 'reset': id=4, encoding=varint, tag=0x20 if (a >= e) - return -355; + return -367; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_reset)); if (n <= 0) - return -356; + return -368; a += n; } // has cd? if (m_cd != -1) { // 'cd': id=5, encoding=varint, tag=0x28 if (a >= e) - return -357; + return -369; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_cd)); if (n <= 0) - return -358; + return -370; a += n; } assert(a <= e); @@ -7850,7 +8079,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 -359; + return -371; set_drv(v); return r; } @@ -7886,7 +8115,7 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cd,value); return r; } - return -360; + return -372; } Message *SpiDeviceConfig::p_getMember(const char *s, const char *e) @@ -7986,7 +8215,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 -361; + return -373; a += fn; switch (fid) { case 0x8: // host id 1, type int8_t, coding signed varint @@ -7994,7 +8223,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 -362; + return -374; a += n; set_host(varint_sint(v)); } @@ -8004,7 +8233,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 -363; + return -375; a += n; set_mosi(varint_sint(v)); } @@ -8014,7 +8243,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 -364; + return -376; a += n; set_miso(varint_sint(v)); } @@ -8024,7 +8253,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 -365; + return -377; a += n; set_sclk(varint_sint(v)); } @@ -8034,7 +8263,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 -366; + return -378; a += n; set_wp(varint_sint(v)); } @@ -8044,7 +8273,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 -367; + return -379; a += n; set_hold(varint_sint(v)); } @@ -8054,7 +8283,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 -368; + return -380; a += n; set_options((spiopt_t) v); } @@ -8064,7 +8293,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 -369; + return -381; a += n; set_dma(varint_sint(v)); } @@ -8075,14 +8304,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 -370; + return -382; 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 -371; + return -383; a += v; } } @@ -8092,7 +8321,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 -372; + return -384; a += s; break; } @@ -8100,7 +8329,7 @@ ssize_t SpiBusConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -373; + return -385; return a-(const uint8_t *)b; } @@ -8113,100 +8342,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 -374; + return -386; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_host)); if (n <= 0) - return -375; + return -387; a += n; } // has mosi? if (m_mosi != -1) { // 'mosi': id=2, encoding=varint, tag=0x10 if (a >= e) - return -376; + return -388; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_mosi)); if (n <= 0) - return -377; + return -389; a += n; } // has miso? if (m_miso != -1) { // 'miso': id=3, encoding=varint, tag=0x18 if (a >= e) - return -378; + return -390; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_miso)); if (n <= 0) - return -379; + return -391; a += n; } // has sclk? if (m_sclk != -1) { // 'sclk': id=4, encoding=varint, tag=0x20 if (a >= e) - return -380; + return -392; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_sclk)); if (n <= 0) - return -381; + return -393; a += n; } // has wp? if (m_wp != -1) { // 'wp': id=5, encoding=varint, tag=0x28 if (a >= e) - return -382; + return -394; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_wp)); if (n <= 0) - return -383; + return -395; a += n; } // has hold? if (m_hold != -1) { // 'hold': id=6, encoding=varint, tag=0x30 if (a >= e) - return -384; + return -396; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_hold)); if (n <= 0) - return -385; + return -397; a += n; } // has options? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'options': id=7, encoding=varint, tag=0x38 if (a >= e) - return -386; + return -398; *a++ = 0x38; n = write_varint(a,e-a,m_options); if (n <= 0) - return -387; + return -399; a += n; } // has dma? if (m_dma != -1) { // 'dma': id=8, encoding=varint, tag=0x40 if (a >= e) - return -388; + return -400; *a++ = 0x40; n = write_varint(a,e-a,sint_varint(m_dma)); if (n <= 0) - return -389; + return -401; a += n; } for (const auto &x : m_devices) { // 'devices': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -390; + return -402; *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 -391; + return -403; n = x.toMemory(a,e-a); a += n; assert(n == devices_ws); @@ -8536,7 +8765,7 @@ int SpiBusConfig::setByName(const char *name, const char *value) set_options_pha_hi((bool)ull); return eptr - value; } else { - return -392; + return -404; } } if (0 == strcmp(name,"dma")) { @@ -8562,21 +8791,21 @@ int SpiBusConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+8,&idxe,0); - if (idxe[0] != ']') - return -393; + if ((idxe[0] != ']') || (idxe == (name+8))) + return -405; if (m_devices.size() <= x) - return -394; + return -406; if ((idxe[1] == 0) && (value == 0)) { m_devices.erase(m_devices.begin()+x); return 0; } } if (idxe[1] != '.') - return -395; + return -407; return m_devices[x].setByName(idxe+2,value); } } - return -396; + return -408; } Message *SpiBusConfig::p_getMember(const char *s, const char *e) @@ -8634,7 +8863,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 -397; + return -409; a += fn; switch (fid) { case 0xa: // name id 1, type std::string, coding byte[] @@ -8643,7 +8872,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 -398; + return -410; m_name.assign((const char*)a,v); a += v; } @@ -8653,7 +8882,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 -399; + return -411; a += n; set_base(v); } @@ -8663,7 +8892,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 -400; + return -412; a += n; set_numio(v); } @@ -8673,7 +8902,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 -401; + return -413; a += n; set_int_a(varint_sint(v)); } @@ -8683,7 +8912,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 -402; + return -414; a += n; set_int_b(varint_sint(v)); } @@ -8693,7 +8922,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 -403; + return -415; a += s; break; } @@ -8701,7 +8930,7 @@ ssize_t GpioCluster::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -404; + return -416; return a-(const uint8_t *)b; } @@ -8714,13 +8943,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 -405; + return -417; *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 -406; + return -418; memcpy(a,m_name.data(),name_s); a += name_s; } @@ -8728,44 +8957,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 -407; + return -419; *a++ = 0x10; n = write_varint(a,e-a,m_base); if (n <= 0) - return -408; + return -420; a += n; } // has numio? if (m_numio != 0) { // 'numio': id=3, encoding=varint, tag=0x18 if (a >= e) - return -409; + return -421; *a++ = 0x18; n = write_varint(a,e-a,m_numio); if (n <= 0) - return -410; + return -422; a += n; } // has int_a? if (m_int_a != -1) { // 'int_a': id=4, encoding=varint, tag=0x20 if (a >= e) - return -411; + return -423; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_int_a)); if (n <= 0) - return -412; + return -424; a += n; } // has int_b? if (m_int_b != -1) { // 'int_b': id=5, encoding=varint, tag=0x28 if (a >= e) - return -413; + return -425; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_int_b)); if (n <= 0) - return -414; + return -426; a += n; } assert(a <= e); @@ -8967,7 +9196,7 @@ int GpioCluster::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_int_b,value); return r; } - return -415; + return -427; } Message *GpioCluster::p_getMember(const char *s, const char *e) @@ -9014,7 +9243,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 -416; + return -428; a += fn; switch (fid) { case 0x10: // sel id 2, type int8_t, coding signed varint @@ -9022,7 +9251,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 -417; + return -429; a += n; set_sel(varint_sint(v)); } @@ -9032,7 +9261,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 -418; + return -430; a += n; set_cf(varint_sint(v)); } @@ -9042,7 +9271,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 -419; + return -431; a += n; set_cf1(varint_sint(v)); } @@ -9052,7 +9281,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 -420; + return -432; a += s; break; } @@ -9060,7 +9289,7 @@ ssize_t Hlw8012Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -421; + return -433; return a-(const uint8_t *)b; } @@ -9073,33 +9302,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 -422; + return -434; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_sel)); if (n <= 0) - return -423; + return -435; a += n; } // has cf? if (m_cf != -1) { // 'cf': id=3, encoding=varint, tag=0x18 if (a >= e) - return -424; + return -436; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_cf)); if (n <= 0) - return -425; + return -437; a += n; } // has cf1? if (m_cf1 != -1) { // 'cf1': id=4, encoding=varint, tag=0x20 if (a >= e) - return -426; + return -438; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_cf1)); if (n <= 0) - return -427; + return -439; a += n; } assert(a <= e); @@ -9239,7 +9468,7 @@ int Hlw8012Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_cf1,value); return r; } - return -428; + return -440; } Message *Hlw8012Config::p_getMember(const char *s, const char *e) @@ -9295,7 +9524,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 -429; + return -441; a += fn; switch (fid) { case 0x8: // dio0 id 1, type int8_t, coding signed varint @@ -9303,7 +9532,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 -430; + return -442; a += n; set_dio0(varint_sint(v)); } @@ -9313,7 +9542,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 -431; + return -443; a += n; set_dio1(varint_sint(v)); } @@ -9323,7 +9552,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 -432; + return -444; a += n; set_dio2(varint_sint(v)); } @@ -9333,7 +9562,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 -433; + return -445; a += n; set_dio3(varint_sint(v)); } @@ -9343,7 +9572,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 -434; + return -446; a += n; set_dio4(varint_sint(v)); } @@ -9353,7 +9582,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 -435; + return -447; a += n; set_dio5(varint_sint(v)); } @@ -9363,7 +9592,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 -436; + return -448; a += s; break; } @@ -9371,7 +9600,7 @@ ssize_t SX1276Config::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -437; + return -449; return a-(const uint8_t *)b; } @@ -9384,66 +9613,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 -438; + return -450; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_dio0)); if (n <= 0) - return -439; + return -451; a += n; } // has dio1? if (m_dio1 != -1) { // 'dio1': id=2, encoding=varint, tag=0x10 if (a >= e) - return -440; + return -452; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_dio1)); if (n <= 0) - return -441; + return -453; a += n; } // has dio2? if (m_dio2 != -1) { // 'dio2': id=3, encoding=varint, tag=0x18 if (a >= e) - return -442; + return -454; *a++ = 0x18; n = write_varint(a,e-a,sint_varint(m_dio2)); if (n <= 0) - return -443; + return -455; a += n; } // has dio3? if (m_dio3 != -1) { // 'dio3': id=4, encoding=varint, tag=0x20 if (a >= e) - return -444; + return -456; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dio3)); if (n <= 0) - return -445; + return -457; a += n; } // has dio4? if (m_dio4 != -1) { // 'dio4': id=5, encoding=varint, tag=0x28 if (a >= e) - return -446; + return -458; *a++ = 0x28; n = write_varint(a,e-a,sint_varint(m_dio4)); if (n <= 0) - return -447; + return -459; a += n; } // has dio5? if (m_dio5 != -1) { // 'dio5': id=6, encoding=varint, tag=0x30 if (a >= e) - return -448; + return -460; *a++ = 0x30; n = write_varint(a,e-a,sint_varint(m_dio5)); if (n <= 0) - return -449; + return -461; a += n; } assert(a <= e); @@ -9667,7 +9896,7 @@ int SX1276Config::setByName(const char *name, const char *value) int r = parse_ascii_s8(&m_dio5,value); return r; } - return -450; + return -462; } Message *SX1276Config::p_getMember(const char *s, const char *e) @@ -9901,8 +10130,18 @@ void HardwareConfig::toASCII(std::ostream &o, size_t indent) const m_tlc5947.toASCII(o,indent); #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - ascii_indent(o,indent,"ws2812b"); - m_ws2812b.toASCII(o,indent); + ascii_indent(o,indent); + size_t s_ws2812b = m_ws2812b.size(); + o << "ws2812b[" << s_ws2812b << "] = {"; + ++indent; + for (size_t i = 0, e = s_ws2812b; i != e; ++i) { + ascii_indent(o,indent); + o << i << ": "; + m_ws2812b[i].toASCII(o,indent); + } + --indent; + ascii_indent(o,indent); + o << '}'; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT ascii_indent(o,indent,"dht"); @@ -9975,12 +10214,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 -451; + return -463; a += fn; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit if ((a+3) >= e) - return -452; + return -464; set_magic((uint32_t) read_u32(a)); a += 4; break; @@ -9990,13 +10229,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 -453; + return -465; if (v != 0) { n = m_system.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -454; + return -466; a += v; } } @@ -10008,14 +10247,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 -455; + return -467; 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 -456; + return -468; a += v; } } @@ -10026,13 +10265,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 -457; + return -469; if (v != 0) { n = m_adc.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -458; + return -470; a += v; } } @@ -10045,13 +10284,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 -459; + return -471; if (v != 0) { n = m_touchpad.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -460; + return -472; a += v; } } @@ -10065,14 +10304,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 -461; + return -473; 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 -462; + return -474; a += v; } } @@ -10084,14 +10323,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 -463; + return -475; m_gpio.emplace_back(); if (v != 0) { n = m_gpio.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -464; + return -476; a += v; } } @@ -10103,14 +10342,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 -465; + return -477; 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 -466; + return -478; a += v; } } @@ -10123,14 +10362,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 -467; + return -479; 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 -468; + return -480; a += v; } } @@ -10143,14 +10382,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 -469; + return -481; 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 -470; + return -482; a += v; } } @@ -10163,14 +10402,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 -471; + return -483; 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 -472; + return -484; a += v; } } @@ -10183,13 +10422,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 -473; + return -485; if (v != 0) { n = m_hlw8012.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -474; + return -486; a += v; } } @@ -10203,13 +10442,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 -475; + return -487; if (v != 0) { n = m_max7219.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -476; + return -488; a += v; } } @@ -10223,13 +10462,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 -477; + return -489; if (v != 0) { n = m_tlc5947.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -478; + return -490; a += v; } } @@ -10243,17 +10482,17 @@ 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 -479; + return -491; + m_ws2812b.emplace_back(); if (v != 0) { - n = m_ws2812b.fromMemory((const uint8_t*)a,v); + n = m_ws2812b.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -480; + return -492; a += v; } } - p_validbits |= ((uint16_t)1U << 7); break; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -10263,17 +10502,17 @@ 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 -481; + return -493; if (v != 0) { n = m_dht.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -482; + return -494; a += v; } } - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); break; #endif // CONFIG_DHT #ifdef CONFIG_I2C @@ -10283,14 +10522,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 -483; + return -495; 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 -484; + return -496; a += v; } } @@ -10303,14 +10542,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 -485; + return -497; 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 -486; + return -498; a += v; } } @@ -10323,17 +10562,17 @@ 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 -487; + return -499; if (v != 0) { n = m_onewire.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -488; + return -500; a += v; } } - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); break; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 @@ -10343,17 +10582,17 @@ 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 -489; + return -501; if (v != 0) { n = m_sx1276.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -490; + return -502; a += v; } } - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); break; #endif // CONFIG_SX1276 #ifdef CONFIG_IOEXTENDERS @@ -10363,14 +10602,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 -491; + return -503; 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 -492; + return -504; a += v; } } @@ -10383,17 +10622,17 @@ 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 -493; + return -505; if (v != 0) { n = m_display.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -494; + return -506; a += v; } } - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); break; #endif // CONFIG_DISPLAY default: @@ -10401,7 +10640,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 -495; + return -507; a += s; break; } @@ -10409,7 +10648,7 @@ ssize_t HardwareConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -496; + return -508; return a-(const uint8_t *)b; } @@ -10422,10 +10661,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 -497; + return -509; *a++ = 0x5; if ((e-a) < 4) - return -498; + return -510; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -10433,13 +10672,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 -499; + return -511; *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 -500; + return -512; n = m_system.toMemory(a,e-a); a += n; assert(n == system_ws); @@ -10447,13 +10686,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 -501; + return -513; *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 -502; + return -514; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -10462,13 +10701,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 -503; + return -515; *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 -504; + return -516; n = m_adc.toMemory(a,e-a); a += n; assert(n == adc_ws); @@ -10478,13 +10717,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 -505; + return -517; *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 -506; + return -518; n = m_touchpad.toMemory(a,e-a); a += n; assert(n == touchpad_ws); @@ -10494,13 +10733,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 -507; + return -519; *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 -508; + return -520; n = x.toMemory(a,e-a); a += n; assert(n == tp_channel_ws); @@ -10509,13 +10748,13 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_gpio) { // 'gpio': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -509; + return -521; *a++ = 0x3a; ssize_t gpio_ws = x.calcSize(); n = write_varint(a,e-a,gpio_ws); a += n; if ((n <= 0) || (gpio_ws > (e-a))) - return -510; + return -522; n = x.toMemory(a,e-a); a += n; assert(n == gpio_ws); @@ -10524,13 +10763,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 -511; + return -523; *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 -512; + return -524; n = x.toMemory(a,e-a); a += n; assert(n == spibus_ws); @@ -10540,14 +10779,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 -513; + return -525; *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 -514; + return -526; n = x.toMemory(a,e-a); a += n; assert(n == button_ws); @@ -10557,14 +10796,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 -515; + return -527; *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 -516; + return -528; n = x.toMemory(a,e-a); a += n; assert(n == relay_ws); @@ -10574,14 +10813,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 -517; + return -529; *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 -518; + return -530; n = x.toMemory(a,e-a); a += n; assert(n == led_ws); @@ -10592,14 +10831,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 -519; + return -531; *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 -520; + return -532; n = m_hlw8012.toMemory(a,e-a); a += n; assert(n == hlw8012_ws); @@ -10610,14 +10849,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 -521; + return -533; *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 -522; + return -534; n = m_max7219.toMemory(a,e-a); a += n; assert(n == max7219_ws); @@ -10628,50 +10867,49 @@ 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 -523; + return -535; *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 -524; + return -536; n = m_tlc5947.toMemory(a,e-a); a += n; assert(n == tlc5947_ws); } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // has ws2812b? - if (0 != (p_validbits & ((uint16_t)1U << 7))) { + for (const auto &x : m_ws2812b) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 if (2 > (e-a)) - return -525; + return -537; *a++ = 0x92; *a++ = 0x2; - ssize_t ws2812b_ws = m_ws2812b.calcSize(); + ssize_t ws2812b_ws = x.calcSize(); n = write_varint(a,e-a,ws2812b_ws); a += n; if ((n <= 0) || (ws2812b_ws > (e-a))) - return -526; - n = m_ws2812b.toMemory(a,e-a); + return -538; + 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a if (2 > (e-a)) - return -527; + return -539; *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 -528; + return -540; n = m_dht.toMemory(a,e-a); a += n; assert(n == dht_ws); @@ -10681,14 +10919,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 -529; + return -541; *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 -530; + return -542; n = x.toMemory(a,e-a); a += n; assert(n == i2c_ws); @@ -10698,14 +10936,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 -531; + return -543; *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 -532; + return -544; n = x.toMemory(a,e-a); a += n; assert(n == hcsr04_ws); @@ -10713,17 +10951,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE // has onewire? - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 if (2 > (e-a)) - return -533; + return -545; *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 -534; + return -546; n = m_onewire.toMemory(a,e-a); a += n; assert(n == onewire_ws); @@ -10731,17 +10969,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 // has sx1276? - if (0 != (p_validbits & ((uint16_t)1U << 10))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a if (2 > (e-a)) - return -535; + return -547; *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 -536; + return -548; n = m_sx1276.toMemory(a,e-a); a += n; assert(n == sx1276_ws); @@ -10751,14 +10989,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 -537; + return -549; *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 -538; + return -550; n = x.toMemory(a,e-a); a += n; assert(n == iocluster_ws); @@ -10766,17 +11004,17 @@ ssize_t HardwareConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY // has display? - if (0 != (p_validbits & ((uint16_t)1U << 11))) { + if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'display': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -539; + return -551; *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 -540; + return -552; n = m_display.toMemory(a,e-a); a += n; assert(n == display_ws); @@ -10896,16 +11134,16 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (0 != (p_validbits & ((uint16_t)1U << 7))) { + for (size_t x = 0, y = m_ws2812b.size(); x != y; ++x) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 put(0x92); put(0x2); - send_varint(put,m_ws2812b.calcSize()); - m_ws2812b.toWire(put); + 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a put(0x9a); put(0x2); @@ -10932,7 +11170,7 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 put(0xb2); put(0x2); @@ -10941,7 +11179,7 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 - if (0 != (p_validbits & ((uint16_t)1U << 10))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a put(0xba); put(0x2); @@ -10959,7 +11197,7 @@ void HardwareConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY - if (0 != (p_validbits & ((uint16_t)1U << 11))) { + if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'display': id=50, encoding=lenpfx, tag=0x192 put(0x92); put(0x3); @@ -11079,16 +11317,16 @@ void HardwareConfig::toString(std::string &put) const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (0 != (p_validbits & ((uint16_t)1U << 7))) { + for (size_t x = 0, y = m_ws2812b.size(); x != y; ++x) { // 'ws2812b': id=34, encoding=lenpfx, tag=0x112 put.push_back(0x92); put.push_back(0x2); - send_varint(put,m_ws2812b.calcSize()); - m_ws2812b.toString(put); + 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { // 'dht': id=35, encoding=lenpfx, tag=0x11a put.push_back(0x9a); put.push_back(0x2); @@ -11115,7 +11353,7 @@ void HardwareConfig::toString(std::string &put) const } #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { // 'onewire': id=38, encoding=lenpfx, tag=0x132 put.push_back(0xb2); put.push_back(0x2); @@ -11124,7 +11362,7 @@ void HardwareConfig::toString(std::string &put) const } #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 - if (0 != (p_validbits & ((uint16_t)1U << 10))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { // 'sx1276': id=39, encoding=lenpfx, tag=0x13a put.push_back(0xba); put.push_back(0x2); @@ -11142,7 +11380,7 @@ void HardwareConfig::toString(std::string &put) const } #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY - if (0 != (p_validbits & ((uint16_t)1U << 11))) { + if (0 != (p_validbits & ((uint16_t)1U << 10))) { // 'display': id=50, encoding=lenpfx, tag=0x192 put.push_back(0x92); put.push_back(0x3); @@ -11329,9 +11567,23 @@ void HardwareConfig::toJSON(std::ostream &json, unsigned indLvl) const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b()) { - fsep = json_indent(json,indLvl,fsep,"ws2812b"); - m_ws2812b.toJSON(json,indLvl); + if (size_t s = m_ws2812b.size()) { + fsep = json_indent(json,indLvl,fsep); + indLvl += 2; + json << "\"ws2812b\":[\n"; + size_t i = 0; + for (;;) { + json_indent(json,indLvl,0); + m_ws2812b[i].toJSON(json,indLvl); + ++i; + if (i == s) + break; + json << ",\n"; + } + indLvl -= 2; + json.put('\n'); + json_indent(json,indLvl,0); + json.put(']'); } #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -11533,15 +11785,17 @@ size_t HardwareConfig::calcSize() const } #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 - if (0 != (p_validbits & ((uint16_t)1U << 7))) { - size_t ws2812b_s = m_ws2812b.calcSize(); - r += ws2812b_s + wiresize(ws2812b_s) + 2 /* tag(ws2812b) 0x110 */; + // repeated Ws2812bConfig ws2812b, id 34 + // repeated message ws2812b + for (size_t x = 0, y = m_ws2812b.size(); x < y; ++x) { + size_t s = m_ws2812b[x].calcSize(); + 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 7))) { size_t dht_s = m_dht.calcSize(); r += dht_s + wiresize(dht_s) + 2 /* tag(dht) 0x118 */; } @@ -11566,14 +11820,14 @@ size_t HardwareConfig::calcSize() const #endif // CONFIG_HCSR04 #ifdef CONFIG_ONEWIRE // optional OneWireConfig onewire, id 38 - if (0 != (p_validbits & ((uint16_t)1U << 9))) { + if (0 != (p_validbits & ((uint16_t)1U << 8))) { 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))) { + if (0 != (p_validbits & ((uint16_t)1U << 9))) { size_t sx1276_s = m_sx1276.calcSize(); r += sx1276_s + wiresize(sx1276_s) + 2 /* tag(sx1276) 0x138 */; } @@ -11589,7 +11843,7 @@ size_t HardwareConfig::calcSize() const #endif // CONFIG_IOEXTENDERS #ifdef CONFIG_DISPLAY // optional DisplayConfig display, id 50 - if (0 != (p_validbits & ((uint16_t)1U << 11))) { + if (0 != (p_validbits & ((uint16_t)1U << 10))) { size_t display_s = m_display.calcSize(); r += display_s + wiresize(display_s) + 2 /* tag(display) 0x190 */; } @@ -11648,7 +11902,7 @@ bool HardwareConfig::operator != (const HardwareConfig &r) const return true; #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - if (has_ws2812b() && (m_ws2812b != r.m_ws2812b)) + if (m_ws2812b != r.m_ws2812b) return true; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT @@ -11732,17 +11986,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -541; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -553; if (m_uart.size() <= x) - return -542; + return -554; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -543; + return -555; return m_uart[x].setByName(idxe+2,value); } } @@ -11782,17 +12036,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -544; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -556; if (m_tp_channel.size() <= x) - return -545; + return -557; if ((idxe[1] == 0) && (value == 0)) { m_tp_channel.erase(m_tp_channel.begin()+x); return 0; } } if (idxe[1] != '.') - return -546; + return -558; return m_tp_channel[x].setByName(idxe+2,value); } } @@ -11812,17 +12066,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -547; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -559; if (m_gpio.size() <= x) - return -548; + return -560; if ((idxe[1] == 0) && (value == 0)) { m_gpio.erase(m_gpio.begin()+x); return 0; } } if (idxe[1] != '.') - return -549; + return -561; return m_gpio[x].setByName(idxe+2,value); } } @@ -11842,17 +12096,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -550; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -562; if (m_spibus.size() <= x) - return -551; + return -563; if ((idxe[1] == 0) && (value == 0)) { m_spibus.erase(m_spibus.begin()+x); return 0; } } if (idxe[1] != '.') - return -552; + return -564; return m_spibus[x].setByName(idxe+2,value); } } @@ -11873,17 +12127,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -553; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -565; if (m_button.size() <= x) - return -554; + return -566; if ((idxe[1] == 0) && (value == 0)) { m_button.erase(m_button.begin()+x); return 0; } } if (idxe[1] != '.') - return -555; + return -567; return m_button[x].setByName(idxe+2,value); } } @@ -11904,17 +12158,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') - return -556; + if ((idxe[0] != ']') || (idxe == (name+6))) + return -568; if (m_relay.size() <= x) - return -557; + return -569; if ((idxe[1] == 0) && (value == 0)) { m_relay.erase(m_relay.begin()+x); return 0; } } if (idxe[1] != '.') - return -558; + return -570; return m_relay[x].setByName(idxe+2,value); } } @@ -11935,17 +12189,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -559; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -571; if (m_led.size() <= x) - return -560; + return -572; if ((idxe[1] == 0) && (value == 0)) { m_led.erase(m_led.begin()+x); return 0; } } if (idxe[1] != '.') - return -561; + return -573; return m_led[x].setByName(idxe+2,value); } } @@ -11988,9 +12242,29 @@ int HardwareConfig::setByName(const char *name, const char *value) if ((name[7] == 0) && (value == 0)) { clear_ws2812b(); return 0; - } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 7); - return m_ws2812b.setByName(name+8,value); + } else if (name[7] == '[') { + char *idxe; + unsigned long x; + if ((name[8] == '+') && (name[9] == ']')) { + x = m_ws2812b.size(); + m_ws2812b.resize(x+1); + idxe = (char*)(name + 9); + if (value == 0) + return 0; + } else { + x = strtoul(name+8,&idxe,0); + if ((idxe[0] != ']') || (idxe == (name+8))) + return -574; + if (m_ws2812b.size() <= x) + return -575; + if ((idxe[1] == 0) && (value == 0)) { + m_ws2812b.erase(m_ws2812b.begin()+x); + return 0; + } + } + if (idxe[1] != '.') + return -576; + return m_ws2812b[x].setByName(idxe+2,value); } } #endif // CONFIG_RGBLEDS @@ -12000,7 +12274,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_dht(); return 0; } else if (name[3] == '.') { - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); return m_dht.setByName(name+4,value); } } @@ -12021,17 +12295,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+4,&idxe,0); - if (idxe[0] != ']') - return -562; + if ((idxe[0] != ']') || (idxe == (name+4))) + return -577; if (m_i2c.size() <= x) - return -563; + return -578; if ((idxe[1] == 0) && (value == 0)) { m_i2c.erase(m_i2c.begin()+x); return 0; } } if (idxe[1] != '.') - return -564; + return -579; return m_i2c[x].setByName(idxe+2,value); } } @@ -12052,17 +12326,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -565; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -580; if (m_hcsr04.size() <= x) - return -566; + return -581; if ((idxe[1] == 0) && (value == 0)) { m_hcsr04.erase(m_hcsr04.begin()+x); return 0; } } if (idxe[1] != '.') - return -567; + return -582; return m_hcsr04[x].setByName(idxe+2,value); } } @@ -12073,7 +12347,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_onewire(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); return m_onewire.setByName(name+8,value); } } @@ -12084,7 +12358,7 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_sx1276(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); return m_sx1276.setByName(name+7,value); } } @@ -12105,17 +12379,17 @@ int HardwareConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -568; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -583; if (m_iocluster.size() <= x) - return -569; + return -584; if ((idxe[1] == 0) && (value == 0)) { m_iocluster.erase(m_iocluster.begin()+x); return 0; } } if (idxe[1] != '.') - return -570; + return -585; return m_iocluster[x].setByName(idxe+2,value); } } @@ -12126,12 +12400,12 @@ int HardwareConfig::setByName(const char *name, const char *value) clear_display(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); return m_display.setByName(name+8,value); } } #endif // CONFIG_DISPLAY - return -571; + return -586; } Message *HardwareConfig::p_getMember(const char *s, const char *e) @@ -12156,10 +12430,6 @@ Message *HardwareConfig::p_getMember(const char *s, const char *e) if (0 == strncmp("tlc5947",s,e-s)) return &m_tlc5947; #endif // CONFIG_TLC5947 - #ifdef CONFIG_RGBLEDS - if (0 == strncmp("ws2812b",s,e-s)) - return &m_ws2812b; - #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT if (0 == strncmp("dht",s,e-s)) return &m_dht; @@ -12226,6 +12496,13 @@ Message *HardwareConfig::p_getMember(const char *s, const char *e, unsigned x) return 0; } #endif // CONFIG_LEDS + #ifdef CONFIG_RGBLEDS + if (0 == strncmp("ws2812b[",s,e-s)) { + if (x < m_ws2812b.size()) + return &m_ws2812b[x]; + return 0; + } + #endif // CONFIG_RGBLEDS #ifdef CONFIG_I2C if (0 == strncmp("i2c[",s,e-s)) { if (x < m_i2c.size()) diff --git a/components/wfc/hwcfg_pc.h b/components/wfc/hwcfg_pc.h index 9a62599..895a5c1 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -175,6 +175,7 @@ typedef enum { i2cdrv_ht16k33 = 10, i2cdrv_ina219 = 11, i2cdrv_si7021 = 12, + i2cdrv_tca9555 = 13, } i2cdrv_t; //! Function to get an ASCII string from a value of a i2cdrv_t. const char *i2cdrv_t_str(i2cdrv_t e); @@ -1837,6 +1838,32 @@ class Ws2812bConfig : public Message */ uint8_t *mutable_nleds(); + // optional string name, id 4 + /*! + * Function for querying if name has been set. + * @return true if name is set. + */ + bool has_name() const; + //! Function to reset name to its default/unset value. + void clear_name(); + //! Get value of name. + const std::string &name() const; + /*! + * Function for setting name using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_name(const void *data, size_t s); + //! Set name using a constant reference + void set_name(const std::string &v); + //! Set name using a pointer to a null-terminated C-string. + void set_name(const char *); + /*! + * Provide mutable access to name. + * @return pointer to member variable of name. + */ + std::string *mutable_name(); + protected: Message *p_getMember(const char *s, const char *e); @@ -1847,6 +1874,8 @@ class Ws2812bConfig : public Message int8_t m_ch; //! uint8 nleds, id 3 uint8_t m_nleds; + //! string name, id 4 + std::string m_name; }; @@ -3027,6 +3056,68 @@ class AdcChannel : public Message */ uint8_t *mutable_window(); + // optional float scale, id 8 + /*! + * Function for querying if scale has been set. + * @return true if scale is set. + */ + bool has_scale() const; + //! Function to reset scale to its default/unset value. + void clear_scale(); + //! Get value of scale. + float scale() const; + //! Set scale using a constant reference + void set_scale(float v); + /*! + * Provide mutable access to scale. + * @return pointer to member variable of scale. + */ + float *mutable_scale(); + + // optional float offset, id 9 + /*! + * Function for querying if offset has been set. + * @return true if offset is set. + */ + bool has_offset() const; + //! Function to reset offset to its default/unset value. + void clear_offset(); + //! Get value of offset. + float offset() const; + //! Set offset using a constant reference + void set_offset(float v); + /*! + * Provide mutable access to offset. + * @return pointer to member variable of offset. + */ + float *mutable_offset(); + + // optional string dim, id 10 + /*! + * Function for querying if dim has been set. + * @return true if dim is set. + */ + bool has_dim() const; + //! Function to reset dim to its default/unset value. + void clear_dim(); + //! Get value of dim. + const std::string &dim() const; + /*! + * Function for setting dim using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_dim(const void *data, size_t s); + //! Set dim using a constant reference + void set_dim(const std::string &v); + //! Set dim using a pointer to a null-terminated C-string. + void set_dim(const char *); + /*! + * Provide mutable access to dim. + * @return pointer to member variable of dim. + */ + std::string *mutable_dim(); + protected: Message *p_getMember(const char *s, const char *e); @@ -3043,6 +3134,12 @@ class AdcChannel : public Message uint16_t m_interval; //! uint8 window, id 6 uint8_t m_window; + //! float scale, id 8 + float m_scale; + //! float offset, id 9 + float m_offset; + //! string dim, id 10 + std::string m_dim; private: uint8_t p_validbits; @@ -5063,29 +5160,29 @@ class HardwareConfig : public Message #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS - // optional Ws2812bConfig ws2812b, id 34 + // repeated Ws2812bConfig ws2812b, id 34 + //! Function get const-access to the elements of ws2812b. + const std::vector &ws2812b() const; + //! Function to get the number of elements in ws2812b. + size_t ws2812b_size() const; /*! - * Function for querying if ws2812b has been set. - * @return true if ws2812b is set. + * Function to append a element to ws2812b. + * @return point to newly added element. */ - bool has_ws2812b() const; + Ws2812bConfig* add_ws2812b(); //! Function to reset ws2812b to its default/unset value. void clear_ws2812b(); - //! Get value of ws2812b. - const Ws2812bConfig &ws2812b() const; - /*! - * Function for setting ws2812b using binary data. - * @param data pointer to binary data - * @param s number of bytes at data pointer - */ - void set_ws2812b(const void *data, size_t s); + //! Get value of element x of ws2812b. + const Ws2812bConfig &ws2812b(unsigned x) const; //! Set ws2812b using a constant reference - void set_ws2812b(const Ws2812bConfig &v); + void set_ws2812b(unsigned x, const Ws2812bConfig &v); /*! * Provide mutable access to ws2812b. * @return pointer to member variable of ws2812b. */ - Ws2812bConfig *mutable_ws2812b(); + 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 @@ -5322,7 +5419,7 @@ class HardwareConfig : public Message #endif // CONFIG_TLC5947 #ifdef CONFIG_RGBLEDS //! Ws2812bConfig ws2812b, id 34 - Ws2812bConfig m_ws2812b; + std::vector m_ws2812b; #endif // CONFIG_RGBLEDS #ifdef CONFIG_DHT //! DhtConfig dht, id 35 @@ -6917,7 +7014,8 @@ inline size_t Ws2812bConfig::getMaxSize() // optional sint8 gpio, id 1 has maximum size 3 // optional sint8 ch, id 2 has maximum size 3 // optional uint8 nleds, id 3 has maximum size 3 - return 9; + // optional string name, id 4 has unlimited size + return SIZE_MAX; } inline int8_t Ws2812bConfig::gpio() const @@ -7013,6 +7111,47 @@ inline void Ws2812bConfig::set_nleds(uint8_t v) +inline const std::string &Ws2812bConfig::name() const +{ + return m_name; +} + +inline bool Ws2812bConfig::has_name() const +{ + return !m_name.empty(); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void Ws2812bConfig::clear_name() +{ + m_name.clear(); +} + +inline std::string *Ws2812bConfig::mutable_name() +{ + return &m_name; +} + +inline void Ws2812bConfig::set_name(const void *data, size_t s) +{ + m_name.assign((const char *)data,s); +} + +inline void Ws2812bConfig::set_name(const char *data) +{ + m_name = data; +} + +inline void Ws2812bConfig::set_name(const std::string &v) +{ + m_name = v; +} + + + inline size_t DhtConfig::getMaxSize() { // optional dht_model_t model, id 1 has maximum size 3 @@ -7891,6 +8030,9 @@ inline size_t AdcChannel::getMaxSize() // optional uint8 atten, id 4 has maximum size 3 // optional uint16 interval, id 5 has maximum size 4 // optional uint8 window, id 6 has maximum size 3 + // optional float scale, id 8 has maximum size 5 + // optional float offset, id 9 has maximum size 5 + // optional string dim, id 10 has unlimited size return SIZE_MAX; } @@ -8096,6 +8238,129 @@ inline void AdcChannel::set_window(uint8_t v) +inline float AdcChannel::scale() const +{ + return m_scale; +} + +inline bool AdcChannel::has_scale() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 1)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_scale() +{ + p_validbits &= ~((uint8_t)1U << 1); + m_scale = 1; +} + +inline float *AdcChannel::mutable_scale() +{ + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); + m_scale = 1; + } + return &m_scale; +} + +inline void AdcChannel::set_scale(float v) +{ + m_scale = v; + p_validbits |= ((uint8_t)1U << 1); +} + + + +inline float AdcChannel::offset() const +{ + return m_offset; +} + +inline bool AdcChannel::has_offset() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 2)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_offset() +{ + p_validbits &= ~((uint8_t)1U << 2); + m_offset = 0; +} + +inline float *AdcChannel::mutable_offset() +{ + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); + m_offset = 0; + } + return &m_offset; +} + +inline void AdcChannel::set_offset(float v) +{ + m_offset = v; + p_validbits |= ((uint8_t)1U << 2); +} + + + +inline const std::string &AdcChannel::dim() const +{ + return m_dim; +} + +inline bool AdcChannel::has_dim() const +{ + return 0 != (p_validbits & ((uint8_t)1U << 3)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void AdcChannel::clear_dim() +{ + p_validbits &= ~((uint8_t)1U << 3); + m_dim.clear(); +} + +inline std::string *AdcChannel::mutable_dim() +{ + if (0 == (p_validbits & ((uint8_t)1U << 3))) { + p_validbits |= ((uint8_t)1U << 3); + m_dim.clear(); + } + return &m_dim; +} + +inline void AdcChannel::set_dim(const void *data, size_t s) +{ + m_dim.assign((const char *)data,s); + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const char *data) +{ + m_dim = data; + p_validbits |= ((uint8_t)1U << 3); +} + +inline void AdcChannel::set_dim(const std::string &v) +{ + m_dim = v; + p_validbits |= ((uint8_t)1U << 3); +} + + + inline size_t AdcConfig::getMaxSize() { // optional string adc_name, id 1 has unlimited size @@ -9804,7 +10069,7 @@ inline size_t HardwareConfig::getMaxSize() // optional Hlw8012Config hlw8012, id 20 has maximum size 11 // optional Max7219Config max7219, id 32 has maximum size 16 // optional Tlc5947Config tlc5947, id 33 has maximum size 17 - // optional Ws2812bConfig ws2812b, id 34 has maximum size 11 + // repeated Ws2812bConfig ws2812b, id 34 has unlimited size // optional DhtConfig dht, id 35 has maximum size 8 // repeated I2CConfig i2c, id 36 has unlimited size // repeated HcSr04Config hcsr04, id 37 has unlimited size @@ -10479,14 +10744,14 @@ inline void HardwareConfig::set_tlc5947(const Tlc5947Config &v) #ifdef CONFIG_RGBLEDS -inline const Ws2812bConfig &HardwareConfig::ws2812b() const +inline const Ws2812bConfig &HardwareConfig::ws2812b(unsigned x) const { - return m_ws2812b; + return m_ws2812b[x]; } -inline bool HardwareConfig::has_ws2812b() const +inline const std::vector &HardwareConfig::ws2812b() const { - return 0 != (p_validbits & ((uint16_t)1U << 7)); + return m_ws2812b; } /*! @@ -10495,29 +10760,36 @@ inline bool HardwareConfig::has_ws2812b() const */ inline void HardwareConfig::clear_ws2812b() { - p_validbits &= ~((uint16_t)1U << 7); m_ws2812b.clear(); } -inline Ws2812bConfig *HardwareConfig::mutable_ws2812b() +inline Ws2812bConfig *HardwareConfig::mutable_ws2812b(unsigned x) +{ + if (x >= m_ws2812b.size()) + m_ws2812b.resize(x+1); + return &m_ws2812b[x]; +} + +inline std::vector *HardwareConfig::mutable_ws2812b() { - if (0 == (p_validbits & ((uint16_t)1U << 7))) { - p_validbits |= ((uint16_t)1U << 7); - m_ws2812b.clear(); - } return &m_ws2812b; } -inline void HardwareConfig::set_ws2812b(const void *data, size_t s) +inline Ws2812bConfig *HardwareConfig::add_ws2812b() { - m_ws2812b.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 7); + m_ws2812b.resize(m_ws2812b.size()+1); + return &m_ws2812b.back(); } -inline void HardwareConfig::set_ws2812b(const Ws2812bConfig &v) +inline void HardwareConfig::set_ws2812b(unsigned x, const Ws2812bConfig &v) { - m_ws2812b = v; - p_validbits |= ((uint16_t)1U << 7); + assert(x < m_ws2812b.size()); + m_ws2812b[x] = v; +} + +inline size_t HardwareConfig::ws2812b_size() const +{ + return m_ws2812b.size(); } #endif // CONFIG_RGBLEDS @@ -10531,7 +10803,7 @@ inline const DhtConfig &HardwareConfig::dht() const inline bool HardwareConfig::has_dht() const { - return 0 != (p_validbits & ((uint16_t)1U << 8)); + return 0 != (p_validbits & ((uint16_t)1U << 7)); } /*! @@ -10540,14 +10812,14 @@ inline bool HardwareConfig::has_dht() const */ inline void HardwareConfig::clear_dht() { - p_validbits &= ~((uint16_t)1U << 8); + p_validbits &= ~((uint16_t)1U << 7); m_dht.clear(); } inline DhtConfig *HardwareConfig::mutable_dht() { - if (0 == (p_validbits & ((uint16_t)1U << 8))) { - p_validbits |= ((uint16_t)1U << 8); + if (0 == (p_validbits & ((uint16_t)1U << 7))) { + p_validbits |= ((uint16_t)1U << 7); m_dht.clear(); } return &m_dht; @@ -10556,13 +10828,13 @@ inline DhtConfig *HardwareConfig::mutable_dht() inline void HardwareConfig::set_dht(const void *data, size_t s) { m_dht.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } inline void HardwareConfig::set_dht(const DhtConfig &v) { m_dht = v; - p_validbits |= ((uint16_t)1U << 8); + p_validbits |= ((uint16_t)1U << 7); } #endif // CONFIG_DHT @@ -10680,7 +10952,7 @@ inline const OneWireConfig &HardwareConfig::onewire() const inline bool HardwareConfig::has_onewire() const { - return 0 != (p_validbits & ((uint16_t)1U << 9)); + return 0 != (p_validbits & ((uint16_t)1U << 8)); } /*! @@ -10689,14 +10961,14 @@ inline bool HardwareConfig::has_onewire() const */ inline void HardwareConfig::clear_onewire() { - p_validbits &= ~((uint16_t)1U << 9); + p_validbits &= ~((uint16_t)1U << 8); m_onewire.clear(); } inline OneWireConfig *HardwareConfig::mutable_onewire() { - if (0 == (p_validbits & ((uint16_t)1U << 9))) { - p_validbits |= ((uint16_t)1U << 9); + if (0 == (p_validbits & ((uint16_t)1U << 8))) { + p_validbits |= ((uint16_t)1U << 8); m_onewire.clear(); } return &m_onewire; @@ -10705,13 +10977,13 @@ inline OneWireConfig *HardwareConfig::mutable_onewire() inline void HardwareConfig::set_onewire(const void *data, size_t s) { m_onewire.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } inline void HardwareConfig::set_onewire(const OneWireConfig &v) { m_onewire = v; - p_validbits |= ((uint16_t)1U << 9); + p_validbits |= ((uint16_t)1U << 8); } #endif // CONFIG_ONEWIRE @@ -10725,7 +10997,7 @@ inline const SX1276Config &HardwareConfig::sx1276() const inline bool HardwareConfig::has_sx1276() const { - return 0 != (p_validbits & ((uint16_t)1U << 10)); + return 0 != (p_validbits & ((uint16_t)1U << 9)); } /*! @@ -10734,14 +11006,14 @@ inline bool HardwareConfig::has_sx1276() const */ inline void HardwareConfig::clear_sx1276() { - p_validbits &= ~((uint16_t)1U << 10); + p_validbits &= ~((uint16_t)1U << 9); m_sx1276.clear(); } inline SX1276Config *HardwareConfig::mutable_sx1276() { - if (0 == (p_validbits & ((uint16_t)1U << 10))) { - p_validbits |= ((uint16_t)1U << 10); + if (0 == (p_validbits & ((uint16_t)1U << 9))) { + p_validbits |= ((uint16_t)1U << 9); m_sx1276.clear(); } return &m_sx1276; @@ -10750,13 +11022,13 @@ inline SX1276Config *HardwareConfig::mutable_sx1276() inline void HardwareConfig::set_sx1276(const void *data, size_t s) { m_sx1276.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } inline void HardwareConfig::set_sx1276(const SX1276Config &v) { m_sx1276 = v; - p_validbits |= ((uint16_t)1U << 10); + p_validbits |= ((uint16_t)1U << 9); } #endif // CONFIG_SX1276 @@ -10822,7 +11094,7 @@ inline const DisplayConfig &HardwareConfig::display() const inline bool HardwareConfig::has_display() const { - return 0 != (p_validbits & ((uint16_t)1U << 11)); + return 0 != (p_validbits & ((uint16_t)1U << 10)); } /*! @@ -10831,14 +11103,14 @@ inline bool HardwareConfig::has_display() const */ inline void HardwareConfig::clear_display() { - p_validbits &= ~((uint16_t)1U << 11); + p_validbits &= ~((uint16_t)1U << 10); m_display.clear(); } inline DisplayConfig *HardwareConfig::mutable_display() { - if (0 == (p_validbits & ((uint16_t)1U << 11))) { - p_validbits |= ((uint16_t)1U << 11); + if (0 == (p_validbits & ((uint16_t)1U << 10))) { + p_validbits |= ((uint16_t)1U << 10); m_display.clear(); } return &m_display; @@ -10847,13 +11119,13 @@ inline DisplayConfig *HardwareConfig::mutable_display() inline void HardwareConfig::set_display(const void *data, size_t s) { m_display.fromMemory((const char *)data,s); - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); } inline void HardwareConfig::set_display(const DisplayConfig &v) { m_display = v; - p_validbits |= ((uint16_t)1U << 11); + p_validbits |= ((uint16_t)1U << 10); } #endif // CONFIG_DISPLAY diff --git a/components/wfc/swcfg_esp32.cpp b/components/wfc/swcfg_esp32.cpp index a71886e..48425a8 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -1368,7 +1368,7 @@ int MQTT::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -41; if (m_subscribtions.size() <= x) return -42; @@ -3482,7 +3482,7 @@ int Trigger::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -149; if (m_action.size() <= x) return -150; @@ -4409,7 +4409,7 @@ int FunctionConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -197; if (m_params.size() <= x) return -198; @@ -5138,7 +5138,7 @@ int StateConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+6))) return -234; if (m_conds.size() <= x) return -235; @@ -5451,7 +5451,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -251; if (m_states.size() <= x) return -252; @@ -5968,7 +5968,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+13,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+13))) return -277; if (m_init_scripts.size() <= x) return -278; @@ -5998,7 +5998,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -280; if (m_compile_files.size() <= x) return -281; @@ -6049,6 +6049,7 @@ NodeConfig::NodeConfig() #endif // CONFIG_FTP #ifdef CONFIG_HTTP #endif // CONFIG_HTTP +, m_otasrv() #ifdef CONFIG_SIGNAL_PROC // omitted obsolete member signals #endif // CONFIG_SIGNAL_PROC @@ -6112,6 +6113,7 @@ void NodeConfig::clear() #ifdef CONFIG_HTTP m_httpd.clear(); #endif // CONFIG_HTTP + m_otasrv.clear(); m_timefuses.clear(); #ifdef CONFIG_STATEMACHINES m_statemachs.clear(); @@ -6259,6 +6261,7 @@ void NodeConfig::toASCII(stream &o, size_t indent) const 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(); o << "timefuses[" << s_timefuses << "] = {"; @@ -6708,20 +6711,32 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) p_validbits |= ((uint32_t)1U << 12); break; #endif // CONFIG_HTTP - case 0xf2: // timefuses id 30, type EventTimer, coding byte[] + case 0xd2: // otasrv id 26, type estring, coding byte[] { varint_t v; int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) return -321; + m_otasrv.assign((const char*)a,v); + a += v; + } + p_validbits |= ((uint32_t)1U << 13); + break; + case 0xf2: // timefuses id 30, type EventTimer, coding byte[] + { + varint_t v; + int n = read_varint(a,e-a,&v); + a += n; + if ((n <= 0) || ((a+v) > e)) + return -322; m_timefuses.emplace_back(); if (v != 0) { n = m_timefuses.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -322; + return -323; a += v; } } @@ -6733,14 +6748,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -323; + return -324; m_statemachs.emplace_back(); if (v != 0) { n = m_statemachs.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -324; + return -325; a += v; } } @@ -6751,7 +6766,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -325; + return -326; a += n; set_max_on_time(v); } @@ -6761,7 +6776,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -326; + return -327; a += n; set_threshold_off(v); } @@ -6771,7 +6786,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -327; + return -328; a += n; set_threshold_on(v); } @@ -6781,14 +6796,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -328; + return -329; a += n; set_dim_step(v); } break; case 0x133: // lightctrl id 38, type bool, coding 8bit if (a >= e) - return -329; + return -330; set_lightctrl(*a++); break; case 0x138: // pwm_freq id 39, type uint32_t, coding varint @@ -6796,7 +6811,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -330; + return -331; a += n; set_pwm_freq(v); } @@ -6808,14 +6823,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -331; + return -332; m_app_params.emplace_back(); if (v != 0) { n = m_app_params.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -332; + return -333; a += v; } } @@ -6828,14 +6843,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -333; + return -334; m_thresholds.emplace_back(); if (v != 0) { n = m_thresholds.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -334; + return -335; a += v; } } @@ -6848,7 +6863,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -335; + return -336; m_luafiles.emplace_back((const char*)a,v); a += v; } @@ -6861,14 +6876,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -336; + return -337; m_owdevices.emplace_back(); if (v != 0) { n = m_owdevices.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -337; + return -338; a += v; } } @@ -6879,7 +6894,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -338; + return -339; a += s; break; } @@ -6887,7 +6902,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -339; + return -340; return a-(const uint8_t *)b; } @@ -6900,10 +6915,10 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -340; + return -341; *a++ = 0x5; if ((e-a) < 4) - return -341; + return -342; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -6911,13 +6926,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_nodename.empty()) { // 'nodename': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -342; + return -343; *a++ = 0xa; ssize_t nodename_s = m_nodename.size(); n = write_varint(a,e-a,nodename_s); a += n; if ((n <= 0) || ((e-a) < nodename_s)) - return -343; + return -344; memcpy(a,m_nodename.data(),nodename_s); a += nodename_s; } @@ -6925,13 +6940,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -344; + return -345; *a++ = 0x12; ssize_t pass_hash_s = m_pass_hash.size(); n = write_varint(a,e-a,pass_hash_s); a += n; if ((n <= 0) || ((e-a) < pass_hash_s)) - return -345; + return -346; memcpy(a,m_pass_hash.data(),pass_hash_s); a += pass_hash_s; } @@ -6939,24 +6954,24 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -346; + return -347; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -347; + return -348; a += n; } // has station? if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -348; + return -349; *a++ = 0x22; ssize_t station_ws = m_station.calcSize(); n = write_varint(a,e-a,station_ws); a += n; if ((n <= 0) || (station_ws > (e-a))) - return -349; + return -350; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); @@ -6965,13 +6980,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -350; + return -351; *a++ = 0x2a; ssize_t softap_ws = m_softap.calcSize(); n = write_varint(a,e-a,softap_ws); a += n; if ((n <= 0) || (softap_ws > (e-a))) - return -351; + return -352; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -6979,13 +6994,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_dns_server) { // 'dns_server': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -352; + return -353; *a++ = 0x32; ssize_t dns_server_s = x.size(); n = write_varint(a,e-a,dns_server_s); a += n; if ((n <= 0) || ((e-a) < dns_server_s)) - return -353; + return -354; memcpy(a,x.data(),dns_server_s); a += dns_server_s; } @@ -6993,13 +7008,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_syslog_host.empty()) { // 'syslog_host': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -354; + return -355; *a++ = 0x3a; ssize_t syslog_host_s = m_syslog_host.size(); n = write_varint(a,e-a,syslog_host_s); a += n; if ((n <= 0) || ((e-a) < syslog_host_s)) - return -355; + return -356; memcpy(a,m_syslog_host.data(),syslog_host_s); a += syslog_host_s; } @@ -7007,13 +7022,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_sntp_server.empty()) { // 'sntp_server': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -356; + return -357; *a++ = 0x42; ssize_t sntp_server_s = m_sntp_server.size(); n = write_varint(a,e-a,sntp_server_s); a += n; if ((n <= 0) || ((e-a) < sntp_server_s)) - return -357; + return -358; memcpy(a,m_sntp_server.data(),sntp_server_s); a += sntp_server_s; } @@ -7021,13 +7036,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_timezone.empty()) { // 'timezone': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -358; + return -359; *a++ = 0x4a; ssize_t timezone_s = m_timezone.size(); n = write_varint(a,e-a,timezone_s); a += n; if ((n <= 0) || ((e-a) < timezone_s)) - return -359; + return -360; memcpy(a,m_timezone.data(),timezone_s); a += timezone_s; } @@ -7036,13 +7051,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -360; + return -361; *a++ = 0x52; ssize_t mqtt_ws = m_mqtt.calcSize(); n = write_varint(a,e-a,mqtt_ws); a += n; if ((n <= 0) || (mqtt_ws > (e-a))) - return -361; + return -362; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); @@ -7052,7 +7067,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -362; + return -363; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; @@ -7062,13 +7077,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -363; + return -364; *a++ = 0x62; ssize_t influx_ws = m_influx.calcSize(); n = write_varint(a,e-a,influx_ws); a += n; if ((n <= 0) || (influx_ws > (e-a))) - return -364; + return -365; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); @@ -7078,38 +7093,38 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -365; + return -366; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -366; + return -367; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -367; + return -368; *a++ = 0x7a; ssize_t domainname_s = m_domainname.size(); n = write_varint(a,e-a,domainname_s); a += n; if ((n <= 0) || ((e-a) < domainname_s)) - return -368; + return -369; memcpy(a,m_domainname.data(),domainname_s); a += domainname_s; } for (const auto &x : m_holidays) { // 'holidays': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -369; + return -370; *a++ = 0x82; *a++ = 0x1; ssize_t holidays_ws = x.calcSize(); n = write_varint(a,e-a,holidays_ws); a += n; if ((n <= 0) || (holidays_ws > (e-a))) - return -370; + return -371; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -7117,14 +7132,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_at_actions) { // 'at_actions': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -371; + return -372; *a++ = 0x8a; *a++ = 0x1; ssize_t at_actions_ws = x.calcSize(); n = write_varint(a,e-a,at_actions_ws); a += n; if ((n <= 0) || (at_actions_ws > (e-a))) - return -372; + return -373; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); @@ -7133,25 +7148,25 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -373; + return -374; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -374; + return -375; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -375; + return -376; *a++ = 0x9a; *a++ = 0x1; ssize_t triggers_ws = x.calcSize(); n = write_varint(a,e-a,triggers_ws); a += n; if ((n <= 0) || (triggers_ws > (e-a))) - return -376; + return -377; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -7159,14 +7174,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_uart) { // 'uart': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -377; + return -378; *a++ = 0xa2; *a++ = 0x1; ssize_t uart_ws = x.calcSize(); n = write_varint(a,e-a,uart_ws); a += n; if ((n <= 0) || (uart_ws > (e-a))) - return -378; + return -379; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -7175,14 +7190,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_terminal) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa if (2 > (e-a)) - return -379; + return -380; *a++ = 0xaa; *a++ = 0x1; ssize_t terminal_ws = x.calcSize(); n = write_varint(a,e-a,terminal_ws); a += n; if ((n <= 0) || (terminal_ws > (e-a))) - return -380; + return -381; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); @@ -7192,7 +7207,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -381; + return -382; *a++ = 0xb4; *a++ = 0x1; write_u16(a,m_udp_ctrl_port); @@ -7201,14 +7216,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_debugs) { // 'debugs': id=23, encoding=lenpfx, tag=0xba if (2 > (e-a)) - return -382; + return -383; *a++ = 0xba; *a++ = 0x1; ssize_t debugs_s = x.size(); n = write_varint(a,e-a,debugs_s); a += n; if ((n <= 0) || ((e-a) < debugs_s)) - return -383; + return -384; memcpy(a,x.data(),debugs_s); a += debugs_s; } @@ -7217,14 +7232,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -384; + return -385; *a++ = 0xc2; *a++ = 0x1; ssize_t ftpd_ws = m_ftpd.calcSize(); n = write_varint(a,e-a,ftpd_ws); a += n; if ((n <= 0) || (ftpd_ws > (e-a))) - return -385; + return -386; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -7235,30 +7250,45 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 12))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -386; + return -387; *a++ = 0xca; *a++ = 0x1; ssize_t httpd_ws = m_httpd.calcSize(); n = write_varint(a,e-a,httpd_ws); a += n; if ((n <= 0) || (httpd_ws > (e-a))) - return -387; + return -388; n = m_httpd.toMemory(a,e-a); a += n; assert(n == httpd_ws); } #endif // CONFIG_HTTP + // has otasrv? + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 + if (2 > (e-a)) + return -389; + *a++ = 0xd2; + *a++ = 0x1; + ssize_t otasrv_s = m_otasrv.size(); + n = write_varint(a,e-a,otasrv_s); + a += n; + if ((n <= 0) || ((e-a) < otasrv_s)) + return -390; + memcpy(a,m_otasrv.data(),otasrv_s); + a += otasrv_s; + } for (const auto &x : m_timefuses) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 if (2 > (e-a)) - return -388; + return -391; *a++ = 0xf2; *a++ = 0x1; ssize_t timefuses_ws = x.calcSize(); n = write_varint(a,e-a,timefuses_ws); a += n; if ((n <= 0) || (timefuses_ws > (e-a))) - return -389; + return -392; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -7273,14 +7303,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_statemachs) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -390; + return -393; *a++ = 0x8a; *a++ = 0x2; ssize_t statemachs_ws = x.calcSize(); n = write_varint(a,e-a,statemachs_ws); a += n; if ((n <= 0) || (statemachs_ws > (e-a))) - return -391; + return -394; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); @@ -7288,74 +7318,74 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'threshold_off': id=35, encoding=varint, tag=0x118 if (2 > (e-a)) - return -392; + return -395; *a++ = 0x98; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_off); if (n <= 0) - return -393; + return -396; a += n; } // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'threshold_on': id=36, encoding=varint, tag=0x120 if (2 > (e-a)) - return -394; + return -397; *a++ = 0xa0; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_on); if (n <= 0) - return -395; + return -398; a += n; } // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -396; + return -399; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -397; + return -400; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -398; + return -401; *a++ = 0xb3; *a++ = 0x2; *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -399; + return -402; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -400; + return -403; 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)) - return -401; + return -404; *a++ = 0xc2; *a++ = 0x2; ssize_t app_params_ws = x.calcSize(); n = write_varint(a,e-a,app_params_ws); a += n; if ((n <= 0) || (app_params_ws > (e-a))) - return -402; + return -405; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -7365,14 +7395,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_thresholds) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a if (2 > (e-a)) - return -403; + return -406; *a++ = 0xca; *a++ = 0x2; ssize_t thresholds_ws = x.calcSize(); n = write_varint(a,e-a,thresholds_ws); a += n; if ((n <= 0) || (thresholds_ws > (e-a))) - return -404; + return -407; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -7382,14 +7412,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_luafiles) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 if (2 > (e-a)) - return -405; + return -408; *a++ = 0xd2; *a++ = 0x2; ssize_t luafiles_s = x.size(); n = write_varint(a,e-a,luafiles_s); a += n; if ((n <= 0) || ((e-a) < luafiles_s)) - return -406; + return -409; memcpy(a,x.data(),luafiles_s); a += luafiles_s; } @@ -7398,14 +7428,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_owdevices) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -407; + return -410; *a++ = 0x92; *a++ = 0x3; ssize_t owdevices_ws = x.calcSize(); n = write_varint(a,e-a,owdevices_ws); a += n; if ((n <= 0) || (owdevices_ws > (e-a))) - return -408; + return -411; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -7627,6 +7657,10 @@ void NodeConfig::toJSON(stream &json, unsigned indLvl) const 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()); + } if (size_t s = m_timefuses.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -7929,6 +7963,11 @@ size_t NodeConfig::calcSize() const r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } #endif // CONFIG_HTTP + // optional string otasrv, id 26 + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + size_t otasrv_s = m_otasrv.size(); + r += otasrv_s + wiresize(otasrv_s) + 2 /* tag(otasrv) 0xd0 */; + } // repeated EventTimer timefuses, id 30 // repeated message timefuses for (size_t x = 0, y = m_timefuses.size(); x < y; ++x) { @@ -7953,23 +7992,23 @@ size_t NodeConfig::calcSize() const #endif // CONFIG_STATEMACHINES // deprecated optional unsigned max_on_time, id 34 // optional unsigned threshold_off, id 35 - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { r += wiresize((varint_t)m_threshold_off) + 2 /* tag(threshold_off) 0x118 */; } // optional unsigned threshold_on, id 36 - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { r += wiresize((varint_t)m_threshold_on) + 2 /* tag(threshold_on) 0x120 */; } // optional unsigned dim_step, id 37 - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { r += wiresize((varint_t)m_dim_step) + 2 /* tag(dim_step) 0x128 */; } // optional bool lightctrl, id 38 - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { r += 3; } // optional unsigned pwm_freq, id 39 - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { r += wiresize((varint_t)m_pwm_freq) + 2 /* tag(pwm_freq) 0x138 */; } #ifdef CONFIG_APP_PARAMS @@ -8077,6 +8116,8 @@ bool NodeConfig::operator != (const NodeConfig &r) const 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 @@ -8202,17 +8243,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -409; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -412; if (m_dns_server.size() <= x) - return -410; + return -413; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -411; + return -414; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -8310,17 +8351,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -412; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -415; if (m_holidays.size() <= x) - return -413; + return -416; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -414; + return -417; return m_holidays[x].setByName(idxe+2,value); } } @@ -8339,17 +8380,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -415; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -418; if (m_at_actions.size() <= x) - return -416; + return -419; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -417; + return -420; return m_at_actions[x].setByName(idxe+2,value); } } @@ -8378,17 +8419,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -418; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -421; if (m_triggers.size() <= x) - return -419; + return -422; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -420; + return -423; return m_triggers[x].setByName(idxe+2,value); } } @@ -8407,17 +8448,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -421; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -424; if (m_uart.size() <= x) - return -422; + return -425; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -423; + return -426; return m_uart[x].setByName(idxe+2,value); } } @@ -8437,17 +8478,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -424; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -427; if (m_terminal.size() <= x) - return -425; + return -428; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -426; + return -429; return m_terminal[x].setByName(idxe+2,value); } } @@ -8477,17 +8518,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -427; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -430; if (m_debugs.size() <= x) - return -428; + return -431; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -429; + return -432; m_debugs[x] = value; return m_debugs[x].size(); } @@ -8514,6 +8555,17 @@ int NodeConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_HTTP + if (0 == strcmp(name,"otasrv")) { + if (value == 0) { + clear_otasrv(); + return 0; + } + m_otasrv = value; + int r = m_otasrv.size(); + if (r > 0) + p_validbits |= ((uint32_t)1U << 13); + return r; + } if (0 == memcmp(name,"timefuses",9)) { if ((name[9] == 0) && (value == 0)) { clear_timefuses(); @@ -8529,17 +8581,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -430; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -433; if (m_timefuses.size() <= x) - return -431; + return -434; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -432; + return -435; return m_timefuses[x].setByName(idxe+2,value); } } @@ -8559,17 +8611,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -433; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -436; if (m_statemachs.size() <= x) - return -434; + return -437; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -435; + return -438; return m_statemachs[x].setByName(idxe+2,value); } } @@ -8589,7 +8641,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_threshold_off,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -8599,7 +8651,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_threshold_on,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"dim_step")) { @@ -8609,7 +8661,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_dim_step,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -8619,7 +8671,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_bool(&m_lightctrl,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -8629,7 +8681,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_pwm_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); return r; } #ifdef CONFIG_APP_PARAMS @@ -8648,17 +8700,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -436; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -439; if (m_app_params.size() <= x) - return -437; + return -440; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -438; + return -441; return m_app_params[x].setByName(idxe+2,value); } } @@ -8679,17 +8731,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -439; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -442; if (m_thresholds.size() <= x) - return -440; + return -443; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -441; + return -444; return m_thresholds[x].setByName(idxe+2,value); } } @@ -8710,17 +8762,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -442; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -445; if (m_luafiles.size() <= x) - return -443; + return -446; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -444; + return -447; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -8742,22 +8794,22 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -445; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -448; if (m_owdevices.size() <= x) - return -446; + return -449; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -447; + return -450; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -448; + return -451; } Message *NodeConfig::p_getMember(const char *s, const char *e) diff --git a/components/wfc/swcfg_esp32.h b/components/wfc/swcfg_esp32.h index c33a8f6..2e9d3b9 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -3794,6 +3794,32 @@ class NodeConfig : public Message FtpHttpConfig *mutable_httpd(); #endif // CONFIG_HTTP + // optional string otasrv, id 26 + /*! + * Function for querying if otasrv has been set. + * @return true if otasrv is set. + */ + bool has_otasrv() const; + //! Function to reset otasrv to its default/unset value. + void clear_otasrv(); + //! Get value of otasrv. + const estring &otasrv() const; + /*! + * Function for setting otasrv using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_otasrv(const void *data, size_t s); + //! Set otasrv using a constant reference + void set_otasrv(const estring &v); + //! Set otasrv using a pointer to a null-terminated C-string. + void set_otasrv(const char *); + /*! + * Provide mutable access to otasrv. + * @return pointer to member variable of otasrv. + */ + estring *mutable_otasrv(); + // repeated EventTimer timefuses, id 30 //! Function get const-access to the elements of timefuses. const std::vector &timefuses() const; @@ -4124,6 +4150,8 @@ class NodeConfig : public Message //! FtpHttpConfig httpd, id 25 FtpHttpConfig m_httpd; #endif // CONFIG_HTTP + //! string otasrv, id 26 + estring m_otasrv; //! EventTimer timefuses, id 30 std::vector m_timefuses; #ifdef CONFIG_SIGNAL_PROC @@ -7105,6 +7133,7 @@ inline size_t NodeConfig::getMaxSize() // repeated string debugs, id 23 has unlimited size // optional FtpHttpConfig ftpd, id 24 has maximum size 5 // optional FtpHttpConfig httpd, id 25 has maximum size 5 + // optional string otasrv, id 26 has unlimited size // repeated EventTimer timefuses, id 30 has unlimited size // obsolete repeated SignalConfig signals, id 31 // obsolete repeated FunctionConfig functions, id 32 @@ -8218,6 +8247,55 @@ inline void NodeConfig::set_httpd(const FtpHttpConfig &v) #endif // CONFIG_HTTP +inline const estring &NodeConfig::otasrv() const +{ + return m_otasrv; +} + +inline bool NodeConfig::has_otasrv() const +{ + return 0 != (p_validbits & ((uint32_t)1U << 13)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void NodeConfig::clear_otasrv() +{ + p_validbits &= ~((uint32_t)1U << 13); + m_otasrv.clear(); +} + +inline estring *NodeConfig::mutable_otasrv() +{ + if (0 == (p_validbits & ((uint32_t)1U << 13))) { + p_validbits |= ((uint32_t)1U << 13); + m_otasrv.clear(); + } + return &m_otasrv; +} + +inline void NodeConfig::set_otasrv(const void *data, size_t s) +{ + m_otasrv.assign((const char *)data,s); + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const char *data) +{ + m_otasrv = data; + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const estring &v) +{ + m_otasrv = v; + p_validbits |= ((uint32_t)1U << 13); +} + + + inline const EventTimer &NodeConfig::timefuses(unsigned x) const { return m_timefuses[x]; @@ -8353,7 +8431,7 @@ inline uint32_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8362,14 +8440,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 13); + p_validbits &= ~((uint32_t)1U << 14); m_threshold_off = 0; } inline uint32_t *NodeConfig::mutable_threshold_off() { - if (0 == (p_validbits & ((uint32_t)1U << 13))) { - p_validbits |= ((uint32_t)1U << 13); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_threshold_off = 0; } return &m_threshold_off; @@ -8378,7 +8456,7 @@ inline uint32_t *NodeConfig::mutable_threshold_off() inline void NodeConfig::set_threshold_off(uint32_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); } @@ -8390,7 +8468,7 @@ inline uint32_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8399,14 +8477,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 15); m_threshold_on = 0; } inline uint32_t *NodeConfig::mutable_threshold_on() { - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_threshold_on = 0; } return &m_threshold_on; @@ -8415,7 +8493,7 @@ inline uint32_t *NodeConfig::mutable_threshold_on() inline void NodeConfig::set_threshold_on(uint32_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); } @@ -8427,7 +8505,7 @@ inline uint32_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8436,14 +8514,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 16); m_dim_step = 0; } inline uint32_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_dim_step = 0; } return &m_dim_step; @@ -8452,7 +8530,7 @@ inline uint32_t *NodeConfig::mutable_dim_step() inline void NodeConfig::set_dim_step(uint32_t v) { m_dim_step = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); } @@ -8464,7 +8542,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 17)); } /*! @@ -8473,14 +8551,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 17); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 17))) { + p_validbits |= ((uint32_t)1U << 17); m_lightctrl = 0; } return &m_lightctrl; @@ -8489,7 +8567,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); } @@ -8501,7 +8579,7 @@ inline uint32_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 18)); } /*! @@ -8510,14 +8588,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 18); m_pwm_freq = 0; } inline uint32_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 18))) { + p_validbits |= ((uint32_t)1U << 18); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8526,7 +8604,7 @@ inline uint32_t *NodeConfig::mutable_pwm_freq() inline void NodeConfig::set_pwm_freq(uint32_t v) { m_pwm_freq = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); } diff --git a/components/wfc/swcfg_esp8266.cpp b/components/wfc/swcfg_esp8266.cpp index f84eda0..90d5b7b 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -1283,7 +1283,7 @@ int MQTT::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -36; if (m_subscribtions.size() <= x) return -37; @@ -3132,7 +3132,7 @@ int Trigger::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -124; if (m_action.size() <= x) return -125; @@ -3935,7 +3935,7 @@ int FunctionConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -167; if (m_params.size() <= x) return -168; @@ -4567,7 +4567,7 @@ int StateConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+6))) return -201; if (m_conds.size() <= x) return -202; @@ -4846,7 +4846,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -216; if (m_states.size() <= x) return -217; @@ -5307,7 +5307,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+13,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+13))) return -240; if (m_init_scripts.size() <= x) return -241; @@ -5337,7 +5337,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -243; if (m_compile_files.size() <= x) return -244; @@ -5378,6 +5378,7 @@ NodeConfig::NodeConfig() #endif // CONFIG_FTP #ifdef CONFIG_HTTP #endif // CONFIG_HTTP +, m_otasrv() #ifdef CONFIG_SIGNAL_PROC // omitted obsolete member signals #endif // CONFIG_SIGNAL_PROC @@ -5441,6 +5442,7 @@ void NodeConfig::clear() #ifdef CONFIG_HTTP m_httpd.clear(); #endif // CONFIG_HTTP + m_otasrv.clear(); m_timefuses.clear(); #ifdef CONFIG_STATEMACHINES m_statemachs.clear(); @@ -5588,6 +5590,7 @@ void NodeConfig::toASCII(stream &o, size_t indent) const 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(); o << "timefuses[" << s_timefuses << "] = {"; @@ -5888,13 +5891,21 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) p_validbits |= ((uint32_t)1U << 12); break; #endif // CONFIG_HTTP + case 0xd2: // otasrv id 26, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -267; + } + m_otasrv.assign((const char*)a,ud.vi); + p_validbits |= ((uint32_t)1U << 13); + a += ud.vi; + break; case 0xf2: // timefuses id 30, type EventTimer, coding byte[] m_timefuses.emplace_back(); if (((ssize_t)ud.vi > 0) && ((ssize_t)ud.vi <= (e-a))) { int n; n = m_timefuses.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -267; + return -268; a += ud.vi; } break; @@ -5905,7 +5916,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_statemachs.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -268; + return -269; a += ud.vi; } break; @@ -5935,7 +5946,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_app_params.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -269; + return -270; a += ud.vi; } break; @@ -5947,7 +5958,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_thresholds.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -270; + return -271; a += ud.vi; } break; @@ -5955,7 +5966,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) #ifdef CONFIG_LUA case 0x152: // luafiles id 42, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -271; + return -272; } m_luafiles.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -5968,7 +5979,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_owdevices.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -272; + return -273; a += ud.vi; } break; @@ -5978,13 +5989,13 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -273; + return -274; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -274; + return -275; return a-(const uint8_t *)b; } @@ -5997,10 +6008,10 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -275; + return -276; *a++ = 0x5; if ((e-a) < 4) - return -276; + return -277; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -6008,46 +6019,46 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_nodename.empty()) { // 'nodename': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -277; + return -278; *a++ = 0xa; n = encode_bytes(m_nodename,a,e); if (n < 0) - return -278; + return -279; a += n; } // has pass_hash? if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -279; + return -280; *a++ = 0x12; n = encode_bytes(m_pass_hash,a,e); if (n < 0) - return -280; + return -281; a += n; } // has cpu_freq? if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -281; + return -282; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -282; + return -283; a += n; } // has station? if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -283; + return -284; *a++ = 0x22; ssize_t station_ws = m_station.calcSize(); n = write_varint(a,e-a,station_ws); a += n; if ((n <= 0) || (station_ws > (e-a))) - return -284; + return -285; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); @@ -6056,13 +6067,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -285; + return -286; *a++ = 0x2a; ssize_t softap_ws = m_softap.calcSize(); n = write_varint(a,e-a,softap_ws); a += n; if ((n <= 0) || (softap_ws > (e-a))) - return -286; + return -287; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -6070,44 +6081,44 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_dns_server) { // 'dns_server': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -287; + return -288; *a++ = 0x32; n = encode_bytes(x,a,e); if (n < 0) - return -288; + return -289; a += n; } // has syslog_host? if (!m_syslog_host.empty()) { // 'syslog_host': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -289; + return -290; *a++ = 0x3a; n = encode_bytes(m_syslog_host,a,e); if (n < 0) - return -290; + return -291; a += n; } // has sntp_server? if (!m_sntp_server.empty()) { // 'sntp_server': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -291; + return -292; *a++ = 0x42; n = encode_bytes(m_sntp_server,a,e); if (n < 0) - return -292; + return -293; a += n; } // has timezone? if (!m_timezone.empty()) { // 'timezone': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -293; + return -294; *a++ = 0x4a; n = encode_bytes(m_timezone,a,e); if (n < 0) - return -294; + return -295; a += n; } #ifdef CONFIG_MQTT @@ -6115,13 +6126,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -295; + return -296; *a++ = 0x52; ssize_t mqtt_ws = m_mqtt.calcSize(); n = write_varint(a,e-a,mqtt_ws); a += n; if ((n <= 0) || (mqtt_ws > (e-a))) - return -296; + return -297; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); @@ -6131,7 +6142,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -297; + return -298; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; @@ -6141,13 +6152,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -298; + return -299; *a++ = 0x62; ssize_t influx_ws = m_influx.calcSize(); n = write_varint(a,e-a,influx_ws); a += n; if ((n <= 0) || (influx_ws > (e-a))) - return -299; + return -300; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); @@ -6157,35 +6168,35 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -300; + return -301; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -301; + return -302; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -302; + return -303; *a++ = 0x7a; n = encode_bytes(m_domainname,a,e); if (n < 0) - return -303; + return -304; a += n; } for (const auto &x : m_holidays) { // 'holidays': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -304; + return -305; *a++ = 0x82; *a++ = 0x1; ssize_t holidays_ws = x.calcSize(); n = write_varint(a,e-a,holidays_ws); a += n; if ((n <= 0) || (holidays_ws > (e-a))) - return -305; + return -306; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -6193,14 +6204,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_at_actions) { // 'at_actions': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -306; + return -307; *a++ = 0x8a; *a++ = 0x1; ssize_t at_actions_ws = x.calcSize(); n = write_varint(a,e-a,at_actions_ws); a += n; if ((n <= 0) || (at_actions_ws > (e-a))) - return -307; + return -308; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); @@ -6209,25 +6220,25 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -308; + return -309; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -309; + return -310; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -310; + return -311; *a++ = 0x9a; *a++ = 0x1; ssize_t triggers_ws = x.calcSize(); n = write_varint(a,e-a,triggers_ws); a += n; if ((n <= 0) || (triggers_ws > (e-a))) - return -311; + return -312; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -6235,14 +6246,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_uart) { // 'uart': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -312; + return -313; *a++ = 0xa2; *a++ = 0x1; ssize_t uart_ws = x.calcSize(); n = write_varint(a,e-a,uart_ws); a += n; if ((n <= 0) || (uart_ws > (e-a))) - return -313; + return -314; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -6251,14 +6262,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_terminal) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa if (2 > (e-a)) - return -314; + return -315; *a++ = 0xaa; *a++ = 0x1; ssize_t terminal_ws = x.calcSize(); n = write_varint(a,e-a,terminal_ws); a += n; if ((n <= 0) || (terminal_ws > (e-a))) - return -315; + return -316; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); @@ -6268,7 +6279,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -316; + return -317; a += write_varint(a,e-a,0xb4); // 'udp_ctrl_port': id=22 write_u16(a,m_udp_ctrl_port); a += 2; @@ -6276,12 +6287,12 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_debugs) { // 'debugs': id=23, encoding=lenpfx, tag=0xba if (2 > (e-a)) - return -317; + return -318; *a++ = 0xba; *a++ = 0x1; n = encode_bytes(x,a,e); if (n < 0) - return -318; + return -319; a += n; } #ifdef CONFIG_FTP @@ -6289,14 +6300,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -319; + return -320; *a++ = 0xc2; *a++ = 0x1; ssize_t ftpd_ws = m_ftpd.calcSize(); n = write_varint(a,e-a,ftpd_ws); a += n; if ((n <= 0) || (ftpd_ws > (e-a))) - return -320; + return -321; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -6307,30 +6318,42 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 12))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -321; + return -322; *a++ = 0xca; *a++ = 0x1; ssize_t httpd_ws = m_httpd.calcSize(); n = write_varint(a,e-a,httpd_ws); a += n; if ((n <= 0) || (httpd_ws > (e-a))) - return -322; + return -323; n = m_httpd.toMemory(a,e-a); a += n; assert(n == httpd_ws); } #endif // CONFIG_HTTP + // has otasrv? + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 + if (2 > (e-a)) + return -324; + *a++ = 0xd2; + *a++ = 0x1; + n = encode_bytes(m_otasrv,a,e); + if (n < 0) + return -325; + a += n; + } for (const auto &x : m_timefuses) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 if (2 > (e-a)) - return -323; + return -326; *a++ = 0xf2; *a++ = 0x1; ssize_t timefuses_ws = x.calcSize(); n = write_varint(a,e-a,timefuses_ws); a += n; if ((n <= 0) || (timefuses_ws > (e-a))) - return -324; + return -327; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -6345,14 +6368,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_statemachs) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -325; + return -328; *a++ = 0x8a; *a++ = 0x2; ssize_t statemachs_ws = x.calcSize(); n = write_varint(a,e-a,statemachs_ws); a += n; if ((n <= 0) || (statemachs_ws > (e-a))) - return -326; + return -329; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); @@ -6360,73 +6383,73 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'threshold_off': id=35, encoding=varint, tag=0x118 if (2 > (e-a)) - return -327; + return -330; *a++ = 0x98; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_off); if (n <= 0) - return -328; + return -331; a += n; } // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'threshold_on': id=36, encoding=varint, tag=0x120 if (2 > (e-a)) - return -329; + return -332; *a++ = 0xa0; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_on); if (n <= 0) - return -330; + return -333; a += n; } // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -331; + return -334; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -332; + return -335; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -333; + return -336; a += write_varint(a,e-a,0x133); // 'lightctrl': id=38 *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -334; + return -337; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -335; + return -338; 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)) - return -336; + return -339; *a++ = 0xc2; *a++ = 0x2; ssize_t app_params_ws = x.calcSize(); n = write_varint(a,e-a,app_params_ws); a += n; if ((n <= 0) || (app_params_ws > (e-a))) - return -337; + return -340; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -6436,14 +6459,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_thresholds) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a if (2 > (e-a)) - return -338; + return -341; *a++ = 0xca; *a++ = 0x2; ssize_t thresholds_ws = x.calcSize(); n = write_varint(a,e-a,thresholds_ws); a += n; if ((n <= 0) || (thresholds_ws > (e-a))) - return -339; + return -342; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -6453,12 +6476,12 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_luafiles) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 if (2 > (e-a)) - return -340; + return -343; *a++ = 0xd2; *a++ = 0x2; n = encode_bytes(x,a,e); if (n < 0) - return -341; + return -344; a += n; } #endif // CONFIG_LUA @@ -6466,14 +6489,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_owdevices) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -342; + return -345; *a++ = 0x92; *a++ = 0x3; ssize_t owdevices_ws = x.calcSize(); n = write_varint(a,e-a,owdevices_ws); a += n; if ((n <= 0) || (owdevices_ws > (e-a))) - return -343; + return -346; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -6695,6 +6718,10 @@ void NodeConfig::toJSON(stream &json, unsigned indLvl) const 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()); + } if (size_t s = m_timefuses.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -6997,6 +7024,11 @@ size_t NodeConfig::calcSize() const r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } #endif // CONFIG_HTTP + // optional string otasrv, id 26 + if (has_otasrv()) { + size_t otasrv_s = m_otasrv.size(); + r += otasrv_s + wiresize(otasrv_s) + 2 /* tag(otasrv) 0xd0 */; + } // repeated EventTimer timefuses, id 30 // repeated message timefuses for (size_t x = 0, y = m_timefuses.size(); x < y; ++x) { @@ -7145,6 +7177,8 @@ bool NodeConfig::operator == (const NodeConfig &r) const if (has_httpd() && (!(m_httpd == r.m_httpd))) return false; #endif // CONFIG_HTTP + if (has_otasrv() && (!(m_otasrv == r.m_otasrv))) + return false; if (!(m_timefuses == r.m_timefuses)) return false; #ifdef CONFIG_SIGNAL_PROC @@ -7270,17 +7304,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -344; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -347; if (m_dns_server.size() <= x) - return -345; + return -348; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -346; + return -349; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -7378,17 +7412,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -347; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -350; if (m_holidays.size() <= x) - return -348; + return -351; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -349; + return -352; return m_holidays[x].setByName(idxe+2,value); } } @@ -7407,17 +7441,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -350; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -353; if (m_at_actions.size() <= x) - return -351; + return -354; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -352; + return -355; return m_at_actions[x].setByName(idxe+2,value); } } @@ -7446,17 +7480,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -353; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -356; if (m_triggers.size() <= x) - return -354; + return -357; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -355; + return -358; return m_triggers[x].setByName(idxe+2,value); } } @@ -7475,17 +7509,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -356; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -359; if (m_uart.size() <= x) - return -357; + return -360; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -358; + return -361; return m_uart[x].setByName(idxe+2,value); } } @@ -7505,17 +7539,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -359; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -362; if (m_terminal.size() <= x) - return -360; + return -363; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -361; + return -364; return m_terminal[x].setByName(idxe+2,value); } } @@ -7545,17 +7579,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -362; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -365; if (m_debugs.size() <= x) - return -363; + return -366; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -364; + return -367; m_debugs[x] = value; return m_debugs[x].size(); } @@ -7582,6 +7616,17 @@ int NodeConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_HTTP + if (0 == strcmp(name,"otasrv")) { + if (value == 0) { + clear_otasrv(); + return 0; + } + m_otasrv = value; + int r = m_otasrv.size(); + if (r > 0) + p_validbits |= ((uint32_t)1U << 13); + return r; + } if (0 == memcmp(name,"timefuses",9)) { if ((name[9] == 0) && (value == 0)) { clear_timefuses(); @@ -7597,17 +7642,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -365; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -368; if (m_timefuses.size() <= x) - return -366; + return -369; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -367; + return -370; return m_timefuses[x].setByName(idxe+2,value); } } @@ -7627,17 +7672,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -368; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -371; if (m_statemachs.size() <= x) - return -369; + return -372; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -370; + return -373; return m_statemachs[x].setByName(idxe+2,value); } } @@ -7657,7 +7702,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_threshold_off,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -7667,7 +7712,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_threshold_on,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"dim_step")) { @@ -7677,7 +7722,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_dim_step,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -7687,7 +7732,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_bool(&m_lightctrl,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -7697,7 +7742,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_pwm_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); return r; } #ifdef CONFIG_APP_PARAMS @@ -7716,17 +7761,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -371; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -374; if (m_app_params.size() <= x) - return -372; + return -375; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -373; + return -376; return m_app_params[x].setByName(idxe+2,value); } } @@ -7747,17 +7792,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -374; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -377; if (m_thresholds.size() <= x) - return -375; + return -378; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -376; + return -379; return m_thresholds[x].setByName(idxe+2,value); } } @@ -7778,17 +7823,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -377; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -380; if (m_luafiles.size() <= x) - return -378; + return -381; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -379; + return -382; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -7810,22 +7855,22 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -380; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -383; if (m_owdevices.size() <= x) - return -381; + return -384; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -382; + return -385; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -383; + return -386; } Message *NodeConfig::p_getMember(const char *s, const char *e) diff --git a/components/wfc/swcfg_esp8266.h b/components/wfc/swcfg_esp8266.h index 94601b1..2c1a45f 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -3742,6 +3742,32 @@ class NodeConfig : public Message FtpHttpConfig *mutable_httpd(); #endif // CONFIG_HTTP + // optional string otasrv, id 26 + /*! + * Function for querying if otasrv has been set. + * @return true if otasrv is set. + */ + bool has_otasrv() const; + //! Function to reset otasrv to its default/unset value. + void clear_otasrv(); + //! Get value of otasrv. + const estring &otasrv() const; + /*! + * Function for setting otasrv using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_otasrv(const void *data, size_t s); + //! Set otasrv using a constant reference + void set_otasrv(const estring &v); + //! Set otasrv using a pointer to a null-terminated C-string. + void set_otasrv(const char *); + /*! + * Provide mutable access to otasrv. + * @return pointer to member variable of otasrv. + */ + estring *mutable_otasrv(); + // repeated EventTimer timefuses, id 30 //! Function get const-access to the elements of timefuses. const std::vector &timefuses() const; @@ -4072,6 +4098,8 @@ class NodeConfig : public Message //! FtpHttpConfig httpd, id 25 FtpHttpConfig m_httpd; #endif // CONFIG_HTTP + //! string otasrv, id 26 + estring m_otasrv; //! EventTimer timefuses, id 30 std::vector m_timefuses; #ifdef CONFIG_SIGNAL_PROC @@ -7053,6 +7081,7 @@ inline size_t NodeConfig::getMaxSize() // repeated string debugs, id 23 has unlimited size // optional FtpHttpConfig ftpd, id 24 has maximum size 5 // optional FtpHttpConfig httpd, id 25 has maximum size 5 + // optional string otasrv, id 26 has unlimited size // repeated EventTimer timefuses, id 30 has unlimited size // obsolete repeated SignalConfig signals, id 31 // obsolete repeated FunctionConfig functions, id 32 @@ -8166,6 +8195,55 @@ inline void NodeConfig::set_httpd(const FtpHttpConfig &v) #endif // CONFIG_HTTP +inline const estring &NodeConfig::otasrv() const +{ + return m_otasrv; +} + +inline bool NodeConfig::has_otasrv() const +{ + return 0 != (p_validbits & ((uint32_t)1U << 13)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void NodeConfig::clear_otasrv() +{ + p_validbits &= ~((uint32_t)1U << 13); + m_otasrv.clear(); +} + +inline estring *NodeConfig::mutable_otasrv() +{ + if (0 == (p_validbits & ((uint32_t)1U << 13))) { + p_validbits |= ((uint32_t)1U << 13); + m_otasrv.clear(); + } + return &m_otasrv; +} + +inline void NodeConfig::set_otasrv(const void *data, size_t s) +{ + m_otasrv.assign((const char *)data,s); + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const char *data) +{ + m_otasrv = data; + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const estring &v) +{ + m_otasrv = v; + p_validbits |= ((uint32_t)1U << 13); +} + + + inline const EventTimer &NodeConfig::timefuses(unsigned x) const { return m_timefuses[x]; @@ -8301,7 +8379,7 @@ inline uint32_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8310,14 +8388,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 13); + p_validbits &= ~((uint32_t)1U << 14); m_threshold_off = 0; } inline uint32_t *NodeConfig::mutable_threshold_off() { - if (0 == (p_validbits & ((uint32_t)1U << 13))) { - p_validbits |= ((uint32_t)1U << 13); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_threshold_off = 0; } return &m_threshold_off; @@ -8326,7 +8404,7 @@ inline uint32_t *NodeConfig::mutable_threshold_off() inline void NodeConfig::set_threshold_off(uint32_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); } @@ -8338,7 +8416,7 @@ inline uint32_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8347,14 +8425,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 15); m_threshold_on = 0; } inline uint32_t *NodeConfig::mutable_threshold_on() { - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_threshold_on = 0; } return &m_threshold_on; @@ -8363,7 +8441,7 @@ inline uint32_t *NodeConfig::mutable_threshold_on() inline void NodeConfig::set_threshold_on(uint32_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); } @@ -8375,7 +8453,7 @@ inline uint32_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8384,14 +8462,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 16); m_dim_step = 0; } inline uint32_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_dim_step = 0; } return &m_dim_step; @@ -8400,7 +8478,7 @@ inline uint32_t *NodeConfig::mutable_dim_step() inline void NodeConfig::set_dim_step(uint32_t v) { m_dim_step = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); } @@ -8412,7 +8490,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 17)); } /*! @@ -8421,14 +8499,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 17); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 17))) { + p_validbits |= ((uint32_t)1U << 17); m_lightctrl = 0; } return &m_lightctrl; @@ -8437,7 +8515,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); } @@ -8449,7 +8527,7 @@ inline uint32_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 18)); } /*! @@ -8458,14 +8536,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 18); m_pwm_freq = 0; } inline uint32_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 18))) { + p_validbits |= ((uint32_t)1U << 18); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8474,7 +8552,7 @@ inline uint32_t *NodeConfig::mutable_pwm_freq() inline void NodeConfig::set_pwm_freq(uint32_t v) { m_pwm_freq = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); } diff --git a/components/wfc/swcfg_esp8285.cpp b/components/wfc/swcfg_esp8285.cpp index 1f80058..bb57c5b 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -1285,7 +1285,7 @@ int MQTT::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -36; if (m_subscribtions.size() <= x) return -37; @@ -3134,7 +3134,7 @@ int Trigger::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -124; if (m_action.size() <= x) return -125; @@ -3937,7 +3937,7 @@ int FunctionConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -167; if (m_params.size() <= x) return -168; @@ -4569,7 +4569,7 @@ int StateConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+6))) return -201; if (m_conds.size() <= x) return -202; @@ -4838,7 +4838,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -216; if (m_states.size() <= x) return -217; @@ -5289,7 +5289,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+13,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+13))) return -240; if (m_init_scripts.size() <= x) return -241; @@ -5319,7 +5319,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -243; if (m_compile_files.size() <= x) return -244; @@ -5360,6 +5360,7 @@ NodeConfig::NodeConfig() #endif // CONFIG_FTP #ifdef CONFIG_HTTP #endif // CONFIG_HTTP +, m_otasrv() #ifdef CONFIG_SIGNAL_PROC // omitted obsolete member signals #endif // CONFIG_SIGNAL_PROC @@ -5423,6 +5424,7 @@ void NodeConfig::clear() #ifdef CONFIG_HTTP m_httpd.clear(); #endif // CONFIG_HTTP + m_otasrv.clear(); m_timefuses.clear(); #ifdef CONFIG_STATEMACHINES m_statemachs.clear(); @@ -5570,6 +5572,7 @@ void NodeConfig::toASCII(stream &o, size_t indent) const 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(); o << "timefuses[" << s_timefuses << "] = {"; @@ -5870,13 +5873,21 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) p_validbits |= ((uint32_t)1U << 12); break; #endif // CONFIG_HTTP + case 0xd2: // otasrv id 26, type estring, coding byte[] + if ((ssize_t)ud.vi > e-a) { + return -267; + } + m_otasrv.assign((const char*)a,ud.vi); + p_validbits |= ((uint32_t)1U << 13); + a += ud.vi; + break; case 0xf2: // timefuses id 30, type EventTimer, coding byte[] m_timefuses.emplace_back(); if (((ssize_t)ud.vi > 0) && ((ssize_t)ud.vi <= (e-a))) { int n; n = m_timefuses.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -267; + return -268; a += ud.vi; } break; @@ -5887,7 +5898,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_statemachs.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -268; + return -269; a += ud.vi; } break; @@ -5917,7 +5928,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_app_params.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -269; + return -270; a += ud.vi; } break; @@ -5929,7 +5940,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_thresholds.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -270; + return -271; a += ud.vi; } break; @@ -5937,7 +5948,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) #ifdef CONFIG_LUA case 0x152: // luafiles id 42, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -271; + return -272; } m_luafiles.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -5950,7 +5961,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_owdevices.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -272; + return -273; a += ud.vi; } break; @@ -5960,13 +5971,13 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -273; + return -274; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -274; + return -275; return a-(const uint8_t *)b; } @@ -5979,10 +5990,10 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -275; + return -276; *a++ = 0x5; if ((e-a) < 4) - return -276; + return -277; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -5990,46 +6001,46 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_nodename.empty()) { // 'nodename': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -277; + return -278; *a++ = 0xa; n = encode_bytes(m_nodename,a,e); if (n < 0) - return -278; + return -279; a += n; } // has pass_hash? if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -279; + return -280; *a++ = 0x12; n = encode_bytes(m_pass_hash,a,e); if (n < 0) - return -280; + return -281; a += n; } // has cpu_freq? if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -281; + return -282; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -282; + return -283; a += n; } // has station? if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -283; + return -284; *a++ = 0x22; ssize_t station_ws = m_station.calcSize(); n = write_varint(a,e-a,station_ws); a += n; if ((n <= 0) || (station_ws > (e-a))) - return -284; + return -285; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); @@ -6038,13 +6049,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -285; + return -286; *a++ = 0x2a; ssize_t softap_ws = m_softap.calcSize(); n = write_varint(a,e-a,softap_ws); a += n; if ((n <= 0) || (softap_ws > (e-a))) - return -286; + return -287; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -6052,44 +6063,44 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_dns_server) { // 'dns_server': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -287; + return -288; *a++ = 0x32; n = encode_bytes(x,a,e); if (n < 0) - return -288; + return -289; a += n; } // has syslog_host? if (!m_syslog_host.empty()) { // 'syslog_host': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -289; + return -290; *a++ = 0x3a; n = encode_bytes(m_syslog_host,a,e); if (n < 0) - return -290; + return -291; a += n; } // has sntp_server? if (!m_sntp_server.empty()) { // 'sntp_server': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -291; + return -292; *a++ = 0x42; n = encode_bytes(m_sntp_server,a,e); if (n < 0) - return -292; + return -293; a += n; } // has timezone? if (!m_timezone.empty()) { // 'timezone': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -293; + return -294; *a++ = 0x4a; n = encode_bytes(m_timezone,a,e); if (n < 0) - return -294; + return -295; a += n; } #ifdef CONFIG_MQTT @@ -6097,13 +6108,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -295; + return -296; *a++ = 0x52; ssize_t mqtt_ws = m_mqtt.calcSize(); n = write_varint(a,e-a,mqtt_ws); a += n; if ((n <= 0) || (mqtt_ws > (e-a))) - return -296; + return -297; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); @@ -6113,7 +6124,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -297; + return -298; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; @@ -6123,13 +6134,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -298; + return -299; *a++ = 0x62; ssize_t influx_ws = m_influx.calcSize(); n = write_varint(a,e-a,influx_ws); a += n; if ((n <= 0) || (influx_ws > (e-a))) - return -299; + return -300; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); @@ -6139,35 +6150,35 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -300; + return -301; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -301; + return -302; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -302; + return -303; *a++ = 0x7a; n = encode_bytes(m_domainname,a,e); if (n < 0) - return -303; + return -304; a += n; } for (const auto &x : m_holidays) { // 'holidays': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -304; + return -305; *a++ = 0x82; *a++ = 0x1; ssize_t holidays_ws = x.calcSize(); n = write_varint(a,e-a,holidays_ws); a += n; if ((n <= 0) || (holidays_ws > (e-a))) - return -305; + return -306; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -6175,14 +6186,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_at_actions) { // 'at_actions': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -306; + return -307; *a++ = 0x8a; *a++ = 0x1; ssize_t at_actions_ws = x.calcSize(); n = write_varint(a,e-a,at_actions_ws); a += n; if ((n <= 0) || (at_actions_ws > (e-a))) - return -307; + return -308; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); @@ -6191,25 +6202,25 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -308; + return -309; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -309; + return -310; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -310; + return -311; *a++ = 0x9a; *a++ = 0x1; ssize_t triggers_ws = x.calcSize(); n = write_varint(a,e-a,triggers_ws); a += n; if ((n <= 0) || (triggers_ws > (e-a))) - return -311; + return -312; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -6217,14 +6228,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_uart) { // 'uart': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -312; + return -313; *a++ = 0xa2; *a++ = 0x1; ssize_t uart_ws = x.calcSize(); n = write_varint(a,e-a,uart_ws); a += n; if ((n <= 0) || (uart_ws > (e-a))) - return -313; + return -314; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -6233,14 +6244,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_terminal) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa if (2 > (e-a)) - return -314; + return -315; *a++ = 0xaa; *a++ = 0x1; ssize_t terminal_ws = x.calcSize(); n = write_varint(a,e-a,terminal_ws); a += n; if ((n <= 0) || (terminal_ws > (e-a))) - return -315; + return -316; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); @@ -6250,7 +6261,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -316; + return -317; a += write_varint(a,e-a,0xb4); // 'udp_ctrl_port': id=22 write_u16(a,m_udp_ctrl_port); a += 2; @@ -6258,12 +6269,12 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_debugs) { // 'debugs': id=23, encoding=lenpfx, tag=0xba if (2 > (e-a)) - return -317; + return -318; *a++ = 0xba; *a++ = 0x1; n = encode_bytes(x,a,e); if (n < 0) - return -318; + return -319; a += n; } #ifdef CONFIG_FTP @@ -6271,14 +6282,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -319; + return -320; *a++ = 0xc2; *a++ = 0x1; ssize_t ftpd_ws = m_ftpd.calcSize(); n = write_varint(a,e-a,ftpd_ws); a += n; if ((n <= 0) || (ftpd_ws > (e-a))) - return -320; + return -321; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -6289,30 +6300,42 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 12))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -321; + return -322; *a++ = 0xca; *a++ = 0x1; ssize_t httpd_ws = m_httpd.calcSize(); n = write_varint(a,e-a,httpd_ws); a += n; if ((n <= 0) || (httpd_ws > (e-a))) - return -322; + return -323; n = m_httpd.toMemory(a,e-a); a += n; assert(n == httpd_ws); } #endif // CONFIG_HTTP + // has otasrv? + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 + if (2 > (e-a)) + return -324; + *a++ = 0xd2; + *a++ = 0x1; + n = encode_bytes(m_otasrv,a,e); + if (n < 0) + return -325; + a += n; + } for (const auto &x : m_timefuses) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 if (2 > (e-a)) - return -323; + return -326; *a++ = 0xf2; *a++ = 0x1; ssize_t timefuses_ws = x.calcSize(); n = write_varint(a,e-a,timefuses_ws); a += n; if ((n <= 0) || (timefuses_ws > (e-a))) - return -324; + return -327; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -6327,14 +6350,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_statemachs) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -325; + return -328; *a++ = 0x8a; *a++ = 0x2; ssize_t statemachs_ws = x.calcSize(); n = write_varint(a,e-a,statemachs_ws); a += n; if ((n <= 0) || (statemachs_ws > (e-a))) - return -326; + return -329; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); @@ -6342,73 +6365,73 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'threshold_off': id=35, encoding=varint, tag=0x118 if (2 > (e-a)) - return -327; + return -330; *a++ = 0x98; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_off); if (n <= 0) - return -328; + return -331; a += n; } // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'threshold_on': id=36, encoding=varint, tag=0x120 if (2 > (e-a)) - return -329; + return -332; *a++ = 0xa0; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_on); if (n <= 0) - return -330; + return -333; a += n; } // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -331; + return -334; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -332; + return -335; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -333; + return -336; a += write_varint(a,e-a,0x133); // 'lightctrl': id=38 *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -334; + return -337; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -335; + return -338; 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)) - return -336; + return -339; *a++ = 0xc2; *a++ = 0x2; ssize_t app_params_ws = x.calcSize(); n = write_varint(a,e-a,app_params_ws); a += n; if ((n <= 0) || (app_params_ws > (e-a))) - return -337; + return -340; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -6418,14 +6441,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_thresholds) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a if (2 > (e-a)) - return -338; + return -341; *a++ = 0xca; *a++ = 0x2; ssize_t thresholds_ws = x.calcSize(); n = write_varint(a,e-a,thresholds_ws); a += n; if ((n <= 0) || (thresholds_ws > (e-a))) - return -339; + return -342; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -6435,12 +6458,12 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_luafiles) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 if (2 > (e-a)) - return -340; + return -343; *a++ = 0xd2; *a++ = 0x2; n = encode_bytes(x,a,e); if (n < 0) - return -341; + return -344; a += n; } #endif // CONFIG_LUA @@ -6448,14 +6471,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_owdevices) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -342; + return -345; *a++ = 0x92; *a++ = 0x3; ssize_t owdevices_ws = x.calcSize(); n = write_varint(a,e-a,owdevices_ws); a += n; if ((n <= 0) || (owdevices_ws > (e-a))) - return -343; + return -346; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -6677,6 +6700,10 @@ void NodeConfig::toJSON(stream &json, unsigned indLvl) const 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()); + } if (size_t s = m_timefuses.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -6979,6 +7006,11 @@ size_t NodeConfig::calcSize() const r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } #endif // CONFIG_HTTP + // optional string otasrv, id 26 + if (has_otasrv()) { + size_t otasrv_s = m_otasrv.size(); + r += otasrv_s + wiresize(otasrv_s) + 2 /* tag(otasrv) 0xd0 */; + } // repeated EventTimer timefuses, id 30 // repeated message timefuses for (size_t x = 0, y = m_timefuses.size(); x < y; ++x) { @@ -7127,6 +7159,8 @@ bool NodeConfig::operator == (const NodeConfig &r) const if (has_httpd() && (!(m_httpd == r.m_httpd))) return false; #endif // CONFIG_HTTP + if (has_otasrv() && (!(m_otasrv == r.m_otasrv))) + return false; if (!(m_timefuses == r.m_timefuses)) return false; #ifdef CONFIG_SIGNAL_PROC @@ -7252,17 +7286,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -344; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -347; if (m_dns_server.size() <= x) - return -345; + return -348; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -346; + return -349; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -7360,17 +7394,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -347; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -350; if (m_holidays.size() <= x) - return -348; + return -351; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -349; + return -352; return m_holidays[x].setByName(idxe+2,value); } } @@ -7389,17 +7423,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -350; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -353; if (m_at_actions.size() <= x) - return -351; + return -354; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -352; + return -355; return m_at_actions[x].setByName(idxe+2,value); } } @@ -7428,17 +7462,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -353; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -356; if (m_triggers.size() <= x) - return -354; + return -357; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -355; + return -358; return m_triggers[x].setByName(idxe+2,value); } } @@ -7457,17 +7491,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -356; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -359; if (m_uart.size() <= x) - return -357; + return -360; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -358; + return -361; return m_uart[x].setByName(idxe+2,value); } } @@ -7487,17 +7521,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -359; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -362; if (m_terminal.size() <= x) - return -360; + return -363; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -361; + return -364; return m_terminal[x].setByName(idxe+2,value); } } @@ -7527,17 +7561,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -362; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -365; if (m_debugs.size() <= x) - return -363; + return -366; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -364; + return -367; m_debugs[x] = value; return m_debugs[x].size(); } @@ -7564,6 +7598,17 @@ int NodeConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_HTTP + if (0 == strcmp(name,"otasrv")) { + if (value == 0) { + clear_otasrv(); + return 0; + } + m_otasrv = value; + int r = m_otasrv.size(); + if (r > 0) + p_validbits |= ((uint32_t)1U << 13); + return r; + } if (0 == memcmp(name,"timefuses",9)) { if ((name[9] == 0) && (value == 0)) { clear_timefuses(); @@ -7579,17 +7624,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -365; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -368; if (m_timefuses.size() <= x) - return -366; + return -369; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -367; + return -370; return m_timefuses[x].setByName(idxe+2,value); } } @@ -7609,17 +7654,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -368; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -371; if (m_statemachs.size() <= x) - return -369; + return -372; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -370; + return -373; return m_statemachs[x].setByName(idxe+2,value); } } @@ -7639,7 +7684,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_threshold_off,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -7649,7 +7694,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_threshold_on,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"dim_step")) { @@ -7659,7 +7704,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_dim_step,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -7669,7 +7714,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_bool(&m_lightctrl,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -7679,7 +7724,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_pwm_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); return r; } #ifdef CONFIG_APP_PARAMS @@ -7698,17 +7743,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -371; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -374; if (m_app_params.size() <= x) - return -372; + return -375; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -373; + return -376; return m_app_params[x].setByName(idxe+2,value); } } @@ -7729,17 +7774,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -374; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -377; if (m_thresholds.size() <= x) - return -375; + return -378; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -376; + return -379; return m_thresholds[x].setByName(idxe+2,value); } } @@ -7760,17 +7805,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -377; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -380; if (m_luafiles.size() <= x) - return -378; + return -381; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -379; + return -382; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -7792,21 +7837,21 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -380; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -383; if (m_owdevices.size() <= x) - return -381; + return -384; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -382; + return -385; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -383; + return -386; } diff --git a/components/wfc/swcfg_esp8285.h b/components/wfc/swcfg_esp8285.h index 17a7e6e..2564121 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -3741,6 +3741,32 @@ class NodeConfig FtpHttpConfig *mutable_httpd(); #endif // CONFIG_HTTP + // optional string otasrv, id 26 + /*! + * Function for querying if otasrv has been set. + * @return true if otasrv is set. + */ + bool has_otasrv() const; + //! Function to reset otasrv to its default/unset value. + void clear_otasrv(); + //! Get value of otasrv. + const estring &otasrv() const; + /*! + * Function for setting otasrv using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_otasrv(const void *data, size_t s); + //! Set otasrv using a constant reference + void set_otasrv(const estring &v); + //! Set otasrv using a pointer to a null-terminated C-string. + void set_otasrv(const char *); + /*! + * Provide mutable access to otasrv. + * @return pointer to member variable of otasrv. + */ + estring *mutable_otasrv(); + // repeated EventTimer timefuses, id 30 //! Function get const-access to the elements of timefuses. const std::vector &timefuses() const; @@ -4069,6 +4095,8 @@ class NodeConfig //! FtpHttpConfig httpd, id 25 FtpHttpConfig m_httpd; #endif // CONFIG_HTTP + //! string otasrv, id 26 + estring m_otasrv; //! EventTimer timefuses, id 30 std::vector m_timefuses; #ifdef CONFIG_SIGNAL_PROC @@ -7050,6 +7078,7 @@ inline size_t NodeConfig::getMaxSize() // repeated string debugs, id 23 has unlimited size // optional FtpHttpConfig ftpd, id 24 has maximum size 5 // optional FtpHttpConfig httpd, id 25 has maximum size 5 + // optional string otasrv, id 26 has unlimited size // repeated EventTimer timefuses, id 30 has unlimited size // obsolete repeated SignalConfig signals, id 31 // obsolete repeated FunctionConfig functions, id 32 @@ -8163,6 +8192,55 @@ inline void NodeConfig::set_httpd(const FtpHttpConfig &v) #endif // CONFIG_HTTP +inline const estring &NodeConfig::otasrv() const +{ + return m_otasrv; +} + +inline bool NodeConfig::has_otasrv() const +{ + return 0 != (p_validbits & ((uint32_t)1U << 13)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void NodeConfig::clear_otasrv() +{ + p_validbits &= ~((uint32_t)1U << 13); + m_otasrv.clear(); +} + +inline estring *NodeConfig::mutable_otasrv() +{ + if (0 == (p_validbits & ((uint32_t)1U << 13))) { + p_validbits |= ((uint32_t)1U << 13); + m_otasrv.clear(); + } + return &m_otasrv; +} + +inline void NodeConfig::set_otasrv(const void *data, size_t s) +{ + m_otasrv.assign((const char *)data,s); + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const char *data) +{ + m_otasrv = data; + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const estring &v) +{ + m_otasrv = v; + p_validbits |= ((uint32_t)1U << 13); +} + + + inline const EventTimer &NodeConfig::timefuses(unsigned x) const { return m_timefuses[x]; @@ -8298,7 +8376,7 @@ inline uint32_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8307,14 +8385,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 13); + p_validbits &= ~((uint32_t)1U << 14); m_threshold_off = 0; } inline uint32_t *NodeConfig::mutable_threshold_off() { - if (0 == (p_validbits & ((uint32_t)1U << 13))) { - p_validbits |= ((uint32_t)1U << 13); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_threshold_off = 0; } return &m_threshold_off; @@ -8323,7 +8401,7 @@ inline uint32_t *NodeConfig::mutable_threshold_off() inline void NodeConfig::set_threshold_off(uint32_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); } @@ -8335,7 +8413,7 @@ inline uint32_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8344,14 +8422,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 15); m_threshold_on = 0; } inline uint32_t *NodeConfig::mutable_threshold_on() { - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_threshold_on = 0; } return &m_threshold_on; @@ -8360,7 +8438,7 @@ inline uint32_t *NodeConfig::mutable_threshold_on() inline void NodeConfig::set_threshold_on(uint32_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); } @@ -8372,7 +8450,7 @@ inline uint32_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8381,14 +8459,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 16); m_dim_step = 0; } inline uint32_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_dim_step = 0; } return &m_dim_step; @@ -8397,7 +8475,7 @@ inline uint32_t *NodeConfig::mutable_dim_step() inline void NodeConfig::set_dim_step(uint32_t v) { m_dim_step = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); } @@ -8409,7 +8487,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 17)); } /*! @@ -8418,14 +8496,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 17); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 17))) { + p_validbits |= ((uint32_t)1U << 17); m_lightctrl = 0; } return &m_lightctrl; @@ -8434,7 +8512,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); } @@ -8446,7 +8524,7 @@ inline uint32_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 18)); } /*! @@ -8455,14 +8533,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 18); m_pwm_freq = 0; } inline uint32_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 18))) { + p_validbits |= ((uint32_t)1U << 18); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8471,7 +8549,7 @@ inline uint32_t *NodeConfig::mutable_pwm_freq() inline void NodeConfig::set_pwm_freq(uint32_t v) { m_pwm_freq = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); } diff --git a/components/wfc/swcfg_pc.cpp b/components/wfc/swcfg_pc.cpp index 3b4d1aa..7f31aba 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -1277,7 +1277,7 @@ int MQTT::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -41; if (m_subscribtions.size() <= x) return -42; @@ -3732,7 +3732,7 @@ int Trigger::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -149; if (m_action.size() <= x) return -150; @@ -4802,7 +4802,7 @@ int FunctionConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -197; if (m_params.size() <= x) return -198; @@ -5643,7 +5643,7 @@ int StateConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+6,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+6))) return -234; if (m_conds.size() <= x) return -235; @@ -6000,7 +6000,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+7))) return -251; if (m_states.size() <= x) return -252; @@ -6595,7 +6595,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+13,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+13))) return -277; if (m_init_scripts.size() <= x) return -278; @@ -6625,7 +6625,7 @@ int LuaConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+14,&idxe,0); - if (idxe[0] != ']') + if ((idxe[0] != ']') || (idxe == (name+14))) return -280; if (m_compile_files.size() <= x) return -281; @@ -6676,6 +6676,7 @@ NodeConfig::NodeConfig() #endif // CONFIG_FTP #ifdef CONFIG_HTTP #endif // CONFIG_HTTP +, m_otasrv() #ifdef CONFIG_SIGNAL_PROC // omitted obsolete member signals #endif // CONFIG_SIGNAL_PROC @@ -6739,6 +6740,7 @@ void NodeConfig::clear() #ifdef CONFIG_HTTP m_httpd.clear(); #endif // CONFIG_HTTP + m_otasrv.clear(); m_timefuses.clear(); #ifdef CONFIG_STATEMACHINES m_statemachs.clear(); @@ -6886,6 +6888,7 @@ void NodeConfig::toASCII(std::ostream &o, size_t indent) const 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(); o << "timefuses[" << s_timefuses << "] = {"; @@ -7335,20 +7338,32 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) p_validbits |= ((uint32_t)1U << 12); break; #endif // CONFIG_HTTP - case 0xf2: // timefuses id 30, type EventTimer, coding byte[] + case 0xd2: // otasrv id 26, 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 -321; + m_otasrv.assign((const char*)a,v); + a += v; + } + p_validbits |= ((uint32_t)1U << 13); + break; + case 0xf2: // timefuses id 30, type EventTimer, coding byte[] + { + varint_t v; + int n = read_varint(a,e-a,&v); + a += n; + if ((n <= 0) || ((a+v) > e)) + return -322; m_timefuses.emplace_back(); if (v != 0) { n = m_timefuses.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -322; + return -323; a += v; } } @@ -7360,14 +7375,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -323; + return -324; m_statemachs.emplace_back(); if (v != 0) { n = m_statemachs.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -324; + return -325; a += v; } } @@ -7378,7 +7393,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -325; + return -326; a += n; set_max_on_time(v); } @@ -7388,7 +7403,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -326; + return -327; a += n; set_threshold_off(v); } @@ -7398,7 +7413,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -327; + return -328; a += n; set_threshold_on(v); } @@ -7408,14 +7423,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -328; + return -329; a += n; set_dim_step(v); } break; case 0x133: // lightctrl id 38, type bool, coding 8bit if (a >= e) - return -329; + return -330; set_lightctrl(*a++); break; case 0x138: // pwm_freq id 39, type uint64_t, coding varint @@ -7423,7 +7438,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -330; + return -331; a += n; set_pwm_freq(v); } @@ -7435,14 +7450,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -331; + return -332; m_app_params.emplace_back(); if (v != 0) { n = m_app_params.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -332; + return -333; a += v; } } @@ -7455,14 +7470,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -333; + return -334; m_thresholds.emplace_back(); if (v != 0) { n = m_thresholds.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -334; + return -335; a += v; } } @@ -7475,7 +7490,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -335; + return -336; m_luafiles.emplace_back((const char*)a,v); a += v; } @@ -7488,14 +7503,14 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -336; + return -337; m_owdevices.emplace_back(); if (v != 0) { n = m_owdevices.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -337; + return -338; a += v; } } @@ -7506,7 +7521,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -338; + return -339; a += s; break; } @@ -7514,7 +7529,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -339; + return -340; return a-(const uint8_t *)b; } @@ -7527,10 +7542,10 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 0))) { // 'magic': id=0, encoding=32bit, tag=0x5 if (5 > (e-a)) - return -340; + return -341; *a++ = 0x5; if ((e-a) < 4) - return -341; + return -342; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -7538,13 +7553,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_nodename.empty()) { // 'nodename': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -342; + return -343; *a++ = 0xa; ssize_t nodename_s = m_nodename.size(); n = write_varint(a,e-a,nodename_s); a += n; if ((n <= 0) || ((e-a) < nodename_s)) - return -343; + return -344; memcpy(a,m_nodename.data(),nodename_s); a += nodename_s; } @@ -7552,13 +7567,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -344; + return -345; *a++ = 0x12; ssize_t pass_hash_s = m_pass_hash.size(); n = write_varint(a,e-a,pass_hash_s); a += n; if ((n <= 0) || ((e-a) < pass_hash_s)) - return -345; + return -346; memcpy(a,m_pass_hash.data(),pass_hash_s); a += pass_hash_s; } @@ -7566,24 +7581,24 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -346; + return -347; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -347; + return -348; a += n; } // has station? if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -348; + return -349; *a++ = 0x22; ssize_t station_ws = m_station.calcSize(); n = write_varint(a,e-a,station_ws); a += n; if ((n <= 0) || (station_ws > (e-a))) - return -349; + return -350; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); @@ -7592,13 +7607,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -350; + return -351; *a++ = 0x2a; ssize_t softap_ws = m_softap.calcSize(); n = write_varint(a,e-a,softap_ws); a += n; if ((n <= 0) || (softap_ws > (e-a))) - return -351; + return -352; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -7606,13 +7621,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_dns_server) { // 'dns_server': id=6, encoding=lenpfx, tag=0x32 if (a >= e) - return -352; + return -353; *a++ = 0x32; ssize_t dns_server_s = x.size(); n = write_varint(a,e-a,dns_server_s); a += n; if ((n <= 0) || ((e-a) < dns_server_s)) - return -353; + return -354; memcpy(a,x.data(),dns_server_s); a += dns_server_s; } @@ -7620,13 +7635,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_syslog_host.empty()) { // 'syslog_host': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -354; + return -355; *a++ = 0x3a; ssize_t syslog_host_s = m_syslog_host.size(); n = write_varint(a,e-a,syslog_host_s); a += n; if ((n <= 0) || ((e-a) < syslog_host_s)) - return -355; + return -356; memcpy(a,m_syslog_host.data(),syslog_host_s); a += syslog_host_s; } @@ -7634,13 +7649,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_sntp_server.empty()) { // 'sntp_server': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -356; + return -357; *a++ = 0x42; ssize_t sntp_server_s = m_sntp_server.size(); n = write_varint(a,e-a,sntp_server_s); a += n; if ((n <= 0) || ((e-a) < sntp_server_s)) - return -357; + return -358; memcpy(a,m_sntp_server.data(),sntp_server_s); a += sntp_server_s; } @@ -7648,13 +7663,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_timezone.empty()) { // 'timezone': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -358; + return -359; *a++ = 0x4a; ssize_t timezone_s = m_timezone.size(); n = write_varint(a,e-a,timezone_s); a += n; if ((n <= 0) || ((e-a) < timezone_s)) - return -359; + return -360; memcpy(a,m_timezone.data(),timezone_s); a += timezone_s; } @@ -7663,13 +7678,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -360; + return -361; *a++ = 0x52; ssize_t mqtt_ws = m_mqtt.calcSize(); n = write_varint(a,e-a,mqtt_ws); a += n; if ((n <= 0) || (mqtt_ws > (e-a))) - return -361; + return -362; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); @@ -7679,7 +7694,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -362; + return -363; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; @@ -7689,13 +7704,13 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -363; + return -364; *a++ = 0x62; ssize_t influx_ws = m_influx.calcSize(); n = write_varint(a,e-a,influx_ws); a += n; if ((n <= 0) || (influx_ws > (e-a))) - return -364; + return -365; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); @@ -7705,38 +7720,38 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -365; + return -366; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -366; + return -367; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -367; + return -368; *a++ = 0x7a; ssize_t domainname_s = m_domainname.size(); n = write_varint(a,e-a,domainname_s); a += n; if ((n <= 0) || ((e-a) < domainname_s)) - return -368; + return -369; memcpy(a,m_domainname.data(),domainname_s); a += domainname_s; } for (const auto &x : m_holidays) { // 'holidays': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -369; + return -370; *a++ = 0x82; *a++ = 0x1; ssize_t holidays_ws = x.calcSize(); n = write_varint(a,e-a,holidays_ws); a += n; if ((n <= 0) || (holidays_ws > (e-a))) - return -370; + return -371; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -7744,14 +7759,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_at_actions) { // 'at_actions': id=17, encoding=lenpfx, tag=0x8a if (2 > (e-a)) - return -371; + return -372; *a++ = 0x8a; *a++ = 0x1; ssize_t at_actions_ws = x.calcSize(); n = write_varint(a,e-a,at_actions_ws); a += n; if ((n <= 0) || (at_actions_ws > (e-a))) - return -372; + return -373; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); @@ -7760,25 +7775,25 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -373; + return -374; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -374; + return -375; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -375; + return -376; *a++ = 0x9a; *a++ = 0x1; ssize_t triggers_ws = x.calcSize(); n = write_varint(a,e-a,triggers_ws); a += n; if ((n <= 0) || (triggers_ws > (e-a))) - return -376; + return -377; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -7786,14 +7801,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_uart) { // 'uart': id=20, encoding=lenpfx, tag=0xa2 if (2 > (e-a)) - return -377; + return -378; *a++ = 0xa2; *a++ = 0x1; ssize_t uart_ws = x.calcSize(); n = write_varint(a,e-a,uart_ws); a += n; if ((n <= 0) || (uart_ws > (e-a))) - return -378; + return -379; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -7802,14 +7817,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_terminal) { // 'terminal': id=21, encoding=lenpfx, tag=0xaa if (2 > (e-a)) - return -379; + return -380; *a++ = 0xaa; *a++ = 0x1; ssize_t terminal_ws = x.calcSize(); n = write_varint(a,e-a,terminal_ws); a += n; if ((n <= 0) || (terminal_ws > (e-a))) - return -380; + return -381; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); @@ -7819,7 +7834,7 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -381; + return -382; *a++ = 0xb4; *a++ = 0x1; write_u16(a,m_udp_ctrl_port); @@ -7828,14 +7843,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_debugs) { // 'debugs': id=23, encoding=lenpfx, tag=0xba if (2 > (e-a)) - return -382; + return -383; *a++ = 0xba; *a++ = 0x1; ssize_t debugs_s = x.size(); n = write_varint(a,e-a,debugs_s); a += n; if ((n <= 0) || ((e-a) < debugs_s)) - return -383; + return -384; memcpy(a,x.data(),debugs_s); a += debugs_s; } @@ -7844,14 +7859,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -384; + return -385; *a++ = 0xc2; *a++ = 0x1; ssize_t ftpd_ws = m_ftpd.calcSize(); n = write_varint(a,e-a,ftpd_ws); a += n; if ((n <= 0) || (ftpd_ws > (e-a))) - return -385; + return -386; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -7862,30 +7877,45 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint32_t)1U << 12))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -386; + return -387; *a++ = 0xca; *a++ = 0x1; ssize_t httpd_ws = m_httpd.calcSize(); n = write_varint(a,e-a,httpd_ws); a += n; if ((n <= 0) || (httpd_ws > (e-a))) - return -387; + return -388; n = m_httpd.toMemory(a,e-a); a += n; assert(n == httpd_ws); } #endif // CONFIG_HTTP + // has otasrv? + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 + if (2 > (e-a)) + return -389; + *a++ = 0xd2; + *a++ = 0x1; + ssize_t otasrv_s = m_otasrv.size(); + n = write_varint(a,e-a,otasrv_s); + a += n; + if ((n <= 0) || ((e-a) < otasrv_s)) + return -390; + memcpy(a,m_otasrv.data(),otasrv_s); + a += otasrv_s; + } for (const auto &x : m_timefuses) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 if (2 > (e-a)) - return -388; + return -391; *a++ = 0xf2; *a++ = 0x1; ssize_t timefuses_ws = x.calcSize(); n = write_varint(a,e-a,timefuses_ws); a += n; if ((n <= 0) || (timefuses_ws > (e-a))) - return -389; + return -392; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -7900,14 +7930,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_statemachs) { // 'statemachs': id=33, encoding=lenpfx, tag=0x10a if (2 > (e-a)) - return -390; + return -393; *a++ = 0x8a; *a++ = 0x2; ssize_t statemachs_ws = x.calcSize(); n = write_varint(a,e-a,statemachs_ws); a += n; if ((n <= 0) || (statemachs_ws > (e-a))) - return -391; + return -394; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); @@ -7915,74 +7945,74 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'threshold_off': id=35, encoding=varint, tag=0x118 if (2 > (e-a)) - return -392; + return -395; *a++ = 0x98; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_off); if (n <= 0) - return -393; + return -396; a += n; } // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'threshold_on': id=36, encoding=varint, tag=0x120 if (2 > (e-a)) - return -394; + return -397; *a++ = 0xa0; *a++ = 0x2; n = write_varint(a,e-a,m_threshold_on); if (n <= 0) - return -395; + return -398; a += n; } // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -396; + return -399; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -397; + return -400; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -398; + return -401; *a++ = 0xb3; *a++ = 0x2; *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -399; + return -402; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -400; + return -403; 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)) - return -401; + return -404; *a++ = 0xc2; *a++ = 0x2; ssize_t app_params_ws = x.calcSize(); n = write_varint(a,e-a,app_params_ws); a += n; if ((n <= 0) || (app_params_ws > (e-a))) - return -402; + return -405; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -7992,14 +8022,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_thresholds) { // 'thresholds': id=41, encoding=lenpfx, tag=0x14a if (2 > (e-a)) - return -403; + return -406; *a++ = 0xca; *a++ = 0x2; ssize_t thresholds_ws = x.calcSize(); n = write_varint(a,e-a,thresholds_ws); a += n; if ((n <= 0) || (thresholds_ws > (e-a))) - return -404; + return -407; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -8009,14 +8039,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_luafiles) { // 'luafiles': id=42, encoding=lenpfx, tag=0x152 if (2 > (e-a)) - return -405; + return -408; *a++ = 0xd2; *a++ = 0x2; ssize_t luafiles_s = x.size(); n = write_varint(a,e-a,luafiles_s); a += n; if ((n <= 0) || ((e-a) < luafiles_s)) - return -406; + return -409; memcpy(a,x.data(),luafiles_s); a += luafiles_s; } @@ -8025,14 +8055,14 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_owdevices) { // 'owdevices': id=50, encoding=lenpfx, tag=0x192 if (2 > (e-a)) - return -407; + return -410; *a++ = 0x92; *a++ = 0x3; ssize_t owdevices_ws = x.calcSize(); n = write_varint(a,e-a,owdevices_ws); a += n; if ((n <= 0) || (owdevices_ws > (e-a))) - return -408; + return -411; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -8216,6 +8246,14 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const m_httpd.toWire(put); } #endif // CONFIG_HTTP + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 + put(0xd2); + put(0x1); + size_t otasrv_s = m_otasrv.size(); + send_varint(put,otasrv_s); + send_bytes(put,(const uint8_t*) m_otasrv.data(),otasrv_s); + } for (size_t x = 0, y = m_timefuses.size(); x != y; ++x) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 put(0xf2); @@ -8235,31 +8273,31 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'threshold_off': id=35, encoding=varint, tag=0x118 put(0x98); put(0x2); send_varint(put,m_threshold_off); } - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'threshold_on': id=36, encoding=varint, tag=0x120 put(0xa0); put(0x2); send_varint(put,m_threshold_on); } - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'dim_step': id=37, encoding=varint, tag=0x128 put(0xa8); put(0x2); send_varint(put,m_dim_step); } - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 put(0xb3); put(0x2); put(m_lightctrl); } - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 put(0xb8); put(0x2); @@ -8478,6 +8516,14 @@ void NodeConfig::toString(std::string &put) const m_httpd.toString(put); } #endif // CONFIG_HTTP + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 + put.push_back(0xd2); + put.push_back(0x1); + size_t otasrv_s = m_otasrv.size(); + send_varint(put,otasrv_s); + put.append((const char *)(const uint8_t*) m_otasrv.data(),otasrv_s); + } for (size_t x = 0, y = m_timefuses.size(); x != y; ++x) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 put.push_back(0xf2); @@ -8497,31 +8543,31 @@ void NodeConfig::toString(std::string &put) const } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'threshold_off': id=35, encoding=varint, tag=0x118 put.push_back(0x98); put.push_back(0x2); send_varint(put,m_threshold_off); } - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'threshold_on': id=36, encoding=varint, tag=0x120 put.push_back(0xa0); put.push_back(0x2); send_varint(put,m_threshold_on); } - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'dim_step': id=37, encoding=varint, tag=0x128 put.push_back(0xa8); put.push_back(0x2); send_varint(put,m_dim_step); } - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 put.push_back(0xb3); put.push_back(0x2); put.push_back(m_lightctrl); } - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 put.push_back(0xb8); put.push_back(0x2); @@ -8778,6 +8824,10 @@ void NodeConfig::toJSON(std::ostream &json, unsigned indLvl) const 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()); + } if (size_t s = m_timefuses.size()) { fsep = json_indent(json,indLvl,fsep); indLvl += 2; @@ -9080,6 +9130,11 @@ size_t NodeConfig::calcSize() const r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } #endif // CONFIG_HTTP + // optional string otasrv, id 26 + if (0 != (p_validbits & ((uint32_t)1U << 13))) { + size_t otasrv_s = m_otasrv.size(); + r += otasrv_s + wiresize(otasrv_s) + 2 /* tag(otasrv) 0xd0 */; + } // repeated EventTimer timefuses, id 30 // repeated message timefuses for (size_t x = 0, y = m_timefuses.size(); x < y; ++x) { @@ -9104,23 +9159,23 @@ size_t NodeConfig::calcSize() const #endif // CONFIG_STATEMACHINES // deprecated optional unsigned max_on_time, id 34 // optional unsigned threshold_off, id 35 - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { r += wiresize((varint_t)m_threshold_off) + 2 /* tag(threshold_off) 0x118 */; } // optional unsigned threshold_on, id 36 - if (0 != (p_validbits & ((uint32_t)1U << 14))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { r += wiresize((varint_t)m_threshold_on) + 2 /* tag(threshold_on) 0x120 */; } // optional unsigned dim_step, id 37 - if (0 != (p_validbits & ((uint32_t)1U << 15))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { r += wiresize((varint_t)m_dim_step) + 2 /* tag(dim_step) 0x128 */; } // optional bool lightctrl, id 38 - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 17))) { r += 3; } // optional unsigned pwm_freq, id 39 - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 18))) { r += wiresize((varint_t)m_pwm_freq) + 2 /* tag(pwm_freq) 0x138 */; } #ifdef CONFIG_APP_PARAMS @@ -9228,6 +9283,8 @@ bool NodeConfig::operator != (const NodeConfig &r) const 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 @@ -9353,17 +9410,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -409; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -412; if (m_dns_server.size() <= x) - return -410; + return -413; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -411; + return -414; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -9461,17 +9518,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -412; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -415; if (m_holidays.size() <= x) - return -413; + return -416; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -414; + return -417; return m_holidays[x].setByName(idxe+2,value); } } @@ -9490,17 +9547,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -415; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -418; if (m_at_actions.size() <= x) - return -416; + return -419; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -417; + return -420; return m_at_actions[x].setByName(idxe+2,value); } } @@ -9529,17 +9586,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -418; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -421; if (m_triggers.size() <= x) - return -419; + return -422; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -420; + return -423; return m_triggers[x].setByName(idxe+2,value); } } @@ -9558,17 +9615,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+5,&idxe,0); - if (idxe[0] != ']') - return -421; + if ((idxe[0] != ']') || (idxe == (name+5))) + return -424; if (m_uart.size() <= x) - return -422; + return -425; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -423; + return -426; return m_uart[x].setByName(idxe+2,value); } } @@ -9588,17 +9645,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -424; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -427; if (m_terminal.size() <= x) - return -425; + return -428; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -426; + return -429; return m_terminal[x].setByName(idxe+2,value); } } @@ -9628,17 +9685,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+7,&idxe,0); - if (idxe[0] != ']') - return -427; + if ((idxe[0] != ']') || (idxe == (name+7))) + return -430; if (m_debugs.size() <= x) - return -428; + return -431; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -429; + return -432; m_debugs[x] = value; return m_debugs[x].size(); } @@ -9665,6 +9722,17 @@ int NodeConfig::setByName(const char *name, const char *value) } } #endif // CONFIG_HTTP + if (0 == strcmp(name,"otasrv")) { + if (value == 0) { + clear_otasrv(); + return 0; + } + m_otasrv = value; + int r = m_otasrv.size(); + if (r > 0) + p_validbits |= ((uint32_t)1U << 13); + return r; + } if (0 == memcmp(name,"timefuses",9)) { if ((name[9] == 0) && (value == 0)) { clear_timefuses(); @@ -9680,17 +9748,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -430; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -433; if (m_timefuses.size() <= x) - return -431; + return -434; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -432; + return -435; return m_timefuses[x].setByName(idxe+2,value); } } @@ -9710,17 +9778,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -433; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -436; if (m_statemachs.size() <= x) - return -434; + return -437; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -435; + return -438; return m_statemachs[x].setByName(idxe+2,value); } } @@ -9740,7 +9808,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_threshold_off,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -9750,7 +9818,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_threshold_on,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"dim_step")) { @@ -9760,7 +9828,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_dim_step,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -9770,7 +9838,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_bool(&m_lightctrl,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -9780,7 +9848,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_pwm_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); return r; } #ifdef CONFIG_APP_PARAMS @@ -9799,17 +9867,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -436; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -439; if (m_app_params.size() <= x) - return -437; + return -440; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -438; + return -441; return m_app_params[x].setByName(idxe+2,value); } } @@ -9830,17 +9898,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+11,&idxe,0); - if (idxe[0] != ']') - return -439; + if ((idxe[0] != ']') || (idxe == (name+11))) + return -442; if (m_thresholds.size() <= x) - return -440; + return -443; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -441; + return -444; return m_thresholds[x].setByName(idxe+2,value); } } @@ -9861,17 +9929,17 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+9,&idxe,0); - if (idxe[0] != ']') - return -442; + if ((idxe[0] != ']') || (idxe == (name+9))) + return -445; if (m_luafiles.size() <= x) - return -443; + return -446; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -444; + return -447; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -9893,22 +9961,22 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } else { x = strtoul(name+10,&idxe,0); - if (idxe[0] != ']') - return -445; + if ((idxe[0] != ']') || (idxe == (name+10))) + return -448; if (m_owdevices.size() <= x) - return -446; + return -449; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -447; + return -450; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -448; + return -451; } Message *NodeConfig::p_getMember(const char *s, const char *e) diff --git a/components/wfc/swcfg_pc.h b/components/wfc/swcfg_pc.h index 9644e20..f0ed455 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 @@ -3966,6 +3966,32 @@ class NodeConfig : public Message FtpHttpConfig *mutable_httpd(); #endif // CONFIG_HTTP + // optional string otasrv, id 26 + /*! + * Function for querying if otasrv has been set. + * @return true if otasrv is set. + */ + bool has_otasrv() const; + //! Function to reset otasrv to its default/unset value. + void clear_otasrv(); + //! Get value of otasrv. + const std::string &otasrv() const; + /*! + * Function for setting otasrv using binary data. + * @param data pointer to binary data + * @param s number of bytes at data pointer + */ + void set_otasrv(const void *data, size_t s); + //! Set otasrv using a constant reference + void set_otasrv(const std::string &v); + //! Set otasrv using a pointer to a null-terminated C-string. + void set_otasrv(const char *); + /*! + * Provide mutable access to otasrv. + * @return pointer to member variable of otasrv. + */ + std::string *mutable_otasrv(); + // repeated EventTimer timefuses, id 30 //! Function get const-access to the elements of timefuses. const std::vector &timefuses() const; @@ -4296,6 +4322,8 @@ class NodeConfig : public Message //! FtpHttpConfig httpd, id 25 FtpHttpConfig m_httpd; #endif // CONFIG_HTTP + //! string otasrv, id 26 + std::string m_otasrv; //! EventTimer timefuses, id 30 std::vector m_timefuses; #ifdef CONFIG_SIGNAL_PROC @@ -7277,6 +7305,7 @@ inline size_t NodeConfig::getMaxSize() // repeated string debugs, id 23 has unlimited size // optional FtpHttpConfig ftpd, id 24 has maximum size 5 // optional FtpHttpConfig httpd, id 25 has maximum size 5 + // optional string otasrv, id 26 has unlimited size // repeated EventTimer timefuses, id 30 has unlimited size // obsolete repeated SignalConfig signals, id 31 // obsolete repeated FunctionConfig functions, id 32 @@ -8390,6 +8419,55 @@ inline void NodeConfig::set_httpd(const FtpHttpConfig &v) #endif // CONFIG_HTTP +inline const std::string &NodeConfig::otasrv() const +{ + return m_otasrv; +} + +inline bool NodeConfig::has_otasrv() const +{ + return 0 != (p_validbits & ((uint32_t)1U << 13)); +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void NodeConfig::clear_otasrv() +{ + p_validbits &= ~((uint32_t)1U << 13); + m_otasrv.clear(); +} + +inline std::string *NodeConfig::mutable_otasrv() +{ + if (0 == (p_validbits & ((uint32_t)1U << 13))) { + p_validbits |= ((uint32_t)1U << 13); + m_otasrv.clear(); + } + return &m_otasrv; +} + +inline void NodeConfig::set_otasrv(const void *data, size_t s) +{ + m_otasrv.assign((const char *)data,s); + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const char *data) +{ + m_otasrv = data; + p_validbits |= ((uint32_t)1U << 13); +} + +inline void NodeConfig::set_otasrv(const std::string &v) +{ + m_otasrv = v; + p_validbits |= ((uint32_t)1U << 13); +} + + + inline const EventTimer &NodeConfig::timefuses(unsigned x) const { return m_timefuses[x]; @@ -8525,7 +8603,7 @@ inline uint64_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8534,14 +8612,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 13); + p_validbits &= ~((uint32_t)1U << 14); m_threshold_off = 0; } inline uint64_t *NodeConfig::mutable_threshold_off() { - if (0 == (p_validbits & ((uint32_t)1U << 13))) { - p_validbits |= ((uint32_t)1U << 13); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_threshold_off = 0; } return &m_threshold_off; @@ -8550,7 +8628,7 @@ inline uint64_t *NodeConfig::mutable_threshold_off() inline void NodeConfig::set_threshold_off(uint64_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 13); + p_validbits |= ((uint32_t)1U << 14); } @@ -8562,7 +8640,7 @@ inline uint64_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8571,14 +8649,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 15); m_threshold_on = 0; } inline uint64_t *NodeConfig::mutable_threshold_on() { - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_threshold_on = 0; } return &m_threshold_on; @@ -8587,7 +8665,7 @@ inline uint64_t *NodeConfig::mutable_threshold_on() inline void NodeConfig::set_threshold_on(uint64_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 15); } @@ -8599,7 +8677,7 @@ inline uint64_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8608,14 +8686,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 16); m_dim_step = 0; } inline uint64_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_dim_step = 0; } return &m_dim_step; @@ -8624,7 +8702,7 @@ inline uint64_t *NodeConfig::mutable_dim_step() inline void NodeConfig::set_dim_step(uint64_t v) { m_dim_step = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 16); } @@ -8636,7 +8714,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 17)); } /*! @@ -8645,14 +8723,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 17); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 17))) { + p_validbits |= ((uint32_t)1U << 17); m_lightctrl = 0; } return &m_lightctrl; @@ -8661,7 +8739,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 16); + p_validbits |= ((uint32_t)1U << 17); } @@ -8673,7 +8751,7 @@ inline uint64_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 18)); } /*! @@ -8682,14 +8760,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 18); m_pwm_freq = 0; } inline uint64_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 18))) { + p_validbits |= ((uint32_t)1U << 18); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8698,7 +8776,7 @@ inline uint64_t *NodeConfig::mutable_pwm_freq() inline void NodeConfig::set_pwm_freq(uint64_t v) { m_pwm_freq = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 18); } diff --git a/components/wfc/wfccore_esp32.cpp b/components/wfc/wfccore_esp32.cpp index e1b377d..0084b63 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_esp32.h b/components/wfc/wfccore_esp32.h index 2ff56b3..88e6287 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_esp8266.cpp b/components/wfc/wfccore_esp8266.cpp index 96ed78b..aff5b16 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_esp8266.h b/components/wfc/wfccore_esp8266.h index af0f829..618afcc 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_esp8285.cpp b/components/wfc/wfccore_esp8285.cpp index 5fdfacb..e1079f0 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_esp8285.h b/components/wfc/wfccore_esp8285.h index ecd0a6f..d1c8086 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_pc.cpp b/components/wfc/wfccore_pc.cpp index 2ef9c4d..231482b 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/components/wfc/wfccore_pc.h b/components/wfc/wfccore_pc.h index 56547f4..1096962 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: P2211.2 (hg:452/70c60fb242a3) + * WFC Version: P2211.3 (hg:453/f8bb395db7c6) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2022 * Author : Thomas Maier-Komor * - * Code generated on 2022-12-19, 19:09:33 (CET). + * Code generated on 2023-01-29, 16:02:18 (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 diff --git a/data/lua/ledstrip.lua b/data/lua/ledstrip.lua index 41d538e..9406e46 100644 --- a/data/lua/ledstrip.lua +++ b/data/lua/ledstrip.lua @@ -2,10 +2,10 @@ if r == nil then r = 30 g = 50 b = 80 - LumMap = { 1<<4, 1<<5, 1<<6, 1<<7, 1<<8, 1<<9, 1<<10, 1<<11 }; + num = rgbleds_num() + args = {} end -args = {} -for i = 0,99,1 do +for i = 1,num,1 do rv = math.floor(((math.sin((((i+r)%100)/50)*3.14)+1)/2)*255) gv = math.floor(((math.sin((((i+g)%100)/50)*3.14)+1)/2)*255) bv = math.floor(((math.sin((((i+b)%100)/50)*3.14)+1)/2)*255) diff --git a/data/man/lua.man b/data/man/lua.man index 69ae0fe..fe8681f 100644 --- a/data/man/lua.man +++ b/data/man/lua.man @@ -1,22 +1,3 @@ synopsis: lua