Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1792 lines
60 KiB

8 years ago
8 years ago
6 years ago
7 years ago
7 years ago
7 years ago
3 years ago
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
api: rework plain and JSON implementations (#2405) - match paths through a custom AsyncWebHandler instead of using generic not-found fallback handler - allow MQTT-like patterns when registering paths (`simple/path`, `path/+/something`, `path/#`) Replaces `relay/0`, `relay/1` etc. with `relay/+`. Magnitudes are plain paths, but using `/+` in case there's more than 1 magnitude of the same type. - restore `std::function` as callback container (no more single-byte arg nonsense). Still, limit to 1 type per handler type - adds JSON handlers which will receive JsonObject root as both input and output. Same logic as plain - GET returns resource data, PUT updates it. - breaking change to `apiAuthenticate(request)`, it no longer will do `request->send(403)` and expect this to be handled externally. - allow `Api-Key` header containing the key, works for both GET & PUT plain requests. The only way to set apikey for JSON. - add `ApiRequest::param` to retrieve both GET and PUT params (aka args), remove ApiBuffer - remove `API_BUFFER_SIZE`. Allow custom form-data key=value pairs for requests, allow to send basic `String`. - add `API_JSON_BUFFER_SIZE` for the JSON buffer (both input and output) - `/apis` replaced with `/api/list`, no longer uses custom handler and is an `apiRegister` callback - `/api/rpc` custom handler replaced with an `apiRegister` callback WIP further down: - no more `webLog` for API requests, unless `webAccessLog` / `WEB_ACCESS_LOG` is set to `1`. This also needs to happen to the other handlers. - migrate to ArduinoJson v6, since it become apparent it is actually a good upgrade :) - actually make use of JSON endpoints more, right now it's just existing GET for sensors and relays - fork ESPAsyncWebServer to cleanup path parsing and temporary objects attached to the request (also, fix things a lot of things based on PRs there...)
4 years ago
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
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
8 years ago
8 years ago
api: rework plain and JSON implementations (#2405) - match paths through a custom AsyncWebHandler instead of using generic not-found fallback handler - allow MQTT-like patterns when registering paths (`simple/path`, `path/+/something`, `path/#`) Replaces `relay/0`, `relay/1` etc. with `relay/+`. Magnitudes are plain paths, but using `/+` in case there's more than 1 magnitude of the same type. - restore `std::function` as callback container (no more single-byte arg nonsense). Still, limit to 1 type per handler type - adds JSON handlers which will receive JsonObject root as both input and output. Same logic as plain - GET returns resource data, PUT updates it. - breaking change to `apiAuthenticate(request)`, it no longer will do `request->send(403)` and expect this to be handled externally. - allow `Api-Key` header containing the key, works for both GET & PUT plain requests. The only way to set apikey for JSON. - add `ApiRequest::param` to retrieve both GET and PUT params (aka args), remove ApiBuffer - remove `API_BUFFER_SIZE`. Allow custom form-data key=value pairs for requests, allow to send basic `String`. - add `API_JSON_BUFFER_SIZE` for the JSON buffer (both input and output) - `/apis` replaced with `/api/list`, no longer uses custom handler and is an `apiRegister` callback - `/api/rpc` custom handler replaced with an `apiRegister` callback WIP further down: - no more `webLog` for API requests, unless `webAccessLog` / `WEB_ACCESS_LOG` is set to `1`. This also needs to happen to the other handlers. - migrate to ArduinoJson v6, since it become apparent it is actually a good upgrade :) - actually make use of JSON endpoints more, right now it's just existing GET for sensors and relays - fork ESPAsyncWebServer to cleanup path parsing and temporary objects attached to the request (also, fix things a lot of things based on PRs there...)
4 years ago
6 years ago
6 years ago
api: rework plain and JSON implementations (#2405) - match paths through a custom AsyncWebHandler instead of using generic not-found fallback handler - allow MQTT-like patterns when registering paths (`simple/path`, `path/+/something`, `path/#`) Replaces `relay/0`, `relay/1` etc. with `relay/+`. Magnitudes are plain paths, but using `/+` in case there's more than 1 magnitude of the same type. - restore `std::function` as callback container (no more single-byte arg nonsense). Still, limit to 1 type per handler type - adds JSON handlers which will receive JsonObject root as both input and output. Same logic as plain - GET returns resource data, PUT updates it. - breaking change to `apiAuthenticate(request)`, it no longer will do `request->send(403)` and expect this to be handled externally. - allow `Api-Key` header containing the key, works for both GET & PUT plain requests. The only way to set apikey for JSON. - add `ApiRequest::param` to retrieve both GET and PUT params (aka args), remove ApiBuffer - remove `API_BUFFER_SIZE`. Allow custom form-data key=value pairs for requests, allow to send basic `String`. - add `API_JSON_BUFFER_SIZE` for the JSON buffer (both input and output) - `/apis` replaced with `/api/list`, no longer uses custom handler and is an `apiRegister` callback - `/api/rpc` custom handler replaced with an `apiRegister` callback WIP further down: - no more `webLog` for API requests, unless `webAccessLog` / `WEB_ACCESS_LOG` is set to `1`. This also needs to happen to the other handlers. - migrate to ArduinoJson v6, since it become apparent it is actually a good upgrade :) - actually make use of JSON endpoints more, right now it's just existing GET for sensors and relays - fork ESPAsyncWebServer to cleanup path parsing and temporary objects attached to the request (also, fix things a lot of things based on PRs there...)
4 years ago
6 years ago
8 years ago
8 years ago
6 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
6 years ago
6 years ago
6 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
8 years ago
6 years ago
providers: relays, lights and buttons refactoring (#2414) - gpio module now tracks the known providers (right now, hardware and mcp expander) - refactored relay struct to use 'Provider' implementing setup,notify,change,boot instead of just BasePin actions - refactored button module to use gpio provider instead of referencing types itself - removed dual & stm code from buttons, migrate both to relay module - added status notify and change callbacks for relayStatus (i.e. 'notify' when relay status was called, but not changed. and 'changed' when it did) - relays runtime configuration keys - relay command now shows configured relays and current & target statuses - refactor the code using relayStatus(0, blah) under LIGHT_PROVIDER check to use lightState instead - remove rfbridge code form relay module. implement through a basic state listener in the rfbridge module, depend on RELAY_SUPPORT - allow to bind rf codes to real relays - drop tuya-specific lights provider, remove tuya code from relays and lights modules - integrate tuya via relay listeners and providers, use lights custom provider - implement channel transitions for tuya. disabled by default, and transition time and step are overridden to 2000 + 100. needs to be set to some value below the total time (i.e. `total transition time / step time == number of steps`, we need to figure out a correct time that serial comms could handle) - lights custom provider (global, not per-pin) and state listeners - remove lights code from relay module. implement through providers & listeners in the lights module, depend on RELAY_SUPPORT - lights per-channel relay provider (unused atm), depend on RELAY_SUPPORT - refactored channel transition - calculate step only once, make sure time + step values are sane, generate quick transitions with very small delay (10ms hardcoded) for transitions during OFF state i.e. we no longer waste 500ms (or whatever transition time is set to) on boot doing nothing - transition time + step parameter for the lightUpdate - report mask parameter for the lightUpdate - minor fixes across the board resolve #2222
3 years ago
  1. //------------------------------------------------------------------------------
  2. // Do not change this file unless you know what you are doing
  3. // To override user configuration, please see custom.h
  4. //------------------------------------------------------------------------------
  5. #pragma once
  6. //------------------------------------------------------------------------------
  7. // GENERAL
  8. //------------------------------------------------------------------------------
  9. #ifndef DEVICE_NAME
  10. #define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name
  11. #endif
  12. // When defined, ADMIN_PASS must be 8..63 printable ASCII characters. See:
  13. // https://en.wikipedia.org/wiki/Wi-Fi_Protected_Access#Target_users_(authentication_key_distribution)
  14. // https://github.com/xoseperez/espurna/issues/1151
  15. #ifndef ADMIN_PASS
  16. #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI SoftAP)
  17. #endif
  18. #ifndef USE_PASSWORD
  19. #define USE_PASSWORD 1 // Insecurity caution! Disabling this will disable password querying completely.
  20. #endif
  21. #ifndef LOOP_DELAY_TIME
  22. #define LOOP_DELAY_TIME 10 // Delay for the main loop, in millis [0-250]
  23. // Recommended minimum is 10, see:
  24. // https://github.com/xoseperez/espurna/issues/1541
  25. // https://github.com/xoseperez/espurna/issues/1631
  26. // https://github.com/esp8266/Arduino/issues/5825
  27. #endif
  28. //------------------------------------------------------------------------------
  29. // HEARTBEAT
  30. //------------------------------------------------------------------------------
  31. #ifndef HEARTBEAT_MODE
  32. #define HEARTBEAT_MODE HEARTBEAT_REPEAT
  33. #endif
  34. #ifndef HEARTBEAT_INTERVAL
  35. #define HEARTBEAT_INTERVAL 300 // Interval between heartbeat messages
  36. #endif
  37. //------------------------------------------------------------------------------
  38. // DEBUG
  39. //------------------------------------------------------------------------------
  40. // Set global logger mode. One of:
  41. // - DebugLogMode::Enabled
  42. // - DebugLogMode::Disabled
  43. // - DebugLogMode::SkipBoot
  44. #ifndef DEBUG_LOG_MODE
  45. #define DEBUG_LOG_MODE DebugLogMode::Enabled
  46. #endif
  47. // Serial debug log
  48. #ifndef DEBUG_SERIAL_SUPPORT
  49. #define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log
  50. #endif
  51. #ifndef DEBUG_PORT
  52. #define DEBUG_PORT Serial // Default debugging port
  53. #endif
  54. #ifndef SERIAL_BAUDRATE
  55. #define SERIAL_BAUDRATE 115200 // Default baudrate
  56. #endif
  57. #ifndef DEBUG_ADD_TIMESTAMP
  58. #define DEBUG_ADD_TIMESTAMP 1 // Add timestamp to debug messages
  59. // (in millis overflowing every 1000 seconds)
  60. #endif
  61. // Second serial port (used for RX)
  62. #ifndef SERIAL_RX_ENABLED
  63. #define SERIAL_RX_ENABLED 0 // Secondary serial port for RX
  64. #endif
  65. #ifndef SERIAL_RX_PORT
  66. #define SERIAL_RX_PORT Serial // This setting is usually defined
  67. // in the hardware.h file for those
  68. // boards that require it
  69. #endif
  70. #ifndef SERIAL_RX_BAUDRATE
  71. #define SERIAL_RX_BAUDRATE 115200 // Default baudrate
  72. #endif
  73. //------------------------------------------------------------------------------
  74. // UDP debug log
  75. // To receive the message on the destination computer use nc:
  76. // nc -ul 8113
  77. #ifndef DEBUG_UDP_SUPPORT
  78. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  79. #endif
  80. #ifndef DEBUG_UDP_IP
  81. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  82. #endif
  83. #ifndef DEBUG_UDP_PORT
  84. #define DEBUG_UDP_PORT 514
  85. #endif
  86. // If DEBUG_UDP_PORT is set to 514 syslog format is assumed
  87. // (https://tools.ietf.org/html/rfc3164)
  88. // DEBUG_UDP_FAC_PRI is the facility+priority
  89. #define DEBUG_UDP_FAC_PRI (SYSLOG_LOCAL0 | SYSLOG_DEBUG)
  90. //------------------------------------------------------------------------------
  91. #ifndef DEBUG_TELNET_SUPPORT
  92. #define DEBUG_TELNET_SUPPORT 1 // Enable telnet debug log (will only work if TELNET_SUPPORT is also 1)
  93. #endif
  94. //------------------------------------------------------------------------------
  95. #ifndef DEBUG_WEB_SUPPORT
  96. #define DEBUG_WEB_SUPPORT 1 // Enable web debug log (will only work if WEB_SUPPORT is also 1)
  97. #endif
  98. //------------------------------------------------------------------------------
  99. #ifndef DEBUG_LOG_BUFFER_SUPPORT
  100. #define DEBUG_LOG_BUFFER_SUPPORT 1 // Support boot log buffer (1.2Kb)
  101. // Will only work if DEBUG_LOG_BUFFER_ENABLED or runtime setting is also 1
  102. #endif
  103. #ifndef DEBUG_LOG_BUFFER_ENABLED
  104. #define DEBUG_LOG_BUFFER_ENABLED 0 // Disable boot log buffer by default
  105. #endif
  106. #ifndef DEBUG_LOG_BUFFER_SIZE
  107. #define DEBUG_LOG_BUFFER_SIZE 4096 // Store 4 Kb of log strings
  108. // WARNING! Memory is only reclaimed after `debug.buffer` prints the buffer contents
  109. #endif
  110. //------------------------------------------------------------------------------
  111. // TELNET
  112. //------------------------------------------------------------------------------
  113. #ifndef TELNET_SUPPORT
  114. #define TELNET_SUPPORT 1 // Enable telnet support by default (3.34Kb)
  115. #endif
  116. #ifndef TELNET_STA
  117. #define TELNET_STA 0 // By default, disallow connections via STA interface
  118. #endif
  119. #ifndef TELNET_AUTHENTICATION
  120. #define TELNET_AUTHENTICATION 1 // Request password to start telnet session by default
  121. #endif
  122. #ifndef TELNET_PORT
  123. #define TELNET_PORT 23 // Port to listen to telnet clients
  124. #endif
  125. #ifndef TELNET_MAX_CLIENTS
  126. #define TELNET_MAX_CLIENTS 1 // Max number of concurrent telnet clients
  127. #endif
  128. #ifndef TELNET_SERVER
  129. #define TELNET_SERVER TELNET_SERVER_ASYNC // Can be either TELNET_SERVER_ASYNC (using ESPAsyncTCP) or TELNET_SERVER_WIFISERVER (using WiFiServer)
  130. #endif
  131. #ifndef TELNET_SERVER_ASYNC_BUFFERED
  132. #define TELNET_SERVER_ASYNC_BUFFERED 1 // Enable buffered output for telnet server (+1Kb)
  133. // Helps to avoid lost data with lwip2 TCP_MSS=536 option
  134. #endif
  135. // Enable this flag to add support for reverse telnet (+800 bytes)
  136. // This is useful to telnet to a device behind a NAT or firewall
  137. // To use this feature, start a listen server on a publicly reachable host with e.g. "ncat -vlp <port>" and use the MQTT reverse telnet command to connect
  138. #ifndef TELNET_REVERSE_SUPPORT
  139. #define TELNET_REVERSE_SUPPORT 0
  140. #endif
  141. //------------------------------------------------------------------------------
  142. // TERMINAL
  143. //------------------------------------------------------------------------------
  144. #ifndef TERMINAL_SUPPORT
  145. #define TERMINAL_SUPPORT 1 // Enable terminal commands (0.97Kb)
  146. #endif
  147. #ifndef TERMINAL_SHARED_BUFFER_SIZE
  148. #define TERMINAL_SHARED_BUFFER_SIZE 128 // Maximum size for command line, shared by the WebUI, Telnet and Serial
  149. #endif
  150. #ifndef TERMINAL_MQTT_SUPPORT
  151. #define TERMINAL_MQTT_SUPPORT 0 // MQTT Terminal support built in
  152. // Depends on MQTT_SUPPORT and TERMINAL_SUPPORT commands being available
  153. #endif
  154. #ifndef TERMINAL_WEB_API_SUPPORT
  155. #define TERMINAL_WEB_API_SUPPORT 0 // Web server API Terminal support built in
  156. // Depends on WEB_SUPPORT and TERMINAL_SUPPORT commands being available
  157. #endif
  158. #ifndef TERMINAL_WEB_API_PATH
  159. #define TERMINAL_WEB_API_PATH "cmd"
  160. #endif
  161. //------------------------------------------------------------------------------
  162. // SYSTEM CHECK
  163. //------------------------------------------------------------------------------
  164. #ifndef SYSTEM_CHECK_ENABLED
  165. #define SYSTEM_CHECK_ENABLED 1 // Enable crash check by default
  166. #endif
  167. #ifndef SYSTEM_CHECK_TIME
  168. #define SYSTEM_CHECK_TIME 60000 // The system is considered stable after these many millis
  169. #endif
  170. #ifndef SYSTEM_CHECK_MAX
  171. #define SYSTEM_CHECK_MAX 5 // After this many crashes on boot
  172. // the system is flagged as unstable
  173. #endif
  174. //------------------------------------------------------------------------------
  175. // EEPROM
  176. //------------------------------------------------------------------------------
  177. //#define EEPROM_RORATE_SECTORS 2 // Number of sectors to use for EEPROM rotation
  178. // If not defined the firmware will use a number based
  179. // on the number of available sectors
  180. #ifndef SAVE_CRASH_ENABLED
  181. #define SAVE_CRASH_ENABLED 1 // Save stack trace to EEPROM by default
  182. // Depends on DEBUG_SUPPORT == 1
  183. #endif
  184. #ifndef SAVE_CRASH_STACK_TRACE_MAX
  185. #define SAVE_CRASH_STACK_TRACE_MAX 0x80 // limit at 128 bytes (increment/decrement by 16)
  186. #endif
  187. //------------------------------------------------------------------------------
  188. // GARLAND
  189. //------------------------------------------------------------------------------
  190. #ifndef GARLAND_SUPPORT
  191. #define GARLAND_SUPPORT 0
  192. #endif
  193. #ifndef GARLAND_D_PIN
  194. #define GARLAND_D_PIN 4 // WS2812 pin number (default: D2 / GPIO4)
  195. #endif
  196. #ifndef GARLAND_LEDS
  197. #define GARLAND_LEDS 60 // Number of LEDs
  198. #endif
  199. //------------------------------------------------------------------------------
  200. // THERMOSTAT
  201. //------------------------------------------------------------------------------
  202. #ifndef THERMOSTAT_SUPPORT
  203. #define THERMOSTAT_SUPPORT 0
  204. #endif
  205. #ifndef THERMOSTAT_DISPLAY_SUPPORT
  206. #define THERMOSTAT_DISPLAY_SUPPORT 0
  207. #endif
  208. #ifndef THERMOSTAT_DISPLAY_OFF_INTERVAL // Interval in seconds after which display will be switched off
  209. #define THERMOSTAT_DISPLAY_OFF_INTERVAL 0 // This will prevent it from burnout
  210. #endif // 0 - newer switch display off
  211. #define THERMOSTAT_SERVER_LOST_INTERVAL 120000 //server means lost after 2 min from last response
  212. #define THERMOSTAT_REMOTE_TEMP_MAX_WAIT 120 // 2 min
  213. #ifndef THERMOSTAT_REMOTE_SENSOR_NAME
  214. #define THERMOSTAT_REMOTE_SENSOR_NAME "" // Get remote temp(hum) from mqtt topic of this device
  215. #endif
  216. //------------------------------------------------------------------------------
  217. // HEARTBEAT REPORT
  218. //------------------------------------------------------------------------------
  219. #ifndef HEARTBEAT_REPORT_STATUS
  220. #define HEARTBEAT_REPORT_STATUS 1
  221. #endif
  222. #ifndef HEARTBEAT_REPORT_SSID
  223. #define HEARTBEAT_REPORT_SSID 1
  224. #endif
  225. #ifndef HEARTBEAT_REPORT_IP
  226. #define HEARTBEAT_REPORT_IP 1
  227. #endif
  228. #ifndef HEARTBEAT_REPORT_MAC
  229. #define HEARTBEAT_REPORT_MAC 1
  230. #endif
  231. #ifndef HEARTBEAT_REPORT_RSSI
  232. #define HEARTBEAT_REPORT_RSSI 1
  233. #endif
  234. #ifndef HEARTBEAT_REPORT_UPTIME
  235. #define HEARTBEAT_REPORT_UPTIME 1
  236. #endif
  237. #ifndef HEARTBEAT_REPORT_DATETIME
  238. #define HEARTBEAT_REPORT_DATETIME 1
  239. #endif
  240. #ifndef HEARTBEAT_REPORT_FREEHEAP
  241. #define HEARTBEAT_REPORT_FREEHEAP 1
  242. #endif
  243. #ifndef HEARTBEAT_REPORT_VCC
  244. #define HEARTBEAT_REPORT_VCC 1
  245. #endif
  246. #ifndef HEARTBEAT_REPORT_RELAY
  247. #define HEARTBEAT_REPORT_RELAY 1
  248. #endif
  249. #ifndef HEARTBEAT_REPORT_LIGHT
  250. #define HEARTBEAT_REPORT_LIGHT 1
  251. #endif
  252. #ifndef HEARTBEAT_REPORT_HOSTNAME
  253. #define HEARTBEAT_REPORT_HOSTNAME 1
  254. #endif
  255. #ifndef HEARTBEAT_REPORT_DESCRIPTION
  256. #define HEARTBEAT_REPORT_DESCRIPTION 1
  257. #endif
  258. #ifndef HEARTBEAT_REPORT_APP
  259. #define HEARTBEAT_REPORT_APP 1
  260. #endif
  261. #ifndef HEARTBEAT_REPORT_VERSION
  262. #define HEARTBEAT_REPORT_VERSION 1
  263. #endif
  264. #ifndef HEARTBEAT_REPORT_BOARD
  265. #define HEARTBEAT_REPORT_BOARD 1
  266. #endif
  267. #ifndef HEARTBEAT_REPORT_LOADAVG
  268. #define HEARTBEAT_REPORT_LOADAVG 1
  269. #endif
  270. #ifndef HEARTBEAT_REPORT_INTERVAL
  271. #define HEARTBEAT_REPORT_INTERVAL 0
  272. #endif
  273. #ifndef HEARTBEAT_REPORT_RANGE
  274. #define HEARTBEAT_REPORT_RANGE 1
  275. #endif
  276. #ifndef HEARTBEAT_REPORT_REMOTE_TEMP
  277. #define HEARTBEAT_REPORT_REMOTE_TEMP 1
  278. #endif
  279. #ifndef HEARTBEAT_REPORT_BSSID
  280. #define HEARTBEAT_REPORT_BSSID 0
  281. #endif
  282. //------------------------------------------------------------------------------
  283. // Load average
  284. //------------------------------------------------------------------------------
  285. #ifndef LOADAVG_INTERVAL
  286. #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
  287. #endif
  288. //------------------------------------------------------------------------------
  289. // RELAY
  290. //------------------------------------------------------------------------------
  291. // Enable general support for relays (aka switches)
  292. #ifndef RELAY_SUPPORT
  293. #define RELAY_SUPPORT 1
  294. #endif
  295. // ESP01-relays with STM co-MCU driving the relays
  296. #ifndef RELAY_PROVIDER_STM_SUPPORT
  297. #define RELAY_PROVIDER_STM_SUPPORT 0
  298. #endif
  299. // Sonoff Dual, using serial protocol
  300. #ifndef RELAY_PROVIDER_DUAL_SUPPORT
  301. #define RELAY_PROVIDER_DUAL_SUPPORT 0
  302. #endif
  303. // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
  304. #ifndef RELAY_BOOT_MODE
  305. #define RELAY_BOOT_MODE RELAY_BOOT_OFF
  306. #endif
  307. // One of RELAY_SYNC_ANY, RELAY_SYNC_NONE_OR_ONE, RELAY_SYNC_SAME or RELAY_SYNC_FIRST
  308. // Default to ANY i.e. don't do anything
  309. #ifndef RELAY_SYNC
  310. #define RELAY_SYNC RELAY_SYNC_ANY
  311. #endif
  312. // 0 (ms) means EVERY relay switches as soon as possible
  313. // otherwise, wait up until this much time before changing the status
  314. #ifndef RELAY_DELAY_INTERLOCK
  315. #define RELAY_DELAY_INTERLOCK 0
  316. #endif
  317. // Default pulse mode / normal mode. Switching from it will start the 'pulse' timer and reset the relay back after it finishes
  318. #ifndef RELAY_PULSE_MODE
  319. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  320. #endif
  321. // Default pulse time in seconds
  322. #ifndef RELAY_PULSE_TIME
  323. #define RELAY_PULSE_TIME 0.0
  324. #endif
  325. // Relay requests flood protection window - in seconds
  326. #ifndef RELAY_FLOOD_WINDOW
  327. #define RELAY_FLOOD_WINDOW 3.0
  328. #endif
  329. // Allowed actual relay changes inside requests flood protection window
  330. #ifndef RELAY_FLOOD_CHANGES
  331. #define RELAY_FLOOD_CHANGES 5
  332. #endif
  333. // Pulse with in milliseconds for a latched relay
  334. #ifndef RELAY_LATCHING_PULSE
  335. #define RELAY_LATCHING_PULSE 10
  336. #endif
  337. // Do not save relay state after these many milliseconds
  338. #ifndef RELAY_SAVE_DELAY
  339. #define RELAY_SAVE_DELAY 1000
  340. #endif
  341. #ifndef RELAY_REPORT_STATUS
  342. #define RELAY_REPORT_STATUS 1
  343. #endif
  344. // Configure the MQTT payload for ON, OFF and TOGGLE
  345. #ifndef RELAY_MQTT_OFF
  346. #define RELAY_MQTT_OFF "0"
  347. #endif
  348. #ifndef RELAY_MQTT_ON
  349. #define RELAY_MQTT_ON "1"
  350. #endif
  351. #ifndef RELAY_MQTT_TOGGLE
  352. #define RELAY_MQTT_TOGGLE "2"
  353. #endif
  354. //------------------------------------------------------------------------------
  355. // BUTTON
  356. //------------------------------------------------------------------------------
  357. #ifndef BUTTON_SUPPORT
  358. #define BUTTON_SUPPORT 1
  359. #endif
  360. #ifndef BUTTON_DEBOUNCE_DELAY
  361. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  362. #endif
  363. #ifndef BUTTON_REPEAT_DELAY
  364. #define BUTTON_REPEAT_DELAY 500 // Time in ms to wait for a second (or third...) click
  365. #endif
  366. #ifndef BUTTON_LNGCLICK_DELAY
  367. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  368. #endif
  369. #ifndef BUTTON_LNGLNGCLICK_DELAY
  370. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  371. #endif
  372. #ifndef BUTTON_MQTT_SEND_ALL_EVENTS
  373. #define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions
  374. // 1 - to send all button events to MQTT
  375. #endif
  376. #ifndef BUTTON_MQTT_RETAIN
  377. #define BUTTON_MQTT_RETAIN 0
  378. #endif
  379. // Generic digital pin support
  380. #ifndef BUTTON_PROVIDER_GPIO_SUPPORT
  381. #define BUTTON_PROVIDER_GPIO_SUPPORT 1
  382. #endif
  383. // Resistor ladder support. Poll analog pin and return digital LOW when analog reading is in a certain range
  384. // ref. https://github.com/bxparks/AceButton/tree/develop/docs/resistor_ladder
  385. // Uses BUTTON#_ANALOG_LEVEL for the individual button level configuration
  386. #ifndef BUTTON_PROVIDER_ANALOG_SUPPORT
  387. #define BUTTON_PROVIDER_ANALOG_SUPPORT 0
  388. #endif
  389. //------------------------------------------------------------------------------
  390. // ENCODER
  391. //------------------------------------------------------------------------------
  392. #ifndef ENCODER_SUPPORT
  393. #define ENCODER_SUPPORT 0
  394. #endif
  395. #ifndef ENCODER_MINIMUM_DELTA
  396. #define ENCODER_MINIMUM_DELTA 1
  397. #endif
  398. //------------------------------------------------------------------------------
  399. // LED
  400. //------------------------------------------------------------------------------
  401. #ifndef LED_SUPPORT
  402. #define LED_SUPPORT 1
  403. #endif
  404. // -----------------------------------------------------------------------------
  405. // WIFI
  406. // -----------------------------------------------------------------------------
  407. #ifndef WIFI_CONNECT_TIMEOUT
  408. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  409. #endif
  410. #ifndef WIFI_RECONNECT_INTERVAL
  411. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  412. #endif
  413. #ifndef WIFI_MAX_NETWORKS
  414. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  415. #endif
  416. #ifndef WIFI_AP_CAPTIVE
  417. #define WIFI_AP_CAPTIVE 1 // Captive portal enabled when in AP mode
  418. #endif
  419. #ifndef WIFI_AP_MODE
  420. #define WIFI_AP_MODE WiFiApMode::Fallback // By default, fallback to AP mode if no STA connection
  421. // Use WiFiApMode::Enabled to start it when the device boots
  422. // Use WiFiApMode::Disabled to disable AP mode completely
  423. #endif
  424. #ifndef WIFI_AP_SSID
  425. #define WIFI_AP_SSID "" // (optional) Specify softAp SSID.
  426. // By default or when empty, hostname (or device identifier) is used instead.
  427. #endif
  428. #ifndef WIFI_AP_PASS
  429. #define WIFI_AP_PASS "" // (optional) Specify softAp passphrase
  430. // By default or when empty, admin password is used instead.
  431. #endif
  432. #ifndef WIFI_AP_LEASES_SUPPORT
  433. #define WIFI_AP_LEASES_SUPPORT 0 // (optional) Specify softAp MAC<->IP DHCP reservations
  434. // Use `set wifiApLease# MAC`, where MAC is a valid 12-byte HEX number without colons
  435. #endif
  436. #ifndef WIFI_SLEEP_MODE
  437. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  438. #endif
  439. #ifndef WIFI_SCAN_NETWORKS
  440. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  441. #endif
  442. // Optional hardcoded configuration (up to 5 networks, depending on WIFI_MAX_NETWORKS and espurna/wifi_config.h)
  443. #ifndef WIFI1_SSID
  444. #define WIFI1_SSID ""
  445. #endif
  446. #ifndef WIFI1_PASS
  447. #define WIFI1_PASS ""
  448. #endif
  449. #ifndef WIFI1_IP
  450. #define WIFI1_IP ""
  451. #endif
  452. #ifndef WIFI1_GW
  453. #define WIFI1_GW ""
  454. #endif
  455. #ifndef WIFI1_MASK
  456. #define WIFI1_MASK ""
  457. #endif
  458. #ifndef WIFI1_DNS
  459. #define WIFI1_DNS ""
  460. #endif
  461. #ifndef WIFI2_SSID
  462. #define WIFI2_SSID ""
  463. #endif
  464. #ifndef WIFI2_PASS
  465. #define WIFI2_PASS ""
  466. #endif
  467. #ifndef WIFI2_IP
  468. #define WIFI2_IP ""
  469. #endif
  470. #ifndef WIFI2_GW
  471. #define WIFI2_GW ""
  472. #endif
  473. #ifndef WIFI2_MASK
  474. #define WIFI2_MASK ""
  475. #endif
  476. #ifndef WIFI2_DNS
  477. #define WIFI2_DNS ""
  478. #endif
  479. #ifndef WIFI3_SSID
  480. #define WIFI3_SSID ""
  481. #endif
  482. #ifndef WIFI3_PASS
  483. #define WIFI3_PASS ""
  484. #endif
  485. #ifndef WIFI3_IP
  486. #define WIFI3_IP ""
  487. #endif
  488. #ifndef WIFI3_GW
  489. #define WIFI3_GW ""
  490. #endif
  491. #ifndef WIFI3_MASK
  492. #define WIFI3_MASK ""
  493. #endif
  494. #ifndef WIFI3_DNS
  495. #define WIFI3_DNS ""
  496. #endif
  497. #ifndef WIFI4_SSID
  498. #define WIFI4_SSID ""
  499. #endif
  500. #ifndef WIFI4_PASS
  501. #define WIFI4_PASS ""
  502. #endif
  503. #ifndef WIFI4_IP
  504. #define WIFI4_IP ""
  505. #endif
  506. #ifndef WIFI4_GW
  507. #define WIFI4_GW ""
  508. #endif
  509. #ifndef WIFI4_MASK
  510. #define WIFI4_MASK ""
  511. #endif
  512. #ifndef WIFI4_DNS
  513. #define WIFI4_DNS ""
  514. #endif
  515. #ifndef WIFI5_SSID
  516. #define WIFI5_SSID ""
  517. #endif
  518. #ifndef WIFI5_PASS
  519. #define WIFI5_PASS ""
  520. #endif
  521. #ifndef WIFI5_IP
  522. #define WIFI5_IP ""
  523. #endif
  524. #ifndef WIFI5_GW
  525. #define WIFI5_GW ""
  526. #endif
  527. #ifndef WIFI5_MASK
  528. #define WIFI5_MASK ""
  529. #endif
  530. #ifndef WIFI5_DNS
  531. #define WIFI5_DNS ""
  532. #endif
  533. #ifndef WIFI_RSSI_1M
  534. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  535. #endif
  536. #ifndef WIFI_PROPAGATION_CONST
  537. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  538. #endif
  539. // ref: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/kconfig.html#config-lwip-esp-gratuitous-arp
  540. // ref: https://github.com/xoseperez/espurna/pull/1877#issuecomment-525612546
  541. //
  542. // Broadcast gratuitous ARP periodically to update ARP tables on the AP and all devices on the same network.
  543. // Helps to solve compatibility issues when ESP fails to timely reply to ARP requests, causing the device's ARP table entry to expire.
  544. #ifndef WIFI_GRATUITOUS_ARP_SUPPORT
  545. #define WIFI_GRATUITOUS_ARP_SUPPORT 1
  546. #endif
  547. // Interval is randomized on each boot in range from ..._MIN to ..._MAX (ms)
  548. #ifndef WIFI_GRATUITOUS_ARP_INTERVAL_MIN
  549. #define WIFI_GRATUITOUS_ARP_INTERVAL_MIN 15000
  550. #endif
  551. #ifndef WIFI_GRATUITOUS_ARP_INTERVAL_MAX
  552. #define WIFI_GRATUITOUS_ARP_INTERVAL_MAX 30000
  553. #endif
  554. // ref: https://github.com/esp8266/Arduino/issues/6471
  555. // ref: https://github.com/esp8266/Arduino/issues/6366
  556. //
  557. // Issue #6366 turned out to be high tx power causing weird behavior. Lowering tx power achieved stability.
  558. #ifndef WIFI_OUTPUT_POWER_DBM
  559. #define WIFI_OUTPUT_POWER_DBM 20.0f
  560. #endif
  561. // -----------------------------------------------------------------------------
  562. // WEB
  563. // -----------------------------------------------------------------------------
  564. #ifndef WEB_SUPPORT
  565. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  566. #endif
  567. #ifndef WEB_EMBEDDED
  568. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  569. #endif
  570. #ifndef WEB_ACCESS_LOG
  571. #define WEB_ACCESS_LOG 0 // Log every request that was received by the server (but, not necessarily processed)
  572. #endif
  573. // Requires ESPAsyncTCP to be built with ASYNC_TCP_SSL_ENABLED=1 and Arduino Core version >= 2.4.0
  574. // XXX: This is not working at the moment!! Pending https://github.com/me-no-dev/ESPAsyncTCP/issues/95
  575. #ifndef WEB_SSL_ENABLED
  576. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  577. #endif
  578. #ifndef WEB_USERNAME
  579. #define WEB_USERNAME "admin" // HTTP username
  580. #endif
  581. #ifndef WEB_FORCE_PASS_CHANGE
  582. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  583. #endif
  584. #ifndef WEB_PORT
  585. #define WEB_PORT 80 // HTTP port
  586. #endif
  587. // Defining a WEB_REMOTE_DOMAIN will enable Cross-Origin Resource Sharing (CORS)
  588. // so you will be able to login to this device from another domain. This will allow
  589. // you to manage all ESPurna devices in your local network from a unique installation
  590. // of the web UI. This installation could be in a local server (a Raspberry Pi, for instance)
  591. // or in the Internet. Since the WebUI is just one compressed file with HTML, CSS and JS
  592. // there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...).
  593. // The only requirement is that the resource must be available under this domain.
  594. #ifndef WEB_REMOTE_DOMAIN
  595. #define WEB_REMOTE_DOMAIN "http://espurna.io"
  596. #endif
  597. // -----------------------------------------------------------------------------
  598. // WEBSOCKETS
  599. // -----------------------------------------------------------------------------
  600. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  601. #ifndef WS_AUTHENTICATION
  602. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  603. #endif
  604. #ifndef WS_BUFFER_SIZE
  605. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  606. #endif
  607. #ifndef WS_TIMEOUT
  608. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  609. #endif
  610. #ifndef WS_UPDATE_INTERVAL
  611. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  612. #endif
  613. // -----------------------------------------------------------------------------
  614. // API
  615. // -----------------------------------------------------------------------------
  616. #ifndef API_SUPPORT
  617. #define API_SUPPORT 1 // API (REST & RPC) support built in
  618. #endif
  619. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  620. #ifndef API_ENABLED
  621. #define API_ENABLED 0 // Do not enable API by default
  622. #endif
  623. #ifndef API_KEY
  624. #define API_KEY "" // Do not enable API by default. WebUI will automatically generate the key
  625. #endif
  626. #ifndef API_RESTFUL
  627. #define API_RESTFUL 1 // A restful API requires changes to be issued as PUT requests
  628. // Setting this to 0 will allow using GET to change relays, for instance
  629. #endif
  630. #ifndef API_JSON_BUFFER_SIZE
  631. #define API_JSON_BUFFER_SIZE 256 // Size of the (de)serializer buffer.
  632. #endif
  633. #ifndef API_BASE_PATH
  634. #define API_BASE_PATH "/api/"
  635. #endif
  636. #ifndef API_REAL_TIME_VALUES
  637. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  638. #endif
  639. // -----------------------------------------------------------------------------
  640. // MDNS / LLMNR / NETBIOS / SSDP
  641. // -----------------------------------------------------------------------------
  642. #ifndef MDNS_SERVER_SUPPORT
  643. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  644. #endif
  645. #ifndef LLMNR_SUPPORT
  646. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires Core version >= 2.4.0
  647. #endif
  648. #ifndef NETBIOS_SUPPORT
  649. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires Core version >= 2.4.0
  650. #endif
  651. #ifndef SSDP_SUPPORT
  652. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  653. // Not compatible with ALEXA_SUPPORT at the moment
  654. #endif
  655. #ifndef SSDP_DEVICE_TYPE
  656. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  657. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  658. #endif
  659. // -----------------------------------------------------------------------------
  660. // SPIFFS
  661. // -----------------------------------------------------------------------------
  662. #ifndef SPIFFS_SUPPORT
  663. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  664. #endif
  665. // -----------------------------------------------------------------------------
  666. // SSL Client ** EXPERIMENTAL **
  667. // -----------------------------------------------------------------------------
  668. #ifndef SECURE_CLIENT
  669. #define SECURE_CLIENT SECURE_CLIENT_NONE // What variant of WiFiClient to use
  670. // SECURE_CLIENT_NONE - No secure client support (default)
  671. // SECURE_CLIENT_AXTLS - axTLS client secure support (All Core versions, ONLY TLS 1.1)
  672. // SECURE_CLIENT_BEARSSL - BearSSL client secure support (starting with 2.5.0, TLS 1.2)
  673. //
  674. // axTLS marked for derecation since Arduino Core 2.4.2 and **will** be removed in the future
  675. #endif
  676. // Security check that is performed when the connection is established:
  677. // SECURE_CLIENT_CHECK_CA - Use Trust Anchor / Root Certificate
  678. // Supported only by the SECURE_CLIENT_BEARSSL
  679. // (See respective ..._SECURE_CLIENT_INCLUDE_CA options per-module)
  680. // SECURE_CLIENT_CHECK_FINGERPRINT - Check certificate fingerprint
  681. // SECURE_CLIENT_CHECK_NONE - Allow insecure connections
  682. #ifndef SECURE_CLIENT_CHECK
  683. #if SECURE_CLIENT == SECURE_CLIENT_BEARSSL
  684. #define SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK_CA
  685. #else
  686. #define SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK_FINGERPRINT
  687. #endif
  688. #endif // SECURE_CLIENT_CHECK
  689. // Support Maximum Fragment Length Negotiation TLS extension
  690. // "...negotiate a smaller maximum fragment length due to memory limitations or bandwidth limitations."
  691. // - https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/bearssl-client-secure-class.html#mfln-or-maximum-fragment-length-negotiation-saving-ram
  692. // - https://tools.ietf.org/html/rfc6066#section-4
  693. #ifndef SECURE_CLIENT_MFLN
  694. #define SECURE_CLIENT_MFLN 0 // The only possible values are: 512, 1024, 2048 and 4096
  695. // Set to 0 to disable (default)
  696. #endif
  697. // -----------------------------------------------------------------------------
  698. // OTA
  699. // -----------------------------------------------------------------------------
  700. #ifndef OTA_PORT
  701. #define OTA_PORT 8266 // Port for ArduinoOTA
  702. #endif
  703. #ifndef OTA_MQTT_SUPPORT
  704. #define OTA_MQTT_SUPPORT 0 // Listen for HTTP(s) URLs at '<root topic>/ota'. Depends on OTA_CLIENT
  705. #endif
  706. #ifndef OTA_ARDUINOOTA_SUPPORT
  707. #define OTA_ARDUINOOTA_SUPPORT 1 // Support ArduinoOTA by default (4.2Kb)
  708. // Implicitly depends on ESP8266mDNS library, thus increasing firmware size
  709. #endif
  710. #ifndef OTA_CLIENT
  711. #define OTA_CLIENT OTA_CLIENT_ASYNCTCP // Terminal / MQTT OTA support
  712. // OTA_CLIENT_ASYNCTCP (ESPAsyncTCP library)
  713. // OTA_CLIENT_HTTPUPDATE (Arduino Core library)j
  714. // OTA_CLIENT_NONE to disable
  715. #endif
  716. #ifndef OTA_WEB_SUPPORT
  717. #define OTA_WEB_SUPPORT 1 // Support `/upgrade` endpoint and WebUI OTA handler
  718. #endif
  719. #define OTA_GITHUB_FP "CA:06:F5:6B:25:8B:7A:0D:4F:2B:05:47:09:39:47:86:51:15:19:84"
  720. #ifndef OTA_FINGERPRINT
  721. #define OTA_FINGERPRINT OTA_GITHUB_FP
  722. #endif
  723. #ifndef OTA_SECURE_CLIENT_CHECK
  724. #define OTA_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK
  725. #endif
  726. #ifndef OTA_SECURE_CLIENT_MFLN
  727. #define OTA_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN
  728. #endif
  729. #ifndef OTA_SECURE_CLIENT_INCLUDE_CA
  730. #define OTA_SECURE_CLIENT_INCLUDE_CA 0 // Use user-provided CA. Only PROGMEM PEM option is supported.
  731. // TODO: eventually should be replaced with pre-parsed structs, read directly from flash
  732. // (ref: https://github.com/earlephilhower/bearssl-esp8266/pull/14)
  733. //
  734. // When enabled, current implementation includes "static/ota_client_trusted_root_ca.h" with
  735. // const char _ota_client_trusted_root_ca[] PROGMEM = "...PEM data...";
  736. // By default, using DigiCert root in "static/digicert_evroot_pem.h" (for https://github.com)
  737. #endif
  738. // -----------------------------------------------------------------------------
  739. // NOFUSS
  740. // -----------------------------------------------------------------------------
  741. #ifndef NOFUSS_SUPPORT
  742. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  743. #endif
  744. #ifndef NOFUSS_ENABLED
  745. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  746. #endif
  747. #ifndef NOFUSS_SERVER
  748. #define NOFUSS_SERVER "" // Default NoFuss Server
  749. #endif
  750. #ifndef NOFUSS_INTERVAL
  751. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  752. #endif
  753. // -----------------------------------------------------------------------------
  754. // UART <-> MQTT
  755. // -----------------------------------------------------------------------------
  756. #ifndef UART_MQTT_SUPPORT
  757. #define UART_MQTT_SUPPORT 0 // No support by default
  758. #endif
  759. #ifndef UART_MQTT_USE_SOFT
  760. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  761. #endif
  762. #ifndef UART_MQTT_HW_PORT
  763. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  764. #endif
  765. #ifndef UART_MQTT_RX_PIN
  766. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  767. #endif
  768. #ifndef UART_MQTT_TX_PIN
  769. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  770. #endif
  771. #ifndef UART_MQTT_BAUDRATE
  772. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  773. #endif
  774. #ifndef UART_MQTT_TERMINATION
  775. #define UART_MQTT_TERMINATION '\n' // Termination character
  776. #endif
  777. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  778. // -----------------------------------------------------------------------------
  779. // MQTT
  780. // -----------------------------------------------------------------------------
  781. #ifndef MQTT_SUPPORT
  782. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  783. #endif
  784. #ifndef MQTT_LIBRARY
  785. #define MQTT_LIBRARY MQTT_LIBRARY_ASYNCMQTTCLIENT // MQTT_LIBRARY_ASYNCMQTTCLIENT (default, https://github.com/marvinroger/async-mqtt-client)
  786. // MQTT_LIBRARY_PUBSUBCLIENT (https://github.com/knolleary/pubsubclient)
  787. // MQTT_LIBRARY_ARDUINOMQTT (https://github.com/256dpi/arduino-mqtt)
  788. #endif
  789. // -----------------------------------------------------------------------------
  790. // MQTT OVER SSL
  791. // -----------------------------------------------------------------------------
  792. //
  793. // Requires SECURE_CLIENT set to SECURE_CLIENT_AXTLS or SECURE_CLIENT_BEARSSL
  794. // It is recommended to use MQTT_LIBRARY_ARDUINOMQTT or MQTT_LIBRARY_PUBSUBCLIENT
  795. // It is recommended to use SECURE_CLIENT_BEARSSL
  796. // It is recommended to use ESP8266 Arduino Core >= 2.5.2 with SECURE_CLIENT_BEARSSL
  797. //
  798. // Current version of MQTT_LIBRARY_ASYNCMQTTCLIENT only supports SECURE_CLIENT_AXTLS
  799. //
  800. // It is recommended to use WEB_SUPPORT=0 with either SECURE_CLIENT option, as there are miscellaneous problems when using them simultaneously
  801. // (although, things might've improved, and I'd encourage to check whether this is true or not)
  802. //
  803. // When using MQTT_LIBRARY_PUBSUBCLIENT or MQTT_LIBRARY_ARDUINOMQTT, you will have to disable every module that uses ESPAsyncTCP:
  804. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0, DEBUG_TELNET_SUPPORT=0 and WEB_SUPPORT=0
  805. // Or, use "sync" versions instead (note that not every module has this option):
  806. // THINGSPEAK_USE_ASYNC=0, TELNET_SERVER=TELNET_SERVER_WIFISERVER
  807. //
  808. // See SECURE_CLIENT_CHECK for all possible connection verification options.
  809. //
  810. // The simpliest way to verify SSL connection is to use fingerprinting.
  811. // For example, to get Google's MQTT server certificate fingerprint, run the following command:
  812. // $ echo -n | openssl s_client -connect mqtt.googleapis.com:8883 2>&1 | openssl x509 -noout -fingerprint -sha1 | cut -d\= -f2
  813. // Note that fingerprint will change when certificate changes e.g. LetsEncrypt renewals or when the CSR updates
  814. #ifndef MQTT_SSL_ENABLED
  815. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  816. #endif
  817. #ifndef MQTT_SSL_FINGERPRINT
  818. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  819. #endif
  820. #ifndef MQTT_SECURE_CLIENT_CHECK
  821. #define MQTT_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK // Use global verification setting by default
  822. #endif
  823. #ifndef MQTT_SECURE_CLIENT_MFLN
  824. #define MQTT_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN // Use global MFLN setting by default
  825. #endif
  826. #ifndef MQTT_SECURE_CLIENT_INCLUDE_CA
  827. #define MQTT_SECURE_CLIENT_INCLUDE_CA 0 // Use user-provided CA. Only PROGMEM PEM option is supported.
  828. // When enabled, current implementation includes "static/mqtt_client_trusted_root_ca.h" with
  829. // const char _mqtt_client_trusted_root_ca[] PROGMEM = "...PEM data...";
  830. // By default, using LetsEncrypt X3 root in "static/letsencrypt_isrgroot_pem.h"
  831. #endif
  832. #ifndef MQTT_ENABLED
  833. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  834. #endif
  835. #ifndef MQTT_AUTOCONNECT
  836. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  837. // autoconnect to the first MQTT broker found if none defined
  838. #endif
  839. #ifndef MQTT_SERVER
  840. #define MQTT_SERVER "" // Default MQTT broker address
  841. #endif
  842. #ifndef MQTT_USER
  843. #define MQTT_USER "" // Default MQTT broker usename
  844. #endif
  845. #ifndef MQTT_PASS
  846. #define MQTT_PASS "" // Default MQTT broker password
  847. #endif
  848. #ifndef MQTT_PORT
  849. #define MQTT_PORT 1883 // MQTT broker port
  850. #endif
  851. #ifndef MQTT_TOPIC
  852. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  853. #endif
  854. #ifndef MQTT_RETAIN
  855. #define MQTT_RETAIN true // MQTT retain flag
  856. #endif
  857. #ifndef MQTT_QOS
  858. #define MQTT_QOS 0 // MQTT QoS value for all messages
  859. #endif
  860. #ifndef MQTT_KEEPALIVE
  861. #define MQTT_KEEPALIVE 120 // MQTT keepalive value
  862. #endif
  863. #ifndef MQTT_RECONNECT_DELAY_MIN
  864. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  865. #endif
  866. #ifndef MQTT_RECONNECT_DELAY_STEP
  867. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  868. #endif
  869. #ifndef MQTT_RECONNECT_DELAY_MAX
  870. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  871. #endif
  872. #ifndef MQTT_SKIP_TIME
  873. #define MQTT_SKIP_TIME 0 // Skip messages for N ms after connection. Disabled by default
  874. #endif
  875. #ifndef MQTT_USE_JSON
  876. #define MQTT_USE_JSON 0 // Don't group messages in a JSON body by default
  877. #endif
  878. #ifndef MQTT_USE_JSON_DELAY
  879. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  880. #endif
  881. #ifndef MQTT_QUEUE_MAX_SIZE
  882. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  883. #endif
  884. #ifndef MQTT_BUFFER_MAX_SIZE
  885. #define MQTT_BUFFER_MAX_SIZE 1024 // Size of the MQTT payload buffer for MQTT_MESSAGE_EVENT. Large messages will only be available via MQTT_MESSAGE_RAW_EVENT.
  886. // Note: When using MQTT_LIBRARY_PUBSUBCLIENT, MQTT_MAX_PACKET_SIZE should not be more than this value.
  887. #endif
  888. // These are the properties that will be sent when useJson is true
  889. #ifndef MQTT_ENQUEUE_IP
  890. #define MQTT_ENQUEUE_IP 1
  891. #endif
  892. #ifndef MQTT_ENQUEUE_MAC
  893. #define MQTT_ENQUEUE_MAC 1
  894. #endif
  895. #ifndef MQTT_ENQUEUE_HOSTNAME
  896. #define MQTT_ENQUEUE_HOSTNAME 1
  897. #endif
  898. #ifndef MQTT_ENQUEUE_DATETIME
  899. #define MQTT_ENQUEUE_DATETIME 1
  900. #endif
  901. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  902. #define MQTT_ENQUEUE_MESSAGE_ID 1
  903. #endif
  904. #ifndef MQTT_STATUS_ONLINE
  905. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  906. #endif
  907. #ifndef MQTT_STATUS_OFFLINE
  908. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  909. #endif
  910. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  911. // Custom get and set postfixes
  912. // Use something like "/status" or "/set", with leading slash
  913. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  914. #ifndef MQTT_GETTER
  915. #define MQTT_GETTER ""
  916. #endif
  917. #ifndef MQTT_SETTER
  918. #define MQTT_SETTER "/set"
  919. #endif
  920. // -----------------------------------------------------------------------------
  921. // BROKER
  922. // -----------------------------------------------------------------------------
  923. #ifndef BROKER_SUPPORT
  924. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  925. #endif
  926. // -----------------------------------------------------------------------------
  927. // SETTINGS
  928. // -----------------------------------------------------------------------------
  929. #ifndef SETTINGS_AUTOSAVE
  930. #define SETTINGS_AUTOSAVE 1 // Autosave settings or force manual commit
  931. #endif
  932. #define SETTINGS_MAX_LIST_COUNT 16 // Maximum index for settings lists
  933. // -----------------------------------------------------------------------------
  934. // LIGHT
  935. // -----------------------------------------------------------------------------
  936. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  937. // They have to be defined for each device in the hardware.h file.
  938. // If 3 or more channels first 3 will be considered RGB.
  939. // Usual configurations are:
  940. // 1 channels => W
  941. // 2 channels => WW
  942. // 3 channels => RGB
  943. // 4 channels => RGBW
  944. // 5 channels => RGBWW
  945. #ifndef LIGHT_PROVIDER
  946. #define LIGHT_PROVIDER LIGHT_PROVIDER_NONE
  947. #endif
  948. #ifndef LIGHT_REPORT_DELAY
  949. #define LIGHT_REPORT_DELAY 100 // Delay reporting current state for the specified number of ms after light update
  950. #endif
  951. #ifndef LIGHT_SAVE_ENABLED
  952. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  953. #endif
  954. #ifndef LIGHT_SAVE_DELAY
  955. #define LIGHT_SAVE_DELAY 5000 // Persist channel & brightness values after the specified number of ms
  956. #endif
  957. #ifndef LIGHT_MIN_PWM
  958. #define LIGHT_MIN_PWM 0
  959. #endif
  960. #ifndef LIGHT_MAX_PWM
  961. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  962. #define LIGHT_MAX_PWM 255
  963. #elif LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  964. #define LIGHT_MAX_PWM 10000 // 10000 * 200ns => 2 kHz
  965. #else
  966. #define LIGHT_MAX_PWM 0
  967. #endif
  968. #endif // LIGHT_MAX_PWM
  969. #ifndef LIGHT_LIMIT_PWM
  970. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  971. #endif
  972. #ifndef LIGHT_MIN_VALUE
  973. #define LIGHT_MIN_VALUE 0 // Minimum light value
  974. #endif
  975. #ifndef LIGHT_MAX_VALUE
  976. #define LIGHT_MAX_VALUE 255 // Maximum light value
  977. #endif
  978. #ifndef LIGHT_MIN_BRIGHTNESS
  979. #define LIGHT_MIN_BRIGHTNESS 0 // Minimum brightness value
  980. #endif
  981. #ifndef LIGHT_MAX_BRIGHTNESS
  982. #define LIGHT_MAX_BRIGHTNESS 255 // Maximum brightness value
  983. #endif
  984. // Default mireds & kelvin to the Philips Hue limits
  985. // https://developers.meethue.com/documentation/core-concepts
  986. //
  987. // Home Assistant also uses these, see Light::min_mireds, Light::max_mireds
  988. // https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/__init__.py
  989. // Used when LIGHT_USE_WHITE AND LIGHT_USE_CCT is 1 - (1000000/Kelvin = MiReds)
  990. // Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
  991. #ifndef LIGHT_COLDWHITE_MIRED
  992. #define LIGHT_COLDWHITE_MIRED 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
  993. #endif
  994. #ifndef LIGHT_WARMWHITE_MIRED
  995. #define LIGHT_WARMWHITE_MIRED 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
  996. #endif
  997. #ifndef LIGHT_STEP
  998. #define LIGHT_STEP 32 // Step size
  999. #endif
  1000. #ifndef LIGHT_USE_COLOR
  1001. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  1002. #endif
  1003. #ifndef LIGHT_USE_WHITE
  1004. #define LIGHT_USE_WHITE 0 // Use the 4th channel as (Warm-)White LEDs
  1005. #endif
  1006. #ifndef LIGHT_USE_CCT
  1007. #define LIGHT_USE_CCT 0 // Use the 5th channel as Coldwhite LEDs, LIGHT_USE_WHITE must be 1.
  1008. #endif
  1009. #ifndef LIGHT_USE_GAMMA
  1010. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  1011. #endif
  1012. #ifndef LIGHT_USE_RGB
  1013. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  1014. #endif
  1015. #ifndef LIGHT_WHITE_FACTOR
  1016. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  1017. // this factor is used to scale the white channel to match brightness
  1018. #endif
  1019. #ifndef LIGHT_USE_TRANSITIONS
  1020. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  1021. #endif
  1022. #ifndef LIGHT_TRANSITION_STEP
  1023. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  1024. #endif
  1025. #ifndef LIGHT_TRANSITION_TIME
  1026. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  1027. #endif
  1028. #ifndef LIGHT_RELAY_ENABLED
  1029. #define LIGHT_RELAY_ENABLED 1 // Add a virtual switch that controls the global light state. Depends on RELAY_SUPPORT
  1030. #endif
  1031. // -----------------------------------------------------------------------------
  1032. // DOMOTICZ
  1033. // -----------------------------------------------------------------------------
  1034. #ifndef DOMOTICZ_SUPPORT
  1035. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  1036. #endif
  1037. #ifndef DOMOTICZ_ENABLED
  1038. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  1039. #endif
  1040. #ifndef DOMOTICZ_IN_TOPIC
  1041. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  1042. #endif
  1043. #ifndef DOMOTICZ_OUT_TOPIC
  1044. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  1045. #endif
  1046. // -----------------------------------------------------------------------------
  1047. // HOME ASSISTANT
  1048. // -----------------------------------------------------------------------------
  1049. #ifndef HOMEASSISTANT_SUPPORT
  1050. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  1051. #endif
  1052. #ifndef HOMEASSISTANT_ENABLED
  1053. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  1054. #endif
  1055. #ifndef HOMEASSISTANT_PREFIX
  1056. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  1057. #endif
  1058. #ifndef HOMEASSISTANT_RETAIN
  1059. #define HOMEASSISTANT_RETAIN MQTT_RETAIN // Make broker retain the messages
  1060. #endif
  1061. // -----------------------------------------------------------------------------
  1062. // INFLUXDB
  1063. // -----------------------------------------------------------------------------
  1064. #ifndef INFLUXDB_SUPPORT
  1065. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  1066. #endif
  1067. #ifndef INFLUXDB_ENABLED
  1068. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  1069. #endif
  1070. #ifndef INFLUXDB_HOST
  1071. #define INFLUXDB_HOST "" // Default server
  1072. #endif
  1073. #ifndef INFLUXDB_PORT
  1074. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  1075. #endif
  1076. #ifndef INFLUXDB_DATABASE
  1077. #define INFLUXDB_DATABASE "" // Default database
  1078. #endif
  1079. #ifndef INFLUXDB_USERNAME
  1080. #define INFLUXDB_USERNAME "" // Default username
  1081. #endif
  1082. #ifndef INFLUXDB_PASSWORD
  1083. #define INFLUXDB_PASSWORD "" // Default password
  1084. #endif
  1085. // -----------------------------------------------------------------------------
  1086. // THINGSPEAK
  1087. // -----------------------------------------------------------------------------
  1088. #ifndef THINGSPEAK_SUPPORT
  1089. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  1090. #endif
  1091. #ifndef THINGSPEAK_ENABLED
  1092. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  1093. #endif
  1094. #ifndef THINGSPEAK_APIKEY
  1095. #define THINGSPEAK_APIKEY "" // Default API KEY
  1096. #endif
  1097. #ifndef THINGSPEAK_CLEAR_CACHE
  1098. #define THINGSPEAK_CLEAR_CACHE 1 // Clear cache after sending values
  1099. // Not clearing it will result in latest values for each field being sent every time
  1100. #endif
  1101. #ifndef THINGSPEAK_USE_ASYNC
  1102. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  1103. #endif
  1104. // THINGSPEAK OVER SSL
  1105. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  1106. // so you should compile it with WEB_SUPPORT to 0.
  1107. // When THINGSPEAK_USE_ASYNC is 1, requires EspAsyncTCP to be built with ASYNC_TCP_SSL_ENABLED=1 and ESP8266 Arduino Core >= 2.4.0.
  1108. // When THINGSPEAK_USE_ASYNC is 0, requires Arduino Core >= 2.6.0 and SECURE_CLIENT_BEARSSL
  1109. //
  1110. // WARNING: Thingspeak servers do not support MFLN right now, connection requires at least 30KB of free RAM.
  1111. // Also see MQTT comments above.
  1112. #ifndef THINGSPEAK_USE_SSL
  1113. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  1114. #endif
  1115. #ifndef THINGSPEAK_SECURE_CLIENT_CHECK
  1116. #define THINGSPEAK_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK
  1117. #endif
  1118. #ifndef THINGSPEAK_SECURE_CLIENT_MFLN
  1119. #define THINGSPEAK_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN
  1120. #endif
  1121. #ifndef THINGSPEAK_FINGERPRINT
  1122. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  1123. #endif
  1124. #ifndef THINGSPEAK_ADDRESS
  1125. #if THINGSPEAK_USE_SSL
  1126. #define THINGSPEAK_ADDRESS "https://api.thingspeak.com/update"
  1127. #else
  1128. #define THINGSPEAK_ADDRESS "http://api.thingspeak.com/update"
  1129. #endif
  1130. #endif // ifndef THINGSPEAK_ADDRESS
  1131. #ifndef THINGSPEAK_TRIES
  1132. #define THINGSPEAK_TRIES 3 // Number of tries when sending data (minimum 1)
  1133. #endif
  1134. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  1135. #define THINGSPEAK_FIELDS 8 // Number of fields
  1136. // -----------------------------------------------------------------------------
  1137. // SCHEDULER
  1138. // -----------------------------------------------------------------------------
  1139. #ifndef SCHEDULER_SUPPORT
  1140. #define SCHEDULER_SUPPORT 1 // Enable scheduler (2.45Kb)
  1141. #endif
  1142. #ifndef SCHEDULER_MAX_SCHEDULES
  1143. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  1144. #endif
  1145. #ifndef SCHEDULER_RESTORE_LAST_SCHEDULE
  1146. #define SCHEDULER_RESTORE_LAST_SCHEDULE 0 // Restore the last schedule state on the device boot
  1147. #endif
  1148. #ifndef SCHEDULER_WEEKDAYS
  1149. #define SCHEDULER_WEEKDAYS "1,2,3,4,5,6,7" // (Default - Run the schedules every day)
  1150. #endif
  1151. // -----------------------------------------------------------------------------
  1152. // RPN RULES
  1153. // -----------------------------------------------------------------------------
  1154. #ifndef RPN_RULES_SUPPORT
  1155. #define RPN_RULES_SUPPORT 0 // Enable RPN Rules (8.6Kb)
  1156. #endif
  1157. #ifndef RPN_DELAY
  1158. #define RPN_DELAY 100 // Execute rules after 100ms without messages
  1159. #endif
  1160. #ifndef RPN_STICKY
  1161. #define RPN_STICKY 1 // Keeps variable after rule execution
  1162. #endif
  1163. // -----------------------------------------------------------------------------
  1164. // NTP
  1165. // -----------------------------------------------------------------------------
  1166. #ifndef NTP_SUPPORT
  1167. #define NTP_SUPPORT 1 // Build with NTP support by default (depends on Core version)
  1168. #endif
  1169. #ifndef NTP_SERVER
  1170. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  1171. #endif
  1172. #ifndef NTP_TIMEZONE
  1173. #define NTP_TIMEZONE TZ_Etc_UTC // POSIX TZ variable. Default to UTC from TZ.h (which is PSTR("UTC0"))
  1174. // For the format documentation, see:
  1175. // - https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
  1176. // ESP8266 Core provides human-readable aliases for POSIX format, see:
  1177. // - Latest: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
  1178. // - PlatformIO: ~/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/TZ.h
  1179. // (or, possibly, c:\.platformio\... on Windows)
  1180. // - Arduino IDE: depends on platform, see `/dist/arduino_ide/README.md`
  1181. #endif
  1182. #ifndef NTP_UPDATE_INTERVAL
  1183. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  1184. #endif
  1185. #ifndef NTP_START_DELAY
  1186. #define NTP_START_DELAY 3 // Delay NTP start for 3 seconds
  1187. #endif
  1188. #ifndef NTP_WAIT_FOR_SYNC
  1189. #define NTP_WAIT_FOR_SYNC 1 // Do not report any datetime until NTP sync'ed
  1190. #endif
  1191. #ifndef NTP_DHCP_SERVER
  1192. #define NTP_DHCP_SERVER 1 // Automatically replace the NTP server value with the one received with the DHCP packet
  1193. #endif
  1194. // -----------------------------------------------------------------------------
  1195. // ALEXA
  1196. // -----------------------------------------------------------------------------
  1197. // This setting defines whether Alexa support should be built into the firmware
  1198. #ifndef ALEXA_SUPPORT
  1199. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  1200. #endif
  1201. // This is default value for the alexaEnabled setting that defines whether
  1202. // this device should be discoberable and respond to Alexa commands.
  1203. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  1204. #ifndef ALEXA_ENABLED
  1205. #define ALEXA_ENABLED 1
  1206. #endif
  1207. #ifndef ALEXA_HOSTNAME
  1208. #define ALEXA_HOSTNAME ""
  1209. #endif
  1210. // -----------------------------------------------------------------------------
  1211. // RF BRIDGE
  1212. // -----------------------------------------------------------------------------
  1213. #ifndef RFB_SUPPORT
  1214. #define RFB_SUPPORT 0
  1215. #endif
  1216. #ifndef RFB_SEND_REPEATS
  1217. #define RFB_SEND_REPEATS 1 // How many times to send the message
  1218. #endif
  1219. // - RFB_PROVIDER_EFM8BB1
  1220. // Default option for the ITEAD_SONOFF_RFBRIDGE or any custom firmware implementing the protocol
  1221. // - RFB_PROVIDER_RCSWITCH
  1222. // Originally implemented for SONOFF BASIC
  1223. // https://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  1224. // Also possible to use with SONOFF RF BRIDGE, thanks to @wildwiz
  1225. // https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack
  1226. #ifndef RFB_PROVIDER
  1227. #define RFB_PROVIDER RFB_PROVIDER_RCSWITCH
  1228. #endif
  1229. #ifndef RFB_RX_PIN
  1230. #define RFB_RX_PIN GPIO_NONE
  1231. #endif
  1232. #ifndef RFB_TX_PIN
  1233. #define RFB_TX_PIN GPIO_NONE
  1234. #endif
  1235. #ifndef RFB_LEARN_TIMEOUT
  1236. #define RFB_LEARN_TIMEOUT 15000
  1237. #endif
  1238. #ifndef RFB_SEND_DELAY
  1239. #define RFB_SEND_DELAY 500 // Interval between sendings in ms
  1240. #endif
  1241. #ifndef RFB_RECEIVE_DELAY
  1242. #define RFB_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid bouncing)
  1243. #endif
  1244. #ifndef RFB_TRANSMIT_REPEATS
  1245. #define RFB_TRANSMIT_REPEATS 5 // How many times RCSwitch will repeat the message
  1246. #endif
  1247. // -----------------------------------------------------------------------------
  1248. // IR Bridge
  1249. // -----------------------------------------------------------------------------
  1250. #ifndef IR_SUPPORT
  1251. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  1252. #endif
  1253. //#define IR_RX_PIN 5 // GPIO the receiver is connected to
  1254. //#define IR_TX_PIN 4 // GPIO the transmitter is connected to
  1255. #ifndef IR_USE_RAW
  1256. #define IR_USE_RAW 0 // Use raw codes
  1257. #endif
  1258. #ifndef IR_BUFFER_SIZE
  1259. #define IR_BUFFER_SIZE 1024
  1260. #endif
  1261. #ifndef IR_TIMEOUT
  1262. #define IR_TIMEOUT 15U
  1263. #endif
  1264. #ifndef IR_REPEAT
  1265. #define IR_REPEAT 1
  1266. #endif
  1267. #ifndef IR_DELAY
  1268. #define IR_DELAY 100
  1269. #endif
  1270. #ifndef IR_DEBOUNCE
  1271. #define IR_DEBOUNCE 500 // IR debounce time in milliseconds
  1272. #endif
  1273. #ifndef IR_BUTTON_SET
  1274. #define IR_BUTTON_SET 0 // IR button set to use (see ../ir_button.h)
  1275. #endif
  1276. //--------------------------------------------------------------------------------
  1277. // Custom RFM69 to MQTT bridge
  1278. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1279. // Enable support by passing RFM69_SUPPORT=1 build flag
  1280. //--------------------------------------------------------------------------------
  1281. #ifndef RFM69_SUPPORT
  1282. #define RFM69_SUPPORT 0
  1283. #endif
  1284. #ifndef RFM69_MAX_TOPICS
  1285. #define RFM69_MAX_TOPICS 50
  1286. #endif
  1287. #ifndef RFM69_MAX_NODES
  1288. #define RFM69_MAX_NODES 255
  1289. #endif
  1290. #ifndef RFM69_DEFAULT_TOPIC
  1291. #define RFM69_DEFAULT_TOPIC "/rfm69gw/{node}/{key}"
  1292. #endif
  1293. #ifndef RFM69_NODE_ID
  1294. #define RFM69_NODE_ID 1
  1295. #endif
  1296. #ifndef RFM69_GATEWAY_ID
  1297. #define RFM69_GATEWAY_ID 1
  1298. #endif
  1299. #ifndef RFM69_NETWORK_ID
  1300. #define RFM69_NETWORK_ID 164
  1301. #endif
  1302. #ifndef RFM69_PROMISCUOUS
  1303. #define RFM69_PROMISCUOUS 0
  1304. #endif
  1305. #ifndef RFM69_PROMISCUOUS_SENDS
  1306. #define RFM69_PROMISCUOUS_SENDS 0
  1307. #endif
  1308. #ifndef RFM69_FREQUENCY
  1309. #define RFM69_FREQUENCY RF69_868MHZ
  1310. #endif
  1311. #ifndef RFM69_ENCRYPTKEY
  1312. #define RFM69_ENCRYPTKEY "fibonacci0123456"
  1313. #endif
  1314. #ifndef RFM69_CS_PIN
  1315. #define RFM69_CS_PIN SS
  1316. #endif
  1317. #ifndef RFM69_IRQ_PIN
  1318. #define RFM69_IRQ_PIN 5
  1319. #endif
  1320. #ifndef RFM69_RESET_PIN
  1321. #define RFM69_RESET_PIN 7
  1322. #endif
  1323. #ifndef RFM69_IS_RFM69HW
  1324. #define RFM69_IS_RFM69HW 0
  1325. #endif
  1326. //--------------------------------------------------------------------------------
  1327. // TUYA switch & dimmer support
  1328. //--------------------------------------------------------------------------------
  1329. #ifndef TUYA_SUPPORT
  1330. #define TUYA_SUPPORT 0
  1331. #endif
  1332. #ifndef TUYA_SERIAL
  1333. #define TUYA_SERIAL Serial
  1334. #endif
  1335. #ifndef TUYA_FILTER_ENABLED
  1336. #define TUYA_FILTER_ENABLED 1
  1337. #endif
  1338. #ifndef TUYA_DEBUG_ENABLED
  1339. #define TUYA_DEBUG_ENABLED 1
  1340. #endif
  1341. //--------------------------------------------------------------------------------
  1342. // Support expander MCP23S08
  1343. //--------------------------------------------------------------------------------
  1344. #ifndef MCP23S08_SUPPORT
  1345. #define MCP23S08_SUPPORT 0
  1346. #endif
  1347. //--------------------------------------------------------------------------------
  1348. // Support prometheus metrics export
  1349. //--------------------------------------------------------------------------------
  1350. #ifndef PROMETHEUS_SUPPORT
  1351. #define PROMETHEUS_SUPPORT 0
  1352. #endif
  1353. //--------------------------------------------------------------------------------
  1354. // ITEAD iFan support
  1355. //--------------------------------------------------------------------------------
  1356. #ifndef IFAN_SUPPORT
  1357. #define IFAN_SUPPORT 0
  1358. #endif
  1359. // =============================================================================
  1360. // Configuration helpers to help detect features
  1361. // =============================================================================
  1362. #ifndef DEBUG_SUPPORT
  1363. #define DEBUG_SUPPORT ( \
  1364. DEBUG_SERIAL_SUPPORT || \
  1365. DEBUG_UDP_SUPPORT || \
  1366. DEBUG_TELNET_SUPPORT || \
  1367. DEBUG_WEB_SUPPORT \
  1368. )
  1369. #endif
  1370. #ifndef FAN_SUPPORT
  1371. #define FAN_SUPPORT IFAN_SUPPORT
  1372. #endif