Terminal: change command-line parser (#2247)
Change the underlying command line handling:
- switch to a custom parser, inspired by redis / sds
- update terminalRegisterCommand signature, pass only bare minimum
- clean-up `help` & `commands`. update settings `set`, `get` and `del`
- allow our custom test suite to run command-line tests
- clean-up Stream IO to allow us to print large things into debug stream (for example, `eeprom.dump`)
- send parsing errors to the debug log
As a proof of concept, introduce `TERMINAL_MQTT_SUPPORT` and `TERMINAL_WEB_API_SUPPORT`
- MQTT subscribes to the `<root>/cmd/set` and sends response to the `<root>/cmd`. We can't output too much, as we don't have any large-send API.
- Web API listens to the `/api/cmd?apikey=...&line=...` (or PUT, params inside the body). This one is intended as a possible replacement of the `API_SUPPORT`. Internals introduce a 'task' around the AsyncWebServerRequest object that will simulate what WiFiClient does and push data into it continuously, switching between CONT and SYS.
Both are experimental. We only accept a single command and not every command is updated to use Print `ctx.output` object. We are also somewhat limited by the Print / Stream overall, perhaps I am overestimating the usefulness of Arduino compatibility to such an extent :)
Web API handler can also sometimes show only part of the result, whenever the command tries to yield() by itself waiting for something. Perhaps we would need to create a custom request handler for that specific use-case. 4 years ago Button pin provider & runtime settings (#2162)
* wip
* cleanup buttons-through-serial code, remove hw mention from button module
* remove wip
* implement mqtt settings
* fixup struct members, dual no longer allocates debouncer
* add missing debounceevent lib
* fix missing event_handler, update names
* fix namespace
* drop lib
* fix int<->bool comparison
* Move gpio16 handling from DigitalPin to EventHandler
* Cleanup debounceevent headers
* Don't expect system headers to be included
* re 70b54c489f - no allocation, for real
* Adjust settings names
* dont retain by default
* unused
* typo
* Fix length type (ref 6017ad9474c5ea2f77fbca5f3c19b6cef058b2e9)
* Move pin class outside of debounce lib, lowercase ns
* move event handling inside of button_t
* refactor config. ..._MODE -> _CONFIG, ..._MODE_... -> ..._ACTION_...
* fix test
* naming
* move indexed value to header
* refactor actions into direct opts
* fix webui, fix buttons not respecting old user setting
* change button config format from bitmask to a struct, adjust settings conversion
* proxy some more header defautls, fix web kv
* gpiopin
* adjust webui func to support every setting
* clarify single-return event->string
* fix dual setting
* fix dual packet condition, de-duplicate funcs
* fix bogus warning 4 years ago Button pin provider & runtime settings (#2162)
* wip
* cleanup buttons-through-serial code, remove hw mention from button module
* remove wip
* implement mqtt settings
* fixup struct members, dual no longer allocates debouncer
* add missing debounceevent lib
* fix missing event_handler, update names
* fix namespace
* drop lib
* fix int<->bool comparison
* Move gpio16 handling from DigitalPin to EventHandler
* Cleanup debounceevent headers
* Don't expect system headers to be included
* re 70b54c489f - no allocation, for real
* Adjust settings names
* dont retain by default
* unused
* typo
* Fix length type (ref 6017ad9474c5ea2f77fbca5f3c19b6cef058b2e9)
* Move pin class outside of debounce lib, lowercase ns
* move event handling inside of button_t
* refactor config. ..._MODE -> _CONFIG, ..._MODE_... -> ..._ACTION_...
* fix test
* naming
* move indexed value to header
* refactor actions into direct opts
* fix webui, fix buttons not respecting old user setting
* change button config format from bitmask to a struct, adjust settings conversion
* proxy some more header defautls, fix web kv
* gpiopin
* adjust webui func to support every setting
* clarify single-return event->string
* fix dual setting
* fix dual packet condition, de-duplicate funcs
* fix bogus warning 4 years ago Button pin provider & runtime settings (#2162)
* wip
* cleanup buttons-through-serial code, remove hw mention from button module
* remove wip
* implement mqtt settings
* fixup struct members, dual no longer allocates debouncer
* add missing debounceevent lib
* fix missing event_handler, update names
* fix namespace
* drop lib
* fix int<->bool comparison
* Move gpio16 handling from DigitalPin to EventHandler
* Cleanup debounceevent headers
* Don't expect system headers to be included
* re 70b54c489f - no allocation, for real
* Adjust settings names
* dont retain by default
* unused
* typo
* Fix length type (ref 6017ad9474c5ea2f77fbca5f3c19b6cef058b2e9)
* Move pin class outside of debounce lib, lowercase ns
* move event handling inside of button_t
* refactor config. ..._MODE -> _CONFIG, ..._MODE_... -> ..._ACTION_...
* fix test
* naming
* move indexed value to header
* refactor actions into direct opts
* fix webui, fix buttons not respecting old user setting
* change button config format from bitmask to a struct, adjust settings conversion
* proxy some more header defautls, fix web kv
* gpiopin
* adjust webui func to support every setting
* clarify single-return event->string
* fix dual setting
* fix dual packet condition, de-duplicate funcs
* fix bogus warning 4 years ago Button pin provider & runtime settings (#2162)
* wip
* cleanup buttons-through-serial code, remove hw mention from button module
* remove wip
* implement mqtt settings
* fixup struct members, dual no longer allocates debouncer
* add missing debounceevent lib
* fix missing event_handler, update names
* fix namespace
* drop lib
* fix int<->bool comparison
* Move gpio16 handling from DigitalPin to EventHandler
* Cleanup debounceevent headers
* Don't expect system headers to be included
* re 70b54c489f - no allocation, for real
* Adjust settings names
* dont retain by default
* unused
* typo
* Fix length type (ref 6017ad9474c5ea2f77fbca5f3c19b6cef058b2e9)
* Move pin class outside of debounce lib, lowercase ns
* move event handling inside of button_t
* refactor config. ..._MODE -> _CONFIG, ..._MODE_... -> ..._ACTION_...
* fix test
* naming
* move indexed value to header
* refactor actions into direct opts
* fix webui, fix buttons not respecting old user setting
* change button config format from bitmask to a struct, adjust settings conversion
* proxy some more header defautls, fix web kv
* gpiopin
* adjust webui func to support every setting
* clarify single-return event->string
* fix dual setting
* fix dual packet condition, de-duplicate funcs
* fix bogus warning 4 years ago |
|
- //------------------------------------------------------------------------------
- // Do not change this file unless you know what you are doing
- // Configuration settings are in the general.h file
- //------------------------------------------------------------------------------
-
- #pragma once
-
- //------------------------------------------------------------------------------
- // Various modules configuration
-
- #if DEBUG_TELNET_SUPPORT
- #undef TELNET_SUPPORT
- #define TELNET_SUPPORT 1
- #endif
-
- #if not WEB_SUPPORT
- #undef DEBUG_WEB_SUPPORT
- #define DEBUG_WEB_SUPPORT 0
- #endif
-
- #if not WEB_SUPPORT
- #undef API_SUPPORT
- #define API_SUPPORT 0 // API support requires web support
- #endif
-
- #if not WEB_SUPPORT
- #undef SSDP_SUPPORT
- #define SSDP_SUPPORT 0 // SSDP support requires web support
- #endif
-
- #if UART_MQTT_SUPPORT
- #undef MQTT_SUPPORT
- #define MQTT_SUPPORT 1 // UART<->MQTT requires MQTT and no serial debug
- #undef DEBUG_SERIAL_SUPPORT
- #define DEBUG_SERIAL_SUPPORT 0 // TODO: compare UART_MQTT_PORT with DEBUG_PORT? (as strings)
- #endif
-
- #if ALEXA_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // If Alexa enabled enable BROKER
- #undef RELAY_SUPPORT
- #define RELAY_SUPPORT 1 // and switches
- #endif
-
- #if RPN_RULES_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // If RPN Rules enabled enable BROKER
- #undef MQTT_SUPPORT
- #define MQTT_SUPPORT 1
- #endif
-
- #if LED_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // If LED is enabled enable BROKER to supply status changes
- #endif
-
- #if INFLUXDB_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // If InfluxDB enabled enable BROKER
- #endif
-
- #if DOMOTICZ_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // If Domoticz enabled enable BROKER
- #undef MQTT_SUPPORT
- #define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT
- #endif
-
- #if HOMEASSISTANT_SUPPORT
- #undef MQTT_SUPPORT
- #define MQTT_SUPPORT 1 // If Home Assistant enabled enable MQTT
- #endif
-
- #if THINGSPEAK_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // If Thingspeak enabled enable BROKER
- #endif
-
- #if THERMOSTAT_SUPPORT
- #undef MQTT_USE_JSON
- #define MQTT_USE_JSON 1 // Thermostat depends on group messages in a JSON body
- #undef RELAY_SUPPORT
- #define RELAY_SUPPORT 1 // Thermostat depends on switches
- #endif
-
- #if SCHEDULER_SUPPORT
- #undef NTP_SUPPORT
- #define NTP_SUPPORT 1 // Scheduler needs NTP to work
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // Scheduler needs Broker to trigger every minute
- #undef RELAY_SUPPORT
- #define RELAY_SUPPORT 1 // Scheduler needs relays
- #endif
-
- #if LWIP_VERSION_MAJOR != 1
- #undef MDNS_CLIENT_SUPPORT
- #define MDNS_CLIENT_SUPPORT 0 // default resolver already handles this
- #endif
-
- #if not defined(ARDUINO_ESP8266_RELEASE_2_3_0)
- #undef TELNET_SERVER_ASYNC_BUFFERED
- #define TELNET_SERVER_ASYNC_BUFFERED 1 // enable buffered telnet by default on latest Cores
- #endif
-
- #if LIGHT_PROVIDER == LIGHT_PROVIDER_TUYA
- #undef TUYA_SUPPORT
- #define TUYA_SUPPORT 1 // Need base Tuya module for this to work
- #undef LIGHT_USE_TRANSITIONS
- #define LIGHT_USE_TRANSITIONS 0 // TODO: temporary, maybe slower step instead?
- #endif
-
- #if TUYA_SUPPORT
- #undef BROKER_SUPPORT
- #define BROKER_SUPPORT 1 // Broker is required to process relay & lights events
- #undef RELAY_SUPPORT
- #define RELAY_SUPPORT 1 // Most of the time we require it
- #endif
-
- #if TERMINAL_WEB_API_SUPPORT
- #undef TERMINAL_SUPPORT
- #define TERMINAL_SUPPORT 1 // Need terminal command line parser and commands
- #undef WEB_SUPPORT
- #define WEB_SUPPORT 1 // Registered as web server request handler
- #endif
-
- #if TERMINAL_MQTT_SUPPORT
- #undef TERMINAL_SUPPORT
- #define TERMINAL_SUPPORT 1 // Need terminal command line parser and commands
- #undef MQTT_SUPPORT
- #define MQTT_SUPPORT 1 // Subscribe and publish things
- #endif
-
- //------------------------------------------------------------------------------
- // Hint about ESPAsyncTCP options and our internal one
- // TODO: clean-up SSL_ENABLED and USE_SSL settings for 1.15.0
-
- #if ASYNC_TCP_SSL_ENABLED && SECURE_CLIENT == SECURE_CLIENT_NONE
- #undef SECURE_CLIENT
- #define SECURE_CLIENT SECURE_CLIENT_AXTLS
- #endif
-
- #if THINGSPEAK_USE_SSL && THINGSPEAK_USE_ASYNC && (!ASYNC_TCP_SSL_ENABLED)
- #warning "Thingspeak in ASYNC mode requires a globally defined ASYNC_TCP_SSL_ENABLED=1"
- #undef THINGSPEAK_SUPPORT
- #define THINGSPEAK_SUPPORT 0 // Thingspeak in ASYNC mode requires ASYNC_TCP_SSL_ENABLED
- #endif
-
- #if WEB_SUPPORT && WEB_SSL_ENABLED && (!ASYNC_TCP_SSL_ENABLED)
- #warning "WEB_SUPPORT with SSL requires a globally defined ASYNC_TCP_SSL_ENABLED=1"
- #undef WEB_SSL_ENABLED
- #define WEB_SSL_ENABLED 0 // WEB_SUPPORT mode th SSL requires ASYNC_TCP_SSL_ENABLED
- #endif
-
- #if !DEBUG_SUPPORT
- #undef DEBUG_LOG_BUFFER_SUPPORT
- #define DEBUG_LOG_BUFFER_SUPPORT 0 // Can't buffer if there is no debugging enabled.
- // Helps to avoid checking twice for both DEBUG_SUPPORT and BUFFER_LOG_SUPPORT
- #endif
-
- //------------------------------------------------------------------------------
- // These depend on newest Core libraries
-
- #if LLMNR_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
- #undef LLMNR_SUPPORT
- #define LLMNR_SUPPORT 0
- #endif
-
- #if NETBIOS_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
- #undef NETBIOS_SUPPORT
- #define NETBIOS_SUPPORT 0
- #endif
-
- #if SSDP_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
- #undef SSDP_SUPPORT
- #define SSDP_SUPPORT 0
- #endif
-
- //------------------------------------------------------------------------------
- // Change ntp module depending on Core version
-
- #if NTP_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
- #define NTP_LEGACY_SUPPORT 1
- #else
- #define NTP_LEGACY_SUPPORT 0
- #endif
-
- //------------------------------------------------------------------------------
- // When using Dual / Lightfox Dual, notify that Serial should be used
-
- #if (BUTTON_EVENTS_SOURCE == BUTTON_EVENTS_SOURCE_ITEAD_SONOFF_DUAL) || \
- (BUTTON_EVENTS_SOURCE == BUTTON_EVENTS_SOURCE_FOXEL_LIGHTFOX_DUAL)
- #if DEBUG_SERIAL_SUPPORT
- #warning "DEBUG_SERIAL_SUPPORT conflicts with the current BUTTON_EVENTS_SOURCE"
- #undef DEBUG_SERIAL_SUPPORT
- #define DEBUG_SERIAL_SUPPORT 0
- #endif
- #endif
-
- //------------------------------------------------------------------------------
- // It looks more natural that one click will enable display
- // and long click will switch relay
-
- #if THERMOSTAT_DISPLAY_SUPPORT
- #undef BUTTON1_CLICK
- #define BUTTON1_CLICK BUTTON_ACTION_DISPLAY_ON
- #undef BUTTON1_LNGCLICK
- #define BUTTON1_LNGCLICK BUTTON_ACTION_TOGGLE
- #endif
-
- //------------------------------------------------------------------------------
- // We should always set MQTT_MAX_PACKET_SIZE
-
- #if MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT
- #if not defined(MQTT_MAX_PACKET_SIZE)
- #warning "MQTT_MAX_PACKET_SIZE should be set in `build_flags = ...` of the environment! Default value is used instead."
- #endif
- #endif
-
- //------------------------------------------------------------------------------
- // Disable BME680 support if using Core version 2.3.0 due to memory constraints.
-
- #if BME680_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
- #warning "BME680_SUPPORT is not available when using Arduino Core 2.3.0 due to memory constraints. Please use Arduino Core 2.6.3+ instead (or set `platform = ${common.platform_latest}` for the latest version)."
- #undef BME680_SUPPORT
- #define BME680_SUPPORT 0
- #endif
-
- //------------------------------------------------------------------------------
- // Prometheus needs web server + request handler API
-
- #if PROMETHEUS_SUPPORT
- #undef WEB_SUPPORT
- #define WEB_SUPPORT 1
- #endif
|