From 249f1b0dffe5427fe3076d60d8234b6dd1b2f866 Mon Sep 17 00:00:00 2001 From: Thomas Maier-Komor Date: Mon, 1 May 2023 22:16:26 +0200 Subject: [PATCH] release R2304 --- CMakeLists.txt | 1 + ChangeLog | 15 + README.md | 10 + components/actions/actions.cpp | 2 +- components/cyclic/cyclic.cpp | 10 + components/env/env.cpp | 28 +- components/event/event.cpp | 254 ++++-- components/event/event.h | 6 + components/logging/logging.c | 8 +- components/lua/lbaselib.c | 4 +- components/lua/lstate.h | 1 + components/netsvc/lwtcp.cpp | 33 +- components/netsvc/udns.cpp | 24 +- components/netsvc/usntp.cpp | 14 +- components/timefuse/timefuse.cpp | 279 +++--- components/timefuse/timefuse.h | 40 +- components/wfc/hwcfg_esp32.cpp | 540 +++-------- components/wfc/hwcfg_esp32.h | 510 ++++++----- components/wfc/hwcfg_esp8266.cpp | 290 +----- components/wfc/hwcfg_esp8266.h | 351 ++++---- components/wfc/hwcfg_esp8285.cpp | 193 +--- components/wfc/hwcfg_esp8285.h | 345 ++++--- components/wfc/hwcfg_pc.cpp | 552 ++++-------- components/wfc/hwcfg_pc.h | 512 ++++++----- components/wfc/swcfg_esp32.cpp | 1154 ++++++++++-------------- components/wfc/swcfg_esp32.h | 979 ++++++++++---------- components/wfc/swcfg_esp8266.cpp | 824 +++++++---------- components/wfc/swcfg_esp8266.h | 854 ++++++++---------- components/wfc/swcfg_esp8285.cpp | 1124 ++++++++++------------- components/wfc/swcfg_esp8285.h | 905 ++++++++----------- components/wfc/swcfg_pc.cpp | 1344 ++++++++++++---------------- components/wfc/swcfg_pc.h | 977 ++++++++++---------- components/wfc/wfccore_esp32.cpp | 23 +- components/wfc/wfccore_esp32.h | 24 +- components/wfc/wfccore_esp8266.cpp | 23 +- components/wfc/wfccore_esp8266.h | 24 +- components/wfc/wfccore_esp8285.cpp | 17 +- components/wfc/wfccore_esp8285.h | 19 +- components/wfc/wfccore_pc.cpp | 23 +- components/wfc/wfccore_pc.h | 27 +- data/lua/rgbcct.lua | 235 +---- data/lua/tracks.lua | 38 +- data/man/dumpadm.man | 5 + data/man/event.man | 3 +- data/man/set.man | 5 - data/man/timer.man | 6 +- drv/button/button.cpp | 22 +- drv/i2c/ina2xx.cpp | 2 +- drv/i2c/tca9555.cpp | 76 +- drv/xio/xio.h | 12 +- hwcfg.wfc | 32 +- main/CMakeLists.txt | 2 +- main/HttpResp.cpp | 2 +- main/HttpServer.cpp | 82 +- main/HttpServer.h | 7 +- main/adc.cpp | 4 +- main/alarms.cpp | 14 +- main/component.mk | 3 + main/dimmer.cpp | 6 +- main/ftpd.cpp | 19 +- main/globals.cpp | 30 +- main/globals.h | 2 +- main/gpios.cpp | 21 +- main/httpd.cpp | 137 +-- main/influx.cpp | 86 +- main/leds.cpp | 44 +- main/luaext.cpp | 109 ++- main/mqtt.cpp | 73 +- main/screen.cpp | 6 +- main/settings.cpp | 58 +- main/shell.cpp | 481 ++++++---- main/startup.cpp | 9 + main/statemach.cpp | 95 +- main/syslog.cpp | 19 +- main/telnet.cpp | 2 + mkatrium.sh | 2 + patches/esp32-lwip-v4.4.4.diff | 26 + projects/esp32-c3_2m | 2 +- projects/esp32-c3_4m | 26 +- projects/esp32-s3_4m | 2 +- projects/esp32-s3_8m | 2 +- projects/esp32_4m | 19 +- swcfg.wfc | 46 +- 83 files changed, 6432 insertions(+), 7803 deletions(-) create mode 100644 data/man/dumpadm.man delete mode 100644 data/man/set.man diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f8c94a..9829219 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.5) add_compile_definitions(ESP$ENV{ESP_FAM}) add_compile_definitions(IDF_VERSION=$ENV{IDF_VERSION}) add_compile_definitions(FWCFG="$ENV{FWCFG}") +add_link_options(LINKER:SHELL:"-gc-sections,--defsym,LDTIMESTAMP=$ENV{TIMESTAMP}") #set(FWCFG $ENV{FWCFG}) # ignored - for whatever reason... #add_compile_definitions(FWCFG="$ENV{FWCFG}") diff --git a/ChangeLog b/ChangeLog index 3577870..fca2543 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +R2304: +====== +- added command line comment suport to ignore lines starting with a # +- added core file handling support, including direct http download +- added FTP binary transfer support +- enhanced sm command to print all event/action associations of states +- output of ls command could be better +- timer infrastructure must deal with invalid timer ids +- more event statistics +- added busy LED that shows activity of event and cyclic processing +- update stt command +- TCA9555 init fix +- fix: env output ignores printing format +- fix: timer argument parsing error + R2303: ====== - added script for convenient flashing diff --git a/README.md b/README.md index acdc4c7..3537082 100644 --- a/README.md +++ b/README.md @@ -1006,6 +1006,16 @@ a file, just executed e.g. `cp /usb/myfile.lua .`. This will copy the file to the current directory, which is per default `/flash`. +Crash dumps: +============ +Atrium projects for 4MB flash size are configured with a core dump +partition and include infrastructure to save and download crash dumps. +For this, the `dumpadm` command is available that allows copying the +current crash dump to a writable storeage filesystem. Additionally, if +the internal www server is started, a download of `http://nodename/core` +will download the core binary from the crash partition. + + Known Issues: ============= - The documentation is incomplete and not completely up-to-date diff --git a/components/actions/actions.cpp b/components/actions/actions.cpp index eccabee..d611652 100644 --- a/components/actions/actions.cpp +++ b/components/actions/actions.cpp @@ -127,7 +127,7 @@ Action *action_add(const char *name, void (*func)(void *), void *arg, const char log_dbug(TAG,"add %s",name); return (Action*) &(*Actions.emplace(name,func,arg,text).first); } - log_warn(TAG,"duplicated action %s",name); + log_warn(TAG,"action exists: %s",name); } return 0; } diff --git a/components/cyclic/cyclic.cpp b/components/cyclic/cyclic.cpp index 96ccbdb..18ee07b 100644 --- a/components/cyclic/cyclic.cpp +++ b/components/cyclic/cyclic.cpp @@ -76,6 +76,14 @@ static SubTask *SubTasks = 0; static SemaphoreHandle_t Mtx = 0; static volatile uint64_t TimeSpent = 0; +#ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB +#define busy_set(...) +#elif defined CONFIG_LEDS +extern "C" void busy_set(int on); +#else +#define busy_set(...) +#endif + int cyclic_add_task(const char *name, unsigned (*loop)(void*), void *arg, unsigned initdelay) { @@ -134,7 +142,9 @@ unsigned cyclic_execute() if (off <= 0) { lock.unlock(); // con_printf("subtask => %s\n",t->name); + busy_set(true); unsigned d = t->code(t->arg); + busy_set(false); int64_t end = esp_timer_get_time(); lock.lock(); t->nextrun = end + (uint64_t)d * 1000LL; diff --git a/components/env/env.cpp b/components/env/env.cpp index 52b9546..34e477b 100644 --- a/components/env/env.cpp +++ b/components/env/env.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022, Thomas Maier-Komor + * Copyright (C) 2020-2023, Thomas Maier-Komor * Atrium Firmware Package for ESP * * This program is free software: you can redistribute it and/or modify @@ -22,6 +22,8 @@ #include #include #include +#include + #include using namespace std; @@ -89,16 +91,13 @@ void EnvNumber::set(float v) event_trigger(m_evhi); m_tst = 1; } - } else if (m_tst >= 0) { + } + // no else for m_tst == 0 to work below + if (m_tst >= 0) { if (v < m_low) { event_trigger(m_evlo); m_tst = -1; } - } else { - if (v > m_high) - m_tst = 1; - else if (v < m_low) - m_tst = -1; } } } @@ -120,8 +119,23 @@ int EnvNumber::setThresholds(float l, float h, const char *n) void EnvNumber::writeValue(stream &o) const { + // writeValue is used for influx + // i.e. spaces must not be included in the output if (isValid()) { +#ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB + // variant needed if printf %f support is missing o << get(); +#else + char buf[128]; + int n = snprintf(buf,sizeof(buf),m_fmt,m_value); + assert((n > 0) && (n < sizeof(buf))); + char *b = buf; + while (*b == ' ') { + ++b; + --n; + } + o.write(b,n); +#endif } else if (m_dim) { o.write("NaN",3); } else { diff --git a/components/event/event.cpp b/components/event/event.cpp index 3ea158f..1a621a8 100644 --- a/components/event/event.cpp +++ b/components/event/event.cpp @@ -21,6 +21,7 @@ #include "event.h" #include "log.h" //#include "profiling.h" +#include "terminal.h" #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include using namespace std; @@ -39,6 +41,16 @@ using namespace std; #define log_devel(...) #endif +// WARNING: no debug support on 1MB devices!!! +#ifdef CONFIG_ESPTOOLPY_FLASHSIZE_1MB +#define log_dbug(...) +#define busy_set(...) +#elif defined CONFIG_LEDS +extern "C" void busy_set(int on); +#else +#define busy_set(...) +#endif + struct Event { event_t id; @@ -54,7 +66,11 @@ static QueueHandle_t EventsQ = 0; static SemaphoreHandle_t EventMtx = 0; static vector EventHandlers; #define TAG MODULE_EVENT -static uint8_t Lost = 0; +#ifdef ESP32 +static atomic Lost, Discarded, Invalid, Processed; +#else +static uint32_t Lost = 0, Discarded = 0, Invalid = 0, Processed = 0; +#endif char *concat(const char *s0, const char *s1) @@ -83,7 +99,7 @@ event_t event_register(const char *cat, const char *type) // event_t 0: name: empty string; invalid event, catched in this loop for (size_t i = 1; i < n; ++i) { if (!strcmp(name,EventHandlers[i].name)) { - log_error(TAG,"duplicate event %d: %s",i,name); + log_warn(TAG,"duplicate event %d: %s",i,name); if (name != cat) free((void*)name); return (event_t) i; @@ -113,37 +129,42 @@ uint64_t event_time(event_t e) trigger_t event_callback(event_t e, Action *a) { + /* + trigger_t t = 0; if (pdFALSE == xSemaphoreTake(EventMtx,MUTEX_ABORT_TIMEOUT)) abort_on_mutex(EventMtx,__FUNCTION__); - if (e < EventHandlers.size()) { + if ((e != 0) && (e < EventHandlers.size())) { Callback c(a); - trigger_t t = (trigger_t) ((e << 16) | EventHandlers[e].callbacks.size()); + t = (trigger_t) ((e << 16) | EventHandlers[e].callbacks.size()); EventHandlers[e].callbacks.push_back(c); - xSemaphoreGive(EventMtx); - log_dbug(TAG,"add %s -> %s",EventHandlers[e].name,a->name); - return t; } xSemaphoreGive(EventMtx); - log_warn(TAG,"invalid event %u",e); - return 0; + if (t) { + log_dbug(TAG,"add %s -> %s",EventHandlers[e].name,a->name); + } else { + log_dbug(TAG,"callback got invalid event %u",e); + } + return t; + */ + return event_callback_arg(e,a,0); } trigger_t event_callback_arg(event_t e, Action *a, const char *arg) { - if (pdFALSE == xSemaphoreTake(EventMtx,MUTEX_ABORT_TIMEOUT)) - abort_on_mutex(EventMtx,__FUNCTION__); - if (e < EventHandlers.size()) { + trigger_t t = 0; + Lock lock(EventMtx); + if ((e != 0) && (e < EventHandlers.size())) { Callback c(a,arg ? strdup(arg) : 0); // copy arg - trigger_t t = (trigger_t) ((e << 16) | EventHandlers[e].callbacks.size()); + t = (trigger_t) ((e << 16) | EventHandlers[e].callbacks.size()); EventHandlers[e].callbacks.push_back(c); - xSemaphoreGive(EventMtx); + } + if (t) { log_dbug(TAG,"add %s -> %s",EventHandlers[e].name,a->name); - return t; + } else { + log_dbug(TAG,"callback_arg got invalid event %u",e); } - xSemaphoreGive(EventMtx); - log_warn(TAG,"invalid event %u",e); - return 0; + return t; } @@ -152,7 +173,7 @@ 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())) { - log_warn(TAG,"invalid trigger %u",t); + log_dbug(TAG,"invalid trigger %u",t); return 1; } EventHandlers[e].callbacks[c].enabled = en; @@ -168,10 +189,11 @@ trigger_t event_callback(const char *event, const char *action) ++sp; char tmp[sp-action]; memcpy(tmp,action,sizeof(tmp)); + tmp[sp-action-1] = 0; if (Action *a = action_get(tmp)) return event_callback_arg(e,a,sp); } else if (Action *a = action_get(action)) - return event_callback(e,a); + return event_callback_arg(e,a,0); x = action; } else { x = event; @@ -197,6 +219,29 @@ trigger_t event_callback_arg(const char *event, const char *action, const char * } +const char *trigger_get_eventname(trigger_t t) +{ + event_t e = t >> 16; + return event_name(e); +} + + +const char *trigger_get_actionname(trigger_t t) +{ + event_t e = t >> 16; + unsigned id = t & 0xffff; + return EventHandlers[e].callbacks[id].action->name; +} + + +const char *trigger_get_arg(trigger_t t) +{ + event_t e = t >> 16; + unsigned id = t & 0xffff; + return EventHandlers[e].callbacks[id].arg; +} + + const EventHandler *event_handler(event_t e) { if (e < EventHandlers.size()) @@ -208,18 +253,16 @@ const EventHandler *event_handler(event_t e) int event_detach(event_t e, Action *a) { const char *err = "invalid event"; - if (e != 0) { + if ((e != 0) && (e < EventHandlers.size())) { Lock lock(EventMtx,__FUNCTION__); - if (e < EventHandlers.size()) { - EventHandler &h = EventHandlers[e]; - for (size_t i = 0, j = h.callbacks.size(); i != j; ++i) { - if (h.callbacks[i].action == a) { - h.callbacks.erase(h.callbacks.begin()+i); - return 0; - } + EventHandler &h = EventHandlers[e]; + for (size_t i = 0, j = h.callbacks.size(); i != j; ++i) { + if (h.callbacks[i].action == a) { + h.callbacks.erase(h.callbacks.begin()+i); + return 0; } - err = "action not found"; } + err = "action not found"; } log_warn(TAG,"detach %u: %s",e,err); return 1; @@ -253,31 +296,33 @@ event_t event_id(const char *n) } - const char *event_name(event_t e) { - if (e != 0) { - if (e < EventHandlers.size()) - return EventHandlers[e].name; + const char *name; + if ((e != 0) && (e < EventHandlers.size())) { + name = EventHandlers[e].name; + } else { + name = 0; } - log_dbug(TAG,"invalid event %u",e); - return 0; + return name; } void event_trigger(event_t id) { - if (id == 0) { - log_devel(TAG,"trigger 0"); - return; + if ((id == 0) || (id >= EventHandlers.size())) { + ++Invalid; + } else if (EventHandlers[id].callbacks.empty()) { + ++Discarded; + } else { + Event e(id); + BaseType_t r = xQueueSend(EventsQ,&e,1000); + if (r != pdTRUE) { + ++Lost; + } else { + log_dbug(TAG,"trigger %s",EventHandlers[id].name); + } } - Event e(id); - BaseType_t r = xQueueSend(EventsQ,&e,1000); - if (r != pdTRUE) { - log_dbug(TAG,"lost event %d",id); - ++Lost; - } else - log_dbug(TAG,"trigger %s",EventHandlers[id].name); } @@ -292,13 +337,20 @@ void event_trigger_nd(event_t id) // no-debug version for syslog only void event_trigger_arg(event_t id, void *arg) { - 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; + if ((id != 0) && (id < EventHandlers.size())) { + if (!EventHandlers[id].callbacks.empty()) { + Event e(id,arg); + log_dbug(TAG,"trigger %d %p",id,arg); + BaseType_t r = xQueueSend(EventsQ,&e,1000); + if (r != pdTRUE) + ++Lost; + return; + } + ++Discarded; + } else { + ++Invalid; } + free(arg); } @@ -325,86 +377,116 @@ void event_isr_trigger_arg(event_t id, void *arg) } } - static void event_task(void *) { #ifdef ESP32 - #ifdef CONFIG_VERIFY_HEAP - #define dt 100 - #else - #define dt portMAX_DELAY - #endif // CONFIG_VERIFY_HEAP + #define dt 1000 #else - unsigned d = 1; -#define dt (d * portTICK_PERIOD_MS) + unsigned d = portTICK_PERIOD_MS; + #define dt (d / portTICK_PERIOD_MS) #endif + uint32_t invalid = 0, lost = 0, discarded = 0; for (;;) { Event e; BaseType_t r = xQueueReceive(EventsQ,&e,dt); - if (Lost) { - log_warn(TAG,"%u lost",(unsigned)Lost); - Lost = 0; - } if (r == pdFALSE) { // timeout: process cyclic -#ifdef ESP32 // cyclic has its own task - #ifdef CONFIG_VERIFY_HEAP - heap_caps_check_integrity_all(true); - #endif -#else +#ifndef ESP32 d = cyclic_execute(); #endif - if (e.id == 0) - continue; +#ifdef CONFIG_VERIFY_HEAP + heap_caps_check_integrity_all(true); +#endif + // low prio stuff + if (Lost != lost) { + log_warn(TAG,"%u lost",Lost-lost); + lost = Lost; + } + if (Invalid != invalid) { + log_warn(TAG,"%u invalid",Invalid-invalid); + invalid = Invalid; + } + if (Discarded != discarded) { + log_dbug(TAG,"%u discarded",Discarded-discarded); + discarded = Discarded; + } + continue; } MLock lock(EventMtx,__FUNCTION__); int64_t start = esp_timer_get_time(); + log_devel(TAG,"process %d",e.id); if (e.id < EventHandlers.size()) { EventHandler &h = EventHandlers[e.id]; ++h.occur; if (!h.callbacks.empty()) { + busy_set(true); log_local(TAG,"%s: %u callbacks, arg %p",h.name,h.callbacks.size(),e.arg); // need to copy the enabled callbacks, // because the enabling might be changed // with an action bool enabled[h.callbacks.size()]; - bzero(enabled,sizeof(enabled)); - unsigned x = 0; + unsigned x = 0, y = sizeof(enabled); for (const auto &c : h.callbacks) { enabled[x] = c.enabled; + if (enabled[x] && (y == sizeof(enabled))) { + y = x; + ++Processed; + } ++x; } - x = 0; - for (const auto &c : h.callbacks) { + if (y == sizeof(enabled)) + ++Discarded; + // after unlock 'EventHandler h' may be + // a wild pointer! Therefore, reinit it + // from its vector every iteration. + for (size_t n = sizeof(enabled); y != n; ++y) { // action arg : set on action_add (cannot be overwritten) // callback arg : set on event_callback_arg // event arg : set on event_trigger_arg - // no unlocking! causes problems... - // unlock sitation need other solution! - if (enabled[x]) { - log_local(TAG,"\t%s, arg %-16s",c.action->name?c.action->name:"",c.arg ? c.arg : ""); -// c.action->activate(e.arg ? e.arg : (c.arg ? strdup((const char *)c.arg) : 0)); - c.action->activate(e.arg ? e.arg : c.arg); + if (enabled[y]) { + const auto &c = EventHandlers[e.id].callbacks[y]; + log_devel(TAG,"\t%s, %s-arg %-16s",c.action->name?c.action->name:"",e.arg?"event": c.arg?"callback":"null",e.arg ? e.arg : c.arg ? c.arg : ""); + Action *a = c.action; + void *arg = e.arg ? e.arg : c.arg; + lock.unlock(); + a->activate(arg); + lock.lock(); } - ++x; } int64_t end = esp_timer_get_time(); - log_local(TAG,"%s time: %lu",h.name,end-start); - h.time += end-start; + EventHandler &h2 = EventHandlers[e.id]; + log_local(TAG,"%s time: %lu",h2.name,end-start); + h2.time += end-start; + busy_set(false); } else { - log_local(TAG,"%s %p: no callbacks",EventHandlers[e.id].name,e.arg); + ++Discarded; } } else { - log_warn(TAG,"invalid event %u",e); + log_local(TAG,"invalid event %d",e.id); + ++Invalid; } if (e.arg) { + log_devel(TAG,"free arg %p",e.arg); free(e.arg); } + log_devel(TAG,"finished %d",e.id); } } +void event_status(Terminal &t) +{ +#ifdef ESP32 + t.printf("%u processed, %u discarded, %u lost, %u invalid\n" + ,Processed.load(),Discarded.load(),Lost.load(),Invalid.load()); +#else + t.printf("%u processed, %u discarded, %u lost, %u invalid\n" + ,Processed,Discarded,Lost,Invalid); +#endif +} + + void event_init(void) { EventMtx = xSemaphoreCreateMutex(); @@ -418,7 +500,7 @@ void event_init(void) int event_start(void) { - BaseType_t r = xTaskCreatePinnedToCore(&event_task, "events", 8192, (void*)0, 9, NULL, 1); + BaseType_t r = xTaskCreatePinnedToCore(&event_task, "events", 8*1024, (void*)0, 9, NULL, 1); if (r != pdPASS) { log_error(TAG,"create task: %d",r); return 1; diff --git a/components/event/event.h b/components/event/event.h index df7f041..01f5849 100644 --- a/components/event/event.h +++ b/components/event/event.h @@ -29,6 +29,7 @@ typedef uint32_t trigger_t; #include class Action; +class Terminal; struct Callback { @@ -56,6 +57,7 @@ struct EventHandler std::vector callbacks; }; +void event_status(Terminal &); trigger_t event_callback(event_t e, Action *a); // strdup's arg @@ -93,6 +95,10 @@ uint32_t event_occur(event_t); uint64_t event_time(event_t); char *concat(const char *s0, const char *s1); +const char *trigger_get_eventname(trigger_t); +const char *trigger_get_actionname(trigger_t); +const char *trigger_get_arg(trigger_t); + #ifdef __cplusplus } #endif diff --git a/components/logging/logging.c b/components/logging/logging.c index fc4c207..eca6ae9 100644 --- a/components/logging/logging.c +++ b/components/logging/logging.c @@ -408,8 +408,12 @@ void abort_on_mutex(SemaphoreHandle_t mtx, const char *usage) uart_print(__FUNCTION__); TaskHandle_t h = xSemaphoreGetMutexHolder(mtx); #if defined ESP32 - uart_print(pcTaskGetTaskName(0)); - uart_print(pcTaskGetTaskName(h)); + const char *n = pcTaskGetTaskName(0); + if (n) + uart_print(n); + n = pcTaskGetTaskName(h); + if (n) + uart_print(n); #else uart_print(pcTaskGetName(0)); uart_print(pcTaskGetName(h)); diff --git a/components/lua/lbaselib.c b/components/lua/lbaselib.c index 1d60c9d..27d3ae1 100644 --- a/components/lua/lbaselib.c +++ b/components/lua/lbaselib.c @@ -21,6 +21,7 @@ #include "lualib.h" +#if 0 // Atrium has its own implementation static int luaB_print (lua_State *L) { int n = lua_gettop(L); /* number of arguments */ int i; @@ -35,6 +36,7 @@ static int luaB_print (lua_State *L) { lua_writeline(); return 0; } +#endif /* @@ -515,7 +517,7 @@ static const luaL_Reg base_funcs[] = { {"next", luaB_next}, {"pairs", luaB_pairs}, {"pcall", luaB_pcall}, - {"print", luaB_print}, +// {"print", luaB_print}, {"warn", luaB_warn}, {"rawequal", luaB_rawequal}, {"rawlen", luaB_rawlen}, diff --git a/components/lua/lstate.h b/components/lua/lstate.h index 61e82cd..5a74423 100644 --- a/components/lua/lstate.h +++ b/components/lua/lstate.h @@ -314,6 +314,7 @@ struct lua_State { UpVal *openupval; /* list of open upvalues in this stack */ StkId tbclist; /* list of to-be-closed variables */ GCObject *gclist; + struct Terminal *term; // Atrium addition struct lua_State *twups; /* list of threads with open upvalues */ struct lua_longjmp *errorJmp; /* current error recover point */ CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ diff --git a/components/netsvc/lwtcp.cpp b/components/netsvc/lwtcp.cpp index 38d57d8..acc6a7e 100644 --- a/components/netsvc/lwtcp.cpp +++ b/components/netsvc/lwtcp.cpp @@ -550,7 +550,7 @@ int LwTcp::read(char *buf, size_t l, unsigned timeout) } xSemaphoreGiveRecursive(m_mtx); if (tofree) { -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); pbuf_free(tofree); LWIP_UNLOCK(); @@ -576,15 +576,24 @@ int LwTcp::send(const char *buf, size_t l, bool copy) return -1; PROFILE_FUNCTION(); log_devel(TAG,"send@%u %u %scopy",m_port,l,copy?"":"no-"); -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 { RLock lock(m_mtx); m_nwrite += l; m_nout += l; } - LWIP_LOCK(); - err_t e = tcp_write(m_pcb,buf,l,copy ? TCP_WRITE_FLAG_COPY : 0); - LWIP_UNLOCK(); + err_t e; +// for (;;) { + LWIP_LOCK(); + e = tcp_write(m_pcb,buf,l,copy ? TCP_WRITE_FLAG_COPY : 0); +// if (e == -1) +// tcp_output(m_pcb); + LWIP_UNLOCK(); +// if (e != -1) +// break; +// log_dbug(TAG,"tcp_write -1"); +// vTaskDelay(1); +// } #else tcpwrite_arg_t a; a.pcb = m_pcb; @@ -597,7 +606,13 @@ int LwTcp::send(const char *buf, size_t l, bool copy) m_nwrite += l; m_nout += l; } - tcpip_send_msg_wait_sem(tcpwrite_fn,&a,&m_lwip); + for (;;) { + tcpip_send_msg_wait_sem(tcpwrite_fn,&a,&m_lwip); + // error -1 means out of memory, so we retry + if (a.err != -1) + break; + vTaskDelay(1); + } err_t e = a.err; #endif if (e == 0) { @@ -642,7 +657,7 @@ void LwTcp::sync(bool block) PROFILE_FUNCTION(); log_local(TAG,"@%u sync %d",m_port,block); err_t r = 0; -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); unsigned w = m_nwrite; if (m_nout) { @@ -686,7 +701,7 @@ LwTcpListener::LwTcpListener(uint16_t port, void (*session)(LwTcp *), const char , m_stack(stack) , m_prio(prio) { -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); m_pcb = tcp_new_ip_type(IPADDR_TYPE_ANY); if (err_t e = tcp_bind(m_pcb,IP_ADDR_ANY,port)) { @@ -713,7 +728,7 @@ LwTcpListener::LwTcpListener(uint16_t port, void (*session)(LwTcp *), const char } -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 void LwTcpListener::create_fn(void *arg) { LwTcpListener *a = (LwTcpListener *) arg; diff --git a/components/netsvc/udns.cpp b/components/netsvc/udns.cpp index 9673cc5..d5ccb29 100644 --- a/components/netsvc/udns.cpp +++ b/components/netsvc/udns.cpp @@ -207,7 +207,7 @@ static ip_addr_t NameServer[4]; static uint16_t CacheSize = 0, MaxCache = 256, Id = 0; static mdns_state_t State = mdns_wifidown; static SemaphoreHandle_t Mtx = 0; -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 static SemaphoreHandle_t LwipSem = 0; #endif @@ -333,7 +333,7 @@ ip_addr_t *cache_lookup(const char *hn) Lock lock(Mtx,__FUNCTION__); long now = xTaskGetTickCount(); while (CacheS && (CacheS->ttl < now)) { - log_dbug(TAG,"entry timed out: %d",CacheS->ttl); + log_dbug(TAG,"entry timeout: %d",CacheS->ttl); cache_remove_head(); } DnsEntry *e = CacheS; @@ -863,7 +863,7 @@ static int udns_send_ns(uint8_t *buf,size_t ql) } -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 static void query_fn(void *a) { Query *q = (Query *)a; @@ -890,7 +890,7 @@ static void query_fn(void *a) #endif -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 typedef struct cb_arg_s { void (*cb)(const char *,const ip_addr_t *,void *); const char *hn; @@ -926,7 +926,7 @@ int udns_query(const char *hn, ip_addr_t *ip, void (*cb)(const char *, const ip_ if (ip) *ip = *ce; if (cb) { -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); cb(hn,ce,arg); LWIP_UNLOCK(); @@ -989,7 +989,7 @@ int udns_query(const char *hn, ip_addr_t *ip, void (*cb)(const char *, const ip_ Queries = q; } uint8_t c = 0; -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); if (local) { if (MPCB) { @@ -1055,7 +1055,7 @@ static err_t sendSelfQuery() } -#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32S2 || defined CONFIG_IDF_TARGET_ESP32S3 || defined CONFIG_IDF_TARGET_ESP32C3 +#if LWIP_TCPIP_CORE_LOCKING == 0 static void udns_cyclic_fn(void *arg) { // no LWIP_LOCK as cyclic is called from tcpip_task via dns_tmr @@ -1082,7 +1082,7 @@ static void udns_cyclic_fn(void *arg) State = mdns_up; break; default: - abort(); + log_fatal(TAG,"invalid State %d",State); } if (Queries) { Lock lock(Mtx,__FUNCTION__); @@ -1108,7 +1108,7 @@ static unsigned udns_cyclic(void *arg) tcpip_send_msg_wait_sem(udns_cyclic_fn,&d,&LwipSem); return d; } -#elif defined CONFIG_LWIP_IGMP +#elif LWIP_IGMP == 1 static unsigned udns_cyclic(void *arg) { // no LWIP_LOCK as cyclic is called from tcpip_task via dns_tmr @@ -1202,7 +1202,7 @@ static inline void mdns_init_fn(void *) } #endif State = mdns_wifiup; -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 assert(LwipSem); if (pdTRUE != xSemaphoreGive(LwipSem)) abort(); @@ -1213,7 +1213,7 @@ static inline void mdns_init_fn(void *) static void mdns_init(void *) { log_dbug(TAG,"init"); -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 tcpip_send_msg_wait_sem(mdns_init_fn,0,&LwipSem); #else mdns_init_fn(0); @@ -1310,7 +1310,7 @@ void dns_init() udp_recv(SPCB,recv_callback,0); udp_bind(SPCB,IP_ANY_TYPE,5353); cyclic_add_task("udns",udns_cyclic,0,250); -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 LwipSem = xSemaphoreCreateBinary(); #endif } diff --git a/components/netsvc/usntp.cpp b/components/netsvc/usntp.cpp index ba98a9f..f5fd576 100644 --- a/components/netsvc/usntp.cpp +++ b/components/netsvc/usntp.cpp @@ -64,7 +64,7 @@ static uint16_t Interval = 0; static int64_t LastUpdate = 0; static char *Server = 0; static bool Queried = false; -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 static sys_sem_t LwipSem = 0; #endif @@ -87,7 +87,7 @@ static inline void sntp_req_fn(void *arg) else log_dbug(TAG,"send req"); pbuf_free(pb); -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 if (pdTRUE != xSemaphoreGive(LwipSem)) abort(); #endif @@ -99,7 +99,7 @@ static void sntp_connect(const char *hn, const ip_addr_t *addr, void *arg); static unsigned sntp_cyclic(void *arg) { if (SPCB != 0) { -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); sntp_req_fn(0); LWIP_UNLOCK(); @@ -195,7 +195,7 @@ static void sntp_mc_init_fn(void *) LWIP_UNLOCK(); } #endif -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 if (pdTRUE != xSemaphoreGive(LwipSem)) abort(); #endif @@ -204,7 +204,7 @@ static void sntp_mc_init_fn(void *) void sntp_mc_init() { -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 sntp_mc_init_fn(0); #else if (LwipSem == 0) @@ -272,7 +272,7 @@ static void sntp_bc_init_fn(void *) ip_set_option(BPCB,SOF_BROADCAST); log_dbug(TAG,"initialized broadcast SNTP"); } -#ifndef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 0 if (pdTRUE != xSemaphoreGive(LwipSem)) abort(); #endif @@ -281,7 +281,7 @@ static void sntp_bc_init_fn(void *) void sntp_bc_init() { -#ifdef CONFIG_IDF_TARGET_ESP8266 +#if LWIP_TCPIP_CORE_LOCKING == 1 LWIP_LOCK(); sntp_bc_init_fn(0); LWIP_UNLOCK(); diff --git a/components/timefuse/timefuse.cpp b/components/timefuse/timefuse.cpp index de95e3d..8db5df6 100644 --- a/components/timefuse/timefuse.cpp +++ b/components/timefuse/timefuse.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021, Thomas Maier-Komor + * Copyright (C) 2020-2023, Thomas Maier-Komor * Atrium Firmware Package for ESP * * This program is free software: you can redistribute it and/or modify @@ -28,29 +28,26 @@ #include #include +#if 0 +#define log_devel log_dbug +#else +#define log_devel(...) +#endif + +#define TIMER_NAME_SIZE 10 struct Timer { - Timer(const char *n, TimerHandle_t i, event_t s, event_t t, event_t o, Timer *x) - : name(n) - , next(x) - , id(i) - , start(s) - , stop(t) - , timeout(o) - { - } - - const char *name; - Timer *next; TimerHandle_t id; event_t start,stop,timeout; + char name[TIMER_NAME_SIZE]; }; #define TAG MODULE_TIMEFUSE static SemaphoreHandle_t Mtx = 0; static Timer *Timers = 0; +uint16_t NumTimers = 0, NumAlloc = 0; static void trigger_timeout(TimerHandle_t h) @@ -61,55 +58,79 @@ static void trigger_timeout(TimerHandle_t h) const char *timefuse_name(timefuse_t t) { - if (t == 0) - return ""; - return t->name; + if ((t > 0) || (t <= NumTimers)) + return Timers[t].name; + return ""; } timefuse_t timefuse_iterator() { - return Timers; + return NumTimers != 0; } timefuse_t timefuse_next(timefuse_t t) { - if (t == 0) - return 0; - return t->next; + if (t != 0) { + ++t; + if (t > NumTimers) + t = 0; + } + return t; } -timefuse_t timefuse_get(const char *n) +static timefuse_t timefuse_get_nl(const char *n) { - Lock lock(Mtx); - Timer *t = Timers; - while (t) { - if (0 == strcmp(n,t->name)) - return t; - t = t->next; + Timer *b = Timers; + auto i = b+1; + Timer *e = b+NumTimers+1; + while (i != e) { + if (0 == strcmp(n,i->name)) { + log_devel(TAG,"get: %s => %d",n,i-b); + return i-b; + } + ++i; } + log_devel(TAG,"unknown timer %s",n); return 0; } +timefuse_t timefuse_get(const char *n) +{ + Lock lock(Mtx); + return timefuse_get_nl(n); +} + + int timefuse_start(timefuse_t t) { - log_dbug(TAG,"start %d",t); - BaseType_t r = xTimerStart(t->id,portMAX_DELAY); - if (pdTRUE == r) { - event_trigger(t->start); - return 0; + int r = 1; + if ((t > 0) && (t <= NumTimers)) { + Lock lock(Mtx); + Timer *x = Timers+t; + if (pdTRUE == xTimerStart(x->id,portMAX_DELAY)) { + event_trigger(x->start); + r = 0; + log_devel(TAG,"started %d, %s",t,x->name); + } else { + log_devel(TAG,"start %d failed",t); + } } - log_warn(TAG,"start error %d",r); - return 1; + if (r) { + log_devel(TAG,"start %d invalid",t); + } + return r; } int timefuse_active(timefuse_t t) { - return xTimerIsTimerActive(t->id); + if ((t > 0) && (t <= NumTimers)) + return xTimerIsTimerActive(Timers[t].id); + return -1; } @@ -117,51 +138,44 @@ int timefuse_start(const char *n) { if (timefuse_t t = timefuse_get(n)) return timefuse_start(t); - log_warn(TAG,"timefuse_start('%s'): invalid timefuse",n); - return 1; + return -1; } +/* int timefuse_delete(timefuse_t t) { - // incomplete - deletion of associated events and timers missing - Timer *d; - if (t == Timers) { - d = Timers; - Timers = d->next; - } else { - Timer *x = Timers; - while ((x != 0) && (x->next != t)) - x = x->next; - if (x == 0) - return 1; - d = x->next; - x->next = d->next; - } - xTimerDelete(t->id,portMAX_DELAY); - delete d; - return 0; + // Not supported - would be incomplete + // deletion of associated events and timers missing } int timefuse_delete(const char *n) { - if (timefuse_t t = timefuse_get(n)) - return timefuse_delete(t); - log_warn(TAG,"timefuse_delete('%s'): invalid timefuse",n); - return 1; + // Not supported - would be incomplete + // deletion of associated events and timers missing } +*/ int timefuse_stop(timefuse_t t) { - BaseType_t r = xTimerStop(t->id,portMAX_DELAY); - if (pdTRUE == r) { - event_trigger(t->stop); - return 0; + int r = 1; + { + Lock lock(Mtx); + if ((t > 0) && (t <= NumTimers)) { + if (pdTRUE == xTimerStop(Timers[t].id,portMAX_DELAY)) { + log_devel(TAG,"timer %s stopped",Timers[t].name); + event_trigger(Timers[t].stop); + } else { + log_devel(TAG,"timer %s stop failed",Timers[t].name); + } + r = 0; + } else { + log_devel(TAG,"stop invalid %d",t); + } } - log_warn(TAG,"stop failure %d",r); - return 1; + return r; } @@ -169,73 +183,91 @@ int timefuse_stop(const char *n) { if (timefuse_t t = timefuse_get(n)) return timefuse_stop(t); - log_warn(TAG,"timefuse_stop('%s'): invalid timefuse",n); + log_devel(TAG,"stop: timer %s unknown",n); return 1; } event_t timefuse_start_event(timefuse_t t) { - if (t == 0) - return 0; - return t->start; + if ((t > 0) && (t <= NumTimers)) + return Timers[t].start; + return 0; } event_t timefuse_stop_event(timefuse_t t) { - if (t == 0) - return 0; - return t->stop; + if ((t > 0) && (t <= NumTimers)) + return Timers[t].stop; + return 0; } event_t timefuse_timeout_event(timefuse_t t) { - if (t == 0) - return 0; - return t->timeout; + if ((t > 0) && (t <= NumTimers)) + return Timers[t].timeout; + return 0; } event_t timefuse_start_event(const char *n) { - return timefuse_start_event(timefuse_get(n)); + if (timefuse_t t = timefuse_get(n)) + return Timers[t].start; + log_devel(TAG,"start: timer %s unknown",n); + return 0; } event_t timefuse_stop_event(const char *n) { - return timefuse_stop_event(timefuse_get(n)); + if (timefuse_t t = timefuse_get(n)) + return Timers[t].stop; + log_devel(TAG,"start: timer %s unknown",n); + return 0; } event_t timefuse_timeout_event(const char *n) { - return timefuse_timeout_event(timefuse_get(n)); + if (timefuse_t t = timefuse_get(n)) + return Timers[t].timeout; + log_devel(TAG,"start: timer %s unknown",n); + return 0; } unsigned timefuse_interval_get(timefuse_t t) { - unsigned ticks = xTimerGetPeriod(t->id); + unsigned ticks = 0; + Lock lock(Mtx); + if ((t > 0) && (t <= NumTimers)) + ticks = xTimerGetPeriod(Timers[t].id); return ticks * portTICK_PERIOD_MS; } unsigned timefuse_interval_get(const char *n) { - return timefuse_interval_get(timefuse_get(n)); + if (timefuse_t t = timefuse_get(n)) + return timefuse_interval_get(t); + return 0; } int timefuse_interval_set(timefuse_t t, unsigned i) { +#ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (i % portTICK_PERIOD_MS) { log_warn(TAG,"invalid interval of %ums",i); return 1; } - return pdFALSE == xTimerChangePeriod(t->id,i/portTICK_PERIOD_MS,portMAX_DELAY); +#endif + if ((t > 0) && (t <= NumTimers)) + return pdFALSE == xTimerChangePeriod(Timers[t].id,i/portTICK_PERIOD_MS,portMAX_DELAY); + return 1; } @@ -245,37 +277,45 @@ int timefuse_interval_set(const char *n, unsigned i) } -/* -bool timefuse_repeat_get(timefuse_t t) +#ifdef ESP32 +int timefuse_repeat_get(timefuse_t t) { - return uxTimerGetReloadMode(t->id); + if ((t > 0) && (t <= NumTimers)) + return uxTimerGetReloadMode(Timers[t].id); + return -1; } -bool timefuse_repeat_get(const char *n) +int timefuse_repeat_get(const char *n) { - return timefuse_repeat_get(timefuse_get(n)); + if (timefuse_t t = timefuse_get(n)) + return timefuse_repeat_get(t); + return -1; } int timefuse_repeat_set(timefuse_t t, bool r) { - vTimerSetReloadMode(t->id,r); - return 0; + if ((t > 0) && (t <= NumTimers)) { + vTimerSetReloadMode(Timers[t].id,r); + return 0; + } + return -1; } int timefuse_repeat_set(const char *n, bool r) { - timefuse_repeat_set(timefuse_get(n),r); - return 0; + if (timefuse_t t = timefuse_get(n)) + return timefuse_repeat_set(t,r); + return -1; } -*/ +#endif // ESP32 static void start_action(void *arg) { - Timer *t = (Timer *)arg; + timefuse_t t = (timefuse_t)(unsigned)arg; timefuse_start(t); } @@ -283,42 +323,55 @@ static void start_action(void *arg) static void stop_action(void *arg) { - Timer *t = (Timer *)arg; + timefuse_t t = (timefuse_t)(unsigned)arg; timefuse_stop(t); } timefuse_t timefuse_create(const char *n, unsigned d_ms, bool repeat) { - if (Mtx == 0) - Mtx = xSemaphoreCreateMutex(); - if (0 != timefuse_get(n)) { - log_warn(TAG,"timer %s already defined",n); + size_t nl = n == 0 ? UINT32_MAX : strlen(n); + if (nl >= TIMER_NAME_SIZE) { + log_warn(TAG,"invalid name"); return 0; } +#ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if ((d_ms % portTICK_PERIOD_MS) || (pdMS_TO_TICKS(d_ms) == 0)) { - log_warn(TAG,"invalid timer interval %ums",d_ms); - return 0; - } - log_dbug(TAG,"create %s",n); - event_t started = event_register(n,"`started"); - event_t stopped = event_register(n,"`stopped"); - event_t timeout = event_register(n,"`timeout"); - if ((timeout == 0) || (stopped == 0) || (started == 0)) - return 0; - TimerHandle_t id = xTimerCreate(n,pdMS_TO_TICKS(d_ms),repeat,(void*)(int)timeout,trigger_timeout); - if (id == 0) { - log_warn(TAG,"create %s failed",n); + log_warn(TAG,"invalid interval %ums",d_ms); return 0; } +#endif + unsigned t = 0; Lock lock(Mtx); - Timer *t = new Timer(strdup(n),id,started,stopped,timeout,Timers); - if (t != 0) { - action_add(concat(n,"!start"),start_action,t,"start this timefuse"); - action_add(concat(n,"!stop"),stop_action,t,"stop this timefuse"); - Timers = t; + if (0 != timefuse_get_nl(n)) { + log_warn(TAG,"%s already defined",n); + } else { + log_dbug(TAG,"create %s, id %u",n,NumTimers+1); + if (NumTimers+1 >= NumAlloc) { + NumAlloc += 4; + Timer *tmp = (Timer *) realloc(Timers,sizeof(Timer)*NumAlloc); + if (tmp == 0) + return 0; + Timers = tmp; + } + t = ++NumTimers; + Timers[t].start = event_register(n,"`started"); + Timers[t].stop = event_register(n,"`stopped"); + timer_t timeout = event_register(n,"`timeout"); + Timers[t].timeout = timeout; + Timers[t].id = xTimerCreate(0,pdMS_TO_TICKS(d_ms),repeat,(void*)(int)timeout,trigger_timeout); + memcpy(Timers[t].name,n,nl+1); + action_add(concat(n,"!start"),start_action,(void*)t,"start this timefuse"); + action_add(concat(n,"!stop"),stop_action,(void*)t,"stop this timefuse"); } return t; } +void timefuse_setup() +{ + Mtx = xSemaphoreCreateMutex(); + NumAlloc = 4; + Timers = (Timer *) malloc(sizeof(Timer)*NumAlloc); + bzero(Timers,sizeof(Timer)); +} diff --git a/components/timefuse/timefuse.h b/components/timefuse/timefuse.h index f44ed0c..c7dbe93 100644 --- a/components/timefuse/timefuse.h +++ b/components/timefuse/timefuse.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020, Thomas Maier-Komor + * Copyright (C) 2020-2023, Thomas Maier-Komor * Atrium Firmware Package for ESP * * This program is free software: you can redistribute it and/or modify @@ -21,36 +21,40 @@ #include "event.h" -class Timer; -typedef Timer* timefuse_t; +typedef uint16_t timefuse_t; +#ifdef __cplusplus timefuse_t timefuse_create(const char *name, unsigned itv, bool repeat = false); -timefuse_t timefuse_get(const char *name); -const char *timefuse_name(timefuse_t); -int timefuse_delete(const char *name); int timefuse_start(const char *name); int timefuse_stop(const char *name); -int timefuse_delete(timefuse_t); +int timefuse_interval_set(const char *,unsigned); +unsigned timefuse_interval_get(const char *); +event_t timefuse_start_event(const char *); +event_t timefuse_stop_event(const char *); +event_t timefuse_timeout_event(const char *); +int timefuse_repeat_get(const char *); // ESP32 only +int timefuse_repeat_set(const char *,bool); // ESP32 only +//int timefuse_delete(const char *name); -- not supported + +extern "C" { +#endif +timefuse_t timefuse_get(const char *name); +const char *timefuse_name(timefuse_t); +//int timefuse_delete(timefuse_t); -- not supported int timefuse_start(timefuse_t); int timefuse_stop(timefuse_t); int timefuse_active(timefuse_t); unsigned timefuse_interval_get(timefuse_t); -unsigned timefuse_interval_get(const char *); int timefuse_interval_set(timefuse_t,unsigned); -int timefuse_interval_set(const char *,unsigned); -event_t timefuse_start_event(const char *); -event_t timefuse_stop_event(const char *); -event_t timefuse_timeout_event(const char *); event_t timefuse_start_event(timefuse_t); event_t timefuse_stop_event(timefuse_t); event_t timefuse_timeout_event(timefuse_t); timefuse_t timefuse_iterator(); timefuse_t timefuse_next(timefuse_t); - -// unsupported by FreeRTOS -//bool timefuse_repeat_get(const char *); -//bool timefuse_repeat_get(timefuse_t); -//int timefuse_repeat_set(const char *,bool); -//int timefuse_repeat_set(timefuse_t,bool); +int timefuse_repeat_get(timefuse_t); // ESP32 only +int timefuse_repeat_set(timefuse_t,bool); // ESP32 only +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/components/wfc/hwcfg_esp32.cpp b/components/wfc/hwcfg_esp32.cpp index 5c91558..b69cd9d 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -560,25 +560,6 @@ const char *spidrv_t_str(spidrv_t e) #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB } -SystemConfig::SystemConfig() -: m_manufacturer() -, m_board_name() -, m_board_rev() -, m_model_name() -, m_model_number() -, m_diag_uart(0) -, m_console_rx(0) -, m_console_tx(0) -#ifdef CONFIG_USB_DIAGLOG -, m_usb_diag(true) -#endif // CONFIG_USB_DIAGLOG -#ifdef CONFIG_USB_CONSOLE -, m_usb_con(true) -#endif // CONFIG_USB_CONSOLE -, p_validbits(0) -{ -} - void SystemConfig::clear() { m_manufacturer.clear(); @@ -1136,26 +1117,18 @@ int SystemConfig::setByName(const char *name, const char *value) return -32; } -Message *SystemConfig::p_getMember(const char *s, const char *e) +Message *SystemConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SystemConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SystemConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -TouchpadConfig::TouchpadConfig() -: m_interval(0) -, m_fsm_mode(false) -, m_lvolt(-1) -, m_hvolt(-1) -, m_atten(-1) -, p_validbits(0) -{ -} - void TouchpadConfig::clear() { m_fsm_mode = false; @@ -1452,26 +1425,18 @@ int TouchpadConfig::setByName(const char *name, const char *value) return -50; } -Message *TouchpadConfig::p_getMember(const char *s, const char *e) +Message *TouchpadConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *TouchpadConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *TouchpadConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -TouchChannelConfig::TouchChannelConfig() -: m_name() -, m_threshold(0) -, m_channel(-1) -, m_slope(0) -, m_tieopt(0) -, p_validbits(0) -{ -} - void TouchChannelConfig::clear() { m_name.clear(); @@ -1780,30 +1745,18 @@ int TouchChannelConfig::setByName(const char *name, const char *value) return -68; } -Message *TouchChannelConfig::p_getMember(const char *s, const char *e) +Message *TouchChannelConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *TouchChannelConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *TouchChannelConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -ButtonConfig::ButtonConfig() -: m_name() -, m_gpio(-1) -, m_presslvl(0) -, m_pull_mode(pull_none) -#ifdef CONFIG_ROTARYENCODER -, m_clk(-1) -#endif // CONFIG_ROTARYENCODER -#ifdef CONFIG_ROTARYENCODER -, m_dt(-1) -#endif // CONFIG_ROTARYENCODER -{ -} - void ButtonConfig::clear() { m_name.clear(); @@ -2205,26 +2158,18 @@ int ButtonConfig::setByName(const char *name, const char *value) return -90; } -Message *ButtonConfig::p_getMember(const char *s, const char *e) +Message *ButtonConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *ButtonConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *ButtonConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -RelayConfig::RelayConfig() -: m_name() -, m_min_itv(0) -, m_gpio(-1) -, m_config(0) -, m_interlock(-1) -, p_validbits(0) -{ -} - void RelayConfig::clear() { m_name.clear(); @@ -2599,25 +2544,18 @@ int RelayConfig::setByName(const char *name, const char *value) return -110; } -Message *RelayConfig::p_getMember(const char *s, const char *e) +Message *RelayConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *RelayConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *RelayConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Max7219Config::Max7219Config() -: m_clk(-1) -, m_dout(-1) -, m_cs(-1) -, m_odrain(false) -, m_digits(0) -{ -} - void Max7219Config::clear() { m_clk = -1; @@ -2909,25 +2847,18 @@ int Max7219Config::setByName(const char *name, const char *value) return -128; } -Message *Max7219Config::p_getMember(const char *s, const char *e) +Message *Max7219Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Max7219Config::p_getMember(const char *s, const char *e, unsigned x) +Message *Max7219Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Tlc5947Config::Tlc5947Config() -: m_sin(-1) -, m_sclk(-1) -, m_xlat(-1) -, m_blank(-1) -, m_ntlc(0) -{ -} - void Tlc5947Config::clear() { m_sin = -1; @@ -3227,24 +3158,18 @@ int Tlc5947Config::setByName(const char *name, const char *value) return -147; } -Message *Tlc5947Config::p_getMember(const char *s, const char *e) +Message *Tlc5947Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Tlc5947Config::p_getMember(const char *s, const char *e, unsigned x) +Message *Tlc5947Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Ws2812bConfig::Ws2812bConfig() -: m_name() -, m_gpio(-1) -, m_ch(-1) -, m_nleds(0) -{ -} - void Ws2812bConfig::clear() { m_gpio = -1; @@ -3509,22 +3434,18 @@ int Ws2812bConfig::setByName(const char *name, const char *value) return -163; } -Message *Ws2812bConfig::p_getMember(const char *s, const char *e) +Message *Ws2812bConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Ws2812bConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *Ws2812bConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -DhtConfig::DhtConfig() -: m_model(DHT_NONE) -, m_gpio(-1) -{ -} - void DhtConfig::clear() { m_model = DHT_NONE; @@ -3716,28 +3637,18 @@ int DhtConfig::setByName(const char *name, const char *value) return -174; } -Message *DhtConfig::p_getMember(const char *s, const char *e) +Message *DhtConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *DhtConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *DhtConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -I2CConfig::I2CConfig() -: m_freq(100000) -#ifdef CONFIG_I2C_XDEV -#endif // CONFIG_I2C_XDEV -, m_port(0) -, m_sda(-1) -, m_scl(-1) -, m_xpullup(false) -, p_validbits(0) -{ -} - void I2CConfig::clear() { m_port = 0; @@ -4189,23 +4100,18 @@ int I2CConfig::setByName(const char *name, const char *value) return -200; } -Message *I2CConfig::p_getMember(const char *s, const char *e) +Message *I2CConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *I2CConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *I2CConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -HcSr04Config::HcSr04Config() -: m_name() -, m_trigger(-1) -, m_echo(-1) -{ -} - void HcSr04Config::clear() { m_trigger = -1; @@ -4429,25 +4335,18 @@ int HcSr04Config::setByName(const char *name, const char *value) return -213; } -Message *HcSr04Config::p_getMember(const char *s, const char *e) +Message *HcSr04Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *HcSr04Config::p_getMember(const char *s, const char *e, unsigned x) +Message *HcSr04Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -LedConfig::LedConfig() -: m_name() -, m_gpio(-1) -, m_config(0) -, m_pwm_ch(-1) -, p_validbits(0) -{ -} - void LedConfig::clear() { m_gpio = -1; @@ -4746,23 +4645,18 @@ int LedConfig::setByName(const char *name, const char *value) return -230; } -Message *LedConfig::p_getMember(const char *s, const char *e) +Message *LedConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *LedConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *LedConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -OneWireConfig::OneWireConfig() -: m_gpio(-1) -, m_pullup(false) -, m_power(-1) -{ -} - void OneWireConfig::clear() { m_gpio = -1; @@ -4972,25 +4866,18 @@ int OneWireConfig::setByName(const char *name, const char *value) return -242; } -Message *OneWireConfig::p_getMember(const char *s, const char *e) +Message *OneWireConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *OneWireConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *OneWireConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -UartConfig::UartConfig() -: m_port(-1) -, m_tx_gpio(-1) -, m_rx_gpio(-1) -, m_cts_gpio(-1) -, m_rts_gpio(-1) -{ -} - void UartConfig::clear() { m_port = -1; @@ -5290,30 +5177,18 @@ int UartConfig::setByName(const char *name, const char *value) return -261; } -Message *UartConfig::p_getMember(const char *s, const char *e) +Message *UartConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *UartConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *UartConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AdcChannel::AdcChannel() -: m_name() -, m_dim() -, m_scale(1) -, m_offset(0) -, m_interval(0) -, m_unit(0) -, m_ch(-1) -, m_atten(0) -, m_window(0) -, p_validbits(0) -{ -} - void AdcChannel::clear() { m_name.clear(); @@ -5440,7 +5315,6 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) m_dim.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 3); break; default: // unknown field (option unknown=skip) @@ -5556,7 +5430,7 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has dim? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { // 'dim': id=10, encoding=lenpfx, tag=0x52 if (a >= e) return -290; @@ -5660,7 +5534,7 @@ size_t AdcChannel::calcSize() const r += 5; } // optional string dim, id 10 - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { size_t dim_s = m_dim.size(); r += dim_s + wiresize(dim_s) + 1 /* tag(dim) 0x50 */; } @@ -5786,34 +5660,23 @@ int AdcChannel::setByName(const char *name, const char *value) } 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) +Message *AdcChannel::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AdcChannel::p_getMember(const char *s, const char *e, unsigned x) +Message *AdcChannel::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AdcConfig::AdcConfig() -: m_adc_name() -, m_hall_name() -, m_adc1_bits(0) -, m_adc2_bits(0) -// omitted unused member mode -// omitted unused member clk_div -, p_validbits(0) -{ -} - void AdcConfig::clear() { m_adc_name.clear(); @@ -6196,29 +6059,22 @@ int AdcConfig::setByName(const char *name, const char *value) return -315; } -Message *AdcConfig::p_getMember(const char *s, const char *e) +Message *AdcConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AdcConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *AdcConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("channels[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 8) && (0 == memcmp("channels",s,8))) { if (x < m_channels.size()) return &m_channels[x]; - return 0; } return 0; } -GpioConfig::GpioConfig() -: m_name() -, m_config(0) -, m_gpio(-1) -, p_validbits(0) -{ -} - void GpioConfig::clear() { m_name.clear(); @@ -6285,7 +6141,6 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x10: // gpio id 2, type int8_t, coding signed varint { @@ -6330,7 +6185,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -322; @@ -6355,7 +6210,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has config? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) return -326; @@ -6399,7 +6254,7 @@ size_t GpioConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } @@ -6408,7 +6263,7 @@ size_t GpioConfig::calcSize() const r += wiresize_s((varint_t)m_gpio) + 1 /* tag(gpio) 0x10 */; } // optional gpiocfg_t config, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += wiresize((varint_t)m_config) + 1 /* tag(config) 0x18 */; } return r; @@ -6450,8 +6305,6 @@ int GpioConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"gpio")) { @@ -6536,25 +6389,18 @@ int GpioConfig::setByName(const char *name, const char *value) return -329; } -Message *GpioConfig::p_getMember(const char *s, const char *e) +Message *GpioConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *GpioConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *GpioConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -DisplayConfig::DisplayConfig() -: m_type(dt_none) -, m_options(0) -, m_maxx(0) -, m_maxy(1) -, p_validbits(0) -{ -} - void DisplayConfig::clear() { m_type = dt_none; @@ -6837,25 +6683,18 @@ int DisplayConfig::setByName(const char *name, const char *value) return -346; } -Message *DisplayConfig::p_getMember(const char *s, const char *e) +Message *DisplayConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *DisplayConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *DisplayConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SpiDeviceConfig::SpiDeviceConfig() -: m_drv(spidrv_invalid) -, m_cs(-1) -, m_intr(-1) -, m_reset(-1) -, m_cd(-1) -{ -} - void SpiDeviceConfig::clear() { m_drv = spidrv_invalid; @@ -7170,29 +7009,18 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) return -366; } -Message *SpiDeviceConfig::p_getMember(const char *s, const char *e) +Message *SpiDeviceConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SpiDeviceConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SpiDeviceConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SpiBusConfig::SpiBusConfig() -: m_host(-1) -, m_mosi(-1) -, m_miso(-1) -, m_sclk(-1) -, m_wp(-1) -, m_hold(-1) -, m_options(0) -, m_dma(-1) -, p_validbits(0) -{ -} - void SpiBusConfig::clear() { m_host = -1; @@ -7805,30 +7633,22 @@ int SpiBusConfig::setByName(const char *name, const char *value) return -402; } -Message *SpiBusConfig::p_getMember(const char *s, const char *e) +Message *SpiBusConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SpiBusConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SpiBusConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("devices[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 7) && (0 == memcmp("devices",s,7))) { if (x < m_devices.size()) return &m_devices[x]; - return 0; } return 0; } -GpioCluster::GpioCluster() -: m_name() -, m_base(0) -, m_numio(0) -, m_int_a(-1) -, m_int_b(-1) -{ -} - void GpioCluster::clear() { m_name.clear(); @@ -8134,23 +7954,18 @@ int GpioCluster::setByName(const char *name, const char *value) return -421; } -Message *GpioCluster::p_getMember(const char *s, const char *e) +Message *GpioCluster::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *GpioCluster::p_getMember(const char *s, const char *e, unsigned x) +Message *GpioCluster::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Hlw8012Config::Hlw8012Config() -: m_sel(-1) -, m_cf(-1) -, m_cf1(-1) -{ -} - void Hlw8012Config::clear() { m_sel = -1; @@ -8368,26 +8183,18 @@ int Hlw8012Config::setByName(const char *name, const char *value) return -434; } -Message *Hlw8012Config::p_getMember(const char *s, const char *e) +Message *Hlw8012Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Hlw8012Config::p_getMember(const char *s, const char *e, unsigned x) +Message *Hlw8012Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SX1276Config::SX1276Config() -: m_dio0(-1) -, m_dio1(-1) -, m_dio2(-1) -, m_dio3(-1) -, m_dio4(-1) -, m_dio5(-1) -{ -} - void SX1276Config::clear() { m_dio0 = -1; @@ -8728,56 +8535,18 @@ int SX1276Config::setByName(const char *name, const char *value) return -456; } -Message *SX1276Config::p_getMember(const char *s, const char *e) +Message *SX1276Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SX1276Config::p_getMember(const char *s, const char *e, unsigned x) +Message *SX1276Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -HardwareConfig::HardwareConfig() -: m_magic(0) -#ifdef CONFIG_HLW8012 -#endif // CONFIG_HLW8012 -#ifdef CONFIG_DISPLAY -#endif // CONFIG_DISPLAY -#ifdef CONFIG_IOEXTENDERS -#endif // CONFIG_IOEXTENDERS -#ifdef CONFIG_SX1276 -#endif // CONFIG_SX1276 -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -#ifdef CONFIG_HCSR04 -#endif // CONFIG_HCSR04 -#ifdef CONFIG_I2C -#endif // CONFIG_I2C -#ifdef CONFIG_DHT -#endif // CONFIG_DHT -#ifdef CONFIG_RGBLEDS -#endif // CONFIG_RGBLEDS -#ifdef CONFIG_TLC5947 -#endif // CONFIG_TLC5947 -#ifdef CONFIG_MAX7219 -#endif // CONFIG_MAX7219 -#ifdef CONFIG_LEDS -#endif // CONFIG_LEDS -#ifdef CONFIG_RELAY -#endif // CONFIG_RELAY -#ifdef CONFIG_BUTTON -#endif // CONFIG_BUTTON -#ifdef CONFIG_SPI -#endif // CONFIG_SPI -#ifdef CONFIG_TOUCHPAD -#endif // CONFIG_TOUCHPAD -#ifdef CONFIG_TOUCHPAD -#endif // CONFIG_TOUCHPAD -, p_validbits(0) -{ -} - void HardwareConfig::clear() { m_magic = 0; @@ -10871,122 +10640,103 @@ int HardwareConfig::setByName(const char *name, const char *value) return -580; } -Message *HardwareConfig::p_getMember(const char *s, const char *e) +Message *HardwareConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("system",s,e-s)) + // caller guarantee: s[n] == '.' + if ((n == 6) && (0 == memcmp("system",s,6))) return &m_system; - if (0 == strncmp("adc",s,e-s)) + if ((n == 3) && (0 == memcmp("adc",s,3))) return &m_adc; #ifdef CONFIG_TOUCHPAD - if (0 == strncmp("touchpad",s,e-s)) + if ((n == 8) && (0 == memcmp("touchpad",s,8))) return &m_touchpad; #endif // CONFIG_TOUCHPAD #ifdef CONFIG_HLW8012 - if (0 == strncmp("hlw8012",s,e-s)) + if ((n == 7) && (0 == memcmp("hlw8012",s,7))) return &m_hlw8012; #endif // CONFIG_HLW8012 #ifdef CONFIG_MAX7219 - if (0 == strncmp("max7219",s,e-s)) + if ((n == 7) && (0 == memcmp("max7219",s,7))) return &m_max7219; #endif // CONFIG_MAX7219 #ifdef CONFIG_TLC5947 - if (0 == strncmp("tlc5947",s,e-s)) + if ((n == 7) && (0 == memcmp("tlc5947",s,7))) return &m_tlc5947; #endif // CONFIG_TLC5947 #ifdef CONFIG_DHT - if (0 == strncmp("dht",s,e-s)) + if ((n == 3) && (0 == memcmp("dht",s,3))) return &m_dht; #endif // CONFIG_DHT #ifdef CONFIG_ONEWIRE - if (0 == strncmp("onewire",s,e-s)) + if ((n == 7) && (0 == memcmp("onewire",s,7))) return &m_onewire; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 - if (0 == strncmp("sx1276",s,e-s)) + if ((n == 6) && (0 == memcmp("sx1276",s,6))) return &m_sx1276; #endif // CONFIG_SX1276 #ifdef CONFIG_DISPLAY - if (0 == strncmp("display",s,e-s)) + if ((n == 7) && (0 == memcmp("display",s,7))) return &m_display; #endif // CONFIG_DISPLAY return 0; } -Message *HardwareConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *HardwareConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("uart[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - return 0; - } - #ifdef CONFIG_TOUCHPAD - if (0 == strncmp("tp_channel[",s,e-s)) { + #ifdef CONFIG_TOUCHPAD + } else if ((n == 10) && (0 == memcmp("tp_channel",s,10))) { if (x < m_tp_channel.size()) return &m_tp_channel[x]; - return 0; - } - #endif // CONFIG_TOUCHPAD - if (0 == strncmp("gpios[",s,e-s)) { + #endif // CONFIG_TOUCHPAD + } else if ((n == 5) && (0 == memcmp("gpios",s,5))) { if (x < m_gpios.size()) return &m_gpios[x]; - return 0; - } - #ifdef CONFIG_SPI - if (0 == strncmp("spibus[",s,e-s)) { + #ifdef CONFIG_SPI + } else if ((n == 6) && (0 == memcmp("spibus",s,6))) { if (x < m_spibus.size()) return &m_spibus[x]; - return 0; - } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON - if (0 == strncmp("button[",s,e-s)) { + #endif // CONFIG_SPI + #ifdef CONFIG_BUTTON + } else if ((n == 6) && (0 == memcmp("button",s,6))) { if (x < m_button.size()) return &m_button[x]; - return 0; - } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY - if (0 == strncmp("relay[",s,e-s)) { + #endif // CONFIG_BUTTON + #ifdef CONFIG_RELAY + } else if ((n == 5) && (0 == memcmp("relay",s,5))) { if (x < m_relay.size()) return &m_relay[x]; - return 0; - } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS - if (0 == strncmp("led[",s,e-s)) { + #endif // CONFIG_RELAY + #ifdef CONFIG_LEDS + } else if ((n == 3) && (0 == memcmp("led",s,3))) { if (x < m_led.size()) return &m_led[x]; - return 0; - } - #endif // CONFIG_LEDS - #ifdef CONFIG_RGBLEDS - if (0 == strncmp("ws2812b[",s,e-s)) { + #endif // CONFIG_LEDS + #ifdef CONFIG_RGBLEDS + } else if ((n == 7) && (0 == memcmp("ws2812b",s,7))) { if (x < m_ws2812b.size()) return &m_ws2812b[x]; - return 0; - } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_I2C - if (0 == strncmp("i2c[",s,e-s)) { + #endif // CONFIG_RGBLEDS + #ifdef CONFIG_I2C + } else if ((n == 3) && (0 == memcmp("i2c",s,3))) { if (x < m_i2c.size()) return &m_i2c[x]; - return 0; - } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 - if (0 == strncmp("hcsr04[",s,e-s)) { + #endif // CONFIG_I2C + #ifdef CONFIG_HCSR04 + } else if ((n == 6) && (0 == memcmp("hcsr04",s,6))) { if (x < m_hcsr04.size()) return &m_hcsr04[x]; - return 0; - } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_IOEXTENDERS - if (0 == strncmp("iocluster[",s,e-s)) { + #endif // CONFIG_HCSR04 + #ifdef CONFIG_IOEXTENDERS + } else if ((n == 9) && (0 == memcmp("iocluster",s,9))) { if (x < m_iocluster.size()) return &m_iocluster[x]; - return 0; + #endif // CONFIG_IOEXTENDERS } - #endif // CONFIG_IOEXTENDERS return 0; } diff --git a/components/wfc/hwcfg_esp32.h b/components/wfc/hwcfg_esp32.h index 6c3e597..97dcc37 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -210,10 +210,14 @@ typedef uint16_t i2cdev_t; typedef uint8_t ledcfg_t; typedef uint16_t gpiocfg_t; typedef uint8_t spiopt_t; + + class SystemConfig : public Message { public: - SystemConfig(); + SystemConfig() + { + } bool operator != (const SystemConfig &r) const; bool operator == (const SystemConfig &r) const; @@ -500,8 +504,8 @@ class SystemConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string manufacturer, id 1 estring m_manufacturer; //! string board_name, id 2 @@ -513,29 +517,33 @@ class SystemConfig : public Message //! string model_number, id 8 estring m_model_number; //! sint8 diag_uart, id 4 - int8_t m_diag_uart; + int8_t m_diag_uart = 0; //! sint8 console_rx, id 5 - int8_t m_console_rx; + int8_t m_console_rx = 0; //! sint8 console_tx, id 6 - int8_t m_console_tx; + int8_t m_console_tx = 0; #ifdef CONFIG_USB_DIAGLOG //! bool usb_diag, id 9 - bool m_usb_diag; + bool m_usb_diag = true; #endif // CONFIG_USB_DIAGLOG #ifdef CONFIG_USB_CONSOLE //! bool usb_con, id 10 - bool m_usb_con; + bool m_usb_con = true; #endif // CONFIG_USB_CONSOLE private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchpadConfig : public Message { public: - TouchpadConfig(); + TouchpadConfig() + { + } bool operator != (const TouchpadConfig &r) const; bool operator == (const TouchpadConfig &r) const; @@ -688,28 +696,32 @@ class TouchpadConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! unsigned interval, id 7 - uint32_t m_interval; + uint32_t m_interval = 0; //! bool fsm_mode, id 1 - bool m_fsm_mode; + bool m_fsm_mode = false; //! sint8 lvolt, id 2 - int8_t m_lvolt; + int8_t m_lvolt = -1; //! sint8 hvolt, id 3 - int8_t m_hvolt; + int8_t m_hvolt = -1; //! sint8 atten, id 4 - int8_t m_atten; + int8_t m_atten = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchChannelConfig : public Message { public: - TouchChannelConfig(); + TouchChannelConfig() + { + } bool operator != (const TouchChannelConfig &r) const; bool operator == (const TouchChannelConfig &r) const; @@ -870,28 +882,32 @@ class TouchChannelConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! fixed16 threshold, id 3 - uint16_t m_threshold; + uint16_t m_threshold = 0; //! sint8 channel, id 2 - int8_t m_channel; + int8_t m_channel = -1; //! uint8 slope, id 4 - uint8_t m_slope; + uint8_t m_slope = 0; //! uint8 tieopt, id 5 - uint8_t m_tieopt; + uint8_t m_tieopt = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ButtonConfig : public Message { public: - ButtonConfig(); + ButtonConfig() + { + } bool operator != (const ButtonConfig &r) const; bool operator == (const ButtonConfig &r) const; @@ -1082,31 +1098,35 @@ class ButtonConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool presslvl, id 3 - bool m_presslvl; + bool m_presslvl = 0; //! pull_mode_t pull_mode, id 4 - pull_mode_t m_pull_mode; + pull_mode_t m_pull_mode = pull_none; #ifdef CONFIG_ROTARYENCODER //! sint8 clk, id 5 - int8_t m_clk; + int8_t m_clk = -1; #endif // CONFIG_ROTARYENCODER #ifdef CONFIG_ROTARYENCODER //! sint8 dt, id 6 - int8_t m_dt; + int8_t m_dt = -1; #endif // CONFIG_ROTARYENCODER }; + + class RelayConfig : public Message { public: - RelayConfig(); + RelayConfig() + { + } bool operator != (const RelayConfig &r) const; bool operator == (const RelayConfig &r) const; @@ -1287,28 +1307,32 @@ class RelayConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! unsigned min_itv, id 4 - uint32_t m_min_itv; + uint32_t m_min_itv = 0; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! relay_cfg_t config, id 3 - relay_cfg_t m_config; + relay_cfg_t m_config = 0; //! sint8 interlock, id 5 - int8_t m_interlock; + int8_t m_interlock = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Max7219Config : public Message { public: - Max7219Config(); + Max7219Config() + { + } bool operator != (const Max7219Config &r) const; bool operator == (const Max7219Config &r) const; @@ -1461,25 +1485,29 @@ class Max7219Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 clk, id 1 - int8_t m_clk; + int8_t m_clk = -1; //! sint8 dout, id 2 - int8_t m_dout; + int8_t m_dout = -1; //! sint8 cs, id 3 - int8_t m_cs; + int8_t m_cs = -1; //! bool odrain, id 4 - bool m_odrain; + bool m_odrain = false; //! uint8 digits, id 5 - uint8_t m_digits; + uint8_t m_digits = 0; }; + + class Tlc5947Config : public Message { public: - Tlc5947Config(); + Tlc5947Config() + { + } bool operator != (const Tlc5947Config &r) const; bool operator == (const Tlc5947Config &r) const; @@ -1632,25 +1660,29 @@ class Tlc5947Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 sin, id 1 - int8_t m_sin; + int8_t m_sin = -1; //! sint8 sclk, id 2 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 xlat, id 3 - int8_t m_xlat; + int8_t m_xlat = -1; //! sint8 blank, id 4 - int8_t m_blank; + int8_t m_blank = -1; //! uint8 ntlc, id 5 - uint8_t m_ntlc; + uint8_t m_ntlc = 0; }; + + class Ws2812bConfig : public Message { public: - Ws2812bConfig(); + Ws2812bConfig() + { + } bool operator != (const Ws2812bConfig &r) const; bool operator == (const Ws2812bConfig &r) const; @@ -1793,23 +1825,27 @@ class Ws2812bConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 4 estring m_name; //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! sint8 ch, id 2 - int8_t m_ch; + int8_t m_ch = -1; //! uint8 nleds, id 3 - uint8_t m_nleds; + uint8_t m_nleds = 0; }; + + class DhtConfig : public Message { public: - DhtConfig(); + DhtConfig() + { + } bool operator != (const DhtConfig &r) const; bool operator == (const DhtConfig &r) const; @@ -1908,19 +1944,23 @@ class DhtConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! dht_model_t model, id 1 - dht_model_t m_model; + dht_model_t m_model = DHT_NONE; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; }; + + class I2CConfig : public Message { public: - I2CConfig(); + I2CConfig() + { + } bool operator != (const I2CConfig &r) const; bool operator == (const I2CConfig &r) const; @@ -2107,32 +2147,36 @@ class I2CConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! unsigned freq, id 4 - uint32_t m_freq; + uint32_t m_freq = 100000; #ifdef CONFIG_I2C_XDEV //! i2cdev_t devices, id 6 std::vector m_devices; #endif // CONFIG_I2C_XDEV //! uint8 port, id 1 - uint8_t m_port; + uint8_t m_port = 0; //! sint8 sda, id 2 - int8_t m_sda; + int8_t m_sda = -1; //! sint8 scl, id 3 - int8_t m_scl; + int8_t m_scl = -1; //! bool xpullup, id 5 - bool m_xpullup; + bool m_xpullup = false; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class HcSr04Config : public Message { public: - HcSr04Config(); + HcSr04Config() + { + } bool operator != (const HcSr04Config &r) const; bool operator == (const HcSr04Config &r) const; @@ -2257,21 +2301,25 @@ class HcSr04Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 3 estring m_name; //! sint8 trigger, id 1 - int8_t m_trigger; + int8_t m_trigger = -1; //! sint8 echo, id 2 - int8_t m_echo; + int8_t m_echo = -1; }; + + class LedConfig : public Message { public: - LedConfig(); + LedConfig() + { + } bool operator != (const LedConfig &r) const; bool operator == (const LedConfig &r) const; @@ -2422,26 +2470,30 @@ class LedConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 3 estring m_name; //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! ledcfg_t config, id 2 - ledcfg_t m_config; + ledcfg_t m_config = 0; //! sint8 pwm_ch, id 4 - int8_t m_pwm_ch; + int8_t m_pwm_ch = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class OneWireConfig : public Message { public: - OneWireConfig(); + OneWireConfig() + { + } bool operator != (const OneWireConfig &r) const; bool operator == (const OneWireConfig &r) const; @@ -2558,21 +2610,25 @@ class OneWireConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool pullup, id 2 - bool m_pullup; + bool m_pullup = false; //! sint8 power, id 3 - int8_t m_power; + int8_t m_power = -1; }; + + class UartConfig : public Message { public: - UartConfig(); + UartConfig() + { + } bool operator != (const UartConfig &r) const; bool operator == (const UartConfig &r) const; @@ -2725,25 +2781,29 @@ class UartConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 port, id 1 - int8_t m_port; + int8_t m_port = -1; //! sint8 tx_gpio, id 2 - int8_t m_tx_gpio; + int8_t m_tx_gpio = -1; //! sint8 rx_gpio, id 3 - int8_t m_rx_gpio; + int8_t m_rx_gpio = -1; //! sint8 cts_gpio, id 4 - int8_t m_cts_gpio; + int8_t m_cts_gpio = -1; //! sint8 rts_gpio, id 5 - int8_t m_rts_gpio; + int8_t m_rts_gpio = -1; }; + + class AdcChannel : public Message { public: - AdcChannel(); + AdcChannel() + { + } bool operator != (const AdcChannel &r) const; bool operator == (const AdcChannel &r) const; @@ -2984,36 +3044,40 @@ class AdcChannel : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! string dim, id 10 estring m_dim; //! float scale, id 8 - float m_scale; + float m_scale = 1; //! float offset, id 9 - float m_offset; + float m_offset = 0; //! uint16 interval, id 5 - uint16_t m_interval; + uint16_t m_interval = 0; //! uint8 unit, id 2 - uint8_t m_unit; + uint8_t m_unit = 0; //! sint8 ch, id 3 - int8_t m_ch; + int8_t m_ch = -1; //! uint8 atten, id 4 - uint8_t m_atten; + uint8_t m_atten = 0; //! uint8 window, id 6 - uint8_t m_window; + uint8_t m_window = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class AdcConfig : public Message { public: - AdcConfig(); + AdcConfig() + { + } bool operator != (const AdcConfig &r) const; bool operator == (const AdcConfig &r) const; @@ -3190,30 +3254,32 @@ class AdcConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string adc_name, id 1 estring m_adc_name; //! string hall_name, id 6 estring m_hall_name; //! uint8 adc1_bits, id 2 - uint8_t m_adc1_bits; + uint8_t m_adc1_bits = 0; //! uint8 adc2_bits, id 3 - uint8_t m_adc2_bits; - // omitted unused member mode - // omitted unused member clk_div + uint8_t m_adc2_bits = 0; //! AdcChannel channels, id 7 std::vector m_channels; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioConfig : public Message { public: - GpioConfig(); + GpioConfig() + { + } bool operator != (const GpioConfig &r) const; bool operator == (const GpioConfig &r) const; @@ -3366,24 +3432,28 @@ class GpioConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! gpiocfg_t config, id 3 - gpiocfg_t m_config; + gpiocfg_t m_config = 0; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class DisplayConfig : public Message { public: - DisplayConfig(); + DisplayConfig() + { + } bool operator != (const DisplayConfig &r) const; bool operator == (const DisplayConfig &r) const; @@ -3518,26 +3588,30 @@ class DisplayConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! disp_t type, id 1 - disp_t m_type; + disp_t m_type = dt_none; //! unsigned options, id 2 - uint32_t m_options; + uint32_t m_options = 0; //! unsigned maxx, id 3 - uint32_t m_maxx; + uint32_t m_maxx = 0; //! unsigned maxy, id 4 - uint32_t m_maxy; + uint32_t m_maxy = 1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class SpiDeviceConfig : public Message { public: - SpiDeviceConfig(); + SpiDeviceConfig() + { + } bool operator != (const SpiDeviceConfig &r) const; bool operator == (const SpiDeviceConfig &r) const; @@ -3690,25 +3764,29 @@ class SpiDeviceConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! spidrv_t drv, id 1 - spidrv_t m_drv; + spidrv_t m_drv = spidrv_invalid; //! sint8 cs, id 2 - int8_t m_cs; + int8_t m_cs = -1; //! sint8 intr, id 3 - int8_t m_intr; + int8_t m_intr = -1; //! sint8 reset, id 4 - int8_t m_reset; + int8_t m_reset = -1; //! sint8 cd, id 5 - int8_t m_cd; + int8_t m_cd = -1; }; + + class SpiBusConfig : public Message { public: - SpiBusConfig(); + SpiBusConfig() + { + } bool operator != (const SpiBusConfig &r) const; bool operator == (const SpiBusConfig &r) const; @@ -3967,36 +4045,40 @@ class SpiBusConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 host, id 1 - int8_t m_host; + int8_t m_host = -1; //! sint8 mosi, id 2 - int8_t m_mosi; + int8_t m_mosi = -1; //! sint8 miso, id 3 - int8_t m_miso; + int8_t m_miso = -1; //! sint8 sclk, id 4 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 wp, id 5 - int8_t m_wp; + int8_t m_wp = -1; //! sint8 hold, id 6 - int8_t m_hold; + int8_t m_hold = -1; //! spiopt_t options, id 7 - spiopt_t m_options; + spiopt_t m_options = 0; //! sint8 dma, id 8 - int8_t m_dma; + int8_t m_dma = -1; //! SpiDeviceConfig devices, id 9 std::vector m_devices; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioCluster : public Message { public: - GpioCluster(); + GpioCluster() + { + } bool operator != (const GpioCluster &r) const; bool operator == (const GpioCluster &r) const; @@ -4157,25 +4239,29 @@ class GpioCluster : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! uint8 base, id 2 - uint8_t m_base; + uint8_t m_base = 0; //! uint8 numio, id 3 - uint8_t m_numio; + uint8_t m_numio = 0; //! sint8 int_a, id 4 - int8_t m_int_a; + int8_t m_int_a = -1; //! sint8 int_b, id 5 - int8_t m_int_b; + int8_t m_int_b = -1; }; + + class Hlw8012Config : public Message { public: - Hlw8012Config(); + Hlw8012Config() + { + } bool operator != (const Hlw8012Config &r) const; bool operator == (const Hlw8012Config &r) const; @@ -4292,21 +4378,25 @@ class Hlw8012Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 sel, id 2 - int8_t m_sel; + int8_t m_sel = -1; //! sint8 cf, id 3 - int8_t m_cf; + int8_t m_cf = -1; //! sint8 cf1, id 4 - int8_t m_cf1; + int8_t m_cf1 = -1; }; + + class SX1276Config : public Message { public: - SX1276Config(); + SX1276Config() + { + } bool operator != (const SX1276Config &r) const; bool operator == (const SX1276Config &r) const; @@ -4477,27 +4567,31 @@ class SX1276Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 dio0, id 1 - int8_t m_dio0; + int8_t m_dio0 = -1; //! sint8 dio1, id 2 - int8_t m_dio1; + int8_t m_dio1 = -1; //! sint8 dio2, id 3 - int8_t m_dio2; + int8_t m_dio2 = -1; //! sint8 dio3, id 4 - int8_t m_dio3; + int8_t m_dio3 = -1; //! sint8 dio4, id 5 - int8_t m_dio4; + int8_t m_dio4 = -1; //! sint8 dio5, id 6 - int8_t m_dio5; + int8_t m_dio5 = -1; }; + + class HardwareConfig : public Message { public: - HardwareConfig(); + HardwareConfig() + { + } bool operator != (const HardwareConfig &r) const; bool operator == (const HardwareConfig &r) const; @@ -5116,10 +5210,10 @@ class HardwareConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! fixed32 magic, id 0 - uint32_t m_magic; + uint32_t m_magic = 0; #ifdef CONFIG_HLW8012 //! Hlw8012Config hlw8012, id 20 Hlw8012Config m_hlw8012; @@ -5198,7 +5292,7 @@ class HardwareConfig : public Message SystemConfig m_system; private: - uint16_t p_validbits; + uint16_t p_validbits = 0; }; @@ -8066,7 +8160,7 @@ inline const estring &AdcChannel::dim() const inline bool AdcChannel::has_dim() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return !m_dim.empty(); } /*! @@ -8075,35 +8169,27 @@ inline bool AdcChannel::has_dim() const */ 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); } @@ -8341,7 +8427,7 @@ inline const estring &GpioConfig::name() const inline bool GpioConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -8350,35 +8436,27 @@ inline bool GpioConfig::has_name() const */ inline void GpioConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *GpioConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void GpioConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -8456,7 +8534,7 @@ inline bool GpioConfig::config_cap_freq_r2r() const inline bool GpioConfig::has_config() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -8465,14 +8543,14 @@ inline bool GpioConfig::has_config() const */ inline void GpioConfig::clear_config() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_config = 0; } inline gpiocfg_t *GpioConfig::mutable_config() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_config = 0; } return &m_config; @@ -8482,55 +8560,55 @@ inline void GpioConfig::set_config_mode(uint8_t v) { m_config &= ~(0x3ULL << 0); m_config |= ((uint16_t) v << 0); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_intrtype(uint8_t v) { m_config &= ~(0x7ULL << 2); m_config |= ((uint16_t) v << 2); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_setinit(bool v) { m_config &= ~(0x1ULL << 5); m_config |= ((uint16_t) v << 5); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_initlvl(bool v) { m_config &= ~(0x1ULL << 6); m_config |= ((uint16_t) v << 6); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pullup(bool v) { m_config &= ~(0x1ULL << 7); m_config |= ((uint16_t) v << 7); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pulldown(bool v) { m_config &= ~(0x1ULL << 8); m_config |= ((uint16_t) v << 8); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_cap_freq_r2r(bool v) { m_config &= ~(0x1ULL << 9); m_config |= ((uint16_t) v << 9); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config(gpiocfg_t v) { m_config = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } diff --git a/components/wfc/hwcfg_esp8266.cpp b/components/wfc/hwcfg_esp8266.cpp index b144101..5909054 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -561,21 +561,6 @@ const char *spidrv_t_str(spidrv_t e) } SystemConfig::SystemConfig() -: m_manufacturer() -, m_board_name() -, m_board_rev() -, m_model_name() -, m_model_number() -, m_diag_uart(0) -, m_console_rx(0) -, m_console_tx(0) -#ifdef CONFIG_USB_DIAGLOG -, m_usb_diag(true) -#endif // CONFIG_USB_DIAGLOG -#ifdef CONFIG_USB_CONSOLE -, m_usb_con(true) -#endif // CONFIG_USB_CONSOLE -, p_validbits(0) { } @@ -1070,12 +1055,6 @@ int SystemConfig::setByName(const char *name, const char *value) } TouchpadConfig::TouchpadConfig() -: m_interval(0) -, m_fsm_mode(false) -, m_lvolt(-1) -, m_hvolt(-1) -, m_atten(-1) -, p_validbits(0) { } @@ -1339,12 +1318,6 @@ int TouchpadConfig::setByName(const char *name, const char *value) } TouchChannelConfig::TouchChannelConfig() -: m_name() -, m_threshold(0) -, m_channel(-1) -, m_slope(0) -, m_tieopt(0) -, p_validbits(0) { } @@ -1619,16 +1592,6 @@ int TouchChannelConfig::setByName(const char *name, const char *value) } ButtonConfig::ButtonConfig() -: m_name() -, m_gpio(-1) -, m_presslvl(0) -, m_pull_mode(pull_none) -#ifdef CONFIG_ROTARYENCODER -, m_clk(-1) -#endif // CONFIG_ROTARYENCODER -#ifdef CONFIG_ROTARYENCODER -, m_dt(-1) -#endif // CONFIG_ROTARYENCODER { } @@ -1990,12 +1953,6 @@ int ButtonConfig::setByName(const char *name, const char *value) } RelayConfig::RelayConfig() -: m_name() -, m_min_itv(0) -, m_gpio(-1) -, m_config(0) -, m_interlock(-1) -, p_validbits(0) { } @@ -2332,11 +2289,6 @@ int RelayConfig::setByName(const char *name, const char *value) } Max7219Config::Max7219Config() -: m_clk(-1) -, m_dout(-1) -, m_cs(-1) -, m_odrain(false) -, m_digits(0) { } @@ -2595,11 +2547,6 @@ int Max7219Config::setByName(const char *name, const char *value) } Tlc5947Config::Tlc5947Config() -: m_sin(-1) -, m_sclk(-1) -, m_xlat(-1) -, m_blank(-1) -, m_ntlc(0) { } @@ -2861,10 +2808,6 @@ int Tlc5947Config::setByName(const char *name, const char *value) } Ws2812bConfig::Ws2812bConfig() -: m_name() -, m_gpio(-1) -// omitted unused member ch -, m_nleds(0) { } @@ -3066,8 +3009,6 @@ int Ws2812bConfig::setByName(const char *name, const char *value) } DhtConfig::DhtConfig() -: m_model(DHT_NONE) -, m_gpio(-1) { } @@ -3242,14 +3183,6 @@ int DhtConfig::setByName(const char *name, const char *value) } I2CConfig::I2CConfig() -// omitted unused member freq -#ifdef CONFIG_I2C_XDEV -#endif // CONFIG_I2C_XDEV -: m_port(0) -, m_sda(-1) -, m_scl(-1) -, m_xpullup(false) -, p_validbits(0) { } @@ -3631,9 +3564,6 @@ int I2CConfig::setByName(const char *name, const char *value) } HcSr04Config::HcSr04Config() -: m_name() -, m_trigger(-1) -, m_echo(-1) { } @@ -3833,11 +3763,6 @@ int HcSr04Config::setByName(const char *name, const char *value) } LedConfig::LedConfig() -: m_name() -, m_gpio(-1) -, m_config(0) -, m_pwm_ch(-1) -, p_validbits(0) { } @@ -4105,9 +4030,6 @@ int LedConfig::setByName(const char *name, const char *value) } OneWireConfig::OneWireConfig() -: m_gpio(-1) -, m_pullup(false) -, m_power(-1) { } @@ -4298,11 +4220,6 @@ int OneWireConfig::setByName(const char *name, const char *value) } UartConfig::UartConfig() -: m_port(-1) -// omitted unused member tx_gpio -// omitted unused member rx_gpio -// omitted unused member cts_gpio -// omitted unused member rts_gpio { } @@ -4436,16 +4353,6 @@ int UartConfig::setByName(const char *name, const char *value) } AdcChannel::AdcChannel() -: m_name() -, m_dim() -, m_scale(1) -, m_offset(0) -, m_interval(0) -, m_unit(0) -, m_ch(-1) -, m_atten(0) -, m_window(0) -, p_validbits(0) { } @@ -4526,7 +4433,6 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) return -195; } m_dim.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 3); a += ud.vi; break; default: @@ -4638,7 +4544,7 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has dim? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { // 'dim': id=10, encoding=lenpfx, tag=0x52 if (a >= e) return -214; @@ -4859,22 +4765,12 @@ int AdcChannel::setByName(const char *name, const char *value) } m_dim = value; int r = m_dim.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 3); return r; } return -216; } AdcConfig::AdcConfig() -: m_adc_name() -// omitted unused member hall_name -// omitted unused member adc1_bits -// omitted unused member adc2_bits -, m_mode(0) -, m_clk_div(0) -// omitted unused member channels -, p_validbits(0) { } @@ -5089,10 +4985,6 @@ int AdcConfig::setByName(const char *name, const char *value) } GpioConfig::GpioConfig() -: m_name() -, m_config(0) -, m_gpio(-1) -, p_validbits(0) { } @@ -5158,7 +5050,6 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) return -229; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x10: // gpio id 2, type int8_t, coding signed varint @@ -5188,7 +5079,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -232; @@ -5210,7 +5101,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has config? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) return -236; @@ -5299,8 +5190,6 @@ int GpioConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"gpio")) { @@ -5386,11 +5275,6 @@ int GpioConfig::setByName(const char *name, const char *value) } DisplayConfig::DisplayConfig() -: m_type(dt_none) -, m_options(0) -, m_maxx(0) -, m_maxy(1) -, p_validbits(0) { } @@ -5642,11 +5526,6 @@ int DisplayConfig::setByName(const char *name, const char *value) } SpiDeviceConfig::SpiDeviceConfig() -: m_drv(spidrv_invalid) -, m_cs(-1) -, m_intr(-1) -, m_reset(-1) -, m_cd(-1) { } @@ -5923,15 +5802,6 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) } SpiBusConfig::SpiBusConfig() -: m_host(-1) -, m_mosi(-1) -, m_miso(-1) -, m_sclk(-1) -, m_wp(-1) -, m_hold(-1) -, m_options(0) -, m_dma(-1) -, p_validbits(0) { } @@ -6476,22 +6346,17 @@ int SpiBusConfig::setByName(const char *name, const char *value) return -294; } -Message *SpiBusConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SpiBusConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("devices[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 7) && (0 == memcmp("devices",s,7))) { if (x < m_devices.size()) return &m_devices[x]; - return 0; } return 0; } GpioCluster::GpioCluster() -: m_name() -, m_base(0) -, m_numio(0) -, m_int_a(-1) -, m_int_b(-1) { } @@ -6759,9 +6624,6 @@ int GpioCluster::setByName(const char *name, const char *value) } Hlw8012Config::Hlw8012Config() -: m_sel(-1) -, m_cf(-1) -, m_cf1(-1) { } @@ -6955,12 +6817,6 @@ int Hlw8012Config::setByName(const char *name, const char *value) } SX1276Config::SX1276Config() -: m_dio0(-1) -, m_dio1(-1) -, m_dio2(-1) -, m_dio3(-1) -, m_dio4(-1) -, m_dio5(-1) { } @@ -7256,45 +7112,6 @@ int SX1276Config::setByName(const char *name, const char *value) } HardwareConfig::HardwareConfig() -: m_magic(0) -#ifdef CONFIG_HLW8012 -#endif // CONFIG_HLW8012 -#ifdef CONFIG_DISPLAY -#endif // CONFIG_DISPLAY -#ifdef CONFIG_IOEXTENDERS -#endif // CONFIG_IOEXTENDERS -#ifdef CONFIG_SX1276 -#endif // CONFIG_SX1276 -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -#ifdef CONFIG_HCSR04 -#endif // CONFIG_HCSR04 -#ifdef CONFIG_I2C -#endif // CONFIG_I2C -#ifdef CONFIG_DHT -#endif // CONFIG_DHT -#ifdef CONFIG_RGBLEDS -#endif // CONFIG_RGBLEDS -#ifdef CONFIG_TLC5947 -#endif // CONFIG_TLC5947 -#ifdef CONFIG_MAX7219 -#endif // CONFIG_MAX7219 -#ifdef CONFIG_LEDS -#endif // CONFIG_LEDS -#ifdef CONFIG_RELAY -#endif // CONFIG_RELAY -#ifdef CONFIG_BUTTON -#endif // CONFIG_BUTTON -#ifdef CONFIG_SPI -#endif // CONFIG_SPI -#ifdef CONFIG_TOUCHPAD -// omitted unused member tp_channel -#endif // CONFIG_TOUCHPAD -#ifdef CONFIG_TOUCHPAD -// omitted unused member touchpad -#endif // CONFIG_TOUCHPAD -// omitted unused member uart -, p_validbits(0) { } @@ -8961,106 +8778,91 @@ int HardwareConfig::setByName(const char *name, const char *value) return -422; } -Message *HardwareConfig::p_getMember(const char *s, const char *e) +Message *HardwareConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("system",s,e-s)) + // caller guarantee: s[n] == '.' + if ((n == 6) && (0 == memcmp("system",s,6))) return &m_system; - if (0 == strncmp("adc",s,e-s)) + if ((n == 3) && (0 == memcmp("adc",s,3))) return &m_adc; #ifdef CONFIG_HLW8012 - if (0 == strncmp("hlw8012",s,e-s)) + if ((n == 7) && (0 == memcmp("hlw8012",s,7))) return &m_hlw8012; #endif // CONFIG_HLW8012 #ifdef CONFIG_MAX7219 - if (0 == strncmp("max7219",s,e-s)) + if ((n == 7) && (0 == memcmp("max7219",s,7))) return &m_max7219; #endif // CONFIG_MAX7219 #ifdef CONFIG_TLC5947 - if (0 == strncmp("tlc5947",s,e-s)) + if ((n == 7) && (0 == memcmp("tlc5947",s,7))) return &m_tlc5947; #endif // CONFIG_TLC5947 #ifdef CONFIG_DHT - if (0 == strncmp("dht",s,e-s)) + if ((n == 3) && (0 == memcmp("dht",s,3))) return &m_dht; #endif // CONFIG_DHT #ifdef CONFIG_ONEWIRE - if (0 == strncmp("onewire",s,e-s)) + if ((n == 7) && (0 == memcmp("onewire",s,7))) return &m_onewire; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 - if (0 == strncmp("sx1276",s,e-s)) + if ((n == 6) && (0 == memcmp("sx1276",s,6))) return &m_sx1276; #endif // CONFIG_SX1276 #ifdef CONFIG_DISPLAY - if (0 == strncmp("display",s,e-s)) + if ((n == 7) && (0 == memcmp("display",s,7))) return &m_display; #endif // CONFIG_DISPLAY return 0; } -Message *HardwareConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *HardwareConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("gpios[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 5) && (0 == memcmp("gpios",s,5))) { if (x < m_gpios.size()) return &m_gpios[x]; - return 0; - } - #ifdef CONFIG_SPI - if (0 == strncmp("spibus[",s,e-s)) { + #ifdef CONFIG_SPI + } else if ((n == 6) && (0 == memcmp("spibus",s,6))) { if (x < m_spibus.size()) return &m_spibus[x]; - return 0; - } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON - if (0 == strncmp("button[",s,e-s)) { + #endif // CONFIG_SPI + #ifdef CONFIG_BUTTON + } else if ((n == 6) && (0 == memcmp("button",s,6))) { if (x < m_button.size()) return &m_button[x]; - return 0; - } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY - if (0 == strncmp("relay[",s,e-s)) { + #endif // CONFIG_BUTTON + #ifdef CONFIG_RELAY + } else if ((n == 5) && (0 == memcmp("relay",s,5))) { if (x < m_relay.size()) return &m_relay[x]; - return 0; - } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS - if (0 == strncmp("led[",s,e-s)) { + #endif // CONFIG_RELAY + #ifdef CONFIG_LEDS + } else if ((n == 3) && (0 == memcmp("led",s,3))) { if (x < m_led.size()) return &m_led[x]; - return 0; - } - #endif // CONFIG_LEDS - #ifdef CONFIG_RGBLEDS - if (0 == strncmp("ws2812b[",s,e-s)) { + #endif // CONFIG_LEDS + #ifdef CONFIG_RGBLEDS + } else if ((n == 7) && (0 == memcmp("ws2812b",s,7))) { if (x < m_ws2812b.size()) return &m_ws2812b[x]; - return 0; - } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_I2C - if (0 == strncmp("i2c[",s,e-s)) { + #endif // CONFIG_RGBLEDS + #ifdef CONFIG_I2C + } else if ((n == 3) && (0 == memcmp("i2c",s,3))) { if (x < m_i2c.size()) return &m_i2c[x]; - return 0; - } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 - if (0 == strncmp("hcsr04[",s,e-s)) { + #endif // CONFIG_I2C + #ifdef CONFIG_HCSR04 + } else if ((n == 6) && (0 == memcmp("hcsr04",s,6))) { if (x < m_hcsr04.size()) return &m_hcsr04[x]; - return 0; - } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_IOEXTENDERS - if (0 == strncmp("iocluster[",s,e-s)) { + #endif // CONFIG_HCSR04 + #ifdef CONFIG_IOEXTENDERS + } else if ((n == 9) && (0 == memcmp("iocluster",s,9))) { if (x < m_iocluster.size()) return &m_iocluster[x]; - return 0; + #endif // CONFIG_IOEXTENDERS } - #endif // CONFIG_IOEXTENDERS return 0; } diff --git a/components/wfc/hwcfg_esp8266.h b/components/wfc/hwcfg_esp8266.h index 54ad30d..6833351 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -211,11 +211,12 @@ typedef uint16_t i2cdev_t; typedef uint8_t ledcfg_t; typedef uint16_t gpiocfg_t; typedef uint8_t spiopt_t; + + class SystemConfig : public Message { public: SystemConfig(); - bool operator == (const SystemConfig &r) const; //! Function for resetting all members to their default values. @@ -511,30 +512,31 @@ class SystemConfig : public Message //! string model_number, id 8 estring m_model_number; //! sint8 diag_uart, id 4 - int8_t m_diag_uart; + int8_t m_diag_uart = 0; //! sint8 console_rx, id 5 - int8_t m_console_rx; + int8_t m_console_rx = 0; //! sint8 console_tx, id 6 - int8_t m_console_tx; + int8_t m_console_tx = 0; #ifdef CONFIG_USB_DIAGLOG //! bool usb_diag, id 9 - bool m_usb_diag; + bool m_usb_diag = true; #endif // CONFIG_USB_DIAGLOG #ifdef CONFIG_USB_CONSOLE //! bool usb_con, id 10 - bool m_usb_con; + bool m_usb_con = true; #endif // CONFIG_USB_CONSOLE private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchpadConfig : public Message { public: TouchpadConfig(); - bool operator == (const TouchpadConfig &r) const; //! Function for resetting all members to their default values. @@ -686,26 +688,27 @@ class TouchpadConfig : public Message protected: //! unsigned interval, id 7 - uint32_t m_interval; + uint32_t m_interval = 0; //! bool fsm_mode, id 1 - bool m_fsm_mode; + bool m_fsm_mode = false; //! sint8 lvolt, id 2 - int8_t m_lvolt; + int8_t m_lvolt = -1; //! sint8 hvolt, id 3 - int8_t m_hvolt; + int8_t m_hvolt = -1; //! sint8 atten, id 4 - int8_t m_atten; + int8_t m_atten = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchChannelConfig : public Message { public: TouchChannelConfig(); - bool operator == (const TouchChannelConfig &r) const; //! Function for resetting all members to their default values. @@ -867,24 +870,25 @@ class TouchChannelConfig : public Message //! string name, id 1 estring m_name; //! fixed16 threshold, id 3 - uint16_t m_threshold; + uint16_t m_threshold = 0; //! sint8 channel, id 2 - int8_t m_channel; + int8_t m_channel = -1; //! uint8 slope, id 4 - uint8_t m_slope; + uint8_t m_slope = 0; //! uint8 tieopt, id 5 - uint8_t m_tieopt; + uint8_t m_tieopt = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ButtonConfig : public Message { public: ButtonConfig(); - bool operator == (const ButtonConfig &r) const; //! Function for resetting all members to their default values. @@ -1076,27 +1080,28 @@ class ButtonConfig : public Message //! string name, id 1 estring m_name; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool presslvl, id 3 - bool m_presslvl; + bool m_presslvl = 0; //! pull_mode_t pull_mode, id 4 - pull_mode_t m_pull_mode; + pull_mode_t m_pull_mode = pull_none; #ifdef CONFIG_ROTARYENCODER //! sint8 clk, id 5 - int8_t m_clk; + int8_t m_clk = -1; #endif // CONFIG_ROTARYENCODER #ifdef CONFIG_ROTARYENCODER //! sint8 dt, id 6 - int8_t m_dt; + int8_t m_dt = -1; #endif // CONFIG_ROTARYENCODER }; + + class RelayConfig : public Message { public: RelayConfig(); - bool operator == (const RelayConfig &r) const; //! Function for resetting all members to their default values. @@ -1278,24 +1283,25 @@ class RelayConfig : public Message //! string name, id 1 estring m_name; //! unsigned min_itv, id 4 - uint32_t m_min_itv; + uint32_t m_min_itv = 0; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! relay_cfg_t config, id 3 - relay_cfg_t m_config; + relay_cfg_t m_config = 0; //! sint8 interlock, id 5 - int8_t m_interlock; + int8_t m_interlock = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Max7219Config : public Message { public: Max7219Config(); - bool operator == (const Max7219Config &r) const; //! Function for resetting all members to their default values. @@ -1447,23 +1453,24 @@ class Max7219Config : public Message protected: //! sint8 clk, id 1 - int8_t m_clk; + int8_t m_clk = -1; //! sint8 dout, id 2 - int8_t m_dout; + int8_t m_dout = -1; //! sint8 cs, id 3 - int8_t m_cs; + int8_t m_cs = -1; //! bool odrain, id 4 - bool m_odrain; + bool m_odrain = false; //! uint8 digits, id 5 - uint8_t m_digits; + uint8_t m_digits = 0; }; + + class Tlc5947Config : public Message { public: Tlc5947Config(); - bool operator == (const Tlc5947Config &r) const; //! Function for resetting all members to their default values. @@ -1615,23 +1622,24 @@ class Tlc5947Config : public Message protected: //! sint8 sin, id 1 - int8_t m_sin; + int8_t m_sin = -1; //! sint8 sclk, id 2 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 xlat, id 3 - int8_t m_xlat; + int8_t m_xlat = -1; //! sint8 blank, id 4 - int8_t m_blank; + int8_t m_blank = -1; //! uint8 ntlc, id 5 - uint8_t m_ntlc; + uint8_t m_ntlc = 0; }; + + class Ws2812bConfig : public Message { public: Ws2812bConfig(); - bool operator == (const Ws2812bConfig &r) const; //! Function for resetting all members to their default values. @@ -1758,18 +1766,18 @@ class Ws2812bConfig : public Message //! string name, id 4 estring m_name; //! sint8 gpio, id 1 - int8_t m_gpio; - // omitted unused member ch + int8_t m_gpio = -1; //! uint8 nleds, id 3 - uint8_t m_nleds; + uint8_t m_nleds = 0; }; + + class DhtConfig : public Message { public: DhtConfig(); - bool operator == (const DhtConfig &r) const; //! Function for resetting all members to their default values. @@ -1867,17 +1875,18 @@ class DhtConfig : public Message protected: //! dht_model_t model, id 1 - dht_model_t m_model; + dht_model_t m_model = DHT_NONE; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; }; + + class I2CConfig : public Message { public: I2CConfig(); - bool operator == (const I2CConfig &r) const; //! Function for resetting all members to their default values. @@ -2045,30 +2054,30 @@ class I2CConfig : public Message protected: - // omitted unused member freq #ifdef CONFIG_I2C_XDEV //! i2cdev_t devices, id 6 std::vector m_devices; #endif // CONFIG_I2C_XDEV //! uint8 port, id 1 - uint8_t m_port; + uint8_t m_port = 0; //! sint8 sda, id 2 - int8_t m_sda; + int8_t m_sda = -1; //! sint8 scl, id 3 - int8_t m_scl; + int8_t m_scl = -1; //! bool xpullup, id 5 - bool m_xpullup; + bool m_xpullup = false; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class HcSr04Config : public Message { public: HcSr04Config(); - bool operator == (const HcSr04Config &r) const; //! Function for resetting all members to their default values. @@ -2194,17 +2203,18 @@ class HcSr04Config : public Message //! string name, id 3 estring m_name; //! sint8 trigger, id 1 - int8_t m_trigger; + int8_t m_trigger = -1; //! sint8 echo, id 2 - int8_t m_echo; + int8_t m_echo = -1; }; + + class LedConfig : public Message { public: LedConfig(); - bool operator == (const LedConfig &r) const; //! Function for resetting all members to their default values. @@ -2356,22 +2366,23 @@ class LedConfig : public Message //! string name, id 3 estring m_name; //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! ledcfg_t config, id 2 - ledcfg_t m_config; + ledcfg_t m_config = 0; //! sint8 pwm_ch, id 4 - int8_t m_pwm_ch; + int8_t m_pwm_ch = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class OneWireConfig : public Message { public: OneWireConfig(); - bool operator == (const OneWireConfig &r) const; //! Function for resetting all members to their default values. @@ -2487,19 +2498,20 @@ class OneWireConfig : public Message protected: //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool pullup, id 2 - bool m_pullup; + bool m_pullup = false; //! sint8 power, id 3 - int8_t m_power; + int8_t m_power = -1; }; + + class UartConfig : public Message { public: UartConfig(); - bool operator == (const UartConfig &r) const; //! Function for resetting all members to their default values. @@ -2583,19 +2595,16 @@ class UartConfig : public Message protected: //! sint8 port, id 1 - int8_t m_port; - // omitted unused member tx_gpio - // omitted unused member rx_gpio - // omitted unused member cts_gpio - // omitted unused member rts_gpio + int8_t m_port = -1; }; + + class AdcChannel : public Message { public: AdcChannel(); - bool operator == (const AdcChannel &r) const; //! Function for resetting all members to their default values. @@ -2839,30 +2848,31 @@ class AdcChannel : public Message //! string dim, id 10 estring m_dim; //! float scale, id 8 - float m_scale; + float m_scale = 1; //! float offset, id 9 - float m_offset; + float m_offset = 0; //! uint16 interval, id 5 - uint16_t m_interval; + uint16_t m_interval = 0; //! uint8 unit, id 2 - uint8_t m_unit; + uint8_t m_unit = 0; //! sint8 ch, id 3 - int8_t m_ch; + int8_t m_ch = -1; //! uint8 atten, id 4 - uint8_t m_atten; + uint8_t m_atten = 0; //! uint8 window, id 6 - uint8_t m_window; + uint8_t m_window = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class AdcConfig : public Message { public: AdcConfig(); - bool operator == (const AdcConfig &r) const; //! Function for resetting all members to their default values. @@ -2991,25 +3001,22 @@ class AdcConfig : public Message protected: //! string adc_name, id 1 estring m_adc_name; - // omitted unused member hall_name - // omitted unused member adc1_bits - // omitted unused member adc2_bits //! uint8 mode, id 4 - uint8_t m_mode; + uint8_t m_mode = 0; //! uint8 clk_div, id 5 - uint8_t m_clk_div; - // omitted unused member channels + uint8_t m_clk_div = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioConfig : public Message { public: GpioConfig(); - bool operator == (const GpioConfig &r) const; //! Function for resetting all members to their default values. @@ -3163,20 +3170,21 @@ class GpioConfig : public Message //! string name, id 1 estring m_name; //! gpiocfg_t config, id 3 - gpiocfg_t m_config; + gpiocfg_t m_config = 0; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class DisplayConfig : public Message { public: DisplayConfig(); - bool operator == (const DisplayConfig &r) const; //! Function for resetting all members to their default values. @@ -3310,24 +3318,25 @@ class DisplayConfig : public Message protected: //! disp_t type, id 1 - disp_t m_type; + disp_t m_type = dt_none; //! unsigned options, id 2 - uint32_t m_options; + uint32_t m_options = 0; //! unsigned maxx, id 3 - uint32_t m_maxx; + uint32_t m_maxx = 0; //! unsigned maxy, id 4 - uint32_t m_maxy; + uint32_t m_maxy = 1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class SpiDeviceConfig : public Message { public: SpiDeviceConfig(); - bool operator == (const SpiDeviceConfig &r) const; //! Function for resetting all members to their default values. @@ -3479,23 +3488,24 @@ class SpiDeviceConfig : public Message protected: //! spidrv_t drv, id 1 - spidrv_t m_drv; + spidrv_t m_drv = spidrv_invalid; //! sint8 cs, id 2 - int8_t m_cs; + int8_t m_cs = -1; //! sint8 intr, id 3 - int8_t m_intr; + int8_t m_intr = -1; //! sint8 reset, id 4 - int8_t m_reset; + int8_t m_reset = -1; //! sint8 cd, id 5 - int8_t m_cd; + int8_t m_cd = -1; }; + + class SpiBusConfig : public Message { public: SpiBusConfig(); - bool operator == (const SpiBusConfig &r) const; //! Function for resetting all members to their default values. @@ -3752,36 +3762,37 @@ class SpiBusConfig : public Message protected: - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 host, id 1 - int8_t m_host; + int8_t m_host = -1; //! sint8 mosi, id 2 - int8_t m_mosi; + int8_t m_mosi = -1; //! sint8 miso, id 3 - int8_t m_miso; + int8_t m_miso = -1; //! sint8 sclk, id 4 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 wp, id 5 - int8_t m_wp; + int8_t m_wp = -1; //! sint8 hold, id 6 - int8_t m_hold; + int8_t m_hold = -1; //! spiopt_t options, id 7 - spiopt_t m_options; + spiopt_t m_options = 0; //! sint8 dma, id 8 - int8_t m_dma; + int8_t m_dma = -1; //! SpiDeviceConfig devices, id 9 std::vector m_devices; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioCluster : public Message { public: GpioCluster(); - bool operator == (const GpioCluster &r) const; //! Function for resetting all members to their default values. @@ -3943,21 +3954,22 @@ class GpioCluster : public Message //! string name, id 1 estring m_name; //! uint8 base, id 2 - uint8_t m_base; + uint8_t m_base = 0; //! uint8 numio, id 3 - uint8_t m_numio; + uint8_t m_numio = 0; //! sint8 int_a, id 4 - int8_t m_int_a; + int8_t m_int_a = -1; //! sint8 int_b, id 5 - int8_t m_int_b; + int8_t m_int_b = -1; }; + + class Hlw8012Config : public Message { public: Hlw8012Config(); - bool operator == (const Hlw8012Config &r) const; //! Function for resetting all members to their default values. @@ -4073,19 +4085,20 @@ class Hlw8012Config : public Message protected: //! sint8 sel, id 2 - int8_t m_sel; + int8_t m_sel = -1; //! sint8 cf, id 3 - int8_t m_cf; + int8_t m_cf = -1; //! sint8 cf1, id 4 - int8_t m_cf1; + int8_t m_cf1 = -1; }; + + class SX1276Config : public Message { public: SX1276Config(); - bool operator == (const SX1276Config &r) const; //! Function for resetting all members to their default values. @@ -4255,25 +4268,26 @@ class SX1276Config : public Message protected: //! sint8 dio0, id 1 - int8_t m_dio0; + int8_t m_dio0 = -1; //! sint8 dio1, id 2 - int8_t m_dio1; + int8_t m_dio1 = -1; //! sint8 dio2, id 3 - int8_t m_dio2; + int8_t m_dio2 = -1; //! sint8 dio3, id 4 - int8_t m_dio3; + int8_t m_dio3 = -1; //! sint8 dio4, id 5 - int8_t m_dio4; + int8_t m_dio4 = -1; //! sint8 dio5, id 6 - int8_t m_dio5; + int8_t m_dio5 = -1; }; + + class HardwareConfig : public Message { public: HardwareConfig(); - bool operator == (const HardwareConfig &r) const; //! Function for resetting all members to their default values. @@ -4821,10 +4835,10 @@ class HardwareConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! fixed32 magic, id 0 - uint32_t m_magic; + uint32_t m_magic = 0; #ifdef CONFIG_HLW8012 //! Hlw8012Config hlw8012, id 20 Hlw8012Config m_hlw8012; @@ -4887,20 +4901,13 @@ class HardwareConfig : public Message #endif // CONFIG_SPI //! GpioConfig gpios, id 7 std::vector m_gpios; - #ifdef CONFIG_TOUCHPAD - // omitted unused member tp_channel - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD - // omitted unused member touchpad - #endif // CONFIG_TOUCHPAD //! AdcConfig adc, id 4 AdcConfig m_adc; - // omitted unused member uart //! SystemConfig system, id 1 SystemConfig m_system; private: - uint16_t p_validbits; + uint16_t p_validbits = 0; }; @@ -7576,7 +7583,7 @@ inline const estring &AdcChannel::dim() const inline bool AdcChannel::has_dim() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return !m_dim.empty(); } /*! @@ -7585,35 +7592,27 @@ inline bool AdcChannel::has_dim() const */ 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); } @@ -7760,7 +7759,7 @@ inline const estring &GpioConfig::name() const inline bool GpioConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -7769,35 +7768,27 @@ inline bool GpioConfig::has_name() const */ inline void GpioConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *GpioConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void GpioConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -7875,7 +7866,7 @@ inline bool GpioConfig::config_cap_freq_r2r() const inline bool GpioConfig::has_config() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -7884,14 +7875,14 @@ inline bool GpioConfig::has_config() const */ inline void GpioConfig::clear_config() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_config = 0; } inline gpiocfg_t *GpioConfig::mutable_config() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_config = 0; } return &m_config; @@ -7901,55 +7892,55 @@ inline void GpioConfig::set_config_mode(uint8_t v) { m_config &= ~(0x3ULL << 0); m_config |= ((uint16_t) v << 0); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_intrtype(uint8_t v) { m_config &= ~(0x7ULL << 2); m_config |= ((uint16_t) v << 2); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_setinit(bool v) { m_config &= ~(0x1ULL << 5); m_config |= ((uint16_t) v << 5); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_initlvl(bool v) { m_config &= ~(0x1ULL << 6); m_config |= ((uint16_t) v << 6); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pullup(bool v) { m_config &= ~(0x1ULL << 7); m_config |= ((uint16_t) v << 7); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pulldown(bool v) { m_config &= ~(0x1ULL << 8); m_config |= ((uint16_t) v << 8); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_cap_freq_r2r(bool v) { m_config &= ~(0x1ULL << 9); m_config |= ((uint16_t) v << 9); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config(gpiocfg_t v) { m_config = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } diff --git a/components/wfc/hwcfg_esp8285.cpp b/components/wfc/hwcfg_esp8285.cpp index 634797f..d247609 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -563,21 +563,6 @@ const char *spidrv_t_str(spidrv_t e) } SystemConfig::SystemConfig() -: m_manufacturer() -, m_board_name() -, m_board_rev() -, m_model_name() -, m_model_number() -, m_diag_uart(0) -, m_console_rx(0) -, m_console_tx(0) -#ifdef CONFIG_USB_DIAGLOG -, m_usb_diag(true) -#endif // CONFIG_USB_DIAGLOG -#ifdef CONFIG_USB_CONSOLE -, m_usb_con(true) -#endif // CONFIG_USB_CONSOLE -, p_validbits(0) { } @@ -1072,12 +1057,6 @@ int SystemConfig::setByName(const char *name, const char *value) } TouchpadConfig::TouchpadConfig() -: m_interval(0) -, m_fsm_mode(false) -, m_lvolt(-1) -, m_hvolt(-1) -, m_atten(-1) -, p_validbits(0) { } @@ -1341,12 +1320,6 @@ int TouchpadConfig::setByName(const char *name, const char *value) } TouchChannelConfig::TouchChannelConfig() -: m_name() -, m_threshold(0) -, m_channel(-1) -, m_slope(0) -, m_tieopt(0) -, p_validbits(0) { } @@ -1621,16 +1594,6 @@ int TouchChannelConfig::setByName(const char *name, const char *value) } ButtonConfig::ButtonConfig() -: m_name() -, m_gpio(-1) -, m_presslvl(0) -, m_pull_mode(pull_none) -#ifdef CONFIG_ROTARYENCODER -, m_clk(-1) -#endif // CONFIG_ROTARYENCODER -#ifdef CONFIG_ROTARYENCODER -, m_dt(-1) -#endif // CONFIG_ROTARYENCODER { } @@ -1992,12 +1955,6 @@ int ButtonConfig::setByName(const char *name, const char *value) } RelayConfig::RelayConfig() -: m_name() -, m_min_itv(0) -, m_gpio(-1) -, m_config(0) -, m_interlock(-1) -, p_validbits(0) { } @@ -2334,11 +2291,6 @@ int RelayConfig::setByName(const char *name, const char *value) } Max7219Config::Max7219Config() -: m_clk(-1) -, m_dout(-1) -, m_cs(-1) -, m_odrain(false) -, m_digits(0) { } @@ -2597,11 +2549,6 @@ int Max7219Config::setByName(const char *name, const char *value) } Tlc5947Config::Tlc5947Config() -: m_sin(-1) -, m_sclk(-1) -, m_xlat(-1) -, m_blank(-1) -, m_ntlc(0) { } @@ -2863,10 +2810,6 @@ int Tlc5947Config::setByName(const char *name, const char *value) } Ws2812bConfig::Ws2812bConfig() -: m_name() -, m_gpio(-1) -// omitted unused member ch -, m_nleds(0) { } @@ -3068,8 +3011,6 @@ int Ws2812bConfig::setByName(const char *name, const char *value) } DhtConfig::DhtConfig() -: m_model(DHT_NONE) -, m_gpio(-1) { } @@ -3244,14 +3185,6 @@ int DhtConfig::setByName(const char *name, const char *value) } I2CConfig::I2CConfig() -// omitted unused member freq -#ifdef CONFIG_I2C_XDEV -#endif // CONFIG_I2C_XDEV -: m_port(0) -, m_sda(-1) -, m_scl(-1) -, m_xpullup(false) -, p_validbits(0) { } @@ -3633,9 +3566,6 @@ int I2CConfig::setByName(const char *name, const char *value) } HcSr04Config::HcSr04Config() -: m_name() -, m_trigger(-1) -, m_echo(-1) { } @@ -3835,11 +3765,6 @@ int HcSr04Config::setByName(const char *name, const char *value) } LedConfig::LedConfig() -: m_name() -, m_gpio(-1) -, m_config(0) -, m_pwm_ch(-1) -, p_validbits(0) { } @@ -4107,9 +4032,6 @@ int LedConfig::setByName(const char *name, const char *value) } OneWireConfig::OneWireConfig() -: m_gpio(-1) -, m_pullup(false) -, m_power(-1) { } @@ -4300,11 +4222,6 @@ int OneWireConfig::setByName(const char *name, const char *value) } UartConfig::UartConfig() -: m_port(-1) -// omitted unused member tx_gpio -// omitted unused member rx_gpio -// omitted unused member cts_gpio -// omitted unused member rts_gpio { } @@ -4438,16 +4355,6 @@ int UartConfig::setByName(const char *name, const char *value) } AdcChannel::AdcChannel() -: m_name() -, m_dim() -, m_scale(1) -, m_offset(0) -, m_interval(0) -, m_unit(0) -, m_ch(-1) -, m_atten(0) -, m_window(0) -, p_validbits(0) { } @@ -4528,7 +4435,6 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) return -195; } m_dim.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 3); a += ud.vi; break; default: @@ -4640,7 +4546,7 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has dim? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { // 'dim': id=10, encoding=lenpfx, tag=0x52 if (a >= e) return -214; @@ -4861,22 +4767,12 @@ int AdcChannel::setByName(const char *name, const char *value) } m_dim = value; int r = m_dim.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 3); return r; } return -216; } AdcConfig::AdcConfig() -: m_adc_name() -// omitted unused member hall_name -// omitted unused member adc1_bits -// omitted unused member adc2_bits -, m_mode(0) -, m_clk_div(0) -// omitted unused member channels -, p_validbits(0) { } @@ -5091,10 +4987,6 @@ int AdcConfig::setByName(const char *name, const char *value) } GpioConfig::GpioConfig() -: m_name() -, m_config(0) -, m_gpio(-1) -, p_validbits(0) { } @@ -5160,7 +5052,6 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) return -229; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x10: // gpio id 2, type int8_t, coding signed varint @@ -5190,7 +5081,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -232; @@ -5212,7 +5103,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has config? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) return -236; @@ -5301,8 +5192,6 @@ int GpioConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"gpio")) { @@ -5388,11 +5277,6 @@ int GpioConfig::setByName(const char *name, const char *value) } DisplayConfig::DisplayConfig() -: m_type(dt_none) -, m_options(0) -, m_maxx(0) -, m_maxy(1) -, p_validbits(0) { } @@ -5644,11 +5528,6 @@ int DisplayConfig::setByName(const char *name, const char *value) } SpiDeviceConfig::SpiDeviceConfig() -: m_drv(spidrv_invalid) -, m_cs(-1) -, m_intr(-1) -, m_reset(-1) -, m_cd(-1) { } @@ -5925,15 +5804,6 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) } SpiBusConfig::SpiBusConfig() -: m_host(-1) -, m_mosi(-1) -, m_miso(-1) -, m_sclk(-1) -, m_wp(-1) -, m_hold(-1) -, m_options(0) -, m_dma(-1) -, p_validbits(0) { } @@ -6479,11 +6349,6 @@ int SpiBusConfig::setByName(const char *name, const char *value) } GpioCluster::GpioCluster() -: m_name() -, m_base(0) -, m_numio(0) -, m_int_a(-1) -, m_int_b(-1) { } @@ -6751,9 +6616,6 @@ int GpioCluster::setByName(const char *name, const char *value) } Hlw8012Config::Hlw8012Config() -: m_sel(-1) -, m_cf(-1) -, m_cf1(-1) { } @@ -6947,12 +6809,6 @@ int Hlw8012Config::setByName(const char *name, const char *value) } SX1276Config::SX1276Config() -: m_dio0(-1) -, m_dio1(-1) -, m_dio2(-1) -, m_dio3(-1) -, m_dio4(-1) -, m_dio5(-1) { } @@ -7248,45 +7104,6 @@ int SX1276Config::setByName(const char *name, const char *value) } HardwareConfig::HardwareConfig() -: m_magic(0) -#ifdef CONFIG_HLW8012 -#endif // CONFIG_HLW8012 -#ifdef CONFIG_DISPLAY -#endif // CONFIG_DISPLAY -#ifdef CONFIG_IOEXTENDERS -#endif // CONFIG_IOEXTENDERS -#ifdef CONFIG_SX1276 -#endif // CONFIG_SX1276 -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -#ifdef CONFIG_HCSR04 -#endif // CONFIG_HCSR04 -#ifdef CONFIG_I2C -#endif // CONFIG_I2C -#ifdef CONFIG_DHT -#endif // CONFIG_DHT -#ifdef CONFIG_RGBLEDS -#endif // CONFIG_RGBLEDS -#ifdef CONFIG_TLC5947 -#endif // CONFIG_TLC5947 -#ifdef CONFIG_MAX7219 -#endif // CONFIG_MAX7219 -#ifdef CONFIG_LEDS -#endif // CONFIG_LEDS -#ifdef CONFIG_RELAY -#endif // CONFIG_RELAY -#ifdef CONFIG_BUTTON -#endif // CONFIG_BUTTON -#ifdef CONFIG_SPI -#endif // CONFIG_SPI -#ifdef CONFIG_TOUCHPAD -// omitted unused member tp_channel -#endif // CONFIG_TOUCHPAD -#ifdef CONFIG_TOUCHPAD -// omitted unused member touchpad -#endif // CONFIG_TOUCHPAD -// omitted unused member uart -, p_validbits(0) { } diff --git a/components/wfc/hwcfg_esp8285.h b/components/wfc/hwcfg_esp8285.h index d01169a..e633373 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -212,11 +212,12 @@ typedef uint16_t i2cdev_t; typedef uint8_t ledcfg_t; typedef uint16_t gpiocfg_t; typedef uint8_t spiopt_t; + + class SystemConfig { public: SystemConfig(); - bool operator == (const SystemConfig &r) const; //! Function for resetting all members to their default values. @@ -512,30 +513,31 @@ class SystemConfig //! string model_number, id 8 estring m_model_number; //! sint8 diag_uart, id 4 - int8_t m_diag_uart; + int8_t m_diag_uart = 0; //! sint8 console_rx, id 5 - int8_t m_console_rx; + int8_t m_console_rx = 0; //! sint8 console_tx, id 6 - int8_t m_console_tx; + int8_t m_console_tx = 0; #ifdef CONFIG_USB_DIAGLOG //! bool usb_diag, id 9 - bool m_usb_diag; + bool m_usb_diag = true; #endif // CONFIG_USB_DIAGLOG #ifdef CONFIG_USB_CONSOLE //! bool usb_con, id 10 - bool m_usb_con; + bool m_usb_con = true; #endif // CONFIG_USB_CONSOLE private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchpadConfig { public: TouchpadConfig(); - bool operator == (const TouchpadConfig &r) const; //! Function for resetting all members to their default values. @@ -687,26 +689,27 @@ class TouchpadConfig protected: //! unsigned interval, id 7 - uint32_t m_interval; + uint32_t m_interval = 0; //! bool fsm_mode, id 1 - bool m_fsm_mode; + bool m_fsm_mode = false; //! sint8 lvolt, id 2 - int8_t m_lvolt; + int8_t m_lvolt = -1; //! sint8 hvolt, id 3 - int8_t m_hvolt; + int8_t m_hvolt = -1; //! sint8 atten, id 4 - int8_t m_atten; + int8_t m_atten = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchChannelConfig { public: TouchChannelConfig(); - bool operator == (const TouchChannelConfig &r) const; //! Function for resetting all members to their default values. @@ -868,24 +871,25 @@ class TouchChannelConfig //! string name, id 1 estring m_name; //! fixed16 threshold, id 3 - uint16_t m_threshold; + uint16_t m_threshold = 0; //! sint8 channel, id 2 - int8_t m_channel; + int8_t m_channel = -1; //! uint8 slope, id 4 - uint8_t m_slope; + uint8_t m_slope = 0; //! uint8 tieopt, id 5 - uint8_t m_tieopt; + uint8_t m_tieopt = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ButtonConfig { public: ButtonConfig(); - bool operator == (const ButtonConfig &r) const; //! Function for resetting all members to their default values. @@ -1077,27 +1081,28 @@ class ButtonConfig //! string name, id 1 estring m_name; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool presslvl, id 3 - bool m_presslvl; + bool m_presslvl = 0; //! pull_mode_t pull_mode, id 4 - pull_mode_t m_pull_mode; + pull_mode_t m_pull_mode = pull_none; #ifdef CONFIG_ROTARYENCODER //! sint8 clk, id 5 - int8_t m_clk; + int8_t m_clk = -1; #endif // CONFIG_ROTARYENCODER #ifdef CONFIG_ROTARYENCODER //! sint8 dt, id 6 - int8_t m_dt; + int8_t m_dt = -1; #endif // CONFIG_ROTARYENCODER }; + + class RelayConfig { public: RelayConfig(); - bool operator == (const RelayConfig &r) const; //! Function for resetting all members to their default values. @@ -1279,24 +1284,25 @@ class RelayConfig //! string name, id 1 estring m_name; //! unsigned min_itv, id 4 - uint32_t m_min_itv; + uint32_t m_min_itv = 0; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! relay_cfg_t config, id 3 - relay_cfg_t m_config; + relay_cfg_t m_config = 0; //! sint8 interlock, id 5 - int8_t m_interlock; + int8_t m_interlock = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Max7219Config { public: Max7219Config(); - bool operator == (const Max7219Config &r) const; //! Function for resetting all members to their default values. @@ -1448,23 +1454,24 @@ class Max7219Config protected: //! sint8 clk, id 1 - int8_t m_clk; + int8_t m_clk = -1; //! sint8 dout, id 2 - int8_t m_dout; + int8_t m_dout = -1; //! sint8 cs, id 3 - int8_t m_cs; + int8_t m_cs = -1; //! bool odrain, id 4 - bool m_odrain; + bool m_odrain = false; //! uint8 digits, id 5 - uint8_t m_digits; + uint8_t m_digits = 0; }; + + class Tlc5947Config { public: Tlc5947Config(); - bool operator == (const Tlc5947Config &r) const; //! Function for resetting all members to their default values. @@ -1616,23 +1623,24 @@ class Tlc5947Config protected: //! sint8 sin, id 1 - int8_t m_sin; + int8_t m_sin = -1; //! sint8 sclk, id 2 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 xlat, id 3 - int8_t m_xlat; + int8_t m_xlat = -1; //! sint8 blank, id 4 - int8_t m_blank; + int8_t m_blank = -1; //! uint8 ntlc, id 5 - uint8_t m_ntlc; + uint8_t m_ntlc = 0; }; + + class Ws2812bConfig { public: Ws2812bConfig(); - bool operator == (const Ws2812bConfig &r) const; //! Function for resetting all members to their default values. @@ -1759,18 +1767,18 @@ class Ws2812bConfig //! string name, id 4 estring m_name; //! sint8 gpio, id 1 - int8_t m_gpio; - // omitted unused member ch + int8_t m_gpio = -1; //! uint8 nleds, id 3 - uint8_t m_nleds; + uint8_t m_nleds = 0; }; + + class DhtConfig { public: DhtConfig(); - bool operator == (const DhtConfig &r) const; //! Function for resetting all members to their default values. @@ -1868,17 +1876,18 @@ class DhtConfig protected: //! dht_model_t model, id 1 - dht_model_t m_model; + dht_model_t m_model = DHT_NONE; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; }; + + class I2CConfig { public: I2CConfig(); - bool operator == (const I2CConfig &r) const; //! Function for resetting all members to their default values. @@ -2046,30 +2055,30 @@ class I2CConfig protected: - // omitted unused member freq #ifdef CONFIG_I2C_XDEV //! i2cdev_t devices, id 6 std::vector m_devices; #endif // CONFIG_I2C_XDEV //! uint8 port, id 1 - uint8_t m_port; + uint8_t m_port = 0; //! sint8 sda, id 2 - int8_t m_sda; + int8_t m_sda = -1; //! sint8 scl, id 3 - int8_t m_scl; + int8_t m_scl = -1; //! bool xpullup, id 5 - bool m_xpullup; + bool m_xpullup = false; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class HcSr04Config { public: HcSr04Config(); - bool operator == (const HcSr04Config &r) const; //! Function for resetting all members to their default values. @@ -2195,17 +2204,18 @@ class HcSr04Config //! string name, id 3 estring m_name; //! sint8 trigger, id 1 - int8_t m_trigger; + int8_t m_trigger = -1; //! sint8 echo, id 2 - int8_t m_echo; + int8_t m_echo = -1; }; + + class LedConfig { public: LedConfig(); - bool operator == (const LedConfig &r) const; //! Function for resetting all members to their default values. @@ -2357,22 +2367,23 @@ class LedConfig //! string name, id 3 estring m_name; //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! ledcfg_t config, id 2 - ledcfg_t m_config; + ledcfg_t m_config = 0; //! sint8 pwm_ch, id 4 - int8_t m_pwm_ch; + int8_t m_pwm_ch = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class OneWireConfig { public: OneWireConfig(); - bool operator == (const OneWireConfig &r) const; //! Function for resetting all members to their default values. @@ -2488,19 +2499,20 @@ class OneWireConfig protected: //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool pullup, id 2 - bool m_pullup; + bool m_pullup = false; //! sint8 power, id 3 - int8_t m_power; + int8_t m_power = -1; }; + + class UartConfig { public: UartConfig(); - bool operator == (const UartConfig &r) const; //! Function for resetting all members to their default values. @@ -2584,19 +2596,16 @@ class UartConfig protected: //! sint8 port, id 1 - int8_t m_port; - // omitted unused member tx_gpio - // omitted unused member rx_gpio - // omitted unused member cts_gpio - // omitted unused member rts_gpio + int8_t m_port = -1; }; + + class AdcChannel { public: AdcChannel(); - bool operator == (const AdcChannel &r) const; //! Function for resetting all members to their default values. @@ -2840,30 +2849,31 @@ class AdcChannel //! string dim, id 10 estring m_dim; //! float scale, id 8 - float m_scale; + float m_scale = 1; //! float offset, id 9 - float m_offset; + float m_offset = 0; //! uint16 interval, id 5 - uint16_t m_interval; + uint16_t m_interval = 0; //! uint8 unit, id 2 - uint8_t m_unit; + uint8_t m_unit = 0; //! sint8 ch, id 3 - int8_t m_ch; + int8_t m_ch = -1; //! uint8 atten, id 4 - uint8_t m_atten; + uint8_t m_atten = 0; //! uint8 window, id 6 - uint8_t m_window; + uint8_t m_window = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class AdcConfig { public: AdcConfig(); - bool operator == (const AdcConfig &r) const; //! Function for resetting all members to their default values. @@ -2992,25 +3002,22 @@ class AdcConfig protected: //! string adc_name, id 1 estring m_adc_name; - // omitted unused member hall_name - // omitted unused member adc1_bits - // omitted unused member adc2_bits //! uint8 mode, id 4 - uint8_t m_mode; + uint8_t m_mode = 0; //! uint8 clk_div, id 5 - uint8_t m_clk_div; - // omitted unused member channels + uint8_t m_clk_div = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioConfig { public: GpioConfig(); - bool operator == (const GpioConfig &r) const; //! Function for resetting all members to their default values. @@ -3164,20 +3171,21 @@ class GpioConfig //! string name, id 1 estring m_name; //! gpiocfg_t config, id 3 - gpiocfg_t m_config; + gpiocfg_t m_config = 0; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class DisplayConfig { public: DisplayConfig(); - bool operator == (const DisplayConfig &r) const; //! Function for resetting all members to their default values. @@ -3311,24 +3319,25 @@ class DisplayConfig protected: //! disp_t type, id 1 - disp_t m_type; + disp_t m_type = dt_none; //! unsigned options, id 2 - uint32_t m_options; + uint32_t m_options = 0; //! unsigned maxx, id 3 - uint32_t m_maxx; + uint32_t m_maxx = 0; //! unsigned maxy, id 4 - uint32_t m_maxy; + uint32_t m_maxy = 1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class SpiDeviceConfig { public: SpiDeviceConfig(); - bool operator == (const SpiDeviceConfig &r) const; //! Function for resetting all members to their default values. @@ -3480,23 +3489,24 @@ class SpiDeviceConfig protected: //! spidrv_t drv, id 1 - spidrv_t m_drv; + spidrv_t m_drv = spidrv_invalid; //! sint8 cs, id 2 - int8_t m_cs; + int8_t m_cs = -1; //! sint8 intr, id 3 - int8_t m_intr; + int8_t m_intr = -1; //! sint8 reset, id 4 - int8_t m_reset; + int8_t m_reset = -1; //! sint8 cd, id 5 - int8_t m_cd; + int8_t m_cd = -1; }; + + class SpiBusConfig { public: SpiBusConfig(); - bool operator == (const SpiBusConfig &r) const; //! Function for resetting all members to their default values. @@ -3754,34 +3764,35 @@ class SpiBusConfig protected: //! sint8 host, id 1 - int8_t m_host; + int8_t m_host = -1; //! sint8 mosi, id 2 - int8_t m_mosi; + int8_t m_mosi = -1; //! sint8 miso, id 3 - int8_t m_miso; + int8_t m_miso = -1; //! sint8 sclk, id 4 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 wp, id 5 - int8_t m_wp; + int8_t m_wp = -1; //! sint8 hold, id 6 - int8_t m_hold; + int8_t m_hold = -1; //! spiopt_t options, id 7 - spiopt_t m_options; + spiopt_t m_options = 0; //! sint8 dma, id 8 - int8_t m_dma; + int8_t m_dma = -1; //! SpiDeviceConfig devices, id 9 std::vector m_devices; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioCluster { public: GpioCluster(); - bool operator == (const GpioCluster &r) const; //! Function for resetting all members to their default values. @@ -3943,21 +3954,22 @@ class GpioCluster //! string name, id 1 estring m_name; //! uint8 base, id 2 - uint8_t m_base; + uint8_t m_base = 0; //! uint8 numio, id 3 - uint8_t m_numio; + uint8_t m_numio = 0; //! sint8 int_a, id 4 - int8_t m_int_a; + int8_t m_int_a = -1; //! sint8 int_b, id 5 - int8_t m_int_b; + int8_t m_int_b = -1; }; + + class Hlw8012Config { public: Hlw8012Config(); - bool operator == (const Hlw8012Config &r) const; //! Function for resetting all members to their default values. @@ -4073,19 +4085,20 @@ class Hlw8012Config protected: //! sint8 sel, id 2 - int8_t m_sel; + int8_t m_sel = -1; //! sint8 cf, id 3 - int8_t m_cf; + int8_t m_cf = -1; //! sint8 cf1, id 4 - int8_t m_cf1; + int8_t m_cf1 = -1; }; + + class SX1276Config { public: SX1276Config(); - bool operator == (const SX1276Config &r) const; //! Function for resetting all members to their default values. @@ -4255,25 +4268,26 @@ class SX1276Config protected: //! sint8 dio0, id 1 - int8_t m_dio0; + int8_t m_dio0 = -1; //! sint8 dio1, id 2 - int8_t m_dio1; + int8_t m_dio1 = -1; //! sint8 dio2, id 3 - int8_t m_dio2; + int8_t m_dio2 = -1; //! sint8 dio3, id 4 - int8_t m_dio3; + int8_t m_dio3 = -1; //! sint8 dio4, id 5 - int8_t m_dio4; + int8_t m_dio4 = -1; //! sint8 dio5, id 6 - int8_t m_dio5; + int8_t m_dio5 = -1; }; + + class HardwareConfig { public: HardwareConfig(); - bool operator == (const HardwareConfig &r) const; //! Function for resetting all members to their default values. @@ -4822,7 +4836,7 @@ class HardwareConfig protected: //! fixed32 magic, id 0 - uint32_t m_magic; + uint32_t m_magic = 0; #ifdef CONFIG_HLW8012 //! Hlw8012Config hlw8012, id 20 Hlw8012Config m_hlw8012; @@ -4885,20 +4899,13 @@ class HardwareConfig #endif // CONFIG_SPI //! GpioConfig gpios, id 7 std::vector m_gpios; - #ifdef CONFIG_TOUCHPAD - // omitted unused member tp_channel - #endif // CONFIG_TOUCHPAD - #ifdef CONFIG_TOUCHPAD - // omitted unused member touchpad - #endif // CONFIG_TOUCHPAD //! AdcConfig adc, id 4 AdcConfig m_adc; - // omitted unused member uart //! SystemConfig system, id 1 SystemConfig m_system; private: - uint16_t p_validbits; + uint16_t p_validbits = 0; }; @@ -7574,7 +7581,7 @@ inline const estring &AdcChannel::dim() const inline bool AdcChannel::has_dim() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return !m_dim.empty(); } /*! @@ -7583,35 +7590,27 @@ inline bool AdcChannel::has_dim() const */ 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); } @@ -7758,7 +7757,7 @@ inline const estring &GpioConfig::name() const inline bool GpioConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -7767,35 +7766,27 @@ inline bool GpioConfig::has_name() const */ inline void GpioConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *GpioConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void GpioConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -7873,7 +7864,7 @@ inline bool GpioConfig::config_cap_freq_r2r() const inline bool GpioConfig::has_config() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -7882,14 +7873,14 @@ inline bool GpioConfig::has_config() const */ inline void GpioConfig::clear_config() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_config = 0; } inline gpiocfg_t *GpioConfig::mutable_config() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_config = 0; } return &m_config; @@ -7899,55 +7890,55 @@ inline void GpioConfig::set_config_mode(uint8_t v) { m_config &= ~(0x3ULL << 0); m_config |= ((uint16_t) v << 0); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_intrtype(uint8_t v) { m_config &= ~(0x7ULL << 2); m_config |= ((uint16_t) v << 2); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_setinit(bool v) { m_config &= ~(0x1ULL << 5); m_config |= ((uint16_t) v << 5); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_initlvl(bool v) { m_config &= ~(0x1ULL << 6); m_config |= ((uint16_t) v << 6); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pullup(bool v) { m_config &= ~(0x1ULL << 7); m_config |= ((uint16_t) v << 7); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pulldown(bool v) { m_config &= ~(0x1ULL << 8); m_config |= ((uint16_t) v << 8); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_cap_freq_r2r(bool v) { m_config &= ~(0x1ULL << 9); m_config |= ((uint16_t) v << 9); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config(gpiocfg_t v) { m_config = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } diff --git a/components/wfc/hwcfg_pc.cpp b/components/wfc/hwcfg_pc.cpp index 0b70bb3..a9cb5ad 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -335,25 +335,6 @@ const char *spidrv_t_str(spidrv_t e) return 0; } -SystemConfig::SystemConfig() -: m_manufacturer() -, m_board_name() -, m_board_rev() -, m_diag_uart(0) -, m_console_rx(0) -, m_console_tx(0) -, m_model_name() -, m_model_number() -#ifdef CONFIG_USB_DIAGLOG -, m_usb_diag(true) -#endif // CONFIG_USB_DIAGLOG -#ifdef CONFIG_USB_CONSOLE -, m_usb_con(true) -#endif // CONFIG_USB_CONSOLE -, p_validbits(0) -{ -} - void SystemConfig::clear() { m_manufacturer.clear(); @@ -1047,26 +1028,18 @@ int SystemConfig::setByName(const char *name, const char *value) return -32; } -Message *SystemConfig::p_getMember(const char *s, const char *e) +Message *SystemConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SystemConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SystemConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -TouchpadConfig::TouchpadConfig() -: m_fsm_mode(false) -, m_lvolt(-1) -, m_hvolt(-1) -, m_atten(-1) -, m_interval(0) -, p_validbits(0) -{ -} - void TouchpadConfig::clear() { m_fsm_mode = false; @@ -1421,26 +1394,18 @@ int TouchpadConfig::setByName(const char *name, const char *value) return -50; } -Message *TouchpadConfig::p_getMember(const char *s, const char *e) +Message *TouchpadConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *TouchpadConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *TouchpadConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -TouchChannelConfig::TouchChannelConfig() -: m_name() -, m_channel(-1) -, m_threshold(0) -, m_slope(0) -, m_tieopt(0) -, p_validbits(0) -{ -} - void TouchChannelConfig::clear() { m_name.clear(); @@ -1811,30 +1776,18 @@ int TouchChannelConfig::setByName(const char *name, const char *value) return -68; } -Message *TouchChannelConfig::p_getMember(const char *s, const char *e) +Message *TouchChannelConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *TouchChannelConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *TouchChannelConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -ButtonConfig::ButtonConfig() -: m_name() -, m_gpio(-1) -, m_presslvl(0) -, m_pull_mode(pull_none) -#ifdef CONFIG_ROTARYENCODER -, m_clk(-1) -#endif // CONFIG_ROTARYENCODER -#ifdef CONFIG_ROTARYENCODER -, m_dt(-1) -#endif // CONFIG_ROTARYENCODER -{ -} - void ButtonConfig::clear() { m_name.clear(); @@ -2301,26 +2254,18 @@ int ButtonConfig::setByName(const char *name, const char *value) return -90; } -Message *ButtonConfig::p_getMember(const char *s, const char *e) +Message *ButtonConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *ButtonConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *ButtonConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -RelayConfig::RelayConfig() -: m_name() -, m_gpio(-1) -, m_config(0) -, m_min_itv(0) -, m_interlock(-1) -, p_validbits(0) -{ -} - void RelayConfig::clear() { m_name.clear(); @@ -2724,25 +2669,18 @@ int RelayConfig::setByName(const char *name, const char *value) return -110; } -Message *RelayConfig::p_getMember(const char *s, const char *e) +Message *RelayConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *RelayConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *RelayConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Max7219Config::Max7219Config() -: m_clk(-1) -, m_dout(-1) -, m_cs(-1) -, m_odrain(false) -, m_digits(0) -{ -} - void Max7219Config::clear() { m_clk = -1; @@ -3092,25 +3030,18 @@ int Max7219Config::setByName(const char *name, const char *value) return -128; } -Message *Max7219Config::p_getMember(const char *s, const char *e) +Message *Max7219Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Max7219Config::p_getMember(const char *s, const char *e, unsigned x) +Message *Max7219Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Tlc5947Config::Tlc5947Config() -: m_sin(-1) -, m_sclk(-1) -, m_xlat(-1) -, m_blank(-1) -, m_ntlc(0) -{ -} - void Tlc5947Config::clear() { m_sin = -1; @@ -3468,24 +3399,18 @@ int Tlc5947Config::setByName(const char *name, const char *value) return -147; } -Message *Tlc5947Config::p_getMember(const char *s, const char *e) +Message *Tlc5947Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Tlc5947Config::p_getMember(const char *s, const char *e, unsigned x) +Message *Tlc5947Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Ws2812bConfig::Ws2812bConfig() -: m_gpio(-1) -, m_ch(-1) -, m_nleds(0) -, m_name() -{ -} - void Ws2812bConfig::clear() { m_gpio = -1; @@ -3802,22 +3727,18 @@ int Ws2812bConfig::setByName(const char *name, const char *value) return -163; } -Message *Ws2812bConfig::p_getMember(const char *s, const char *e) +Message *Ws2812bConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Ws2812bConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *Ws2812bConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -DhtConfig::DhtConfig() -: m_model(DHT_NONE) -, m_gpio(-1) -{ -} - void DhtConfig::clear() { m_model = DHT_NONE; @@ -4037,28 +3958,18 @@ int DhtConfig::setByName(const char *name, const char *value) return -174; } -Message *DhtConfig::p_getMember(const char *s, const char *e) +Message *DhtConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *DhtConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *DhtConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -I2CConfig::I2CConfig() -: m_port(0) -, m_sda(-1) -, m_scl(-1) -, m_freq(100000) -, m_xpullup(false) -#ifdef CONFIG_I2C_XDEV -#endif // CONFIG_I2C_XDEV -, p_validbits(0) -{ -} - void I2CConfig::clear() { m_port = 0; @@ -4585,23 +4496,18 @@ int I2CConfig::setByName(const char *name, const char *value) return -200; } -Message *I2CConfig::p_getMember(const char *s, const char *e) +Message *I2CConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *I2CConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *I2CConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -HcSr04Config::HcSr04Config() -: m_trigger(-1) -, m_echo(-1) -, m_name() -{ -} - void HcSr04Config::clear() { m_trigger = -1; @@ -4867,25 +4773,18 @@ int HcSr04Config::setByName(const char *name, const char *value) return -213; } -Message *HcSr04Config::p_getMember(const char *s, const char *e) +Message *HcSr04Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *HcSr04Config::p_getMember(const char *s, const char *e, unsigned x) +Message *HcSr04Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -LedConfig::LedConfig() -: m_gpio(-1) -, m_config(0) -, m_name() -, m_pwm_ch(-1) -, p_validbits(0) -{ -} - void LedConfig::clear() { m_gpio = -1; @@ -5221,23 +5120,18 @@ int LedConfig::setByName(const char *name, const char *value) return -230; } -Message *LedConfig::p_getMember(const char *s, const char *e) +Message *LedConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *LedConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *LedConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -OneWireConfig::OneWireConfig() -: m_gpio(-1) -, m_pullup(false) -, m_power(-1) -{ -} - void OneWireConfig::clear() { m_gpio = -1; @@ -5485,25 +5379,18 @@ int OneWireConfig::setByName(const char *name, const char *value) return -242; } -Message *OneWireConfig::p_getMember(const char *s, const char *e) +Message *OneWireConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *OneWireConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *OneWireConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -UartConfig::UartConfig() -: m_port(-1) -, m_tx_gpio(-1) -, m_rx_gpio(-1) -, m_cts_gpio(-1) -, m_rts_gpio(-1) -{ -} - void UartConfig::clear() { m_port = -1; @@ -5861,30 +5748,18 @@ int UartConfig::setByName(const char *name, const char *value) return -261; } -Message *UartConfig::p_getMember(const char *s, const char *e) +Message *UartConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *UartConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *UartConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AdcChannel::AdcChannel() -: m_name() -, m_unit(0) -, m_ch(-1) -, m_atten(0) -, m_interval(0) -, m_window(0) -, m_scale(1) -, m_offset(0) -, m_dim() -, p_validbits(0) -{ -} - void AdcChannel::clear() { m_name.clear(); @@ -6011,7 +5886,6 @@ ssize_t AdcChannel::fromMemory(const void *b, ssize_t s) m_dim.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 3); break; default: // unknown field (option unknown=skip) @@ -6127,7 +6001,7 @@ ssize_t AdcChannel::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has dim? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { // 'dim': id=10, encoding=lenpfx, tag=0x52 if (a >= e) return -290; @@ -6188,7 +6062,7 @@ void AdcChannel::toWire(void (*put)(uint8_t)) const put(0x4d); // 'offset': id=9 send_u32(put,mangle_float(m_offset)); } - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { // 'dim': id=10, encoding=lenpfx, tag=0x52 put(0x52); // 'dim': id=10 size_t dim_s = m_dim.size(); @@ -6241,7 +6115,7 @@ void AdcChannel::toString(std::string &put) const put.push_back(0x4d); // 'offset': id=9 send_u32(put,mangle_float(m_offset)); } - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { // 'dim': id=10, encoding=lenpfx, tag=0x52 put.push_back(0x52); // 'dim': id=10 size_t dim_s = m_dim.size(); @@ -6337,7 +6211,7 @@ size_t AdcChannel::calcSize() const r += 5; } // optional string dim, id 10 - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (!m_dim.empty()) { size_t dim_s = m_dim.size(); r += dim_s + wiresize(dim_s) + 1 /* tag(dim) 0x50 */; } @@ -6463,34 +6337,23 @@ int AdcChannel::setByName(const char *name, const char *value) } 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) +Message *AdcChannel::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AdcChannel::p_getMember(const char *s, const char *e, unsigned x) +Message *AdcChannel::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AdcConfig::AdcConfig() -: m_adc_name() -, m_adc1_bits(0) -, m_adc2_bits(0) -, m_mode(0) -, m_clk_div(0) -, m_hall_name() -, p_validbits(0) -{ -} - void AdcConfig::clear() { m_adc_name.clear(); @@ -7043,29 +6906,22 @@ int AdcConfig::setByName(const char *name, const char *value) return -321; } -Message *AdcConfig::p_getMember(const char *s, const char *e) +Message *AdcConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AdcConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *AdcConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("channels[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 8) && (0 == memcmp("channels",s,8))) { if (x < m_channels.size()) return &m_channels[x]; - return 0; } return 0; } -GpioConfig::GpioConfig() -: m_name() -, m_gpio(-1) -, m_config(0) -, p_validbits(0) -{ -} - void GpioConfig::clear() { m_name.clear(); @@ -7132,7 +6988,6 @@ ssize_t GpioConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x10: // gpio id 2, type int8_t, coding signed varint { @@ -7177,7 +7032,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -328; @@ -7202,7 +7057,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has config? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) return -332; @@ -7218,7 +7073,7 @@ ssize_t GpioConfig::toMemory(uint8_t *b, ssize_t s) const void GpioConfig::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'name': id=1 size_t name_s = m_name.size(); @@ -7230,7 +7085,7 @@ void GpioConfig::toWire(void (*put)(uint8_t)) const put(0x10); // 'gpio': id=2 send_varint(put,sint_varint(m_gpio)); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=3, encoding=varint, tag=0x18 put(0x18); // 'config': id=3 send_varint(put,m_config); @@ -7239,7 +7094,7 @@ void GpioConfig::toWire(void (*put)(uint8_t)) const void GpioConfig::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'name': id=1 size_t name_s = m_name.size(); @@ -7251,7 +7106,7 @@ void GpioConfig::toString(std::string &put) const put.push_back(0x10); // 'gpio': id=2 send_varint(put,sint_varint(m_gpio)); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'config': id=3, encoding=varint, tag=0x18 put.push_back(0x18); // 'config': id=3 send_varint(put,m_config); @@ -7288,7 +7143,7 @@ size_t GpioConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } @@ -7297,7 +7152,7 @@ size_t GpioConfig::calcSize() const r += wiresize_s((varint_t)m_gpio) + 1 /* tag(gpio) 0x10 */; } // optional gpiocfg_t config, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += wiresize((varint_t)m_config) + 1 /* tag(config) 0x18 */; } return r; @@ -7339,8 +7194,6 @@ int GpioConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"gpio")) { @@ -7380,25 +7233,18 @@ int GpioConfig::setByName(const char *name, const char *value) return -335; } -Message *GpioConfig::p_getMember(const char *s, const char *e) +Message *GpioConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *GpioConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *GpioConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -DisplayConfig::DisplayConfig() -: m_type(dt_none) -, m_options(0) -, m_maxx(0) -, m_maxy(1) -, p_validbits(0) -{ -} - void DisplayConfig::clear() { m_type = dt_none; @@ -7729,25 +7575,18 @@ int DisplayConfig::setByName(const char *name, const char *value) return -352; } -Message *DisplayConfig::p_getMember(const char *s, const char *e) +Message *DisplayConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *DisplayConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *DisplayConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SpiDeviceConfig::SpiDeviceConfig() -: m_drv(spidrv_invalid) -, m_cs(-1) -, m_intr(-1) -, m_reset(-1) -, m_cd(-1) -{ -} - void SpiDeviceConfig::clear() { m_drv = spidrv_invalid; @@ -8120,29 +7959,18 @@ int SpiDeviceConfig::setByName(const char *name, const char *value) return -372; } -Message *SpiDeviceConfig::p_getMember(const char *s, const char *e) +Message *SpiDeviceConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SpiDeviceConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SpiDeviceConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SpiBusConfig::SpiBusConfig() -: m_host(-1) -, m_mosi(-1) -, m_miso(-1) -, m_sclk(-1) -, m_wp(-1) -, m_hold(-1) -, m_options(0) -, m_dma(-1) -, p_validbits(0) -{ -} - void SpiBusConfig::clear() { m_host = -1; @@ -8810,30 +8638,22 @@ int SpiBusConfig::setByName(const char *name, const char *value) return -408; } -Message *SpiBusConfig::p_getMember(const char *s, const char *e) +Message *SpiBusConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SpiBusConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SpiBusConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("devices[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 7) && (0 == memcmp("devices",s,7))) { if (x < m_devices.size()) return &m_devices[x]; - return 0; } return 0; } -GpioCluster::GpioCluster() -: m_name() -, m_base(0) -, m_numio(0) -, m_int_a(-1) -, m_int_b(-1) -{ -} - void GpioCluster::clear() { m_name.clear(); @@ -9201,23 +9021,18 @@ int GpioCluster::setByName(const char *name, const char *value) return -427; } -Message *GpioCluster::p_getMember(const char *s, const char *e) +Message *GpioCluster::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *GpioCluster::p_getMember(const char *s, const char *e, unsigned x) +Message *GpioCluster::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Hlw8012Config::Hlw8012Config() -: m_sel(-1) -, m_cf(-1) -, m_cf1(-1) -{ -} - void Hlw8012Config::clear() { m_sel = -1; @@ -9473,26 +9288,18 @@ int Hlw8012Config::setByName(const char *name, const char *value) return -440; } -Message *Hlw8012Config::p_getMember(const char *s, const char *e) +Message *Hlw8012Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Hlw8012Config::p_getMember(const char *s, const char *e, unsigned x) +Message *Hlw8012Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SX1276Config::SX1276Config() -: m_dio0(-1) -, m_dio1(-1) -, m_dio2(-1) -, m_dio3(-1) -, m_dio4(-1) -, m_dio5(-1) -{ -} - void SX1276Config::clear() { m_dio0 = -1; @@ -9901,56 +9708,18 @@ int SX1276Config::setByName(const char *name, const char *value) return -462; } -Message *SX1276Config::p_getMember(const char *s, const char *e) +Message *SX1276Config::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SX1276Config::p_getMember(const char *s, const char *e, unsigned x) +Message *SX1276Config::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -HardwareConfig::HardwareConfig() -: m_magic(0) -#ifdef CONFIG_TOUCHPAD -#endif // CONFIG_TOUCHPAD -#ifdef CONFIG_TOUCHPAD -#endif // CONFIG_TOUCHPAD -#ifdef CONFIG_SPI -#endif // CONFIG_SPI -#ifdef CONFIG_BUTTON -#endif // CONFIG_BUTTON -#ifdef CONFIG_RELAY -#endif // CONFIG_RELAY -#ifdef CONFIG_LEDS -#endif // CONFIG_LEDS -#ifdef CONFIG_HLW8012 -#endif // CONFIG_HLW8012 -#ifdef CONFIG_MAX7219 -#endif // CONFIG_MAX7219 -#ifdef CONFIG_TLC5947 -#endif // CONFIG_TLC5947 -#ifdef CONFIG_RGBLEDS -#endif // CONFIG_RGBLEDS -#ifdef CONFIG_DHT -#endif // CONFIG_DHT -#ifdef CONFIG_I2C -#endif // CONFIG_I2C -#ifdef CONFIG_HCSR04 -#endif // CONFIG_HCSR04 -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -#ifdef CONFIG_SX1276 -#endif // CONFIG_SX1276 -#ifdef CONFIG_IOEXTENDERS -#endif // CONFIG_IOEXTENDERS -#ifdef CONFIG_DISPLAY -#endif // CONFIG_DISPLAY -, p_validbits(0) -{ -} - void HardwareConfig::clear() { m_magic = 0; @@ -12410,122 +12179,103 @@ int HardwareConfig::setByName(const char *name, const char *value) return -586; } -Message *HardwareConfig::p_getMember(const char *s, const char *e) +Message *HardwareConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("system",s,e-s)) + // caller guarantee: s[n] == '.' + if ((n == 6) && (0 == memcmp("system",s,6))) return &m_system; - if (0 == strncmp("adc",s,e-s)) + if ((n == 3) && (0 == memcmp("adc",s,3))) return &m_adc; #ifdef CONFIG_TOUCHPAD - if (0 == strncmp("touchpad",s,e-s)) + if ((n == 8) && (0 == memcmp("touchpad",s,8))) return &m_touchpad; #endif // CONFIG_TOUCHPAD #ifdef CONFIG_HLW8012 - if (0 == strncmp("hlw8012",s,e-s)) + if ((n == 7) && (0 == memcmp("hlw8012",s,7))) return &m_hlw8012; #endif // CONFIG_HLW8012 #ifdef CONFIG_MAX7219 - if (0 == strncmp("max7219",s,e-s)) + if ((n == 7) && (0 == memcmp("max7219",s,7))) return &m_max7219; #endif // CONFIG_MAX7219 #ifdef CONFIG_TLC5947 - if (0 == strncmp("tlc5947",s,e-s)) + if ((n == 7) && (0 == memcmp("tlc5947",s,7))) return &m_tlc5947; #endif // CONFIG_TLC5947 #ifdef CONFIG_DHT - if (0 == strncmp("dht",s,e-s)) + if ((n == 3) && (0 == memcmp("dht",s,3))) return &m_dht; #endif // CONFIG_DHT #ifdef CONFIG_ONEWIRE - if (0 == strncmp("onewire",s,e-s)) + if ((n == 7) && (0 == memcmp("onewire",s,7))) return &m_onewire; #endif // CONFIG_ONEWIRE #ifdef CONFIG_SX1276 - if (0 == strncmp("sx1276",s,e-s)) + if ((n == 6) && (0 == memcmp("sx1276",s,6))) return &m_sx1276; #endif // CONFIG_SX1276 #ifdef CONFIG_DISPLAY - if (0 == strncmp("display",s,e-s)) + if ((n == 7) && (0 == memcmp("display",s,7))) return &m_display; #endif // CONFIG_DISPLAY return 0; } -Message *HardwareConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *HardwareConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("uart[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - return 0; - } - #ifdef CONFIG_TOUCHPAD - if (0 == strncmp("tp_channel[",s,e-s)) { + #ifdef CONFIG_TOUCHPAD + } else if ((n == 10) && (0 == memcmp("tp_channel",s,10))) { if (x < m_tp_channel.size()) return &m_tp_channel[x]; - return 0; - } - #endif // CONFIG_TOUCHPAD - if (0 == strncmp("gpios[",s,e-s)) { + #endif // CONFIG_TOUCHPAD + } else if ((n == 5) && (0 == memcmp("gpios",s,5))) { if (x < m_gpios.size()) return &m_gpios[x]; - return 0; - } - #ifdef CONFIG_SPI - if (0 == strncmp("spibus[",s,e-s)) { + #ifdef CONFIG_SPI + } else if ((n == 6) && (0 == memcmp("spibus",s,6))) { if (x < m_spibus.size()) return &m_spibus[x]; - return 0; - } - #endif // CONFIG_SPI - #ifdef CONFIG_BUTTON - if (0 == strncmp("button[",s,e-s)) { + #endif // CONFIG_SPI + #ifdef CONFIG_BUTTON + } else if ((n == 6) && (0 == memcmp("button",s,6))) { if (x < m_button.size()) return &m_button[x]; - return 0; - } - #endif // CONFIG_BUTTON - #ifdef CONFIG_RELAY - if (0 == strncmp("relay[",s,e-s)) { + #endif // CONFIG_BUTTON + #ifdef CONFIG_RELAY + } else if ((n == 5) && (0 == memcmp("relay",s,5))) { if (x < m_relay.size()) return &m_relay[x]; - return 0; - } - #endif // CONFIG_RELAY - #ifdef CONFIG_LEDS - if (0 == strncmp("led[",s,e-s)) { + #endif // CONFIG_RELAY + #ifdef CONFIG_LEDS + } else if ((n == 3) && (0 == memcmp("led",s,3))) { if (x < m_led.size()) return &m_led[x]; - return 0; - } - #endif // CONFIG_LEDS - #ifdef CONFIG_RGBLEDS - if (0 == strncmp("ws2812b[",s,e-s)) { + #endif // CONFIG_LEDS + #ifdef CONFIG_RGBLEDS + } else if ((n == 7) && (0 == memcmp("ws2812b",s,7))) { if (x < m_ws2812b.size()) return &m_ws2812b[x]; - return 0; - } - #endif // CONFIG_RGBLEDS - #ifdef CONFIG_I2C - if (0 == strncmp("i2c[",s,e-s)) { + #endif // CONFIG_RGBLEDS + #ifdef CONFIG_I2C + } else if ((n == 3) && (0 == memcmp("i2c",s,3))) { if (x < m_i2c.size()) return &m_i2c[x]; - return 0; - } - #endif // CONFIG_I2C - #ifdef CONFIG_HCSR04 - if (0 == strncmp("hcsr04[",s,e-s)) { + #endif // CONFIG_I2C + #ifdef CONFIG_HCSR04 + } else if ((n == 6) && (0 == memcmp("hcsr04",s,6))) { if (x < m_hcsr04.size()) return &m_hcsr04[x]; - return 0; - } - #endif // CONFIG_HCSR04 - #ifdef CONFIG_IOEXTENDERS - if (0 == strncmp("iocluster[",s,e-s)) { + #endif // CONFIG_HCSR04 + #ifdef CONFIG_IOEXTENDERS + } else if ((n == 9) && (0 == memcmp("iocluster",s,9))) { if (x < m_iocluster.size()) return &m_iocluster[x]; - return 0; + #endif // CONFIG_IOEXTENDERS } - #endif // CONFIG_IOEXTENDERS return 0; } diff --git a/components/wfc/hwcfg_pc.h b/components/wfc/hwcfg_pc.h index 145bc06..6665d6d 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -212,10 +212,14 @@ typedef uint16_t i2cdev_t; typedef uint8_t ledcfg_t; typedef uint16_t gpiocfg_t; typedef uint8_t spiopt_t; + + class SystemConfig : public Message { public: - SystemConfig(); + SystemConfig() + { + } bool operator != (const SystemConfig &r) const; bool operator == (const SystemConfig &r) const; @@ -511,8 +515,8 @@ class SystemConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string manufacturer, id 1 std::string m_manufacturer; //! string board_name, id 2 @@ -520,33 +524,37 @@ class SystemConfig : public Message //! string board_rev, id 3 std::string m_board_rev; //! sint8 diag_uart, id 4 - int8_t m_diag_uart; + int8_t m_diag_uart = 0; //! sint8 console_rx, id 5 - int8_t m_console_rx; + int8_t m_console_rx = 0; //! sint8 console_tx, id 6 - int8_t m_console_tx; + int8_t m_console_tx = 0; //! string model_name, id 7 std::string m_model_name; //! string model_number, id 8 std::string m_model_number; #ifdef CONFIG_USB_DIAGLOG //! bool usb_diag, id 9 - bool m_usb_diag; + bool m_usb_diag = true; #endif // CONFIG_USB_DIAGLOG #ifdef CONFIG_USB_CONSOLE //! bool usb_con, id 10 - bool m_usb_con; + bool m_usb_con = true; #endif // CONFIG_USB_CONSOLE private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchpadConfig : public Message { public: - TouchpadConfig(); + TouchpadConfig() + { + } bool operator != (const TouchpadConfig &r) const; bool operator == (const TouchpadConfig &r) const; @@ -708,28 +716,32 @@ class TouchpadConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! bool fsm_mode, id 1 - bool m_fsm_mode; + bool m_fsm_mode = false; //! sint8 lvolt, id 2 - int8_t m_lvolt; + int8_t m_lvolt = -1; //! sint8 hvolt, id 3 - int8_t m_hvolt; + int8_t m_hvolt = -1; //! sint8 atten, id 4 - int8_t m_atten; + int8_t m_atten = -1; //! unsigned interval, id 7 - uint64_t m_interval; + uint64_t m_interval = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TouchChannelConfig : public Message { public: - TouchChannelConfig(); + TouchChannelConfig() + { + } bool operator != (const TouchChannelConfig &r) const; bool operator == (const TouchChannelConfig &r) const; @@ -899,28 +911,32 @@ class TouchChannelConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! sint8 channel, id 2 - int8_t m_channel; + int8_t m_channel = -1; //! fixed16 threshold, id 3 - uint16_t m_threshold; + uint16_t m_threshold = 0; //! uint8 slope, id 4 - uint8_t m_slope; + uint8_t m_slope = 0; //! uint8 tieopt, id 5 - uint8_t m_tieopt; + uint8_t m_tieopt = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ButtonConfig : public Message { public: - ButtonConfig(); + ButtonConfig() + { + } bool operator != (const ButtonConfig &r) const; bool operator == (const ButtonConfig &r) const; @@ -1120,31 +1136,35 @@ class ButtonConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool presslvl, id 3 - bool m_presslvl; + bool m_presslvl = 0; //! pull_mode_t pull_mode, id 4 - pull_mode_t m_pull_mode; + pull_mode_t m_pull_mode = pull_none; #ifdef CONFIG_ROTARYENCODER //! sint8 clk, id 5 - int8_t m_clk; + int8_t m_clk = -1; #endif // CONFIG_ROTARYENCODER #ifdef CONFIG_ROTARYENCODER //! sint8 dt, id 6 - int8_t m_dt; + int8_t m_dt = -1; #endif // CONFIG_ROTARYENCODER }; + + class RelayConfig : public Message { public: - RelayConfig(); + RelayConfig() + { + } bool operator != (const RelayConfig &r) const; bool operator == (const RelayConfig &r) const; @@ -1334,28 +1354,32 @@ class RelayConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! relay_cfg_t config, id 3 - relay_cfg_t m_config; + relay_cfg_t m_config = 0; //! unsigned min_itv, id 4 - uint64_t m_min_itv; + uint64_t m_min_itv = 0; //! sint8 interlock, id 5 - int8_t m_interlock; + int8_t m_interlock = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Max7219Config : public Message { public: - Max7219Config(); + Max7219Config() + { + } bool operator != (const Max7219Config &r) const; bool operator == (const Max7219Config &r) const; @@ -1517,25 +1541,29 @@ class Max7219Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 clk, id 1 - int8_t m_clk; + int8_t m_clk = -1; //! sint8 dout, id 2 - int8_t m_dout; + int8_t m_dout = -1; //! sint8 cs, id 3 - int8_t m_cs; + int8_t m_cs = -1; //! bool odrain, id 4 - bool m_odrain; + bool m_odrain = false; //! uint8 digits, id 5 - uint8_t m_digits; + uint8_t m_digits = 0; }; + + class Tlc5947Config : public Message { public: - Tlc5947Config(); + Tlc5947Config() + { + } bool operator != (const Tlc5947Config &r) const; bool operator == (const Tlc5947Config &r) const; @@ -1697,25 +1725,29 @@ class Tlc5947Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 sin, id 1 - int8_t m_sin; + int8_t m_sin = -1; //! sint8 sclk, id 2 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 xlat, id 3 - int8_t m_xlat; + int8_t m_xlat = -1; //! sint8 blank, id 4 - int8_t m_blank; + int8_t m_blank = -1; //! uint8 ntlc, id 5 - uint8_t m_ntlc; + uint8_t m_ntlc = 0; }; + + class Ws2812bConfig : public Message { public: - Ws2812bConfig(); + Ws2812bConfig() + { + } bool operator != (const Ws2812bConfig &r) const; bool operator == (const Ws2812bConfig &r) const; @@ -1867,23 +1899,27 @@ class Ws2812bConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! sint8 ch, id 2 - int8_t m_ch; + int8_t m_ch = -1; //! uint8 nleds, id 3 - uint8_t m_nleds; + uint8_t m_nleds = 0; //! string name, id 4 std::string m_name; }; + + class DhtConfig : public Message { public: - DhtConfig(); + DhtConfig() + { + } bool operator != (const DhtConfig &r) const; bool operator == (const DhtConfig &r) const; @@ -1991,19 +2027,23 @@ class DhtConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! dht_model_t model, id 1 - dht_model_t m_model; + dht_model_t m_model = DHT_NONE; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; }; + + class I2CConfig : public Message { public: - I2CConfig(); + I2CConfig() + { + } bool operator != (const I2CConfig &r) const; bool operator == (const I2CConfig &r) const; @@ -2199,32 +2239,36 @@ class I2CConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! uint8 port, id 1 - uint8_t m_port; + uint8_t m_port = 0; //! sint8 sda, id 2 - int8_t m_sda; + int8_t m_sda = -1; //! sint8 scl, id 3 - int8_t m_scl; + int8_t m_scl = -1; //! unsigned freq, id 4 - uint64_t m_freq; + uint64_t m_freq = 100000; //! bool xpullup, id 5 - bool m_xpullup; + bool m_xpullup = false; #ifdef CONFIG_I2C_XDEV //! i2cdev_t devices, id 6 std::vector m_devices; #endif // CONFIG_I2C_XDEV private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class HcSr04Config : public Message { public: - HcSr04Config(); + HcSr04Config() + { + } bool operator != (const HcSr04Config &r) const; bool operator == (const HcSr04Config &r) const; @@ -2358,21 +2402,25 @@ class HcSr04Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 trigger, id 1 - int8_t m_trigger; + int8_t m_trigger = -1; //! sint8 echo, id 2 - int8_t m_echo; + int8_t m_echo = -1; //! string name, id 3 std::string m_name; }; + + class LedConfig : public Message { public: - LedConfig(); + LedConfig() + { + } bool operator != (const LedConfig &r) const; bool operator == (const LedConfig &r) const; @@ -2532,26 +2580,30 @@ class LedConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! ledcfg_t config, id 2 - ledcfg_t m_config; + ledcfg_t m_config = 0; //! string name, id 3 std::string m_name; //! sint8 pwm_ch, id 4 - int8_t m_pwm_ch; + int8_t m_pwm_ch = -1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class OneWireConfig : public Message { public: - OneWireConfig(); + OneWireConfig() + { + } bool operator != (const OneWireConfig &r) const; bool operator == (const OneWireConfig &r) const; @@ -2677,21 +2729,25 @@ class OneWireConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 gpio, id 1 - int8_t m_gpio; + int8_t m_gpio = -1; //! bool pullup, id 2 - bool m_pullup; + bool m_pullup = false; //! sint8 power, id 3 - int8_t m_power; + int8_t m_power = -1; }; + + class UartConfig : public Message { public: - UartConfig(); + UartConfig() + { + } bool operator != (const UartConfig &r) const; bool operator == (const UartConfig &r) const; @@ -2853,25 +2909,29 @@ class UartConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 port, id 1 - int8_t m_port; + int8_t m_port = -1; //! sint8 tx_gpio, id 2 - int8_t m_tx_gpio; + int8_t m_tx_gpio = -1; //! sint8 rx_gpio, id 3 - int8_t m_rx_gpio; + int8_t m_rx_gpio = -1; //! sint8 cts_gpio, id 4 - int8_t m_cts_gpio; + int8_t m_cts_gpio = -1; //! sint8 rts_gpio, id 5 - int8_t m_rts_gpio; + int8_t m_rts_gpio = -1; }; + + class AdcChannel : public Message { public: - AdcChannel(); + AdcChannel() + { + } bool operator != (const AdcChannel &r) const; bool operator == (const AdcChannel &r) const; @@ -3121,36 +3181,40 @@ class AdcChannel : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! uint8 unit, id 2 - uint8_t m_unit; + uint8_t m_unit = 0; //! sint8 ch, id 3 - int8_t m_ch; + int8_t m_ch = -1; //! uint8 atten, id 4 - uint8_t m_atten; + uint8_t m_atten = 0; //! uint16 interval, id 5 - uint16_t m_interval; + uint16_t m_interval = 0; //! uint8 window, id 6 - uint8_t m_window; + uint8_t m_window = 0; //! float scale, id 8 - float m_scale; + float m_scale = 1; //! float offset, id 9 - float m_offset; + float m_offset = 0; //! string dim, id 10 std::string m_dim; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class AdcConfig : public Message { public: - AdcConfig(); + AdcConfig() + { + } bool operator != (const AdcConfig &r) const; bool operator == (const AdcConfig &r) const; @@ -3370,32 +3434,36 @@ class AdcConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string adc_name, id 1 std::string m_adc_name; //! uint8 adc1_bits, id 2 - uint8_t m_adc1_bits; + uint8_t m_adc1_bits = 0; //! uint8 adc2_bits, id 3 - uint8_t m_adc2_bits; + uint8_t m_adc2_bits = 0; //! uint8 mode, id 4 - uint8_t m_mode; + uint8_t m_mode = 0; //! uint8 clk_div, id 5 - uint8_t m_clk_div; + uint8_t m_clk_div = 0; //! string hall_name, id 6 std::string m_hall_name; //! AdcChannel channels, id 7 std::vector m_channels; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioConfig : public Message { public: - GpioConfig(); + GpioConfig() + { + } bool operator != (const GpioConfig &r) const; bool operator == (const GpioConfig &r) const; @@ -3557,24 +3625,28 @@ class GpioConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! sint8 gpio, id 2 - int8_t m_gpio; + int8_t m_gpio = -1; //! gpiocfg_t config, id 3 - gpiocfg_t m_config; + gpiocfg_t m_config = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class DisplayConfig : public Message { public: - DisplayConfig(); + DisplayConfig() + { + } bool operator != (const DisplayConfig &r) const; bool operator == (const DisplayConfig &r) const; @@ -3718,26 +3790,30 @@ class DisplayConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! disp_t type, id 1 - disp_t m_type; + disp_t m_type = dt_none; //! unsigned options, id 2 - uint64_t m_options; + uint64_t m_options = 0; //! unsigned maxx, id 3 - uint64_t m_maxx; + uint64_t m_maxx = 0; //! unsigned maxy, id 4 - uint64_t m_maxy; + uint64_t m_maxy = 1; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class SpiDeviceConfig : public Message { public: - SpiDeviceConfig(); + SpiDeviceConfig() + { + } bool operator != (const SpiDeviceConfig &r) const; bool operator == (const SpiDeviceConfig &r) const; @@ -3899,25 +3975,29 @@ class SpiDeviceConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! spidrv_t drv, id 1 - spidrv_t m_drv; + spidrv_t m_drv = spidrv_invalid; //! sint8 cs, id 2 - int8_t m_cs; + int8_t m_cs = -1; //! sint8 intr, id 3 - int8_t m_intr; + int8_t m_intr = -1; //! sint8 reset, id 4 - int8_t m_reset; + int8_t m_reset = -1; //! sint8 cd, id 5 - int8_t m_cd; + int8_t m_cd = -1; }; + + class SpiBusConfig : public Message { public: - SpiBusConfig(); + SpiBusConfig() + { + } bool operator != (const SpiBusConfig &r) const; bool operator == (const SpiBusConfig &r) const; @@ -4185,36 +4265,40 @@ class SpiBusConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 host, id 1 - int8_t m_host; + int8_t m_host = -1; //! sint8 mosi, id 2 - int8_t m_mosi; + int8_t m_mosi = -1; //! sint8 miso, id 3 - int8_t m_miso; + int8_t m_miso = -1; //! sint8 sclk, id 4 - int8_t m_sclk; + int8_t m_sclk = -1; //! sint8 wp, id 5 - int8_t m_wp; + int8_t m_wp = -1; //! sint8 hold, id 6 - int8_t m_hold; + int8_t m_hold = -1; //! spiopt_t options, id 7 - spiopt_t m_options; + spiopt_t m_options = 0; //! sint8 dma, id 8 - int8_t m_dma; + int8_t m_dma = -1; //! SpiDeviceConfig devices, id 9 std::vector m_devices; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class GpioCluster : public Message { public: - GpioCluster(); + GpioCluster() + { + } bool operator != (const GpioCluster &r) const; bool operator == (const GpioCluster &r) const; @@ -4384,25 +4468,29 @@ class GpioCluster : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! uint8 base, id 2 - uint8_t m_base; + uint8_t m_base = 0; //! uint8 numio, id 3 - uint8_t m_numio; + uint8_t m_numio = 0; //! sint8 int_a, id 4 - int8_t m_int_a; + int8_t m_int_a = -1; //! sint8 int_b, id 5 - int8_t m_int_b; + int8_t m_int_b = -1; }; + + class Hlw8012Config : public Message { public: - Hlw8012Config(); + Hlw8012Config() + { + } bool operator != (const Hlw8012Config &r) const; bool operator == (const Hlw8012Config &r) const; @@ -4528,21 +4616,25 @@ class Hlw8012Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 sel, id 2 - int8_t m_sel; + int8_t m_sel = -1; //! sint8 cf, id 3 - int8_t m_cf; + int8_t m_cf = -1; //! sint8 cf1, id 4 - int8_t m_cf1; + int8_t m_cf1 = -1; }; + + class SX1276Config : public Message { public: - SX1276Config(); + SX1276Config() + { + } bool operator != (const SX1276Config &r) const; bool operator == (const SX1276Config &r) const; @@ -4722,27 +4814,31 @@ class SX1276Config : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! sint8 dio0, id 1 - int8_t m_dio0; + int8_t m_dio0 = -1; //! sint8 dio1, id 2 - int8_t m_dio1; + int8_t m_dio1 = -1; //! sint8 dio2, id 3 - int8_t m_dio2; + int8_t m_dio2 = -1; //! sint8 dio3, id 4 - int8_t m_dio3; + int8_t m_dio3 = -1; //! sint8 dio4, id 5 - int8_t m_dio4; + int8_t m_dio4 = -1; //! sint8 dio5, id 6 - int8_t m_dio5; + int8_t m_dio5 = -1; }; + + class HardwareConfig : public Message { public: - HardwareConfig(); + HardwareConfig() + { + } bool operator != (const HardwareConfig &r) const; bool operator == (const HardwareConfig &r) const; @@ -5370,10 +5466,10 @@ class HardwareConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! fixed32 magic, id 0 - uint32_t m_magic; + uint32_t m_magic = 0; //! SystemConfig system, id 1 SystemConfig m_system; //! UartConfig uart, id 3 @@ -5452,7 +5548,7 @@ class HardwareConfig : public Message #endif // CONFIG_DISPLAY private: - uint16_t p_validbits; + uint16_t p_validbits = 0; }; @@ -8320,7 +8416,7 @@ inline const std::string &AdcChannel::dim() const inline bool AdcChannel::has_dim() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return !m_dim.empty(); } /*! @@ -8329,35 +8425,27 @@ inline bool AdcChannel::has_dim() const */ 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); } @@ -8669,7 +8757,7 @@ inline const std::string &GpioConfig::name() const inline bool GpioConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -8678,35 +8766,27 @@ inline bool GpioConfig::has_name() const */ inline void GpioConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline std::string *GpioConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void GpioConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -8784,7 +8864,7 @@ inline bool GpioConfig::config_cap_freq_r2r() const inline bool GpioConfig::has_config() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -8793,14 +8873,14 @@ inline bool GpioConfig::has_config() const */ inline void GpioConfig::clear_config() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_config = 0; } inline gpiocfg_t *GpioConfig::mutable_config() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_config = 0; } return &m_config; @@ -8810,55 +8890,55 @@ inline void GpioConfig::set_config_mode(uint8_t v) { m_config &= ~(0x3ULL << 0); m_config |= ((uint16_t) v << 0); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_intrtype(uint8_t v) { m_config &= ~(0x7ULL << 2); m_config |= ((uint16_t) v << 2); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_setinit(bool v) { m_config &= ~(0x1ULL << 5); m_config |= ((uint16_t) v << 5); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_initlvl(bool v) { m_config &= ~(0x1ULL << 6); m_config |= ((uint16_t) v << 6); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pullup(bool v) { m_config &= ~(0x1ULL << 7); m_config |= ((uint16_t) v << 7); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_pulldown(bool v) { m_config &= ~(0x1ULL << 8); m_config |= ((uint16_t) v << 8); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config_cap_freq_r2r(bool v) { m_config &= ~(0x1ULL << 9); m_config |= ((uint16_t) v << 9); - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } inline void GpioConfig::set_config(gpiocfg_t v) { m_config = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } diff --git a/components/wfc/swcfg_esp32.cpp b/components/wfc/swcfg_esp32.cpp index 4d890a9..003a5a0 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -48,6 +48,7 @@ * options from common: * BaseClass : "Message" * getMember : "getMember" + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -73,7 +74,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * toJSON : "toJSON" * toMemory : "toMemory" * UnknownField : "skip" @@ -610,18 +610,6 @@ const char *sigtype_t_str(sigtype_t e) #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB } -WifiConfig::WifiConfig() -: m_ssid() -, m_pass() -, m_mac() -, m_activate(false) -, m_addr4(0) -, m_netmask4(0) -, m_gateway4(0) -, p_validbits(0) -{ -} - void WifiConfig::clear() { m_ssid.clear(); @@ -697,7 +685,6 @@ ssize_t WifiConfig::fromMemory(const void *b, ssize_t s) m_mac.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x23: // activate id 4, type bool, coding 8bit if (a >= e) @@ -772,7 +759,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += pass_s; } // has mac? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { // 'mac': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -15; @@ -791,7 +778,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x23; *a++ = m_activate; // has addr4? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'addr4': id=5, encoding=32bit, tag=0x2d if (5 > (e-a)) return -18; @@ -802,7 +789,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has netmask4? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'netmask4': id=6, encoding=8bit, tag=0x33 if (2 > (e-a)) return -20; @@ -810,7 +797,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = m_netmask4; } // has gateway4? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'gateway4': id=7, encoding=32bit, tag=0x3d if (5 > (e-a)) return -21; @@ -883,20 +870,20 @@ size_t WifiConfig::calcSize() const r += pass_s + wiresize(pass_s) + 1 /* tag(pass) 0x10 */; } // optional bytes mac, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { size_t mac_s = m_mac.size(); r += mac_s + wiresize(mac_s) + 1 /* tag(mac) 0x18 */; } // optional fixed32 addr4, id 5 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += 5; } // optional fixed8 netmask4, id 6 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { r += 2; } // optional fixed32 gateway4, id 7 - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { r += 5; } return r; @@ -963,8 +950,6 @@ int WifiConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_mac,value); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"activate")) { @@ -978,7 +963,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_addr4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"netmask4")) { @@ -988,7 +973,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_netmask4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"gateway4")) { @@ -998,32 +983,24 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_gateway4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); return r; } return -23; } -Message *WifiConfig::p_getMember(const char *s, const char *e) +Message *WifiConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *WifiConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *WifiConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -MQTT::MQTT() -: m_uri() -, m_enable(false) -, m_username() -, m_password() -, m_keepalive(60) -, p_validbits(0) -{ -} - void MQTT::clear() { m_uri.clear(); @@ -1434,26 +1411,18 @@ int MQTT::setByName(const char *name, const char *value) return -47; } -Message *MQTT::p_getMember(const char *s, const char *e) +Message *MQTT::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *MQTT::p_getMember(const char *s, const char *e, unsigned x) +Message *MQTT::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Date::Date() -: m_day(0) -, m_month(0) -, m_year(0) -, m_endday(0) -, m_endmonth(0) -, m_endyear(0) -{ -} - void Date::clear() { m_day = 0; @@ -1747,25 +1716,18 @@ int Date::setByName(const char *name, const char *value) return -63; } -Message *Date::p_getMember(const char *s, const char *e) +Message *Date::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Date::p_getMember(const char *s, const char *e, unsigned x) +Message *Date::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AtAction::AtAction() -: m_day(Sunday) -, m_min_of_day(0) -, m_action() -, m_enable(true) -, p_validbits(0) -{ -} - void AtAction::clear() { m_day = Sunday; @@ -1834,7 +1796,6 @@ ssize_t AtAction::fromMemory(const void *b, ssize_t s) m_action.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 2); break; case 0x23: // enable id 4, type bool, coding 8bit if (a >= e) @@ -1886,7 +1847,7 @@ ssize_t AtAction::toMemory(uint8_t *b, ssize_t s) const a += n; } // has action? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { // 'action': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -75; @@ -1957,7 +1918,7 @@ size_t AtAction::calcSize() const r += wiresize((varint_t)m_min_of_day) + 1 /* tag(min_of_day) 0x10 */; } // optional string action, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { size_t action_s = m_action.size(); r += action_s + wiresize(action_s) + 1 /* tag(action) 0x18 */; } @@ -2024,8 +1985,6 @@ int AtAction::setByName(const char *name, const char *value) } m_action = value; int r = m_action.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"enable")) { @@ -2035,25 +1994,18 @@ int AtAction::setByName(const char *name, const char *value) return -79; } -Message *AtAction::p_getMember(const char *s, const char *e) +Message *AtAction::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AtAction::p_getMember(const char *s, const char *e, unsigned x) +Message *AtAction::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Influx::Influx() -: m_hostname() -, m_port(0) -, m_measurement() -// omitted obsolete member interval -, m_database() -{ -} - void Influx::clear() { m_hostname.clear(); @@ -2326,27 +2278,18 @@ int Influx::setByName(const char *name, const char *value) return -94; } -Message *Influx::p_getMember(const char *s, const char *e) +Message *Influx::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Influx::p_getMember(const char *s, const char *e, unsigned x) +Message *Influx::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -UartSettings::UartSettings() -: m_port(0) -, m_baudrate(0) -, m_config(5) -, m_rx_thresh(0) -, m_tx_bufsize(0) -, m_rx_bufsize(0) -, p_validbits(0) -{ -} - void UartSettings::clear() { m_port = 0; @@ -2762,25 +2705,18 @@ int UartSettings::setByName(const char *name, const char *value) return -115; } -Message *UartSettings::p_getMember(const char *s, const char *e) +Message *UartSettings::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *UartSettings::p_getMember(const char *s, const char *e, unsigned x) +Message *UartSettings::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -FtpHttpConfig::FtpHttpConfig() -: m_port(0) -, m_start(true) -, m_root() -, m_uploaddir() -, p_validbits(0) -{ -} - void FtpHttpConfig::clear() { m_port = 0; @@ -3042,30 +2978,23 @@ int FtpHttpConfig::setByName(const char *name, const char *value) return -129; } -Message *FtpHttpConfig::p_getMember(const char *s, const char *e) +Message *FtpHttpConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *FtpHttpConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *FtpHttpConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -TerminalConfig::TerminalConfig() -: m_uart_rx(-1) -, m_uart_tx(-1) -, m_name() -, p_validbits(0) -{ -} - void TerminalConfig::clear() { m_uart_rx = -1; m_uart_tx = -1; m_name.clear(); - p_validbits = 0; } void TerminalConfig::toASCII(stream &o, size_t indent) const @@ -3121,7 +3050,6 @@ ssize_t TerminalConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; default: // unknown field (option unknown=skip) @@ -3168,7 +3096,7 @@ ssize_t TerminalConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -140; @@ -3223,7 +3151,7 @@ size_t TerminalConfig::calcSize() const r += wiresize_s((varint_t)m_uart_tx) + 1 /* tag(uart_tx) 0x10 */; } // optional string name, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x18 */; } @@ -3232,8 +3160,6 @@ size_t TerminalConfig::calcSize() const bool TerminalConfig::operator != (const TerminalConfig &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_uart_rx() && (m_uart_rx != r.m_uart_rx)) return true; if (has_uart_tx() && (m_uart_tx != r.m_uart_tx)) @@ -3282,34 +3208,27 @@ int TerminalConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } return -142; } -Message *TerminalConfig::p_getMember(const char *s, const char *e) +Message *TerminalConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *TerminalConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *TerminalConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Trigger::Trigger() -: m_event() -, p_validbits(0) -{ -} - void Trigger::clear() { m_event.clear(); m_action.clear(); - p_validbits = 0; } void Trigger::toASCII(stream &o, size_t indent) const @@ -3355,7 +3274,6 @@ ssize_t Trigger::fromMemory(const void *b, ssize_t s) m_event.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x12: // action id 2, type estring, coding byte[] { @@ -3391,7 +3309,7 @@ ssize_t Trigger::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has event? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { // 'event': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -148; @@ -3461,7 +3379,7 @@ size_t Trigger::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string event, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { size_t event_s = m_event.size(); r += event_s + wiresize(event_s) + 1 /* tag(event) 0x8 */; } @@ -3479,8 +3397,6 @@ size_t Trigger::calcSize() const bool Trigger::operator != (const Trigger &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_event() && (m_event != r.m_event)) return true; if (m_action != r.m_action) @@ -3511,8 +3427,6 @@ int Trigger::setByName(const char *name, const char *value) } m_event = value; int r = m_event.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"action",6)) { @@ -3548,26 +3462,18 @@ int Trigger::setByName(const char *name, const char *value) return -155; } -Message *Trigger::p_getMember(const char *s, const char *e) +Message *Trigger::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Trigger::p_getMember(const char *s, const char *e, unsigned x) +Message *Trigger::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AppParam::AppParam() -: m_key() -, m_uValue(0) -, m_sValue() -, m_dValue(0) -, m_fValue(0) -, p_validbits(0) -{ -} - void AppParam::clear() { m_key.clear(); @@ -3613,7 +3519,6 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) m_key.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x10: // uValue id 2, type uint32_t, coding varint { @@ -3635,7 +3540,6 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) m_sValue.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 2); break; case 0x20: // dValue id 4, type int32_t, coding signed varint { @@ -3676,7 +3580,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has key? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { // 'key': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -164; @@ -3690,7 +3594,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += key_s; } // has uValue? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'uValue': id=2, encoding=varint, tag=0x10 if (a >= e) return -166; @@ -3701,7 +3605,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has sValue? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { // 'sValue': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -168; @@ -3715,7 +3619,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += sValue_s; } // has dValue? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'dValue': id=4, encoding=varint, tag=0x20 if (a >= e) return -170; @@ -3726,7 +3630,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has fValue? - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'fValue': id=5, encoding=64bit, tag=0x29 if (9 > (e-a)) return -172; @@ -3776,25 +3680,25 @@ size_t AppParam::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string key, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { size_t key_s = m_key.size(); r += key_s + wiresize(key_s) + 1 /* tag(key) 0x8 */; } // optional unsigned uValue, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += wiresize((varint_t)m_uValue) + 1 /* tag(uValue) 0x10 */; } // optional string sValue, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { size_t sValue_s = m_sValue.size(); r += sValue_s + wiresize(sValue_s) + 1 /* tag(sValue) 0x18 */; } // optional signed dValue, id 4 - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { r += wiresize_s((varint_t)m_dValue) + 1 /* tag(dValue) 0x20 */; } // optional double fValue, id 5 - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { r += 9; } return r; @@ -3840,8 +3744,6 @@ int AppParam::setByName(const char *name, const char *value) } m_key = value; int r = m_key.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"uValue")) { @@ -3851,7 +3753,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_uValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"sValue")) { @@ -3861,8 +3763,6 @@ int AppParam::setByName(const char *name, const char *value) } m_sValue = value; int r = m_sValue.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"dValue")) { @@ -3872,7 +3772,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_s32(&m_dValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"fValue")) { @@ -3882,30 +3782,24 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_dbl(&m_fValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); return r; } return -173; } -Message *AppParam::p_getMember(const char *s, const char *e) +Message *AppParam::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AppParam::p_getMember(const char *s, const char *e, unsigned x) +Message *AppParam::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -EventTimer::EventTimer() -: m_name() -, m_time(0) -, m_config(0) -, p_validbits(0) -{ -} - void EventTimer::clear() { m_name.clear(); @@ -4165,29 +4059,23 @@ int EventTimer::setByName(const char *name, const char *value) return -187; } -Message *EventTimer::p_getMember(const char *s, const char *e) +Message *EventTimer::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *EventTimer::p_getMember(const char *s, const char *e, unsigned x) +Message *EventTimer::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -FunctionConfig::FunctionConfig() -: m_name() -, m_func() -, p_validbits(0) -{ -} - void FunctionConfig::clear() { m_name.clear(); m_func.clear(); m_params.clear(); - p_validbits = 0; } void FunctionConfig::toASCII(stream &o, size_t indent) const @@ -4234,7 +4122,6 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x12: // func id 2, type estring, coding byte[] { @@ -4246,7 +4133,6 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) m_func.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 1); break; case 0x1a: // params id 3, type estring, coding byte[] { @@ -4282,7 +4168,7 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -194; @@ -4296,7 +4182,7 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const a += name_s; } // has func? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { // 'func': id=2, encoding=lenpfx, tag=0x12 if (a >= e) return -196; @@ -4370,12 +4256,12 @@ size_t FunctionConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } // optional string func, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { size_t func_s = m_func.size(); r += func_s + wiresize(func_s) + 1 /* tag(func) 0x10 */; } @@ -4393,8 +4279,6 @@ size_t FunctionConfig::calcSize() const bool FunctionConfig::operator != (const FunctionConfig &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_name() && (m_name != r.m_name)) return true; if (has_func() && (m_func != r.m_func)) @@ -4427,8 +4311,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"func")) { @@ -4438,8 +4320,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_func = value; int r = m_func.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == memcmp(name,"params",6)) { @@ -4475,23 +4355,18 @@ int FunctionConfig::setByName(const char *name, const char *value) return -203; } -Message *FunctionConfig::p_getMember(const char *s, const char *e) +Message *FunctionConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *FunctionConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *FunctionConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SignalConfig::SignalConfig() -: m_name() -, m_type(st_invalid) -, m_iv() -{ -} - void SignalConfig::clear() { m_name.clear(); @@ -4736,23 +4611,18 @@ int SignalConfig::setByName(const char *name, const char *value) return -217; } -Message *SignalConfig::p_getMember(const char *s, const char *e) +Message *SignalConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SignalConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SignalConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -OwDeviceConfig::OwDeviceConfig() -: m_id(0) -, m_name() -, p_validbits(0) -{ -} - void OwDeviceConfig::clear() { m_id = 0; @@ -4800,7 +4670,6 @@ ssize_t OwDeviceConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 1); break; default: // unknown field (option unknown=skip) @@ -4834,7 +4703,7 @@ ssize_t OwDeviceConfig::toMemory(uint8_t *b, ssize_t s) const a += 8; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { // 'name': id=2, encoding=lenpfx, tag=0x12 if (a >= e) return -224; @@ -4881,7 +4750,7 @@ size_t OwDeviceConfig::calcSize() const r += 9; } // optional string name, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x10 */; } @@ -4932,34 +4801,27 @@ int OwDeviceConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } return -226; } -Message *OwDeviceConfig::p_getMember(const char *s, const char *e) +Message *OwDeviceConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *OwDeviceConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *OwDeviceConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -StateConfig::StateConfig() -: m_name() -, p_validbits(0) -{ -} - void StateConfig::clear() { m_name.clear(); m_conds.clear(); - p_validbits = 0; } void StateConfig::toASCII(stream &o, size_t indent) const @@ -5005,7 +4867,6 @@ ssize_t StateConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x12: // conds id 2, type Trigger, coding byte[] { @@ -5048,7 +4909,7 @@ ssize_t StateConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -233; @@ -5119,7 +4980,7 @@ size_t StateConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } @@ -5135,8 +4996,6 @@ size_t StateConfig::calcSize() const bool StateConfig::operator != (const StateConfig &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_name() && (m_name != r.m_name)) return true; if (m_conds != r.m_conds) @@ -5167,8 +5026,6 @@ int StateConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"conds",5)) { @@ -5203,33 +5060,28 @@ int StateConfig::setByName(const char *name, const char *value) return -240; } -Message *StateConfig::p_getMember(const char *s, const char *e) +Message *StateConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *StateConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *StateConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("conds[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 5) && (0 == memcmp("conds",s,5))) { if (x < m_conds.size()) return &m_conds[x]; - return 0; } return 0; } -StateMachineConfig::StateMachineConfig() -: m_name() -, m_ini_st(0) -, p_validbits(0) -{ -} - void StateMachineConfig::clear() { m_name.clear(); m_ini_st = 0; m_states.clear(); + m_persistent = false; p_validbits = 0; } @@ -5251,6 +5103,7 @@ void StateMachineConfig::toASCII(stream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; + ascii_bool(o, indent, "persistent", m_persistent); --indent; ascii_indent(o,indent); o << '}'; @@ -5277,7 +5130,6 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x10: // ini_st id 2, type uint8_t, coding varint { @@ -5307,12 +5159,17 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) } } break; + case 0x23: // persistent id 4, type bool, coding 8bit + if (a >= e) + return -246; + set_persistent(*a++); + break; default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -246; + return -247; a += s; break; } @@ -5320,7 +5177,7 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -247; + return -248; return a-(const uint8_t *)b; } @@ -5330,44 +5187,52 @@ ssize_t StateMachineConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -248; + return -249; *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 -249; + return -250; memcpy(a,m_name.data(),name_s); a += name_s; } // has ini_st? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'ini_st': id=2, encoding=varint, tag=0x10 if (a >= e) - return -250; + return -251; *a++ = 0x10; n = write_varint(a,e-a,m_ini_st); if (n <= 0) - return -251; + return -252; a += n; } for (const auto &x : m_states) { // 'states': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -252; + return -253; *a++ = 0x1a; ssize_t states_ws = x.calcSize(); n = write_varint(a,e-a,states_ws); a += n; if ((n <= 0) || (states_ws > (e-a))) - return -253; + return -254; n = x.toMemory(a,e-a); a += n; assert(n == states_ws); } + // has persistent? + if (m_persistent != false) { + // 'persistent': id=4, encoding=8bit, tag=0x23 + if (2 > (e-a)) + return -255; + *a++ = 0x23; + *a++ = m_persistent; + } assert(a <= e); return a-b; } @@ -5402,6 +5267,10 @@ void StateMachineConfig::toJSON(stream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } + if (has_persistent()) { + fsep = json_indent(json,indLvl,fsep,"persistent"); + json << (m_persistent ? "true" : "false"); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -5416,12 +5285,12 @@ size_t StateMachineConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } // optional uint8 ini_st, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += wiresize((varint_t)m_ini_st) + 1 /* tag(ini_st) 0x10 */; } // repeated StateConfig states, id 3 @@ -5431,6 +5300,10 @@ size_t StateMachineConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(states) 0x18 */; } + // optional bool persistent, id 4 + if (m_persistent != false) { + r += 2; + } return r; } @@ -5444,6 +5317,8 @@ bool StateMachineConfig::operator != (const StateMachineConfig &r) const return true; if (m_states != r.m_states) return true; + if (has_persistent() && (m_persistent != r.m_persistent)) + return true; return false; } @@ -5470,8 +5345,6 @@ int StateMachineConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"ini_st")) { @@ -5481,7 +5354,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_ini_st,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"states",6)) { @@ -5500,45 +5373,46 @@ int StateMachineConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -254; + return -256; if (m_states.size() <= x) - return -255; + return -257; if ((idxe[1] == 0) && (value == 0)) { m_states.erase(m_states.begin()+x); return 0; } } if (idxe[1] != '.') - return -256; + return -258; return m_states[x].setByName(idxe+2,value); } } - return -257; + if (0 == strcmp(name,"persistent")) { + if (value == 0) { + clear_persistent(); + return 0; + } + int r = parse_ascii_bool(&m_persistent,value); + return r; + } + return -259; } -Message *StateMachineConfig::p_getMember(const char *s, const char *e) +Message *StateMachineConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *StateMachineConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *StateMachineConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("states[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 6) && (0 == memcmp("states",s,6))) { if (x < m_states.size()) return &m_states[x]; - return 0; } return 0; } -ThresholdConfig::ThresholdConfig() -: m_name() -, m_low(0) -, m_high(0) -, p_validbits(0) -{ -} - void ThresholdConfig::clear() { m_name.clear(); @@ -5567,7 +5441,7 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -258; + return -260; a += fn; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] @@ -5576,21 +5450,20 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -259; + return -261; m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x15: // low id 2, type float, coding 32bit if ((a+3) >= e) - return -260; + return -262; set_low(read_float(a)); a += 4; break; case 0x1d: // high id 3, type float, coding 32bit if ((a+3) >= e) - return -261; + return -263; set_high(read_float(a)); a += 4; break; @@ -5599,7 +5472,7 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -262; + return -264; a += s; break; } @@ -5607,7 +5480,7 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -263; + return -265; return a-(const uint8_t *)b; } @@ -5617,38 +5490,38 @@ ssize_t ThresholdConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -264; + return -266; *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 -265; + return -267; memcpy(a,m_name.data(),name_s); a += name_s; } // has low? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'low': id=2, encoding=32bit, tag=0x15 if (5 > (e-a)) - return -266; + return -268; *a++ = 0x15; if ((e-a) < 4) - return -267; + return -269; write_u32(a,mangle_float(m_low)); a += 4; } // has high? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'high': id=3, encoding=32bit, tag=0x1d if (5 > (e-a)) - return -268; + return -270; *a++ = 0x1d; if ((e-a) < 4) - return -269; + return -271; write_u32(a,mangle_float(m_high)); a += 4; } @@ -5686,16 +5559,16 @@ size_t ThresholdConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } // optional float low, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += 5; } // optional float high, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { r += 5; } return r; @@ -5737,8 +5610,6 @@ int ThresholdConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"low")) { @@ -5748,7 +5619,7 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_low,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"high")) { @@ -5758,26 +5629,24 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_high,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } - return -270; + return -272; } -Message *ThresholdConfig::p_getMember(const char *s, const char *e) +Message *ThresholdConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *ThresholdConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *ThresholdConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -LuaConfig::LuaConfig() -{ -} - void LuaConfig::clear() { m_init_scripts.clear(); @@ -5825,7 +5694,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -271; + return -273; a += fn; switch (fid) { case 0xa: // init_scripts id 1, type estring, coding byte[] @@ -5834,7 +5703,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -272; + return -274; m_init_scripts.emplace_back((const char*)a,v); a += v; } @@ -5845,7 +5714,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -273; + return -275; m_compile_files.emplace_back((const char*)a,v); a += v; } @@ -5855,7 +5724,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -274; + return -276; a += s; break; } @@ -5863,7 +5732,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -275; + return -277; return a-(const uint8_t *)b; } @@ -5875,26 +5744,26 @@ ssize_t LuaConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_init_scripts) { // 'init_scripts': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -276; + return -278; *a++ = 0xa; ssize_t init_scripts_s = x.size(); n = write_varint(a,e-a,init_scripts_s); a += n; if ((n <= 0) || ((e-a) < init_scripts_s)) - return -277; + return -279; memcpy(a,x.data(),init_scripts_s); a += init_scripts_s; } for (const auto &x : m_compile_files) { // 'compile_files': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -278; + return -280; *a++ = 0x12; ssize_t compile_files_s = x.size(); n = write_varint(a,e-a,compile_files_s); a += n; if ((n <= 0) || ((e-a) < compile_files_s)) - return -279; + return -281; memcpy(a,x.data(),compile_files_s); a += compile_files_s; } @@ -6017,16 +5886,16 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+13,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+13))) - return -280; + return -282; if (m_init_scripts.size() <= x) - return -281; + return -283; if ((idxe[1] == 0) && (value == 0)) { m_init_scripts.erase(m_init_scripts.begin()+x); return 0; } } if (idxe[1] != 0) - return -282; + return -284; m_init_scripts[x] = value; return m_init_scripts[x].size(); } @@ -6047,83 +5916,35 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+14,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+14))) - return -283; + return -285; if (m_compile_files.size() <= x) - return -284; + return -286; if ((idxe[1] == 0) && (value == 0)) { m_compile_files.erase(m_compile_files.begin()+x); return 0; } } if (idxe[1] != 0) - return -285; + return -287; m_compile_files[x] = value; return m_compile_files[x].size(); } } - return -286; + return -288; } -Message *LuaConfig::p_getMember(const char *s, const char *e) +Message *LuaConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *LuaConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *LuaConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -NodeConfig::NodeConfig() -: m_magic(0) -, m_nodename() -, m_pass_hash() -, m_cpu_freq(0) -, m_syslog_host() -, m_sntp_server() -, m_timezone() -#ifdef CONFIG_MQTT -#endif // CONFIG_MQTT -, m_dmesg_size(2048) -#ifdef CONFIG_INFLUX -#endif // CONFIG_INFLUX -, m_station2ap_time(0) -, m_domainname() -, m_actions_enable(1) -#ifdef CONFIG_TERMSERV -#endif // CONFIG_TERMSERV -, m_udp_ctrl_port(12719) -#ifdef CONFIG_FTP -#endif // CONFIG_FTP -#ifdef CONFIG_HTTP -#endif // CONFIG_HTTP -, m_otasrv() -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member signals -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member functions -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_STATEMACHINES -#endif // CONFIG_STATEMACHINES -, m_max_on_time(0) -, m_threshold_off(0) -, m_threshold_on(0) -, m_dim_step(0) -, m_lightctrl(0) -, m_pwm_freq(0) -#ifdef CONFIG_APP_PARAMS -#endif // CONFIG_APP_PARAMS -#ifdef CONFIG_THRESHOLDS -#endif // CONFIG_THRESHOLDS -#ifdef CONFIG_LUA -#endif // CONFIG_LUA -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -, p_validbits(0) -{ -} - void NodeConfig::clear() { m_magic = 0; @@ -6411,12 +6232,12 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -287; + return -289; a += fn; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit if ((a+3) >= e) - return -288; + return -290; set_magic((uint32_t) read_u32(a)); a += 4; break; @@ -6426,7 +6247,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 -289; + return -291; m_nodename.assign((const char*)a,v); a += v; } @@ -6437,18 +6258,17 @@ 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 -290; + return -292; m_pass_hash.assign((const char*)a,v); a += v; } - p_validbits |= ((uint32_t)1U << 1); break; case 0x18: // cpu_freq id 3, type uint32_t, coding varint { varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -291; + return -293; a += n; set_cpu_freq(v); } @@ -6459,17 +6279,17 @@ 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 -292; + return -294; if (v != 0) { n = m_station.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -293; + return -295; a += v; } } - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); break; case 0x2a: // softap id 5, type WifiConfig, coding byte[] { @@ -6477,17 +6297,17 @@ 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 -294; + return -296; if (v != 0) { n = m_softap.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -295; + return -297; a += v; } } - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); break; case 0x32: // dns_server id 6, type estring, coding byte[] { @@ -6495,7 +6315,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 -296; + return -298; m_dns_server.emplace_back((const char*)a,v); a += v; } @@ -6506,7 +6326,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 -297; + return -299; m_syslog_host.assign((const char*)a,v); a += v; } @@ -6517,7 +6337,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 -298; + return -300; m_sntp_server.assign((const char*)a,v); a += v; } @@ -6528,7 +6348,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 -299; + return -301; m_timezone.assign((const char*)a,v); a += v; } @@ -6540,22 +6360,22 @@ 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 -300; + return -302; if (v != 0) { n = m_mqtt.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -301; + return -303; a += v; } } - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); break; #endif // CONFIG_MQTT case 0x5c: // dmesg_size id 11, type uint16_t, coding 16bit if ((a+1) >= e) - return -302; + return -304; set_dmesg_size((uint16_t) read_u16(a)); a += 2; break; @@ -6566,17 +6386,17 @@ 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 -303; + return -305; if (v != 0) { n = m_influx.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -304; + return -306; a += v; } } - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); break; #endif // CONFIG_INFLUX case 0x68: // station2ap_time id 13, type uint32_t, coding varint @@ -6584,7 +6404,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 -305; + return -307; a += n; set_station2ap_time(v); } @@ -6595,7 +6415,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 -306; + return -308; m_domainname.assign((const char*)a,v); a += v; } @@ -6606,14 +6426,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 -307; + return -309; m_holidays.emplace_back(); if (v != 0) { n = m_holidays.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -308; + return -310; a += v; } } @@ -6624,14 +6444,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 -309; + return -311; m_at_actions.emplace_back(); if (v != 0) { n = m_at_actions.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -310; + return -312; a += v; } } @@ -6641,7 +6461,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 -311; + return -313; a += n; set_actions_enable(v); } @@ -6652,14 +6472,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 -312; + return -314; m_triggers.emplace_back(); if (v != 0) { n = m_triggers.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -313; + return -315; a += v; } } @@ -6670,14 +6490,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 -314; + return -316; 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 -315; + return -317; a += v; } } @@ -6689,14 +6509,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 -316; + return -318; m_terminal.emplace_back(); if (v != 0) { n = m_terminal.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -317; + return -319; a += v; } } @@ -6704,7 +6524,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) #endif // CONFIG_TERMSERV case 0xb4: // udp_ctrl_port id 22, type uint16_t, coding 16bit if ((a+1) >= e) - return -318; + return -320; set_udp_ctrl_port((uint16_t) read_u16(a)); a += 2; break; @@ -6714,7 +6534,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 -319; + return -321; m_debugs.emplace_back((const char*)a,v); a += v; } @@ -6726,17 +6546,17 @@ 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 -320; + return -322; if (v != 0) { n = m_ftpd.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -321; + return -323; a += v; } } - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); break; #endif // CONFIG_FTP #ifdef CONFIG_HTTP @@ -6746,17 +6566,17 @@ 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 -322; + return -324; if (v != 0) { n = m_httpd.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -323; + return -325; a += v; } } - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); break; #endif // CONFIG_HTTP case 0xd2: // otasrv id 26, type estring, coding byte[] @@ -6765,11 +6585,10 @@ 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 -324; + return -326; 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[] { @@ -6777,14 +6596,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 -325; + return -327; 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 -326; + return -328; a += v; } } @@ -6796,14 +6615,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 -327; + return -329; 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 -328; + return -330; a += v; } } @@ -6814,7 +6633,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 -329; + return -331; a += n; set_max_on_time(v); } @@ -6824,7 +6643,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 -332; a += n; set_threshold_off(v); } @@ -6834,7 +6653,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 -331; + return -333; a += n; set_threshold_on(v); } @@ -6844,14 +6663,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 -332; + return -334; a += n; set_dim_step(v); } break; case 0x133: // lightctrl id 38, type bool, coding 8bit if (a >= e) - return -333; + return -335; set_lightctrl(*a++); break; case 0x138: // pwm_freq id 39, type uint32_t, coding varint @@ -6859,7 +6678,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 -334; + return -336; a += n; set_pwm_freq(v); } @@ -6871,14 +6690,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 -335; + return -337; 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 -336; + return -338; a += v; } } @@ -6891,14 +6710,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 -337; + return -339; 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 -338; + return -340; a += v; } } @@ -6911,7 +6730,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 -339; + return -341; m_luafiles.emplace_back((const char*)a,v); a += v; } @@ -6924,14 +6743,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 -340; + return -342; 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 -341; + return -343; a += v; } } @@ -6942,7 +6761,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 -342; + return -344; a += s; break; } @@ -6950,7 +6769,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -343; + return -345; return a-(const uint8_t *)b; } @@ -6963,10 +6782,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 -344; + return -346; *a++ = 0x5; if ((e-a) < 4) - return -345; + return -347; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -6974,67 +6793,67 @@ 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 -346; + return -348; *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 -347; + return -349; memcpy(a,m_nodename.data(),nodename_s); a += nodename_s; } // has pass_hash? - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -348; + return -350; *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 -349; + return -351; memcpy(a,m_pass_hash.data(),pass_hash_s); a += pass_hash_s; } // has cpu_freq? - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -350; + return -352; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -351; + return -353; a += n; } // has station? - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -352; + return -354; *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 -353; + return -355; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); } // has softap? - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -354; + return -356; *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 -355; + return -357; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -7042,13 +6861,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 -356; + return -358; *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 -357; + return -359; memcpy(a,x.data(),dns_server_s); a += dns_server_s; } @@ -7056,13 +6875,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 -358; + return -360; *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 -359; + return -361; memcpy(a,m_syslog_host.data(),syslog_host_s); a += syslog_host_s; } @@ -7070,13 +6889,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 -360; + return -362; *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 -361; + return -363; memcpy(a,m_sntp_server.data(),sntp_server_s); a += sntp_server_s; } @@ -7084,95 +6903,95 @@ 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 -362; + return -364; *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 -363; + return -365; memcpy(a,m_timezone.data(),timezone_s); a += timezone_s; } #ifdef CONFIG_MQTT // has mqtt? - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -364; + return -366; *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 -365; + return -367; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); } #endif // CONFIG_MQTT // has dmesg_size? - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -366; + return -368; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; } #ifdef CONFIG_INFLUX // has influx? - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -367; + return -369; *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 -368; + return -370; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); } #endif // CONFIG_INFLUX // has station2ap_time? - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -369; + return -371; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -370; + return -372; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -371; + return -373; *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 -372; + return -374; 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 -373; + return -375; *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 -374; + return -376; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -7180,41 +6999,41 @@ 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 -375; + return -377; *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 -376; + return -378; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); } // has actions_enable? - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -377; + return -379; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -378; + return -380; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -379; + return -381; *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 -380; + return -382; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -7222,14 +7041,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 -381; + return -383; *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 -382; + return -384; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -7238,24 +7057,24 @@ 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 -383; + return -385; *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 -384; + return -386; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); } #endif // CONFIG_TERMSERV // has udp_ctrl_port? - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -385; + return -387; *a++ = 0xb4; *a++ = 0x1; write_u16(a,m_udp_ctrl_port); @@ -7264,30 +7083,30 @@ 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 -386; + return -388; *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 -387; + return -389; memcpy(a,x.data(),debugs_s); a += debugs_s; } #ifdef CONFIG_FTP // has ftpd? - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -388; + return -390; *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 -389; + return -391; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -7295,48 +7114,48 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_FTP #ifdef CONFIG_HTTP // has httpd? - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -390; + return -392; *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 -391; + return -393; 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))) { + if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 if (2 > (e-a)) - return -392; + return -394; *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 -393; + return -395; 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 -394; + return -396; *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 -395; + return -397; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -7351,89 +7170,67 @@ 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 -396; + return -398; *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 -397; + return -399; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. - // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { - // 'threshold_off': id=35, encoding=varint, tag=0x118 - if (2 > (e-a)) - return -398; - *a++ = 0x98; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_off); - if (n <= 0) - return -399; - a += n; - } - // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { - // 'threshold_on': id=36, encoding=varint, tag=0x120 - if (2 > (e-a)) - return -400; - *a++ = 0xa0; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_on); - if (n <= 0) - return -401; - a += n; - } + // 'threshold_off' is deprecated. Therefore no data will be written. + // 'threshold_on' is deprecated. Therefore no data will be written. // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -402; + return -400; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -403; + return -401; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -404; + return -402; *a++ = 0xb3; *a++ = 0x2; *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -405; + return -403; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -406; + return -404; a += n; } #ifdef CONFIG_APP_PARAMS for (const auto &x : m_app_params) { // 'app_params': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) - return -407; + return -405; *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 -408; + return -406; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -7443,14 +7240,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 -409; + return -407; *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 -410; + return -408; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -7460,14 +7257,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 -411; + return -409; *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 -412; + return -410; memcpy(a,x.data(),luafiles_s); a += luafiles_s; } @@ -7476,14 +7273,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 -413; + return -411; *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 -414; + return -412; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -7874,21 +7671,21 @@ size_t NodeConfig::calcSize() const r += nodename_s + wiresize(nodename_s) + 1 /* tag(nodename) 0x8 */; } // optional bytes pass_hash, id 2 - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { size_t pass_hash_s = m_pass_hash.size(); r += pass_hash_s + wiresize(pass_hash_s) + 1 /* tag(pass_hash) 0x10 */; } // optional unsigned cpu_freq, id 3 - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { r += wiresize((varint_t)m_cpu_freq) + 1 /* tag(cpu_freq) 0x18 */; } // optional WifiConfig station, id 4 - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { size_t station_s = m_station.calcSize(); r += station_s + wiresize(station_s) + 1 /* tag(station) 0x20 */; } // optional WifiConfig softap, id 5 - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { size_t softap_s = m_softap.calcSize(); r += softap_s + wiresize(softap_s) + 1 /* tag(softap) 0x28 */; } @@ -7918,24 +7715,24 @@ size_t NodeConfig::calcSize() const } #ifdef CONFIG_MQTT // optional MQTT mqtt, id 10 - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { size_t mqtt_s = m_mqtt.calcSize(); r += mqtt_s + wiresize(mqtt_s) + 1 /* tag(mqtt) 0x50 */; } #endif // CONFIG_MQTT // optional fixed16 dmesg_size, id 11 - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { r += 3; } #ifdef CONFIG_INFLUX // optional Influx influx, id 12 - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { size_t influx_s = m_influx.calcSize(); r += influx_s + wiresize(influx_s) + 1 /* tag(influx) 0x60 */; } #endif // CONFIG_INFLUX // optional unsigned station2ap_time, id 13 - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { r += wiresize((varint_t)m_station2ap_time) + 1 /* tag(station2ap_time) 0x68 */; } // optional string domainname, id 15 @@ -7958,7 +7755,7 @@ size_t NodeConfig::calcSize() const r += s + 2 /* tag(at_actions) 0x88 */; } // optional unsigned actions_enable, id 18 - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { r += wiresize((varint_t)m_actions_enable) + 2 /* tag(actions_enable) 0x90 */; } // repeated Trigger triggers, id 19 @@ -7985,7 +7782,7 @@ size_t NodeConfig::calcSize() const } #endif // CONFIG_TERMSERV // optional fixed16 udp_ctrl_port, id 22 - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { r += 4; } // repeated string debugs, id 23 @@ -7999,20 +7796,20 @@ size_t NodeConfig::calcSize() const } #ifdef CONFIG_FTP // optional FtpHttpConfig ftpd, id 24 - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { size_t ftpd_s = m_ftpd.calcSize(); r += ftpd_s + wiresize(ftpd_s) + 2 /* tag(ftpd) 0xc0 */; } #endif // CONFIG_FTP #ifdef CONFIG_HTTP // optional FtpHttpConfig httpd, id 25 - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { size_t httpd_s = m_httpd.calcSize(); r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } #endif // CONFIG_HTTP // optional string otasrv, id 26 - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (!m_otasrv.empty()) { size_t otasrv_s = m_otasrv.size(); r += otasrv_s + wiresize(otasrv_s) + 2 /* tag(otasrv) 0xd0 */; } @@ -8039,24 +7836,18 @@ 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 << 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 << 15))) { - r += wiresize((varint_t)m_threshold_on) + 2 /* tag(threshold_on) 0x120 */; - } + // deprecated optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_on, id 36 // optional unsigned dim_step, id 37 - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { r += wiresize((varint_t)m_dim_step) + 2 /* tag(dim_step) 0x128 */; } // optional bool lightctrl, id 38 - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { r += 3; } // optional unsigned pwm_freq, id 39 - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { r += wiresize((varint_t)m_pwm_freq) + 2 /* tag(pwm_freq) 0x138 */; } #ifdef CONFIG_APP_PARAMS @@ -8244,8 +8035,6 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_pass_hash,value); - if (r > 0) - p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == strcmp(name,"cpu_freq")) { @@ -8255,7 +8044,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_cpu_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == memcmp(name,"station",7)) { @@ -8263,7 +8052,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_station(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); return m_station.setByName(name+8,value); } } @@ -8272,7 +8061,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_softap(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); return m_softap.setByName(name+7,value); } } @@ -8292,16 +8081,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -415; + return -413; if (m_dns_server.size() <= x) - return -416; + return -414; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -417; + return -415; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -8339,7 +8128,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_mqtt(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); return m_mqtt.setByName(name+5,value); } } @@ -8351,7 +8140,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_dmesg_size,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); return r; } #ifdef CONFIG_INFLUX @@ -8360,7 +8149,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_influx(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); return m_influx.setByName(name+7,value); } } @@ -8372,7 +8161,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_station2ap_time,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); return r; } if (0 == strcmp(name,"domainname")) { @@ -8400,16 +8189,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -418; + return -416; if (m_holidays.size() <= x) - return -419; + return -417; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -420; + return -418; return m_holidays[x].setByName(idxe+2,value); } } @@ -8429,16 +8218,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -421; + return -419; if (m_at_actions.size() <= x) - return -422; + return -420; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -423; + return -421; return m_at_actions[x].setByName(idxe+2,value); } } @@ -8449,7 +8238,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_actions_enable,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); return r; } if (0 == memcmp(name,"triggers",8)) { @@ -8468,16 +8257,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -424; + return -422; if (m_triggers.size() <= x) - return -425; + return -423; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -426; + return -424; return m_triggers[x].setByName(idxe+2,value); } } @@ -8497,16 +8286,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+5,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+5))) - return -427; + return -425; if (m_uart.size() <= x) - return -428; + return -426; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -429; + return -427; return m_uart[x].setByName(idxe+2,value); } } @@ -8527,16 +8316,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -430; + return -428; if (m_terminal.size() <= x) - return -431; + return -429; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -432; + return -430; return m_terminal[x].setByName(idxe+2,value); } } @@ -8548,7 +8337,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_udp_ctrl_port,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); return r; } if (0 == memcmp(name,"debugs",6)) { @@ -8567,16 +8356,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -433; + return -431; if (m_debugs.size() <= x) - return -434; + return -432; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -435; + return -433; m_debugs[x] = value; return m_debugs[x].size(); } @@ -8587,7 +8376,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_ftpd(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); return m_ftpd.setByName(name+5,value); } } @@ -8598,7 +8387,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_httpd(); return 0; } else if (name[5] == '.') { - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); return m_httpd.setByName(name+6,value); } } @@ -8610,8 +8399,6 @@ int NodeConfig::setByName(const char *name, const char *value) } 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)) { @@ -8630,16 +8417,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -436; + return -434; if (m_timefuses.size() <= x) - return -437; + return -435; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -438; + return -436; return m_timefuses[x].setByName(idxe+2,value); } } @@ -8660,16 +8447,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -439; + return -437; if (m_statemachs.size() <= x) - return -440; + return -438; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -441; + return -439; return m_statemachs[x].setByName(idxe+2,value); } } @@ -8689,7 +8476,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 << 14); + p_validbits |= ((uint32_t)1U << 12); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -8699,7 +8486,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 << 15); + p_validbits |= ((uint32_t)1U << 13); return r; } if (0 == strcmp(name,"dim_step")) { @@ -8709,7 +8496,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 << 16); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -8719,7 +8506,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 << 17); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -8729,7 +8516,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 << 18); + p_validbits |= ((uint32_t)1U << 16); return r; } #ifdef CONFIG_APP_PARAMS @@ -8749,16 +8536,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -442; + return -440; if (m_app_params.size() <= x) - return -443; + return -441; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -444; + return -442; return m_app_params[x].setByName(idxe+2,value); } } @@ -8780,16 +8567,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -445; + return -443; if (m_thresholds.size() <= x) - return -446; + return -444; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -447; + return -445; return m_thresholds[x].setByName(idxe+2,value); } } @@ -8811,16 +8598,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -448; + return -446; if (m_luafiles.size() <= x) - return -449; + return -447; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -450; + return -448; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -8843,124 +8630,103 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -451; + return -449; if (m_owdevices.size() <= x) - return -452; + return -450; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -453; + return -451; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -454; + return -452; } -Message *NodeConfig::p_getMember(const char *s, const char *e) +Message *NodeConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("station",s,e-s)) + // caller guarantee: s[n] == '.' + if ((n == 7) && (0 == memcmp("station",s,7))) return &m_station; - if (0 == strncmp("softap",s,e-s)) + if ((n == 6) && (0 == memcmp("softap",s,6))) return &m_softap; #ifdef CONFIG_MQTT - if (0 == strncmp("mqtt",s,e-s)) + if ((n == 4) && (0 == memcmp("mqtt",s,4))) return &m_mqtt; #endif // CONFIG_MQTT #ifdef CONFIG_INFLUX - if (0 == strncmp("influx",s,e-s)) + if ((n == 6) && (0 == memcmp("influx",s,6))) return &m_influx; #endif // CONFIG_INFLUX #ifdef CONFIG_FTP - if (0 == strncmp("ftpd",s,e-s)) + if ((n == 4) && (0 == memcmp("ftpd",s,4))) return &m_ftpd; #endif // CONFIG_FTP #ifdef CONFIG_HTTP - if (0 == strncmp("httpd",s,e-s)) + if ((n == 5) && (0 == memcmp("httpd",s,5))) return &m_httpd; #endif // CONFIG_HTTP return 0; } -Message *NodeConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *NodeConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("holidays[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 8) && (0 == memcmp("holidays",s,8))) { if (x < m_holidays.size()) return &m_holidays[x]; - return 0; - } - if (0 == strncmp("at_actions[",s,e-s)) { + } else if ((n == 10) && (0 == memcmp("at_actions",s,10))) { if (x < m_at_actions.size()) return &m_at_actions[x]; - return 0; - } - if (0 == strncmp("triggers[",s,e-s)) { + } else if ((n == 8) && (0 == memcmp("triggers",s,8))) { if (x < m_triggers.size()) return &m_triggers[x]; - return 0; - } - if (0 == strncmp("uart[",s,e-s)) { + } else if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - return 0; - } - #ifdef CONFIG_TERMSERV - if (0 == strncmp("terminal[",s,e-s)) { + #ifdef CONFIG_TERMSERV + } else if ((n == 8) && (0 == memcmp("terminal",s,8))) { if (x < m_terminal.size()) return &m_terminal[x]; - return 0; - } - #endif // CONFIG_TERMSERV - if (0 == strncmp("timefuses[",s,e-s)) { + #endif // CONFIG_TERMSERV + } else if ((n == 9) && (0 == memcmp("timefuses",s,9))) { if (x < m_timefuses.size()) return &m_timefuses[x]; - return 0; - } - #ifdef CONFIG_SIGNAL_PROC - if (0 == strncmp("signals[",s,e-s)) { + #ifdef CONFIG_SIGNAL_PROC + } else if ((n == 7) && (0 == memcmp("signals",s,7))) { if (x < m_signals.size()) return &m_signals[x]; - return 0; - } - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - if (0 == strncmp("functions[",s,e-s)) { + #endif // CONFIG_SIGNAL_PROC + #ifdef CONFIG_SIGNAL_PROC + } else if ((n == 9) && (0 == memcmp("functions",s,9))) { if (x < m_functions.size()) return &m_functions[x]; - return 0; - } - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - if (0 == strncmp("statemachs[",s,e-s)) { + #endif // CONFIG_SIGNAL_PROC + #ifdef CONFIG_STATEMACHINES + } else if ((n == 10) && (0 == memcmp("statemachs",s,10))) { if (x < m_statemachs.size()) return &m_statemachs[x]; - return 0; - } - #endif // CONFIG_STATEMACHINES - #ifdef CONFIG_APP_PARAMS - if (0 == strncmp("app_params[",s,e-s)) { + #endif // CONFIG_STATEMACHINES + #ifdef CONFIG_APP_PARAMS + } else if ((n == 10) && (0 == memcmp("app_params",s,10))) { if (x < m_app_params.size()) return &m_app_params[x]; - return 0; - } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS - if (0 == strncmp("thresholds[",s,e-s)) { + #endif // CONFIG_APP_PARAMS + #ifdef CONFIG_THRESHOLDS + } else if ((n == 10) && (0 == memcmp("thresholds",s,10))) { if (x < m_thresholds.size()) return &m_thresholds[x]; - return 0; - } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_ONEWIRE - if (0 == strncmp("owdevices[",s,e-s)) { + #endif // CONFIG_THRESHOLDS + #ifdef CONFIG_ONEWIRE + } else if ((n == 9) && (0 == memcmp("owdevices",s,9))) { if (x < m_owdevices.size()) return &m_owdevices[x]; - return 0; + #endif // CONFIG_ONEWIRE } - #endif // CONFIG_ONEWIRE return 0; } diff --git a/components/wfc/swcfg_esp32.h b/components/wfc/swcfg_esp32.h index ceb183c..1cf6c9d 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -48,6 +48,7 @@ * options from common: * BaseClass : "Message" * getMember : "getMember" + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -73,7 +74,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * toJSON : "toJSON" * toMemory : "toMemory" * UnknownField : "skip" @@ -215,10 +215,14 @@ size_t parse_ascii_sigtype_t(sigtype_t *, const char *); typedef uint16_t uartcfg_t; typedef uint8_t eventcfg_t; + + class WifiConfig : public Message { public: - WifiConfig(); + WifiConfig() + { + } bool operator != (const WifiConfig &r) const; bool operator == (const WifiConfig &r) const; @@ -422,32 +426,36 @@ class WifiConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string ssid, id 1 estring m_ssid; //! string pass, id 2 estring m_pass; //! bytes mac, id 3 estring m_mac; - //! bool activate, id 4 - bool m_activate; //! fixed32 addr4, id 5 - uint32_t m_addr4; - //! fixed8 netmask4, id 6 - uint8_t m_netmask4; + uint32_t m_addr4 = 0; //! fixed32 gateway4, id 7 - uint32_t m_gateway4; + uint32_t m_gateway4 = 0; + //! bool activate, id 4 + bool m_activate = false; + //! fixed8 netmask4, id 6 + uint8_t m_netmask4 = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class MQTT : public Message { public: - MQTT(); + MQTT() + { + } bool operator != (const MQTT &r) const; bool operator == (const MQTT &r) const; @@ -650,12 +658,10 @@ class MQTT : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string uri, id 1 estring m_uri; - //! bool enable, id 2 - bool m_enable; //! string username, id 3 estring m_username; //! string password, id 4 @@ -663,17 +669,23 @@ class MQTT : public Message //! string subscribtions, id 5 std::vector m_subscribtions; //! uint16 keepalive, id 6 - uint16_t m_keepalive; + uint16_t m_keepalive = 60; + //! bool enable, id 2 + bool m_enable = false; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Date : public Message { public: - Date(); + Date() + { + } bool operator != (const Date &r) const; bool operator == (const Date &r) const; @@ -844,27 +856,31 @@ class Date : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); + //! fixed16 year, id 3 + uint16_t m_year = 0; //! fixed8 day, id 1 - uint8_t m_day; + uint8_t m_day = 0; //! fixed8 month, id 2 - uint8_t m_month; - //! fixed16 year, id 3 - uint16_t m_year; + uint8_t m_month = 0; //! fixed8 endday, id 4 - uint8_t m_endday; + uint8_t m_endday = 0; //! fixed8 endmonth, id 5 - uint8_t m_endmonth; + uint8_t m_endmonth = 0; //! fixed8 endyear, id 6 - uint8_t m_endyear; + uint8_t m_endyear = 0; }; + + class AtAction : public Message { public: - AtAction(); + AtAction() + { + } bool operator != (const AtAction &r) const; bool operator == (const AtAction &r) const; @@ -1000,26 +1016,30 @@ class AtAction : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! WeekDay day, id 1 - WeekDay m_day; - //! unsigned min_of_day, id 2 - uint32_t m_min_of_day; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string action, id 3 estring m_action; + //! WeekDay day, id 1 + WeekDay m_day = Sunday; + //! unsigned min_of_day, id 2 + uint32_t m_min_of_day = 0; //! bool enable, id 4 - bool m_enable; + bool m_enable = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Influx : public Message { public: - Influx(); + Influx() + { + } bool operator != (const Influx &r) const; bool operator == (const Influx &r) const; @@ -1179,24 +1199,27 @@ class Influx : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string hostname, id 1 estring m_hostname; - //! fixed16 port, id 2 - uint16_t m_port; //! string measurement, id 3 estring m_measurement; - // omitted obsolete member interval //! string database, id 5 estring m_database; + //! fixed16 port, id 2 + uint16_t m_port = 0; }; + + class UartSettings : public Message { public: - UartSettings(); + UartSettings() + { + } bool operator != (const UartSettings &r) const; bool operator == (const UartSettings &r) const; @@ -1391,30 +1414,34 @@ class UartSettings : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! uint8 port, id 1 - uint8_t m_port; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! unsigned baudrate, id 2 - uint32_t m_baudrate; - //! uartcfg_t config, id 3 - uartcfg_t m_config; - //! fixed8 rx_thresh, id 4 - uint8_t m_rx_thresh; + uint32_t m_baudrate = 0; //! unsigned tx_bufsize, id 6 - uint32_t m_tx_bufsize; + uint32_t m_tx_bufsize = 0; //! unsigned rx_bufsize, id 7 - uint32_t m_rx_bufsize; + uint32_t m_rx_bufsize = 0; + //! uartcfg_t config, id 3 + uartcfg_t m_config = 5; + //! uint8 port, id 1 + uint8_t m_port = 0; + //! fixed8 rx_thresh, id 4 + uint8_t m_rx_thresh = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FtpHttpConfig : public Message { public: - FtpHttpConfig(); + FtpHttpConfig() + { + } bool operator != (const FtpHttpConfig &r) const; bool operator == (const FtpHttpConfig &r) const; @@ -1565,26 +1592,30 @@ class FtpHttpConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! fixed16 port, id 1 - uint16_t m_port; - //! bool start, id 2 - bool m_start; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string root, id 3 estring m_root; //! string uploaddir, id 4 estring m_uploaddir; + //! fixed16 port, id 1 + uint16_t m_port = 0; + //! bool start, id 2 + bool m_start = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TerminalConfig : public Message { public: - TerminalConfig(); + TerminalConfig() + { + } bool operator != (const TerminalConfig &r) const; bool operator == (const TerminalConfig &r) const; @@ -1709,24 +1740,25 @@ class TerminalConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! sint8 uart_rx, id 1 - int8_t m_uart_rx; - //! sint8 uart_tx, id 2 - int8_t m_uart_tx; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 3 estring m_name; - - private: - uint8_t p_validbits; + //! sint8 uart_rx, id 1 + int8_t m_uart_rx = -1; + //! sint8 uart_tx, id 2 + int8_t m_uart_tx = -1; }; + + class Trigger : public Message { public: - Trigger(); + Trigger() + { + } bool operator != (const Trigger &r) const; bool operator == (const Trigger &r) const; @@ -1841,22 +1873,23 @@ class Trigger : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string event, id 1 estring m_event; //! string action, id 2 std::vector m_action; - - private: - uint8_t p_validbits; }; + + class AppParam : public Message { public: - AppParam(); + AppParam() + { + } bool operator != (const AppParam &r) const; bool operator == (const AppParam &r) const; @@ -2025,28 +2058,32 @@ class AppParam : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string key, id 1 estring m_key; - //! unsigned uValue, id 2 - uint32_t m_uValue; //! string sValue, id 3 estring m_sValue; - //! signed dValue, id 4 - int32_t m_dValue; //! double fValue, id 5 - double m_fValue; + double m_fValue = 0; + //! unsigned uValue, id 2 + uint32_t m_uValue = 0; + //! signed dValue, id 4 + int32_t m_dValue = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class EventTimer : public Message { public: - EventTimer(); + EventTimer() + { + } bool operator != (const EventTimer &r) const; bool operator == (const EventTimer &r) const; @@ -2179,24 +2216,28 @@ class EventTimer : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! unsigned time, id 2 - uint32_t m_time; + uint32_t m_time = 0; //! eventcfg_t config, id 3 - eventcfg_t m_config; + eventcfg_t m_config = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FunctionConfig : public Message { public: - FunctionConfig(); + FunctionConfig() + { + } bool operator != (const FunctionConfig &r) const; bool operator == (const FunctionConfig &r) const; @@ -2337,24 +2378,25 @@ class FunctionConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! string func, id 2 estring m_func; //! string params, id 3 std::vector m_params; - - private: - uint8_t p_validbits; }; + + class SignalConfig : public Message { public: - SignalConfig(); + SignalConfig() + { + } bool operator != (const SignalConfig &r) const; bool operator == (const SignalConfig &r) const; @@ -2487,21 +2529,25 @@ class SignalConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; - //! sigtype_t type, id 2 - sigtype_t m_type; //! string iv, id 3 estring m_iv; + //! sigtype_t type, id 2 + sigtype_t m_type = st_invalid; }; + + class OwDeviceConfig : public Message { public: - OwDeviceConfig(); + OwDeviceConfig() + { + } bool operator != (const OwDeviceConfig &r) const; bool operator == (const OwDeviceConfig &r) const; @@ -2608,22 +2654,26 @@ class OwDeviceConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! fixed64 id, id 1 - uint64_t m_id; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 2 estring m_name; + //! fixed64 id, id 1 + uint64_t m_id = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class StateConfig : public Message { public: - StateConfig(); + StateConfig() + { + } bool operator != (const StateConfig &r) const; bool operator == (const StateConfig &r) const; @@ -2736,22 +2786,23 @@ class StateConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! Trigger conds, id 2 std::vector m_conds; - - private: - uint8_t p_validbits; }; + + class StateMachineConfig : public Message { public: - StateMachineConfig(); + StateMachineConfig() + { + } bool operator != (const StateMachineConfig &r) const; bool operator == (const StateMachineConfig &r) const; @@ -2880,26 +2931,50 @@ class StateMachineConfig : public Message //! Function to get mutable access to all elements of states. std::vector *mutable_states(); + // optional bool persistent, id 4 + /*! + * Function for querying if persistent has been set. + * @return true if persistent is set. + */ + bool has_persistent() const; + //! Function to reset persistent to its default/unset value. + void clear_persistent(); + //! Get value of persistent. + bool persistent() const; + //! Set persistent using a constant reference + void set_persistent(bool v); + /*! + * Provide mutable access to persistent. + * @return pointer to member variable of persistent. + */ + bool *mutable_persistent(); + protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! uint8 ini_st, id 2 - uint8_t m_ini_st; + uint8_t m_ini_st = 0; + //! bool persistent, id 4 + bool m_persistent = false; //! StateConfig states, id 3 std::vector m_states; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ThresholdConfig : public Message { public: - ThresholdConfig(); + ThresholdConfig() + { + } bool operator != (const ThresholdConfig &r) const; bool operator == (const ThresholdConfig &r) const; @@ -3024,24 +3099,28 @@ class ThresholdConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! float low, id 2 - float m_low; + float m_low = 0; //! float high, id 3 - float m_high; + float m_high = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class LuaConfig : public Message { public: - LuaConfig(); + LuaConfig() + { + } bool operator != (const LuaConfig &r) const; bool operator == (const LuaConfig &r) const; @@ -3156,8 +3235,8 @@ class LuaConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string init_scripts, id 1 std::vector m_init_scripts; //! string compile_files, id 2 @@ -3165,10 +3244,14 @@ class LuaConfig : public Message }; + + class NodeConfig : public Message { public: - NodeConfig(); + NodeConfig() + { + } bool operator != (const NodeConfig &r) const; bool operator == (const NodeConfig &r) const; @@ -3910,7 +3993,7 @@ class NodeConfig : public Message //! Get value of max_on_time. uint32_t max_on_time() const __attribute__ ((deprecated)); - // optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_off, id 35 /*! * Function for querying if threshold_off has been set. * @return true if threshold_off is set. @@ -3919,16 +4002,9 @@ class NodeConfig : public Message //! Function to reset threshold_off to its default/unset value. void clear_threshold_off(); //! Get value of threshold_off. - uint32_t threshold_off() const; - //! Set threshold_off using a constant reference - void set_threshold_off(uint32_t v); - /*! - * Provide mutable access to threshold_off. - * @return pointer to member variable of threshold_off. - */ - uint32_t *mutable_threshold_off(); + uint32_t threshold_off() const __attribute__ ((deprecated)); - // optional unsigned threshold_on, id 36 + // deprecated optional unsigned threshold_on, id 36 /*! * Function for querying if threshold_on has been set. * @return true if threshold_on is set. @@ -3937,14 +4013,7 @@ class NodeConfig : public Message //! Function to reset threshold_on to its default/unset value. void clear_threshold_on(); //! Get value of threshold_on. - uint32_t threshold_on() const; - //! Set threshold_on using a constant reference - void set_threshold_on(uint32_t v); - /*! - * Provide mutable access to threshold_on. - * @return pointer to member variable of threshold_on. - */ - uint32_t *mutable_threshold_on(); + uint32_t threshold_on() const __attribute__ ((deprecated)); // optional unsigned dim_step, id 37 /*! @@ -4108,23 +4177,27 @@ class NodeConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); // deprecated unsigned max_on_time, id 34 //! Set max_on_time using a constant reference void set_max_on_time(uint32_t v); - //! fixed32 magic, id 0 - uint32_t m_magic; + // deprecated unsigned threshold_off, id 35 + //! Set threshold_off using a constant reference + void set_threshold_off(uint32_t v); + // deprecated unsigned threshold_on, id 36 + //! Set threshold_on using a constant reference + void set_threshold_on(uint32_t v); //! string nodename, id 1 estring m_nodename; //! bytes pass_hash, id 2 estring m_pass_hash; - //! unsigned cpu_freq, id 3 - uint32_t m_cpu_freq; - //! WifiConfig station, id 4 - WifiConfig m_station; - //! WifiConfig softap, id 5 - WifiConfig m_softap; + //! string otasrv, id 26 + estring m_otasrv; + #ifdef CONFIG_LUA + //! string luafiles, id 42 + std::vector m_luafiles; + #endif // CONFIG_LUA //! string dns_server, id 6 std::vector m_dns_server; //! string syslog_host, id 7 @@ -4133,72 +4206,38 @@ class NodeConfig : public Message estring m_sntp_server; //! string timezone, id 9 estring m_timezone; - #ifdef CONFIG_MQTT - //! MQTT mqtt, id 10 - MQTT m_mqtt; - #endif // CONFIG_MQTT - //! fixed16 dmesg_size, id 11 - uint16_t m_dmesg_size; - #ifdef CONFIG_INFLUX - //! Influx influx, id 12 - Influx m_influx; - #endif // CONFIG_INFLUX - //! unsigned station2ap_time, id 13 - uint32_t m_station2ap_time; - //! string domainname, id 15 - estring m_domainname; - //! Date holidays, id 16 - std::vector m_holidays; - //! AtAction at_actions, id 17 - std::vector m_at_actions; - //! unsigned actions_enable, id 18 - uint32_t m_actions_enable; - //! Trigger triggers, id 19 - std::vector m_triggers; - //! UartSettings uart, id 20 - std::vector m_uart; - #ifdef CONFIG_TERMSERV - //! TerminalConfig terminal, id 21 - std::vector m_terminal; - #endif // CONFIG_TERMSERV - //! fixed16 udp_ctrl_port, id 22 - uint16_t m_udp_ctrl_port; //! string debugs, id 23 std::vector m_debugs; - #ifdef CONFIG_FTP - //! FtpHttpConfig ftpd, id 24 - FtpHttpConfig m_ftpd; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP - //! 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 - // omitted obsolete member signals - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - // omitted obsolete member functions - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - //! StateMachineConfig statemachs, id 33 - std::vector m_statemachs; - #endif // CONFIG_STATEMACHINES + //! string domainname, id 15 + estring m_domainname; + //! unsigned station2ap_time, id 13 + uint32_t m_station2ap_time = 0; //! unsigned max_on_time, id 34 - uint32_t m_max_on_time; + uint32_t m_max_on_time = 0; //! unsigned threshold_off, id 35 - uint32_t m_threshold_off; + uint32_t m_threshold_off = 0; //! unsigned threshold_on, id 36 - uint32_t m_threshold_on; + uint32_t m_threshold_on = 0; //! unsigned dim_step, id 37 - uint32_t m_dim_step; - //! bool lightctrl, id 38 - bool m_lightctrl; + uint32_t m_dim_step = 0; + //! unsigned actions_enable, id 18 + uint32_t m_actions_enable = 1; //! unsigned pwm_freq, id 39 - uint32_t m_pwm_freq; + uint32_t m_pwm_freq = 0; + //! fixed32 magic, id 0 + uint32_t m_magic = 0; + //! unsigned cpu_freq, id 3 + uint32_t m_cpu_freq = 0; + //! fixed16 dmesg_size, id 11 + uint16_t m_dmesg_size = 2048; + //! fixed16 udp_ctrl_port, id 22 + uint16_t m_udp_ctrl_port = 12719; + //! bool lightctrl, id 38 + bool m_lightctrl = 0; + #ifdef CONFIG_ONEWIRE + //! OwDeviceConfig owdevices, id 50 + std::vector m_owdevices; + #endif // CONFIG_ONEWIRE #ifdef CONFIG_APP_PARAMS //! AppParam app_params, id 40 std::vector m_app_params; @@ -4207,17 +4246,47 @@ class NodeConfig : public Message //! ThresholdConfig thresholds, id 41 std::vector m_thresholds; #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA - //! string luafiles, id 42 - std::vector m_luafiles; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE - //! OwDeviceConfig owdevices, id 50 - std::vector m_owdevices; - #endif // CONFIG_ONEWIRE + #ifdef CONFIG_STATEMACHINES + //! StateMachineConfig statemachs, id 33 + std::vector m_statemachs; + #endif // CONFIG_STATEMACHINES + //! EventTimer timefuses, id 30 + std::vector m_timefuses; + #ifdef CONFIG_HTTP + //! FtpHttpConfig httpd, id 25 + FtpHttpConfig m_httpd; + #endif // CONFIG_HTTP + #ifdef CONFIG_FTP + //! FtpHttpConfig ftpd, id 24 + FtpHttpConfig m_ftpd; + #endif // CONFIG_FTP + #ifdef CONFIG_TERMSERV + //! TerminalConfig terminal, id 21 + std::vector m_terminal; + #endif // CONFIG_TERMSERV + //! UartSettings uart, id 20 + std::vector m_uart; + //! Trigger triggers, id 19 + std::vector m_triggers; + //! AtAction at_actions, id 17 + std::vector m_at_actions; + //! Date holidays, id 16 + std::vector m_holidays; + #ifdef CONFIG_INFLUX + //! Influx influx, id 12 + Influx m_influx; + #endif // CONFIG_INFLUX + #ifdef CONFIG_MQTT + //! MQTT mqtt, id 10 + MQTT m_mqtt; + #endif // CONFIG_MQTT + //! WifiConfig softap, id 5 + WifiConfig m_softap; + //! WifiConfig station, id 4 + WifiConfig m_station; private: - uint32_t p_validbits; + uint32_t p_validbits = 0; }; @@ -4322,7 +4391,7 @@ inline const estring &WifiConfig::mac() const inline bool WifiConfig::has_mac() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_mac.empty(); } /*! @@ -4331,29 +4400,22 @@ inline bool WifiConfig::has_mac() const */ inline void WifiConfig::clear_mac() { - p_validbits &= ~((uint8_t)1U << 0); m_mac.clear(); } inline estring *WifiConfig::mutable_mac() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_mac.clear(); - } return &m_mac; } inline void WifiConfig::set_mac(const void *data, size_t s) { m_mac.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void WifiConfig::set_mac(const estring &v) { m_mac = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -4382,7 +4444,7 @@ inline uint32_t WifiConfig::addr4() const inline bool WifiConfig::has_addr4() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -4391,14 +4453,14 @@ inline bool WifiConfig::has_addr4() const */ inline void WifiConfig::clear_addr4() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_addr4 = 0; } inline uint32_t *WifiConfig::mutable_addr4() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_addr4 = 0; } return &m_addr4; @@ -4407,7 +4469,7 @@ inline uint32_t *WifiConfig::mutable_addr4() inline void WifiConfig::set_addr4(uint32_t v) { m_addr4 = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -4419,7 +4481,7 @@ inline uint8_t WifiConfig::netmask4() const inline bool WifiConfig::has_netmask4() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -4428,14 +4490,14 @@ inline bool WifiConfig::has_netmask4() const */ inline void WifiConfig::clear_netmask4() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_netmask4 = 0; } inline uint8_t *WifiConfig::mutable_netmask4() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_netmask4 = 0; } return &m_netmask4; @@ -4444,7 +4506,7 @@ inline uint8_t *WifiConfig::mutable_netmask4() inline void WifiConfig::set_netmask4(uint8_t v) { m_netmask4 = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -4456,7 +4518,7 @@ inline uint32_t WifiConfig::gateway4() const inline bool WifiConfig::has_gateway4() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -4465,14 +4527,14 @@ inline bool WifiConfig::has_gateway4() const */ inline void WifiConfig::clear_gateway4() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 2); m_gateway4 = 0; } inline uint32_t *WifiConfig::mutable_gateway4() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_gateway4 = 0; } return &m_gateway4; @@ -4481,7 +4543,7 @@ inline uint32_t *WifiConfig::mutable_gateway4() inline void WifiConfig::set_gateway4(uint32_t v) { m_gateway4 = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); } @@ -5029,7 +5091,7 @@ inline const estring &AtAction::action() const inline bool AtAction::has_action() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_action.empty(); } /*! @@ -5038,35 +5100,27 @@ inline bool AtAction::has_action() const */ inline void AtAction::clear_action() { - p_validbits &= ~((uint8_t)1U << 2); m_action.clear(); } inline estring *AtAction::mutable_action() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_action.clear(); - } return &m_action; } inline void AtAction::set_action(const void *data, size_t s) { m_action.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const char *data) { m_action = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const estring &v) { m_action = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -5787,7 +5841,7 @@ inline const estring &TerminalConfig::name() const inline bool TerminalConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -5796,35 +5850,27 @@ inline bool TerminalConfig::has_name() const */ inline void TerminalConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *TerminalConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void TerminalConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5843,7 +5889,7 @@ inline const estring &Trigger::event() const inline bool Trigger::has_event() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_event.empty(); } /*! @@ -5852,35 +5898,27 @@ inline bool Trigger::has_event() const */ inline void Trigger::clear_event() { - p_validbits &= ~((uint8_t)1U << 0); m_event.clear(); } inline estring *Trigger::mutable_event() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_event.clear(); - } return &m_event; } inline void Trigger::set_event(const void *data, size_t s) { m_event.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const char *data) { m_event = data; - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const estring &v) { m_event = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5956,7 +5994,7 @@ inline const estring &AppParam::key() const inline bool AppParam::has_key() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_key.empty(); } /*! @@ -5965,35 +6003,27 @@ inline bool AppParam::has_key() const */ inline void AppParam::clear_key() { - p_validbits &= ~((uint8_t)1U << 0); m_key.clear(); } inline estring *AppParam::mutable_key() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_key.clear(); - } return &m_key; } inline void AppParam::set_key(const void *data, size_t s) { m_key.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const char *data) { m_key = data; - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const estring &v) { m_key = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6005,7 +6035,7 @@ inline uint32_t AppParam::uValue() const inline bool AppParam::has_uValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6014,14 +6044,14 @@ inline bool AppParam::has_uValue() const */ inline void AppParam::clear_uValue() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_uValue = 0; } inline uint32_t *AppParam::mutable_uValue() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_uValue = 0; } return &m_uValue; @@ -6030,7 +6060,7 @@ inline uint32_t *AppParam::mutable_uValue() inline void AppParam::set_uValue(uint32_t v) { m_uValue = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6042,7 +6072,7 @@ inline const estring &AppParam::sValue() const inline bool AppParam::has_sValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_sValue.empty(); } /*! @@ -6051,35 +6081,27 @@ inline bool AppParam::has_sValue() const */ inline void AppParam::clear_sValue() { - p_validbits &= ~((uint8_t)1U << 2); m_sValue.clear(); } inline estring *AppParam::mutable_sValue() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_sValue.clear(); - } return &m_sValue; } inline void AppParam::set_sValue(const void *data, size_t s) { m_sValue.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const char *data) { m_sValue = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const estring &v) { m_sValue = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -6091,7 +6113,7 @@ inline int32_t AppParam::dValue() const inline bool AppParam::has_dValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -6100,14 +6122,14 @@ inline bool AppParam::has_dValue() const */ inline void AppParam::clear_dValue() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 1); m_dValue = 0; } inline int32_t *AppParam::mutable_dValue() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_dValue = 0; } return &m_dValue; @@ -6116,7 +6138,7 @@ inline int32_t *AppParam::mutable_dValue() inline void AppParam::set_dValue(int32_t v) { m_dValue = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); } @@ -6128,7 +6150,7 @@ inline double AppParam::fValue() const inline bool AppParam::has_fValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 4)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -6137,14 +6159,14 @@ inline bool AppParam::has_fValue() const */ inline void AppParam::clear_fValue() { - p_validbits &= ~((uint8_t)1U << 4); + p_validbits &= ~((uint8_t)1U << 2); m_fValue = 0; } inline double *AppParam::mutable_fValue() { - if (0 == (p_validbits & ((uint8_t)1U << 4))) { - p_validbits |= ((uint8_t)1U << 4); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_fValue = 0; } return &m_fValue; @@ -6153,7 +6175,7 @@ inline double *AppParam::mutable_fValue() inline void AppParam::set_fValue(double v) { m_fValue = v; - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); } @@ -6312,7 +6334,7 @@ inline const estring &FunctionConfig::name() const inline bool FunctionConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6321,35 +6343,27 @@ inline bool FunctionConfig::has_name() const */ inline void FunctionConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *FunctionConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void FunctionConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6361,7 +6375,7 @@ inline const estring &FunctionConfig::func() const inline bool FunctionConfig::has_func() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_func.empty(); } /*! @@ -6370,35 +6384,27 @@ inline bool FunctionConfig::has_func() const */ inline void FunctionConfig::clear_func() { - p_validbits &= ~((uint8_t)1U << 1); m_func.clear(); } inline estring *FunctionConfig::mutable_func() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_func.clear(); - } return &m_func; } inline void FunctionConfig::set_func(const void *data, size_t s) { m_func.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const char *data) { m_func = data; - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const estring &v) { m_func = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6629,7 +6635,7 @@ inline const estring &OwDeviceConfig::name() const inline bool OwDeviceConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_name.empty(); } /*! @@ -6638,35 +6644,27 @@ inline bool OwDeviceConfig::has_name() const */ inline void OwDeviceConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 1); m_name.clear(); } inline estring *OwDeviceConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_name.clear(); - } return &m_name; } inline void OwDeviceConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6685,7 +6683,7 @@ inline const estring &StateConfig::name() const inline bool StateConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6694,35 +6692,27 @@ inline bool StateConfig::has_name() const */ inline void StateConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *StateConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6782,6 +6772,7 @@ inline size_t StateMachineConfig::getMaxSize() // optional string name, id 1 has unlimited size // optional uint8 ini_st, id 2 has maximum size 3 // repeated StateConfig states, id 3 has unlimited size + // optional bool persistent, id 4 has maximum size 2 return SIZE_MAX; } @@ -6792,7 +6783,7 @@ inline const estring &StateMachineConfig::name() const inline bool StateMachineConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6801,35 +6792,27 @@ inline bool StateMachineConfig::has_name() const */ inline void StateMachineConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *StateMachineConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateMachineConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6841,7 +6824,7 @@ inline uint8_t StateMachineConfig::ini_st() const inline bool StateMachineConfig::has_ini_st() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6850,14 +6833,14 @@ inline bool StateMachineConfig::has_ini_st() const */ inline void StateMachineConfig::clear_ini_st() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_ini_st = 0; } inline uint8_t *StateMachineConfig::mutable_ini_st() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_ini_st = 0; } return &m_ini_st; @@ -6866,7 +6849,7 @@ inline uint8_t *StateMachineConfig::mutable_ini_st() inline void StateMachineConfig::set_ini_st(uint8_t v) { m_ini_st = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6921,6 +6904,37 @@ inline size_t StateMachineConfig::states_size() const +inline bool StateMachineConfig::persistent() const +{ + return m_persistent; +} + +inline bool StateMachineConfig::has_persistent() const +{ + return m_persistent != false; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void StateMachineConfig::clear_persistent() +{ + m_persistent = false; +} + +inline bool *StateMachineConfig::mutable_persistent() +{ + return &m_persistent; +} + +inline void StateMachineConfig::set_persistent(bool v) +{ + m_persistent = v; +} + + + inline size_t ThresholdConfig::getMaxSize() { // optional string name, id 1 has unlimited size @@ -6936,7 +6950,7 @@ inline const estring &ThresholdConfig::name() const inline bool ThresholdConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6945,35 +6959,27 @@ inline bool ThresholdConfig::has_name() const */ inline void ThresholdConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *ThresholdConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void ThresholdConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6985,7 +6991,7 @@ inline float ThresholdConfig::low() const inline bool ThresholdConfig::has_low() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6994,14 +7000,14 @@ inline bool ThresholdConfig::has_low() const */ inline void ThresholdConfig::clear_low() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_low = 0; } inline float *ThresholdConfig::mutable_low() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_low = 0; } return &m_low; @@ -7010,7 +7016,7 @@ inline float *ThresholdConfig::mutable_low() inline void ThresholdConfig::set_low(float v) { m_low = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -7022,7 +7028,7 @@ inline float ThresholdConfig::high() const inline bool ThresholdConfig::has_high() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -7031,14 +7037,14 @@ inline bool ThresholdConfig::has_high() const */ inline void ThresholdConfig::clear_high() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_high = 0; } inline float *ThresholdConfig::mutable_high() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_high = 0; } return &m_high; @@ -7047,7 +7053,7 @@ inline float *ThresholdConfig::mutable_high() inline void ThresholdConfig::set_high(float v) { m_high = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -7200,8 +7206,8 @@ inline size_t NodeConfig::getMaxSize() // obsolete repeated FunctionConfig functions, id 32 // repeated StateMachineConfig statemachs, id 33 has unlimited size // deprecated optional unsigned max_on_time, id 34 has maximum size 7 - // optional unsigned threshold_off, id 35 has maximum size 7 - // optional unsigned threshold_on, id 36 has maximum size 7 + // deprecated optional unsigned threshold_off, id 35 has maximum size 7 + // deprecated optional unsigned threshold_on, id 36 has maximum size 7 // optional unsigned dim_step, id 37 has maximum size 7 // optional bool lightctrl, id 38 has maximum size 3 // optional unsigned pwm_freq, id 39 has maximum size 7 @@ -7297,7 +7303,7 @@ inline const estring &NodeConfig::pass_hash() const inline bool NodeConfig::has_pass_hash() const { - return 0 != (p_validbits & ((uint32_t)1U << 1)); + return !m_pass_hash.empty(); } /*! @@ -7306,29 +7312,22 @@ inline bool NodeConfig::has_pass_hash() const */ inline void NodeConfig::clear_pass_hash() { - p_validbits &= ~((uint32_t)1U << 1); m_pass_hash.clear(); } inline estring *NodeConfig::mutable_pass_hash() { - if (0 == (p_validbits & ((uint32_t)1U << 1))) { - p_validbits |= ((uint32_t)1U << 1); - m_pass_hash.clear(); - } return &m_pass_hash; } inline void NodeConfig::set_pass_hash(const void *data, size_t s) { m_pass_hash.assign((const char *)data,s); - p_validbits |= ((uint32_t)1U << 1); } inline void NodeConfig::set_pass_hash(const estring &v) { m_pass_hash = v; - p_validbits |= ((uint32_t)1U << 1); } @@ -7340,7 +7339,7 @@ inline uint32_t NodeConfig::cpu_freq() const inline bool NodeConfig::has_cpu_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 2)); + return 0 != (p_validbits & ((uint32_t)1U << 1)); } /*! @@ -7349,14 +7348,14 @@ inline bool NodeConfig::has_cpu_freq() const */ inline void NodeConfig::clear_cpu_freq() { - p_validbits &= ~((uint32_t)1U << 2); + p_validbits &= ~((uint32_t)1U << 1); m_cpu_freq = 0; } inline uint32_t *NodeConfig::mutable_cpu_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 2))) { - p_validbits |= ((uint32_t)1U << 2); + if (0 == (p_validbits & ((uint32_t)1U << 1))) { + p_validbits |= ((uint32_t)1U << 1); m_cpu_freq = 0; } return &m_cpu_freq; @@ -7365,7 +7364,7 @@ inline uint32_t *NodeConfig::mutable_cpu_freq() inline void NodeConfig::set_cpu_freq(uint32_t v) { m_cpu_freq = v; - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); } @@ -7377,7 +7376,7 @@ inline const WifiConfig &NodeConfig::station() const inline bool NodeConfig::has_station() const { - return 0 != (p_validbits & ((uint32_t)1U << 3)); + return 0 != (p_validbits & ((uint32_t)1U << 2)); } /*! @@ -7386,14 +7385,14 @@ inline bool NodeConfig::has_station() const */ inline void NodeConfig::clear_station() { - p_validbits &= ~((uint32_t)1U << 3); + p_validbits &= ~((uint32_t)1U << 2); m_station.clear(); } inline WifiConfig *NodeConfig::mutable_station() { - if (0 == (p_validbits & ((uint32_t)1U << 3))) { - p_validbits |= ((uint32_t)1U << 3); + if (0 == (p_validbits & ((uint32_t)1U << 2))) { + p_validbits |= ((uint32_t)1U << 2); m_station.clear(); } return &m_station; @@ -7402,13 +7401,13 @@ inline WifiConfig *NodeConfig::mutable_station() inline void NodeConfig::set_station(const void *data, size_t s) { m_station.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } inline void NodeConfig::set_station(const WifiConfig &v) { m_station = v; - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } @@ -7420,7 +7419,7 @@ inline const WifiConfig &NodeConfig::softap() const inline bool NodeConfig::has_softap() const { - return 0 != (p_validbits & ((uint32_t)1U << 4)); + return 0 != (p_validbits & ((uint32_t)1U << 3)); } /*! @@ -7429,14 +7428,14 @@ inline bool NodeConfig::has_softap() const */ inline void NodeConfig::clear_softap() { - p_validbits &= ~((uint32_t)1U << 4); + p_validbits &= ~((uint32_t)1U << 3); m_softap.clear(); } inline WifiConfig *NodeConfig::mutable_softap() { - if (0 == (p_validbits & ((uint32_t)1U << 4))) { - p_validbits |= ((uint32_t)1U << 4); + if (0 == (p_validbits & ((uint32_t)1U << 3))) { + p_validbits |= ((uint32_t)1U << 3); m_softap.clear(); } return &m_softap; @@ -7445,13 +7444,13 @@ inline WifiConfig *NodeConfig::mutable_softap() inline void NodeConfig::set_softap(const void *data, size_t s) { m_softap.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } inline void NodeConfig::set_softap(const WifiConfig &v) { m_softap = v; - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } @@ -7478,7 +7477,7 @@ inline void NodeConfig::clear_dns_server() inline estring *NodeConfig::mutable_dns_server(unsigned x) { if (x >= m_dns_server.size()) - m_dns_server.resize(x+1,""); + m_dns_server.resize(x+1); return &m_dns_server[x]; } @@ -7641,7 +7640,7 @@ inline const MQTT &NodeConfig::mqtt() const inline bool NodeConfig::has_mqtt() const { - return 0 != (p_validbits & ((uint32_t)1U << 5)); + return 0 != (p_validbits & ((uint32_t)1U << 4)); } /*! @@ -7650,14 +7649,14 @@ inline bool NodeConfig::has_mqtt() const */ inline void NodeConfig::clear_mqtt() { - p_validbits &= ~((uint32_t)1U << 5); + p_validbits &= ~((uint32_t)1U << 4); m_mqtt.clear(); } inline MQTT *NodeConfig::mutable_mqtt() { - if (0 == (p_validbits & ((uint32_t)1U << 5))) { - p_validbits |= ((uint32_t)1U << 5); + if (0 == (p_validbits & ((uint32_t)1U << 4))) { + p_validbits |= ((uint32_t)1U << 4); m_mqtt.clear(); } return &m_mqtt; @@ -7666,13 +7665,13 @@ inline MQTT *NodeConfig::mutable_mqtt() inline void NodeConfig::set_mqtt(const void *data, size_t s) { m_mqtt.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } inline void NodeConfig::set_mqtt(const MQTT &v) { m_mqtt = v; - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } #endif // CONFIG_MQTT @@ -7685,7 +7684,7 @@ inline uint16_t NodeConfig::dmesg_size() const inline bool NodeConfig::has_dmesg_size() const { - return 0 != (p_validbits & ((uint32_t)1U << 6)); + return 0 != (p_validbits & ((uint32_t)1U << 5)); } /*! @@ -7694,14 +7693,14 @@ inline bool NodeConfig::has_dmesg_size() const */ inline void NodeConfig::clear_dmesg_size() { - p_validbits &= ~((uint32_t)1U << 6); + p_validbits &= ~((uint32_t)1U << 5); m_dmesg_size = 2048; } inline uint16_t *NodeConfig::mutable_dmesg_size() { - if (0 == (p_validbits & ((uint32_t)1U << 6))) { - p_validbits |= ((uint32_t)1U << 6); + if (0 == (p_validbits & ((uint32_t)1U << 5))) { + p_validbits |= ((uint32_t)1U << 5); m_dmesg_size = 2048; } return &m_dmesg_size; @@ -7710,7 +7709,7 @@ inline uint16_t *NodeConfig::mutable_dmesg_size() inline void NodeConfig::set_dmesg_size(uint16_t v) { m_dmesg_size = v; - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); } @@ -7723,7 +7722,7 @@ inline const Influx &NodeConfig::influx() const inline bool NodeConfig::has_influx() const { - return 0 != (p_validbits & ((uint32_t)1U << 7)); + return 0 != (p_validbits & ((uint32_t)1U << 6)); } /*! @@ -7732,14 +7731,14 @@ inline bool NodeConfig::has_influx() const */ inline void NodeConfig::clear_influx() { - p_validbits &= ~((uint32_t)1U << 7); + p_validbits &= ~((uint32_t)1U << 6); m_influx.clear(); } inline Influx *NodeConfig::mutable_influx() { - if (0 == (p_validbits & ((uint32_t)1U << 7))) { - p_validbits |= ((uint32_t)1U << 7); + if (0 == (p_validbits & ((uint32_t)1U << 6))) { + p_validbits |= ((uint32_t)1U << 6); m_influx.clear(); } return &m_influx; @@ -7748,13 +7747,13 @@ inline Influx *NodeConfig::mutable_influx() inline void NodeConfig::set_influx(const void *data, size_t s) { m_influx.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } inline void NodeConfig::set_influx(const Influx &v) { m_influx = v; - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } #endif // CONFIG_INFLUX @@ -7767,7 +7766,7 @@ inline uint32_t NodeConfig::station2ap_time() const inline bool NodeConfig::has_station2ap_time() const { - return 0 != (p_validbits & ((uint32_t)1U << 8)); + return 0 != (p_validbits & ((uint32_t)1U << 7)); } /*! @@ -7776,14 +7775,14 @@ inline bool NodeConfig::has_station2ap_time() const */ inline void NodeConfig::clear_station2ap_time() { - p_validbits &= ~((uint32_t)1U << 8); + p_validbits &= ~((uint32_t)1U << 7); m_station2ap_time = 0; } inline uint32_t *NodeConfig::mutable_station2ap_time() { - if (0 == (p_validbits & ((uint32_t)1U << 8))) { - p_validbits |= ((uint32_t)1U << 8); + if (0 == (p_validbits & ((uint32_t)1U << 7))) { + p_validbits |= ((uint32_t)1U << 7); m_station2ap_time = 0; } return &m_station2ap_time; @@ -7792,7 +7791,7 @@ inline uint32_t *NodeConfig::mutable_station2ap_time() inline void NodeConfig::set_station2ap_time(uint32_t v) { m_station2ap_time = v; - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); } @@ -7945,7 +7944,7 @@ inline uint32_t NodeConfig::actions_enable() const inline bool NodeConfig::has_actions_enable() const { - return 0 != (p_validbits & ((uint32_t)1U << 9)); + return 0 != (p_validbits & ((uint32_t)1U << 8)); } /*! @@ -7954,14 +7953,14 @@ inline bool NodeConfig::has_actions_enable() const */ inline void NodeConfig::clear_actions_enable() { - p_validbits &= ~((uint32_t)1U << 9); + p_validbits &= ~((uint32_t)1U << 8); m_actions_enable = 1; } inline uint32_t *NodeConfig::mutable_actions_enable() { - if (0 == (p_validbits & ((uint32_t)1U << 9))) { - p_validbits |= ((uint32_t)1U << 9); + if (0 == (p_validbits & ((uint32_t)1U << 8))) { + p_validbits |= ((uint32_t)1U << 8); m_actions_enable = 1; } return &m_actions_enable; @@ -7970,7 +7969,7 @@ inline uint32_t *NodeConfig::mutable_actions_enable() inline void NodeConfig::set_actions_enable(uint32_t v) { m_actions_enable = v; - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); } @@ -8134,7 +8133,7 @@ inline uint16_t NodeConfig::udp_ctrl_port() const inline bool NodeConfig::has_udp_ctrl_port() const { - return 0 != (p_validbits & ((uint32_t)1U << 10)); + return 0 != (p_validbits & ((uint32_t)1U << 9)); } /*! @@ -8143,14 +8142,14 @@ inline bool NodeConfig::has_udp_ctrl_port() const */ inline void NodeConfig::clear_udp_ctrl_port() { - p_validbits &= ~((uint32_t)1U << 10); + p_validbits &= ~((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } inline uint16_t *NodeConfig::mutable_udp_ctrl_port() { - if (0 == (p_validbits & ((uint32_t)1U << 10))) { - p_validbits |= ((uint32_t)1U << 10); + if (0 == (p_validbits & ((uint32_t)1U << 9))) { + p_validbits |= ((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } return &m_udp_ctrl_port; @@ -8159,7 +8158,7 @@ inline uint16_t *NodeConfig::mutable_udp_ctrl_port() inline void NodeConfig::set_udp_ctrl_port(uint16_t v) { m_udp_ctrl_port = v; - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); } @@ -8226,7 +8225,7 @@ inline const FtpHttpConfig &NodeConfig::ftpd() const inline bool NodeConfig::has_ftpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 11)); + return 0 != (p_validbits & ((uint32_t)1U << 10)); } /*! @@ -8235,14 +8234,14 @@ inline bool NodeConfig::has_ftpd() const */ inline void NodeConfig::clear_ftpd() { - p_validbits &= ~((uint32_t)1U << 11); + p_validbits &= ~((uint32_t)1U << 10); m_ftpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_ftpd() { - if (0 == (p_validbits & ((uint32_t)1U << 11))) { - p_validbits |= ((uint32_t)1U << 11); + if (0 == (p_validbits & ((uint32_t)1U << 10))) { + p_validbits |= ((uint32_t)1U << 10); m_ftpd.clear(); } return &m_ftpd; @@ -8251,13 +8250,13 @@ inline FtpHttpConfig *NodeConfig::mutable_ftpd() inline void NodeConfig::set_ftpd(const void *data, size_t s) { m_ftpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } inline void NodeConfig::set_ftpd(const FtpHttpConfig &v) { m_ftpd = v; - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } #endif // CONFIG_FTP @@ -8271,7 +8270,7 @@ inline const FtpHttpConfig &NodeConfig::httpd() const inline bool NodeConfig::has_httpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 12)); + return 0 != (p_validbits & ((uint32_t)1U << 11)); } /*! @@ -8280,14 +8279,14 @@ inline bool NodeConfig::has_httpd() const */ inline void NodeConfig::clear_httpd() { - p_validbits &= ~((uint32_t)1U << 12); + p_validbits &= ~((uint32_t)1U << 11); m_httpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_httpd() { - if (0 == (p_validbits & ((uint32_t)1U << 12))) { - p_validbits |= ((uint32_t)1U << 12); + if (0 == (p_validbits & ((uint32_t)1U << 11))) { + p_validbits |= ((uint32_t)1U << 11); m_httpd.clear(); } return &m_httpd; @@ -8296,13 +8295,13 @@ inline FtpHttpConfig *NodeConfig::mutable_httpd() inline void NodeConfig::set_httpd(const void *data, size_t s) { m_httpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } inline void NodeConfig::set_httpd(const FtpHttpConfig &v) { m_httpd = v; - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } #endif // CONFIG_HTTP @@ -8315,7 +8314,7 @@ inline const estring &NodeConfig::otasrv() const inline bool NodeConfig::has_otasrv() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return !m_otasrv.empty(); } /*! @@ -8324,35 +8323,27 @@ inline bool NodeConfig::has_otasrv() const */ 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); } @@ -8492,7 +8483,7 @@ inline uint32_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 12)); } /*! @@ -8501,23 +8492,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 12); m_threshold_off = 0; } -inline uint32_t *NodeConfig::mutable_threshold_off() -{ - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); - m_threshold_off = 0; - } - return &m_threshold_off; -} - inline void NodeConfig::set_threshold_off(uint32_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 12); } @@ -8529,7 +8511,7 @@ inline uint32_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 13)); } /*! @@ -8538,23 +8520,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 13); m_threshold_on = 0; } -inline uint32_t *NodeConfig::mutable_threshold_on() -{ - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); - m_threshold_on = 0; - } - return &m_threshold_on; -} - inline void NodeConfig::set_threshold_on(uint32_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 13); } @@ -8566,7 +8539,7 @@ inline uint32_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8575,14 +8548,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 14); m_dim_step = 0; } inline uint32_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_dim_step = 0; } return &m_dim_step; @@ -8591,7 +8564,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 << 16); + p_validbits |= ((uint32_t)1U << 14); } @@ -8603,7 +8576,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8612,14 +8585,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 15); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_lightctrl = 0; } return &m_lightctrl; @@ -8628,7 +8601,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 15); } @@ -8640,7 +8613,7 @@ inline uint32_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 18)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8649,14 +8622,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 18); + p_validbits &= ~((uint32_t)1U << 16); m_pwm_freq = 0; } inline uint32_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 18))) { - p_validbits |= ((uint32_t)1U << 18); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8665,7 +8638,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 << 18); + p_validbits |= ((uint32_t)1U << 16); } diff --git a/components/wfc/swcfg_esp8266.cpp b/components/wfc/swcfg_esp8266.cpp index ce09ff8..b5a06b4 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -47,6 +47,7 @@ * options from common: * BaseClass : "Message" * getMember : "getMember" + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -73,7 +74,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * toJSON : "toJSON" * toMemory : "toMemory" * UnknownField : "skip" @@ -611,14 +611,6 @@ const char *sigtype_t_str(sigtype_t e) } WifiConfig::WifiConfig() -: m_ssid() -, m_pass() -, m_mac() -, m_activate(false) -, m_addr4(0) -, m_netmask4(0) -, m_gateway4(0) -, p_validbits(0) { } @@ -685,7 +677,6 @@ ssize_t WifiConfig::fromMemory(const void *b, ssize_t s) return -4; } m_mac.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x23: // activate id 4, type bool, coding 8bit @@ -743,7 +734,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has mac? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { // 'mac': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -11; @@ -759,7 +750,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x23; *a++ = m_activate; // has addr4? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'addr4': id=5, encoding=32bit, tag=0x2d if (5 > (e-a)) return -14; @@ -770,7 +761,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has netmask4? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'netmask4': id=6, encoding=8bit, tag=0x33 if (2 > (e-a)) return -16; @@ -778,7 +769,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = m_netmask4; } // has gateway4? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'gateway4': id=7, encoding=32bit, tag=0x3d if (5 > (e-a)) return -17; @@ -925,8 +916,6 @@ int WifiConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_mac,value); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"activate")) { @@ -940,7 +929,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_addr4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"netmask4")) { @@ -950,7 +939,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_netmask4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"gateway4")) { @@ -960,19 +949,13 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_gateway4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); return r; } return -19; } MQTT::MQTT() -: m_uri() -, m_enable(false) -, m_username() -, m_password() -, m_keepalive(60) -, p_validbits(0) { } @@ -1343,12 +1326,6 @@ int MQTT::setByName(const char *name, const char *value) } Date::Date() -: m_day(0) -, m_month(0) -, m_year(0) -, m_endday(0) -, m_endmonth(0) -, m_endyear(0) { } @@ -1626,11 +1603,6 @@ int Date::setByName(const char *name, const char *value) } AtAction::AtAction() -: m_day(Sunday) -, m_min_of_day(0) -, m_action() -, m_enable(true) -, p_validbits(0) { } @@ -1684,7 +1656,6 @@ ssize_t AtAction::fromMemory(const void *b, ssize_t s) return -53; } m_action.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 2); a += ud.vi; break; case 0x23: // enable id 4, type bool, coding 8bit @@ -1733,7 +1704,7 @@ ssize_t AtAction::toMemory(uint8_t *b, ssize_t s) const a += n; } // has action? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { // 'action': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -60; @@ -1862,8 +1833,6 @@ int AtAction::setByName(const char *name, const char *value) } m_action = value; int r = m_action.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"enable")) { @@ -1874,11 +1843,6 @@ int AtAction::setByName(const char *name, const char *value) } Influx::Influx() -: m_hostname() -, m_port(0) -, m_measurement() -// omitted obsolete member interval -, m_database() { } @@ -2125,13 +2089,6 @@ int Influx::setByName(const char *name, const char *value) } UartSettings::UartSettings() -: m_port(0) -, m_baudrate(0) -, m_config(5) -, m_rx_thresh(0) -, m_tx_bufsize(0) -, m_rx_bufsize(0) -, p_validbits(0) { } @@ -2511,11 +2468,6 @@ int UartSettings::setByName(const char *name, const char *value) } FtpHttpConfig::FtpHttpConfig() -: m_port(0) -, m_start(true) -, m_root() -, m_uploaddir() -, p_validbits(0) { } @@ -2755,10 +2707,6 @@ int FtpHttpConfig::setByName(const char *name, const char *value) } TerminalConfig::TerminalConfig() -: m_uart_rx(-1) -, m_uart_tx(-1) -, m_name() -, p_validbits(0) { } @@ -2767,7 +2715,6 @@ void TerminalConfig::clear() m_uart_rx = -1; m_uart_tx = -1; m_name.clear(); - p_validbits = 0; } void TerminalConfig::toASCII(stream &o, size_t indent) const @@ -2805,7 +2752,6 @@ ssize_t TerminalConfig::fromMemory(const void *b, ssize_t s) return -107; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; default: @@ -2851,7 +2797,7 @@ ssize_t TerminalConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -114; @@ -2912,8 +2858,6 @@ size_t TerminalConfig::calcSize() const bool TerminalConfig::operator == (const TerminalConfig &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_uart_rx() && (!(m_uart_rx == r.m_uart_rx))) return false; if (has_uart_tx() && (!(m_uart_tx == r.m_uart_tx))) @@ -2956,16 +2900,12 @@ int TerminalConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } return -116; } Trigger::Trigger() -: m_event() -, p_validbits(0) { } @@ -2973,7 +2913,6 @@ void Trigger::clear() { m_event.clear(); m_action.clear(); - p_validbits = 0; } void Trigger::toASCII(stream &o, size_t indent) const @@ -3015,7 +2954,6 @@ ssize_t Trigger::fromMemory(const void *b, ssize_t s) return -118; } m_event.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x12: // action id 2, type estring, coding byte[] @@ -3046,7 +2984,7 @@ ssize_t Trigger::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has event? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { // 'event': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -122; @@ -3128,8 +3066,6 @@ size_t Trigger::calcSize() const bool Trigger::operator == (const Trigger &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_event() && (!(m_event == r.m_event))) return false; if (!(m_action == r.m_action)) @@ -3154,8 +3090,6 @@ int Trigger::setByName(const char *name, const char *value) } m_event = value; int r = m_event.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"action",6)) { @@ -3192,12 +3126,6 @@ int Trigger::setByName(const char *name, const char *value) } AppParam::AppParam() -: m_key() -, m_uValue(0) -, m_sValue() -, m_dValue(0) -, m_fValue(0) -, p_validbits(0) { } @@ -3242,7 +3170,6 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) return -131; } m_key.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x10: // uValue id 2, type uint32_t, coding varint @@ -3253,7 +3180,6 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) return -132; } m_sValue.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 2); a += ud.vi; break; case 0x20: // dValue id 4, type int32_t, coding signed varint @@ -3283,7 +3209,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has key? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { // 'key': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -135; @@ -3294,7 +3220,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has uValue? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'uValue': id=2, encoding=varint, tag=0x10 if (a >= e) return -137; @@ -3305,7 +3231,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has sValue? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { // 'sValue': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -139; @@ -3316,7 +3242,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has dValue? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'dValue': id=4, encoding=varint, tag=0x20 if (a >= e) return -141; @@ -3327,7 +3253,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has fValue? - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'fValue': id=5, encoding=64bit, tag=0x29 if (9 > (e-a)) return -143; @@ -3435,8 +3361,6 @@ int AppParam::setByName(const char *name, const char *value) } m_key = value; int r = m_key.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"uValue")) { @@ -3446,7 +3370,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_uValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"sValue")) { @@ -3456,8 +3380,6 @@ int AppParam::setByName(const char *name, const char *value) } m_sValue = value; int r = m_sValue.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"dValue")) { @@ -3467,7 +3389,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_s32(&m_dValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"fValue")) { @@ -3477,17 +3399,13 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_dbl(&m_fValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); return r; } return -144; } EventTimer::EventTimer() -: m_name() -, m_time(0) -, m_config(0) -, p_validbits(0) { } @@ -3723,9 +3641,6 @@ int EventTimer::setByName(const char *name, const char *value) } FunctionConfig::FunctionConfig() -: m_name() -, m_func() -, p_validbits(0) { } @@ -3734,7 +3649,6 @@ void FunctionConfig::clear() m_name.clear(); m_func.clear(); m_params.clear(); - p_validbits = 0; } void FunctionConfig::toASCII(stream &o, size_t indent) const @@ -3777,7 +3691,6 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) return -158; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x12: // func id 2, type estring, coding byte[] @@ -3785,7 +3698,6 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) return -159; } m_func.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 1); a += ud.vi; break; case 0x1a: // params id 3, type estring, coding byte[] @@ -3816,7 +3728,7 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -163; @@ -3827,7 +3739,7 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has func? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { // 'func': id=2, encoding=lenpfx, tag=0x12 if (a >= e) return -165; @@ -3918,8 +3830,6 @@ size_t FunctionConfig::calcSize() const bool FunctionConfig::operator == (const FunctionConfig &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_name() && (!(m_name == r.m_name))) return false; if (has_func() && (!(m_func == r.m_func))) @@ -3946,8 +3856,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"func")) { @@ -3957,8 +3865,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_func = value; int r = m_func.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == memcmp(name,"params",6)) { @@ -3995,9 +3901,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } SignalConfig::SignalConfig() -: m_name() -, m_type(st_invalid) -, m_iv() { } @@ -4218,9 +4121,6 @@ int SignalConfig::setByName(const char *name, const char *value) } OwDeviceConfig::OwDeviceConfig() -: m_id(0) -, m_name() -, p_validbits(0) { } @@ -4264,7 +4164,6 @@ ssize_t OwDeviceConfig::fromMemory(const void *b, ssize_t s) return -187; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 1); a += ud.vi; break; default: @@ -4297,7 +4196,7 @@ ssize_t OwDeviceConfig::toMemory(uint8_t *b, ssize_t s) const a += 8; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { // 'name': id=2, encoding=lenpfx, tag=0x12 if (a >= e) return -191; @@ -4386,16 +4285,12 @@ int OwDeviceConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } return -193; } StateConfig::StateConfig() -: m_name() -, p_validbits(0) { } @@ -4403,7 +4298,6 @@ void StateConfig::clear() { m_name.clear(); m_conds.clear(); - p_validbits = 0; } void StateConfig::toASCII(stream &o, size_t indent) const @@ -4445,7 +4339,6 @@ ssize_t StateConfig::fromMemory(const void *b, ssize_t s) return -195; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x12: // conds id 2, type Trigger, coding byte[] @@ -4479,7 +4372,7 @@ ssize_t StateConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -199; @@ -4563,8 +4456,6 @@ size_t StateConfig::calcSize() const bool StateConfig::operator == (const StateConfig &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_name() && (!(m_name == r.m_name))) return false; if (!(m_conds == r.m_conds)) @@ -4589,8 +4480,6 @@ int StateConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"conds",5)) { @@ -4625,20 +4514,17 @@ int StateConfig::setByName(const char *name, const char *value) return -206; } -Message *StateConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *StateConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("conds[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 5) && (0 == memcmp("conds",s,5))) { if (x < m_conds.size()) return &m_conds[x]; - return 0; } return 0; } StateMachineConfig::StateMachineConfig() -: m_name() -, m_ini_st(0) -, p_validbits(0) { } @@ -4647,6 +4533,7 @@ void StateMachineConfig::clear() m_name.clear(); m_ini_st = 0; m_states.clear(); + m_persistent = false; p_validbits = 0; } @@ -4668,6 +4555,7 @@ void StateMachineConfig::toASCII(stream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; + ascii_bool(o, indent, "persistent", m_persistent); --indent; ascii_indent(o,indent); o << '}'; @@ -4690,7 +4578,6 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) return -208; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x10: // ini_st id 2, type uint8_t, coding varint @@ -4706,6 +4593,9 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) a += ud.vi; } break; + case 0x23: // persistent id 4, type bool, coding 8bit + set_persistent(ud.u8); + break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data @@ -4727,7 +4617,7 @@ ssize_t StateMachineConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -212; @@ -4738,7 +4628,7 @@ ssize_t StateMachineConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has ini_st? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'ini_st': id=2, encoding=varint, tag=0x10 if (a >= e) return -214; @@ -4762,6 +4652,14 @@ ssize_t StateMachineConfig::toMemory(uint8_t *b, ssize_t s) const a += n; assert(n == states_ws); } + // has persistent? + if (m_persistent != false) { + // 'persistent': id=4, encoding=8bit, tag=0x23 + if (2 > (e-a)) + return -218; + *a++ = 0x23; + *a++ = m_persistent; + } assert(a <= e); return a-b; } @@ -4796,6 +4694,10 @@ void StateMachineConfig::toJSON(stream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } + if (has_persistent()) { + fsep = json_indent(json,indLvl,fsep,"persistent"); + json << (m_persistent ? "true" : "false"); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -4825,6 +4727,10 @@ size_t StateMachineConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(states) 0x18 */; } + // optional bool persistent, id 4 + if (has_persistent()) { + r += 2; + } return r; } @@ -4838,6 +4744,8 @@ bool StateMachineConfig::operator == (const StateMachineConfig &r) const return false; if (!(m_states == r.m_states)) return false; + if (has_persistent() && (!(m_persistent == r.m_persistent))) + return false; return true; } @@ -4858,8 +4766,6 @@ int StateMachineConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"ini_st")) { @@ -4869,7 +4775,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_ini_st,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"states",6)) { @@ -4888,37 +4794,41 @@ int StateMachineConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -218; - if (m_states.size() <= x) return -219; + if (m_states.size() <= x) + return -220; if ((idxe[1] == 0) && (value == 0)) { m_states.erase(m_states.begin()+x); return 0; } } if (idxe[1] != '.') - return -220; + return -221; return m_states[x].setByName(idxe+2,value); } } - return -221; + if (0 == strcmp(name,"persistent")) { + if (value == 0) { + clear_persistent(); + return 0; + } + int r = parse_ascii_bool(&m_persistent,value); + return r; + } + return -222; } -Message *StateMachineConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *StateMachineConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("states[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 6) && (0 == memcmp("states",s,6))) { if (x < m_states.size()) return &m_states[x]; - return 0; } return 0; } ThresholdConfig::ThresholdConfig() -: m_name() -, m_low(0) -, m_high(0) -, p_validbits(0) { } @@ -4951,15 +4861,14 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -222; + return -223; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -223; + return -224; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x15: // low id 2, type float, coding 32bit @@ -4973,13 +4882,13 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -224; + return -225; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -225; + return -226; return a-(const uint8_t *)b; } @@ -4989,35 +4898,35 @@ ssize_t ThresholdConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -226; + return -227; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -227; + return -228; a += n; } // has low? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'low': id=2, encoding=32bit, tag=0x15 if (5 > (e-a)) - return -228; + return -229; *a++ = 0x15; if ((e-a) < 4) - return -229; + return -230; write_u32(a,mangle_float(m_low)); a += 4; } // has high? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'high': id=3, encoding=32bit, tag=0x1d if (5 > (e-a)) - return -230; + return -231; *a++ = 0x1d; if ((e-a) < 4) - return -231; + return -232; write_u32(a,mangle_float(m_high)); a += 4; } @@ -5100,8 +5009,6 @@ int ThresholdConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"low")) { @@ -5111,7 +5018,7 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_low,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"high")) { @@ -5121,10 +5028,10 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_high,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } - return -232; + return -233; } LuaConfig::LuaConfig() @@ -5179,19 +5086,19 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -233; + return -234; a += x; switch (fid) { case 0xa: // init_scripts id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -234; + return -235; } m_init_scripts.emplace_back((const char*)a,ud.vi); a += ud.vi; break; case 0x12: // compile_files id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -235; + return -236; } m_compile_files.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -5201,13 +5108,13 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -236; + return -237; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -237; + return -238; return a-(const uint8_t *)b; } @@ -5219,21 +5126,21 @@ ssize_t LuaConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_init_scripts) { // 'init_scripts': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -238; + return -239; *a++ = 0xa; n = encode_bytes(x,a,e); if (n < 0) - return -239; + return -240; a += n; } for (const auto &x : m_compile_files) { // 'compile_files': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -240; + return -241; *a++ = 0x12; n = encode_bytes(x,a,e); if (n < 0) - return -241; + return -242; a += n; } assert(a <= e); @@ -5349,16 +5256,16 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+13,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+13))) - return -242; - if (m_init_scripts.size() <= x) return -243; + if (m_init_scripts.size() <= x) + return -244; if ((idxe[1] == 0) && (value == 0)) { m_init_scripts.erase(m_init_scripts.begin()+x); return 0; } } if (idxe[1] != 0) - return -244; + return -245; m_init_scripts[x] = value; return m_init_scripts[x].size(); } @@ -5379,70 +5286,24 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+14,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+14))) - return -245; - if (m_compile_files.size() <= x) return -246; + if (m_compile_files.size() <= x) + return -247; if ((idxe[1] == 0) && (value == 0)) { m_compile_files.erase(m_compile_files.begin()+x); return 0; } } if (idxe[1] != 0) - return -247; + return -248; m_compile_files[x] = value; return m_compile_files[x].size(); } } - return -248; + return -249; } NodeConfig::NodeConfig() -: m_magic(0) -, m_nodename() -, m_pass_hash() -, m_cpu_freq(0) -, m_syslog_host() -, m_sntp_server() -, m_timezone() -#ifdef CONFIG_MQTT -#endif // CONFIG_MQTT -, m_dmesg_size(2048) -#ifdef CONFIG_INFLUX -#endif // CONFIG_INFLUX -, m_station2ap_time(0) -, m_domainname() -, m_actions_enable(1) -#ifdef CONFIG_TERMSERV -#endif // CONFIG_TERMSERV -, m_udp_ctrl_port(12719) -#ifdef CONFIG_FTP -#endif // CONFIG_FTP -#ifdef CONFIG_HTTP -#endif // CONFIG_HTTP -, m_otasrv() -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member signals -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member functions -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_STATEMACHINES -#endif // CONFIG_STATEMACHINES -, m_max_on_time(0) -, m_threshold_off(0) -, m_threshold_on(0) -, m_dim_step(0) -, m_lightctrl(0) -, m_pwm_freq(0) -#ifdef CONFIG_APP_PARAMS -#endif // CONFIG_APP_PARAMS -#ifdef CONFIG_THRESHOLDS -#endif // CONFIG_THRESHOLDS -#ifdef CONFIG_LUA -#endif // CONFIG_LUA -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -, p_validbits(0) { } @@ -5734,7 +5595,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -249; + return -250; a += x; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit @@ -5742,17 +5603,16 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) break; case 0xa: // nodename id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -250; + return -251; } m_nodename.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x12: // pass_hash id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -251; + return -252; } m_pass_hash.assign((const char*)a,ud.vi); - p_validbits |= ((uint32_t)1U << 1); a += ud.vi; break; case 0x18: // cpu_freq id 3, type uint32_t, coding varint @@ -5763,45 +5623,45 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_station.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -252; + return -253; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); break; case 0x2a: // softap id 5, type WifiConfig, coding byte[] if (((ssize_t)ud.vi > 0) && ((ssize_t)ud.vi <= (e-a))) { int n; n = m_softap.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -253; + return -254; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); break; case 0x32: // dns_server id 6, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -254; + return -255; } m_dns_server.emplace_back((const char*)a,ud.vi); a += ud.vi; break; case 0x3a: // syslog_host id 7, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -255; + return -256; } m_syslog_host.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x42: // sntp_server id 8, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -256; + return -257; } m_sntp_server.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x4a: // timezone id 9, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -257; + return -258; } m_timezone.assign((const char*)a,ud.vi); a += ud.vi; @@ -5812,10 +5672,10 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_mqtt.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -258; + return -259; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); break; #endif // CONFIG_MQTT case 0x5c: // dmesg_size id 11, type uint16_t, coding 16bit @@ -5827,10 +5687,10 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_influx.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -259; + return -260; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); break; #endif // CONFIG_INFLUX case 0x68: // station2ap_time id 13, type uint32_t, coding varint @@ -5838,7 +5698,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) break; case 0x7a: // domainname id 15, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -260; + return -261; } m_domainname.assign((const char*)a,ud.vi); a += ud.vi; @@ -5849,7 +5709,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_holidays.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -261; + return -262; a += ud.vi; } break; @@ -5859,7 +5719,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_at_actions.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -262; + return -263; a += ud.vi; } break; @@ -5872,7 +5732,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_triggers.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -263; + return -264; a += ud.vi; } break; @@ -5882,7 +5742,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_uart.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -264; + return -265; a += ud.vi; } break; @@ -5893,7 +5753,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_terminal.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -265; + return -266; a += ud.vi; } break; @@ -5903,7 +5763,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) break; case 0xba: // debugs id 23, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -266; + return -267; } m_debugs.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -5914,10 +5774,10 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_ftpd.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -267; + return -268; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); break; #endif // CONFIG_FTP #ifdef CONFIG_HTTP @@ -5926,18 +5786,17 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_httpd.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -268; + return -269; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); break; #endif // CONFIG_HTTP case 0xd2: // otasrv id 26, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -269; + return -270; } 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[] @@ -5946,7 +5805,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_timefuses.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -270; + return -271; a += ud.vi; } break; @@ -5957,7 +5816,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 -271; + return -272; a += ud.vi; } break; @@ -5987,7 +5846,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 -272; + return -273; a += ud.vi; } break; @@ -5999,7 +5858,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 -273; + return -274; a += ud.vi; } break; @@ -6007,7 +5866,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 -274; + return -275; } m_luafiles.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -6020,7 +5879,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 -275; + return -276; a += ud.vi; } break; @@ -6030,13 +5889,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 -276; + return -277; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -277; + return -278; return a-(const uint8_t *)b; } @@ -6049,10 +5908,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 -278; + return -279; *a++ = 0x5; if ((e-a) < 4) - return -279; + return -280; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -6060,61 +5919,61 @@ 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 -280; + return -281; *a++ = 0xa; n = encode_bytes(m_nodename,a,e); if (n < 0) - return -281; + return -282; a += n; } // has pass_hash? - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -282; + return -283; *a++ = 0x12; n = encode_bytes(m_pass_hash,a,e); if (n < 0) - return -283; + return -284; a += n; } // has cpu_freq? - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -284; + return -285; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -285; + return -286; a += n; } // has station? - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -286; + return -287; *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 -287; + return -288; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); } // has softap? - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -288; + return -289; *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 -289; + return -290; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -6122,122 +5981,122 @@ 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 -290; + return -291; *a++ = 0x32; n = encode_bytes(x,a,e); if (n < 0) - return -291; + return -292; a += n; } // has syslog_host? if (!m_syslog_host.empty()) { // 'syslog_host': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -292; + return -293; *a++ = 0x3a; n = encode_bytes(m_syslog_host,a,e); if (n < 0) - return -293; + return -294; a += n; } // has sntp_server? if (!m_sntp_server.empty()) { // 'sntp_server': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -294; + return -295; *a++ = 0x42; n = encode_bytes(m_sntp_server,a,e); if (n < 0) - return -295; + return -296; a += n; } // has timezone? if (!m_timezone.empty()) { // 'timezone': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -296; + return -297; *a++ = 0x4a; n = encode_bytes(m_timezone,a,e); if (n < 0) - return -297; + return -298; a += n; } #ifdef CONFIG_MQTT // has mqtt? - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -298; + return -299; *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 -299; + return -300; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); } #endif // CONFIG_MQTT // has dmesg_size? - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -300; + return -301; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; } #ifdef CONFIG_INFLUX // has influx? - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -301; + return -302; *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 -302; + return -303; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); } #endif // CONFIG_INFLUX // has station2ap_time? - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -303; + return -304; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -304; + return -305; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -305; + return -306; *a++ = 0x7a; n = encode_bytes(m_domainname,a,e); if (n < 0) - return -306; + return -307; a += n; } for (const auto &x : m_holidays) { // 'holidays': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -307; + return -308; *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 -308; + return -309; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -6245,41 +6104,41 @@ 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 -309; + return -310; *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 -310; + return -311; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); } // has actions_enable? - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -311; + return -312; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -312; + return -313; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -313; + return -314; *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 -314; + return -315; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -6287,14 +6146,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 -315; + return -316; *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 -316; + return -317; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -6303,24 +6162,24 @@ 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 -317; + return -318; *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 -318; + return -319; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); } #endif // CONFIG_TERMSERV // has udp_ctrl_port? - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -319; + return -320; a += write_varint(a,e-a,0xb4); // 'udp_ctrl_port': id=22 write_u16(a,m_udp_ctrl_port); a += 2; @@ -6328,27 +6187,27 @@ 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 -320; + return -321; *a++ = 0xba; *a++ = 0x1; n = encode_bytes(x,a,e); if (n < 0) - return -321; + return -322; a += n; } #ifdef CONFIG_FTP // has ftpd? - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -322; + return -323; *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 -323; + return -324; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -6356,45 +6215,45 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_FTP #ifdef CONFIG_HTTP // has httpd? - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -324; + return -325; *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 -325; + return -326; 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))) { + if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 if (2 > (e-a)) - return -326; + return -327; *a++ = 0xd2; *a++ = 0x1; n = encode_bytes(m_otasrv,a,e); if (n < 0) - return -327; + return -328; a += n; } for (const auto &x : m_timefuses) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 if (2 > (e-a)) - return -328; + return -329; *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 -329; + return -330; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -6409,88 +6268,66 @@ 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 -330; + return -331; *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 -331; + return -332; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. - // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { - // 'threshold_off': id=35, encoding=varint, tag=0x118 - if (2 > (e-a)) - return -332; - *a++ = 0x98; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_off); - if (n <= 0) - return -333; - a += n; - } - // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { - // 'threshold_on': id=36, encoding=varint, tag=0x120 - if (2 > (e-a)) - return -334; - *a++ = 0xa0; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_on); - if (n <= 0) - return -335; - a += n; - } + // 'threshold_off' is deprecated. Therefore no data will be written. + // 'threshold_on' is deprecated. Therefore no data will be written. // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -336; + return -333; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -337; + return -334; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -338; + return -335; a += write_varint(a,e-a,0x133); // 'lightctrl': id=38 *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -339; + return -336; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -340; + return -337; 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 -341; + return -338; *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 -342; + return -339; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -6500,14 +6337,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 -343; + return -340; *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 -344; + return -341; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -6517,12 +6354,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 -345; + return -342; *a++ = 0xd2; *a++ = 0x2; n = encode_bytes(x,a,e); if (n < 0) - return -346; + return -343; a += n; } #endif // CONFIG_LUA @@ -6530,14 +6367,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 -347; + return -344; *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 -348; + return -345; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -7093,14 +6930,8 @@ size_t NodeConfig::calcSize() const } #endif // CONFIG_STATEMACHINES // deprecated optional unsigned max_on_time, id 34 - // optional unsigned threshold_off, id 35 - if (has_threshold_off()) { - r += wiresize((varint_t)m_threshold_off) + 2 /* tag(threshold_off) 0x118 */; - } - // optional unsigned threshold_on, id 36 - if (has_threshold_on()) { - r += wiresize((varint_t)m_threshold_on) + 2 /* tag(threshold_on) 0x120 */; - } + // deprecated optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_on, id 36 // optional unsigned dim_step, id 37 if (has_dim_step()) { r += wiresize((varint_t)m_dim_step) + 2 /* tag(dim_step) 0x128 */; @@ -7298,8 +7129,6 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_pass_hash,value); - if (r > 0) - p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == strcmp(name,"cpu_freq")) { @@ -7309,7 +7138,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_cpu_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == memcmp(name,"station",7)) { @@ -7317,7 +7146,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_station(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); return m_station.setByName(name+8,value); } } @@ -7326,7 +7155,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_softap(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); return m_softap.setByName(name+7,value); } } @@ -7346,16 +7175,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -349; + return -346; if (m_dns_server.size() <= x) - return -350; + return -347; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -351; + return -348; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -7393,7 +7222,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_mqtt(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); return m_mqtt.setByName(name+5,value); } } @@ -7405,7 +7234,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_dmesg_size,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); return r; } #ifdef CONFIG_INFLUX @@ -7414,7 +7243,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_influx(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); return m_influx.setByName(name+7,value); } } @@ -7426,7 +7255,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_station2ap_time,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); return r; } if (0 == strcmp(name,"domainname")) { @@ -7454,16 +7283,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -352; + return -349; if (m_holidays.size() <= x) - return -353; + return -350; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -354; + return -351; return m_holidays[x].setByName(idxe+2,value); } } @@ -7483,16 +7312,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -355; + return -352; if (m_at_actions.size() <= x) - return -356; + return -353; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -357; + return -354; return m_at_actions[x].setByName(idxe+2,value); } } @@ -7503,7 +7332,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_actions_enable,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); return r; } if (0 == memcmp(name,"triggers",8)) { @@ -7522,16 +7351,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -358; + return -355; if (m_triggers.size() <= x) - return -359; + return -356; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -360; + return -357; return m_triggers[x].setByName(idxe+2,value); } } @@ -7551,16 +7380,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+5,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+5))) - return -361; + return -358; if (m_uart.size() <= x) - return -362; + return -359; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -363; + return -360; return m_uart[x].setByName(idxe+2,value); } } @@ -7581,16 +7410,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -364; + return -361; if (m_terminal.size() <= x) - return -365; + return -362; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -366; + return -363; return m_terminal[x].setByName(idxe+2,value); } } @@ -7602,7 +7431,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_udp_ctrl_port,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); return r; } if (0 == memcmp(name,"debugs",6)) { @@ -7621,16 +7450,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -367; + return -364; if (m_debugs.size() <= x) - return -368; + return -365; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -369; + return -366; m_debugs[x] = value; return m_debugs[x].size(); } @@ -7641,7 +7470,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_ftpd(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); return m_ftpd.setByName(name+5,value); } } @@ -7652,7 +7481,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_httpd(); return 0; } else if (name[5] == '.') { - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); return m_httpd.setByName(name+6,value); } } @@ -7664,8 +7493,6 @@ int NodeConfig::setByName(const char *name, const char *value) } 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)) { @@ -7684,16 +7511,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -370; + return -367; if (m_timefuses.size() <= x) - return -371; + return -368; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -372; + return -369; return m_timefuses[x].setByName(idxe+2,value); } } @@ -7714,16 +7541,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -373; + return -370; if (m_statemachs.size() <= x) - return -374; + return -371; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -375; + return -372; return m_statemachs[x].setByName(idxe+2,value); } } @@ -7743,7 +7570,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 << 14); + p_validbits |= ((uint32_t)1U << 12); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -7753,7 +7580,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 << 15); + p_validbits |= ((uint32_t)1U << 13); return r; } if (0 == strcmp(name,"dim_step")) { @@ -7763,7 +7590,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 << 16); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -7773,7 +7600,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 << 17); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -7783,7 +7610,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 << 18); + p_validbits |= ((uint32_t)1U << 16); return r; } #ifdef CONFIG_APP_PARAMS @@ -7803,16 +7630,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -376; + return -373; if (m_app_params.size() <= x) - return -377; + return -374; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -378; + return -375; return m_app_params[x].setByName(idxe+2,value); } } @@ -7834,16 +7661,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -379; + return -376; if (m_thresholds.size() <= x) - return -380; + return -377; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -381; + return -378; return m_thresholds[x].setByName(idxe+2,value); } } @@ -7865,16 +7692,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -382; + return -379; if (m_luafiles.size() <= x) - return -383; + return -380; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -384; + return -381; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -7897,124 +7724,103 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -385; + return -382; if (m_owdevices.size() <= x) - return -386; + return -383; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -387; + return -384; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -388; + return -385; } -Message *NodeConfig::p_getMember(const char *s, const char *e) +Message *NodeConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("station",s,e-s)) + // caller guarantee: s[n] == '.' + if ((n == 7) && (0 == memcmp("station",s,7))) return &m_station; - if (0 == strncmp("softap",s,e-s)) + if ((n == 6) && (0 == memcmp("softap",s,6))) return &m_softap; #ifdef CONFIG_MQTT - if (0 == strncmp("mqtt",s,e-s)) + if ((n == 4) && (0 == memcmp("mqtt",s,4))) return &m_mqtt; #endif // CONFIG_MQTT #ifdef CONFIG_INFLUX - if (0 == strncmp("influx",s,e-s)) + if ((n == 6) && (0 == memcmp("influx",s,6))) return &m_influx; #endif // CONFIG_INFLUX #ifdef CONFIG_FTP - if (0 == strncmp("ftpd",s,e-s)) + if ((n == 4) && (0 == memcmp("ftpd",s,4))) return &m_ftpd; #endif // CONFIG_FTP #ifdef CONFIG_HTTP - if (0 == strncmp("httpd",s,e-s)) + if ((n == 5) && (0 == memcmp("httpd",s,5))) return &m_httpd; #endif // CONFIG_HTTP return 0; } -Message *NodeConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *NodeConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("holidays[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 8) && (0 == memcmp("holidays",s,8))) { if (x < m_holidays.size()) return &m_holidays[x]; - return 0; - } - if (0 == strncmp("at_actions[",s,e-s)) { + } else if ((n == 10) && (0 == memcmp("at_actions",s,10))) { if (x < m_at_actions.size()) return &m_at_actions[x]; - return 0; - } - if (0 == strncmp("triggers[",s,e-s)) { + } else if ((n == 8) && (0 == memcmp("triggers",s,8))) { if (x < m_triggers.size()) return &m_triggers[x]; - return 0; - } - if (0 == strncmp("uart[",s,e-s)) { + } else if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - return 0; - } - #ifdef CONFIG_TERMSERV - if (0 == strncmp("terminal[",s,e-s)) { + #ifdef CONFIG_TERMSERV + } else if ((n == 8) && (0 == memcmp("terminal",s,8))) { if (x < m_terminal.size()) return &m_terminal[x]; - return 0; - } - #endif // CONFIG_TERMSERV - if (0 == strncmp("timefuses[",s,e-s)) { + #endif // CONFIG_TERMSERV + } else if ((n == 9) && (0 == memcmp("timefuses",s,9))) { if (x < m_timefuses.size()) return &m_timefuses[x]; - return 0; - } - #ifdef CONFIG_SIGNAL_PROC - if (0 == strncmp("signals[",s,e-s)) { + #ifdef CONFIG_SIGNAL_PROC + } else if ((n == 7) && (0 == memcmp("signals",s,7))) { if (x < m_signals.size()) return &m_signals[x]; - return 0; - } - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - if (0 == strncmp("functions[",s,e-s)) { + #endif // CONFIG_SIGNAL_PROC + #ifdef CONFIG_SIGNAL_PROC + } else if ((n == 9) && (0 == memcmp("functions",s,9))) { if (x < m_functions.size()) return &m_functions[x]; - return 0; - } - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - if (0 == strncmp("statemachs[",s,e-s)) { + #endif // CONFIG_SIGNAL_PROC + #ifdef CONFIG_STATEMACHINES + } else if ((n == 10) && (0 == memcmp("statemachs",s,10))) { if (x < m_statemachs.size()) return &m_statemachs[x]; - return 0; - } - #endif // CONFIG_STATEMACHINES - #ifdef CONFIG_APP_PARAMS - if (0 == strncmp("app_params[",s,e-s)) { + #endif // CONFIG_STATEMACHINES + #ifdef CONFIG_APP_PARAMS + } else if ((n == 10) && (0 == memcmp("app_params",s,10))) { if (x < m_app_params.size()) return &m_app_params[x]; - return 0; - } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS - if (0 == strncmp("thresholds[",s,e-s)) { + #endif // CONFIG_APP_PARAMS + #ifdef CONFIG_THRESHOLDS + } else if ((n == 10) && (0 == memcmp("thresholds",s,10))) { if (x < m_thresholds.size()) return &m_thresholds[x]; - return 0; - } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_ONEWIRE - if (0 == strncmp("owdevices[",s,e-s)) { + #endif // CONFIG_THRESHOLDS + #ifdef CONFIG_ONEWIRE + } else if ((n == 9) && (0 == memcmp("owdevices",s,9))) { if (x < m_owdevices.size()) return &m_owdevices[x]; - return 0; + #endif // CONFIG_ONEWIRE } - #endif // CONFIG_ONEWIRE return 0; } diff --git a/components/wfc/swcfg_esp8266.h b/components/wfc/swcfg_esp8266.h index ca6954f..97a642b 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -47,6 +47,7 @@ * options from common: * BaseClass : "Message" * getMember : "getMember" + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -73,7 +74,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * toJSON : "toJSON" * toMemory : "toMemory" * UnknownField : "skip" @@ -216,11 +216,12 @@ size_t parse_ascii_sigtype_t(sigtype_t *, const char *); typedef uint16_t uartcfg_t; typedef uint8_t eventcfg_t; + + class WifiConfig : public Message { public: WifiConfig(); - bool operator == (const WifiConfig &r) const; //! Function for resetting all members to their default values. @@ -428,25 +429,26 @@ class WifiConfig : public Message estring m_pass; //! bytes mac, id 3 estring m_mac; - //! bool activate, id 4 - bool m_activate; //! fixed32 addr4, id 5 - uint32_t m_addr4; - //! fixed8 netmask4, id 6 - uint8_t m_netmask4; + uint32_t m_addr4 = 0; //! fixed32 gateway4, id 7 - uint32_t m_gateway4; + uint32_t m_gateway4 = 0; + //! bool activate, id 4 + bool m_activate = false; + //! fixed8 netmask4, id 6 + uint8_t m_netmask4 = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class MQTT : public Message { public: MQTT(); - bool operator == (const MQTT &r) const; //! Function for resetting all members to their default values. @@ -649,8 +651,6 @@ class MQTT : public Message protected: //! string uri, id 1 estring m_uri; - //! bool enable, id 2 - bool m_enable; //! string username, id 3 estring m_username; //! string password, id 4 @@ -658,18 +658,21 @@ class MQTT : public Message //! string subscribtions, id 5 std::vector m_subscribtions; //! uint16 keepalive, id 6 - uint16_t m_keepalive; + uint16_t m_keepalive = 60; + //! bool enable, id 2 + bool m_enable = false; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Date : public Message { public: Date(); - bool operator == (const Date &r) const; //! Function for resetting all members to their default values. @@ -838,26 +841,27 @@ class Date : public Message protected: + //! fixed16 year, id 3 + uint16_t m_year = 0; //! fixed8 day, id 1 - uint8_t m_day; + uint8_t m_day = 0; //! fixed8 month, id 2 - uint8_t m_month; - //! fixed16 year, id 3 - uint16_t m_year; + uint8_t m_month = 0; //! fixed8 endday, id 4 - uint8_t m_endday; + uint8_t m_endday = 0; //! fixed8 endmonth, id 5 - uint8_t m_endmonth; + uint8_t m_endmonth = 0; //! fixed8 endyear, id 6 - uint8_t m_endyear; + uint8_t m_endyear = 0; }; + + class AtAction : public Message { public: AtAction(); - bool operator == (const AtAction &r) const; //! Function for resetting all members to their default values. @@ -991,25 +995,26 @@ class AtAction : public Message protected: - //! WeekDay day, id 1 - WeekDay m_day; - //! unsigned min_of_day, id 2 - uint32_t m_min_of_day; //! string action, id 3 estring m_action; + //! WeekDay day, id 1 + WeekDay m_day = Sunday; + //! unsigned min_of_day, id 2 + uint32_t m_min_of_day = 0; //! bool enable, id 4 - bool m_enable; + bool m_enable = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Influx : public Message { public: Influx(); - bool operator == (const Influx &r) const; //! Function for resetting all members to their default values. @@ -1169,21 +1174,21 @@ class Influx : public Message protected: //! string hostname, id 1 estring m_hostname; - //! fixed16 port, id 2 - uint16_t m_port; //! string measurement, id 3 estring m_measurement; - // omitted obsolete member interval //! string database, id 5 estring m_database; + //! fixed16 port, id 2 + uint16_t m_port = 0; }; + + class UartSettings : public Message { public: UartSettings(); - bool operator == (const UartSettings &r) const; //! Function for resetting all members to their default values. @@ -1376,29 +1381,30 @@ class UartSettings : public Message protected: - //! uint8 port, id 1 - uint8_t m_port; //! unsigned baudrate, id 2 - uint32_t m_baudrate; - //! uartcfg_t config, id 3 - uartcfg_t m_config; - //! fixed8 rx_thresh, id 4 - uint8_t m_rx_thresh; + uint32_t m_baudrate = 0; //! unsigned tx_bufsize, id 6 - uint32_t m_tx_bufsize; + uint32_t m_tx_bufsize = 0; //! unsigned rx_bufsize, id 7 - uint32_t m_rx_bufsize; + uint32_t m_rx_bufsize = 0; + //! uartcfg_t config, id 3 + uartcfg_t m_config = 5; + //! uint8 port, id 1 + uint8_t m_port = 0; + //! fixed8 rx_thresh, id 4 + uint8_t m_rx_thresh = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FtpHttpConfig : public Message { public: FtpHttpConfig(); - bool operator == (const FtpHttpConfig &r) const; //! Function for resetting all members to their default values. @@ -1547,25 +1553,26 @@ class FtpHttpConfig : public Message protected: - //! fixed16 port, id 1 - uint16_t m_port; - //! bool start, id 2 - bool m_start; //! string root, id 3 estring m_root; //! string uploaddir, id 4 estring m_uploaddir; + //! fixed16 port, id 1 + uint16_t m_port = 0; + //! bool start, id 2 + bool m_start = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TerminalConfig : public Message { public: TerminalConfig(); - bool operator == (const TerminalConfig &r) const; //! Function for resetting all members to their default values. @@ -1688,23 +1695,21 @@ class TerminalConfig : public Message protected: - //! sint8 uart_rx, id 1 - int8_t m_uart_rx; - //! sint8 uart_tx, id 2 - int8_t m_uart_tx; //! string name, id 3 estring m_name; - - private: - uint8_t p_validbits; + //! sint8 uart_rx, id 1 + int8_t m_uart_rx = -1; + //! sint8 uart_tx, id 2 + int8_t m_uart_tx = -1; }; + + class Trigger : public Message { public: Trigger(); - bool operator == (const Trigger &r) const; //! Function for resetting all members to their default values. @@ -1821,17 +1826,15 @@ class Trigger : public Message estring m_event; //! string action, id 2 std::vector m_action; - - private: - uint8_t p_validbits; }; + + class AppParam : public Message { public: AppParam(); - bool operator == (const AppParam &r) const; //! Function for resetting all members to their default values. @@ -2000,25 +2003,26 @@ class AppParam : public Message protected: //! string key, id 1 estring m_key; - //! unsigned uValue, id 2 - uint32_t m_uValue; //! string sValue, id 3 estring m_sValue; - //! signed dValue, id 4 - int32_t m_dValue; //! double fValue, id 5 - double m_fValue; + double m_fValue = 0; + //! unsigned uValue, id 2 + uint32_t m_uValue = 0; + //! signed dValue, id 4 + int32_t m_dValue = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class EventTimer : public Message { public: EventTimer(); - bool operator == (const EventTimer &r) const; //! Function for resetting all members to their default values. @@ -2152,20 +2156,21 @@ class EventTimer : public Message //! string name, id 1 estring m_name; //! unsigned time, id 2 - uint32_t m_time; + uint32_t m_time = 0; //! eventcfg_t config, id 3 - eventcfg_t m_config; + eventcfg_t m_config = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FunctionConfig : public Message { public: FunctionConfig(); - bool operator == (const FunctionConfig &r) const; //! Function for resetting all members to their default values. @@ -2310,17 +2315,15 @@ class FunctionConfig : public Message estring m_func; //! string params, id 3 std::vector m_params; - - private: - uint8_t p_validbits; }; + + class SignalConfig : public Message { public: SignalConfig(); - bool operator == (const SignalConfig &r) const; //! Function for resetting all members to their default values. @@ -2453,18 +2456,19 @@ class SignalConfig : public Message protected: //! string name, id 1 estring m_name; - //! sigtype_t type, id 2 - sigtype_t m_type; //! string iv, id 3 estring m_iv; + //! sigtype_t type, id 2 + sigtype_t m_type = st_invalid; }; + + class OwDeviceConfig : public Message { public: OwDeviceConfig(); - bool operator == (const OwDeviceConfig &r) const; //! Function for resetting all members to their default values. @@ -2569,21 +2573,22 @@ class OwDeviceConfig : public Message protected: - //! fixed64 id, id 1 - uint64_t m_id; //! string name, id 2 estring m_name; + //! fixed64 id, id 1 + uint64_t m_id = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class StateConfig : public Message { public: StateConfig(); - bool operator == (const StateConfig &r) const; //! Function for resetting all members to their default values. @@ -2694,22 +2699,20 @@ class StateConfig : public Message protected: - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! Trigger conds, id 2 std::vector m_conds; - - private: - uint8_t p_validbits; }; + + class StateMachineConfig : public Message { public: StateMachineConfig(); - bool operator == (const StateMachineConfig &r) const; //! Function for resetting all members to their default values. @@ -2836,26 +2839,47 @@ class StateMachineConfig : public Message //! Function to get mutable access to all elements of states. std::vector *mutable_states(); + // optional bool persistent, id 4 + /*! + * Function for querying if persistent has been set. + * @return true if persistent is set. + */ + bool has_persistent() const; + //! Function to reset persistent to its default/unset value. + void clear_persistent(); + //! Get value of persistent. + bool persistent() const; + //! Set persistent using a constant reference + void set_persistent(bool v); + /*! + * Provide mutable access to persistent. + * @return pointer to member variable of persistent. + */ + bool *mutable_persistent(); + protected: - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 estring m_name; //! uint8 ini_st, id 2 - uint8_t m_ini_st; + uint8_t m_ini_st = 0; + //! bool persistent, id 4 + bool m_persistent = false; //! StateConfig states, id 3 std::vector m_states; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ThresholdConfig : public Message { public: ThresholdConfig(); - bool operator == (const ThresholdConfig &r) const; //! Function for resetting all members to their default values. @@ -2981,20 +3005,21 @@ class ThresholdConfig : public Message //! string name, id 1 estring m_name; //! float low, id 2 - float m_low; + float m_low = 0; //! float high, id 3 - float m_high; + float m_high = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class LuaConfig : public Message { public: LuaConfig(); - bool operator == (const LuaConfig &r) const; //! Function for resetting all members to their default values. @@ -3114,11 +3139,12 @@ class LuaConfig : public Message }; + + class NodeConfig : public Message { public: NodeConfig(); - bool operator == (const NodeConfig &r) const; //! Function for resetting all members to their default values. @@ -3858,7 +3884,7 @@ class NodeConfig : public Message //! Get value of max_on_time. uint32_t max_on_time() const __attribute__ ((deprecated)); - // optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_off, id 35 /*! * Function for querying if threshold_off has been set. * @return true if threshold_off is set. @@ -3867,16 +3893,9 @@ class NodeConfig : public Message //! Function to reset threshold_off to its default/unset value. void clear_threshold_off(); //! Get value of threshold_off. - uint32_t threshold_off() const; - //! Set threshold_off using a constant reference - void set_threshold_off(uint32_t v); - /*! - * Provide mutable access to threshold_off. - * @return pointer to member variable of threshold_off. - */ - uint32_t *mutable_threshold_off(); + uint32_t threshold_off() const __attribute__ ((deprecated)); - // optional unsigned threshold_on, id 36 + // deprecated optional unsigned threshold_on, id 36 /*! * Function for querying if threshold_on has been set. * @return true if threshold_on is set. @@ -3885,14 +3904,7 @@ class NodeConfig : public Message //! Function to reset threshold_on to its default/unset value. void clear_threshold_on(); //! Get value of threshold_on. - uint32_t threshold_on() const; - //! Set threshold_on using a constant reference - void set_threshold_on(uint32_t v); - /*! - * Provide mutable access to threshold_on. - * @return pointer to member variable of threshold_on. - */ - uint32_t *mutable_threshold_on(); + uint32_t threshold_on() const __attribute__ ((deprecated)); // optional unsigned dim_step, id 37 /*! @@ -4056,23 +4068,27 @@ class NodeConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); // deprecated unsigned max_on_time, id 34 //! Set max_on_time using a constant reference void set_max_on_time(uint32_t v); - //! fixed32 magic, id 0 - uint32_t m_magic; + // deprecated unsigned threshold_off, id 35 + //! Set threshold_off using a constant reference + void set_threshold_off(uint32_t v); + // deprecated unsigned threshold_on, id 36 + //! Set threshold_on using a constant reference + void set_threshold_on(uint32_t v); //! string nodename, id 1 estring m_nodename; //! bytes pass_hash, id 2 estring m_pass_hash; - //! unsigned cpu_freq, id 3 - uint32_t m_cpu_freq; - //! WifiConfig station, id 4 - WifiConfig m_station; - //! WifiConfig softap, id 5 - WifiConfig m_softap; + //! string otasrv, id 26 + estring m_otasrv; + #ifdef CONFIG_LUA + //! string luafiles, id 42 + std::vector m_luafiles; + #endif // CONFIG_LUA //! string dns_server, id 6 std::vector m_dns_server; //! string syslog_host, id 7 @@ -4081,72 +4097,38 @@ class NodeConfig : public Message estring m_sntp_server; //! string timezone, id 9 estring m_timezone; - #ifdef CONFIG_MQTT - //! MQTT mqtt, id 10 - MQTT m_mqtt; - #endif // CONFIG_MQTT - //! fixed16 dmesg_size, id 11 - uint16_t m_dmesg_size; - #ifdef CONFIG_INFLUX - //! Influx influx, id 12 - Influx m_influx; - #endif // CONFIG_INFLUX - //! unsigned station2ap_time, id 13 - uint32_t m_station2ap_time; - //! string domainname, id 15 - estring m_domainname; - //! Date holidays, id 16 - std::vector m_holidays; - //! AtAction at_actions, id 17 - std::vector m_at_actions; - //! unsigned actions_enable, id 18 - uint32_t m_actions_enable; - //! Trigger triggers, id 19 - std::vector m_triggers; - //! UartSettings uart, id 20 - std::vector m_uart; - #ifdef CONFIG_TERMSERV - //! TerminalConfig terminal, id 21 - std::vector m_terminal; - #endif // CONFIG_TERMSERV - //! fixed16 udp_ctrl_port, id 22 - uint16_t m_udp_ctrl_port; //! string debugs, id 23 std::vector m_debugs; - #ifdef CONFIG_FTP - //! FtpHttpConfig ftpd, id 24 - FtpHttpConfig m_ftpd; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP - //! 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 - // omitted obsolete member signals - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - // omitted obsolete member functions - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - //! StateMachineConfig statemachs, id 33 - std::vector m_statemachs; - #endif // CONFIG_STATEMACHINES + //! string domainname, id 15 + estring m_domainname; + //! unsigned station2ap_time, id 13 + uint32_t m_station2ap_time = 0; //! unsigned max_on_time, id 34 - uint32_t m_max_on_time; + uint32_t m_max_on_time = 0; //! unsigned threshold_off, id 35 - uint32_t m_threshold_off; + uint32_t m_threshold_off = 0; //! unsigned threshold_on, id 36 - uint32_t m_threshold_on; + uint32_t m_threshold_on = 0; //! unsigned dim_step, id 37 - uint32_t m_dim_step; - //! bool lightctrl, id 38 - bool m_lightctrl; + uint32_t m_dim_step = 0; + //! unsigned actions_enable, id 18 + uint32_t m_actions_enable = 1; //! unsigned pwm_freq, id 39 - uint32_t m_pwm_freq; + uint32_t m_pwm_freq = 0; + //! fixed32 magic, id 0 + uint32_t m_magic = 0; + //! unsigned cpu_freq, id 3 + uint32_t m_cpu_freq = 0; + //! fixed16 dmesg_size, id 11 + uint16_t m_dmesg_size = 2048; + //! fixed16 udp_ctrl_port, id 22 + uint16_t m_udp_ctrl_port = 12719; + //! bool lightctrl, id 38 + bool m_lightctrl = 0; + #ifdef CONFIG_ONEWIRE + //! OwDeviceConfig owdevices, id 50 + std::vector m_owdevices; + #endif // CONFIG_ONEWIRE #ifdef CONFIG_APP_PARAMS //! AppParam app_params, id 40 std::vector m_app_params; @@ -4155,17 +4137,47 @@ class NodeConfig : public Message //! ThresholdConfig thresholds, id 41 std::vector m_thresholds; #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA - //! string luafiles, id 42 - std::vector m_luafiles; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE - //! OwDeviceConfig owdevices, id 50 - std::vector m_owdevices; - #endif // CONFIG_ONEWIRE + #ifdef CONFIG_STATEMACHINES + //! StateMachineConfig statemachs, id 33 + std::vector m_statemachs; + #endif // CONFIG_STATEMACHINES + //! EventTimer timefuses, id 30 + std::vector m_timefuses; + #ifdef CONFIG_HTTP + //! FtpHttpConfig httpd, id 25 + FtpHttpConfig m_httpd; + #endif // CONFIG_HTTP + #ifdef CONFIG_FTP + //! FtpHttpConfig ftpd, id 24 + FtpHttpConfig m_ftpd; + #endif // CONFIG_FTP + #ifdef CONFIG_TERMSERV + //! TerminalConfig terminal, id 21 + std::vector m_terminal; + #endif // CONFIG_TERMSERV + //! UartSettings uart, id 20 + std::vector m_uart; + //! Trigger triggers, id 19 + std::vector m_triggers; + //! AtAction at_actions, id 17 + std::vector m_at_actions; + //! Date holidays, id 16 + std::vector m_holidays; + #ifdef CONFIG_INFLUX + //! Influx influx, id 12 + Influx m_influx; + #endif // CONFIG_INFLUX + #ifdef CONFIG_MQTT + //! MQTT mqtt, id 10 + MQTT m_mqtt; + #endif // CONFIG_MQTT + //! WifiConfig softap, id 5 + WifiConfig m_softap; + //! WifiConfig station, id 4 + WifiConfig m_station; private: - uint32_t p_validbits; + uint32_t p_validbits = 0; }; @@ -4270,7 +4282,7 @@ inline const estring &WifiConfig::mac() const inline bool WifiConfig::has_mac() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_mac.empty(); } /*! @@ -4279,29 +4291,22 @@ inline bool WifiConfig::has_mac() const */ inline void WifiConfig::clear_mac() { - p_validbits &= ~((uint8_t)1U << 0); m_mac.clear(); } inline estring *WifiConfig::mutable_mac() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_mac.clear(); - } return &m_mac; } inline void WifiConfig::set_mac(const void *data, size_t s) { m_mac.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void WifiConfig::set_mac(const estring &v) { m_mac = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -4330,7 +4335,7 @@ inline uint32_t WifiConfig::addr4() const inline bool WifiConfig::has_addr4() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -4339,14 +4344,14 @@ inline bool WifiConfig::has_addr4() const */ inline void WifiConfig::clear_addr4() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_addr4 = 0; } inline uint32_t *WifiConfig::mutable_addr4() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_addr4 = 0; } return &m_addr4; @@ -4355,7 +4360,7 @@ inline uint32_t *WifiConfig::mutable_addr4() inline void WifiConfig::set_addr4(uint32_t v) { m_addr4 = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -4367,7 +4372,7 @@ inline uint8_t WifiConfig::netmask4() const inline bool WifiConfig::has_netmask4() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -4376,14 +4381,14 @@ inline bool WifiConfig::has_netmask4() const */ inline void WifiConfig::clear_netmask4() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_netmask4 = 0; } inline uint8_t *WifiConfig::mutable_netmask4() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_netmask4 = 0; } return &m_netmask4; @@ -4392,7 +4397,7 @@ inline uint8_t *WifiConfig::mutable_netmask4() inline void WifiConfig::set_netmask4(uint8_t v) { m_netmask4 = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -4404,7 +4409,7 @@ inline uint32_t WifiConfig::gateway4() const inline bool WifiConfig::has_gateway4() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -4413,14 +4418,14 @@ inline bool WifiConfig::has_gateway4() const */ inline void WifiConfig::clear_gateway4() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 2); m_gateway4 = 0; } inline uint32_t *WifiConfig::mutable_gateway4() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_gateway4 = 0; } return &m_gateway4; @@ -4429,7 +4434,7 @@ inline uint32_t *WifiConfig::mutable_gateway4() inline void WifiConfig::set_gateway4(uint32_t v) { m_gateway4 = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); } @@ -4977,7 +4982,7 @@ inline const estring &AtAction::action() const inline bool AtAction::has_action() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_action.empty(); } /*! @@ -4986,35 +4991,27 @@ inline bool AtAction::has_action() const */ inline void AtAction::clear_action() { - p_validbits &= ~((uint8_t)1U << 2); m_action.clear(); } inline estring *AtAction::mutable_action() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_action.clear(); - } return &m_action; } inline void AtAction::set_action(const void *data, size_t s) { m_action.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const char *data) { m_action = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const estring &v) { m_action = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -5735,7 +5732,7 @@ inline const estring &TerminalConfig::name() const inline bool TerminalConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -5744,35 +5741,27 @@ inline bool TerminalConfig::has_name() const */ inline void TerminalConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *TerminalConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void TerminalConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5791,7 +5780,7 @@ inline const estring &Trigger::event() const inline bool Trigger::has_event() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_event.empty(); } /*! @@ -5800,35 +5789,27 @@ inline bool Trigger::has_event() const */ inline void Trigger::clear_event() { - p_validbits &= ~((uint8_t)1U << 0); m_event.clear(); } inline estring *Trigger::mutable_event() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_event.clear(); - } return &m_event; } inline void Trigger::set_event(const void *data, size_t s) { m_event.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const char *data) { m_event = data; - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const estring &v) { m_event = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5904,7 +5885,7 @@ inline const estring &AppParam::key() const inline bool AppParam::has_key() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_key.empty(); } /*! @@ -5913,35 +5894,27 @@ inline bool AppParam::has_key() const */ inline void AppParam::clear_key() { - p_validbits &= ~((uint8_t)1U << 0); m_key.clear(); } inline estring *AppParam::mutable_key() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_key.clear(); - } return &m_key; } inline void AppParam::set_key(const void *data, size_t s) { m_key.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const char *data) { m_key = data; - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const estring &v) { m_key = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5953,7 +5926,7 @@ inline uint32_t AppParam::uValue() const inline bool AppParam::has_uValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -5962,14 +5935,14 @@ inline bool AppParam::has_uValue() const */ inline void AppParam::clear_uValue() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_uValue = 0; } inline uint32_t *AppParam::mutable_uValue() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_uValue = 0; } return &m_uValue; @@ -5978,7 +5951,7 @@ inline uint32_t *AppParam::mutable_uValue() inline void AppParam::set_uValue(uint32_t v) { m_uValue = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -5990,7 +5963,7 @@ inline const estring &AppParam::sValue() const inline bool AppParam::has_sValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_sValue.empty(); } /*! @@ -5999,35 +5972,27 @@ inline bool AppParam::has_sValue() const */ inline void AppParam::clear_sValue() { - p_validbits &= ~((uint8_t)1U << 2); m_sValue.clear(); } inline estring *AppParam::mutable_sValue() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_sValue.clear(); - } return &m_sValue; } inline void AppParam::set_sValue(const void *data, size_t s) { m_sValue.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const char *data) { m_sValue = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const estring &v) { m_sValue = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -6039,7 +6004,7 @@ inline int32_t AppParam::dValue() const inline bool AppParam::has_dValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -6048,14 +6013,14 @@ inline bool AppParam::has_dValue() const */ inline void AppParam::clear_dValue() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 1); m_dValue = 0; } inline int32_t *AppParam::mutable_dValue() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_dValue = 0; } return &m_dValue; @@ -6064,7 +6029,7 @@ inline int32_t *AppParam::mutable_dValue() inline void AppParam::set_dValue(int32_t v) { m_dValue = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); } @@ -6076,7 +6041,7 @@ inline double AppParam::fValue() const inline bool AppParam::has_fValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 4)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -6085,14 +6050,14 @@ inline bool AppParam::has_fValue() const */ inline void AppParam::clear_fValue() { - p_validbits &= ~((uint8_t)1U << 4); + p_validbits &= ~((uint8_t)1U << 2); m_fValue = 0; } inline double *AppParam::mutable_fValue() { - if (0 == (p_validbits & ((uint8_t)1U << 4))) { - p_validbits |= ((uint8_t)1U << 4); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_fValue = 0; } return &m_fValue; @@ -6101,7 +6066,7 @@ inline double *AppParam::mutable_fValue() inline void AppParam::set_fValue(double v) { m_fValue = v; - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); } @@ -6260,7 +6225,7 @@ inline const estring &FunctionConfig::name() const inline bool FunctionConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6269,35 +6234,27 @@ inline bool FunctionConfig::has_name() const */ inline void FunctionConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *FunctionConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void FunctionConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6309,7 +6266,7 @@ inline const estring &FunctionConfig::func() const inline bool FunctionConfig::has_func() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_func.empty(); } /*! @@ -6318,35 +6275,27 @@ inline bool FunctionConfig::has_func() const */ inline void FunctionConfig::clear_func() { - p_validbits &= ~((uint8_t)1U << 1); m_func.clear(); } inline estring *FunctionConfig::mutable_func() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_func.clear(); - } return &m_func; } inline void FunctionConfig::set_func(const void *data, size_t s) { m_func.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const char *data) { m_func = data; - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const estring &v) { m_func = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6577,7 +6526,7 @@ inline const estring &OwDeviceConfig::name() const inline bool OwDeviceConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_name.empty(); } /*! @@ -6586,35 +6535,27 @@ inline bool OwDeviceConfig::has_name() const */ inline void OwDeviceConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 1); m_name.clear(); } inline estring *OwDeviceConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_name.clear(); - } return &m_name; } inline void OwDeviceConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6633,7 +6574,7 @@ inline const estring &StateConfig::name() const inline bool StateConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6642,35 +6583,27 @@ inline bool StateConfig::has_name() const */ inline void StateConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *StateConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6730,6 +6663,7 @@ inline size_t StateMachineConfig::getMaxSize() // optional string name, id 1 has unlimited size // optional uint8 ini_st, id 2 has maximum size 3 // repeated StateConfig states, id 3 has unlimited size + // optional bool persistent, id 4 has maximum size 2 return SIZE_MAX; } @@ -6740,7 +6674,7 @@ inline const estring &StateMachineConfig::name() const inline bool StateMachineConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6749,35 +6683,27 @@ inline bool StateMachineConfig::has_name() const */ inline void StateMachineConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *StateMachineConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateMachineConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6789,7 +6715,7 @@ inline uint8_t StateMachineConfig::ini_st() const inline bool StateMachineConfig::has_ini_st() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6798,14 +6724,14 @@ inline bool StateMachineConfig::has_ini_st() const */ inline void StateMachineConfig::clear_ini_st() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_ini_st = 0; } inline uint8_t *StateMachineConfig::mutable_ini_st() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_ini_st = 0; } return &m_ini_st; @@ -6814,7 +6740,7 @@ inline uint8_t *StateMachineConfig::mutable_ini_st() inline void StateMachineConfig::set_ini_st(uint8_t v) { m_ini_st = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6869,6 +6795,37 @@ inline size_t StateMachineConfig::states_size() const +inline bool StateMachineConfig::persistent() const +{ + return m_persistent; +} + +inline bool StateMachineConfig::has_persistent() const +{ + return m_persistent != false; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void StateMachineConfig::clear_persistent() +{ + m_persistent = false; +} + +inline bool *StateMachineConfig::mutable_persistent() +{ + return &m_persistent; +} + +inline void StateMachineConfig::set_persistent(bool v) +{ + m_persistent = v; +} + + + inline size_t ThresholdConfig::getMaxSize() { // optional string name, id 1 has unlimited size @@ -6884,7 +6841,7 @@ inline const estring &ThresholdConfig::name() const inline bool ThresholdConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6893,35 +6850,27 @@ inline bool ThresholdConfig::has_name() const */ inline void ThresholdConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *ThresholdConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void ThresholdConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6933,7 +6882,7 @@ inline float ThresholdConfig::low() const inline bool ThresholdConfig::has_low() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6942,14 +6891,14 @@ inline bool ThresholdConfig::has_low() const */ inline void ThresholdConfig::clear_low() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_low = 0; } inline float *ThresholdConfig::mutable_low() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_low = 0; } return &m_low; @@ -6958,7 +6907,7 @@ inline float *ThresholdConfig::mutable_low() inline void ThresholdConfig::set_low(float v) { m_low = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6970,7 +6919,7 @@ inline float ThresholdConfig::high() const inline bool ThresholdConfig::has_high() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -6979,14 +6928,14 @@ inline bool ThresholdConfig::has_high() const */ inline void ThresholdConfig::clear_high() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_high = 0; } inline float *ThresholdConfig::mutable_high() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_high = 0; } return &m_high; @@ -6995,7 +6944,7 @@ inline float *ThresholdConfig::mutable_high() inline void ThresholdConfig::set_high(float v) { m_high = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -7148,8 +7097,8 @@ inline size_t NodeConfig::getMaxSize() // obsolete repeated FunctionConfig functions, id 32 // repeated StateMachineConfig statemachs, id 33 has unlimited size // deprecated optional unsigned max_on_time, id 34 has maximum size 7 - // optional unsigned threshold_off, id 35 has maximum size 7 - // optional unsigned threshold_on, id 36 has maximum size 7 + // deprecated optional unsigned threshold_off, id 35 has maximum size 7 + // deprecated optional unsigned threshold_on, id 36 has maximum size 7 // optional unsigned dim_step, id 37 has maximum size 7 // optional bool lightctrl, id 38 has maximum size 3 // optional unsigned pwm_freq, id 39 has maximum size 7 @@ -7245,7 +7194,7 @@ inline const estring &NodeConfig::pass_hash() const inline bool NodeConfig::has_pass_hash() const { - return 0 != (p_validbits & ((uint32_t)1U << 1)); + return !m_pass_hash.empty(); } /*! @@ -7254,29 +7203,22 @@ inline bool NodeConfig::has_pass_hash() const */ inline void NodeConfig::clear_pass_hash() { - p_validbits &= ~((uint32_t)1U << 1); m_pass_hash.clear(); } inline estring *NodeConfig::mutable_pass_hash() { - if (0 == (p_validbits & ((uint32_t)1U << 1))) { - p_validbits |= ((uint32_t)1U << 1); - m_pass_hash.clear(); - } return &m_pass_hash; } inline void NodeConfig::set_pass_hash(const void *data, size_t s) { m_pass_hash.assign((const char *)data,s); - p_validbits |= ((uint32_t)1U << 1); } inline void NodeConfig::set_pass_hash(const estring &v) { m_pass_hash = v; - p_validbits |= ((uint32_t)1U << 1); } @@ -7288,7 +7230,7 @@ inline uint32_t NodeConfig::cpu_freq() const inline bool NodeConfig::has_cpu_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 2)); + return 0 != (p_validbits & ((uint32_t)1U << 1)); } /*! @@ -7297,14 +7239,14 @@ inline bool NodeConfig::has_cpu_freq() const */ inline void NodeConfig::clear_cpu_freq() { - p_validbits &= ~((uint32_t)1U << 2); + p_validbits &= ~((uint32_t)1U << 1); m_cpu_freq = 0; } inline uint32_t *NodeConfig::mutable_cpu_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 2))) { - p_validbits |= ((uint32_t)1U << 2); + if (0 == (p_validbits & ((uint32_t)1U << 1))) { + p_validbits |= ((uint32_t)1U << 1); m_cpu_freq = 0; } return &m_cpu_freq; @@ -7313,7 +7255,7 @@ inline uint32_t *NodeConfig::mutable_cpu_freq() inline void NodeConfig::set_cpu_freq(uint32_t v) { m_cpu_freq = v; - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); } @@ -7325,7 +7267,7 @@ inline const WifiConfig &NodeConfig::station() const inline bool NodeConfig::has_station() const { - return 0 != (p_validbits & ((uint32_t)1U << 3)); + return 0 != (p_validbits & ((uint32_t)1U << 2)); } /*! @@ -7334,14 +7276,14 @@ inline bool NodeConfig::has_station() const */ inline void NodeConfig::clear_station() { - p_validbits &= ~((uint32_t)1U << 3); + p_validbits &= ~((uint32_t)1U << 2); m_station.clear(); } inline WifiConfig *NodeConfig::mutable_station() { - if (0 == (p_validbits & ((uint32_t)1U << 3))) { - p_validbits |= ((uint32_t)1U << 3); + if (0 == (p_validbits & ((uint32_t)1U << 2))) { + p_validbits |= ((uint32_t)1U << 2); m_station.clear(); } return &m_station; @@ -7350,13 +7292,13 @@ inline WifiConfig *NodeConfig::mutable_station() inline void NodeConfig::set_station(const void *data, size_t s) { m_station.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } inline void NodeConfig::set_station(const WifiConfig &v) { m_station = v; - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } @@ -7368,7 +7310,7 @@ inline const WifiConfig &NodeConfig::softap() const inline bool NodeConfig::has_softap() const { - return 0 != (p_validbits & ((uint32_t)1U << 4)); + return 0 != (p_validbits & ((uint32_t)1U << 3)); } /*! @@ -7377,14 +7319,14 @@ inline bool NodeConfig::has_softap() const */ inline void NodeConfig::clear_softap() { - p_validbits &= ~((uint32_t)1U << 4); + p_validbits &= ~((uint32_t)1U << 3); m_softap.clear(); } inline WifiConfig *NodeConfig::mutable_softap() { - if (0 == (p_validbits & ((uint32_t)1U << 4))) { - p_validbits |= ((uint32_t)1U << 4); + if (0 == (p_validbits & ((uint32_t)1U << 3))) { + p_validbits |= ((uint32_t)1U << 3); m_softap.clear(); } return &m_softap; @@ -7393,13 +7335,13 @@ inline WifiConfig *NodeConfig::mutable_softap() inline void NodeConfig::set_softap(const void *data, size_t s) { m_softap.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } inline void NodeConfig::set_softap(const WifiConfig &v) { m_softap = v; - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } @@ -7426,7 +7368,7 @@ inline void NodeConfig::clear_dns_server() inline estring *NodeConfig::mutable_dns_server(unsigned x) { if (x >= m_dns_server.size()) - m_dns_server.resize(x+1,""); + m_dns_server.resize(x+1); return &m_dns_server[x]; } @@ -7589,7 +7531,7 @@ inline const MQTT &NodeConfig::mqtt() const inline bool NodeConfig::has_mqtt() const { - return 0 != (p_validbits & ((uint32_t)1U << 5)); + return 0 != (p_validbits & ((uint32_t)1U << 4)); } /*! @@ -7598,14 +7540,14 @@ inline bool NodeConfig::has_mqtt() const */ inline void NodeConfig::clear_mqtt() { - p_validbits &= ~((uint32_t)1U << 5); + p_validbits &= ~((uint32_t)1U << 4); m_mqtt.clear(); } inline MQTT *NodeConfig::mutable_mqtt() { - if (0 == (p_validbits & ((uint32_t)1U << 5))) { - p_validbits |= ((uint32_t)1U << 5); + if (0 == (p_validbits & ((uint32_t)1U << 4))) { + p_validbits |= ((uint32_t)1U << 4); m_mqtt.clear(); } return &m_mqtt; @@ -7614,13 +7556,13 @@ inline MQTT *NodeConfig::mutable_mqtt() inline void NodeConfig::set_mqtt(const void *data, size_t s) { m_mqtt.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } inline void NodeConfig::set_mqtt(const MQTT &v) { m_mqtt = v; - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } #endif // CONFIG_MQTT @@ -7633,7 +7575,7 @@ inline uint16_t NodeConfig::dmesg_size() const inline bool NodeConfig::has_dmesg_size() const { - return 0 != (p_validbits & ((uint32_t)1U << 6)); + return 0 != (p_validbits & ((uint32_t)1U << 5)); } /*! @@ -7642,14 +7584,14 @@ inline bool NodeConfig::has_dmesg_size() const */ inline void NodeConfig::clear_dmesg_size() { - p_validbits &= ~((uint32_t)1U << 6); + p_validbits &= ~((uint32_t)1U << 5); m_dmesg_size = 2048; } inline uint16_t *NodeConfig::mutable_dmesg_size() { - if (0 == (p_validbits & ((uint32_t)1U << 6))) { - p_validbits |= ((uint32_t)1U << 6); + if (0 == (p_validbits & ((uint32_t)1U << 5))) { + p_validbits |= ((uint32_t)1U << 5); m_dmesg_size = 2048; } return &m_dmesg_size; @@ -7658,7 +7600,7 @@ inline uint16_t *NodeConfig::mutable_dmesg_size() inline void NodeConfig::set_dmesg_size(uint16_t v) { m_dmesg_size = v; - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); } @@ -7671,7 +7613,7 @@ inline const Influx &NodeConfig::influx() const inline bool NodeConfig::has_influx() const { - return 0 != (p_validbits & ((uint32_t)1U << 7)); + return 0 != (p_validbits & ((uint32_t)1U << 6)); } /*! @@ -7680,14 +7622,14 @@ inline bool NodeConfig::has_influx() const */ inline void NodeConfig::clear_influx() { - p_validbits &= ~((uint32_t)1U << 7); + p_validbits &= ~((uint32_t)1U << 6); m_influx.clear(); } inline Influx *NodeConfig::mutable_influx() { - if (0 == (p_validbits & ((uint32_t)1U << 7))) { - p_validbits |= ((uint32_t)1U << 7); + if (0 == (p_validbits & ((uint32_t)1U << 6))) { + p_validbits |= ((uint32_t)1U << 6); m_influx.clear(); } return &m_influx; @@ -7696,13 +7638,13 @@ inline Influx *NodeConfig::mutable_influx() inline void NodeConfig::set_influx(const void *data, size_t s) { m_influx.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } inline void NodeConfig::set_influx(const Influx &v) { m_influx = v; - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } #endif // CONFIG_INFLUX @@ -7715,7 +7657,7 @@ inline uint32_t NodeConfig::station2ap_time() const inline bool NodeConfig::has_station2ap_time() const { - return 0 != (p_validbits & ((uint32_t)1U << 8)); + return 0 != (p_validbits & ((uint32_t)1U << 7)); } /*! @@ -7724,14 +7666,14 @@ inline bool NodeConfig::has_station2ap_time() const */ inline void NodeConfig::clear_station2ap_time() { - p_validbits &= ~((uint32_t)1U << 8); + p_validbits &= ~((uint32_t)1U << 7); m_station2ap_time = 0; } inline uint32_t *NodeConfig::mutable_station2ap_time() { - if (0 == (p_validbits & ((uint32_t)1U << 8))) { - p_validbits |= ((uint32_t)1U << 8); + if (0 == (p_validbits & ((uint32_t)1U << 7))) { + p_validbits |= ((uint32_t)1U << 7); m_station2ap_time = 0; } return &m_station2ap_time; @@ -7740,7 +7682,7 @@ inline uint32_t *NodeConfig::mutable_station2ap_time() inline void NodeConfig::set_station2ap_time(uint32_t v) { m_station2ap_time = v; - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); } @@ -7893,7 +7835,7 @@ inline uint32_t NodeConfig::actions_enable() const inline bool NodeConfig::has_actions_enable() const { - return 0 != (p_validbits & ((uint32_t)1U << 9)); + return 0 != (p_validbits & ((uint32_t)1U << 8)); } /*! @@ -7902,14 +7844,14 @@ inline bool NodeConfig::has_actions_enable() const */ inline void NodeConfig::clear_actions_enable() { - p_validbits &= ~((uint32_t)1U << 9); + p_validbits &= ~((uint32_t)1U << 8); m_actions_enable = 1; } inline uint32_t *NodeConfig::mutable_actions_enable() { - if (0 == (p_validbits & ((uint32_t)1U << 9))) { - p_validbits |= ((uint32_t)1U << 9); + if (0 == (p_validbits & ((uint32_t)1U << 8))) { + p_validbits |= ((uint32_t)1U << 8); m_actions_enable = 1; } return &m_actions_enable; @@ -7918,7 +7860,7 @@ inline uint32_t *NodeConfig::mutable_actions_enable() inline void NodeConfig::set_actions_enable(uint32_t v) { m_actions_enable = v; - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); } @@ -8082,7 +8024,7 @@ inline uint16_t NodeConfig::udp_ctrl_port() const inline bool NodeConfig::has_udp_ctrl_port() const { - return 0 != (p_validbits & ((uint32_t)1U << 10)); + return 0 != (p_validbits & ((uint32_t)1U << 9)); } /*! @@ -8091,14 +8033,14 @@ inline bool NodeConfig::has_udp_ctrl_port() const */ inline void NodeConfig::clear_udp_ctrl_port() { - p_validbits &= ~((uint32_t)1U << 10); + p_validbits &= ~((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } inline uint16_t *NodeConfig::mutable_udp_ctrl_port() { - if (0 == (p_validbits & ((uint32_t)1U << 10))) { - p_validbits |= ((uint32_t)1U << 10); + if (0 == (p_validbits & ((uint32_t)1U << 9))) { + p_validbits |= ((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } return &m_udp_ctrl_port; @@ -8107,7 +8049,7 @@ inline uint16_t *NodeConfig::mutable_udp_ctrl_port() inline void NodeConfig::set_udp_ctrl_port(uint16_t v) { m_udp_ctrl_port = v; - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); } @@ -8174,7 +8116,7 @@ inline const FtpHttpConfig &NodeConfig::ftpd() const inline bool NodeConfig::has_ftpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 11)); + return 0 != (p_validbits & ((uint32_t)1U << 10)); } /*! @@ -8183,14 +8125,14 @@ inline bool NodeConfig::has_ftpd() const */ inline void NodeConfig::clear_ftpd() { - p_validbits &= ~((uint32_t)1U << 11); + p_validbits &= ~((uint32_t)1U << 10); m_ftpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_ftpd() { - if (0 == (p_validbits & ((uint32_t)1U << 11))) { - p_validbits |= ((uint32_t)1U << 11); + if (0 == (p_validbits & ((uint32_t)1U << 10))) { + p_validbits |= ((uint32_t)1U << 10); m_ftpd.clear(); } return &m_ftpd; @@ -8199,13 +8141,13 @@ inline FtpHttpConfig *NodeConfig::mutable_ftpd() inline void NodeConfig::set_ftpd(const void *data, size_t s) { m_ftpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } inline void NodeConfig::set_ftpd(const FtpHttpConfig &v) { m_ftpd = v; - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } #endif // CONFIG_FTP @@ -8219,7 +8161,7 @@ inline const FtpHttpConfig &NodeConfig::httpd() const inline bool NodeConfig::has_httpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 12)); + return 0 != (p_validbits & ((uint32_t)1U << 11)); } /*! @@ -8228,14 +8170,14 @@ inline bool NodeConfig::has_httpd() const */ inline void NodeConfig::clear_httpd() { - p_validbits &= ~((uint32_t)1U << 12); + p_validbits &= ~((uint32_t)1U << 11); m_httpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_httpd() { - if (0 == (p_validbits & ((uint32_t)1U << 12))) { - p_validbits |= ((uint32_t)1U << 12); + if (0 == (p_validbits & ((uint32_t)1U << 11))) { + p_validbits |= ((uint32_t)1U << 11); m_httpd.clear(); } return &m_httpd; @@ -8244,13 +8186,13 @@ inline FtpHttpConfig *NodeConfig::mutable_httpd() inline void NodeConfig::set_httpd(const void *data, size_t s) { m_httpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } inline void NodeConfig::set_httpd(const FtpHttpConfig &v) { m_httpd = v; - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } #endif // CONFIG_HTTP @@ -8263,7 +8205,7 @@ inline const estring &NodeConfig::otasrv() const inline bool NodeConfig::has_otasrv() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return !m_otasrv.empty(); } /*! @@ -8272,35 +8214,27 @@ inline bool NodeConfig::has_otasrv() const */ 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); } @@ -8440,7 +8374,7 @@ inline uint32_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 12)); } /*! @@ -8449,23 +8383,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 12); m_threshold_off = 0; } -inline uint32_t *NodeConfig::mutable_threshold_off() -{ - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); - m_threshold_off = 0; - } - return &m_threshold_off; -} - inline void NodeConfig::set_threshold_off(uint32_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 12); } @@ -8477,7 +8402,7 @@ inline uint32_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 13)); } /*! @@ -8486,23 +8411,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 13); m_threshold_on = 0; } -inline uint32_t *NodeConfig::mutable_threshold_on() -{ - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); - m_threshold_on = 0; - } - return &m_threshold_on; -} - inline void NodeConfig::set_threshold_on(uint32_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 13); } @@ -8514,7 +8430,7 @@ inline uint32_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8523,14 +8439,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 14); m_dim_step = 0; } inline uint32_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_dim_step = 0; } return &m_dim_step; @@ -8539,7 +8455,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 << 16); + p_validbits |= ((uint32_t)1U << 14); } @@ -8551,7 +8467,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8560,14 +8476,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 15); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_lightctrl = 0; } return &m_lightctrl; @@ -8576,7 +8492,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 15); } @@ -8588,7 +8504,7 @@ inline uint32_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 18)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8597,14 +8513,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 18); + p_validbits &= ~((uint32_t)1U << 16); m_pwm_freq = 0; } inline uint32_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 18))) { - p_validbits |= ((uint32_t)1U << 18); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8613,7 +8529,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 << 18); + p_validbits |= ((uint32_t)1U << 16); } diff --git a/components/wfc/swcfg_esp8285.cpp b/components/wfc/swcfg_esp8285.cpp index 5a757ab..34ce608 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -49,6 +49,7 @@ * varintbits : 32 * * options from common: + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -75,7 +76,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * toJSON : "toJSON" * toMemory : "toMemory" * UnknownField : "skip" @@ -613,14 +613,6 @@ const char *sigtype_t_str(sigtype_t e) } WifiConfig::WifiConfig() -: m_ssid() -, m_pass() -, m_mac() -, m_activate(false) -, m_addr4(0) -, m_netmask4(0) -, m_gateway4(0) -, p_validbits(0) { } @@ -687,7 +679,6 @@ ssize_t WifiConfig::fromMemory(const void *b, ssize_t s) return -4; } m_mac.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x23: // activate id 4, type bool, coding 8bit @@ -745,7 +736,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has mac? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { // 'mac': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -11; @@ -761,7 +752,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x23; *a++ = m_activate; // has addr4? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'addr4': id=5, encoding=32bit, tag=0x2d if (5 > (e-a)) return -14; @@ -772,7 +763,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has netmask4? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'netmask4': id=6, encoding=8bit, tag=0x33 if (2 > (e-a)) return -16; @@ -780,7 +771,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = m_netmask4; } // has gateway4? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'gateway4': id=7, encoding=32bit, tag=0x3d if (5 > (e-a)) return -17; @@ -927,8 +918,6 @@ int WifiConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_mac,value); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"activate")) { @@ -942,7 +931,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_addr4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"netmask4")) { @@ -952,7 +941,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_netmask4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"gateway4")) { @@ -962,19 +951,13 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_gateway4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); return r; } return -19; } MQTT::MQTT() -: m_uri() -, m_enable(false) -, m_username() -, m_password() -, m_keepalive(60) -, p_validbits(0) { } @@ -985,8 +968,6 @@ void MQTT::clear() m_username.clear(); m_password.clear(); m_subscribtions.clear(); - m_keepalive = 60; - p_validbits = 0; } void MQTT::toASCII(stream &o, size_t indent) const @@ -1009,7 +990,6 @@ void MQTT::toASCII(stream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; - ascii_numeric(o, indent, "keepalive", m_keepalive); --indent; ascii_indent(o,indent); o << '}'; @@ -1058,9 +1038,6 @@ ssize_t MQTT::fromMemory(const void *b, ssize_t s) m_subscribtions.emplace_back((const char*)a,ud.vi); a += ud.vi; break; - case 0x30: // keepalive id 6, type uint16_t, coding varint - set_keepalive((uint16_t)ud.u32); - break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data @@ -1132,17 +1109,7 @@ ssize_t MQTT::toMemory(uint8_t *b, ssize_t s) const return -35; a += n; } - // has keepalive? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { - // 'keepalive': id=6, encoding=varint, tag=0x30 - if (a >= e) - return -36; - *a++ = 0x30; - n = write_varint(a,e-a,m_keepalive); - if (n <= 0) - return -37; - a += n; - } + // 'keepalive' is unused. Therefore no data will be written. assert(a <= e); return a-b; } @@ -1185,10 +1152,6 @@ void MQTT::toJSON(stream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } - if (has_keepalive()) { - fsep = json_indent(json,indLvl,fsep,"keepalive"); - to_decstr(json,m_keepalive); - } if (fsep == '{') json.put('{'); json.put('\n'); @@ -1230,17 +1193,12 @@ size_t MQTT::calcSize() const r += s + 1 /* tag(subscribtions) 0x28 */; } } - // optional uint16 keepalive, id 6 - if (has_keepalive()) { - r += wiresize((varint_t)m_keepalive) + 1 /* tag(keepalive) 0x30 */; - } + // unused optional uint16 keepalive, id 6 return r; } bool MQTT::operator == (const MQTT &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_uri() && (!(m_uri == r.m_uri))) return false; if (has_enable() && (!(m_enable == r.m_enable))) @@ -1251,8 +1209,6 @@ bool MQTT::operator == (const MQTT &r) const return false; if (!(m_subscribtions == r.m_subscribtions)) return false; - if (has_keepalive() && (!(m_keepalive == r.m_keepalive))) - return false; return true; } @@ -1317,40 +1273,24 @@ int MQTT::setByName(const char *name, const char *value) } else { x = strtoul(name+14,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+14))) - return -38; + return -36; if (m_subscribtions.size() <= x) - return -39; + return -37; if ((idxe[1] == 0) && (value == 0)) { m_subscribtions.erase(m_subscribtions.begin()+x); return 0; } } if (idxe[1] != 0) - return -40; + return -38; m_subscribtions[x] = value; return m_subscribtions[x].size(); } } - if (0 == strcmp(name,"keepalive")) { - if (value == 0) { - clear_keepalive(); - return 0; - } - int r = parse_ascii_u16(&m_keepalive,value); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); - return r; - } - return -41; + return -39; } Date::Date() -: m_day(0) -, m_month(0) -, m_year(0) -, m_endday(0) -, m_endmonth(0) -, m_endyear(0) { } @@ -1388,7 +1328,7 @@ ssize_t Date::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -42; + return -40; a += x; switch (fid) { case 0xb: // day id 1, type uint8_t, coding 8bit @@ -1414,13 +1354,13 @@ ssize_t Date::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -43; + return -41; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -44; + return -42; return a-(const uint8_t *)b; } @@ -1432,7 +1372,7 @@ ssize_t Date::toMemory(uint8_t *b, ssize_t s) const if (m_day != 0) { // 'day': id=1, encoding=8bit, tag=0xb if (2 > (e-a)) - return -45; + return -43; *a++ = 0xb; *a++ = m_day; } @@ -1440,7 +1380,7 @@ ssize_t Date::toMemory(uint8_t *b, ssize_t s) const if (m_month != 0) { // 'month': id=2, encoding=8bit, tag=0x13 if (2 > (e-a)) - return -46; + return -44; *a++ = 0x13; *a++ = m_month; } @@ -1448,7 +1388,7 @@ ssize_t Date::toMemory(uint8_t *b, ssize_t s) const if (m_year != 0) { // 'year': id=3, encoding=16bit, tag=0x1c if (3 > (e-a)) - return -47; + return -45; *a++ = 0x1c; write_u16(a,m_year); a += 2; @@ -1457,7 +1397,7 @@ ssize_t Date::toMemory(uint8_t *b, ssize_t s) const if (m_endday != 0) { // 'endday': id=4, encoding=8bit, tag=0x23 if (2 > (e-a)) - return -48; + return -46; *a++ = 0x23; *a++ = m_endday; } @@ -1465,7 +1405,7 @@ ssize_t Date::toMemory(uint8_t *b, ssize_t s) const if (m_endmonth != 0) { // 'endmonth': id=5, encoding=8bit, tag=0x2b if (2 > (e-a)) - return -49; + return -47; *a++ = 0x2b; *a++ = m_endmonth; } @@ -1473,7 +1413,7 @@ ssize_t Date::toMemory(uint8_t *b, ssize_t s) const if (m_endyear != 0) { // 'endyear': id=6, encoding=8bit, tag=0x33 if (2 > (e-a)) - return -50; + return -48; *a++ = 0x33; *a++ = m_endyear; } @@ -1624,15 +1564,10 @@ int Date::setByName(const char *name, const char *value) int r = parse_ascii_u8(&m_endyear,value); return r; } - return -51; + return -49; } AtAction::AtAction() -: m_day(Sunday) -, m_min_of_day(0) -, m_action() -, m_enable(true) -, p_validbits(0) { } @@ -1672,7 +1607,7 @@ ssize_t AtAction::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -52; + return -50; a += x; switch (fid) { case 0x8: // day id 1, type WeekDay, coding varint @@ -1683,10 +1618,9 @@ ssize_t AtAction::fromMemory(const void *b, ssize_t s) break; case 0x1a: // action id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -53; + return -51; } m_action.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 2); a += ud.vi; break; case 0x23: // enable id 4, type bool, coding 8bit @@ -1697,13 +1631,13 @@ ssize_t AtAction::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -54; + return -52; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -55; + return -53; return a-(const uint8_t *)b; } @@ -1716,38 +1650,38 @@ ssize_t AtAction::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'day': id=1, encoding=varint, tag=0x8 if (a >= e) - return -56; + return -54; *a++ = 0x8; n = write_varint(a,e-a,m_day); if (n <= 0) - return -57; + return -55; a += n; } // has min_of_day? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'min_of_day': id=2, encoding=varint, tag=0x10 if (a >= e) - return -58; + return -56; *a++ = 0x10; n = write_varint(a,e-a,m_min_of_day); if (n <= 0) - return -59; + return -57; a += n; } // has action? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { // 'action': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -60; + return -58; *a++ = 0x1a; n = encode_bytes(m_action,a,e); if (n < 0) - return -61; + return -59; a += n; } // 'enable': id=4, encoding=8bit, tag=0x23 if (2 > (e-a)) - return -62; + return -60; *a++ = 0x23; *a++ = m_enable; assert(a <= e); @@ -1843,7 +1777,7 @@ int AtAction::setByName(const char *name, const char *value) WeekDay v; size_t r = parse_ascii_WeekDay(&v,value); if (r == 0) - return -63; + return -61; set_day(v); return r; } @@ -1864,23 +1798,16 @@ int AtAction::setByName(const char *name, const char *value) } m_action = value; int r = m_action.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"enable")) { int r = parse_ascii_bool(&m_enable,value); return r; } - return -64; + return -62; } Influx::Influx() -: m_hostname() -, m_port(0) -, m_measurement() -// omitted obsolete member interval -, m_database() { } @@ -1914,12 +1841,12 @@ ssize_t Influx::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -65; + return -63; a += x; switch (fid) { case 0xa: // hostname id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -66; + return -64; } m_hostname.assign((const char*)a,ud.vi); a += ud.vi; @@ -1929,14 +1856,14 @@ ssize_t Influx::fromMemory(const void *b, ssize_t s) break; case 0x1a: // measurement id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -67; + return -65; } m_measurement.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x2a: // database id 5, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -68; + return -66; } m_database.assign((const char*)a,ud.vi); a += ud.vi; @@ -1946,13 +1873,13 @@ ssize_t Influx::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -69; + return -67; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -70; + return -68; return a-(const uint8_t *)b; } @@ -1965,18 +1892,18 @@ ssize_t Influx::toMemory(uint8_t *b, ssize_t s) const if (!m_hostname.empty()) { // 'hostname': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -71; + return -69; *a++ = 0xa; n = encode_bytes(m_hostname,a,e); if (n < 0) - return -72; + return -70; a += n; } // has port? if (m_port != 0) { // 'port': id=2, encoding=16bit, tag=0x14 if (3 > (e-a)) - return -73; + return -71; *a++ = 0x14; write_u16(a,m_port); a += 2; @@ -1985,11 +1912,11 @@ ssize_t Influx::toMemory(uint8_t *b, ssize_t s) const if (!m_measurement.empty()) { // 'measurement': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -74; + return -72; *a++ = 0x1a; n = encode_bytes(m_measurement,a,e); if (n < 0) - return -75; + return -73; a += n; } // 'interval' is obsolete. Therefore no data will be written. @@ -1997,11 +1924,11 @@ ssize_t Influx::toMemory(uint8_t *b, ssize_t s) const if (!m_database.empty()) { // 'database': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -76; + return -74; *a++ = 0x2a; n = encode_bytes(m_database,a,e); if (n < 0) - return -77; + return -75; a += n; } assert(a <= e); @@ -2123,17 +2050,10 @@ int Influx::setByName(const char *name, const char *value) int r = m_database.size(); return r; } - return -78; + return -76; } UartSettings::UartSettings() -: m_port(0) -, m_baudrate(0) -, m_config(5) -, m_rx_thresh(0) -, m_tx_bufsize(0) -, m_rx_bufsize(0) -, p_validbits(0) { } @@ -2195,7 +2115,7 @@ ssize_t UartSettings::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -79; + return -77; a += x; switch (fid) { case 0x8: // port id 1, type uint8_t, coding varint @@ -2221,13 +2141,13 @@ ssize_t UartSettings::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -80; + return -78; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -81; + return -79; return a-(const uint8_t *)b; } @@ -2240,29 +2160,29 @@ ssize_t UartSettings::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 -82; + return -80; *a++ = 0x8; n = write_varint(a,e-a,m_port); if (n <= 0) - return -83; + return -81; a += n; } // has baudrate? if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'baudrate': id=2, encoding=varint, tag=0x10 if (a >= e) - return -84; + return -82; *a++ = 0x10; n = write_varint(a,e-a,m_baudrate); if (n <= 0) - return -85; + return -83; a += n; } // has config? if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'config': id=3, encoding=16bit, tag=0x1c if (a >= e) - return -86; + return -84; *a++ = 0x1c; write_u16(a,m_config); a += 2; @@ -2271,7 +2191,7 @@ ssize_t UartSettings::toMemory(uint8_t *b, ssize_t s) const if (m_rx_thresh != 0) { // 'rx_thresh': id=4, encoding=8bit, tag=0x23 if (2 > (e-a)) - return -87; + return -85; *a++ = 0x23; *a++ = m_rx_thresh; } @@ -2279,22 +2199,22 @@ ssize_t UartSettings::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 3))) { // 'tx_bufsize': id=6, encoding=varint, tag=0x30 if (a >= e) - return -88; + return -86; *a++ = 0x30; n = write_varint(a,e-a,m_tx_bufsize); if (n <= 0) - return -89; + return -87; a += n; } // has rx_bufsize? if (0 != (p_validbits & ((uint8_t)1U << 4))) { // 'rx_bufsize': id=7, encoding=varint, tag=0x38 if (a >= e) - return -90; + return -88; *a++ = 0x38; n = write_varint(a,e-a,m_rx_bufsize); if (n <= 0) - return -91; + return -89; a += n; } assert(a <= e); @@ -2441,7 +2361,7 @@ int UartSettings::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -92; + return -90; } else if (!strcmp(name,"wl")) { uart_wl_t tmp; size_t r = parse_ascii_uart_wl_t(&tmp,value); @@ -2509,15 +2429,10 @@ int UartSettings::setByName(const char *name, const char *value) p_validbits |= ((uint8_t)1U << 4); return r; } - return -93; + return -91; } FtpHttpConfig::FtpHttpConfig() -: m_port(0) -, m_start(true) -, m_root() -, m_uploaddir() -, p_validbits(0) { } @@ -2552,7 +2467,7 @@ ssize_t FtpHttpConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -94; + return -92; a += x; switch (fid) { case 0xc: // port id 1, type uint16_t, coding 16bit @@ -2563,14 +2478,14 @@ ssize_t FtpHttpConfig::fromMemory(const void *b, ssize_t s) break; case 0x1a: // root id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -95; + return -93; } m_root.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x22: // uploaddir id 4, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -96; + return -94; } m_uploaddir.assign((const char*)a,ud.vi); a += ud.vi; @@ -2580,13 +2495,13 @@ ssize_t FtpHttpConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -97; + return -95; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -98; + return -96; return a-(const uint8_t *)b; } @@ -2599,7 +2514,7 @@ ssize_t FtpHttpConfig::toMemory(uint8_t *b, ssize_t s) const if (m_port != 0) { // 'port': id=1, encoding=16bit, tag=0xc if (3 > (e-a)) - return -99; + return -97; *a++ = 0xc; write_u16(a,m_port); a += 2; @@ -2608,7 +2523,7 @@ ssize_t FtpHttpConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'start': id=2, encoding=8bit, tag=0x13 if (2 > (e-a)) - return -100; + return -98; *a++ = 0x13; *a++ = m_start; } @@ -2616,22 +2531,22 @@ ssize_t FtpHttpConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_root.empty()) { // 'root': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -101; + return -99; *a++ = 0x1a; n = encode_bytes(m_root,a,e); if (n < 0) - return -102; + return -100; a += n; } // has uploaddir? if (!m_uploaddir.empty()) { // 'uploaddir': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -103; + return -101; *a++ = 0x22; n = encode_bytes(m_uploaddir,a,e); if (n < 0) - return -104; + return -102; a += n; } assert(a <= e); @@ -2753,14 +2668,10 @@ int FtpHttpConfig::setByName(const char *name, const char *value) int r = m_uploaddir.size(); return r; } - return -105; + return -103; } TerminalConfig::TerminalConfig() -: m_uart_rx(-1) -, m_uart_tx(-1) -, m_name() -, p_validbits(0) { } @@ -2769,7 +2680,6 @@ void TerminalConfig::clear() m_uart_rx = -1; m_uart_tx = -1; m_name.clear(); - p_validbits = 0; } void TerminalConfig::toASCII(stream &o, size_t indent) const @@ -2793,7 +2703,7 @@ ssize_t TerminalConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -106; + return -104; a += x; switch (fid) { case 0x8: // uart_rx id 1, type int8_t, coding signed varint @@ -2804,10 +2714,9 @@ ssize_t TerminalConfig::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 -107; + return -105; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; default: @@ -2815,13 +2724,13 @@ ssize_t TerminalConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -108; + return -106; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -109; + return -107; return a-(const uint8_t *)b; } @@ -2834,33 +2743,33 @@ ssize_t TerminalConfig::toMemory(uint8_t *b, ssize_t s) const if (m_uart_rx != -1) { // 'uart_rx': id=1, encoding=varint, tag=0x8 if (a >= e) - return -110; + return -108; *a++ = 0x8; n = write_varint(a,e-a,sint_varint(m_uart_rx)); if (n <= 0) - return -111; + return -109; a += n; } // has uart_tx? if (m_uart_tx != -1) { // 'uart_tx': id=2, encoding=varint, tag=0x10 if (a >= e) - return -112; + return -110; *a++ = 0x10; n = write_varint(a,e-a,sint_varint(m_uart_tx)); if (n <= 0) - return -113; + return -111; a += n; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -114; + return -112; *a++ = 0x1a; n = encode_bytes(m_name,a,e); if (n < 0) - return -115; + return -113; a += n; } assert(a <= e); @@ -2914,8 +2823,6 @@ size_t TerminalConfig::calcSize() const bool TerminalConfig::operator == (const TerminalConfig &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_uart_rx() && (!(m_uart_rx == r.m_uart_rx))) return false; if (has_uart_tx() && (!(m_uart_tx == r.m_uart_tx))) @@ -2958,16 +2865,12 @@ int TerminalConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } - return -116; + return -114; } Trigger::Trigger() -: m_event() -, p_validbits(0) { } @@ -2975,7 +2878,6 @@ void Trigger::clear() { m_event.clear(); m_action.clear(); - p_validbits = 0; } void Trigger::toASCII(stream &o, size_t indent) const @@ -3009,20 +2911,19 @@ ssize_t Trigger::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -117; + return -115; a += x; switch (fid) { case 0xa: // event id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -118; + return -116; } m_event.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x12: // action id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -119; + return -117; } m_action.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -3032,13 +2933,13 @@ ssize_t Trigger::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -120; + return -118; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -121; + return -119; return a-(const uint8_t *)b; } @@ -3048,24 +2949,24 @@ ssize_t Trigger::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has event? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { // 'event': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -122; + return -120; *a++ = 0xa; n = encode_bytes(m_event,a,e); if (n < 0) - return -123; + return -121; a += n; } for (const auto &x : m_action) { // 'action': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -124; + return -122; *a++ = 0x12; n = encode_bytes(x,a,e); if (n < 0) - return -125; + return -123; a += n; } assert(a <= e); @@ -3130,8 +3031,6 @@ size_t Trigger::calcSize() const bool Trigger::operator == (const Trigger &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_event() && (!(m_event == r.m_event))) return false; if (!(m_action == r.m_action)) @@ -3156,8 +3055,6 @@ int Trigger::setByName(const char *name, const char *value) } m_event = value; int r = m_event.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"action",6)) { @@ -3176,30 +3073,24 @@ int Trigger::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -126; + return -124; if (m_action.size() <= x) - return -127; + return -125; if ((idxe[1] == 0) && (value == 0)) { m_action.erase(m_action.begin()+x); return 0; } } if (idxe[1] != 0) - return -128; + return -126; m_action[x] = value; return m_action[x].size(); } } - return -129; + return -127; } AppParam::AppParam() -: m_key() -, m_uValue(0) -, m_sValue() -, m_dValue(0) -, m_fValue(0) -, p_validbits(0) { } @@ -3236,15 +3127,14 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -130; + return -128; a += x; switch (fid) { case 0xa: // key id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -131; + return -129; } m_key.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x10: // uValue id 2, type uint32_t, coding varint @@ -3252,10 +3142,9 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) break; case 0x1a: // sValue id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -132; + return -130; } m_sValue.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 2); a += ud.vi; break; case 0x20: // dValue id 4, type int32_t, coding signed varint @@ -3269,13 +3158,13 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -133; + return -131; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -134; + return -132; return a-(const uint8_t *)b; } @@ -3285,54 +3174,54 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has key? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { // 'key': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -135; + return -133; *a++ = 0xa; n = encode_bytes(m_key,a,e); if (n < 0) - return -136; + return -134; a += n; } // has uValue? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'uValue': id=2, encoding=varint, tag=0x10 if (a >= e) - return -137; + return -135; *a++ = 0x10; n = write_varint(a,e-a,m_uValue); if (n <= 0) - return -138; + return -136; a += n; } // has sValue? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { // 'sValue': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -139; + return -137; *a++ = 0x1a; n = encode_bytes(m_sValue,a,e); if (n < 0) - return -140; + return -138; a += n; } // has dValue? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'dValue': id=4, encoding=varint, tag=0x20 if (a >= e) - return -141; + return -139; *a++ = 0x20; n = write_varint(a,e-a,sint_varint(m_dValue)); if (n <= 0) - return -142; + return -140; a += n; } // has fValue? - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'fValue': id=5, encoding=64bit, tag=0x29 if (9 > (e-a)) - return -143; + return -141; *a++ = 0x29; write_u64(a,mangle_double(m_fValue)); a += 8; @@ -3437,8 +3326,6 @@ int AppParam::setByName(const char *name, const char *value) } m_key = value; int r = m_key.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"uValue")) { @@ -3448,7 +3335,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_uValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"sValue")) { @@ -3458,8 +3345,6 @@ int AppParam::setByName(const char *name, const char *value) } m_sValue = value; int r = m_sValue.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"dValue")) { @@ -3469,7 +3354,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_s32(&m_dValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"fValue")) { @@ -3479,17 +3364,13 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_dbl(&m_fValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); return r; } - return -144; + return -142; } EventTimer::EventTimer() -: m_name() -, m_time(0) -, m_config(0) -, p_validbits(0) { } @@ -3530,12 +3411,12 @@ ssize_t EventTimer::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -145; + return -143; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -146; + return -144; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -3551,13 +3432,13 @@ ssize_t EventTimer::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -147; + return -145; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -148; + return -146; return a-(const uint8_t *)b; } @@ -3570,33 +3451,33 @@ ssize_t EventTimer::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -149; + return -147; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -150; + return -148; a += n; } // has time? if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'time': id=2, encoding=varint, tag=0x10 if (a >= e) - return -151; + return -149; *a++ = 0x10; n = write_varint(a,e-a,m_time); if (n <= 0) - return -152; + return -150; a += n; } // has config? if (m_config != 0) { // 'config': id=3, encoding=varint, tag=0x18 if (a >= e) - return -153; + return -151; *a++ = 0x18; n = write_varint(a,e-a,m_config); if (n <= 0) - return -154; + return -152; a += n; } assert(a <= e); @@ -3705,7 +3586,7 @@ int EventTimer::setByName(const char *name, const char *value) } #ifndef CONFIG_ESPTOOLPY_FLASHSIZE_1MB if (*name++ != '.') { - return -155; + return -153; } else if (!strcmp(name,"restart")) { bool tmp; size_t r = parse_ascii_bool(&tmp,value); @@ -3721,13 +3602,10 @@ int EventTimer::setByName(const char *name, const char *value) } #endif // !CONFIG_ESPTOOLPY_FLASHSIZE_1MB } - return -156; + return -154; } FunctionConfig::FunctionConfig() -: m_name() -, m_func() -, p_validbits(0) { } @@ -3736,7 +3614,6 @@ void FunctionConfig::clear() m_name.clear(); m_func.clear(); m_params.clear(); - p_validbits = 0; } void FunctionConfig::toASCII(stream &o, size_t indent) const @@ -3771,28 +3648,26 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -157; + return -155; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -158; + return -156; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x12: // func id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -159; + return -157; } m_func.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 1); a += ud.vi; break; case 0x1a: // params id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -160; + return -158; } m_params.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -3802,13 +3677,13 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -161; + return -159; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -162; + return -160; return a-(const uint8_t *)b; } @@ -3818,35 +3693,35 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -163; + return -161; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -164; + return -162; a += n; } // has func? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { // 'func': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -165; + return -163; *a++ = 0x12; n = encode_bytes(m_func,a,e); if (n < 0) - return -166; + return -164; a += n; } for (const auto &x : m_params) { // 'params': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -167; + return -165; *a++ = 0x1a; n = encode_bytes(x,a,e); if (n < 0) - return -168; + return -166; a += n; } assert(a <= e); @@ -3920,8 +3795,6 @@ size_t FunctionConfig::calcSize() const bool FunctionConfig::operator == (const FunctionConfig &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_name() && (!(m_name == r.m_name))) return false; if (has_func() && (!(m_func == r.m_func))) @@ -3948,8 +3821,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"func")) { @@ -3959,8 +3830,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_func = value; int r = m_func.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == memcmp(name,"params",6)) { @@ -3979,27 +3848,24 @@ int FunctionConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -169; + return -167; if (m_params.size() <= x) - return -170; + return -168; if ((idxe[1] == 0) && (value == 0)) { m_params.erase(m_params.begin()+x); return 0; } } if (idxe[1] != 0) - return -171; + return -169; m_params[x] = value; return m_params[x].size(); } } - return -172; + return -170; } SignalConfig::SignalConfig() -: m_name() -, m_type(st_invalid) -, m_iv() { } @@ -4036,12 +3902,12 @@ ssize_t SignalConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -173; + return -171; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -174; + return -172; } m_name.assign((const char*)a,ud.vi); a += ud.vi; @@ -4051,7 +3917,7 @@ ssize_t SignalConfig::fromMemory(const void *b, ssize_t s) break; case 0x1a: // iv id 3, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -175; + return -173; } m_iv.assign((const char*)a,ud.vi); a += ud.vi; @@ -4061,13 +3927,13 @@ ssize_t SignalConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -176; + return -174; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -177; + return -175; return a-(const uint8_t *)b; } @@ -4080,33 +3946,33 @@ ssize_t SignalConfig::toMemory(uint8_t *b, ssize_t s) const if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -178; + return -176; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -179; + return -177; a += n; } // has type? if (m_type != st_invalid) { // 'type': id=2, encoding=varint, tag=0x10 if (a >= e) - return -180; + return -178; *a++ = 0x10; n = write_varint(a,e-a,m_type); if (n <= 0) - return -181; + return -179; a += n; } // has iv? if (!m_iv.empty()) { // 'iv': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -182; + return -180; *a++ = 0x1a; n = encode_bytes(m_iv,a,e); if (n < 0) - return -183; + return -181; a += n; } assert(a <= e); @@ -4203,7 +4069,7 @@ int SignalConfig::setByName(const char *name, const char *value) sigtype_t v; size_t r = parse_ascii_sigtype_t(&v,value); if (r == 0) - return -184; + return -182; set_type(v); return r; } @@ -4216,13 +4082,10 @@ int SignalConfig::setByName(const char *name, const char *value) int r = m_iv.size(); return r; } - return -185; + return -183; } OwDeviceConfig::OwDeviceConfig() -: m_id(0) -, m_name() -, p_validbits(0) { } @@ -4255,7 +4118,7 @@ ssize_t OwDeviceConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -186; + return -184; a += x; switch (fid) { case 0x9: // id id 1, type uint64_t, coding 64bit @@ -4263,10 +4126,9 @@ ssize_t OwDeviceConfig::fromMemory(const void *b, ssize_t s) break; case 0x12: // name id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -187; + return -185; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 1); a += ud.vi; break; default: @@ -4274,13 +4136,13 @@ ssize_t OwDeviceConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -188; + return -186; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -189; + return -187; return a-(const uint8_t *)b; } @@ -4293,20 +4155,20 @@ ssize_t OwDeviceConfig::toMemory(uint8_t *b, ssize_t s) const if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'id': id=1, encoding=64bit, tag=0x9 if (9 > (e-a)) - return -190; + return -188; *a++ = 0x9; write_u64(a,(uint64_t)m_id); a += 8; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { // 'name': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -191; + return -189; *a++ = 0x12; n = encode_bytes(m_name,a,e); if (n < 0) - return -192; + return -190; a += n; } assert(a <= e); @@ -4388,16 +4250,12 @@ int OwDeviceConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } - return -193; + return -191; } StateConfig::StateConfig() -: m_name() -, p_validbits(0) { } @@ -4405,7 +4263,6 @@ void StateConfig::clear() { m_name.clear(); m_conds.clear(); - p_validbits = 0; } void StateConfig::toASCII(stream &o, size_t indent) const @@ -4439,15 +4296,14 @@ ssize_t StateConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -194; + return -192; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -195; + return -193; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x12: // conds id 2, type Trigger, coding byte[] @@ -4456,7 +4312,7 @@ ssize_t StateConfig::fromMemory(const void *b, ssize_t s) int n; n = m_conds.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -196; + return -194; a += ud.vi; } break; @@ -4465,13 +4321,13 @@ ssize_t StateConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -197; + return -195; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -198; + return -196; return a-(const uint8_t *)b; } @@ -4481,26 +4337,26 @@ ssize_t StateConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -199; + return -197; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -200; + return -198; a += n; } for (const auto &x : m_conds) { // 'conds': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -201; + return -199; *a++ = 0x12; ssize_t conds_ws = x.calcSize(); n = write_varint(a,e-a,conds_ws); a += n; if ((n <= 0) || (conds_ws > (e-a))) - return -202; + return -200; n = x.toMemory(a,e-a); a += n; assert(n == conds_ws); @@ -4565,8 +4421,6 @@ size_t StateConfig::calcSize() const bool StateConfig::operator == (const StateConfig &r) const { - if (p_validbits != r.p_validbits) - return false; if (has_name() && (!(m_name == r.m_name))) return false; if (!(m_conds == r.m_conds)) @@ -4591,8 +4445,6 @@ int StateConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"conds",5)) { @@ -4611,26 +4463,23 @@ int StateConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+6,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+6))) - return -203; + return -201; if (m_conds.size() <= x) - return -204; + return -202; if ((idxe[1] == 0) && (value == 0)) { m_conds.erase(m_conds.begin()+x); return 0; } } if (idxe[1] != '.') - return -205; + return -203; return m_conds[x].setByName(idxe+2,value); } } - return -206; + return -204; } StateMachineConfig::StateMachineConfig() -: m_name() -, m_ini_st(0) -, p_validbits(0) { } @@ -4639,6 +4488,7 @@ void StateMachineConfig::clear() m_name.clear(); m_ini_st = 0; m_states.clear(); + m_persistent = false; p_validbits = 0; } @@ -4660,6 +4510,7 @@ void StateMachineConfig::toASCII(stream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; + ascii_bool(o, indent, "persistent", m_persistent); --indent; ascii_indent(o,indent); o << '}'; @@ -4674,15 +4525,14 @@ ssize_t StateMachineConfig::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 -205; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -208; + return -206; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x10: // ini_st id 2, type uint8_t, coding varint @@ -4694,22 +4544,25 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) int n; n = m_states.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -209; + return -207; a += ud.vi; } break; + case 0x23: // persistent id 4, type bool, coding 8bit + set_persistent(ud.u8); + break; default: if ((fid & 7) == 2) { // need only to skip len prefixed data a += ud.vi; if (a > e) - return -210; + return -208; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -211; + return -209; return a-(const uint8_t *)b; } @@ -4719,43 +4572,51 @@ ssize_t StateMachineConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -212; + return -210; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -213; + return -211; a += n; } // has ini_st? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'ini_st': id=2, encoding=varint, tag=0x10 if (a >= e) - return -214; + return -212; *a++ = 0x10; n = write_varint(a,e-a,m_ini_st); if (n <= 0) - return -215; + return -213; a += n; } for (const auto &x : m_states) { // 'states': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -216; + return -214; *a++ = 0x1a; ssize_t states_ws = x.calcSize(); n = write_varint(a,e-a,states_ws); a += n; if ((n <= 0) || (states_ws > (e-a))) - return -217; + return -215; n = x.toMemory(a,e-a); a += n; assert(n == states_ws); } - assert(a <= e); - return a-b; + // has persistent? + if (m_persistent != false) { + // 'persistent': id=4, encoding=8bit, tag=0x23 + if (2 > (e-a)) + return -216; + *a++ = 0x23; + *a++ = m_persistent; + } + assert(a <= e); + return a-b; } void StateMachineConfig::toJSON(stream &json, unsigned indLvl) const @@ -4788,6 +4649,10 @@ void StateMachineConfig::toJSON(stream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } + if (has_persistent()) { + fsep = json_indent(json,indLvl,fsep,"persistent"); + json << (m_persistent ? "true" : "false"); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -4817,6 +4682,10 @@ size_t StateMachineConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(states) 0x18 */; } + // optional bool persistent, id 4 + if (has_persistent()) { + r += 2; + } return r; } @@ -4830,6 +4699,8 @@ bool StateMachineConfig::operator == (const StateMachineConfig &r) const return false; if (!(m_states == r.m_states)) return false; + if (has_persistent() && (!(m_persistent == r.m_persistent))) + return false; return true; } @@ -4850,8 +4721,6 @@ int StateMachineConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"ini_st")) { @@ -4861,7 +4730,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_ini_st,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"states",6)) { @@ -4880,27 +4749,31 @@ int StateMachineConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -218; + return -217; if (m_states.size() <= x) - return -219; + return -218; if ((idxe[1] == 0) && (value == 0)) { m_states.erase(m_states.begin()+x); return 0; } } if (idxe[1] != '.') - return -220; + return -219; return m_states[x].setByName(idxe+2,value); } } - return -221; + if (0 == strcmp(name,"persistent")) { + if (value == 0) { + clear_persistent(); + return 0; + } + int r = parse_ascii_bool(&m_persistent,value); + return r; + } + return -220; } ThresholdConfig::ThresholdConfig() -: m_name() -, m_low(0) -, m_high(0) -, p_validbits(0) { } @@ -4933,15 +4806,14 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -222; + return -221; a += x; switch (fid) { case 0xa: // name id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -223; + return -222; } m_name.assign((const char*)a,ud.vi); - p_validbits |= ((uint8_t)1U << 0); a += ud.vi; break; case 0x15: // low id 2, type float, coding 32bit @@ -4955,13 +4827,13 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -224; + return -223; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -225; + return -224; return a-(const uint8_t *)b; } @@ -4971,35 +4843,35 @@ ssize_t ThresholdConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -226; + return -225; *a++ = 0xa; n = encode_bytes(m_name,a,e); if (n < 0) - return -227; + return -226; a += n; } // has low? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'low': id=2, encoding=32bit, tag=0x15 if (5 > (e-a)) - return -228; + return -227; *a++ = 0x15; if ((e-a) < 4) - return -229; + return -228; write_u32(a,mangle_float(m_low)); a += 4; } // has high? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'high': id=3, encoding=32bit, tag=0x1d if (5 > (e-a)) - return -230; + return -229; *a++ = 0x1d; if ((e-a) < 4) - return -231; + return -230; write_u32(a,mangle_float(m_high)); a += 4; } @@ -5082,8 +4954,6 @@ int ThresholdConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"low")) { @@ -5093,7 +4963,7 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_low,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"high")) { @@ -5103,10 +4973,10 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_high,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } - return -232; + return -231; } LuaConfig::LuaConfig() @@ -5161,19 +5031,19 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -233; + return -232; a += x; switch (fid) { case 0xa: // init_scripts id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -234; + return -233; } m_init_scripts.emplace_back((const char*)a,ud.vi); a += ud.vi; break; case 0x12: // compile_files id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -235; + return -234; } m_compile_files.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -5183,13 +5053,13 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) // need only to skip len prefixed data a += ud.vi; if (a > e) - return -236; + return -235; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -237; + return -236; return a-(const uint8_t *)b; } @@ -5201,21 +5071,21 @@ ssize_t LuaConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_init_scripts) { // 'init_scripts': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -238; + return -237; *a++ = 0xa; n = encode_bytes(x,a,e); if (n < 0) - return -239; + return -238; a += n; } for (const auto &x : m_compile_files) { // 'compile_files': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -240; + return -239; *a++ = 0x12; n = encode_bytes(x,a,e); if (n < 0) - return -241; + return -240; a += n; } assert(a <= e); @@ -5331,16 +5201,16 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+13,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+13))) - return -242; + return -241; if (m_init_scripts.size() <= x) - return -243; + return -242; if ((idxe[1] == 0) && (value == 0)) { m_init_scripts.erase(m_init_scripts.begin()+x); return 0; } } if (idxe[1] != 0) - return -244; + return -243; m_init_scripts[x] = value; return m_init_scripts[x].size(); } @@ -5361,70 +5231,24 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+14,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+14))) - return -245; + return -244; if (m_compile_files.size() <= x) - return -246; + return -245; if ((idxe[1] == 0) && (value == 0)) { m_compile_files.erase(m_compile_files.begin()+x); return 0; } } if (idxe[1] != 0) - return -247; + return -246; m_compile_files[x] = value; return m_compile_files[x].size(); } } - return -248; + return -247; } NodeConfig::NodeConfig() -: m_magic(0) -, m_nodename() -, m_pass_hash() -, m_cpu_freq(0) -, m_syslog_host() -, m_sntp_server() -, m_timezone() -#ifdef CONFIG_MQTT -#endif // CONFIG_MQTT -, m_dmesg_size(2048) -#ifdef CONFIG_INFLUX -#endif // CONFIG_INFLUX -, m_station2ap_time(0) -, m_domainname() -, m_actions_enable(1) -#ifdef CONFIG_TERMSERV -#endif // CONFIG_TERMSERV -, m_udp_ctrl_port(12719) -#ifdef CONFIG_FTP -#endif // CONFIG_FTP -#ifdef CONFIG_HTTP -#endif // CONFIG_HTTP -, m_otasrv() -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member signals -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member functions -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_STATEMACHINES -#endif // CONFIG_STATEMACHINES -, m_max_on_time(0) -, m_threshold_off(0) -, m_threshold_on(0) -, m_dim_step(0) -, m_lightctrl(0) -, m_pwm_freq(0) -#ifdef CONFIG_APP_PARAMS -#endif // CONFIG_APP_PARAMS -#ifdef CONFIG_THRESHOLDS -#endif // CONFIG_THRESHOLDS -#ifdef CONFIG_LUA -#endif // CONFIG_LUA -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -, p_validbits(0) { } @@ -5716,7 +5540,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) union decode_union ud; ssize_t x = decode_early(a,e,&ud,&fid); if (x < 0) - return -249; + return -248; a += x; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit @@ -5724,17 +5548,16 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) break; case 0xa: // nodename id 1, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -250; + return -249; } m_nodename.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x12: // pass_hash id 2, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -251; + return -250; } m_pass_hash.assign((const char*)a,ud.vi); - p_validbits |= ((uint32_t)1U << 1); a += ud.vi; break; case 0x18: // cpu_freq id 3, type uint32_t, coding varint @@ -5745,45 +5568,45 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_station.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -252; + return -251; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); break; case 0x2a: // softap id 5, type WifiConfig, coding byte[] if (((ssize_t)ud.vi > 0) && ((ssize_t)ud.vi <= (e-a))) { int n; n = m_softap.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -253; + return -252; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); break; case 0x32: // dns_server id 6, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -254; + return -253; } m_dns_server.emplace_back((const char*)a,ud.vi); a += ud.vi; break; case 0x3a: // syslog_host id 7, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -255; + return -254; } m_syslog_host.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x42: // sntp_server id 8, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -256; + return -255; } m_sntp_server.assign((const char*)a,ud.vi); a += ud.vi; break; case 0x4a: // timezone id 9, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -257; + return -256; } m_timezone.assign((const char*)a,ud.vi); a += ud.vi; @@ -5794,10 +5617,10 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_mqtt.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -258; + return -257; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); break; #endif // CONFIG_MQTT case 0x5c: // dmesg_size id 11, type uint16_t, coding 16bit @@ -5809,10 +5632,10 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_influx.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -259; + return -258; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); break; #endif // CONFIG_INFLUX case 0x68: // station2ap_time id 13, type uint32_t, coding varint @@ -5820,7 +5643,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) break; case 0x7a: // domainname id 15, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -260; + return -259; } m_domainname.assign((const char*)a,ud.vi); a += ud.vi; @@ -5831,7 +5654,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_holidays.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -261; + return -260; a += ud.vi; } break; @@ -5841,7 +5664,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_at_actions.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -262; + return -261; a += ud.vi; } break; @@ -5854,7 +5677,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_triggers.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -263; + return -262; a += ud.vi; } break; @@ -5864,7 +5687,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_uart.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -264; + return -263; a += ud.vi; } break; @@ -5875,7 +5698,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_terminal.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -265; + return -264; a += ud.vi; } break; @@ -5885,7 +5708,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) break; case 0xba: // debugs id 23, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -266; + return -265; } m_debugs.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -5896,10 +5719,10 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_ftpd.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -267; + return -266; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); break; #endif // CONFIG_FTP #ifdef CONFIG_HTTP @@ -5908,18 +5731,17 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_httpd.fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -268; + return -267; a += ud.vi; } - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); break; #endif // CONFIG_HTTP case 0xd2: // otasrv id 26, type estring, coding byte[] if ((ssize_t)ud.vi > e-a) { - return -269; + return -268; } 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[] @@ -5928,7 +5750,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) int n; n = m_timefuses.back().fromMemory((const uint8_t*)a,ud.vi); if (n != (ssize_t)ud.vi) - return -270; + return -269; a += ud.vi; } break; @@ -5939,7 +5761,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 -271; + return -270; a += ud.vi; } break; @@ -5969,7 +5791,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 -272; + return -271; a += ud.vi; } break; @@ -5981,7 +5803,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 -273; + return -272; a += ud.vi; } break; @@ -5989,7 +5811,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 -274; + return -273; } m_luafiles.emplace_back((const char*)a,ud.vi); a += ud.vi; @@ -6002,7 +5824,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 -275; + return -274; a += ud.vi; } break; @@ -6012,13 +5834,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 -276; + return -275; } } } assert((a-(const uint8_t *)b) == s); if (a > e) - return -277; + return -276; return a-(const uint8_t *)b; } @@ -6031,10 +5853,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 -278; + return -277; *a++ = 0x5; if ((e-a) < 4) - return -279; + return -278; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -6042,61 +5864,61 @@ 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 -280; + return -279; *a++ = 0xa; n = encode_bytes(m_nodename,a,e); if (n < 0) - return -281; + return -280; a += n; } // has pass_hash? - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -282; + return -281; *a++ = 0x12; n = encode_bytes(m_pass_hash,a,e); if (n < 0) - return -283; + return -282; a += n; } // has cpu_freq? - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -284; + return -283; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -285; + return -284; a += n; } // has station? - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -286; + return -285; *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 -287; + return -286; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); } // has softap? - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -288; + return -287; *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 -289; + return -288; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -6104,122 +5926,122 @@ 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 -290; + return -289; *a++ = 0x32; n = encode_bytes(x,a,e); if (n < 0) - return -291; + return -290; a += n; } // has syslog_host? if (!m_syslog_host.empty()) { // 'syslog_host': id=7, encoding=lenpfx, tag=0x3a if (a >= e) - return -292; + return -291; *a++ = 0x3a; n = encode_bytes(m_syslog_host,a,e); if (n < 0) - return -293; + return -292; a += n; } // has sntp_server? if (!m_sntp_server.empty()) { // 'sntp_server': id=8, encoding=lenpfx, tag=0x42 if (a >= e) - return -294; + return -293; *a++ = 0x42; n = encode_bytes(m_sntp_server,a,e); if (n < 0) - return -295; + return -294; a += n; } // has timezone? if (!m_timezone.empty()) { // 'timezone': id=9, encoding=lenpfx, tag=0x4a if (a >= e) - return -296; + return -295; *a++ = 0x4a; n = encode_bytes(m_timezone,a,e); if (n < 0) - return -297; + return -296; a += n; } #ifdef CONFIG_MQTT // has mqtt? - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -298; + return -297; *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 -299; + return -298; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); } #endif // CONFIG_MQTT // has dmesg_size? - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -300; + return -299; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; } #ifdef CONFIG_INFLUX // has influx? - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -301; + return -300; *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 -302; + return -301; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); } #endif // CONFIG_INFLUX // has station2ap_time? - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -303; + return -302; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -304; + return -303; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -305; + return -304; *a++ = 0x7a; n = encode_bytes(m_domainname,a,e); if (n < 0) - return -306; + return -305; a += n; } for (const auto &x : m_holidays) { // 'holidays': id=16, encoding=lenpfx, tag=0x82 if (2 > (e-a)) - return -307; + return -306; *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 -308; + return -307; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -6227,41 +6049,41 @@ 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 -309; + return -308; *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 -310; + return -309; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); } // has actions_enable? - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -311; + return -310; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -312; + return -311; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -313; + return -312; *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 -314; + return -313; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -6269,14 +6091,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 -315; + return -314; *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 -316; + return -315; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -6285,24 +6107,24 @@ 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 -317; + return -316; *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 -318; + return -317; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); } #endif // CONFIG_TERMSERV // has udp_ctrl_port? - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -319; + return -318; a += write_varint(a,e-a,0xb4); // 'udp_ctrl_port': id=22 write_u16(a,m_udp_ctrl_port); a += 2; @@ -6310,27 +6132,27 @@ 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 -320; + return -319; *a++ = 0xba; *a++ = 0x1; n = encode_bytes(x,a,e); if (n < 0) - return -321; + return -320; a += n; } #ifdef CONFIG_FTP // has ftpd? - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -322; + return -321; *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 -323; + return -322; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -6338,45 +6160,45 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_FTP #ifdef CONFIG_HTTP // has httpd? - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -324; + return -323; *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 -325; + return -324; 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))) { + if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 if (2 > (e-a)) - return -326; + return -325; *a++ = 0xd2; *a++ = 0x1; n = encode_bytes(m_otasrv,a,e); if (n < 0) - return -327; + return -326; a += n; } for (const auto &x : m_timefuses) { // 'timefuses': id=30, encoding=lenpfx, tag=0xf2 if (2 > (e-a)) - return -328; + return -327; *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 -329; + return -328; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -6391,88 +6213,66 @@ 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 -330; + return -329; *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 -331; + return -330; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. - // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { - // 'threshold_off': id=35, encoding=varint, tag=0x118 - if (2 > (e-a)) - return -332; - *a++ = 0x98; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_off); - if (n <= 0) - return -333; - a += n; - } - // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { - // 'threshold_on': id=36, encoding=varint, tag=0x120 - if (2 > (e-a)) - return -334; - *a++ = 0xa0; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_on); - if (n <= 0) - return -335; - a += n; - } + // 'threshold_off' is deprecated. Therefore no data will be written. + // 'threshold_on' is deprecated. Therefore no data will be written. // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -336; + return -331; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -337; + return -332; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -338; + return -333; a += write_varint(a,e-a,0x133); // 'lightctrl': id=38 *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -339; + return -334; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -340; + return -335; 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 -341; + return -336; *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 -342; + return -337; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -6482,14 +6282,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 -343; + return -338; *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 -344; + return -339; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -6499,12 +6299,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 -345; + return -340; *a++ = 0xd2; *a++ = 0x2; n = encode_bytes(x,a,e); if (n < 0) - return -346; + return -341; a += n; } #endif // CONFIG_LUA @@ -6512,14 +6312,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 -347; + return -342; *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 -348; + return -343; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -7075,14 +6875,8 @@ size_t NodeConfig::calcSize() const } #endif // CONFIG_STATEMACHINES // deprecated optional unsigned max_on_time, id 34 - // optional unsigned threshold_off, id 35 - if (has_threshold_off()) { - r += wiresize((varint_t)m_threshold_off) + 2 /* tag(threshold_off) 0x118 */; - } - // optional unsigned threshold_on, id 36 - if (has_threshold_on()) { - r += wiresize((varint_t)m_threshold_on) + 2 /* tag(threshold_on) 0x120 */; - } + // deprecated optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_on, id 36 // optional unsigned dim_step, id 37 if (has_dim_step()) { r += wiresize((varint_t)m_dim_step) + 2 /* tag(dim_step) 0x128 */; @@ -7280,8 +7074,6 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_pass_hash,value); - if (r > 0) - p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == strcmp(name,"cpu_freq")) { @@ -7291,7 +7083,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_cpu_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == memcmp(name,"station",7)) { @@ -7299,7 +7091,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_station(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); return m_station.setByName(name+8,value); } } @@ -7308,7 +7100,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_softap(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); return m_softap.setByName(name+7,value); } } @@ -7328,16 +7120,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -349; + return -344; if (m_dns_server.size() <= x) - return -350; + return -345; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -351; + return -346; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -7375,7 +7167,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_mqtt(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); return m_mqtt.setByName(name+5,value); } } @@ -7387,7 +7179,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_dmesg_size,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); return r; } #ifdef CONFIG_INFLUX @@ -7396,7 +7188,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_influx(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); return m_influx.setByName(name+7,value); } } @@ -7408,7 +7200,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_station2ap_time,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); return r; } if (0 == strcmp(name,"domainname")) { @@ -7436,16 +7228,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -352; + return -347; if (m_holidays.size() <= x) - return -353; + return -348; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -354; + return -349; return m_holidays[x].setByName(idxe+2,value); } } @@ -7465,16 +7257,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -355; + return -350; if (m_at_actions.size() <= x) - return -356; + return -351; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -357; + return -352; return m_at_actions[x].setByName(idxe+2,value); } } @@ -7485,7 +7277,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u32(&m_actions_enable,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); return r; } if (0 == memcmp(name,"triggers",8)) { @@ -7504,16 +7296,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -358; + return -353; if (m_triggers.size() <= x) - return -359; + return -354; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -360; + return -355; return m_triggers[x].setByName(idxe+2,value); } } @@ -7533,16 +7325,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+5,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+5))) - return -361; + return -356; if (m_uart.size() <= x) - return -362; + return -357; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -363; + return -358; return m_uart[x].setByName(idxe+2,value); } } @@ -7563,16 +7355,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -364; + return -359; if (m_terminal.size() <= x) - return -365; + return -360; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -366; + return -361; return m_terminal[x].setByName(idxe+2,value); } } @@ -7584,7 +7376,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_udp_ctrl_port,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); return r; } if (0 == memcmp(name,"debugs",6)) { @@ -7603,16 +7395,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -367; + return -362; if (m_debugs.size() <= x) - return -368; + return -363; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -369; + return -364; m_debugs[x] = value; return m_debugs[x].size(); } @@ -7623,7 +7415,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_ftpd(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); return m_ftpd.setByName(name+5,value); } } @@ -7634,7 +7426,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_httpd(); return 0; } else if (name[5] == '.') { - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); return m_httpd.setByName(name+6,value); } } @@ -7646,8 +7438,6 @@ int NodeConfig::setByName(const char *name, const char *value) } 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)) { @@ -7666,16 +7456,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -370; + return -365; if (m_timefuses.size() <= x) - return -371; + return -366; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -372; + return -367; return m_timefuses[x].setByName(idxe+2,value); } } @@ -7696,16 +7486,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -373; + return -368; if (m_statemachs.size() <= x) - return -374; + return -369; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -375; + return -370; return m_statemachs[x].setByName(idxe+2,value); } } @@ -7725,7 +7515,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 << 14); + p_validbits |= ((uint32_t)1U << 12); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -7735,7 +7525,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 << 15); + p_validbits |= ((uint32_t)1U << 13); return r; } if (0 == strcmp(name,"dim_step")) { @@ -7745,7 +7535,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 << 16); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -7755,7 +7545,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 << 17); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -7765,7 +7555,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 << 18); + p_validbits |= ((uint32_t)1U << 16); return r; } #ifdef CONFIG_APP_PARAMS @@ -7785,16 +7575,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -376; + return -371; if (m_app_params.size() <= x) - return -377; + return -372; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -378; + return -373; return m_app_params[x].setByName(idxe+2,value); } } @@ -7816,16 +7606,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -379; + return -374; if (m_thresholds.size() <= x) - return -380; + return -375; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -381; + return -376; return m_thresholds[x].setByName(idxe+2,value); } } @@ -7847,16 +7637,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -382; + return -377; if (m_luafiles.size() <= x) - return -383; + return -378; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -384; + return -379; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -7879,20 +7669,20 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -385; + return -380; if (m_owdevices.size() <= x) - return -386; + return -381; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -387; + return -382; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -388; + return -383; } diff --git a/components/wfc/swcfg_esp8285.h b/components/wfc/swcfg_esp8285.h index e6f91fa..fe9f2c0 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -49,6 +49,7 @@ * varintbits : 32 * * options from common: + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -75,7 +76,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * toJSON : "toJSON" * toMemory : "toMemory" * UnknownField : "skip" @@ -217,11 +217,12 @@ size_t parse_ascii_sigtype_t(sigtype_t *, const char *); typedef uint16_t uartcfg_t; typedef uint8_t eventcfg_t; + + class WifiConfig { public: WifiConfig(); - bool operator == (const WifiConfig &r) const; //! Function for resetting all members to their default values. @@ -429,25 +430,26 @@ class WifiConfig estring m_pass; //! bytes mac, id 3 estring m_mac; - //! bool activate, id 4 - bool m_activate; //! fixed32 addr4, id 5 - uint32_t m_addr4; - //! fixed8 netmask4, id 6 - uint8_t m_netmask4; + uint32_t m_addr4 = 0; //! fixed32 gateway4, id 7 - uint32_t m_gateway4; + uint32_t m_gateway4 = 0; + //! bool activate, id 4 + bool m_activate = false; + //! fixed8 netmask4, id 6 + uint8_t m_netmask4 = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class MQTT { public: MQTT(); - bool operator == (const MQTT &r) const; //! Function for resetting all members to their default values. @@ -628,49 +630,28 @@ class MQTT //! Function to get mutable access to all elements of subscribtions. std::vector *mutable_subscribtions(); - // optional uint16 keepalive, id 6 - /*! - * Function for querying if keepalive has been set. - * @return true if keepalive is set. - */ - bool has_keepalive() const; - //! Function to reset keepalive to its default/unset value. - void clear_keepalive(); - //! Get value of keepalive. - uint16_t keepalive() const; - //! Set keepalive using a constant reference - void set_keepalive(uint16_t v); - /*! - * Provide mutable access to keepalive. - * @return pointer to member variable of keepalive. - */ - uint16_t *mutable_keepalive(); - + // unused optional uint16 keepalive, id 6 protected: //! string uri, id 1 estring m_uri; - //! bool enable, id 2 - bool m_enable; //! string username, id 3 estring m_username; //! string password, id 4 estring m_password; //! string subscribtions, id 5 std::vector m_subscribtions; - //! uint16 keepalive, id 6 - uint16_t m_keepalive; - - private: - uint8_t p_validbits; + //! bool enable, id 2 + bool m_enable = false; }; + + class Date { public: Date(); - bool operator == (const Date &r) const; //! Function for resetting all members to their default values. @@ -839,26 +820,27 @@ class Date protected: + //! fixed16 year, id 3 + uint16_t m_year = 0; //! fixed8 day, id 1 - uint8_t m_day; + uint8_t m_day = 0; //! fixed8 month, id 2 - uint8_t m_month; - //! fixed16 year, id 3 - uint16_t m_year; + uint8_t m_month = 0; //! fixed8 endday, id 4 - uint8_t m_endday; + uint8_t m_endday = 0; //! fixed8 endmonth, id 5 - uint8_t m_endmonth; + uint8_t m_endmonth = 0; //! fixed8 endyear, id 6 - uint8_t m_endyear; + uint8_t m_endyear = 0; }; + + class AtAction { public: AtAction(); - bool operator == (const AtAction &r) const; //! Function for resetting all members to their default values. @@ -992,25 +974,26 @@ class AtAction protected: - //! WeekDay day, id 1 - WeekDay m_day; - //! unsigned min_of_day, id 2 - uint32_t m_min_of_day; //! string action, id 3 estring m_action; + //! WeekDay day, id 1 + WeekDay m_day = Sunday; + //! unsigned min_of_day, id 2 + uint32_t m_min_of_day = 0; //! bool enable, id 4 - bool m_enable; + bool m_enable = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Influx { public: Influx(); - bool operator == (const Influx &r) const; //! Function for resetting all members to their default values. @@ -1170,21 +1153,21 @@ class Influx protected: //! string hostname, id 1 estring m_hostname; - //! fixed16 port, id 2 - uint16_t m_port; //! string measurement, id 3 estring m_measurement; - // omitted obsolete member interval //! string database, id 5 estring m_database; + //! fixed16 port, id 2 + uint16_t m_port = 0; }; + + class UartSettings { public: UartSettings(); - bool operator == (const UartSettings &r) const; //! Function for resetting all members to their default values. @@ -1377,29 +1360,30 @@ class UartSettings protected: - //! uint8 port, id 1 - uint8_t m_port; //! unsigned baudrate, id 2 - uint32_t m_baudrate; - //! uartcfg_t config, id 3 - uartcfg_t m_config; - //! fixed8 rx_thresh, id 4 - uint8_t m_rx_thresh; + uint32_t m_baudrate = 0; //! unsigned tx_bufsize, id 6 - uint32_t m_tx_bufsize; + uint32_t m_tx_bufsize = 0; //! unsigned rx_bufsize, id 7 - uint32_t m_rx_bufsize; + uint32_t m_rx_bufsize = 0; + //! uartcfg_t config, id 3 + uartcfg_t m_config = 5; + //! uint8 port, id 1 + uint8_t m_port = 0; + //! fixed8 rx_thresh, id 4 + uint8_t m_rx_thresh = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FtpHttpConfig { public: FtpHttpConfig(); - bool operator == (const FtpHttpConfig &r) const; //! Function for resetting all members to their default values. @@ -1548,25 +1532,26 @@ class FtpHttpConfig protected: - //! fixed16 port, id 1 - uint16_t m_port; - //! bool start, id 2 - bool m_start; //! string root, id 3 estring m_root; //! string uploaddir, id 4 estring m_uploaddir; + //! fixed16 port, id 1 + uint16_t m_port = 0; + //! bool start, id 2 + bool m_start = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TerminalConfig { public: TerminalConfig(); - bool operator == (const TerminalConfig &r) const; //! Function for resetting all members to their default values. @@ -1689,23 +1674,21 @@ class TerminalConfig protected: - //! sint8 uart_rx, id 1 - int8_t m_uart_rx; - //! sint8 uart_tx, id 2 - int8_t m_uart_tx; //! string name, id 3 estring m_name; - - private: - uint8_t p_validbits; + //! sint8 uart_rx, id 1 + int8_t m_uart_rx = -1; + //! sint8 uart_tx, id 2 + int8_t m_uart_tx = -1; }; + + class Trigger { public: Trigger(); - bool operator == (const Trigger &r) const; //! Function for resetting all members to their default values. @@ -1822,17 +1805,15 @@ class Trigger estring m_event; //! string action, id 2 std::vector m_action; - - private: - uint8_t p_validbits; }; + + class AppParam { public: AppParam(); - bool operator == (const AppParam &r) const; //! Function for resetting all members to their default values. @@ -2001,25 +1982,26 @@ class AppParam protected: //! string key, id 1 estring m_key; - //! unsigned uValue, id 2 - uint32_t m_uValue; //! string sValue, id 3 estring m_sValue; - //! signed dValue, id 4 - int32_t m_dValue; //! double fValue, id 5 - double m_fValue; + double m_fValue = 0; + //! unsigned uValue, id 2 + uint32_t m_uValue = 0; + //! signed dValue, id 4 + int32_t m_dValue = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class EventTimer { public: EventTimer(); - bool operator == (const EventTimer &r) const; //! Function for resetting all members to their default values. @@ -2153,20 +2135,21 @@ class EventTimer //! string name, id 1 estring m_name; //! unsigned time, id 2 - uint32_t m_time; + uint32_t m_time = 0; //! eventcfg_t config, id 3 - eventcfg_t m_config; + eventcfg_t m_config = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FunctionConfig { public: FunctionConfig(); - bool operator == (const FunctionConfig &r) const; //! Function for resetting all members to their default values. @@ -2311,17 +2294,15 @@ class FunctionConfig estring m_func; //! string params, id 3 std::vector m_params; - - private: - uint8_t p_validbits; }; + + class SignalConfig { public: SignalConfig(); - bool operator == (const SignalConfig &r) const; //! Function for resetting all members to their default values. @@ -2454,18 +2435,19 @@ class SignalConfig protected: //! string name, id 1 estring m_name; - //! sigtype_t type, id 2 - sigtype_t m_type; //! string iv, id 3 estring m_iv; + //! sigtype_t type, id 2 + sigtype_t m_type = st_invalid; }; + + class OwDeviceConfig { public: OwDeviceConfig(); - bool operator == (const OwDeviceConfig &r) const; //! Function for resetting all members to their default values. @@ -2570,21 +2552,22 @@ class OwDeviceConfig protected: - //! fixed64 id, id 1 - uint64_t m_id; //! string name, id 2 estring m_name; + //! fixed64 id, id 1 + uint64_t m_id = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class StateConfig { public: StateConfig(); - bool operator == (const StateConfig &r) const; //! Function for resetting all members to their default values. @@ -2699,17 +2682,15 @@ class StateConfig estring m_name; //! Trigger conds, id 2 std::vector m_conds; - - private: - uint8_t p_validbits; }; + + class StateMachineConfig { public: StateMachineConfig(); - bool operator == (const StateMachineConfig &r) const; //! Function for resetting all members to their default values. @@ -2836,25 +2817,46 @@ class StateMachineConfig //! Function to get mutable access to all elements of states. std::vector *mutable_states(); + // optional bool persistent, id 4 + /*! + * Function for querying if persistent has been set. + * @return true if persistent is set. + */ + bool has_persistent() const; + //! Function to reset persistent to its default/unset value. + void clear_persistent(); + //! Get value of persistent. + bool persistent() const; + //! Set persistent using a constant reference + void set_persistent(bool v); + /*! + * Provide mutable access to persistent. + * @return pointer to member variable of persistent. + */ + bool *mutable_persistent(); + protected: //! string name, id 1 estring m_name; //! uint8 ini_st, id 2 - uint8_t m_ini_st; + uint8_t m_ini_st = 0; + //! bool persistent, id 4 + bool m_persistent = false; //! StateConfig states, id 3 std::vector m_states; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ThresholdConfig { public: ThresholdConfig(); - bool operator == (const ThresholdConfig &r) const; //! Function for resetting all members to their default values. @@ -2980,20 +2982,21 @@ class ThresholdConfig //! string name, id 1 estring m_name; //! float low, id 2 - float m_low; + float m_low = 0; //! float high, id 3 - float m_high; + float m_high = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class LuaConfig { public: LuaConfig(); - bool operator == (const LuaConfig &r) const; //! Function for resetting all members to their default values. @@ -3113,11 +3116,12 @@ class LuaConfig }; + + class NodeConfig { public: NodeConfig(); - bool operator == (const NodeConfig &r) const; //! Function for resetting all members to their default values. @@ -3857,7 +3861,7 @@ class NodeConfig //! Get value of max_on_time. uint32_t max_on_time() const __attribute__ ((deprecated)); - // optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_off, id 35 /*! * Function for querying if threshold_off has been set. * @return true if threshold_off is set. @@ -3866,16 +3870,9 @@ class NodeConfig //! Function to reset threshold_off to its default/unset value. void clear_threshold_off(); //! Get value of threshold_off. - uint32_t threshold_off() const; - //! Set threshold_off using a constant reference - void set_threshold_off(uint32_t v); - /*! - * Provide mutable access to threshold_off. - * @return pointer to member variable of threshold_off. - */ - uint32_t *mutable_threshold_off(); + uint32_t threshold_off() const __attribute__ ((deprecated)); - // optional unsigned threshold_on, id 36 + // deprecated optional unsigned threshold_on, id 36 /*! * Function for querying if threshold_on has been set. * @return true if threshold_on is set. @@ -3884,14 +3881,7 @@ class NodeConfig //! Function to reset threshold_on to its default/unset value. void clear_threshold_on(); //! Get value of threshold_on. - uint32_t threshold_on() const; - //! Set threshold_on using a constant reference - void set_threshold_on(uint32_t v); - /*! - * Provide mutable access to threshold_on. - * @return pointer to member variable of threshold_on. - */ - uint32_t *mutable_threshold_on(); + uint32_t threshold_on() const __attribute__ ((deprecated)); // optional unsigned dim_step, id 37 /*! @@ -4058,18 +4048,22 @@ class NodeConfig // deprecated unsigned max_on_time, id 34 //! Set max_on_time using a constant reference void set_max_on_time(uint32_t v); - //! fixed32 magic, id 0 - uint32_t m_magic; + // deprecated unsigned threshold_off, id 35 + //! Set threshold_off using a constant reference + void set_threshold_off(uint32_t v); + // deprecated unsigned threshold_on, id 36 + //! Set threshold_on using a constant reference + void set_threshold_on(uint32_t v); //! string nodename, id 1 estring m_nodename; //! bytes pass_hash, id 2 estring m_pass_hash; - //! unsigned cpu_freq, id 3 - uint32_t m_cpu_freq; - //! WifiConfig station, id 4 - WifiConfig m_station; - //! WifiConfig softap, id 5 - WifiConfig m_softap; + //! string otasrv, id 26 + estring m_otasrv; + #ifdef CONFIG_LUA + //! string luafiles, id 42 + std::vector m_luafiles; + #endif // CONFIG_LUA //! string dns_server, id 6 std::vector m_dns_server; //! string syslog_host, id 7 @@ -4078,72 +4072,38 @@ class NodeConfig estring m_sntp_server; //! string timezone, id 9 estring m_timezone; - #ifdef CONFIG_MQTT - //! MQTT mqtt, id 10 - MQTT m_mqtt; - #endif // CONFIG_MQTT - //! fixed16 dmesg_size, id 11 - uint16_t m_dmesg_size; - #ifdef CONFIG_INFLUX - //! Influx influx, id 12 - Influx m_influx; - #endif // CONFIG_INFLUX - //! unsigned station2ap_time, id 13 - uint32_t m_station2ap_time; - //! string domainname, id 15 - estring m_domainname; - //! Date holidays, id 16 - std::vector m_holidays; - //! AtAction at_actions, id 17 - std::vector m_at_actions; - //! unsigned actions_enable, id 18 - uint32_t m_actions_enable; - //! Trigger triggers, id 19 - std::vector m_triggers; - //! UartSettings uart, id 20 - std::vector m_uart; - #ifdef CONFIG_TERMSERV - //! TerminalConfig terminal, id 21 - std::vector m_terminal; - #endif // CONFIG_TERMSERV - //! fixed16 udp_ctrl_port, id 22 - uint16_t m_udp_ctrl_port; //! string debugs, id 23 std::vector m_debugs; - #ifdef CONFIG_FTP - //! FtpHttpConfig ftpd, id 24 - FtpHttpConfig m_ftpd; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP - //! 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 - // omitted obsolete member signals - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - // omitted obsolete member functions - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - //! StateMachineConfig statemachs, id 33 - std::vector m_statemachs; - #endif // CONFIG_STATEMACHINES + //! string domainname, id 15 + estring m_domainname; + //! unsigned station2ap_time, id 13 + uint32_t m_station2ap_time = 0; //! unsigned max_on_time, id 34 - uint32_t m_max_on_time; + uint32_t m_max_on_time = 0; //! unsigned threshold_off, id 35 - uint32_t m_threshold_off; + uint32_t m_threshold_off = 0; //! unsigned threshold_on, id 36 - uint32_t m_threshold_on; + uint32_t m_threshold_on = 0; //! unsigned dim_step, id 37 - uint32_t m_dim_step; - //! bool lightctrl, id 38 - bool m_lightctrl; + uint32_t m_dim_step = 0; + //! unsigned actions_enable, id 18 + uint32_t m_actions_enable = 1; //! unsigned pwm_freq, id 39 - uint32_t m_pwm_freq; + uint32_t m_pwm_freq = 0; + //! fixed32 magic, id 0 + uint32_t m_magic = 0; + //! unsigned cpu_freq, id 3 + uint32_t m_cpu_freq = 0; + //! fixed16 dmesg_size, id 11 + uint16_t m_dmesg_size = 2048; + //! fixed16 udp_ctrl_port, id 22 + uint16_t m_udp_ctrl_port = 12719; + //! bool lightctrl, id 38 + bool m_lightctrl = 0; + #ifdef CONFIG_ONEWIRE + //! OwDeviceConfig owdevices, id 50 + std::vector m_owdevices; + #endif // CONFIG_ONEWIRE #ifdef CONFIG_APP_PARAMS //! AppParam app_params, id 40 std::vector m_app_params; @@ -4152,17 +4112,47 @@ class NodeConfig //! ThresholdConfig thresholds, id 41 std::vector m_thresholds; #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA - //! string luafiles, id 42 - std::vector m_luafiles; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE - //! OwDeviceConfig owdevices, id 50 - std::vector m_owdevices; - #endif // CONFIG_ONEWIRE + #ifdef CONFIG_STATEMACHINES + //! StateMachineConfig statemachs, id 33 + std::vector m_statemachs; + #endif // CONFIG_STATEMACHINES + //! EventTimer timefuses, id 30 + std::vector m_timefuses; + #ifdef CONFIG_HTTP + //! FtpHttpConfig httpd, id 25 + FtpHttpConfig m_httpd; + #endif // CONFIG_HTTP + #ifdef CONFIG_FTP + //! FtpHttpConfig ftpd, id 24 + FtpHttpConfig m_ftpd; + #endif // CONFIG_FTP + #ifdef CONFIG_TERMSERV + //! TerminalConfig terminal, id 21 + std::vector m_terminal; + #endif // CONFIG_TERMSERV + //! UartSettings uart, id 20 + std::vector m_uart; + //! Trigger triggers, id 19 + std::vector m_triggers; + //! AtAction at_actions, id 17 + std::vector m_at_actions; + //! Date holidays, id 16 + std::vector m_holidays; + #ifdef CONFIG_INFLUX + //! Influx influx, id 12 + Influx m_influx; + #endif // CONFIG_INFLUX + #ifdef CONFIG_MQTT + //! MQTT mqtt, id 10 + MQTT m_mqtt; + #endif // CONFIG_MQTT + //! WifiConfig softap, id 5 + WifiConfig m_softap; + //! WifiConfig station, id 4 + WifiConfig m_station; private: - uint32_t p_validbits; + uint32_t p_validbits = 0; }; @@ -4267,7 +4257,7 @@ inline const estring &WifiConfig::mac() const inline bool WifiConfig::has_mac() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_mac.empty(); } /*! @@ -4276,29 +4266,22 @@ inline bool WifiConfig::has_mac() const */ inline void WifiConfig::clear_mac() { - p_validbits &= ~((uint8_t)1U << 0); m_mac.clear(); } inline estring *WifiConfig::mutable_mac() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_mac.clear(); - } return &m_mac; } inline void WifiConfig::set_mac(const void *data, size_t s) { m_mac.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void WifiConfig::set_mac(const estring &v) { m_mac = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -4327,7 +4310,7 @@ inline uint32_t WifiConfig::addr4() const inline bool WifiConfig::has_addr4() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -4336,14 +4319,14 @@ inline bool WifiConfig::has_addr4() const */ inline void WifiConfig::clear_addr4() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_addr4 = 0; } inline uint32_t *WifiConfig::mutable_addr4() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_addr4 = 0; } return &m_addr4; @@ -4352,7 +4335,7 @@ inline uint32_t *WifiConfig::mutable_addr4() inline void WifiConfig::set_addr4(uint32_t v) { m_addr4 = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -4364,7 +4347,7 @@ inline uint8_t WifiConfig::netmask4() const inline bool WifiConfig::has_netmask4() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -4373,14 +4356,14 @@ inline bool WifiConfig::has_netmask4() const */ inline void WifiConfig::clear_netmask4() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_netmask4 = 0; } inline uint8_t *WifiConfig::mutable_netmask4() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_netmask4 = 0; } return &m_netmask4; @@ -4389,7 +4372,7 @@ inline uint8_t *WifiConfig::mutable_netmask4() inline void WifiConfig::set_netmask4(uint8_t v) { m_netmask4 = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -4401,7 +4384,7 @@ inline uint32_t WifiConfig::gateway4() const inline bool WifiConfig::has_gateway4() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -4410,14 +4393,14 @@ inline bool WifiConfig::has_gateway4() const */ inline void WifiConfig::clear_gateway4() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 2); m_gateway4 = 0; } inline uint32_t *WifiConfig::mutable_gateway4() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_gateway4 = 0; } return &m_gateway4; @@ -4426,7 +4409,7 @@ inline uint32_t *WifiConfig::mutable_gateway4() inline void WifiConfig::set_gateway4(uint32_t v) { m_gateway4 = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); } @@ -4438,7 +4421,7 @@ inline size_t MQTT::getMaxSize() // optional string username, id 3 has unlimited size // optional string password, id 4 has unlimited size // repeated string subscribtions, id 5 has unlimited size - // optional uint16 keepalive, id 6 has maximum size 4 + // unused optional uint16 keepalive, id 6 return SIZE_MAX; } @@ -4650,43 +4633,6 @@ inline size_t MQTT::subscribtions_size() const -inline uint16_t MQTT::keepalive() const -{ - return m_keepalive; -} - -inline bool MQTT::has_keepalive() const -{ - return 0 != (p_validbits & ((uint8_t)1U << 0)); -} - -/*! - * Function for clearing the associated member variable. - * It will reset the value to the default value. - */ -inline void MQTT::clear_keepalive() -{ - p_validbits &= ~((uint8_t)1U << 0); - m_keepalive = 60; -} - -inline uint16_t *MQTT::mutable_keepalive() -{ - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_keepalive = 60; - } - return &m_keepalive; -} - -inline void MQTT::set_keepalive(uint16_t v) -{ - m_keepalive = v; - p_validbits |= ((uint8_t)1U << 0); -} - - - inline size_t Date::getMaxSize() { // optional fixed8 day, id 1 has maximum size 2 @@ -4974,7 +4920,7 @@ inline const estring &AtAction::action() const inline bool AtAction::has_action() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_action.empty(); } /*! @@ -4983,35 +4929,27 @@ inline bool AtAction::has_action() const */ inline void AtAction::clear_action() { - p_validbits &= ~((uint8_t)1U << 2); m_action.clear(); } inline estring *AtAction::mutable_action() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_action.clear(); - } return &m_action; } inline void AtAction::set_action(const void *data, size_t s) { m_action.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const char *data) { m_action = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const estring &v) { m_action = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -5732,7 +5670,7 @@ inline const estring &TerminalConfig::name() const inline bool TerminalConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -5741,35 +5679,27 @@ inline bool TerminalConfig::has_name() const */ inline void TerminalConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *TerminalConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void TerminalConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5788,7 +5718,7 @@ inline const estring &Trigger::event() const inline bool Trigger::has_event() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_event.empty(); } /*! @@ -5797,35 +5727,27 @@ inline bool Trigger::has_event() const */ inline void Trigger::clear_event() { - p_validbits &= ~((uint8_t)1U << 0); m_event.clear(); } inline estring *Trigger::mutable_event() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_event.clear(); - } return &m_event; } inline void Trigger::set_event(const void *data, size_t s) { m_event.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const char *data) { m_event = data; - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const estring &v) { m_event = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5901,7 +5823,7 @@ inline const estring &AppParam::key() const inline bool AppParam::has_key() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_key.empty(); } /*! @@ -5910,35 +5832,27 @@ inline bool AppParam::has_key() const */ inline void AppParam::clear_key() { - p_validbits &= ~((uint8_t)1U << 0); m_key.clear(); } inline estring *AppParam::mutable_key() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_key.clear(); - } return &m_key; } inline void AppParam::set_key(const void *data, size_t s) { m_key.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const char *data) { m_key = data; - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const estring &v) { m_key = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -5950,7 +5864,7 @@ inline uint32_t AppParam::uValue() const inline bool AppParam::has_uValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -5959,14 +5873,14 @@ inline bool AppParam::has_uValue() const */ inline void AppParam::clear_uValue() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_uValue = 0; } inline uint32_t *AppParam::mutable_uValue() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_uValue = 0; } return &m_uValue; @@ -5975,7 +5889,7 @@ inline uint32_t *AppParam::mutable_uValue() inline void AppParam::set_uValue(uint32_t v) { m_uValue = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -5987,7 +5901,7 @@ inline const estring &AppParam::sValue() const inline bool AppParam::has_sValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_sValue.empty(); } /*! @@ -5996,35 +5910,27 @@ inline bool AppParam::has_sValue() const */ inline void AppParam::clear_sValue() { - p_validbits &= ~((uint8_t)1U << 2); m_sValue.clear(); } inline estring *AppParam::mutable_sValue() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_sValue.clear(); - } return &m_sValue; } inline void AppParam::set_sValue(const void *data, size_t s) { m_sValue.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const char *data) { m_sValue = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const estring &v) { m_sValue = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -6036,7 +5942,7 @@ inline int32_t AppParam::dValue() const inline bool AppParam::has_dValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -6045,14 +5951,14 @@ inline bool AppParam::has_dValue() const */ inline void AppParam::clear_dValue() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 1); m_dValue = 0; } inline int32_t *AppParam::mutable_dValue() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_dValue = 0; } return &m_dValue; @@ -6061,7 +5967,7 @@ inline int32_t *AppParam::mutable_dValue() inline void AppParam::set_dValue(int32_t v) { m_dValue = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); } @@ -6073,7 +5979,7 @@ inline double AppParam::fValue() const inline bool AppParam::has_fValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 4)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -6082,14 +5988,14 @@ inline bool AppParam::has_fValue() const */ inline void AppParam::clear_fValue() { - p_validbits &= ~((uint8_t)1U << 4); + p_validbits &= ~((uint8_t)1U << 2); m_fValue = 0; } inline double *AppParam::mutable_fValue() { - if (0 == (p_validbits & ((uint8_t)1U << 4))) { - p_validbits |= ((uint8_t)1U << 4); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_fValue = 0; } return &m_fValue; @@ -6098,7 +6004,7 @@ inline double *AppParam::mutable_fValue() inline void AppParam::set_fValue(double v) { m_fValue = v; - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); } @@ -6257,7 +6163,7 @@ inline const estring &FunctionConfig::name() const inline bool FunctionConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6266,35 +6172,27 @@ inline bool FunctionConfig::has_name() const */ inline void FunctionConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *FunctionConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void FunctionConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6306,7 +6204,7 @@ inline const estring &FunctionConfig::func() const inline bool FunctionConfig::has_func() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_func.empty(); } /*! @@ -6315,35 +6213,27 @@ inline bool FunctionConfig::has_func() const */ inline void FunctionConfig::clear_func() { - p_validbits &= ~((uint8_t)1U << 1); m_func.clear(); } inline estring *FunctionConfig::mutable_func() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_func.clear(); - } return &m_func; } inline void FunctionConfig::set_func(const void *data, size_t s) { m_func.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const char *data) { m_func = data; - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const estring &v) { m_func = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6574,7 +6464,7 @@ inline const estring &OwDeviceConfig::name() const inline bool OwDeviceConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_name.empty(); } /*! @@ -6583,35 +6473,27 @@ inline bool OwDeviceConfig::has_name() const */ inline void OwDeviceConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 1); m_name.clear(); } inline estring *OwDeviceConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_name.clear(); - } return &m_name; } inline void OwDeviceConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6630,7 +6512,7 @@ inline const estring &StateConfig::name() const inline bool StateConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6639,35 +6521,27 @@ inline bool StateConfig::has_name() const */ inline void StateConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *StateConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6727,6 +6601,7 @@ inline size_t StateMachineConfig::getMaxSize() // optional string name, id 1 has unlimited size // optional uint8 ini_st, id 2 has maximum size 3 // repeated StateConfig states, id 3 has unlimited size + // optional bool persistent, id 4 has maximum size 2 return SIZE_MAX; } @@ -6737,7 +6612,7 @@ inline const estring &StateMachineConfig::name() const inline bool StateMachineConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6746,35 +6621,27 @@ inline bool StateMachineConfig::has_name() const */ inline void StateMachineConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *StateMachineConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateMachineConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6786,7 +6653,7 @@ inline uint8_t StateMachineConfig::ini_st() const inline bool StateMachineConfig::has_ini_st() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6795,14 +6662,14 @@ inline bool StateMachineConfig::has_ini_st() const */ inline void StateMachineConfig::clear_ini_st() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_ini_st = 0; } inline uint8_t *StateMachineConfig::mutable_ini_st() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_ini_st = 0; } return &m_ini_st; @@ -6811,7 +6678,7 @@ inline uint8_t *StateMachineConfig::mutable_ini_st() inline void StateMachineConfig::set_ini_st(uint8_t v) { m_ini_st = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6866,6 +6733,37 @@ inline size_t StateMachineConfig::states_size() const +inline bool StateMachineConfig::persistent() const +{ + return m_persistent; +} + +inline bool StateMachineConfig::has_persistent() const +{ + return m_persistent != false; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void StateMachineConfig::clear_persistent() +{ + m_persistent = false; +} + +inline bool *StateMachineConfig::mutable_persistent() +{ + return &m_persistent; +} + +inline void StateMachineConfig::set_persistent(bool v) +{ + m_persistent = v; +} + + + inline size_t ThresholdConfig::getMaxSize() { // optional string name, id 1 has unlimited size @@ -6881,7 +6779,7 @@ inline const estring &ThresholdConfig::name() const inline bool ThresholdConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6890,35 +6788,27 @@ inline bool ThresholdConfig::has_name() const */ inline void ThresholdConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline estring *ThresholdConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void ThresholdConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const estring &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6930,7 +6820,7 @@ inline float ThresholdConfig::low() const inline bool ThresholdConfig::has_low() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6939,14 +6829,14 @@ inline bool ThresholdConfig::has_low() const */ inline void ThresholdConfig::clear_low() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_low = 0; } inline float *ThresholdConfig::mutable_low() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_low = 0; } return &m_low; @@ -6955,7 +6845,7 @@ inline float *ThresholdConfig::mutable_low() inline void ThresholdConfig::set_low(float v) { m_low = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6967,7 +6857,7 @@ inline float ThresholdConfig::high() const inline bool ThresholdConfig::has_high() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -6976,14 +6866,14 @@ inline bool ThresholdConfig::has_high() const */ inline void ThresholdConfig::clear_high() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_high = 0; } inline float *ThresholdConfig::mutable_high() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_high = 0; } return &m_high; @@ -6992,7 +6882,7 @@ inline float *ThresholdConfig::mutable_high() inline void ThresholdConfig::set_high(float v) { m_high = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -7145,8 +7035,8 @@ inline size_t NodeConfig::getMaxSize() // obsolete repeated FunctionConfig functions, id 32 // repeated StateMachineConfig statemachs, id 33 has unlimited size // deprecated optional unsigned max_on_time, id 34 has maximum size 7 - // optional unsigned threshold_off, id 35 has maximum size 7 - // optional unsigned threshold_on, id 36 has maximum size 7 + // deprecated optional unsigned threshold_off, id 35 has maximum size 7 + // deprecated optional unsigned threshold_on, id 36 has maximum size 7 // optional unsigned dim_step, id 37 has maximum size 7 // optional bool lightctrl, id 38 has maximum size 3 // optional unsigned pwm_freq, id 39 has maximum size 7 @@ -7242,7 +7132,7 @@ inline const estring &NodeConfig::pass_hash() const inline bool NodeConfig::has_pass_hash() const { - return 0 != (p_validbits & ((uint32_t)1U << 1)); + return !m_pass_hash.empty(); } /*! @@ -7251,29 +7141,22 @@ inline bool NodeConfig::has_pass_hash() const */ inline void NodeConfig::clear_pass_hash() { - p_validbits &= ~((uint32_t)1U << 1); m_pass_hash.clear(); } inline estring *NodeConfig::mutable_pass_hash() { - if (0 == (p_validbits & ((uint32_t)1U << 1))) { - p_validbits |= ((uint32_t)1U << 1); - m_pass_hash.clear(); - } return &m_pass_hash; } inline void NodeConfig::set_pass_hash(const void *data, size_t s) { m_pass_hash.assign((const char *)data,s); - p_validbits |= ((uint32_t)1U << 1); } inline void NodeConfig::set_pass_hash(const estring &v) { m_pass_hash = v; - p_validbits |= ((uint32_t)1U << 1); } @@ -7285,7 +7168,7 @@ inline uint32_t NodeConfig::cpu_freq() const inline bool NodeConfig::has_cpu_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 2)); + return 0 != (p_validbits & ((uint32_t)1U << 1)); } /*! @@ -7294,14 +7177,14 @@ inline bool NodeConfig::has_cpu_freq() const */ inline void NodeConfig::clear_cpu_freq() { - p_validbits &= ~((uint32_t)1U << 2); + p_validbits &= ~((uint32_t)1U << 1); m_cpu_freq = 0; } inline uint32_t *NodeConfig::mutable_cpu_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 2))) { - p_validbits |= ((uint32_t)1U << 2); + if (0 == (p_validbits & ((uint32_t)1U << 1))) { + p_validbits |= ((uint32_t)1U << 1); m_cpu_freq = 0; } return &m_cpu_freq; @@ -7310,7 +7193,7 @@ inline uint32_t *NodeConfig::mutable_cpu_freq() inline void NodeConfig::set_cpu_freq(uint32_t v) { m_cpu_freq = v; - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); } @@ -7322,7 +7205,7 @@ inline const WifiConfig &NodeConfig::station() const inline bool NodeConfig::has_station() const { - return 0 != (p_validbits & ((uint32_t)1U << 3)); + return 0 != (p_validbits & ((uint32_t)1U << 2)); } /*! @@ -7331,14 +7214,14 @@ inline bool NodeConfig::has_station() const */ inline void NodeConfig::clear_station() { - p_validbits &= ~((uint32_t)1U << 3); + p_validbits &= ~((uint32_t)1U << 2); m_station.clear(); } inline WifiConfig *NodeConfig::mutable_station() { - if (0 == (p_validbits & ((uint32_t)1U << 3))) { - p_validbits |= ((uint32_t)1U << 3); + if (0 == (p_validbits & ((uint32_t)1U << 2))) { + p_validbits |= ((uint32_t)1U << 2); m_station.clear(); } return &m_station; @@ -7347,13 +7230,13 @@ inline WifiConfig *NodeConfig::mutable_station() inline void NodeConfig::set_station(const void *data, size_t s) { m_station.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } inline void NodeConfig::set_station(const WifiConfig &v) { m_station = v; - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } @@ -7365,7 +7248,7 @@ inline const WifiConfig &NodeConfig::softap() const inline bool NodeConfig::has_softap() const { - return 0 != (p_validbits & ((uint32_t)1U << 4)); + return 0 != (p_validbits & ((uint32_t)1U << 3)); } /*! @@ -7374,14 +7257,14 @@ inline bool NodeConfig::has_softap() const */ inline void NodeConfig::clear_softap() { - p_validbits &= ~((uint32_t)1U << 4); + p_validbits &= ~((uint32_t)1U << 3); m_softap.clear(); } inline WifiConfig *NodeConfig::mutable_softap() { - if (0 == (p_validbits & ((uint32_t)1U << 4))) { - p_validbits |= ((uint32_t)1U << 4); + if (0 == (p_validbits & ((uint32_t)1U << 3))) { + p_validbits |= ((uint32_t)1U << 3); m_softap.clear(); } return &m_softap; @@ -7390,13 +7273,13 @@ inline WifiConfig *NodeConfig::mutable_softap() inline void NodeConfig::set_softap(const void *data, size_t s) { m_softap.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } inline void NodeConfig::set_softap(const WifiConfig &v) { m_softap = v; - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } @@ -7423,7 +7306,7 @@ inline void NodeConfig::clear_dns_server() inline estring *NodeConfig::mutable_dns_server(unsigned x) { if (x >= m_dns_server.size()) - m_dns_server.resize(x+1,""); + m_dns_server.resize(x+1); return &m_dns_server[x]; } @@ -7586,7 +7469,7 @@ inline const MQTT &NodeConfig::mqtt() const inline bool NodeConfig::has_mqtt() const { - return 0 != (p_validbits & ((uint32_t)1U << 5)); + return 0 != (p_validbits & ((uint32_t)1U << 4)); } /*! @@ -7595,14 +7478,14 @@ inline bool NodeConfig::has_mqtt() const */ inline void NodeConfig::clear_mqtt() { - p_validbits &= ~((uint32_t)1U << 5); + p_validbits &= ~((uint32_t)1U << 4); m_mqtt.clear(); } inline MQTT *NodeConfig::mutable_mqtt() { - if (0 == (p_validbits & ((uint32_t)1U << 5))) { - p_validbits |= ((uint32_t)1U << 5); + if (0 == (p_validbits & ((uint32_t)1U << 4))) { + p_validbits |= ((uint32_t)1U << 4); m_mqtt.clear(); } return &m_mqtt; @@ -7611,13 +7494,13 @@ inline MQTT *NodeConfig::mutable_mqtt() inline void NodeConfig::set_mqtt(const void *data, size_t s) { m_mqtt.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } inline void NodeConfig::set_mqtt(const MQTT &v) { m_mqtt = v; - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } #endif // CONFIG_MQTT @@ -7630,7 +7513,7 @@ inline uint16_t NodeConfig::dmesg_size() const inline bool NodeConfig::has_dmesg_size() const { - return 0 != (p_validbits & ((uint32_t)1U << 6)); + return 0 != (p_validbits & ((uint32_t)1U << 5)); } /*! @@ -7639,14 +7522,14 @@ inline bool NodeConfig::has_dmesg_size() const */ inline void NodeConfig::clear_dmesg_size() { - p_validbits &= ~((uint32_t)1U << 6); + p_validbits &= ~((uint32_t)1U << 5); m_dmesg_size = 2048; } inline uint16_t *NodeConfig::mutable_dmesg_size() { - if (0 == (p_validbits & ((uint32_t)1U << 6))) { - p_validbits |= ((uint32_t)1U << 6); + if (0 == (p_validbits & ((uint32_t)1U << 5))) { + p_validbits |= ((uint32_t)1U << 5); m_dmesg_size = 2048; } return &m_dmesg_size; @@ -7655,7 +7538,7 @@ inline uint16_t *NodeConfig::mutable_dmesg_size() inline void NodeConfig::set_dmesg_size(uint16_t v) { m_dmesg_size = v; - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); } @@ -7668,7 +7551,7 @@ inline const Influx &NodeConfig::influx() const inline bool NodeConfig::has_influx() const { - return 0 != (p_validbits & ((uint32_t)1U << 7)); + return 0 != (p_validbits & ((uint32_t)1U << 6)); } /*! @@ -7677,14 +7560,14 @@ inline bool NodeConfig::has_influx() const */ inline void NodeConfig::clear_influx() { - p_validbits &= ~((uint32_t)1U << 7); + p_validbits &= ~((uint32_t)1U << 6); m_influx.clear(); } inline Influx *NodeConfig::mutable_influx() { - if (0 == (p_validbits & ((uint32_t)1U << 7))) { - p_validbits |= ((uint32_t)1U << 7); + if (0 == (p_validbits & ((uint32_t)1U << 6))) { + p_validbits |= ((uint32_t)1U << 6); m_influx.clear(); } return &m_influx; @@ -7693,13 +7576,13 @@ inline Influx *NodeConfig::mutable_influx() inline void NodeConfig::set_influx(const void *data, size_t s) { m_influx.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } inline void NodeConfig::set_influx(const Influx &v) { m_influx = v; - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } #endif // CONFIG_INFLUX @@ -7712,7 +7595,7 @@ inline uint32_t NodeConfig::station2ap_time() const inline bool NodeConfig::has_station2ap_time() const { - return 0 != (p_validbits & ((uint32_t)1U << 8)); + return 0 != (p_validbits & ((uint32_t)1U << 7)); } /*! @@ -7721,14 +7604,14 @@ inline bool NodeConfig::has_station2ap_time() const */ inline void NodeConfig::clear_station2ap_time() { - p_validbits &= ~((uint32_t)1U << 8); + p_validbits &= ~((uint32_t)1U << 7); m_station2ap_time = 0; } inline uint32_t *NodeConfig::mutable_station2ap_time() { - if (0 == (p_validbits & ((uint32_t)1U << 8))) { - p_validbits |= ((uint32_t)1U << 8); + if (0 == (p_validbits & ((uint32_t)1U << 7))) { + p_validbits |= ((uint32_t)1U << 7); m_station2ap_time = 0; } return &m_station2ap_time; @@ -7737,7 +7620,7 @@ inline uint32_t *NodeConfig::mutable_station2ap_time() inline void NodeConfig::set_station2ap_time(uint32_t v) { m_station2ap_time = v; - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); } @@ -7890,7 +7773,7 @@ inline uint32_t NodeConfig::actions_enable() const inline bool NodeConfig::has_actions_enable() const { - return 0 != (p_validbits & ((uint32_t)1U << 9)); + return 0 != (p_validbits & ((uint32_t)1U << 8)); } /*! @@ -7899,14 +7782,14 @@ inline bool NodeConfig::has_actions_enable() const */ inline void NodeConfig::clear_actions_enable() { - p_validbits &= ~((uint32_t)1U << 9); + p_validbits &= ~((uint32_t)1U << 8); m_actions_enable = 1; } inline uint32_t *NodeConfig::mutable_actions_enable() { - if (0 == (p_validbits & ((uint32_t)1U << 9))) { - p_validbits |= ((uint32_t)1U << 9); + if (0 == (p_validbits & ((uint32_t)1U << 8))) { + p_validbits |= ((uint32_t)1U << 8); m_actions_enable = 1; } return &m_actions_enable; @@ -7915,7 +7798,7 @@ inline uint32_t *NodeConfig::mutable_actions_enable() inline void NodeConfig::set_actions_enable(uint32_t v) { m_actions_enable = v; - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); } @@ -8079,7 +7962,7 @@ inline uint16_t NodeConfig::udp_ctrl_port() const inline bool NodeConfig::has_udp_ctrl_port() const { - return 0 != (p_validbits & ((uint32_t)1U << 10)); + return 0 != (p_validbits & ((uint32_t)1U << 9)); } /*! @@ -8088,14 +7971,14 @@ inline bool NodeConfig::has_udp_ctrl_port() const */ inline void NodeConfig::clear_udp_ctrl_port() { - p_validbits &= ~((uint32_t)1U << 10); + p_validbits &= ~((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } inline uint16_t *NodeConfig::mutable_udp_ctrl_port() { - if (0 == (p_validbits & ((uint32_t)1U << 10))) { - p_validbits |= ((uint32_t)1U << 10); + if (0 == (p_validbits & ((uint32_t)1U << 9))) { + p_validbits |= ((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } return &m_udp_ctrl_port; @@ -8104,7 +7987,7 @@ inline uint16_t *NodeConfig::mutable_udp_ctrl_port() inline void NodeConfig::set_udp_ctrl_port(uint16_t v) { m_udp_ctrl_port = v; - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); } @@ -8171,7 +8054,7 @@ inline const FtpHttpConfig &NodeConfig::ftpd() const inline bool NodeConfig::has_ftpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 11)); + return 0 != (p_validbits & ((uint32_t)1U << 10)); } /*! @@ -8180,14 +8063,14 @@ inline bool NodeConfig::has_ftpd() const */ inline void NodeConfig::clear_ftpd() { - p_validbits &= ~((uint32_t)1U << 11); + p_validbits &= ~((uint32_t)1U << 10); m_ftpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_ftpd() { - if (0 == (p_validbits & ((uint32_t)1U << 11))) { - p_validbits |= ((uint32_t)1U << 11); + if (0 == (p_validbits & ((uint32_t)1U << 10))) { + p_validbits |= ((uint32_t)1U << 10); m_ftpd.clear(); } return &m_ftpd; @@ -8196,13 +8079,13 @@ inline FtpHttpConfig *NodeConfig::mutable_ftpd() inline void NodeConfig::set_ftpd(const void *data, size_t s) { m_ftpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } inline void NodeConfig::set_ftpd(const FtpHttpConfig &v) { m_ftpd = v; - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } #endif // CONFIG_FTP @@ -8216,7 +8099,7 @@ inline const FtpHttpConfig &NodeConfig::httpd() const inline bool NodeConfig::has_httpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 12)); + return 0 != (p_validbits & ((uint32_t)1U << 11)); } /*! @@ -8225,14 +8108,14 @@ inline bool NodeConfig::has_httpd() const */ inline void NodeConfig::clear_httpd() { - p_validbits &= ~((uint32_t)1U << 12); + p_validbits &= ~((uint32_t)1U << 11); m_httpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_httpd() { - if (0 == (p_validbits & ((uint32_t)1U << 12))) { - p_validbits |= ((uint32_t)1U << 12); + if (0 == (p_validbits & ((uint32_t)1U << 11))) { + p_validbits |= ((uint32_t)1U << 11); m_httpd.clear(); } return &m_httpd; @@ -8241,13 +8124,13 @@ inline FtpHttpConfig *NodeConfig::mutable_httpd() inline void NodeConfig::set_httpd(const void *data, size_t s) { m_httpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } inline void NodeConfig::set_httpd(const FtpHttpConfig &v) { m_httpd = v; - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } #endif // CONFIG_HTTP @@ -8260,7 +8143,7 @@ inline const estring &NodeConfig::otasrv() const inline bool NodeConfig::has_otasrv() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return !m_otasrv.empty(); } /*! @@ -8269,35 +8152,27 @@ inline bool NodeConfig::has_otasrv() const */ 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); } @@ -8437,7 +8312,7 @@ inline uint32_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 12)); } /*! @@ -8446,23 +8321,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 12); m_threshold_off = 0; } -inline uint32_t *NodeConfig::mutable_threshold_off() -{ - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); - m_threshold_off = 0; - } - return &m_threshold_off; -} - inline void NodeConfig::set_threshold_off(uint32_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 12); } @@ -8474,7 +8340,7 @@ inline uint32_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 13)); } /*! @@ -8483,23 +8349,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 13); m_threshold_on = 0; } -inline uint32_t *NodeConfig::mutable_threshold_on() -{ - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); - m_threshold_on = 0; - } - return &m_threshold_on; -} - inline void NodeConfig::set_threshold_on(uint32_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 13); } @@ -8511,7 +8368,7 @@ inline uint32_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8520,14 +8377,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 14); m_dim_step = 0; } inline uint32_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_dim_step = 0; } return &m_dim_step; @@ -8536,7 +8393,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 << 16); + p_validbits |= ((uint32_t)1U << 14); } @@ -8548,7 +8405,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8557,14 +8414,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 15); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_lightctrl = 0; } return &m_lightctrl; @@ -8573,7 +8430,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 15); } @@ -8585,7 +8442,7 @@ inline uint32_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 18)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8594,14 +8451,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 18); + p_validbits &= ~((uint32_t)1U << 16); m_pwm_freq = 0; } inline uint32_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 18))) { - p_validbits |= ((uint32_t)1U << 18); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8610,7 +8467,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 << 18); + p_validbits |= ((uint32_t)1U << 16); } diff --git a/components/wfc/swcfg_pc.cpp b/components/wfc/swcfg_pc.cpp index 15e044d..aba53f4 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -39,6 +39,7 @@ * options from common: * BaseClass : "Message" * getMember : "getMember" + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -67,7 +68,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * stringtype : "std::string" * toJSON : "toJSON" * toMemory : "toMemory" @@ -359,18 +359,6 @@ const char *sigtype_t_str(sigtype_t e) return 0; } -WifiConfig::WifiConfig() -: m_ssid() -, m_pass() -, m_mac() -, m_activate(false) -, m_addr4(0) -, m_netmask4(0) -, m_gateway4(0) -, p_validbits(0) -{ -} - void WifiConfig::clear() { m_ssid.clear(); @@ -446,7 +434,6 @@ ssize_t WifiConfig::fromMemory(const void *b, ssize_t s) m_mac.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x23: // activate id 4, type bool, coding 8bit if (a >= e) @@ -521,7 +508,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += pass_s; } // has mac? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { // 'mac': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -15; @@ -540,7 +527,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = 0x23; *a++ = m_activate; // has addr4? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'addr4': id=5, encoding=32bit, tag=0x2d if (5 > (e-a)) return -18; @@ -551,7 +538,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const a += 4; } // has netmask4? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'netmask4': id=6, encoding=8bit, tag=0x33 if (2 > (e-a)) return -20; @@ -559,7 +546,7 @@ ssize_t WifiConfig::toMemory(uint8_t *b, ssize_t s) const *a++ = m_netmask4; } // has gateway4? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'gateway4': id=7, encoding=32bit, tag=0x3d if (5 > (e-a)) return -21; @@ -589,7 +576,7 @@ void WifiConfig::toWire(void (*put)(uint8_t)) const send_varint(put,pass_s); send_bytes(put,(const uint8_t*) m_pass.data(),pass_s); } - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { // 'mac': id=3, encoding=lenpfx, tag=0x1a put(0x1a); // 'mac': id=3 size_t mac_s = m_mac.size(); @@ -599,17 +586,17 @@ void WifiConfig::toWire(void (*put)(uint8_t)) const // 'activate': id=4, encoding=8bit, tag=0x23 put(0x23); // 'activate': id=4 put(m_activate); - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'addr4': id=5, encoding=32bit, tag=0x2d put(0x2d); // 'addr4': id=5 send_u32(put,(uint32_t)m_addr4); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'netmask4': id=6, encoding=8bit, tag=0x33 put(0x33); // 'netmask4': id=6 put(m_netmask4); } - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'gateway4': id=7, encoding=32bit, tag=0x3d put(0x3d); // 'gateway4': id=7 send_u32(put,(uint32_t)m_gateway4); @@ -632,7 +619,7 @@ void WifiConfig::toString(std::string &put) const send_varint(put,pass_s); put.append((const char *)(const uint8_t*) m_pass.data(),pass_s); } - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { // 'mac': id=3, encoding=lenpfx, tag=0x1a put.push_back(0x1a); // 'mac': id=3 size_t mac_s = m_mac.size(); @@ -642,17 +629,17 @@ void WifiConfig::toString(std::string &put) const // 'activate': id=4, encoding=8bit, tag=0x23 put.push_back(0x23); // 'activate': id=4 put.push_back(m_activate); - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'addr4': id=5, encoding=32bit, tag=0x2d put.push_back(0x2d); // 'addr4': id=5 send_u32(put,(uint32_t)m_addr4); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'netmask4': id=6, encoding=8bit, tag=0x33 put.push_back(0x33); // 'netmask4': id=6 put.push_back(m_netmask4); } - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'gateway4': id=7, encoding=32bit, tag=0x3d put.push_back(0x3d); // 'gateway4': id=7 send_u32(put,(uint32_t)m_gateway4); @@ -718,20 +705,20 @@ size_t WifiConfig::calcSize() const r += pass_s + wiresize(pass_s) + 1 /* tag(pass) 0x10 */; } // optional bytes mac, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_mac.empty()) { size_t mac_s = m_mac.size(); r += mac_s + wiresize(mac_s) + 1 /* tag(mac) 0x18 */; } // optional fixed32 addr4, id 5 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += 5; } // optional fixed8 netmask4, id 6 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { r += 2; } // optional fixed32 gateway4, id 7 - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { r += 5; } return r; @@ -798,8 +785,6 @@ int WifiConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_mac,value); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"activate")) { @@ -813,7 +798,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_addr4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"netmask4")) { @@ -823,7 +808,7 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_netmask4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"gateway4")) { @@ -833,32 +818,24 @@ int WifiConfig::setByName(const char *name, const char *value) } int r = parse_ipv4(&m_gateway4,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); return r; } return -23; } -Message *WifiConfig::p_getMember(const char *s, const char *e) +Message *WifiConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *WifiConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *WifiConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -MQTT::MQTT() -: m_uri() -, m_enable(false) -, m_username() -, m_password() -, m_keepalive(60) -, p_validbits(0) -{ -} - void MQTT::clear() { m_uri.clear(); @@ -1353,26 +1330,18 @@ int MQTT::setByName(const char *name, const char *value) return -47; } -Message *MQTT::p_getMember(const char *s, const char *e) +Message *MQTT::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *MQTT::p_getMember(const char *s, const char *e, unsigned x) +Message *MQTT::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Date::Date() -: m_day(0) -, m_month(0) -, m_year(0) -, m_endday(0) -, m_endmonth(0) -, m_endyear(0) -{ -} - void Date::clear() { m_day = 0; @@ -1734,25 +1703,18 @@ int Date::setByName(const char *name, const char *value) return -63; } -Message *Date::p_getMember(const char *s, const char *e) +Message *Date::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Date::p_getMember(const char *s, const char *e, unsigned x) +Message *Date::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AtAction::AtAction() -: m_day(Sunday) -, m_min_of_day(0) -, m_action() -, m_enable(true) -, p_validbits(0) -{ -} - void AtAction::clear() { m_day = Sunday; @@ -1821,7 +1783,6 @@ ssize_t AtAction::fromMemory(const void *b, ssize_t s) m_action.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 2); break; case 0x23: // enable id 4, type bool, coding 8bit if (a >= e) @@ -1873,7 +1834,7 @@ ssize_t AtAction::toMemory(uint8_t *b, ssize_t s) const a += n; } // has action? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { // 'action': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -75; @@ -1907,7 +1868,7 @@ void AtAction::toWire(void (*put)(uint8_t)) const put(0x10); // 'min_of_day': id=2 send_varint(put,m_min_of_day); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { // 'action': id=3, encoding=lenpfx, tag=0x1a put(0x1a); // 'action': id=3 size_t action_s = m_action.size(); @@ -1931,7 +1892,7 @@ void AtAction::toString(std::string &put) const put.push_back(0x10); // 'min_of_day': id=2 send_varint(put,m_min_of_day); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { // 'action': id=3, encoding=lenpfx, tag=0x1a put.push_back(0x1a); // 'action': id=3 size_t action_s = m_action.size(); @@ -1992,7 +1953,7 @@ size_t AtAction::calcSize() const r += wiresize((varint_t)m_min_of_day) + 1 /* tag(min_of_day) 0x10 */; } // optional string action, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_action.empty()) { size_t action_s = m_action.size(); r += action_s + wiresize(action_s) + 1 /* tag(action) 0x18 */; } @@ -2059,8 +2020,6 @@ int AtAction::setByName(const char *name, const char *value) } m_action = value; int r = m_action.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"enable")) { @@ -2070,25 +2029,18 @@ int AtAction::setByName(const char *name, const char *value) return -79; } -Message *AtAction::p_getMember(const char *s, const char *e) +Message *AtAction::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AtAction::p_getMember(const char *s, const char *e, unsigned x) +Message *AtAction::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Influx::Influx() -: m_hostname() -, m_port(0) -, m_measurement() -// omitted obsolete member interval -, m_database() -{ -} - void Influx::clear() { m_hostname.clear(); @@ -2423,27 +2375,18 @@ int Influx::setByName(const char *name, const char *value) return -94; } -Message *Influx::p_getMember(const char *s, const char *e) +Message *Influx::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Influx::p_getMember(const char *s, const char *e, unsigned x) +Message *Influx::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -UartSettings::UartSettings() -: m_port(0) -, m_baudrate(0) -, m_config(5) -, m_rx_thresh(0) -, m_tx_bufsize(0) -, m_rx_bufsize(0) -, p_validbits(0) -{ -} - void UartSettings::clear() { m_port = 0; @@ -2888,25 +2831,18 @@ int UartSettings::setByName(const char *name, const char *value) return -115; } -Message *UartSettings::p_getMember(const char *s, const char *e) +Message *UartSettings::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *UartSettings::p_getMember(const char *s, const char *e, unsigned x) +Message *UartSettings::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -FtpHttpConfig::FtpHttpConfig() -: m_port(0) -, m_start(true) -, m_root() -, m_uploaddir() -, p_validbits(0) -{ -} - void FtpHttpConfig::clear() { m_port = 0; @@ -3224,30 +3160,23 @@ int FtpHttpConfig::setByName(const char *name, const char *value) return -129; } -Message *FtpHttpConfig::p_getMember(const char *s, const char *e) +Message *FtpHttpConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *FtpHttpConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *FtpHttpConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -TerminalConfig::TerminalConfig() -: m_uart_rx(-1) -, m_uart_tx(-1) -, m_name() -, p_validbits(0) -{ -} - void TerminalConfig::clear() { m_uart_rx = -1; m_uart_tx = -1; m_name.clear(); - p_validbits = 0; } void TerminalConfig::toASCII(std::ostream &o, size_t indent) const @@ -3303,7 +3232,6 @@ ssize_t TerminalConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; default: // unknown field (option unknown=skip) @@ -3350,7 +3278,7 @@ ssize_t TerminalConfig::toMemory(uint8_t *b, ssize_t s) const a += n; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -140; @@ -3379,7 +3307,7 @@ void TerminalConfig::toWire(void (*put)(uint8_t)) const put(0x10); // 'uart_tx': id=2 send_varint(put,sint_varint(m_uart_tx)); } - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a put(0x1a); // 'name': id=3 size_t name_s = m_name.size(); @@ -3400,7 +3328,7 @@ void TerminalConfig::toString(std::string &put) const put.push_back(0x10); // 'uart_tx': id=2 send_varint(put,sint_varint(m_uart_tx)); } - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=3, encoding=lenpfx, tag=0x1a put.push_back(0x1a); // 'name': id=3 size_t name_s = m_name.size(); @@ -3447,7 +3375,7 @@ size_t TerminalConfig::calcSize() const r += wiresize_s((varint_t)m_uart_tx) + 1 /* tag(uart_tx) 0x10 */; } // optional string name, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x18 */; } @@ -3456,8 +3384,6 @@ size_t TerminalConfig::calcSize() const bool TerminalConfig::operator != (const TerminalConfig &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_uart_rx() && (m_uart_rx != r.m_uart_rx)) return true; if (has_uart_tx() && (m_uart_tx != r.m_uart_tx)) @@ -3506,34 +3432,27 @@ int TerminalConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } return -142; } -Message *TerminalConfig::p_getMember(const char *s, const char *e) +Message *TerminalConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *TerminalConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *TerminalConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -Trigger::Trigger() -: m_event() -, p_validbits(0) -{ -} - void Trigger::clear() { m_event.clear(); m_action.clear(); - p_validbits = 0; } void Trigger::toASCII(std::ostream &o, size_t indent) const @@ -3579,7 +3498,6 @@ ssize_t Trigger::fromMemory(const void *b, ssize_t s) m_event.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x12: // action id 2, type std::string, coding byte[] { @@ -3615,7 +3533,7 @@ ssize_t Trigger::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has event? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { // 'event': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -148; @@ -3647,7 +3565,7 @@ ssize_t Trigger::toMemory(uint8_t *b, ssize_t s) const void Trigger::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { // 'event': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'event': id=1 size_t event_s = m_event.size(); @@ -3665,7 +3583,7 @@ void Trigger::toWire(void (*put)(uint8_t)) const void Trigger::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { // 'event': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'event': id=1 size_t event_s = m_event.size(); @@ -3721,7 +3639,7 @@ size_t Trigger::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string event, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_event.empty()) { size_t event_s = m_event.size(); r += event_s + wiresize(event_s) + 1 /* tag(event) 0x8 */; } @@ -3739,8 +3657,6 @@ size_t Trigger::calcSize() const bool Trigger::operator != (const Trigger &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_event() && (m_event != r.m_event)) return true; if (m_action != r.m_action) @@ -3771,8 +3687,6 @@ int Trigger::setByName(const char *name, const char *value) } m_event = value; int r = m_event.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"action",6)) { @@ -3808,26 +3722,18 @@ int Trigger::setByName(const char *name, const char *value) return -155; } -Message *Trigger::p_getMember(const char *s, const char *e) +Message *Trigger::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *Trigger::p_getMember(const char *s, const char *e, unsigned x) +Message *Trigger::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -AppParam::AppParam() -: m_key() -, m_uValue(0) -, m_sValue() -, m_dValue(0) -, m_fValue(0) -, p_validbits(0) -{ -} - void AppParam::clear() { m_key.clear(); @@ -3873,7 +3779,6 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) m_key.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x10: // uValue id 2, type uint64_t, coding varint { @@ -3895,7 +3800,6 @@ ssize_t AppParam::fromMemory(const void *b, ssize_t s) m_sValue.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 2); break; case 0x20: // dValue id 4, type int64_t, coding signed varint { @@ -3936,7 +3840,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has key? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { // 'key': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -164; @@ -3950,7 +3854,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += key_s; } // has uValue? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'uValue': id=2, encoding=varint, tag=0x10 if (a >= e) return -166; @@ -3961,7 +3865,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has sValue? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { // 'sValue': id=3, encoding=lenpfx, tag=0x1a if (a >= e) return -168; @@ -3975,7 +3879,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += sValue_s; } // has dValue? - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'dValue': id=4, encoding=varint, tag=0x20 if (a >= e) return -170; @@ -3986,7 +3890,7 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const a += n; } // has fValue? - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'fValue': id=5, encoding=64bit, tag=0x29 if (9 > (e-a)) return -172; @@ -4000,31 +3904,31 @@ ssize_t AppParam::toMemory(uint8_t *b, ssize_t s) const void AppParam::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { // 'key': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'key': id=1 size_t key_s = m_key.size(); send_varint(put,key_s); send_bytes(put,(const uint8_t*) m_key.data(),key_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'uValue': id=2, encoding=varint, tag=0x10 put(0x10); // 'uValue': id=2 send_varint(put,m_uValue); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { // 'sValue': id=3, encoding=lenpfx, tag=0x1a put(0x1a); // 'sValue': id=3 size_t sValue_s = m_sValue.size(); send_varint(put,sValue_s); send_bytes(put,(const uint8_t*) m_sValue.data(),sValue_s); } - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'dValue': id=4, encoding=varint, tag=0x20 put(0x20); // 'dValue': id=4 send_varint(put,sint_varint(m_dValue)); } - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'fValue': id=5, encoding=64bit, tag=0x29 put(0x29); // 'fValue': id=5 send_u64(put,mangle_double(m_fValue)); @@ -4033,31 +3937,31 @@ void AppParam::toWire(void (*put)(uint8_t)) const void AppParam::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { // 'key': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'key': id=1 size_t key_s = m_key.size(); send_varint(put,key_s); put.append((const char *)(const uint8_t*) m_key.data(),key_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'uValue': id=2, encoding=varint, tag=0x10 put.push_back(0x10); // 'uValue': id=2 send_varint(put,m_uValue); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { // 'sValue': id=3, encoding=lenpfx, tag=0x1a put.push_back(0x1a); // 'sValue': id=3 size_t sValue_s = m_sValue.size(); send_varint(put,sValue_s); put.append((const char *)(const uint8_t*) m_sValue.data(),sValue_s); } - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'dValue': id=4, encoding=varint, tag=0x20 put.push_back(0x20); // 'dValue': id=4 send_varint(put,sint_varint(m_dValue)); } - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { // 'fValue': id=5, encoding=64bit, tag=0x29 put.push_back(0x29); // 'fValue': id=5 send_u64(put,mangle_double(m_fValue)); @@ -4102,25 +4006,25 @@ size_t AppParam::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string key, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_key.empty()) { size_t key_s = m_key.size(); r += key_s + wiresize(key_s) + 1 /* tag(key) 0x8 */; } // optional unsigned uValue, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += wiresize((varint_t)m_uValue) + 1 /* tag(uValue) 0x10 */; } // optional string sValue, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (!m_sValue.empty()) { size_t sValue_s = m_sValue.size(); r += sValue_s + wiresize(sValue_s) + 1 /* tag(sValue) 0x18 */; } // optional signed dValue, id 4 - if (0 != (p_validbits & ((uint8_t)1U << 3))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { r += wiresize_s((varint_t)m_dValue) + 1 /* tag(dValue) 0x20 */; } // optional double fValue, id 5 - if (0 != (p_validbits & ((uint8_t)1U << 4))) { + if (0 != (p_validbits & ((uint8_t)1U << 2))) { r += 9; } return r; @@ -4166,8 +4070,6 @@ int AppParam::setByName(const char *name, const char *value) } m_key = value; int r = m_key.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"uValue")) { @@ -4177,7 +4079,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_uValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"sValue")) { @@ -4187,8 +4089,6 @@ int AppParam::setByName(const char *name, const char *value) } m_sValue = value; int r = m_sValue.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 2); return r; } if (0 == strcmp(name,"dValue")) { @@ -4198,7 +4098,7 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_s64(&m_dValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == strcmp(name,"fValue")) { @@ -4208,30 +4108,24 @@ int AppParam::setByName(const char *name, const char *value) } int r = parse_ascii_dbl(&m_fValue,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); return r; } return -173; } -Message *AppParam::p_getMember(const char *s, const char *e) +Message *AppParam::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *AppParam::p_getMember(const char *s, const char *e, unsigned x) +Message *AppParam::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -EventTimer::EventTimer() -: m_name() -, m_time(0) -, m_config(0) -, p_validbits(0) -{ -} - void EventTimer::clear() { m_name.clear(); @@ -4518,29 +4412,23 @@ int EventTimer::setByName(const char *name, const char *value) return -187; } -Message *EventTimer::p_getMember(const char *s, const char *e) +Message *EventTimer::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *EventTimer::p_getMember(const char *s, const char *e, unsigned x) +Message *EventTimer::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -FunctionConfig::FunctionConfig() -: m_name() -, m_func() -, p_validbits(0) -{ -} - void FunctionConfig::clear() { m_name.clear(); m_func.clear(); m_params.clear(); - p_validbits = 0; } void FunctionConfig::toASCII(std::ostream &o, size_t indent) const @@ -4587,7 +4475,6 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x12: // func id 2, type std::string, coding byte[] { @@ -4599,7 +4486,6 @@ ssize_t FunctionConfig::fromMemory(const void *b, ssize_t s) m_func.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 1); break; case 0x1a: // params id 3, type std::string, coding byte[] { @@ -4635,7 +4521,7 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -194; @@ -4649,7 +4535,7 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const a += name_s; } // has func? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { // 'func': id=2, encoding=lenpfx, tag=0x12 if (a >= e) return -196; @@ -4681,14 +4567,14 @@ ssize_t FunctionConfig::toMemory(uint8_t *b, ssize_t s) const void FunctionConfig::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'name': id=1 size_t name_s = m_name.size(); send_varint(put,name_s); send_bytes(put,(const uint8_t*) m_name.data(),name_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { // 'func': id=2, encoding=lenpfx, tag=0x12 put(0x12); // 'func': id=2 size_t func_s = m_func.size(); @@ -4706,14 +4592,14 @@ void FunctionConfig::toWire(void (*put)(uint8_t)) const void FunctionConfig::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'name': id=1 size_t name_s = m_name.size(); send_varint(put,name_s); put.append((const char *)(const uint8_t*) m_name.data(),name_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { // 'func': id=2, encoding=lenpfx, tag=0x12 put.push_back(0x12); // 'func': id=2 size_t func_s = m_func.size(); @@ -4773,12 +4659,12 @@ size_t FunctionConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } // optional string func, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_func.empty()) { size_t func_s = m_func.size(); r += func_s + wiresize(func_s) + 1 /* tag(func) 0x10 */; } @@ -4796,8 +4682,6 @@ size_t FunctionConfig::calcSize() const bool FunctionConfig::operator != (const FunctionConfig &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_name() && (m_name != r.m_name)) return true; if (has_func() && (m_func != r.m_func)) @@ -4830,8 +4714,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"func")) { @@ -4841,8 +4723,6 @@ int FunctionConfig::setByName(const char *name, const char *value) } m_func = value; int r = m_func.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } if (0 == memcmp(name,"params",6)) { @@ -4878,23 +4758,18 @@ int FunctionConfig::setByName(const char *name, const char *value) return -203; } -Message *FunctionConfig::p_getMember(const char *s, const char *e) +Message *FunctionConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *FunctionConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *FunctionConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -SignalConfig::SignalConfig() -: m_name() -, m_type(st_invalid) -, m_iv() -{ -} - void SignalConfig::clear() { m_name.clear(); @@ -5185,23 +5060,18 @@ int SignalConfig::setByName(const char *name, const char *value) return -217; } -Message *SignalConfig::p_getMember(const char *s, const char *e) +Message *SignalConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *SignalConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *SignalConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -OwDeviceConfig::OwDeviceConfig() -: m_id(0) -, m_name() -, p_validbits(0) -{ -} - void OwDeviceConfig::clear() { m_id = 0; @@ -5249,7 +5119,6 @@ ssize_t OwDeviceConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 1); break; default: // unknown field (option unknown=skip) @@ -5283,7 +5152,7 @@ ssize_t OwDeviceConfig::toMemory(uint8_t *b, ssize_t s) const a += 8; } // has name? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { // 'name': id=2, encoding=lenpfx, tag=0x12 if (a >= e) return -224; @@ -5307,7 +5176,7 @@ void OwDeviceConfig::toWire(void (*put)(uint8_t)) const put(0x9); // 'id': id=1 send_u64(put,(uint64_t)m_id); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { // 'name': id=2, encoding=lenpfx, tag=0x12 put(0x12); // 'name': id=2 size_t name_s = m_name.size(); @@ -5323,7 +5192,7 @@ void OwDeviceConfig::toString(std::string &put) const put.push_back(0x9); // 'id': id=1 send_u64(put,(uint64_t)m_id); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { // 'name': id=2, encoding=lenpfx, tag=0x12 put.push_back(0x12); // 'name': id=2 size_t name_s = m_name.size(); @@ -5362,7 +5231,7 @@ size_t OwDeviceConfig::calcSize() const r += 9; } // optional string name, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x10 */; } @@ -5413,34 +5282,27 @@ int OwDeviceConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 1); return r; } return -226; } -Message *OwDeviceConfig::p_getMember(const char *s, const char *e) +Message *OwDeviceConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *OwDeviceConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *OwDeviceConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -StateConfig::StateConfig() -: m_name() -, p_validbits(0) -{ -} - void StateConfig::clear() { m_name.clear(); m_conds.clear(); - p_validbits = 0; } void StateConfig::toASCII(std::ostream &o, size_t indent) const @@ -5486,7 +5348,6 @@ ssize_t StateConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x12: // conds id 2, type Trigger, coding byte[] { @@ -5529,7 +5390,7 @@ ssize_t StateConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) return -233; @@ -5562,7 +5423,7 @@ ssize_t StateConfig::toMemory(uint8_t *b, ssize_t s) const void StateConfig::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'name': id=1 size_t name_s = m_name.size(); @@ -5579,7 +5440,7 @@ void StateConfig::toWire(void (*put)(uint8_t)) const void StateConfig::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'name': id=1 size_t name_s = m_name.size(); @@ -5634,7 +5495,7 @@ size_t StateConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } @@ -5650,8 +5511,6 @@ size_t StateConfig::calcSize() const bool StateConfig::operator != (const StateConfig &r) const { - if (p_validbits != r.p_validbits) - return true; if (has_name() && (m_name != r.m_name)) return true; if (m_conds != r.m_conds) @@ -5682,8 +5541,6 @@ int StateConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"conds",5)) { @@ -5718,33 +5575,28 @@ int StateConfig::setByName(const char *name, const char *value) return -240; } -Message *StateConfig::p_getMember(const char *s, const char *e) +Message *StateConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *StateConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *StateConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("conds[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 5) && (0 == memcmp("conds",s,5))) { if (x < m_conds.size()) return &m_conds[x]; - return 0; } return 0; } -StateMachineConfig::StateMachineConfig() -: m_name() -, m_ini_st(0) -, p_validbits(0) -{ -} - void StateMachineConfig::clear() { m_name.clear(); m_ini_st = 0; m_states.clear(); + m_persistent = false; p_validbits = 0; } @@ -5766,6 +5618,7 @@ void StateMachineConfig::toASCII(std::ostream &o, size_t indent) const --indent; ascii_indent(o,indent); o << '}'; + ascii_bool(o, indent, "persistent", m_persistent); --indent; ascii_indent(o,indent); o << '}'; @@ -5792,7 +5645,6 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x10: // ini_st id 2, type uint8_t, coding varint { @@ -5822,12 +5674,17 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) } } break; + case 0x23: // persistent id 4, type bool, coding 8bit + if (a >= e) + return -246; + set_persistent(*a++); + break; default: // unknown field (option unknown=skip) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -246; + return -247; a += s; break; } @@ -5835,7 +5692,7 @@ ssize_t StateMachineConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -247; + return -248; return a-(const uint8_t *)b; } @@ -5845,58 +5702,66 @@ ssize_t StateMachineConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -248; + return -249; *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 -249; + return -250; memcpy(a,m_name.data(),name_s); a += name_s; } // has ini_st? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'ini_st': id=2, encoding=varint, tag=0x10 if (a >= e) - return -250; + return -251; *a++ = 0x10; n = write_varint(a,e-a,m_ini_st); if (n <= 0) - return -251; + return -252; a += n; } for (const auto &x : m_states) { // 'states': id=3, encoding=lenpfx, tag=0x1a if (a >= e) - return -252; + return -253; *a++ = 0x1a; ssize_t states_ws = x.calcSize(); n = write_varint(a,e-a,states_ws); a += n; if ((n <= 0) || (states_ws > (e-a))) - return -253; + return -254; n = x.toMemory(a,e-a); a += n; assert(n == states_ws); } + // has persistent? + if (m_persistent != false) { + // 'persistent': id=4, encoding=8bit, tag=0x23 + if (2 > (e-a)) + return -255; + *a++ = 0x23; + *a++ = m_persistent; + } assert(a <= e); return a-b; } void StateMachineConfig::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'name': id=1 size_t name_s = m_name.size(); send_varint(put,name_s); send_bytes(put,(const uint8_t*) m_name.data(),name_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'ini_st': id=2, encoding=varint, tag=0x10 put(0x10); // 'ini_st': id=2 send_varint(put,m_ini_st); @@ -5907,18 +5772,23 @@ void StateMachineConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_states[x].calcSize()); m_states[x].toWire(put); } + if (m_persistent != false) { + // 'persistent': id=4, encoding=8bit, tag=0x23 + put(0x23); // 'persistent': id=4 + put(m_persistent); + } } void StateMachineConfig::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'name': id=1 size_t name_s = m_name.size(); send_varint(put,name_s); put.append((const char *)(const uint8_t*) m_name.data(),name_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'ini_st': id=2, encoding=varint, tag=0x10 put.push_back(0x10); // 'ini_st': id=2 send_varint(put,m_ini_st); @@ -5929,6 +5799,11 @@ void StateMachineConfig::toString(std::string &put) const send_varint(put,m_states[x].calcSize()); m_states[x].toString(put); } + if (m_persistent != false) { + // 'persistent': id=4, encoding=8bit, tag=0x23 + put.push_back(0x23); // 'persistent': id=4 + put.push_back(m_persistent); + } } void StateMachineConfig::toJSON(std::ostream &json, unsigned indLvl) const @@ -5961,6 +5836,10 @@ void StateMachineConfig::toJSON(std::ostream &json, unsigned indLvl) const json_indent(json,indLvl,0); json.put(']'); } + if (has_persistent()) { + fsep = json_indent(json,indLvl,fsep,"persistent"); + json << (m_persistent ? "true" : "false"); + } if (fsep == '{') json.put('{'); json.put('\n'); @@ -5975,12 +5854,12 @@ size_t StateMachineConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } // optional uint8 ini_st, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += wiresize((varint_t)m_ini_st) + 1 /* tag(ini_st) 0x10 */; } // repeated StateConfig states, id 3 @@ -5990,6 +5869,10 @@ size_t StateMachineConfig::calcSize() const r += wiresize(s); r += s + 1 /* tag(states) 0x18 */; } + // optional bool persistent, id 4 + if (m_persistent != false) { + r += 2; + } return r; } @@ -6003,6 +5886,8 @@ bool StateMachineConfig::operator != (const StateMachineConfig &r) const return true; if (m_states != r.m_states) return true; + if (has_persistent() && (m_persistent != r.m_persistent)) + return true; return false; } @@ -6029,8 +5914,6 @@ int StateMachineConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"ini_st")) { @@ -6040,7 +5923,7 @@ int StateMachineConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u8(&m_ini_st,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == memcmp(name,"states",6)) { @@ -6059,43 +5942,44 @@ int StateMachineConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -254; + return -256; if (m_states.size() <= x) - return -255; + return -257; if ((idxe[1] == 0) && (value == 0)) { m_states.erase(m_states.begin()+x); return 0; } } if (idxe[1] != '.') - return -256; + return -258; return m_states[x].setByName(idxe+2,value); } } - return -257; -} - -Message *StateMachineConfig::p_getMember(const char *s, const char *e) -{ - return 0; + if (0 == strcmp(name,"persistent")) { + if (value == 0) { + clear_persistent(); + return 0; + } + int r = parse_ascii_bool(&m_persistent,value); + return r; + } + return -259; } -Message *StateMachineConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *StateMachineConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("states[",s,e-s)) { - if (x < m_states.size()) - return &m_states[x]; - return 0; - } + // caller guarantee: s[n] == '.' return 0; } -ThresholdConfig::ThresholdConfig() -: m_name() -, m_low(0) -, m_high(0) -, p_validbits(0) +Message *StateMachineConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' + if ((n == 6) && (0 == memcmp("states",s,6))) { + if (x < m_states.size()) + return &m_states[x]; + } + return 0; } void ThresholdConfig::clear() @@ -6126,7 +6010,7 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -258; + return -260; a += fn; switch (fid) { case 0xa: // name id 1, type std::string, coding byte[] @@ -6135,21 +6019,20 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -259; + return -261; m_name.assign((const char*)a,v); a += v; } - p_validbits |= ((uint8_t)1U << 0); break; case 0x15: // low id 2, type float, coding 32bit if ((a+3) >= e) - return -260; + return -262; set_low(read_float(a)); a += 4; break; case 0x1d: // high id 3, type float, coding 32bit if ((a+3) >= e) - return -261; + return -263; set_high(read_float(a)); a += 4; break; @@ -6158,7 +6041,7 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -262; + return -264; a += s; break; } @@ -6166,7 +6049,7 @@ ssize_t ThresholdConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -263; + return -265; return a-(const uint8_t *)b; } @@ -6176,38 +6059,38 @@ ssize_t ThresholdConfig::toMemory(uint8_t *b, ssize_t s) const uint8_t *a = b, *e = b + s; signed n; // has name? - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -264; + return -266; *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 -265; + return -267; memcpy(a,m_name.data(),name_s); a += name_s; } // has low? - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'low': id=2, encoding=32bit, tag=0x15 if (5 > (e-a)) - return -266; + return -268; *a++ = 0x15; if ((e-a) < 4) - return -267; + return -269; write_u32(a,mangle_float(m_low)); a += 4; } // has high? - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'high': id=3, encoding=32bit, tag=0x1d if (5 > (e-a)) - return -268; + return -270; *a++ = 0x1d; if ((e-a) < 4) - return -269; + return -271; write_u32(a,mangle_float(m_high)); a += 4; } @@ -6217,19 +6100,19 @@ ssize_t ThresholdConfig::toMemory(uint8_t *b, ssize_t s) const void ThresholdConfig::toWire(void (*put)(uint8_t)) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put(0xa); // 'name': id=1 size_t name_s = m_name.size(); send_varint(put,name_s); send_bytes(put,(const uint8_t*) m_name.data(),name_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'low': id=2, encoding=32bit, tag=0x15 put(0x15); // 'low': id=2 send_u32(put,mangle_float(m_low)); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'high': id=3, encoding=32bit, tag=0x1d put(0x1d); // 'high': id=3 send_u32(put,mangle_float(m_high)); @@ -6238,19 +6121,19 @@ void ThresholdConfig::toWire(void (*put)(uint8_t)) const void ThresholdConfig::toString(std::string &put) const { - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { // 'name': id=1, encoding=lenpfx, tag=0xa put.push_back(0xa); // 'name': id=1 size_t name_s = m_name.size(); send_varint(put,name_s); put.append((const char *)(const uint8_t*) m_name.data(),name_s); } - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { // 'low': id=2, encoding=32bit, tag=0x15 put.push_back(0x15); // 'low': id=2 send_u32(put,mangle_float(m_low)); } - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { // 'high': id=3, encoding=32bit, tag=0x1d put.push_back(0x1d); // 'high': id=3 send_u32(put,mangle_float(m_high)); @@ -6287,16 +6170,16 @@ size_t ThresholdConfig::calcSize() const { size_t r = 0; // required size, default is fixed length // optional string name, id 1 - if (0 != (p_validbits & ((uint8_t)1U << 0))) { + if (!m_name.empty()) { size_t name_s = m_name.size(); r += name_s + wiresize(name_s) + 1 /* tag(name) 0x8 */; } // optional float low, id 2 - if (0 != (p_validbits & ((uint8_t)1U << 1))) { + if (0 != (p_validbits & ((uint8_t)1U << 0))) { r += 5; } // optional float high, id 3 - if (0 != (p_validbits & ((uint8_t)1U << 2))) { + if (0 != (p_validbits & ((uint8_t)1U << 1))) { r += 5; } return r; @@ -6338,8 +6221,6 @@ int ThresholdConfig::setByName(const char *name, const char *value) } m_name = value; int r = m_name.size(); - if (r > 0) - p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"low")) { @@ -6349,7 +6230,7 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_low,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); return r; } if (0 == strcmp(name,"high")) { @@ -6359,26 +6240,24 @@ int ThresholdConfig::setByName(const char *name, const char *value) } int r = parse_ascii_flt(&m_high,value); if (r > 0) - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); return r; } - return -270; + return -272; } -Message *ThresholdConfig::p_getMember(const char *s, const char *e) +Message *ThresholdConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *ThresholdConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *ThresholdConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -LuaConfig::LuaConfig() -{ -} - void LuaConfig::clear() { m_init_scripts.clear(); @@ -6426,7 +6305,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -271; + return -273; a += fn; switch (fid) { case 0xa: // init_scripts id 1, type std::string, coding byte[] @@ -6435,7 +6314,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -272; + return -274; m_init_scripts.emplace_back((const char*)a,v); a += v; } @@ -6446,7 +6325,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) int n = read_varint(a,e-a,&v); a += n; if ((n <= 0) || ((a+v) > e)) - return -273; + return -275; m_compile_files.emplace_back((const char*)a,v); a += v; } @@ -6456,7 +6335,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) { ssize_t s = skip_content(a,e-a,fid&7); if (s <= 0) - return -274; + return -276; a += s; break; } @@ -6464,7 +6343,7 @@ ssize_t LuaConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -275; + return -277; return a-(const uint8_t *)b; } @@ -6476,26 +6355,26 @@ ssize_t LuaConfig::toMemory(uint8_t *b, ssize_t s) const for (const auto &x : m_init_scripts) { // 'init_scripts': id=1, encoding=lenpfx, tag=0xa if (a >= e) - return -276; + return -278; *a++ = 0xa; ssize_t init_scripts_s = x.size(); n = write_varint(a,e-a,init_scripts_s); a += n; if ((n <= 0) || ((e-a) < init_scripts_s)) - return -277; + return -279; memcpy(a,x.data(),init_scripts_s); a += init_scripts_s; } for (const auto &x : m_compile_files) { // 'compile_files': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -278; + return -280; *a++ = 0x12; ssize_t compile_files_s = x.size(); n = write_varint(a,e-a,compile_files_s); a += n; if ((n <= 0) || ((e-a) < compile_files_s)) - return -279; + return -281; memcpy(a,x.data(),compile_files_s); a += compile_files_s; } @@ -6654,16 +6533,16 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+13,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+13))) - return -280; + return -282; if (m_init_scripts.size() <= x) - return -281; + return -283; if ((idxe[1] == 0) && (value == 0)) { m_init_scripts.erase(m_init_scripts.begin()+x); return 0; } } if (idxe[1] != 0) - return -282; + return -284; m_init_scripts[x] = value; return m_init_scripts[x].size(); } @@ -6684,83 +6563,35 @@ int LuaConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+14,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+14))) - return -283; + return -285; if (m_compile_files.size() <= x) - return -284; + return -286; if ((idxe[1] == 0) && (value == 0)) { m_compile_files.erase(m_compile_files.begin()+x); return 0; } } if (idxe[1] != 0) - return -285; + return -287; m_compile_files[x] = value; return m_compile_files[x].size(); } } - return -286; + return -288; } -Message *LuaConfig::p_getMember(const char *s, const char *e) +Message *LuaConfig::p_getMember(const char *s, unsigned n) { + // caller guarantee: s[n] == '.' return 0; } -Message *LuaConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *LuaConfig::p_getMember(const char *s, unsigned n, unsigned x) { + // caller guarantee: s[n] == '[' return 0; } -NodeConfig::NodeConfig() -: m_magic(0) -, m_nodename() -, m_pass_hash() -, m_cpu_freq(0) -, m_syslog_host() -, m_sntp_server() -, m_timezone() -#ifdef CONFIG_MQTT -#endif // CONFIG_MQTT -, m_dmesg_size(2048) -#ifdef CONFIG_INFLUX -#endif // CONFIG_INFLUX -, m_station2ap_time(0) -, m_domainname() -, m_actions_enable(1) -#ifdef CONFIG_TERMSERV -#endif // CONFIG_TERMSERV -, m_udp_ctrl_port(12719) -#ifdef CONFIG_FTP -#endif // CONFIG_FTP -#ifdef CONFIG_HTTP -#endif // CONFIG_HTTP -, m_otasrv() -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member signals -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_SIGNAL_PROC -// omitted obsolete member functions -#endif // CONFIG_SIGNAL_PROC -#ifdef CONFIG_STATEMACHINES -#endif // CONFIG_STATEMACHINES -, m_max_on_time(0) -, m_threshold_off(0) -, m_threshold_on(0) -, m_dim_step(0) -, m_lightctrl(0) -, m_pwm_freq(0) -#ifdef CONFIG_APP_PARAMS -#endif // CONFIG_APP_PARAMS -#ifdef CONFIG_THRESHOLDS -#endif // CONFIG_THRESHOLDS -#ifdef CONFIG_LUA -#endif // CONFIG_LUA -#ifdef CONFIG_ONEWIRE -#endif // CONFIG_ONEWIRE -, p_validbits(0) -{ -} - void NodeConfig::clear() { m_magic = 0; @@ -7048,12 +6879,12 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) varint_t fid; int fn = read_varint(a,e-a,&fid); if (fn <= 0) - return -287; + return -289; a += fn; switch (fid) { case 0x5: // magic id 0, type uint32_t, coding 32bit if ((a+3) >= e) - return -288; + return -290; set_magic((uint32_t) read_u32(a)); a += 4; break; @@ -7063,7 +6894,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 -289; + return -291; m_nodename.assign((const char*)a,v); a += v; } @@ -7074,18 +6905,17 @@ 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 -290; + return -292; m_pass_hash.assign((const char*)a,v); a += v; } - p_validbits |= ((uint32_t)1U << 1); break; case 0x18: // cpu_freq id 3, type uint64_t, coding varint { varint_t v; int n = read_varint(a,e-a,&v); if (n <= 0) - return -291; + return -293; a += n; set_cpu_freq(v); } @@ -7096,17 +6926,17 @@ 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 -292; + return -294; if (v != 0) { n = m_station.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -293; + return -295; a += v; } } - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); break; case 0x2a: // softap id 5, type WifiConfig, coding byte[] { @@ -7114,17 +6944,17 @@ 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 -294; + return -296; if (v != 0) { n = m_softap.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -295; + return -297; a += v; } } - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); break; case 0x32: // dns_server id 6, type std::string, coding byte[] { @@ -7132,7 +6962,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 -296; + return -298; m_dns_server.emplace_back((const char*)a,v); a += v; } @@ -7143,7 +6973,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 -297; + return -299; m_syslog_host.assign((const char*)a,v); a += v; } @@ -7154,7 +6984,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 -298; + return -300; m_sntp_server.assign((const char*)a,v); a += v; } @@ -7165,7 +6995,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 -299; + return -301; m_timezone.assign((const char*)a,v); a += v; } @@ -7177,22 +7007,22 @@ 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 -300; + return -302; if (v != 0) { n = m_mqtt.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -301; + return -303; a += v; } } - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); break; #endif // CONFIG_MQTT case 0x5c: // dmesg_size id 11, type uint16_t, coding 16bit if ((a+1) >= e) - return -302; + return -304; set_dmesg_size((uint16_t) read_u16(a)); a += 2; break; @@ -7203,17 +7033,17 @@ 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 -303; + return -305; if (v != 0) { n = m_influx.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -304; + return -306; a += v; } } - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); break; #endif // CONFIG_INFLUX case 0x68: // station2ap_time id 13, type uint64_t, coding varint @@ -7221,7 +7051,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 -305; + return -307; a += n; set_station2ap_time(v); } @@ -7232,7 +7062,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 -306; + return -308; m_domainname.assign((const char*)a,v); a += v; } @@ -7243,14 +7073,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 -307; + return -309; m_holidays.emplace_back(); if (v != 0) { n = m_holidays.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -308; + return -310; a += v; } } @@ -7261,14 +7091,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 -309; + return -311; m_at_actions.emplace_back(); if (v != 0) { n = m_at_actions.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -310; + return -312; a += v; } } @@ -7278,7 +7108,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 -311; + return -313; a += n; set_actions_enable(v); } @@ -7289,14 +7119,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 -312; + return -314; m_triggers.emplace_back(); if (v != 0) { n = m_triggers.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -313; + return -315; a += v; } } @@ -7307,14 +7137,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 -314; + return -316; 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 -315; + return -317; a += v; } } @@ -7326,14 +7156,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 -316; + return -318; m_terminal.emplace_back(); if (v != 0) { n = m_terminal.back().fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -317; + return -319; a += v; } } @@ -7341,7 +7171,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) #endif // CONFIG_TERMSERV case 0xb4: // udp_ctrl_port id 22, type uint16_t, coding 16bit if ((a+1) >= e) - return -318; + return -320; set_udp_ctrl_port((uint16_t) read_u16(a)); a += 2; break; @@ -7351,7 +7181,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 -319; + return -321; m_debugs.emplace_back((const char*)a,v); a += v; } @@ -7363,17 +7193,17 @@ 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 -320; + return -322; if (v != 0) { n = m_ftpd.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -321; + return -323; a += v; } } - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); break; #endif // CONFIG_FTP #ifdef CONFIG_HTTP @@ -7383,17 +7213,17 @@ 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 -322; + return -324; if (v != 0) { n = m_httpd.fromMemory((const uint8_t*)a,v); if (n < 0) return n; if (n != (ssize_t)v) - return -323; + return -325; a += v; } } - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); break; #endif // CONFIG_HTTP case 0xd2: // otasrv id 26, type std::string, coding byte[] @@ -7402,11 +7232,10 @@ 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 -324; + return -326; 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[] { @@ -7414,14 +7243,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 -325; + return -327; 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 -326; + return -328; a += v; } } @@ -7433,14 +7262,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 -327; + return -329; 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 -328; + return -330; a += v; } } @@ -7451,7 +7280,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 -329; + return -331; a += n; set_max_on_time(v); } @@ -7461,7 +7290,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 -332; a += n; set_threshold_off(v); } @@ -7471,7 +7300,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 -331; + return -333; a += n; set_threshold_on(v); } @@ -7481,14 +7310,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 -332; + return -334; a += n; set_dim_step(v); } break; case 0x133: // lightctrl id 38, type bool, coding 8bit if (a >= e) - return -333; + return -335; set_lightctrl(*a++); break; case 0x138: // pwm_freq id 39, type uint64_t, coding varint @@ -7496,7 +7325,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 -334; + return -336; a += n; set_pwm_freq(v); } @@ -7508,14 +7337,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 -335; + return -337; 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 -336; + return -338; a += v; } } @@ -7528,14 +7357,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 -337; + return -339; 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 -338; + return -340; a += v; } } @@ -7548,7 +7377,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 -339; + return -341; m_luafiles.emplace_back((const char*)a,v); a += v; } @@ -7561,14 +7390,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 -340; + return -342; 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 -341; + return -343; a += v; } } @@ -7579,7 +7408,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 -342; + return -344; a += s; break; } @@ -7587,7 +7416,7 @@ ssize_t NodeConfig::fromMemory(const void *b, ssize_t s) } assert((a-(const uint8_t *)b) == s); if (a > e) - return -343; + return -345; return a-(const uint8_t *)b; } @@ -7600,10 +7429,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 -344; + return -346; *a++ = 0x5; if ((e-a) < 4) - return -345; + return -347; write_u32(a,(uint32_t)m_magic); a += 4; } @@ -7611,67 +7440,67 @@ 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 -346; + return -348; *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 -347; + return -349; memcpy(a,m_nodename.data(),nodename_s); a += nodename_s; } // has pass_hash? - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 if (a >= e) - return -348; + return -350; *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 -349; + return -351; memcpy(a,m_pass_hash.data(),pass_hash_s); a += pass_hash_s; } // has cpu_freq? - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 if (a >= e) - return -350; + return -352; *a++ = 0x18; n = write_varint(a,e-a,m_cpu_freq); if (n <= 0) - return -351; + return -353; a += n; } // has station? - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'station': id=4, encoding=lenpfx, tag=0x22 if (a >= e) - return -352; + return -354; *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 -353; + return -355; n = m_station.toMemory(a,e-a); a += n; assert(n == station_ws); } // has softap? - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a if (a >= e) - return -354; + return -356; *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 -355; + return -357; n = m_softap.toMemory(a,e-a); a += n; assert(n == softap_ws); @@ -7679,13 +7508,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 -356; + return -358; *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 -357; + return -359; memcpy(a,x.data(),dns_server_s); a += dns_server_s; } @@ -7693,13 +7522,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 -358; + return -360; *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 -359; + return -361; memcpy(a,m_syslog_host.data(),syslog_host_s); a += syslog_host_s; } @@ -7707,13 +7536,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 -360; + return -362; *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 -361; + return -363; memcpy(a,m_sntp_server.data(),sntp_server_s); a += sntp_server_s; } @@ -7721,95 +7550,95 @@ 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 -362; + return -364; *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 -363; + return -365; memcpy(a,m_timezone.data(),timezone_s); a += timezone_s; } #ifdef CONFIG_MQTT // has mqtt? - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 if (a >= e) - return -364; + return -366; *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 -365; + return -367; n = m_mqtt.toMemory(a,e-a); a += n; assert(n == mqtt_ws); } #endif // CONFIG_MQTT // has dmesg_size? - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c if (3 > (e-a)) - return -366; + return -368; *a++ = 0x5c; write_u16(a,m_dmesg_size); a += 2; } #ifdef CONFIG_INFLUX // has influx? - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 if (a >= e) - return -367; + return -369; *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 -368; + return -370; n = m_influx.toMemory(a,e-a); a += n; assert(n == influx_ws); } #endif // CONFIG_INFLUX // has station2ap_time? - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 if (a >= e) - return -369; + return -371; *a++ = 0x68; n = write_varint(a,e-a,m_station2ap_time); if (n <= 0) - return -370; + return -372; a += n; } // has domainname? if (!m_domainname.empty()) { // 'domainname': id=15, encoding=lenpfx, tag=0x7a if (a >= e) - return -371; + return -373; *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 -372; + return -374; 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 -373; + return -375; *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 -374; + return -376; n = x.toMemory(a,e-a); a += n; assert(n == holidays_ws); @@ -7817,41 +7646,41 @@ 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 -375; + return -377; *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 -376; + return -378; n = x.toMemory(a,e-a); a += n; assert(n == at_actions_ws); } // has actions_enable? - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 if (2 > (e-a)) - return -377; + return -379; *a++ = 0x90; *a++ = 0x1; n = write_varint(a,e-a,m_actions_enable); if (n <= 0) - return -378; + return -380; a += n; } for (const auto &x : m_triggers) { // 'triggers': id=19, encoding=lenpfx, tag=0x9a if (2 > (e-a)) - return -379; + return -381; *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 -380; + return -382; n = x.toMemory(a,e-a); a += n; assert(n == triggers_ws); @@ -7859,14 +7688,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 -381; + return -383; *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 -382; + return -384; n = x.toMemory(a,e-a); a += n; assert(n == uart_ws); @@ -7875,24 +7704,24 @@ 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 -383; + return -385; *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 -384; + return -386; n = x.toMemory(a,e-a); a += n; assert(n == terminal_ws); } #endif // CONFIG_TERMSERV // has udp_ctrl_port? - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 if (4 > (e-a)) - return -385; + return -387; *a++ = 0xb4; *a++ = 0x1; write_u16(a,m_udp_ctrl_port); @@ -7901,30 +7730,30 @@ 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 -386; + return -388; *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 -387; + return -389; memcpy(a,x.data(),debugs_s); a += debugs_s; } #ifdef CONFIG_FTP // has ftpd? - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 if (2 > (e-a)) - return -388; + return -390; *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 -389; + return -391; n = m_ftpd.toMemory(a,e-a); a += n; assert(n == ftpd_ws); @@ -7932,48 +7761,48 @@ ssize_t NodeConfig::toMemory(uint8_t *b, ssize_t s) const #endif // CONFIG_FTP #ifdef CONFIG_HTTP // has httpd? - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca if (2 > (e-a)) - return -390; + return -392; *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 -391; + return -393; 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))) { + if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 if (2 > (e-a)) - return -392; + return -394; *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 -393; + return -395; 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 -394; + return -396; *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 -395; + return -397; n = x.toMemory(a,e-a); a += n; assert(n == timefuses_ws); @@ -7988,89 +7817,67 @@ 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 -396; + return -398; *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 -397; + return -399; n = x.toMemory(a,e-a); a += n; assert(n == statemachs_ws); } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. - // has threshold_off? - if (0 != (p_validbits & ((uint32_t)1U << 14))) { - // 'threshold_off': id=35, encoding=varint, tag=0x118 - if (2 > (e-a)) - return -398; - *a++ = 0x98; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_off); - if (n <= 0) - return -399; - a += n; - } - // has threshold_on? - if (0 != (p_validbits & ((uint32_t)1U << 15))) { - // 'threshold_on': id=36, encoding=varint, tag=0x120 - if (2 > (e-a)) - return -400; - *a++ = 0xa0; - *a++ = 0x2; - n = write_varint(a,e-a,m_threshold_on); - if (n <= 0) - return -401; - a += n; - } + // 'threshold_off' is deprecated. Therefore no data will be written. + // 'threshold_on' is deprecated. Therefore no data will be written. // has dim_step? - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { // 'dim_step': id=37, encoding=varint, tag=0x128 if (2 > (e-a)) - return -402; + return -400; *a++ = 0xa8; *a++ = 0x2; n = write_varint(a,e-a,m_dim_step); if (n <= 0) - return -403; + return -401; a += n; } // has lightctrl? - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 if (3 > (e-a)) - return -404; + return -402; *a++ = 0xb3; *a++ = 0x2; *a++ = m_lightctrl; } // has pwm_freq? - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 if (2 > (e-a)) - return -405; + return -403; *a++ = 0xb8; *a++ = 0x2; n = write_varint(a,e-a,m_pwm_freq); if (n <= 0) - return -406; + return -404; a += n; } #ifdef CONFIG_APP_PARAMS for (const auto &x : m_app_params) { // 'app_params': id=40, encoding=lenpfx, tag=0x142 if (2 > (e-a)) - return -407; + return -405; *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 -408; + return -406; n = x.toMemory(a,e-a); a += n; assert(n == app_params_ws); @@ -8080,14 +7887,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 -409; + return -407; *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 -410; + return -408; n = x.toMemory(a,e-a); a += n; assert(n == thresholds_ws); @@ -8097,14 +7904,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 -411; + return -409; *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 -412; + return -410; memcpy(a,x.data(),luafiles_s); a += luafiles_s; } @@ -8113,14 +7920,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 -413; + return -411; *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 -414; + return -412; n = x.toMemory(a,e-a); a += n; assert(n == owdevices_ws); @@ -8144,25 +7951,25 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,nodename_s); send_bytes(put,(const uint8_t*) m_nodename.data(),nodename_s); } - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 put(0x12); // 'pass_hash': id=2 size_t pass_hash_s = m_pass_hash.size(); send_varint(put,pass_hash_s); send_bytes(put,(const uint8_t*) m_pass_hash.data(),pass_hash_s); } - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 put(0x18); // 'cpu_freq': id=3 send_varint(put,m_cpu_freq); } - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'station': id=4, encoding=lenpfx, tag=0x22 put(0x22); // 'station': id=4 send_varint(put,m_station.calcSize()); m_station.toWire(put); } - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a put(0x2a); // 'softap': id=5 send_varint(put,m_softap.calcSize()); @@ -8197,27 +8004,27 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_bytes(put,(const uint8_t*) m_timezone.data(),timezone_s); } #ifdef CONFIG_MQTT - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 put(0x52); // 'mqtt': id=10 send_varint(put,m_mqtt.calcSize()); m_mqtt.toWire(put); } #endif // CONFIG_MQTT - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c put(0x5c); // 'dmesg_size': id=11 send_u16(put,m_dmesg_size); } #ifdef CONFIG_INFLUX - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 put(0x62); // 'influx': id=12 send_varint(put,m_influx.calcSize()); m_influx.toWire(put); } #endif // CONFIG_INFLUX - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 put(0x68); // 'station2ap_time': id=13 send_varint(put,m_station2ap_time); @@ -8243,7 +8050,7 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_varint(put,m_at_actions[x].calcSize()); m_at_actions[x].toWire(put); } - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 put(0x90); put(0x1); @@ -8272,7 +8079,7 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const m_terminal[x].toWire(put); } #endif // CONFIG_TERMSERV - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 put(0xb4); put(0x1); @@ -8287,7 +8094,7 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const send_bytes(put,(const uint8_t*) m_debugs[x].data(),debugs_s); } #ifdef CONFIG_FTP - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 put(0xc2); put(0x1); @@ -8296,7 +8103,7 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_FTP #ifdef CONFIG_HTTP - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca put(0xca); put(0x1); @@ -8304,7 +8111,7 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const m_httpd.toWire(put); } #endif // CONFIG_HTTP - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 put(0xd2); put(0x1); @@ -8331,31 +8138,21 @@ void NodeConfig::toWire(void (*put)(uint8_t)) const } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. + // 'threshold_off' is deprecated. Therefore no data will be written. + // 'threshold_on' is deprecated. Therefore no data will be written. 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 << 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 << 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 << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // 'lightctrl': id=38, encoding=8bit, tag=0x133 put(0xb3); put(0x2); put(m_lightctrl); } - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 put(0xb8); put(0x2); @@ -8414,25 +8211,25 @@ void NodeConfig::toString(std::string &put) const send_varint(put,nodename_s); put.append((const char *)(const uint8_t*) m_nodename.data(),nodename_s); } - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { // 'pass_hash': id=2, encoding=lenpfx, tag=0x12 put.push_back(0x12); // 'pass_hash': id=2 size_t pass_hash_s = m_pass_hash.size(); send_varint(put,pass_hash_s); put.append((const char *)(const uint8_t*) m_pass_hash.data(),pass_hash_s); } - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { // 'cpu_freq': id=3, encoding=varint, tag=0x18 put.push_back(0x18); // 'cpu_freq': id=3 send_varint(put,m_cpu_freq); } - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { // 'station': id=4, encoding=lenpfx, tag=0x22 put.push_back(0x22); // 'station': id=4 send_varint(put,m_station.calcSize()); m_station.toString(put); } - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { // 'softap': id=5, encoding=lenpfx, tag=0x2a put.push_back(0x2a); // 'softap': id=5 send_varint(put,m_softap.calcSize()); @@ -8467,27 +8264,27 @@ void NodeConfig::toString(std::string &put) const put.append((const char *)(const uint8_t*) m_timezone.data(),timezone_s); } #ifdef CONFIG_MQTT - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { // 'mqtt': id=10, encoding=lenpfx, tag=0x52 put.push_back(0x52); // 'mqtt': id=10 send_varint(put,m_mqtt.calcSize()); m_mqtt.toString(put); } #endif // CONFIG_MQTT - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { // 'dmesg_size': id=11, encoding=16bit, tag=0x5c put.push_back(0x5c); // 'dmesg_size': id=11 send_u16(put,m_dmesg_size); } #ifdef CONFIG_INFLUX - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { // 'influx': id=12, encoding=lenpfx, tag=0x62 put.push_back(0x62); // 'influx': id=12 send_varint(put,m_influx.calcSize()); m_influx.toString(put); } #endif // CONFIG_INFLUX - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { // 'station2ap_time': id=13, encoding=varint, tag=0x68 put.push_back(0x68); // 'station2ap_time': id=13 send_varint(put,m_station2ap_time); @@ -8513,7 +8310,7 @@ void NodeConfig::toString(std::string &put) const send_varint(put,m_at_actions[x].calcSize()); m_at_actions[x].toString(put); } - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { // 'actions_enable': id=18, encoding=varint, tag=0x90 put.push_back(0x90); put.push_back(0x1); @@ -8542,7 +8339,7 @@ void NodeConfig::toString(std::string &put) const m_terminal[x].toString(put); } #endif // CONFIG_TERMSERV - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { // 'udp_ctrl_port': id=22, encoding=16bit, tag=0xb4 put.push_back(0xb4); put.push_back(0x1); @@ -8557,7 +8354,7 @@ void NodeConfig::toString(std::string &put) const put.append((const char *)(const uint8_t*) m_debugs[x].data(),debugs_s); } #ifdef CONFIG_FTP - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { // 'ftpd': id=24, encoding=lenpfx, tag=0xc2 put.push_back(0xc2); put.push_back(0x1); @@ -8566,7 +8363,7 @@ void NodeConfig::toString(std::string &put) const } #endif // CONFIG_FTP #ifdef CONFIG_HTTP - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { // 'httpd': id=25, encoding=lenpfx, tag=0xca put.push_back(0xca); put.push_back(0x1); @@ -8574,7 +8371,7 @@ void NodeConfig::toString(std::string &put) const m_httpd.toString(put); } #endif // CONFIG_HTTP - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (!m_otasrv.empty()) { // 'otasrv': id=26, encoding=lenpfx, tag=0xd2 put.push_back(0xd2); put.push_back(0x1); @@ -8601,31 +8398,21 @@ void NodeConfig::toString(std::string &put) const } #endif // CONFIG_STATEMACHINES // 'max_on_time' is deprecated. Therefore no data will be written. + // 'threshold_off' is deprecated. Therefore no data will be written. + // 'threshold_on' is deprecated. Therefore no data will be written. 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 << 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 << 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 << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { // '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 << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { // 'pwm_freq': id=39, encoding=varint, tag=0x138 put.push_back(0xb8); put.push_back(0x2); @@ -9051,21 +8838,21 @@ size_t NodeConfig::calcSize() const r += nodename_s + wiresize(nodename_s) + 1 /* tag(nodename) 0x8 */; } // optional bytes pass_hash, id 2 - if (0 != (p_validbits & ((uint32_t)1U << 1))) { + if (!m_pass_hash.empty()) { size_t pass_hash_s = m_pass_hash.size(); r += pass_hash_s + wiresize(pass_hash_s) + 1 /* tag(pass_hash) 0x10 */; } // optional unsigned cpu_freq, id 3 - if (0 != (p_validbits & ((uint32_t)1U << 2))) { + if (0 != (p_validbits & ((uint32_t)1U << 1))) { r += wiresize((varint_t)m_cpu_freq) + 1 /* tag(cpu_freq) 0x18 */; } // optional WifiConfig station, id 4 - if (0 != (p_validbits & ((uint32_t)1U << 3))) { + if (0 != (p_validbits & ((uint32_t)1U << 2))) { size_t station_s = m_station.calcSize(); r += station_s + wiresize(station_s) + 1 /* tag(station) 0x20 */; } // optional WifiConfig softap, id 5 - if (0 != (p_validbits & ((uint32_t)1U << 4))) { + if (0 != (p_validbits & ((uint32_t)1U << 3))) { size_t softap_s = m_softap.calcSize(); r += softap_s + wiresize(softap_s) + 1 /* tag(softap) 0x28 */; } @@ -9095,24 +8882,24 @@ size_t NodeConfig::calcSize() const } #ifdef CONFIG_MQTT // optional MQTT mqtt, id 10 - if (0 != (p_validbits & ((uint32_t)1U << 5))) { + if (0 != (p_validbits & ((uint32_t)1U << 4))) { size_t mqtt_s = m_mqtt.calcSize(); r += mqtt_s + wiresize(mqtt_s) + 1 /* tag(mqtt) 0x50 */; } #endif // CONFIG_MQTT // optional fixed16 dmesg_size, id 11 - if (0 != (p_validbits & ((uint32_t)1U << 6))) { + if (0 != (p_validbits & ((uint32_t)1U << 5))) { r += 3; } #ifdef CONFIG_INFLUX // optional Influx influx, id 12 - if (0 != (p_validbits & ((uint32_t)1U << 7))) { + if (0 != (p_validbits & ((uint32_t)1U << 6))) { size_t influx_s = m_influx.calcSize(); r += influx_s + wiresize(influx_s) + 1 /* tag(influx) 0x60 */; } #endif // CONFIG_INFLUX // optional unsigned station2ap_time, id 13 - if (0 != (p_validbits & ((uint32_t)1U << 8))) { + if (0 != (p_validbits & ((uint32_t)1U << 7))) { r += wiresize((varint_t)m_station2ap_time) + 1 /* tag(station2ap_time) 0x68 */; } // optional string domainname, id 15 @@ -9135,7 +8922,7 @@ size_t NodeConfig::calcSize() const r += s + 2 /* tag(at_actions) 0x88 */; } // optional unsigned actions_enable, id 18 - if (0 != (p_validbits & ((uint32_t)1U << 9))) { + if (0 != (p_validbits & ((uint32_t)1U << 8))) { r += wiresize((varint_t)m_actions_enable) + 2 /* tag(actions_enable) 0x90 */; } // repeated Trigger triggers, id 19 @@ -9162,7 +8949,7 @@ size_t NodeConfig::calcSize() const } #endif // CONFIG_TERMSERV // optional fixed16 udp_ctrl_port, id 22 - if (0 != (p_validbits & ((uint32_t)1U << 10))) { + if (0 != (p_validbits & ((uint32_t)1U << 9))) { r += 4; } // repeated string debugs, id 23 @@ -9176,20 +8963,20 @@ size_t NodeConfig::calcSize() const } #ifdef CONFIG_FTP // optional FtpHttpConfig ftpd, id 24 - if (0 != (p_validbits & ((uint32_t)1U << 11))) { + if (0 != (p_validbits & ((uint32_t)1U << 10))) { size_t ftpd_s = m_ftpd.calcSize(); r += ftpd_s + wiresize(ftpd_s) + 2 /* tag(ftpd) 0xc0 */; } #endif // CONFIG_FTP #ifdef CONFIG_HTTP // optional FtpHttpConfig httpd, id 25 - if (0 != (p_validbits & ((uint32_t)1U << 12))) { + if (0 != (p_validbits & ((uint32_t)1U << 11))) { size_t httpd_s = m_httpd.calcSize(); r += httpd_s + wiresize(httpd_s) + 2 /* tag(httpd) 0xc8 */; } #endif // CONFIG_HTTP // optional string otasrv, id 26 - if (0 != (p_validbits & ((uint32_t)1U << 13))) { + if (!m_otasrv.empty()) { size_t otasrv_s = m_otasrv.size(); r += otasrv_s + wiresize(otasrv_s) + 2 /* tag(otasrv) 0xd0 */; } @@ -9216,24 +9003,18 @@ 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 << 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 << 15))) { - r += wiresize((varint_t)m_threshold_on) + 2 /* tag(threshold_on) 0x120 */; - } + // deprecated optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_on, id 36 // optional unsigned dim_step, id 37 - if (0 != (p_validbits & ((uint32_t)1U << 16))) { + if (0 != (p_validbits & ((uint32_t)1U << 14))) { r += wiresize((varint_t)m_dim_step) + 2 /* tag(dim_step) 0x128 */; } // optional bool lightctrl, id 38 - if (0 != (p_validbits & ((uint32_t)1U << 17))) { + if (0 != (p_validbits & ((uint32_t)1U << 15))) { r += 3; } // optional unsigned pwm_freq, id 39 - if (0 != (p_validbits & ((uint32_t)1U << 18))) { + if (0 != (p_validbits & ((uint32_t)1U << 16))) { r += wiresize((varint_t)m_pwm_freq) + 2 /* tag(pwm_freq) 0x138 */; } #ifdef CONFIG_APP_PARAMS @@ -9421,8 +9202,6 @@ int NodeConfig::setByName(const char *name, const char *value) return 0; } int r = parse_ascii_bytes(m_pass_hash,value); - if (r > 0) - p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == strcmp(name,"cpu_freq")) { @@ -9432,7 +9211,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_cpu_freq,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); return r; } if (0 == memcmp(name,"station",7)) { @@ -9440,7 +9219,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_station(); return 0; } else if (name[7] == '.') { - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); return m_station.setByName(name+8,value); } } @@ -9449,7 +9228,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_softap(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); return m_softap.setByName(name+7,value); } } @@ -9469,16 +9248,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -415; + return -413; if (m_dns_server.size() <= x) - return -416; + return -414; if ((idxe[1] == 0) && (value == 0)) { m_dns_server.erase(m_dns_server.begin()+x); return 0; } } if (idxe[1] != 0) - return -417; + return -415; m_dns_server[x] = value; return m_dns_server[x].size(); } @@ -9516,7 +9295,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_mqtt(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); return m_mqtt.setByName(name+5,value); } } @@ -9528,7 +9307,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_dmesg_size,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); return r; } #ifdef CONFIG_INFLUX @@ -9537,7 +9316,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_influx(); return 0; } else if (name[6] == '.') { - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); return m_influx.setByName(name+7,value); } } @@ -9549,7 +9328,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_station2ap_time,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); return r; } if (0 == strcmp(name,"domainname")) { @@ -9577,16 +9356,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -418; + return -416; if (m_holidays.size() <= x) - return -419; + return -417; if ((idxe[1] == 0) && (value == 0)) { m_holidays.erase(m_holidays.begin()+x); return 0; } } if (idxe[1] != '.') - return -420; + return -418; return m_holidays[x].setByName(idxe+2,value); } } @@ -9606,16 +9385,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -421; + return -419; if (m_at_actions.size() <= x) - return -422; + return -420; if ((idxe[1] == 0) && (value == 0)) { m_at_actions.erase(m_at_actions.begin()+x); return 0; } } if (idxe[1] != '.') - return -423; + return -421; return m_at_actions[x].setByName(idxe+2,value); } } @@ -9626,7 +9405,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u64(&m_actions_enable,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); return r; } if (0 == memcmp(name,"triggers",8)) { @@ -9645,16 +9424,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -424; + return -422; if (m_triggers.size() <= x) - return -425; + return -423; if ((idxe[1] == 0) && (value == 0)) { m_triggers.erase(m_triggers.begin()+x); return 0; } } if (idxe[1] != '.') - return -426; + return -424; return m_triggers[x].setByName(idxe+2,value); } } @@ -9674,16 +9453,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+5,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+5))) - return -427; + return -425; if (m_uart.size() <= x) - return -428; + return -426; if ((idxe[1] == 0) && (value == 0)) { m_uart.erase(m_uart.begin()+x); return 0; } } if (idxe[1] != '.') - return -429; + return -427; return m_uart[x].setByName(idxe+2,value); } } @@ -9704,16 +9483,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -430; + return -428; if (m_terminal.size() <= x) - return -431; + return -429; if ((idxe[1] == 0) && (value == 0)) { m_terminal.erase(m_terminal.begin()+x); return 0; } } if (idxe[1] != '.') - return -432; + return -430; return m_terminal[x].setByName(idxe+2,value); } } @@ -9725,7 +9504,7 @@ int NodeConfig::setByName(const char *name, const char *value) } int r = parse_ascii_u16(&m_udp_ctrl_port,value); if (r > 0) - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); return r; } if (0 == memcmp(name,"debugs",6)) { @@ -9744,16 +9523,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+7,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+7))) - return -433; + return -431; if (m_debugs.size() <= x) - return -434; + return -432; if ((idxe[1] == 0) && (value == 0)) { m_debugs.erase(m_debugs.begin()+x); return 0; } } if (idxe[1] != 0) - return -435; + return -433; m_debugs[x] = value; return m_debugs[x].size(); } @@ -9764,7 +9543,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_ftpd(); return 0; } else if (name[4] == '.') { - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); return m_ftpd.setByName(name+5,value); } } @@ -9775,7 +9554,7 @@ int NodeConfig::setByName(const char *name, const char *value) clear_httpd(); return 0; } else if (name[5] == '.') { - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); return m_httpd.setByName(name+6,value); } } @@ -9787,8 +9566,6 @@ int NodeConfig::setByName(const char *name, const char *value) } 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)) { @@ -9807,16 +9584,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -436; + return -434; if (m_timefuses.size() <= x) - return -437; + return -435; if ((idxe[1] == 0) && (value == 0)) { m_timefuses.erase(m_timefuses.begin()+x); return 0; } } if (idxe[1] != '.') - return -438; + return -436; return m_timefuses[x].setByName(idxe+2,value); } } @@ -9837,16 +9614,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -439; + return -437; if (m_statemachs.size() <= x) - return -440; + return -438; if ((idxe[1] == 0) && (value == 0)) { m_statemachs.erase(m_statemachs.begin()+x); return 0; } } if (idxe[1] != '.') - return -441; + return -439; return m_statemachs[x].setByName(idxe+2,value); } } @@ -9866,7 +9643,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 << 14); + p_validbits |= ((uint32_t)1U << 12); return r; } if (0 == strcmp(name,"threshold_on")) { @@ -9876,7 +9653,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 << 15); + p_validbits |= ((uint32_t)1U << 13); return r; } if (0 == strcmp(name,"dim_step")) { @@ -9886,7 +9663,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 << 16); + p_validbits |= ((uint32_t)1U << 14); return r; } if (0 == strcmp(name,"lightctrl")) { @@ -9896,7 +9673,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 << 17); + p_validbits |= ((uint32_t)1U << 15); return r; } if (0 == strcmp(name,"pwm_freq")) { @@ -9906,7 +9683,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 << 18); + p_validbits |= ((uint32_t)1U << 16); return r; } #ifdef CONFIG_APP_PARAMS @@ -9926,16 +9703,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -442; + return -440; if (m_app_params.size() <= x) - return -443; + return -441; if ((idxe[1] == 0) && (value == 0)) { m_app_params.erase(m_app_params.begin()+x); return 0; } } if (idxe[1] != '.') - return -444; + return -442; return m_app_params[x].setByName(idxe+2,value); } } @@ -9957,16 +9734,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+11,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+11))) - return -445; + return -443; if (m_thresholds.size() <= x) - return -446; + return -444; if ((idxe[1] == 0) && (value == 0)) { m_thresholds.erase(m_thresholds.begin()+x); return 0; } } if (idxe[1] != '.') - return -447; + return -445; return m_thresholds[x].setByName(idxe+2,value); } } @@ -9988,16 +9765,16 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+9,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+9))) - return -448; + return -446; if (m_luafiles.size() <= x) - return -449; + return -447; if ((idxe[1] == 0) && (value == 0)) { m_luafiles.erase(m_luafiles.begin()+x); return 0; } } if (idxe[1] != 0) - return -450; + return -448; m_luafiles[x] = value; return m_luafiles[x].size(); } @@ -10020,124 +9797,103 @@ int NodeConfig::setByName(const char *name, const char *value) } else { x = strtoul(name+10,&idxe,0); if ((idxe[0] != ']') || (idxe == (name+10))) - return -451; + return -449; if (m_owdevices.size() <= x) - return -452; + return -450; if ((idxe[1] == 0) && (value == 0)) { m_owdevices.erase(m_owdevices.begin()+x); return 0; } } if (idxe[1] != '.') - return -453; + return -451; return m_owdevices[x].setByName(idxe+2,value); } } #endif // CONFIG_ONEWIRE - return -454; + return -452; } -Message *NodeConfig::p_getMember(const char *s, const char *e) +Message *NodeConfig::p_getMember(const char *s, unsigned n) { - if (0 == strncmp("station",s,e-s)) + // caller guarantee: s[n] == '.' + if ((n == 7) && (0 == memcmp("station",s,7))) return &m_station; - if (0 == strncmp("softap",s,e-s)) + if ((n == 6) && (0 == memcmp("softap",s,6))) return &m_softap; #ifdef CONFIG_MQTT - if (0 == strncmp("mqtt",s,e-s)) + if ((n == 4) && (0 == memcmp("mqtt",s,4))) return &m_mqtt; #endif // CONFIG_MQTT #ifdef CONFIG_INFLUX - if (0 == strncmp("influx",s,e-s)) + if ((n == 6) && (0 == memcmp("influx",s,6))) return &m_influx; #endif // CONFIG_INFLUX #ifdef CONFIG_FTP - if (0 == strncmp("ftpd",s,e-s)) + if ((n == 4) && (0 == memcmp("ftpd",s,4))) return &m_ftpd; #endif // CONFIG_FTP #ifdef CONFIG_HTTP - if (0 == strncmp("httpd",s,e-s)) + if ((n == 5) && (0 == memcmp("httpd",s,5))) return &m_httpd; #endif // CONFIG_HTTP return 0; } -Message *NodeConfig::p_getMember(const char *s, const char *e, unsigned x) +Message *NodeConfig::p_getMember(const char *s, unsigned n, unsigned x) { - if (0 == strncmp("holidays[",s,e-s)) { + // caller guarantee: s[n] == '[' + if ((n == 8) && (0 == memcmp("holidays",s,8))) { if (x < m_holidays.size()) return &m_holidays[x]; - return 0; - } - if (0 == strncmp("at_actions[",s,e-s)) { + } else if ((n == 10) && (0 == memcmp("at_actions",s,10))) { if (x < m_at_actions.size()) return &m_at_actions[x]; - return 0; - } - if (0 == strncmp("triggers[",s,e-s)) { + } else if ((n == 8) && (0 == memcmp("triggers",s,8))) { if (x < m_triggers.size()) return &m_triggers[x]; - return 0; - } - if (0 == strncmp("uart[",s,e-s)) { + } else if ((n == 4) && (0 == memcmp("uart",s,4))) { if (x < m_uart.size()) return &m_uart[x]; - return 0; - } - #ifdef CONFIG_TERMSERV - if (0 == strncmp("terminal[",s,e-s)) { + #ifdef CONFIG_TERMSERV + } else if ((n == 8) && (0 == memcmp("terminal",s,8))) { if (x < m_terminal.size()) return &m_terminal[x]; - return 0; - } - #endif // CONFIG_TERMSERV - if (0 == strncmp("timefuses[",s,e-s)) { + #endif // CONFIG_TERMSERV + } else if ((n == 9) && (0 == memcmp("timefuses",s,9))) { if (x < m_timefuses.size()) return &m_timefuses[x]; - return 0; - } - #ifdef CONFIG_SIGNAL_PROC - if (0 == strncmp("signals[",s,e-s)) { + #ifdef CONFIG_SIGNAL_PROC + } else if ((n == 7) && (0 == memcmp("signals",s,7))) { if (x < m_signals.size()) return &m_signals[x]; - return 0; - } - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - if (0 == strncmp("functions[",s,e-s)) { + #endif // CONFIG_SIGNAL_PROC + #ifdef CONFIG_SIGNAL_PROC + } else if ((n == 9) && (0 == memcmp("functions",s,9))) { if (x < m_functions.size()) return &m_functions[x]; - return 0; - } - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - if (0 == strncmp("statemachs[",s,e-s)) { + #endif // CONFIG_SIGNAL_PROC + #ifdef CONFIG_STATEMACHINES + } else if ((n == 10) && (0 == memcmp("statemachs",s,10))) { if (x < m_statemachs.size()) return &m_statemachs[x]; - return 0; - } - #endif // CONFIG_STATEMACHINES - #ifdef CONFIG_APP_PARAMS - if (0 == strncmp("app_params[",s,e-s)) { + #endif // CONFIG_STATEMACHINES + #ifdef CONFIG_APP_PARAMS + } else if ((n == 10) && (0 == memcmp("app_params",s,10))) { if (x < m_app_params.size()) return &m_app_params[x]; - return 0; - } - #endif // CONFIG_APP_PARAMS - #ifdef CONFIG_THRESHOLDS - if (0 == strncmp("thresholds[",s,e-s)) { + #endif // CONFIG_APP_PARAMS + #ifdef CONFIG_THRESHOLDS + } else if ((n == 10) && (0 == memcmp("thresholds",s,10))) { if (x < m_thresholds.size()) return &m_thresholds[x]; - return 0; - } - #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_ONEWIRE - if (0 == strncmp("owdevices[",s,e-s)) { + #endif // CONFIG_THRESHOLDS + #ifdef CONFIG_ONEWIRE + } else if ((n == 9) && (0 == memcmp("owdevices",s,9))) { if (x < m_owdevices.size()) return &m_owdevices[x]; - return 0; + #endif // CONFIG_ONEWIRE } - #endif // CONFIG_ONEWIRE return 0; } diff --git a/components/wfc/swcfg_pc.h b/components/wfc/swcfg_pc.h index 77bd7dc..868054d 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -39,6 +39,7 @@ * options from common: * BaseClass : "Message" * getMember : "getMember" + * SortMembers : "size" * wfclib : "extern" * * options from defaults: @@ -67,7 +68,6 @@ * namespace : "" * SetByName : "setByName" * SetPrefix : "set_" - * SortMembers : "id" * stringtype : "std::string" * toJSON : "toJSON" * toMemory : "toMemory" @@ -216,10 +216,14 @@ size_t parse_ascii_sigtype_t(sigtype_t *, const char *); typedef uint16_t uartcfg_t; typedef uint8_t eventcfg_t; + + class WifiConfig : public Message { public: - WifiConfig(); + WifiConfig() + { + } bool operator != (const WifiConfig &r) const; bool operator == (const WifiConfig &r) const; @@ -432,32 +436,36 @@ class WifiConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string ssid, id 1 std::string m_ssid; //! string pass, id 2 std::string m_pass; //! bytes mac, id 3 std::string m_mac; - //! bool activate, id 4 - bool m_activate; //! fixed32 addr4, id 5 - uint32_t m_addr4; - //! fixed8 netmask4, id 6 - uint8_t m_netmask4; + uint32_t m_addr4 = 0; //! fixed32 gateway4, id 7 - uint32_t m_gateway4; + uint32_t m_gateway4 = 0; + //! bool activate, id 4 + bool m_activate = false; + //! fixed8 netmask4, id 6 + uint8_t m_netmask4 = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class MQTT : public Message { public: - MQTT(); + MQTT() + { + } bool operator != (const MQTT &r) const; bool operator == (const MQTT &r) const; @@ -669,12 +677,10 @@ class MQTT : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string uri, id 1 std::string m_uri; - //! bool enable, id 2 - bool m_enable; //! string username, id 3 std::string m_username; //! string password, id 4 @@ -682,17 +688,23 @@ class MQTT : public Message //! string subscribtions, id 5 std::vector m_subscribtions; //! uint16 keepalive, id 6 - uint16_t m_keepalive; + uint16_t m_keepalive = 60; + //! bool enable, id 2 + bool m_enable = false; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Date : public Message { public: - Date(); + Date() + { + } bool operator != (const Date &r) const; bool operator == (const Date &r) const; @@ -872,27 +884,31 @@ class Date : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); + //! fixed16 year, id 3 + uint16_t m_year = 0; //! fixed8 day, id 1 - uint8_t m_day; + uint8_t m_day = 0; //! fixed8 month, id 2 - uint8_t m_month; - //! fixed16 year, id 3 - uint16_t m_year; + uint8_t m_month = 0; //! fixed8 endday, id 4 - uint8_t m_endday; + uint8_t m_endday = 0; //! fixed8 endmonth, id 5 - uint8_t m_endmonth; + uint8_t m_endmonth = 0; //! fixed8 endyear, id 6 - uint8_t m_endyear; + uint8_t m_endyear = 0; }; + + class AtAction : public Message { public: - AtAction(); + AtAction() + { + } bool operator != (const AtAction &r) const; bool operator == (const AtAction &r) const; @@ -1037,26 +1053,30 @@ class AtAction : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! WeekDay day, id 1 - WeekDay m_day; - //! unsigned min_of_day, id 2 - uint64_t m_min_of_day; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string action, id 3 std::string m_action; + //! WeekDay day, id 1 + WeekDay m_day = Sunday; + //! unsigned min_of_day, id 2 + uint64_t m_min_of_day = 0; //! bool enable, id 4 - bool m_enable; + bool m_enable = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class Influx : public Message { public: - Influx(); + Influx() + { + } bool operator != (const Influx &r) const; bool operator == (const Influx &r) const; @@ -1225,24 +1245,27 @@ class Influx : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string hostname, id 1 std::string m_hostname; - //! fixed16 port, id 2 - uint16_t m_port; //! string measurement, id 3 std::string m_measurement; - // omitted obsolete member interval //! string database, id 5 std::string m_database; + //! fixed16 port, id 2 + uint16_t m_port = 0; }; + + class UartSettings : public Message { public: - UartSettings(); + UartSettings() + { + } bool operator != (const UartSettings &r) const; bool operator == (const UartSettings &r) const; @@ -1446,30 +1469,34 @@ class UartSettings : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! uint8 port, id 1 - uint8_t m_port; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! unsigned baudrate, id 2 - uint64_t m_baudrate; - //! uartcfg_t config, id 3 - uartcfg_t m_config; - //! fixed8 rx_thresh, id 4 - uint8_t m_rx_thresh; + uint64_t m_baudrate = 0; //! unsigned tx_bufsize, id 6 - uint64_t m_tx_bufsize; + uint64_t m_tx_bufsize = 0; //! unsigned rx_bufsize, id 7 - uint64_t m_rx_bufsize; + uint64_t m_rx_bufsize = 0; + //! uartcfg_t config, id 3 + uartcfg_t m_config = 5; + //! uint8 port, id 1 + uint8_t m_port = 0; + //! fixed8 rx_thresh, id 4 + uint8_t m_rx_thresh = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FtpHttpConfig : public Message { public: - FtpHttpConfig(); + FtpHttpConfig() + { + } bool operator != (const FtpHttpConfig &r) const; bool operator == (const FtpHttpConfig &r) const; @@ -1629,26 +1656,30 @@ class FtpHttpConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! fixed16 port, id 1 - uint16_t m_port; - //! bool start, id 2 - bool m_start; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string root, id 3 std::string m_root; //! string uploaddir, id 4 std::string m_uploaddir; + //! fixed16 port, id 1 + uint16_t m_port = 0; + //! bool start, id 2 + bool m_start = true; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class TerminalConfig : public Message { public: - TerminalConfig(); + TerminalConfig() + { + } bool operator != (const TerminalConfig &r) const; bool operator == (const TerminalConfig &r) const; @@ -1782,24 +1813,25 @@ class TerminalConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! sint8 uart_rx, id 1 - int8_t m_uart_rx; - //! sint8 uart_tx, id 2 - int8_t m_uart_tx; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 3 std::string m_name; - - private: - uint8_t p_validbits; + //! sint8 uart_rx, id 1 + int8_t m_uart_rx = -1; + //! sint8 uart_tx, id 2 + int8_t m_uart_tx = -1; }; + + class Trigger : public Message { public: - Trigger(); + Trigger() + { + } bool operator != (const Trigger &r) const; bool operator == (const Trigger &r) const; @@ -1923,22 +1955,23 @@ class Trigger : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string event, id 1 std::string m_event; //! string action, id 2 std::vector m_action; - - private: - uint8_t p_validbits; }; + + class AppParam : public Message { public: - AppParam(); + AppParam() + { + } bool operator != (const AppParam &r) const; bool operator == (const AppParam &r) const; @@ -2116,28 +2149,32 @@ class AppParam : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string key, id 1 std::string m_key; - //! unsigned uValue, id 2 - uint64_t m_uValue; //! string sValue, id 3 std::string m_sValue; + //! unsigned uValue, id 2 + uint64_t m_uValue = 0; //! signed dValue, id 4 - int64_t m_dValue; + int64_t m_dValue = 0; //! double fValue, id 5 - double m_fValue; + double m_fValue = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class EventTimer : public Message { public: - EventTimer(); + EventTimer() + { + } bool operator != (const EventTimer &r) const; bool operator == (const EventTimer &r) const; @@ -2279,24 +2316,28 @@ class EventTimer : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! unsigned time, id 2 - uint64_t m_time; + uint64_t m_time = 0; //! eventcfg_t config, id 3 - eventcfg_t m_config; + eventcfg_t m_config = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class FunctionConfig : public Message { public: - FunctionConfig(); + FunctionConfig() + { + } bool operator != (const FunctionConfig &r) const; bool operator == (const FunctionConfig &r) const; @@ -2446,24 +2487,25 @@ class FunctionConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! string func, id 2 std::string m_func; //! string params, id 3 std::vector m_params; - - private: - uint8_t p_validbits; }; + + class SignalConfig : public Message { public: - SignalConfig(); + SignalConfig() + { + } bool operator != (const SignalConfig &r) const; bool operator == (const SignalConfig &r) const; @@ -2605,21 +2647,25 @@ class SignalConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; - //! sigtype_t type, id 2 - sigtype_t m_type; //! string iv, id 3 std::string m_iv; + //! sigtype_t type, id 2 + sigtype_t m_type = st_invalid; }; + + class OwDeviceConfig : public Message { public: - OwDeviceConfig(); + OwDeviceConfig() + { + } bool operator != (const OwDeviceConfig &r) const; bool operator == (const OwDeviceConfig &r) const; @@ -2735,22 +2781,26 @@ class OwDeviceConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); - //! fixed64 id, id 1 - uint64_t m_id; + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 2 std::string m_name; + //! fixed64 id, id 1 + uint64_t m_id = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class StateConfig : public Message { public: - StateConfig(); + StateConfig() + { + } bool operator != (const StateConfig &r) const; bool operator == (const StateConfig &r) const; @@ -2872,22 +2922,23 @@ class StateConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! Trigger conds, id 2 std::vector m_conds; - - private: - uint8_t p_validbits; }; + + class StateMachineConfig : public Message { public: - StateMachineConfig(); + StateMachineConfig() + { + } bool operator != (const StateMachineConfig &r) const; bool operator == (const StateMachineConfig &r) const; @@ -3025,26 +3076,50 @@ class StateMachineConfig : public Message //! Function to get mutable access to all elements of states. std::vector *mutable_states(); + // optional bool persistent, id 4 + /*! + * Function for querying if persistent has been set. + * @return true if persistent is set. + */ + bool has_persistent() const; + //! Function to reset persistent to its default/unset value. + void clear_persistent(); + //! Get value of persistent. + bool persistent() const; + //! Set persistent using a constant reference + void set_persistent(bool v); + /*! + * Provide mutable access to persistent. + * @return pointer to member variable of persistent. + */ + bool *mutable_persistent(); + protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! uint8 ini_st, id 2 - uint8_t m_ini_st; + uint8_t m_ini_st = 0; + //! bool persistent, id 4 + bool m_persistent = false; //! StateConfig states, id 3 std::vector m_states; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class ThresholdConfig : public Message { public: - ThresholdConfig(); + ThresholdConfig() + { + } bool operator != (const ThresholdConfig &r) const; bool operator == (const ThresholdConfig &r) const; @@ -3178,24 +3253,28 @@ class ThresholdConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string name, id 1 std::string m_name; //! float low, id 2 - float m_low; + float m_low = 0; //! float high, id 3 - float m_high; + float m_high = 0; private: - uint8_t p_validbits; + uint8_t p_validbits = 0; }; + + class LuaConfig : public Message { public: - LuaConfig(); + LuaConfig() + { + } bool operator != (const LuaConfig &r) const; bool operator == (const LuaConfig &r) const; @@ -3319,8 +3398,8 @@ class LuaConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); //! string init_scripts, id 1 std::vector m_init_scripts; //! string compile_files, id 2 @@ -3328,10 +3407,14 @@ class LuaConfig : public Message }; + + class NodeConfig : public Message { public: - NodeConfig(); + NodeConfig() + { + } bool operator != (const NodeConfig &r) const; bool operator == (const NodeConfig &r) const; @@ -4082,7 +4165,7 @@ class NodeConfig : public Message //! Get value of max_on_time. uint64_t max_on_time() const __attribute__ ((deprecated)); - // optional unsigned threshold_off, id 35 + // deprecated optional unsigned threshold_off, id 35 /*! * Function for querying if threshold_off has been set. * @return true if threshold_off is set. @@ -4091,16 +4174,9 @@ class NodeConfig : public Message //! Function to reset threshold_off to its default/unset value. void clear_threshold_off(); //! Get value of threshold_off. - uint64_t threshold_off() const; - //! Set threshold_off using a constant reference - void set_threshold_off(uint64_t v); - /*! - * Provide mutable access to threshold_off. - * @return pointer to member variable of threshold_off. - */ - uint64_t *mutable_threshold_off(); + uint64_t threshold_off() const __attribute__ ((deprecated)); - // optional unsigned threshold_on, id 36 + // deprecated optional unsigned threshold_on, id 36 /*! * Function for querying if threshold_on has been set. * @return true if threshold_on is set. @@ -4109,14 +4185,7 @@ class NodeConfig : public Message //! Function to reset threshold_on to its default/unset value. void clear_threshold_on(); //! Get value of threshold_on. - uint64_t threshold_on() const; - //! Set threshold_on using a constant reference - void set_threshold_on(uint64_t v); - /*! - * Provide mutable access to threshold_on. - * @return pointer to member variable of threshold_on. - */ - uint64_t *mutable_threshold_on(); + uint64_t threshold_on() const __attribute__ ((deprecated)); // optional unsigned dim_step, id 37 /*! @@ -4280,23 +4349,27 @@ class NodeConfig : public Message protected: - Message *p_getMember(const char *s, const char *e); - Message *p_getMember(const char *s, const char *e, unsigned i); + Message *p_getMember(const char *s, unsigned n); + Message *p_getMember(const char *s, unsigned n, unsigned i); // deprecated unsigned max_on_time, id 34 //! Set max_on_time using a constant reference void set_max_on_time(uint64_t v); - //! fixed32 magic, id 0 - uint32_t m_magic; + // deprecated unsigned threshold_off, id 35 + //! Set threshold_off using a constant reference + void set_threshold_off(uint64_t v); + // deprecated unsigned threshold_on, id 36 + //! Set threshold_on using a constant reference + void set_threshold_on(uint64_t v); //! string nodename, id 1 std::string m_nodename; //! bytes pass_hash, id 2 std::string m_pass_hash; - //! unsigned cpu_freq, id 3 - uint64_t m_cpu_freq; - //! WifiConfig station, id 4 - WifiConfig m_station; - //! WifiConfig softap, id 5 - WifiConfig m_softap; + //! string otasrv, id 26 + std::string m_otasrv; + #ifdef CONFIG_LUA + //! string luafiles, id 42 + std::vector m_luafiles; + #endif // CONFIG_LUA //! string dns_server, id 6 std::vector m_dns_server; //! string syslog_host, id 7 @@ -4305,72 +4378,38 @@ class NodeConfig : public Message std::string m_sntp_server; //! string timezone, id 9 std::string m_timezone; - #ifdef CONFIG_MQTT - //! MQTT mqtt, id 10 - MQTT m_mqtt; - #endif // CONFIG_MQTT - //! fixed16 dmesg_size, id 11 - uint16_t m_dmesg_size; - #ifdef CONFIG_INFLUX - //! Influx influx, id 12 - Influx m_influx; - #endif // CONFIG_INFLUX - //! unsigned station2ap_time, id 13 - uint64_t m_station2ap_time; - //! string domainname, id 15 - std::string m_domainname; - //! Date holidays, id 16 - std::vector m_holidays; - //! AtAction at_actions, id 17 - std::vector m_at_actions; - //! unsigned actions_enable, id 18 - uint64_t m_actions_enable; - //! Trigger triggers, id 19 - std::vector m_triggers; - //! UartSettings uart, id 20 - std::vector m_uart; - #ifdef CONFIG_TERMSERV - //! TerminalConfig terminal, id 21 - std::vector m_terminal; - #endif // CONFIG_TERMSERV - //! fixed16 udp_ctrl_port, id 22 - uint16_t m_udp_ctrl_port; //! string debugs, id 23 std::vector m_debugs; - #ifdef CONFIG_FTP - //! FtpHttpConfig ftpd, id 24 - FtpHttpConfig m_ftpd; - #endif // CONFIG_FTP - #ifdef CONFIG_HTTP - //! 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 - // omitted obsolete member signals - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_SIGNAL_PROC - // omitted obsolete member functions - #endif // CONFIG_SIGNAL_PROC - #ifdef CONFIG_STATEMACHINES - //! StateMachineConfig statemachs, id 33 - std::vector m_statemachs; - #endif // CONFIG_STATEMACHINES + //! string domainname, id 15 + std::string m_domainname; + //! unsigned station2ap_time, id 13 + uint64_t m_station2ap_time = 0; //! unsigned max_on_time, id 34 - uint64_t m_max_on_time; + uint64_t m_max_on_time = 0; //! unsigned threshold_off, id 35 - uint64_t m_threshold_off; + uint64_t m_threshold_off = 0; //! unsigned threshold_on, id 36 - uint64_t m_threshold_on; + uint64_t m_threshold_on = 0; //! unsigned dim_step, id 37 - uint64_t m_dim_step; - //! bool lightctrl, id 38 - bool m_lightctrl; + uint64_t m_dim_step = 0; + //! unsigned actions_enable, id 18 + uint64_t m_actions_enable = 1; //! unsigned pwm_freq, id 39 - uint64_t m_pwm_freq; + uint64_t m_pwm_freq = 0; + //! unsigned cpu_freq, id 3 + uint64_t m_cpu_freq = 0; + //! fixed32 magic, id 0 + uint32_t m_magic = 0; + //! fixed16 dmesg_size, id 11 + uint16_t m_dmesg_size = 2048; + //! fixed16 udp_ctrl_port, id 22 + uint16_t m_udp_ctrl_port = 12719; + //! bool lightctrl, id 38 + bool m_lightctrl = 0; + #ifdef CONFIG_ONEWIRE + //! OwDeviceConfig owdevices, id 50 + std::vector m_owdevices; + #endif // CONFIG_ONEWIRE #ifdef CONFIG_APP_PARAMS //! AppParam app_params, id 40 std::vector m_app_params; @@ -4379,17 +4418,47 @@ class NodeConfig : public Message //! ThresholdConfig thresholds, id 41 std::vector m_thresholds; #endif // CONFIG_THRESHOLDS - #ifdef CONFIG_LUA - //! string luafiles, id 42 - std::vector m_luafiles; - #endif // CONFIG_LUA - #ifdef CONFIG_ONEWIRE - //! OwDeviceConfig owdevices, id 50 - std::vector m_owdevices; - #endif // CONFIG_ONEWIRE + #ifdef CONFIG_STATEMACHINES + //! StateMachineConfig statemachs, id 33 + std::vector m_statemachs; + #endif // CONFIG_STATEMACHINES + //! EventTimer timefuses, id 30 + std::vector m_timefuses; + #ifdef CONFIG_HTTP + //! FtpHttpConfig httpd, id 25 + FtpHttpConfig m_httpd; + #endif // CONFIG_HTTP + #ifdef CONFIG_FTP + //! FtpHttpConfig ftpd, id 24 + FtpHttpConfig m_ftpd; + #endif // CONFIG_FTP + #ifdef CONFIG_TERMSERV + //! TerminalConfig terminal, id 21 + std::vector m_terminal; + #endif // CONFIG_TERMSERV + //! UartSettings uart, id 20 + std::vector m_uart; + //! Trigger triggers, id 19 + std::vector m_triggers; + //! AtAction at_actions, id 17 + std::vector m_at_actions; + //! Date holidays, id 16 + std::vector m_holidays; + #ifdef CONFIG_INFLUX + //! Influx influx, id 12 + Influx m_influx; + #endif // CONFIG_INFLUX + #ifdef CONFIG_MQTT + //! MQTT mqtt, id 10 + MQTT m_mqtt; + #endif // CONFIG_MQTT + //! WifiConfig softap, id 5 + WifiConfig m_softap; + //! WifiConfig station, id 4 + WifiConfig m_station; private: - uint32_t p_validbits; + uint32_t p_validbits = 0; }; @@ -4494,7 +4563,7 @@ inline const std::string &WifiConfig::mac() const inline bool WifiConfig::has_mac() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_mac.empty(); } /*! @@ -4503,29 +4572,22 @@ inline bool WifiConfig::has_mac() const */ inline void WifiConfig::clear_mac() { - p_validbits &= ~((uint8_t)1U << 0); m_mac.clear(); } inline std::string *WifiConfig::mutable_mac() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_mac.clear(); - } return &m_mac; } inline void WifiConfig::set_mac(const void *data, size_t s) { m_mac.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void WifiConfig::set_mac(const std::string &v) { m_mac = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -4554,7 +4616,7 @@ inline uint32_t WifiConfig::addr4() const inline bool WifiConfig::has_addr4() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -4563,14 +4625,14 @@ inline bool WifiConfig::has_addr4() const */ inline void WifiConfig::clear_addr4() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_addr4 = 0; } inline uint32_t *WifiConfig::mutable_addr4() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_addr4 = 0; } return &m_addr4; @@ -4579,7 +4641,7 @@ inline uint32_t *WifiConfig::mutable_addr4() inline void WifiConfig::set_addr4(uint32_t v) { m_addr4 = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -4591,7 +4653,7 @@ inline uint8_t WifiConfig::netmask4() const inline bool WifiConfig::has_netmask4() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -4600,14 +4662,14 @@ inline bool WifiConfig::has_netmask4() const */ inline void WifiConfig::clear_netmask4() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_netmask4 = 0; } inline uint8_t *WifiConfig::mutable_netmask4() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_netmask4 = 0; } return &m_netmask4; @@ -4616,7 +4678,7 @@ inline uint8_t *WifiConfig::mutable_netmask4() inline void WifiConfig::set_netmask4(uint8_t v) { m_netmask4 = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -4628,7 +4690,7 @@ inline uint32_t WifiConfig::gateway4() const inline bool WifiConfig::has_gateway4() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -4637,14 +4699,14 @@ inline bool WifiConfig::has_gateway4() const */ inline void WifiConfig::clear_gateway4() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 2); m_gateway4 = 0; } inline uint32_t *WifiConfig::mutable_gateway4() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_gateway4 = 0; } return &m_gateway4; @@ -4653,7 +4715,7 @@ inline uint32_t *WifiConfig::mutable_gateway4() inline void WifiConfig::set_gateway4(uint32_t v) { m_gateway4 = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 2); } @@ -5201,7 +5263,7 @@ inline const std::string &AtAction::action() const inline bool AtAction::has_action() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_action.empty(); } /*! @@ -5210,35 +5272,27 @@ inline bool AtAction::has_action() const */ inline void AtAction::clear_action() { - p_validbits &= ~((uint8_t)1U << 2); m_action.clear(); } inline std::string *AtAction::mutable_action() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_action.clear(); - } return &m_action; } inline void AtAction::set_action(const void *data, size_t s) { m_action.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const char *data) { m_action = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AtAction::set_action(const std::string &v) { m_action = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -5959,7 +6013,7 @@ inline const std::string &TerminalConfig::name() const inline bool TerminalConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -5968,35 +6022,27 @@ inline bool TerminalConfig::has_name() const */ inline void TerminalConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline std::string *TerminalConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void TerminalConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void TerminalConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6015,7 +6061,7 @@ inline const std::string &Trigger::event() const inline bool Trigger::has_event() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_event.empty(); } /*! @@ -6024,35 +6070,27 @@ inline bool Trigger::has_event() const */ inline void Trigger::clear_event() { - p_validbits &= ~((uint8_t)1U << 0); m_event.clear(); } inline std::string *Trigger::mutable_event() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_event.clear(); - } return &m_event; } inline void Trigger::set_event(const void *data, size_t s) { m_event.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const char *data) { m_event = data; - p_validbits |= ((uint8_t)1U << 0); } inline void Trigger::set_event(const std::string &v) { m_event = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6128,7 +6166,7 @@ inline const std::string &AppParam::key() const inline bool AppParam::has_key() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_key.empty(); } /*! @@ -6137,35 +6175,27 @@ inline bool AppParam::has_key() const */ inline void AppParam::clear_key() { - p_validbits &= ~((uint8_t)1U << 0); m_key.clear(); } inline std::string *AppParam::mutable_key() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_key.clear(); - } return &m_key; } inline void AppParam::set_key(const void *data, size_t s) { m_key.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const char *data) { m_key = data; - p_validbits |= ((uint8_t)1U << 0); } inline void AppParam::set_key(const std::string &v) { m_key = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6177,7 +6207,7 @@ inline uint64_t AppParam::uValue() const inline bool AppParam::has_uValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -6186,14 +6216,14 @@ inline bool AppParam::has_uValue() const */ inline void AppParam::clear_uValue() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_uValue = 0; } inline uint64_t *AppParam::mutable_uValue() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_uValue = 0; } return &m_uValue; @@ -6202,7 +6232,7 @@ inline uint64_t *AppParam::mutable_uValue() inline void AppParam::set_uValue(uint64_t v) { m_uValue = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -6214,7 +6244,7 @@ inline const std::string &AppParam::sValue() const inline bool AppParam::has_sValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return !m_sValue.empty(); } /*! @@ -6223,35 +6253,27 @@ inline bool AppParam::has_sValue() const */ inline void AppParam::clear_sValue() { - p_validbits &= ~((uint8_t)1U << 2); m_sValue.clear(); } inline std::string *AppParam::mutable_sValue() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); - m_sValue.clear(); - } return &m_sValue; } inline void AppParam::set_sValue(const void *data, size_t s) { m_sValue.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const char *data) { m_sValue = data; - p_validbits |= ((uint8_t)1U << 2); } inline void AppParam::set_sValue(const std::string &v) { m_sValue = v; - p_validbits |= ((uint8_t)1U << 2); } @@ -6263,7 +6285,7 @@ inline int64_t AppParam::dValue() const inline bool AppParam::has_dValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 3)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -6272,14 +6294,14 @@ inline bool AppParam::has_dValue() const */ inline void AppParam::clear_dValue() { - p_validbits &= ~((uint8_t)1U << 3); + p_validbits &= ~((uint8_t)1U << 1); m_dValue = 0; } inline int64_t *AppParam::mutable_dValue() { - if (0 == (p_validbits & ((uint8_t)1U << 3))) { - p_validbits |= ((uint8_t)1U << 3); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_dValue = 0; } return &m_dValue; @@ -6288,7 +6310,7 @@ inline int64_t *AppParam::mutable_dValue() inline void AppParam::set_dValue(int64_t v) { m_dValue = v; - p_validbits |= ((uint8_t)1U << 3); + p_validbits |= ((uint8_t)1U << 1); } @@ -6300,7 +6322,7 @@ inline double AppParam::fValue() const inline bool AppParam::has_fValue() const { - return 0 != (p_validbits & ((uint8_t)1U << 4)); + return 0 != (p_validbits & ((uint8_t)1U << 2)); } /*! @@ -6309,14 +6331,14 @@ inline bool AppParam::has_fValue() const */ inline void AppParam::clear_fValue() { - p_validbits &= ~((uint8_t)1U << 4); + p_validbits &= ~((uint8_t)1U << 2); m_fValue = 0; } inline double *AppParam::mutable_fValue() { - if (0 == (p_validbits & ((uint8_t)1U << 4))) { - p_validbits |= ((uint8_t)1U << 4); + if (0 == (p_validbits & ((uint8_t)1U << 2))) { + p_validbits |= ((uint8_t)1U << 2); m_fValue = 0; } return &m_fValue; @@ -6325,7 +6347,7 @@ inline double *AppParam::mutable_fValue() inline void AppParam::set_fValue(double v) { m_fValue = v; - p_validbits |= ((uint8_t)1U << 4); + p_validbits |= ((uint8_t)1U << 2); } @@ -6484,7 +6506,7 @@ inline const std::string &FunctionConfig::name() const inline bool FunctionConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6493,35 +6515,27 @@ inline bool FunctionConfig::has_name() const */ inline void FunctionConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline std::string *FunctionConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void FunctionConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void FunctionConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6533,7 +6547,7 @@ inline const std::string &FunctionConfig::func() const inline bool FunctionConfig::has_func() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_func.empty(); } /*! @@ -6542,35 +6556,27 @@ inline bool FunctionConfig::has_func() const */ inline void FunctionConfig::clear_func() { - p_validbits &= ~((uint8_t)1U << 1); m_func.clear(); } inline std::string *FunctionConfig::mutable_func() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_func.clear(); - } return &m_func; } inline void FunctionConfig::set_func(const void *data, size_t s) { m_func.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const char *data) { m_func = data; - p_validbits |= ((uint8_t)1U << 1); } inline void FunctionConfig::set_func(const std::string &v) { m_func = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6801,7 +6807,7 @@ inline const std::string &OwDeviceConfig::name() const inline bool OwDeviceConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return !m_name.empty(); } /*! @@ -6810,35 +6816,27 @@ inline bool OwDeviceConfig::has_name() const */ inline void OwDeviceConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 1); m_name.clear(); } inline std::string *OwDeviceConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); - m_name.clear(); - } return &m_name; } inline void OwDeviceConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 1); } inline void OwDeviceConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 1); } @@ -6857,7 +6855,7 @@ inline const std::string &StateConfig::name() const inline bool StateConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6866,35 +6864,27 @@ inline bool StateConfig::has_name() const */ inline void StateConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline std::string *StateConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -6954,6 +6944,7 @@ inline size_t StateMachineConfig::getMaxSize() // optional string name, id 1 has unlimited size // optional uint8 ini_st, id 2 has maximum size 3 // repeated StateConfig states, id 3 has unlimited size + // optional bool persistent, id 4 has maximum size 2 return SIZE_MAX; } @@ -6964,7 +6955,7 @@ inline const std::string &StateMachineConfig::name() const inline bool StateMachineConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -6973,35 +6964,27 @@ inline bool StateMachineConfig::has_name() const */ inline void StateMachineConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline std::string *StateMachineConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void StateMachineConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void StateMachineConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -7013,7 +6996,7 @@ inline uint8_t StateMachineConfig::ini_st() const inline bool StateMachineConfig::has_ini_st() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -7022,14 +7005,14 @@ inline bool StateMachineConfig::has_ini_st() const */ inline void StateMachineConfig::clear_ini_st() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_ini_st = 0; } inline uint8_t *StateMachineConfig::mutable_ini_st() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_ini_st = 0; } return &m_ini_st; @@ -7038,7 +7021,7 @@ inline uint8_t *StateMachineConfig::mutable_ini_st() inline void StateMachineConfig::set_ini_st(uint8_t v) { m_ini_st = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -7093,6 +7076,37 @@ inline size_t StateMachineConfig::states_size() const +inline bool StateMachineConfig::persistent() const +{ + return m_persistent; +} + +inline bool StateMachineConfig::has_persistent() const +{ + return m_persistent != false; +} + +/*! + * Function for clearing the associated member variable. + * It will reset the value to the default value. + */ +inline void StateMachineConfig::clear_persistent() +{ + m_persistent = false; +} + +inline bool *StateMachineConfig::mutable_persistent() +{ + return &m_persistent; +} + +inline void StateMachineConfig::set_persistent(bool v) +{ + m_persistent = v; +} + + + inline size_t ThresholdConfig::getMaxSize() { // optional string name, id 1 has unlimited size @@ -7108,7 +7122,7 @@ inline const std::string &ThresholdConfig::name() const inline bool ThresholdConfig::has_name() const { - return 0 != (p_validbits & ((uint8_t)1U << 0)); + return !m_name.empty(); } /*! @@ -7117,35 +7131,27 @@ inline bool ThresholdConfig::has_name() const */ inline void ThresholdConfig::clear_name() { - p_validbits &= ~((uint8_t)1U << 0); m_name.clear(); } inline std::string *ThresholdConfig::mutable_name() { - if (0 == (p_validbits & ((uint8_t)1U << 0))) { - p_validbits |= ((uint8_t)1U << 0); - m_name.clear(); - } return &m_name; } inline void ThresholdConfig::set_name(const void *data, size_t s) { m_name.assign((const char *)data,s); - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const char *data) { m_name = data; - p_validbits |= ((uint8_t)1U << 0); } inline void ThresholdConfig::set_name(const std::string &v) { m_name = v; - p_validbits |= ((uint8_t)1U << 0); } @@ -7157,7 +7163,7 @@ inline float ThresholdConfig::low() const inline bool ThresholdConfig::has_low() const { - return 0 != (p_validbits & ((uint8_t)1U << 1)); + return 0 != (p_validbits & ((uint8_t)1U << 0)); } /*! @@ -7166,14 +7172,14 @@ inline bool ThresholdConfig::has_low() const */ inline void ThresholdConfig::clear_low() { - p_validbits &= ~((uint8_t)1U << 1); + p_validbits &= ~((uint8_t)1U << 0); m_low = 0; } inline float *ThresholdConfig::mutable_low() { - if (0 == (p_validbits & ((uint8_t)1U << 1))) { - p_validbits |= ((uint8_t)1U << 1); + if (0 == (p_validbits & ((uint8_t)1U << 0))) { + p_validbits |= ((uint8_t)1U << 0); m_low = 0; } return &m_low; @@ -7182,7 +7188,7 @@ inline float *ThresholdConfig::mutable_low() inline void ThresholdConfig::set_low(float v) { m_low = v; - p_validbits |= ((uint8_t)1U << 1); + p_validbits |= ((uint8_t)1U << 0); } @@ -7194,7 +7200,7 @@ inline float ThresholdConfig::high() const inline bool ThresholdConfig::has_high() const { - return 0 != (p_validbits & ((uint8_t)1U << 2)); + return 0 != (p_validbits & ((uint8_t)1U << 1)); } /*! @@ -7203,14 +7209,14 @@ inline bool ThresholdConfig::has_high() const */ inline void ThresholdConfig::clear_high() { - p_validbits &= ~((uint8_t)1U << 2); + p_validbits &= ~((uint8_t)1U << 1); m_high = 0; } inline float *ThresholdConfig::mutable_high() { - if (0 == (p_validbits & ((uint8_t)1U << 2))) { - p_validbits |= ((uint8_t)1U << 2); + if (0 == (p_validbits & ((uint8_t)1U << 1))) { + p_validbits |= ((uint8_t)1U << 1); m_high = 0; } return &m_high; @@ -7219,7 +7225,7 @@ inline float *ThresholdConfig::mutable_high() inline void ThresholdConfig::set_high(float v) { m_high = v; - p_validbits |= ((uint8_t)1U << 2); + p_validbits |= ((uint8_t)1U << 1); } @@ -7372,8 +7378,8 @@ inline size_t NodeConfig::getMaxSize() // obsolete repeated FunctionConfig functions, id 32 // repeated StateMachineConfig statemachs, id 33 has unlimited size // deprecated optional unsigned max_on_time, id 34 has maximum size 12 - // optional unsigned threshold_off, id 35 has maximum size 12 - // optional unsigned threshold_on, id 36 has maximum size 12 + // deprecated optional unsigned threshold_off, id 35 has maximum size 12 + // deprecated optional unsigned threshold_on, id 36 has maximum size 12 // optional unsigned dim_step, id 37 has maximum size 12 // optional bool lightctrl, id 38 has maximum size 3 // optional unsigned pwm_freq, id 39 has maximum size 12 @@ -7469,7 +7475,7 @@ inline const std::string &NodeConfig::pass_hash() const inline bool NodeConfig::has_pass_hash() const { - return 0 != (p_validbits & ((uint32_t)1U << 1)); + return !m_pass_hash.empty(); } /*! @@ -7478,29 +7484,22 @@ inline bool NodeConfig::has_pass_hash() const */ inline void NodeConfig::clear_pass_hash() { - p_validbits &= ~((uint32_t)1U << 1); m_pass_hash.clear(); } inline std::string *NodeConfig::mutable_pass_hash() { - if (0 == (p_validbits & ((uint32_t)1U << 1))) { - p_validbits |= ((uint32_t)1U << 1); - m_pass_hash.clear(); - } return &m_pass_hash; } inline void NodeConfig::set_pass_hash(const void *data, size_t s) { m_pass_hash.assign((const char *)data,s); - p_validbits |= ((uint32_t)1U << 1); } inline void NodeConfig::set_pass_hash(const std::string &v) { m_pass_hash = v; - p_validbits |= ((uint32_t)1U << 1); } @@ -7512,7 +7511,7 @@ inline uint64_t NodeConfig::cpu_freq() const inline bool NodeConfig::has_cpu_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 2)); + return 0 != (p_validbits & ((uint32_t)1U << 1)); } /*! @@ -7521,14 +7520,14 @@ inline bool NodeConfig::has_cpu_freq() const */ inline void NodeConfig::clear_cpu_freq() { - p_validbits &= ~((uint32_t)1U << 2); + p_validbits &= ~((uint32_t)1U << 1); m_cpu_freq = 0; } inline uint64_t *NodeConfig::mutable_cpu_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 2))) { - p_validbits |= ((uint32_t)1U << 2); + if (0 == (p_validbits & ((uint32_t)1U << 1))) { + p_validbits |= ((uint32_t)1U << 1); m_cpu_freq = 0; } return &m_cpu_freq; @@ -7537,7 +7536,7 @@ inline uint64_t *NodeConfig::mutable_cpu_freq() inline void NodeConfig::set_cpu_freq(uint64_t v) { m_cpu_freq = v; - p_validbits |= ((uint32_t)1U << 2); + p_validbits |= ((uint32_t)1U << 1); } @@ -7549,7 +7548,7 @@ inline const WifiConfig &NodeConfig::station() const inline bool NodeConfig::has_station() const { - return 0 != (p_validbits & ((uint32_t)1U << 3)); + return 0 != (p_validbits & ((uint32_t)1U << 2)); } /*! @@ -7558,14 +7557,14 @@ inline bool NodeConfig::has_station() const */ inline void NodeConfig::clear_station() { - p_validbits &= ~((uint32_t)1U << 3); + p_validbits &= ~((uint32_t)1U << 2); m_station.clear(); } inline WifiConfig *NodeConfig::mutable_station() { - if (0 == (p_validbits & ((uint32_t)1U << 3))) { - p_validbits |= ((uint32_t)1U << 3); + if (0 == (p_validbits & ((uint32_t)1U << 2))) { + p_validbits |= ((uint32_t)1U << 2); m_station.clear(); } return &m_station; @@ -7574,13 +7573,13 @@ inline WifiConfig *NodeConfig::mutable_station() inline void NodeConfig::set_station(const void *data, size_t s) { m_station.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } inline void NodeConfig::set_station(const WifiConfig &v) { m_station = v; - p_validbits |= ((uint32_t)1U << 3); + p_validbits |= ((uint32_t)1U << 2); } @@ -7592,7 +7591,7 @@ inline const WifiConfig &NodeConfig::softap() const inline bool NodeConfig::has_softap() const { - return 0 != (p_validbits & ((uint32_t)1U << 4)); + return 0 != (p_validbits & ((uint32_t)1U << 3)); } /*! @@ -7601,14 +7600,14 @@ inline bool NodeConfig::has_softap() const */ inline void NodeConfig::clear_softap() { - p_validbits &= ~((uint32_t)1U << 4); + p_validbits &= ~((uint32_t)1U << 3); m_softap.clear(); } inline WifiConfig *NodeConfig::mutable_softap() { - if (0 == (p_validbits & ((uint32_t)1U << 4))) { - p_validbits |= ((uint32_t)1U << 4); + if (0 == (p_validbits & ((uint32_t)1U << 3))) { + p_validbits |= ((uint32_t)1U << 3); m_softap.clear(); } return &m_softap; @@ -7617,13 +7616,13 @@ inline WifiConfig *NodeConfig::mutable_softap() inline void NodeConfig::set_softap(const void *data, size_t s) { m_softap.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } inline void NodeConfig::set_softap(const WifiConfig &v) { m_softap = v; - p_validbits |= ((uint32_t)1U << 4); + p_validbits |= ((uint32_t)1U << 3); } @@ -7650,7 +7649,7 @@ inline void NodeConfig::clear_dns_server() inline std::string *NodeConfig::mutable_dns_server(unsigned x) { if (x >= m_dns_server.size()) - m_dns_server.resize(x+1,""); + m_dns_server.resize(x+1); return &m_dns_server[x]; } @@ -7813,7 +7812,7 @@ inline const MQTT &NodeConfig::mqtt() const inline bool NodeConfig::has_mqtt() const { - return 0 != (p_validbits & ((uint32_t)1U << 5)); + return 0 != (p_validbits & ((uint32_t)1U << 4)); } /*! @@ -7822,14 +7821,14 @@ inline bool NodeConfig::has_mqtt() const */ inline void NodeConfig::clear_mqtt() { - p_validbits &= ~((uint32_t)1U << 5); + p_validbits &= ~((uint32_t)1U << 4); m_mqtt.clear(); } inline MQTT *NodeConfig::mutable_mqtt() { - if (0 == (p_validbits & ((uint32_t)1U << 5))) { - p_validbits |= ((uint32_t)1U << 5); + if (0 == (p_validbits & ((uint32_t)1U << 4))) { + p_validbits |= ((uint32_t)1U << 4); m_mqtt.clear(); } return &m_mqtt; @@ -7838,13 +7837,13 @@ inline MQTT *NodeConfig::mutable_mqtt() inline void NodeConfig::set_mqtt(const void *data, size_t s) { m_mqtt.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } inline void NodeConfig::set_mqtt(const MQTT &v) { m_mqtt = v; - p_validbits |= ((uint32_t)1U << 5); + p_validbits |= ((uint32_t)1U << 4); } #endif // CONFIG_MQTT @@ -7857,7 +7856,7 @@ inline uint16_t NodeConfig::dmesg_size() const inline bool NodeConfig::has_dmesg_size() const { - return 0 != (p_validbits & ((uint32_t)1U << 6)); + return 0 != (p_validbits & ((uint32_t)1U << 5)); } /*! @@ -7866,14 +7865,14 @@ inline bool NodeConfig::has_dmesg_size() const */ inline void NodeConfig::clear_dmesg_size() { - p_validbits &= ~((uint32_t)1U << 6); + p_validbits &= ~((uint32_t)1U << 5); m_dmesg_size = 2048; } inline uint16_t *NodeConfig::mutable_dmesg_size() { - if (0 == (p_validbits & ((uint32_t)1U << 6))) { - p_validbits |= ((uint32_t)1U << 6); + if (0 == (p_validbits & ((uint32_t)1U << 5))) { + p_validbits |= ((uint32_t)1U << 5); m_dmesg_size = 2048; } return &m_dmesg_size; @@ -7882,7 +7881,7 @@ inline uint16_t *NodeConfig::mutable_dmesg_size() inline void NodeConfig::set_dmesg_size(uint16_t v) { m_dmesg_size = v; - p_validbits |= ((uint32_t)1U << 6); + p_validbits |= ((uint32_t)1U << 5); } @@ -7895,7 +7894,7 @@ inline const Influx &NodeConfig::influx() const inline bool NodeConfig::has_influx() const { - return 0 != (p_validbits & ((uint32_t)1U << 7)); + return 0 != (p_validbits & ((uint32_t)1U << 6)); } /*! @@ -7904,14 +7903,14 @@ inline bool NodeConfig::has_influx() const */ inline void NodeConfig::clear_influx() { - p_validbits &= ~((uint32_t)1U << 7); + p_validbits &= ~((uint32_t)1U << 6); m_influx.clear(); } inline Influx *NodeConfig::mutable_influx() { - if (0 == (p_validbits & ((uint32_t)1U << 7))) { - p_validbits |= ((uint32_t)1U << 7); + if (0 == (p_validbits & ((uint32_t)1U << 6))) { + p_validbits |= ((uint32_t)1U << 6); m_influx.clear(); } return &m_influx; @@ -7920,13 +7919,13 @@ inline Influx *NodeConfig::mutable_influx() inline void NodeConfig::set_influx(const void *data, size_t s) { m_influx.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } inline void NodeConfig::set_influx(const Influx &v) { m_influx = v; - p_validbits |= ((uint32_t)1U << 7); + p_validbits |= ((uint32_t)1U << 6); } #endif // CONFIG_INFLUX @@ -7939,7 +7938,7 @@ inline uint64_t NodeConfig::station2ap_time() const inline bool NodeConfig::has_station2ap_time() const { - return 0 != (p_validbits & ((uint32_t)1U << 8)); + return 0 != (p_validbits & ((uint32_t)1U << 7)); } /*! @@ -7948,14 +7947,14 @@ inline bool NodeConfig::has_station2ap_time() const */ inline void NodeConfig::clear_station2ap_time() { - p_validbits &= ~((uint32_t)1U << 8); + p_validbits &= ~((uint32_t)1U << 7); m_station2ap_time = 0; } inline uint64_t *NodeConfig::mutable_station2ap_time() { - if (0 == (p_validbits & ((uint32_t)1U << 8))) { - p_validbits |= ((uint32_t)1U << 8); + if (0 == (p_validbits & ((uint32_t)1U << 7))) { + p_validbits |= ((uint32_t)1U << 7); m_station2ap_time = 0; } return &m_station2ap_time; @@ -7964,7 +7963,7 @@ inline uint64_t *NodeConfig::mutable_station2ap_time() inline void NodeConfig::set_station2ap_time(uint64_t v) { m_station2ap_time = v; - p_validbits |= ((uint32_t)1U << 8); + p_validbits |= ((uint32_t)1U << 7); } @@ -8117,7 +8116,7 @@ inline uint64_t NodeConfig::actions_enable() const inline bool NodeConfig::has_actions_enable() const { - return 0 != (p_validbits & ((uint32_t)1U << 9)); + return 0 != (p_validbits & ((uint32_t)1U << 8)); } /*! @@ -8126,14 +8125,14 @@ inline bool NodeConfig::has_actions_enable() const */ inline void NodeConfig::clear_actions_enable() { - p_validbits &= ~((uint32_t)1U << 9); + p_validbits &= ~((uint32_t)1U << 8); m_actions_enable = 1; } inline uint64_t *NodeConfig::mutable_actions_enable() { - if (0 == (p_validbits & ((uint32_t)1U << 9))) { - p_validbits |= ((uint32_t)1U << 9); + if (0 == (p_validbits & ((uint32_t)1U << 8))) { + p_validbits |= ((uint32_t)1U << 8); m_actions_enable = 1; } return &m_actions_enable; @@ -8142,7 +8141,7 @@ inline uint64_t *NodeConfig::mutable_actions_enable() inline void NodeConfig::set_actions_enable(uint64_t v) { m_actions_enable = v; - p_validbits |= ((uint32_t)1U << 9); + p_validbits |= ((uint32_t)1U << 8); } @@ -8306,7 +8305,7 @@ inline uint16_t NodeConfig::udp_ctrl_port() const inline bool NodeConfig::has_udp_ctrl_port() const { - return 0 != (p_validbits & ((uint32_t)1U << 10)); + return 0 != (p_validbits & ((uint32_t)1U << 9)); } /*! @@ -8315,14 +8314,14 @@ inline bool NodeConfig::has_udp_ctrl_port() const */ inline void NodeConfig::clear_udp_ctrl_port() { - p_validbits &= ~((uint32_t)1U << 10); + p_validbits &= ~((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } inline uint16_t *NodeConfig::mutable_udp_ctrl_port() { - if (0 == (p_validbits & ((uint32_t)1U << 10))) { - p_validbits |= ((uint32_t)1U << 10); + if (0 == (p_validbits & ((uint32_t)1U << 9))) { + p_validbits |= ((uint32_t)1U << 9); m_udp_ctrl_port = 12719; } return &m_udp_ctrl_port; @@ -8331,7 +8330,7 @@ inline uint16_t *NodeConfig::mutable_udp_ctrl_port() inline void NodeConfig::set_udp_ctrl_port(uint16_t v) { m_udp_ctrl_port = v; - p_validbits |= ((uint32_t)1U << 10); + p_validbits |= ((uint32_t)1U << 9); } @@ -8398,7 +8397,7 @@ inline const FtpHttpConfig &NodeConfig::ftpd() const inline bool NodeConfig::has_ftpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 11)); + return 0 != (p_validbits & ((uint32_t)1U << 10)); } /*! @@ -8407,14 +8406,14 @@ inline bool NodeConfig::has_ftpd() const */ inline void NodeConfig::clear_ftpd() { - p_validbits &= ~((uint32_t)1U << 11); + p_validbits &= ~((uint32_t)1U << 10); m_ftpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_ftpd() { - if (0 == (p_validbits & ((uint32_t)1U << 11))) { - p_validbits |= ((uint32_t)1U << 11); + if (0 == (p_validbits & ((uint32_t)1U << 10))) { + p_validbits |= ((uint32_t)1U << 10); m_ftpd.clear(); } return &m_ftpd; @@ -8423,13 +8422,13 @@ inline FtpHttpConfig *NodeConfig::mutable_ftpd() inline void NodeConfig::set_ftpd(const void *data, size_t s) { m_ftpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } inline void NodeConfig::set_ftpd(const FtpHttpConfig &v) { m_ftpd = v; - p_validbits |= ((uint32_t)1U << 11); + p_validbits |= ((uint32_t)1U << 10); } #endif // CONFIG_FTP @@ -8443,7 +8442,7 @@ inline const FtpHttpConfig &NodeConfig::httpd() const inline bool NodeConfig::has_httpd() const { - return 0 != (p_validbits & ((uint32_t)1U << 12)); + return 0 != (p_validbits & ((uint32_t)1U << 11)); } /*! @@ -8452,14 +8451,14 @@ inline bool NodeConfig::has_httpd() const */ inline void NodeConfig::clear_httpd() { - p_validbits &= ~((uint32_t)1U << 12); + p_validbits &= ~((uint32_t)1U << 11); m_httpd.clear(); } inline FtpHttpConfig *NodeConfig::mutable_httpd() { - if (0 == (p_validbits & ((uint32_t)1U << 12))) { - p_validbits |= ((uint32_t)1U << 12); + if (0 == (p_validbits & ((uint32_t)1U << 11))) { + p_validbits |= ((uint32_t)1U << 11); m_httpd.clear(); } return &m_httpd; @@ -8468,13 +8467,13 @@ inline FtpHttpConfig *NodeConfig::mutable_httpd() inline void NodeConfig::set_httpd(const void *data, size_t s) { m_httpd.fromMemory((const char *)data,s); - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } inline void NodeConfig::set_httpd(const FtpHttpConfig &v) { m_httpd = v; - p_validbits |= ((uint32_t)1U << 12); + p_validbits |= ((uint32_t)1U << 11); } #endif // CONFIG_HTTP @@ -8487,7 +8486,7 @@ inline const std::string &NodeConfig::otasrv() const inline bool NodeConfig::has_otasrv() const { - return 0 != (p_validbits & ((uint32_t)1U << 13)); + return !m_otasrv.empty(); } /*! @@ -8496,35 +8495,27 @@ inline bool NodeConfig::has_otasrv() const */ 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); } @@ -8664,7 +8655,7 @@ inline uint64_t NodeConfig::threshold_off() const inline bool NodeConfig::has_threshold_off() const { - return 0 != (p_validbits & ((uint32_t)1U << 14)); + return 0 != (p_validbits & ((uint32_t)1U << 12)); } /*! @@ -8673,23 +8664,14 @@ inline bool NodeConfig::has_threshold_off() const */ inline void NodeConfig::clear_threshold_off() { - p_validbits &= ~((uint32_t)1U << 14); + p_validbits &= ~((uint32_t)1U << 12); m_threshold_off = 0; } -inline uint64_t *NodeConfig::mutable_threshold_off() -{ - if (0 == (p_validbits & ((uint32_t)1U << 14))) { - p_validbits |= ((uint32_t)1U << 14); - m_threshold_off = 0; - } - return &m_threshold_off; -} - inline void NodeConfig::set_threshold_off(uint64_t v) { m_threshold_off = v; - p_validbits |= ((uint32_t)1U << 14); + p_validbits |= ((uint32_t)1U << 12); } @@ -8701,7 +8683,7 @@ inline uint64_t NodeConfig::threshold_on() const inline bool NodeConfig::has_threshold_on() const { - return 0 != (p_validbits & ((uint32_t)1U << 15)); + return 0 != (p_validbits & ((uint32_t)1U << 13)); } /*! @@ -8710,23 +8692,14 @@ inline bool NodeConfig::has_threshold_on() const */ inline void NodeConfig::clear_threshold_on() { - p_validbits &= ~((uint32_t)1U << 15); + p_validbits &= ~((uint32_t)1U << 13); m_threshold_on = 0; } -inline uint64_t *NodeConfig::mutable_threshold_on() -{ - if (0 == (p_validbits & ((uint32_t)1U << 15))) { - p_validbits |= ((uint32_t)1U << 15); - m_threshold_on = 0; - } - return &m_threshold_on; -} - inline void NodeConfig::set_threshold_on(uint64_t v) { m_threshold_on = v; - p_validbits |= ((uint32_t)1U << 15); + p_validbits |= ((uint32_t)1U << 13); } @@ -8738,7 +8711,7 @@ inline uint64_t NodeConfig::dim_step() const inline bool NodeConfig::has_dim_step() const { - return 0 != (p_validbits & ((uint32_t)1U << 16)); + return 0 != (p_validbits & ((uint32_t)1U << 14)); } /*! @@ -8747,14 +8720,14 @@ inline bool NodeConfig::has_dim_step() const */ inline void NodeConfig::clear_dim_step() { - p_validbits &= ~((uint32_t)1U << 16); + p_validbits &= ~((uint32_t)1U << 14); m_dim_step = 0; } inline uint64_t *NodeConfig::mutable_dim_step() { - if (0 == (p_validbits & ((uint32_t)1U << 16))) { - p_validbits |= ((uint32_t)1U << 16); + if (0 == (p_validbits & ((uint32_t)1U << 14))) { + p_validbits |= ((uint32_t)1U << 14); m_dim_step = 0; } return &m_dim_step; @@ -8763,7 +8736,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 << 16); + p_validbits |= ((uint32_t)1U << 14); } @@ -8775,7 +8748,7 @@ inline bool NodeConfig::lightctrl() const inline bool NodeConfig::has_lightctrl() const { - return 0 != (p_validbits & ((uint32_t)1U << 17)); + return 0 != (p_validbits & ((uint32_t)1U << 15)); } /*! @@ -8784,14 +8757,14 @@ inline bool NodeConfig::has_lightctrl() const */ inline void NodeConfig::clear_lightctrl() { - p_validbits &= ~((uint32_t)1U << 17); + p_validbits &= ~((uint32_t)1U << 15); m_lightctrl = 0; } inline bool *NodeConfig::mutable_lightctrl() { - if (0 == (p_validbits & ((uint32_t)1U << 17))) { - p_validbits |= ((uint32_t)1U << 17); + if (0 == (p_validbits & ((uint32_t)1U << 15))) { + p_validbits |= ((uint32_t)1U << 15); m_lightctrl = 0; } return &m_lightctrl; @@ -8800,7 +8773,7 @@ inline bool *NodeConfig::mutable_lightctrl() inline void NodeConfig::set_lightctrl(bool v) { m_lightctrl = v; - p_validbits |= ((uint32_t)1U << 17); + p_validbits |= ((uint32_t)1U << 15); } @@ -8812,7 +8785,7 @@ inline uint64_t NodeConfig::pwm_freq() const inline bool NodeConfig::has_pwm_freq() const { - return 0 != (p_validbits & ((uint32_t)1U << 18)); + return 0 != (p_validbits & ((uint32_t)1U << 16)); } /*! @@ -8821,14 +8794,14 @@ inline bool NodeConfig::has_pwm_freq() const */ inline void NodeConfig::clear_pwm_freq() { - p_validbits &= ~((uint32_t)1U << 18); + p_validbits &= ~((uint32_t)1U << 16); m_pwm_freq = 0; } inline uint64_t *NodeConfig::mutable_pwm_freq() { - if (0 == (p_validbits & ((uint32_t)1U << 18))) { - p_validbits |= ((uint32_t)1U << 18); + if (0 == (p_validbits & ((uint32_t)1U << 16))) { + p_validbits |= ((uint32_t)1U << 16); m_pwm_freq = 0; } return &m_pwm_freq; @@ -8837,7 +8810,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 << 18); + p_validbits |= ((uint32_t)1U << 16); } diff --git a/components/wfc/wfccore_esp32.cpp b/components/wfc/wfccore_esp32.cpp index 3fb460c..c223046 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -506,24 +506,22 @@ void to_dblstr(stream &s, double d) */ int parse_ascii_bool(bool *v, const char *ascii) { - int r = 0; + int r; + bool b = false; if ('0' == ascii[0]) { - *v = false; r = 1; } else if ('1' == ascii[0]) { - *v = true; + b = true; r = 1; } else if (0 == memcmp(ascii,"true",4)) { - *v = true; + b = true; r = 4; } else if (0 == memcmp(ascii,"false",5)) { - *v = false; r = 5; } else if (0 == memcmp(ascii,"on",2)) { - *v = true; + b = true; r = 2; } else if (0 == memcmp(ascii,"off",3)) { - *v = false; r = 3; } else { return -14; @@ -531,6 +529,7 @@ int parse_ascii_bool(bool *v, const char *ascii) char c = ascii[r]; if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_')) return -15; + *v = b; return r; } @@ -962,17 +961,17 @@ Message *Message::getMember(const char *n) long l = strtol(b+1,&e,0); if ((l < 0) || (*e != ']')) return 0; - r = r->p_getMember(n,b,l); + r = r->p_getMember(n,b-n,l); n = e + 1; if (*n == 0) return r; if (*n != '.') return 0; } else if (d) { - r = r->p_getMember(n,d); + r = r->p_getMember(n,d-n); n = d; } else { - return r->p_getMember(n,n+strlen(n)); + return r->p_getMember(n,strlen(n)); } ++n; } while (r); diff --git a/components/wfc/wfccore_esp32.h b/components/wfc/wfccore_esp32.h index 37b108b..f8c198d 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -92,6 +92,22 @@ * asserts, comments, genlib, gnux */ +#ifdef WFC_ENDIAN +#if WFC_ENDIAN != 0 +#error WFC generated code incompatible due to endian +#endif +#else +#define WFC_ENDIAN 0 // little endian +#endif + +#define HAVE_TO_MEMORY 1 +#define HAVE_TO_ASCII 1 +#define HAVE_TO_JSON 1 +#define HAVE_GET_MEMBER 1 +#define HAVE_FROM_MEMORY 1 +#define ON_ERROR_CANCEL 1 +#define HAVE_ENUM_NAMES 1 + #ifndef _WFCCORE_H #define _WFCCORE_H @@ -157,8 +173,8 @@ class Message Message *getMember(const char *); protected: - virtual Message *p_getMember(const char *s, const char *e) = 0; - virtual Message *p_getMember(const char *s, const char *e, unsigned x) = 0; + virtual Message *p_getMember(const char *s, unsigned n) = 0; + virtual Message *p_getMember(const char *s, unsigned n, unsigned x) = 0; }; inline Message::~Message() diff --git a/components/wfc/wfccore_esp8266.cpp b/components/wfc/wfccore_esp8266.cpp index 11d211b..abb327a 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -576,24 +576,22 @@ void to_dblstr(stream &s, double d) */ int parse_ascii_bool(bool *v, const char *ascii) { - int r = 0; + int r; + bool b = false; if ('0' == ascii[0]) { - *v = false; r = 1; } else if ('1' == ascii[0]) { - *v = true; + b = true; r = 1; } else if (0 == memcmp(ascii,"true",4)) { - *v = true; + b = true; r = 4; } else if (0 == memcmp(ascii,"false",5)) { - *v = false; r = 5; } else if (0 == memcmp(ascii,"on",2)) { - *v = true; + b = true; r = 2; } else if (0 == memcmp(ascii,"off",3)) { - *v = false; r = 3; } else { return -14; @@ -601,6 +599,7 @@ int parse_ascii_bool(bool *v, const char *ascii) char c = ascii[r]; if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_')) return -15; + *v = b; return r; } @@ -1008,17 +1007,17 @@ Message *Message::getMember(const char *n) long l = strtol(b+1,&e,0); if ((l < 0) || (*e != ']')) return 0; - r = r->p_getMember(n,b,l); + r = r->p_getMember(n,b-n,l); n = e + 1; if (*n == 0) return r; if (*n != '.') return 0; } else if (d) { - r = r->p_getMember(n,d); + r = r->p_getMember(n,d-n); n = d; } else { - return r->p_getMember(n,n+strlen(n)); + return r->p_getMember(n,strlen(n)); } ++n; } while (r); diff --git a/components/wfc/wfccore_esp8266.h b/components/wfc/wfccore_esp8266.h index d21a27e..0c898a5 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -92,6 +92,22 @@ * asserts, comments, genlib, gnux */ +#ifdef WFC_ENDIAN +#if WFC_ENDIAN != 0 +#error WFC generated code incompatible due to endian +#endif +#else +#define WFC_ENDIAN 0 // unknown endian +#endif + +#define HAVE_TO_MEMORY 1 +#define HAVE_TO_ASCII 1 +#define HAVE_TO_JSON 1 +#define HAVE_GET_MEMBER 1 +#define HAVE_FROM_MEMORY 1 +#define ON_ERROR_CANCEL 1 +#define HAVE_ENUM_NAMES 1 + #ifndef _WFCCORE_H #define _WFCCORE_H @@ -158,9 +174,9 @@ class Message Message *getMember(const char *); protected: - virtual Message *p_getMember(const char *s, const char *e) + virtual Message *p_getMember(const char *s, unsigned n) { return 0; } - virtual Message *p_getMember(const char *s, const char *e, unsigned x) + virtual Message *p_getMember(const char *s, unsigned n, unsigned x) { return 0; } }; diff --git a/components/wfc/wfccore_esp8285.cpp b/components/wfc/wfccore_esp8285.cpp index 99942f4..68012f0 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -578,24 +578,22 @@ void to_dblstr(stream &s, double d) */ int parse_ascii_bool(bool *v, const char *ascii) { - int r = 0; + int r; + bool b = false; if ('0' == ascii[0]) { - *v = false; r = 1; } else if ('1' == ascii[0]) { - *v = true; + b = true; r = 1; } else if (0 == memcmp(ascii,"true",4)) { - *v = true; + b = true; r = 4; } else if (0 == memcmp(ascii,"false",5)) { - *v = false; r = 5; } else if (0 == memcmp(ascii,"on",2)) { - *v = true; + b = true; r = 2; } else if (0 == memcmp(ascii,"off",3)) { - *v = false; r = 3; } else { return -14; @@ -603,6 +601,7 @@ int parse_ascii_bool(bool *v, const char *ascii) char c = ascii[r]; if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_')) return -15; + *v = b; return r; } diff --git a/components/wfc/wfccore_esp8285.h b/components/wfc/wfccore_esp8285.h index c9130ad..ac41558 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -94,6 +94,21 @@ * asserts, comments, genlib, gnux */ +#ifdef WFC_ENDIAN +#if WFC_ENDIAN != 0 +#error WFC generated code incompatible due to endian +#endif +#else +#define WFC_ENDIAN 0 // unknown endian +#endif + +#define HAVE_TO_MEMORY 1 +#define HAVE_TO_ASCII 1 +#define HAVE_TO_JSON 1 +#define HAVE_FROM_MEMORY 1 +#define ON_ERROR_CANCEL 1 +#define HAVE_ENUM_NAMES 1 + #ifndef _WFCCORE_H #define _WFCCORE_H diff --git a/components/wfc/wfccore_pc.cpp b/components/wfc/wfccore_pc.cpp index f7f3126..d73bf52 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -573,24 +573,22 @@ void to_dblstr(std::ostream &s, double d) */ int parse_ascii_bool(bool *v, const char *ascii) { - int r = 0; + int r; + bool b = false; if ('0' == ascii[0]) { - *v = false; r = 1; } else if ('1' == ascii[0]) { - *v = true; + b = true; r = 1; } else if (0 == memcmp(ascii,"true",4)) { - *v = true; + b = true; r = 4; } else if (0 == memcmp(ascii,"false",5)) { - *v = false; r = 5; } else if (0 == memcmp(ascii,"on",2)) { - *v = true; + b = true; r = 2; } else if (0 == memcmp(ascii,"off",3)) { - *v = false; r = 3; } else { return -14; @@ -598,6 +596,7 @@ int parse_ascii_bool(bool *v, const char *ascii) char c = ascii[r]; if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_')) return -15; + *v = b; return r; } @@ -964,17 +963,17 @@ Message *Message::getMember(const char *n) long l = strtol(b+1,&e,0); if ((l < 0) || (*e != ']')) return 0; - r = r->p_getMember(n,b,l); + r = r->p_getMember(n,b-n,l); n = e + 1; if (*n == 0) return r; if (*n != '.') return 0; } else if (d) { - r = r->p_getMember(n,d); + r = r->p_getMember(n,d-n); n = d; } else { - return r->p_getMember(n,n+strlen(n)); + return r->p_getMember(n,strlen(n)); } ++n; } while (r); diff --git a/components/wfc/wfccore_pc.h b/components/wfc/wfccore_pc.h index 04e735e..d52fcd8 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.3 (hg:453/f8bb395db7c6) + * WFC Version: P2304 (hg:456/095c4982cbea) * WFC is Copyright 2015-2022, Thomas Maier-Komor * * Source Information: @@ -10,7 +10,7 @@ * Copyright: 2018-2023 * Author : Thomas Maier-Komor * - * Code generated on 2023-03-05, 15:22:10 (CET). + * Code generated on 2023-04-23, 11:07:00 (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 @@ -88,6 +88,25 @@ * asserts, comments, genlib, gnux, withEqual, withUnequal */ +#ifdef WFC_ENDIAN +#if WFC_ENDIAN != 0 +#error WFC generated code incompatible due to endian +#endif +#else +#define WFC_ENDIAN 0 // unknown endian +#endif + +#define HAVE_TO_MEMORY 1 +#define HAVE_TO_STRING 1 +#define HAVE_TO_WIRE 1 +#define HAVE_TO_ASCII 1 +#define HAVE_TO_JSON 1 +#define HAVE_GET_MEMBER 1 +#define HAVE_FROM_MEMORY 1 +#define ON_ERROR_CANCEL 1 +#define HAVE_ENUM_MAP 1 +#define HAVE_ENUM_NAMES 1 + #ifndef _WFCCORE_H #define _WFCCORE_H @@ -153,8 +172,8 @@ class Message Message *getMember(const char *); protected: - virtual Message *p_getMember(const char *s, const char *e) = 0; - virtual Message *p_getMember(const char *s, const char *e, unsigned x) = 0; + virtual Message *p_getMember(const char *s, unsigned n) = 0; + virtual Message *p_getMember(const char *s, unsigned n, unsigned x) = 0; }; inline Message::~Message() diff --git a/data/lua/rgbcct.lua b/data/lua/rgbcct.lua index 57ecfc3..ce716d8 100644 --- a/data/lua/rgbcct.lua +++ b/data/lua/rgbcct.lua @@ -1,91 +1,56 @@ if colors == nil then var_new('color','none'); colors = { - ["schwarz"] = {0,0,0}, - ["weiß"] = {255,255,255}, ["rot"] = {255,0,0}, ["limette"] = {0,255,0}, ["blau"] = {0,0,255}, ["gelb"] = {255,255,0}, - ["cyan / aqua"] = {0,255,255}, - ["magenta / fuchsia"] = {255,0,255}, - ["silber"] = {192, 192, 192}, - ["grau"] = {128, 128, 128}, - ["kastanienbraun"] = {128,0,0}, + ["cyan"] = {0,255,255}, + ["magenta"] = {255,0,255}, ["olive"] = {128,128,0}, ["grün"] = {0,128,0}, ["lila"] = {128,0,128}, ["blaugrün"] = {0,128,128}, ["marine"] = {0,0,128}, - ["kastanienbraun"] = {128,0,0}, ["dunkelrot"] = {139,0,0}, ["braun"] = {165, 42, 42}, ["schamottestein"] = {178, 34, 34}, ["purpur"] = {220, 20, 60}, - ["rot"] = {255,0,0}, - ["tomate"] = {255,99,71}, ["koralle"] = {255, 127, 80}, ["indisch rot"] = {205,92,92}, - ["leichte koralle"] = {240, 128, 128}, - ["dunkler lachs"] = {233, 150, 122}, ["lachs"] = {250, 128, 114}, - ["leichter lachs"] = {255, 160, 122}, ["orange rot"] = {255,69,0}, ["dunkelorange"] = {255, 140, 0}, ["orange"] = {255,165,0}, ["gold"] = {255,215,0}, - ["dunkelgoldener stab"] = {184, 134, 11}, - ["goldener stab"] = {218, 165, 32}, - ["blassgoldener stab"] = {238,232,170}, - ["dunkles khaki"] = {189, 183, 107}, - ["khaki"] = {240, 230, 140}, - ["olive"] = {128,128,0}, - ["gelb"] = {255,255,0}, ["gelbgrün"] = {154, 205, 50}, ["dunkelolivgrün"] = {85, 107, 47}, ["olivgrün"] = {107, 142, 35}, ["rasen grün"] = {124,252,0}, - ["wiederverwendung von diagrammen"] = {127,255,0}, ["grün gelb"] = {173, 255, 47}, ["dunkelgrün"] = {0,100,0}, - ["grün"] = {0,128,0}, ["waldgrün"] = {34, 139, 34}, - ["limette"] = {0,255,0}, ["lindgrün"] = {50, 205, 50}, ["hellgrün"] = {144, 238, 144}, - ["blasses grün"] = {152, 251, 152}, ["dunkles seegrün"] = {143, 188, 143}, - ["mittleres frühlingsgrün"] = {0,250,154}, ["frühlingsgrün"] = {0,255,127}, ["meeresgrün"] = {46, 139, 87}, ["medium aqua marine"] = {102, 205, 170}, ["mittleres seegrün"] = {60, 179, 113}, - ["hell meergrün"] = {32, 178, 170}, - ["dunkles schiefergrau"] = {47,79,79}, - ["blaugrün"] = {0,128,128}, ["dunkles cyan"] = {0,139,139}, ["aqua"] = {0,255,255}, - ["cyan"] = {0,255,255}, - ["helles cyan"] = {224,255,255}, ["dunkles türkis"] = {0,206,209}, ["türkis"] = {64, 224, 208}, ["mittleres türkis"] = {72, 209, 204}, - ["blass türkis"] = {175, 238, 238}, ["aqua marine"] = {127, 255, 212}, - ["puderblau"] = {176, 224, 230}, ["kadettenblau"] = {95, 158, 160}, ["stahlblau"] = {70, 130, 180}, ["kornblumenblau"] = {100, 149, 237}, ["tiefes himmelblau"] = {0,191,255}, ["dodger blau"] = {30, 144, 255}, - ["hellblau"] = {173, 216, 230}, ["himmelblau"] = {135, 206, 235}, - ["hell himmelblau"] = {135, 206, 250}, ["mitternachtsblau"] = {25,25,112}, - ["marine"] = {0,0,128}, - ["dunkelblau"] = {0,0,139}, ["mittelblau"] = {0,0,205}, - ["blau"] = {0,0,255}, ["königsblau"] = {65, 105, 225}, ["blau violett"] = {138, 43, 226}, ["indigo"] = {75,0,130}, @@ -95,203 +60,15 @@ if colors == nil then ["mittelviolett"] = {147, 112, 219}, ["dunkles magenta"] = {139,0,139}, ["dunkelviolett"] = {148,0,211}, - ["dunkle orchidee"] = {153,50,204}, - ["mittlere orchidee"] = {186,85,211}, - ["lila"] = {128,0,128}, - ["distel"] = {216, 191, 216}, + ["orchidee"] = {153,50,204}, ["pflaume"] = {221,160,221}, ["violett"] = {238, 130, 238}, - ["magenta / fuchsia"] = {255,0,255}, - ["orchidee"] = {218,112,214}, ["mittelviolett rot"] = {199, 21, 133}, ["hellviolettrot"] = {219,112,147}, ["dunkelrosa"] = {255, 20, 147}, ["pink"] = {255, 105, 180}, - ["hell-pink"] = {255, 182, 193}, - ["rosa"] = {255, 192, 203}, - ["altweiß"] = {250, 235, 215}, - ["beige"] = {245, 245, 220}, - ["biskuit"] = {255,228,196}, - ["blanchierte mandel"] = {255,235,205}, - ["weizen"] = {245,222,179}, - ["maisseide"] = {255,248,220}, - ["zitronen-chiffon"] = {255, 250, 205}, - ["hellgoldener stab gelb"] = {250, 250, 210}, - ["hellgelb"] = {255, 255, 224}, - ["sattel braun"] = {139,69,19}, ["sienna"] = {160,82,45}, ["peru"] = {205, 133, 63}, - ["kräftiges holz"] = {222, 184, 135}, - ["tan"] = {210, 180, 140}, - ["rosigbraun"] = {188, 143, 143}, - ["mokassin"] = {255,228,181}, - ["navajo weiß"] = {255,222,173}, - ["pfirsich-blätterteig"] = {255,218,185}, - ["neblige rose"] = {255,228,225}, - ["lavendel erröten"] = {255,240,245}, - ["leinen-"] = {250, 240, 230}, - ["alte spitze"] = {253, 245, 230}, - ["papaya-peitsche"] = {255,239,213}, - ["muschel"] = {255, 245, 238}, - ["minzcreme"] = {245,255,250}, - ["schiefer grau"] = {112, 128, 144}, - ["hell schiefergrau"] = {119, 136, 153}, - ["hellstahlblau"] = {176, 196, 222}, - ["lavendel"] = {230,230,250}, - ["blumenweiß"] = {255, 250, 240}, - ["alice blau"] = {240, 248, 255}, - ["geist weiß"] = {248,248,255}, - ["honigtau"] = {240, 255, 240}, - ["elfenbein"] = {255, 255, 240}, - ["azurblau"] = {240, 255, 255}, - ["schnee"] = {255, 250, 250}, - ["dunkelgrau / dunkelgrau"] = {105, 105, 105}, - ["grau / grau"] = {128, 128, 128}, - ["dunkelgrau / dunkelgrau"] = {169, 169, 169}, - ["silber-"] = {192, 192, 192}, - ["hellgrau / hellgrau"] = {211,211,211}, - ["gainsboro"] = {220,220,220}, - ["weißer rauch"] = {245, 245, 245}, - -- ["weiß"] = {255,255,255}, - -- ["maroon"] = {128,0,0}, - -- ["dark red"] = {139,0,0}, - -- ["brown"] = {165,42,42}, - -- ["firebrick"] = {178,34,34}, - -- ["crimson"] = {220,20,60}, - -- ["red"] = {255,0,0}, - -- ["tomato"] = {255,99,71}, - -- ["coral"] = {255,127,80}, - -- ["indian red"] = {205,92,92}, - -- ["light coral"] = {240,128,128}, - -- ["dark salmon"] = {233,150,122}, - -- ["salmon"] = {250,128,114}, - -- ["light salmon"] = {255,160,122}, - -- ["orange red"] = {255,69,0}, - -- ["dark orange"] = {255,140,0}, - -- ["orange"] = {255,165,0}, - -- ["gold"] = {255,215,0}, - -- ["dark golden rod"] = {184,134,11}, - -- ["golden rod"] = {218,165,32}, - -- ["pale golden rod"] = {238,232,170}, - -- ["dark khaki"] = {189,183,107}, - -- ["khaki"] = {240,230,140}, - -- ["olive"] = {128,128,0}, - -- ["yellow"] = {255,255,0}, - -- ["yellow green"] = {154,205,50}, - -- ["dark olive green"] = {85,107,47}, - -- ["olive drab"] = {107,142,35}, - -- ["lawn green"] = {124,252,0}, - -- ["chartreuse"] = {127,255,0}, - -- ["green yellow"] = {173,255,47}, - -- ["dark green"] = {0,100,0}, - -- ["green"] = {0,128,0}, - -- ["forest green"] = {34,139,34}, - -- ["lime"] = {0,255,0}, - -- ["lime green"] = {50,205,50}, - -- ["light green"] = {144,238,144}, - -- ["pale green"] = {152,251,152}, - -- ["dark sea green"] = {143,188,143}, - -- ["medium spring green"] = {0,250,154}, - -- ["spring green"] = {0,255,127}, - -- ["sea green"] = {46,139,87}, - -- ["medium aqua marine"] = {102,205,170}, - -- ["medium sea green"] = {60,179,113}, - -- ["light sea green"] = {32,178,170}, - -- ["dark slate gray"] = {47,79,79}, - -- ["teal"] = {0,128,128}, - -- ["dark cyan"] = {0,139,139}, - -- ["aqua"] = {0,255,255}, - -- ["cyan"] = {0,255,255}, - -- ["light cyan"] = {224,255,255}, - -- ["dark turquoise"] = {0,206,209}, - -- ["turquoise"] = {64,224,208}, - -- ["medium turquoise"] = {72,209,204}, - -- ["pale turquoise"] = {175,238,238}, - -- ["aqua marine"] = {127,255,212}, - -- ["powder blue"] = {176,224,230}, - -- ["cadet blue"] = {95,158,160}, - -- ["steel blue"] = {70,130,180}, - -- ["corn flower blue"] = {100,149,237}, - -- ["deep sky blue"] = {0,191,255}, - -- ["dodger blue"] = {30,144,255}, - -- ["light blue"] = {173,216,230}, - -- ["sky blue"] = {135,206,235}, - -- ["light sky blue"] = {135,206,250}, - -- ["midnight blue"] = {25,25,112}, - -- ["navy"] = {0,0,128}, - -- ["dark blue"] = {0,0,139}, - -- ["medium blue"] = {0,0,205}, - -- ["blue"] = {0,0,255}, - -- ["royal blue"] = {65,105,225}, - -- ["blue violet"] = {138,43,226}, - -- ["indigo"] = {75,0,130}, - -- ["dark slate blue"] = {72,61,139}, - -- ["slate blue"] = {106,90,205}, - -- ["medium slate blue"] = {123,104,238}, - -- ["medium purple"] = {147,112,219}, - -- ["dark magenta"] = {139,0,139}, - -- ["dark violet"] = {148,0,211}, - -- ["dark orchid"] = {153,50,204}, - -- ["medium orchid"] = {186,85,211}, - -- ["purple"] = {128,0,128}, - -- ["thistle"] = {216,191,216}, - -- ["plum"] = {221,160,221}, - -- ["violet"] = {238,130,238}, - -- ["magenta / fuchsia"] = {255,0,255}, - -- ["orchid"] = {218,112,214}, - -- ["medium violet red"] = {199,21,133}, - -- ["pale violet red"] = {219,112,147}, - -- ["deep pink"] = {255,20,147}, - -- ["hot pink"] = {255,105,180}, - -- ["light pink"] = {255,182,193}, - -- ["pink"] = {255,192,203}, - -- ["antique white"] = {250,235,215}, - -- ["beige"] = {245,245,220}, - -- ["bisque"] = {255,228,196}, - -- ["blanched almond"] = {255,235,205}, - -- ["wheat"] = {245,222,179}, - -- ["corn silk"] = {255,248,220}, - -- ["lemon chiffon"] = {255,250,205}, - -- ["light golden rod yellow"] = {250,250,210}, - -- ["light yellow"] = {255,255,224}, - -- ["saddle brown"] = {139,69,19}, - -- ["sienna"] = {160,82,45}, - -- ["chocolate"] = {210,105,30}, - -- ["peru"] = {205,133,63}, - -- ["sandy brown"] = {244,164,96}, - -- ["burly wood"] = {222,184,135}, - -- ["tan"] = {210,180,140}, - -- ["rosy brown"] = {188,143,143}, - -- ["moccasin"] = {255,228,181}, - -- ["navajo white"] = {255,222,173}, - -- ["peach puff"] = {255,218,185}, - -- ["misty rose"] = {255,228,225}, - -- ["lavender blush"] = {255,240,245}, - -- ["linen"] = {250,240,230}, - -- ["old lace"] = {253,245,230}, - -- ["papaya whip"] = {255,239,213}, - -- ["sea shell"] = {255,245,238}, - -- ["mint cream"] = {245,255,250}, - -- ["slate gray"] = {112,128,144}, - -- ["light slate gray"] = {119,136,153}, - -- ["light steel blue"] = {176,196,222}, - -- ["lavender"] = {230,230,250}, - -- ["floral white"] = {255,250,240}, - -- ["alice blue"] = {240,248,255}, - -- ["ghost white"] = {248,248,255}, - -- ["honeydew"] = {240,255,240}, - -- ["ivory"] = {255,255,240}, - -- ["azure"] = {240,255,255}, - -- ["snow"] = {255,250,250}, - -- ["black"] = {0,0,0}, - -- ["dim gray / dim grey"] = {105,105,105}, - -- ["gray / grey"] = {128,128,128}, - -- ["dark gray / dark grey"] = {169,169,169}, - -- ["silver"] = {192,192,192}, - -- ["light gray / light grey"] = {211,211,211}, - -- ["gainsboro"] = {220,220,220}, - -- ["white smoke"] = {245,245,245}, - -- ["white"] = {255,255,255}, } end @@ -301,11 +78,11 @@ for k,v in pairs(colors) do numcolors = numcolors + 1 colornames[numcolors] = k end +h,m = time() function color_set(arg) local r,g,b,c,w - --log_info("color_set "..arg) if (string.sub(arg,1,1) == '#') then r = tonumber(string.sub(arg,2,3),16) g = tonumber(string.sub(arg,4,5),16) @@ -319,8 +96,6 @@ function color_set(arg) r,g,b,c,w = 0,1023,0,0,0 elseif arg == "cyan" then r,g,b,c,w = 0,1023,1023,0,0 - elseif arg == "magenta" then - r,g,b,c,w = 1023,0,1023,0,0 elseif arg == "yellow" then r,g,b,c,w = 1023,1023,0,0,0 elseif arg == "white" then @@ -337,8 +112,6 @@ function color_set(arg) r,g,b,c,w = 1023,1023,1023,1023,1023 elseif arg == "navy" then r,g,b,c,w = 0,0,512,0,0 - elseif arg == "olive" then - r,g,b,c,w = 512,512,0,0,0 else if colors[arg] then r = colors[arg][1]*4 diff --git a/data/lua/tracks.lua b/data/lua/tracks.lua index 0b02231..4a541e3 100644 --- a/data/lua/tracks.lua +++ b/data/lua/tracks.lua @@ -1,16 +1,44 @@ function track_switch(tr) log_info('track_switch '..tr) - local tid = tmr_getid(tr) + local tidn = string.sub(tr,1,-2) + local tid = tmr_getid(tidn) if tid == 0 then - tid = tmr_create(tr,250) - event_attach(tr..'`timeout','lua!run','track_switch_off("'..tr..'")') + tid = tmr_create(tidn,250) + print("timer "..tid) + event_attach(tidn..'`timeout','lua!run','track_switch_off("'..tidn..'")') + print("attached"..tidn) end gpio_set(tr,1) - tmr_start(tr) + tmr_start(tid) end function track_switch_off(tr) log_info('switch_off '..tr) - gpio_set(tr,0) + gpio_set(tr..'a',0) + gpio_set(tr..'b',0) end +function track_init() + if track_init_state == nil then + track_init_state = 1 + init_tmr = tmr_create('tracktmr',500) + event_attach('tracktmr`timeout','lua!run','track_init') + else + track_init_state = track_init_state + 1 + end + local track + if track_init_state <= 8 then + track = "w"..track_init_state.."a" + elseif track_init_state <= 16 then + track = "w"..(track_init_state-8).."b" + else + return + end + print(track) + track_switch(track) + tmr_start(init_tmr) +end + +--for i=1,8 do +-- track_switch("w"..i.."a") +--end diff --git a/data/man/dumpadm.man b/data/man/dumpadm.man new file mode 100644 index 0000000..d436034 --- /dev/null +++ b/data/man/dumpadm.man @@ -0,0 +1,5 @@ +synopsis: dumpadm