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.

1796 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...)
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
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...)
3 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...)
3 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. // Configure the MQTT payload for ON, OFF and TOGGLE
  342. #ifndef RELAY_MQTT_OFF
  343. #define RELAY_MQTT_OFF "0"
  344. #endif
  345. #ifndef RELAY_MQTT_ON
  346. #define RELAY_MQTT_ON "1"
  347. #endif
  348. #ifndef RELAY_MQTT_TOGGLE
  349. #define RELAY_MQTT_TOGGLE "2"
  350. #endif
  351. #ifndef RELAY_MQTT_TOPIC_MODE
  352. #define RELAY_MQTT_TOPIC_MODE RELAY_MQTT_TOPIC_NORMAL
  353. #endif
  354. #ifndef RELAY_MQTT_DISCONNECT_STATUS
  355. #define RELAY_MQTT_DISCONNECT_STATUS RELAY_MQTT_DISCONNECT_NONE
  356. #endif
  357. //------------------------------------------------------------------------------
  358. // BUTTON
  359. //------------------------------------------------------------------------------
  360. #ifndef BUTTON_SUPPORT
  361. #define BUTTON_SUPPORT 1
  362. #endif
  363. #ifndef BUTTON_DEBOUNCE_DELAY
  364. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  365. #endif
  366. #ifndef BUTTON_REPEAT_DELAY
  367. #define BUTTON_REPEAT_DELAY 500 // Time in ms to wait for a second (or third...) click
  368. #endif
  369. #ifndef BUTTON_LNGCLICK_DELAY
  370. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  371. #endif
  372. #ifndef BUTTON_LNGLNGCLICK_DELAY
  373. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  374. #endif
  375. #ifndef BUTTON_MQTT_SEND_ALL_EVENTS
  376. #define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions
  377. // 1 - to send all button events to MQTT
  378. #endif
  379. #ifndef BUTTON_MQTT_RETAIN
  380. #define BUTTON_MQTT_RETAIN 0
  381. #endif
  382. // Generic digital pin support
  383. #ifndef BUTTON_PROVIDER_GPIO_SUPPORT
  384. #define BUTTON_PROVIDER_GPIO_SUPPORT 1
  385. #endif
  386. // Resistor ladder support. Poll analog pin and return digital LOW when analog reading is in a certain range
  387. // ref. https://github.com/bxparks/AceButton/tree/develop/docs/resistor_ladder
  388. // Uses BUTTON#_ANALOG_LEVEL for the individual button level configuration
  389. #ifndef BUTTON_PROVIDER_ANALOG_SUPPORT
  390. #define BUTTON_PROVIDER_ANALOG_SUPPORT 0
  391. #endif
  392. //------------------------------------------------------------------------------
  393. // ENCODER
  394. //------------------------------------------------------------------------------
  395. #ifndef ENCODER_SUPPORT
  396. #define ENCODER_SUPPORT 0
  397. #endif
  398. #ifndef ENCODER_MINIMUM_DELTA
  399. #define ENCODER_MINIMUM_DELTA 1
  400. #endif
  401. //------------------------------------------------------------------------------
  402. // LED
  403. //------------------------------------------------------------------------------
  404. #ifndef LED_SUPPORT
  405. #define LED_SUPPORT 1
  406. #endif
  407. // -----------------------------------------------------------------------------
  408. // WIFI
  409. // -----------------------------------------------------------------------------
  410. #ifndef WIFI_CONNECT_TIMEOUT
  411. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  412. #endif
  413. #ifndef WIFI_RECONNECT_INTERVAL
  414. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  415. #endif
  416. #ifndef WIFI_MAX_NETWORKS
  417. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  418. #endif
  419. #ifndef WIFI_AP_CAPTIVE
  420. #define WIFI_AP_CAPTIVE 1 // Captive portal enabled when in AP mode
  421. #endif
  422. #ifndef WIFI_AP_MODE
  423. #define WIFI_AP_MODE WiFiApMode::Fallback // By default, fallback to AP mode if no STA connection
  424. // Use WiFiApMode::Enabled to start it when the device boots
  425. // Use WiFiApMode::Disabled to disable AP mode completely
  426. #endif
  427. #ifndef WIFI_AP_SSID
  428. #define WIFI_AP_SSID "" // (optional) Specify softAp SSID.
  429. // By default or when empty, hostname (or device identifier) is used instead.
  430. #endif
  431. #ifndef WIFI_AP_PASS
  432. #define WIFI_AP_PASS "" // (optional) Specify softAp passphrase
  433. // By default or when empty, admin password is used instead.
  434. #endif
  435. #ifndef WIFI_AP_LEASES_SUPPORT
  436. #define WIFI_AP_LEASES_SUPPORT 0 // (optional) Specify softAp MAC<->IP DHCP reservations
  437. // Use `set wifiApLease# MAC`, where MAC is a valid 12-byte HEX number without colons
  438. #endif
  439. #ifndef WIFI_SLEEP_MODE
  440. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  441. #endif
  442. #ifndef WIFI_SCAN_NETWORKS
  443. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  444. #endif
  445. // Optional hardcoded configuration (up to 5 networks, depending on WIFI_MAX_NETWORKS and espurna/wifi_config.h)
  446. #ifndef WIFI1_SSID
  447. #define WIFI1_SSID ""
  448. #endif
  449. #ifndef WIFI1_PASS
  450. #define WIFI1_PASS ""
  451. #endif
  452. #ifndef WIFI1_IP
  453. #define WIFI1_IP ""
  454. #endif
  455. #ifndef WIFI1_GW
  456. #define WIFI1_GW ""
  457. #endif
  458. #ifndef WIFI1_MASK
  459. #define WIFI1_MASK ""
  460. #endif
  461. #ifndef WIFI1_DNS
  462. #define WIFI1_DNS ""
  463. #endif
  464. #ifndef WIFI2_SSID
  465. #define WIFI2_SSID ""
  466. #endif
  467. #ifndef WIFI2_PASS
  468. #define WIFI2_PASS ""
  469. #endif
  470. #ifndef WIFI2_IP
  471. #define WIFI2_IP ""
  472. #endif
  473. #ifndef WIFI2_GW
  474. #define WIFI2_GW ""
  475. #endif
  476. #ifndef WIFI2_MASK
  477. #define WIFI2_MASK ""
  478. #endif
  479. #ifndef WIFI2_DNS
  480. #define WIFI2_DNS ""
  481. #endif
  482. #ifndef WIFI3_SSID
  483. #define WIFI3_SSID ""
  484. #endif
  485. #ifndef WIFI3_PASS
  486. #define WIFI3_PASS ""
  487. #endif
  488. #ifndef WIFI3_IP
  489. #define WIFI3_IP ""
  490. #endif
  491. #ifndef WIFI3_GW
  492. #define WIFI3_GW ""
  493. #endif
  494. #ifndef WIFI3_MASK
  495. #define WIFI3_MASK ""
  496. #endif
  497. #ifndef WIFI3_DNS
  498. #define WIFI3_DNS ""
  499. #endif
  500. #ifndef WIFI4_SSID
  501. #define WIFI4_SSID ""
  502. #endif
  503. #ifndef WIFI4_PASS
  504. #define WIFI4_PASS ""
  505. #endif
  506. #ifndef WIFI4_IP
  507. #define WIFI4_IP ""
  508. #endif
  509. #ifndef WIFI4_GW
  510. #define WIFI4_GW ""
  511. #endif
  512. #ifndef WIFI4_MASK
  513. #define WIFI4_MASK ""
  514. #endif
  515. #ifndef WIFI4_DNS
  516. #define WIFI4_DNS ""
  517. #endif
  518. #ifndef WIFI5_SSID
  519. #define WIFI5_SSID ""
  520. #endif
  521. #ifndef WIFI5_PASS
  522. #define WIFI5_PASS ""
  523. #endif
  524. #ifndef WIFI5_IP
  525. #define WIFI5_IP ""
  526. #endif
  527. #ifndef WIFI5_GW
  528. #define WIFI5_GW ""
  529. #endif
  530. #ifndef WIFI5_MASK
  531. #define WIFI5_MASK ""
  532. #endif
  533. #ifndef WIFI5_DNS
  534. #define WIFI5_DNS ""
  535. #endif
  536. #ifndef WIFI_RSSI_1M
  537. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  538. #endif
  539. #ifndef WIFI_PROPAGATION_CONST
  540. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  541. #endif
  542. // ref: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/kconfig.html#config-lwip-esp-gratuitous-arp
  543. // ref: https://github.com/xoseperez/espurna/pull/1877#issuecomment-525612546
  544. //
  545. // Broadcast gratuitous ARP periodically to update ARP tables on the AP and all devices on the same network.
  546. // Helps to solve compatibility issues when ESP fails to timely reply to ARP requests, causing the device's ARP table entry to expire.
  547. #ifndef WIFI_GRATUITOUS_ARP_SUPPORT
  548. #define WIFI_GRATUITOUS_ARP_SUPPORT 1
  549. #endif
  550. // Interval is randomized on each boot in range from ..._MIN to ..._MAX (ms)
  551. #ifndef WIFI_GRATUITOUS_ARP_INTERVAL_MIN
  552. #define WIFI_GRATUITOUS_ARP_INTERVAL_MIN 15000
  553. #endif
  554. #ifndef WIFI_GRATUITOUS_ARP_INTERVAL_MAX
  555. #define WIFI_GRATUITOUS_ARP_INTERVAL_MAX 30000
  556. #endif
  557. // ref: https://github.com/esp8266/Arduino/issues/6471
  558. // ref: https://github.com/esp8266/Arduino/issues/6366
  559. //
  560. // Issue #6366 turned out to be high tx power causing weird behavior. Lowering tx power achieved stability.
  561. #ifndef WIFI_OUTPUT_POWER_DBM
  562. #define WIFI_OUTPUT_POWER_DBM 20.0f
  563. #endif
  564. // -----------------------------------------------------------------------------
  565. // WEB
  566. // -----------------------------------------------------------------------------
  567. #ifndef WEB_SUPPORT
  568. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  569. #endif
  570. #ifndef WEB_EMBEDDED
  571. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  572. #endif
  573. #ifndef WEB_ACCESS_LOG
  574. #define WEB_ACCESS_LOG 0 // Log every request that was received by the server (but, not necessarily processed)
  575. #endif
  576. // Requires ESPAsyncTCP to be built with ASYNC_TCP_SSL_ENABLED=1 and Arduino Core version >= 2.4.0
  577. // XXX: This is not working at the moment!! Pending https://github.com/me-no-dev/ESPAsyncTCP/issues/95
  578. #ifndef WEB_SSL_ENABLED
  579. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  580. #endif
  581. #ifndef WEB_USERNAME
  582. #define WEB_USERNAME "admin" // HTTP username
  583. #endif
  584. #ifndef WEB_FORCE_PASS_CHANGE
  585. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  586. #endif
  587. #ifndef WEB_PORT
  588. #define WEB_PORT 80 // HTTP port
  589. #endif
  590. // Defining a WEB_REMOTE_DOMAIN will enable Cross-Origin Resource Sharing (CORS)
  591. // so you will be able to login to this device from another domain. This will allow
  592. // you to manage all ESPurna devices in your local network from a unique installation
  593. // of the web UI. This installation could be in a local server (a Raspberry Pi, for instance)
  594. // or in the Internet. Since the WebUI is just one compressed file with HTML, CSS and JS
  595. // there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...).
  596. // The only requirement is that the resource must be available under this domain.
  597. #ifndef WEB_REMOTE_DOMAIN
  598. #define WEB_REMOTE_DOMAIN "http://espurna.io"
  599. #endif
  600. // -----------------------------------------------------------------------------
  601. // WEBSOCKETS
  602. // -----------------------------------------------------------------------------
  603. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  604. #ifndef WS_AUTHENTICATION
  605. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  606. #endif
  607. #ifndef WS_BUFFER_SIZE
  608. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  609. #endif
  610. #ifndef WS_TIMEOUT
  611. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  612. #endif
  613. #ifndef WS_UPDATE_INTERVAL
  614. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  615. #endif
  616. // -----------------------------------------------------------------------------
  617. // API
  618. // -----------------------------------------------------------------------------
  619. #ifndef API_SUPPORT
  620. #define API_SUPPORT 1 // API (REST & RPC) support built in
  621. #endif
  622. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  623. #ifndef API_ENABLED
  624. #define API_ENABLED 0 // Do not enable API by default
  625. #endif
  626. #ifndef API_KEY
  627. #define API_KEY "" // Do not enable API by default. WebUI will automatically generate the key
  628. #endif
  629. #ifndef API_RESTFUL
  630. #define API_RESTFUL 1 // A restful API requires changes to be issued as PUT requests
  631. // Setting this to 0 will allow using GET to change relays, for instance
  632. #endif
  633. #ifndef API_JSON_BUFFER_SIZE
  634. #define API_JSON_BUFFER_SIZE 256 // Size of the (de)serializer buffer.
  635. #endif
  636. #ifndef API_BASE_PATH
  637. #define API_BASE_PATH "/api/"
  638. #endif
  639. #ifndef API_REAL_TIME_VALUES
  640. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  641. #endif
  642. // -----------------------------------------------------------------------------
  643. // MDNS / LLMNR / NETBIOS / SSDP
  644. // -----------------------------------------------------------------------------
  645. #ifndef MDNS_SERVER_SUPPORT
  646. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  647. #endif
  648. #ifndef LLMNR_SUPPORT
  649. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires Core version >= 2.4.0
  650. #endif
  651. #ifndef NETBIOS_SUPPORT
  652. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires Core version >= 2.4.0
  653. #endif
  654. #ifndef SSDP_SUPPORT
  655. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  656. // Not compatible with ALEXA_SUPPORT at the moment
  657. #endif
  658. #ifndef SSDP_DEVICE_TYPE
  659. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  660. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  661. #endif
  662. // -----------------------------------------------------------------------------
  663. // SPIFFS
  664. // -----------------------------------------------------------------------------
  665. #ifndef SPIFFS_SUPPORT
  666. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  667. #endif
  668. // -----------------------------------------------------------------------------
  669. // SSL Client ** EXPERIMENTAL **
  670. // -----------------------------------------------------------------------------
  671. #ifndef SECURE_CLIENT
  672. #define SECURE_CLIENT SECURE_CLIENT_NONE // What variant of WiFiClient to use
  673. // SECURE_CLIENT_NONE - No secure client support (default)
  674. // SECURE_CLIENT_AXTLS - axTLS client secure support (All Core versions, ONLY TLS 1.1)
  675. // SECURE_CLIENT_BEARSSL - BearSSL client secure support (starting with 2.5.0, TLS 1.2)
  676. //
  677. // axTLS marked for derecation since Arduino Core 2.4.2 and **will** be removed in the future
  678. #endif
  679. // Security check that is performed when the connection is established:
  680. // SECURE_CLIENT_CHECK_CA - Use Trust Anchor / Root Certificate
  681. // Supported only by the SECURE_CLIENT_BEARSSL
  682. // (See respective ..._SECURE_CLIENT_INCLUDE_CA options per-module)
  683. // SECURE_CLIENT_CHECK_FINGERPRINT - Check certificate fingerprint
  684. // SECURE_CLIENT_CHECK_NONE - Allow insecure connections
  685. #ifndef SECURE_CLIENT_CHECK
  686. #if SECURE_CLIENT == SECURE_CLIENT_BEARSSL
  687. #define SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK_CA
  688. #else
  689. #define SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK_FINGERPRINT
  690. #endif
  691. #endif // SECURE_CLIENT_CHECK
  692. // Support Maximum Fragment Length Negotiation TLS extension
  693. // "...negotiate a smaller maximum fragment length due to memory limitations or bandwidth limitations."
  694. // - https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/bearssl-client-secure-class.html#mfln-or-maximum-fragment-length-negotiation-saving-ram
  695. // - https://tools.ietf.org/html/rfc6066#section-4
  696. #ifndef SECURE_CLIENT_MFLN
  697. #define SECURE_CLIENT_MFLN 0 // The only possible values are: 512, 1024, 2048 and 4096
  698. // Set to 0 to disable (default)
  699. #endif
  700. // -----------------------------------------------------------------------------
  701. // OTA
  702. // -----------------------------------------------------------------------------
  703. #ifndef OTA_PORT
  704. #define OTA_PORT 8266 // Port for ArduinoOTA
  705. #endif
  706. #ifndef OTA_MQTT_SUPPORT
  707. #define OTA_MQTT_SUPPORT 0 // Listen for HTTP(s) URLs at '<root topic>/ota'. Depends on OTA_CLIENT
  708. #endif
  709. #ifndef OTA_ARDUINOOTA_SUPPORT
  710. #define OTA_ARDUINOOTA_SUPPORT 1 // Support ArduinoOTA by default (4.2Kb)
  711. // Implicitly depends on ESP8266mDNS library, thus increasing firmware size
  712. #endif
  713. #ifndef OTA_CLIENT
  714. #define OTA_CLIENT OTA_CLIENT_ASYNCTCP // Terminal / MQTT OTA support
  715. // OTA_CLIENT_ASYNCTCP (ESPAsyncTCP library)
  716. // OTA_CLIENT_HTTPUPDATE (Arduino Core library)j
  717. // OTA_CLIENT_NONE to disable
  718. #endif
  719. #ifndef OTA_WEB_SUPPORT
  720. #define OTA_WEB_SUPPORT 1 // Support `/upgrade` endpoint and WebUI OTA handler
  721. #endif
  722. #define OTA_GITHUB_FP "CA:06:F5:6B:25:8B:7A:0D:4F:2B:05:47:09:39:47:86:51:15:19:84"
  723. #ifndef OTA_FINGERPRINT
  724. #define OTA_FINGERPRINT OTA_GITHUB_FP
  725. #endif
  726. #ifndef OTA_SECURE_CLIENT_CHECK
  727. #define OTA_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK
  728. #endif
  729. #ifndef OTA_SECURE_CLIENT_MFLN
  730. #define OTA_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN
  731. #endif
  732. #ifndef OTA_SECURE_CLIENT_INCLUDE_CA
  733. #define OTA_SECURE_CLIENT_INCLUDE_CA 0 // Use user-provided CA. Only PROGMEM PEM option is supported.
  734. // TODO: eventually should be replaced with pre-parsed structs, read directly from flash
  735. // (ref: https://github.com/earlephilhower/bearssl-esp8266/pull/14)
  736. //
  737. // When enabled, current implementation includes "static/ota_client_trusted_root_ca.h" with
  738. // const char _ota_client_trusted_root_ca[] PROGMEM = "...PEM data...";
  739. // By default, using DigiCert root in "static/digicert_evroot_pem.h" (for https://github.com)
  740. #endif
  741. // -----------------------------------------------------------------------------
  742. // NOFUSS
  743. // -----------------------------------------------------------------------------
  744. #ifndef NOFUSS_SUPPORT
  745. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  746. #endif
  747. #ifndef NOFUSS_ENABLED
  748. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  749. #endif
  750. #ifndef NOFUSS_SERVER
  751. #define NOFUSS_SERVER "" // Default NoFuss Server
  752. #endif
  753. #ifndef NOFUSS_INTERVAL
  754. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  755. #endif
  756. // -----------------------------------------------------------------------------
  757. // UART <-> MQTT
  758. // -----------------------------------------------------------------------------
  759. #ifndef UART_MQTT_SUPPORT
  760. #define UART_MQTT_SUPPORT 0 // No support by default
  761. #endif
  762. #ifndef UART_MQTT_USE_SOFT
  763. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  764. #endif
  765. #ifndef UART_MQTT_HW_PORT
  766. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  767. #endif
  768. #ifndef UART_MQTT_RX_PIN
  769. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  770. #endif
  771. #ifndef UART_MQTT_TX_PIN
  772. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  773. #endif
  774. #ifndef UART_MQTT_BAUDRATE
  775. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  776. #endif
  777. #ifndef UART_MQTT_TERMINATION
  778. #define UART_MQTT_TERMINATION '\n' // Termination character
  779. #endif
  780. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  781. // -----------------------------------------------------------------------------
  782. // MQTT
  783. // -----------------------------------------------------------------------------
  784. #ifndef MQTT_SUPPORT
  785. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  786. #endif
  787. #ifndef MQTT_LIBRARY
  788. #define MQTT_LIBRARY MQTT_LIBRARY_ASYNCMQTTCLIENT // MQTT_LIBRARY_ASYNCMQTTCLIENT (default, https://github.com/marvinroger/async-mqtt-client)
  789. // MQTT_LIBRARY_PUBSUBCLIENT (https://github.com/knolleary/pubsubclient)
  790. // MQTT_LIBRARY_ARDUINOMQTT (https://github.com/256dpi/arduino-mqtt)
  791. #endif
  792. // -----------------------------------------------------------------------------
  793. // MQTT OVER SSL
  794. // -----------------------------------------------------------------------------
  795. //
  796. // Requires SECURE_CLIENT set to SECURE_CLIENT_AXTLS or SECURE_CLIENT_BEARSSL
  797. // It is recommended to use MQTT_LIBRARY_ARDUINOMQTT or MQTT_LIBRARY_PUBSUBCLIENT
  798. // It is recommended to use SECURE_CLIENT_BEARSSL
  799. // It is recommended to use ESP8266 Arduino Core >= 2.5.2 with SECURE_CLIENT_BEARSSL
  800. //
  801. // Current version of MQTT_LIBRARY_ASYNCMQTTCLIENT only supports SECURE_CLIENT_AXTLS
  802. //
  803. // It is recommended to use WEB_SUPPORT=0 with either SECURE_CLIENT option, as there are miscellaneous problems when using them simultaneously
  804. // (although, things might've improved, and I'd encourage to check whether this is true or not)
  805. //
  806. // When using MQTT_LIBRARY_PUBSUBCLIENT or MQTT_LIBRARY_ARDUINOMQTT, you will have to disable every module that uses ESPAsyncTCP:
  807. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0, DEBUG_TELNET_SUPPORT=0 and WEB_SUPPORT=0
  808. // Or, use "sync" versions instead (note that not every module has this option):
  809. // THINGSPEAK_USE_ASYNC=0, TELNET_SERVER=TELNET_SERVER_WIFISERVER
  810. //
  811. // See SECURE_CLIENT_CHECK for all possible connection verification options.
  812. //
  813. // The simpliest way to verify SSL connection is to use fingerprinting.
  814. // For example, to get Google's MQTT server certificate fingerprint, run the following command:
  815. // $ echo -n | openssl s_client -connect mqtt.googleapis.com:8883 2>&1 | openssl x509 -noout -fingerprint -sha1 | cut -d\= -f2
  816. // Note that fingerprint will change when certificate changes e.g. LetsEncrypt renewals or when the CSR updates
  817. #ifndef MQTT_SSL_ENABLED
  818. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  819. #endif
  820. #ifndef MQTT_SSL_FINGERPRINT
  821. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  822. #endif
  823. #ifndef MQTT_SECURE_CLIENT_CHECK
  824. #define MQTT_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK // Use global verification setting by default
  825. #endif
  826. #ifndef MQTT_SECURE_CLIENT_MFLN
  827. #define MQTT_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN // Use global MFLN setting by default
  828. #endif
  829. #ifndef MQTT_SECURE_CLIENT_INCLUDE_CA
  830. #define MQTT_SECURE_CLIENT_INCLUDE_CA 0 // Use user-provided CA. Only PROGMEM PEM option is supported.
  831. // When enabled, current implementation includes "static/mqtt_client_trusted_root_ca.h" with
  832. // const char _mqtt_client_trusted_root_ca[] PROGMEM = "...PEM data...";
  833. // By default, using LetsEncrypt X3 root in "static/letsencrypt_isrgroot_pem.h"
  834. #endif
  835. #ifndef MQTT_ENABLED
  836. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  837. #endif
  838. #ifndef MQTT_AUTOCONNECT
  839. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  840. // autoconnect to the first MQTT broker found if none defined
  841. #endif
  842. #ifndef MQTT_SERVER
  843. #define MQTT_SERVER "" // Default MQTT broker address
  844. #endif
  845. #ifndef MQTT_USER
  846. #define MQTT_USER "" // Default MQTT broker usename
  847. #endif
  848. #ifndef MQTT_PASS
  849. #define MQTT_PASS "" // Default MQTT broker password
  850. #endif
  851. #ifndef MQTT_PORT
  852. #define MQTT_PORT 1883 // MQTT broker port
  853. #endif
  854. #ifndef MQTT_TOPIC
  855. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  856. #endif
  857. #ifndef MQTT_RETAIN
  858. #define MQTT_RETAIN true // MQTT retain flag
  859. #endif
  860. #ifndef MQTT_QOS
  861. #define MQTT_QOS 0 // MQTT QoS value for all messages
  862. #endif
  863. #ifndef MQTT_KEEPALIVE
  864. #define MQTT_KEEPALIVE 120 // MQTT keepalive value
  865. #endif
  866. #ifndef MQTT_RECONNECT_DELAY_MIN
  867. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  868. #endif
  869. #ifndef MQTT_RECONNECT_DELAY_STEP
  870. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  871. #endif
  872. #ifndef MQTT_RECONNECT_DELAY_MAX
  873. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  874. #endif
  875. #ifndef MQTT_SKIP_TIME
  876. #define MQTT_SKIP_TIME 0 // Skip messages for N ms after connection. Disabled by default
  877. #endif
  878. #ifndef MQTT_USE_JSON
  879. #define MQTT_USE_JSON 0 // Don't group messages in a JSON body by default
  880. #endif
  881. #ifndef MQTT_USE_JSON_DELAY
  882. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  883. #endif
  884. #ifndef MQTT_QUEUE_MAX_SIZE
  885. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  886. #endif
  887. #ifndef MQTT_BUFFER_MAX_SIZE
  888. #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.
  889. // Note: When using MQTT_LIBRARY_PUBSUBCLIENT, MQTT_MAX_PACKET_SIZE should not be more than this value.
  890. #endif
  891. // These are the properties that will be sent when useJson is true
  892. #ifndef MQTT_ENQUEUE_IP
  893. #define MQTT_ENQUEUE_IP 1
  894. #endif
  895. #ifndef MQTT_ENQUEUE_MAC
  896. #define MQTT_ENQUEUE_MAC 1
  897. #endif
  898. #ifndef MQTT_ENQUEUE_HOSTNAME
  899. #define MQTT_ENQUEUE_HOSTNAME 1
  900. #endif
  901. #ifndef MQTT_ENQUEUE_DATETIME
  902. #define MQTT_ENQUEUE_DATETIME 1
  903. #endif
  904. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  905. #define MQTT_ENQUEUE_MESSAGE_ID 1
  906. #endif
  907. #ifndef MQTT_STATUS_ONLINE
  908. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  909. #endif
  910. #ifndef MQTT_STATUS_OFFLINE
  911. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  912. #endif
  913. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  914. // Custom get and set postfixes
  915. // Use something like "/status" or "/set", with leading slash
  916. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  917. #ifndef MQTT_GETTER
  918. #define MQTT_GETTER ""
  919. #endif
  920. #ifndef MQTT_SETTER
  921. #define MQTT_SETTER "/set"
  922. #endif
  923. // -----------------------------------------------------------------------------
  924. // BROKER
  925. // -----------------------------------------------------------------------------
  926. #ifndef BROKER_SUPPORT
  927. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  928. #endif
  929. // -----------------------------------------------------------------------------
  930. // SETTINGS
  931. // -----------------------------------------------------------------------------
  932. #ifndef SETTINGS_AUTOSAVE
  933. #define SETTINGS_AUTOSAVE 1 // Autosave settings or force manual commit
  934. #endif
  935. #define SETTINGS_MAX_LIST_COUNT 16 // Maximum index for settings lists
  936. // -----------------------------------------------------------------------------
  937. // LIGHT
  938. // -----------------------------------------------------------------------------
  939. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  940. // They have to be defined for each device in the hardware.h file.
  941. // If 3 or more channels first 3 will be considered RGB.
  942. // Usual configurations are:
  943. // 1 channels => W
  944. // 2 channels => WW
  945. // 3 channels => RGB
  946. // 4 channels => RGBW
  947. // 5 channels => RGBWW
  948. #ifndef LIGHT_PROVIDER
  949. #define LIGHT_PROVIDER LIGHT_PROVIDER_NONE
  950. #endif
  951. #ifndef LIGHT_REPORT_DELAY
  952. #define LIGHT_REPORT_DELAY 100 // Delay reporting current state for the specified number of ms after light update
  953. #endif
  954. #ifndef LIGHT_SAVE_ENABLED
  955. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  956. #endif
  957. #ifndef LIGHT_SAVE_DELAY
  958. #define LIGHT_SAVE_DELAY 5000 // Persist channel & brightness values after the specified number of ms
  959. #endif
  960. #ifndef LIGHT_MIN_PWM
  961. #define LIGHT_MIN_PWM 0
  962. #endif
  963. #ifndef LIGHT_MAX_PWM
  964. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  965. #define LIGHT_MAX_PWM 255
  966. #elif LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  967. #define LIGHT_MAX_PWM 10000 // 10000 * 200ns => 2 kHz
  968. #else
  969. #define LIGHT_MAX_PWM 0
  970. #endif
  971. #endif // LIGHT_MAX_PWM
  972. #ifndef LIGHT_LIMIT_PWM
  973. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  974. #endif
  975. #ifndef LIGHT_MIN_VALUE
  976. #define LIGHT_MIN_VALUE 0 // Minimum light value
  977. #endif
  978. #ifndef LIGHT_MAX_VALUE
  979. #define LIGHT_MAX_VALUE 255 // Maximum light value
  980. #endif
  981. #ifndef LIGHT_MIN_BRIGHTNESS
  982. #define LIGHT_MIN_BRIGHTNESS 0 // Minimum brightness value
  983. #endif
  984. #ifndef LIGHT_MAX_BRIGHTNESS
  985. #define LIGHT_MAX_BRIGHTNESS 255 // Maximum brightness value
  986. #endif
  987. // Default mireds & kelvin to the Philips Hue limits
  988. // https://developers.meethue.com/documentation/core-concepts
  989. //
  990. // Home Assistant also uses these, see Light::min_mireds, Light::max_mireds
  991. // https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/__init__.py
  992. // Used when LIGHT_USE_WHITE AND LIGHT_USE_CCT is 1 - (1000000/Kelvin = MiReds)
  993. // Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
  994. #ifndef LIGHT_COLDWHITE_MIRED
  995. #define LIGHT_COLDWHITE_MIRED 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
  996. #endif
  997. #ifndef LIGHT_WARMWHITE_MIRED
  998. #define LIGHT_WARMWHITE_MIRED 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
  999. #endif
  1000. #ifndef LIGHT_STEP
  1001. #define LIGHT_STEP 32 // Step size
  1002. #endif
  1003. #ifndef LIGHT_USE_COLOR
  1004. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  1005. #endif
  1006. #ifndef LIGHT_USE_WHITE
  1007. #define LIGHT_USE_WHITE 0 // Use the 4th channel as (Warm-)White LEDs
  1008. #endif
  1009. #ifndef LIGHT_USE_CCT
  1010. #define LIGHT_USE_CCT 0 // Use the 5th channel as Coldwhite LEDs, LIGHT_USE_WHITE must be 1.
  1011. #endif
  1012. #ifndef LIGHT_USE_GAMMA
  1013. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  1014. #endif
  1015. #ifndef LIGHT_USE_RGB
  1016. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  1017. #endif
  1018. #ifndef LIGHT_WHITE_FACTOR
  1019. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  1020. // this factor is used to scale the white channel to match brightness
  1021. #endif
  1022. #ifndef LIGHT_USE_TRANSITIONS
  1023. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  1024. #endif
  1025. #ifndef LIGHT_TRANSITION_STEP
  1026. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  1027. #endif
  1028. #ifndef LIGHT_TRANSITION_TIME
  1029. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  1030. #endif
  1031. #ifndef LIGHT_RELAY_ENABLED
  1032. #define LIGHT_RELAY_ENABLED 1 // Add a virtual switch that controls the global light state. Depends on RELAY_SUPPORT
  1033. #endif
  1034. // -----------------------------------------------------------------------------
  1035. // DOMOTICZ
  1036. // -----------------------------------------------------------------------------
  1037. #ifndef DOMOTICZ_SUPPORT
  1038. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  1039. #endif
  1040. #ifndef DOMOTICZ_ENABLED
  1041. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  1042. #endif
  1043. #ifndef DOMOTICZ_IN_TOPIC
  1044. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  1045. #endif
  1046. #ifndef DOMOTICZ_OUT_TOPIC
  1047. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  1048. #endif
  1049. // -----------------------------------------------------------------------------
  1050. // HOME ASSISTANT
  1051. // -----------------------------------------------------------------------------
  1052. #ifndef HOMEASSISTANT_SUPPORT
  1053. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  1054. #endif
  1055. #ifndef HOMEASSISTANT_ENABLED
  1056. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  1057. #endif
  1058. #ifndef HOMEASSISTANT_PREFIX
  1059. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  1060. #endif
  1061. #ifndef HOMEASSISTANT_RETAIN
  1062. #define HOMEASSISTANT_RETAIN MQTT_RETAIN // Make broker retain the messages
  1063. #endif
  1064. // -----------------------------------------------------------------------------
  1065. // INFLUXDB
  1066. // -----------------------------------------------------------------------------
  1067. #ifndef INFLUXDB_SUPPORT
  1068. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  1069. #endif
  1070. #ifndef INFLUXDB_ENABLED
  1071. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  1072. #endif
  1073. #ifndef INFLUXDB_HOST
  1074. #define INFLUXDB_HOST "" // Default server
  1075. #endif
  1076. #ifndef INFLUXDB_PORT
  1077. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  1078. #endif
  1079. #ifndef INFLUXDB_DATABASE
  1080. #define INFLUXDB_DATABASE "" // Default database
  1081. #endif
  1082. #ifndef INFLUXDB_USERNAME
  1083. #define INFLUXDB_USERNAME "" // Default username
  1084. #endif
  1085. #ifndef INFLUXDB_PASSWORD
  1086. #define INFLUXDB_PASSWORD "" // Default password
  1087. #endif
  1088. // -----------------------------------------------------------------------------
  1089. // THINGSPEAK
  1090. // -----------------------------------------------------------------------------
  1091. #ifndef THINGSPEAK_SUPPORT
  1092. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  1093. #endif
  1094. #ifndef THINGSPEAK_ENABLED
  1095. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  1096. #endif
  1097. #ifndef THINGSPEAK_APIKEY
  1098. #define THINGSPEAK_APIKEY "" // Default API KEY
  1099. #endif
  1100. #ifndef THINGSPEAK_CLEAR_CACHE
  1101. #define THINGSPEAK_CLEAR_CACHE 1 // Clear cache after sending values
  1102. // Not clearing it will result in latest values for each field being sent every time
  1103. #endif
  1104. #ifndef THINGSPEAK_USE_ASYNC
  1105. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  1106. #endif
  1107. // THINGSPEAK OVER SSL
  1108. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  1109. // so you should compile it with WEB_SUPPORT to 0.
  1110. // When THINGSPEAK_USE_ASYNC is 1, requires EspAsyncTCP to be built with ASYNC_TCP_SSL_ENABLED=1 and ESP8266 Arduino Core >= 2.4.0.
  1111. // When THINGSPEAK_USE_ASYNC is 0, requires Arduino Core >= 2.6.0 and SECURE_CLIENT_BEARSSL
  1112. //
  1113. // WARNING: Thingspeak servers do not support MFLN right now, connection requires at least 30KB of free RAM.
  1114. // Also see MQTT comments above.
  1115. #ifndef THINGSPEAK_USE_SSL
  1116. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  1117. #endif
  1118. #ifndef THINGSPEAK_SECURE_CLIENT_CHECK
  1119. #define THINGSPEAK_SECURE_CLIENT_CHECK SECURE_CLIENT_CHECK
  1120. #endif
  1121. #ifndef THINGSPEAK_SECURE_CLIENT_MFLN
  1122. #define THINGSPEAK_SECURE_CLIENT_MFLN SECURE_CLIENT_MFLN
  1123. #endif
  1124. #ifndef THINGSPEAK_FINGERPRINT
  1125. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  1126. #endif
  1127. #ifndef THINGSPEAK_ADDRESS
  1128. #if THINGSPEAK_USE_SSL
  1129. #define THINGSPEAK_ADDRESS "https://api.thingspeak.com/update"
  1130. #else
  1131. #define THINGSPEAK_ADDRESS "http://api.thingspeak.com/update"
  1132. #endif
  1133. #endif // ifndef THINGSPEAK_ADDRESS
  1134. #ifndef THINGSPEAK_TRIES
  1135. #define THINGSPEAK_TRIES 3 // Number of tries when sending data (minimum 1)
  1136. #endif
  1137. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  1138. #define THINGSPEAK_FIELDS 8 // Number of fields
  1139. // -----------------------------------------------------------------------------
  1140. // SCHEDULER
  1141. // -----------------------------------------------------------------------------
  1142. #ifndef SCHEDULER_SUPPORT
  1143. #define SCHEDULER_SUPPORT 1 // Enable scheduler (2.45Kb)
  1144. #endif
  1145. #ifndef SCHEDULER_MAX_SCHEDULES
  1146. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  1147. #endif
  1148. #ifndef SCHEDULER_RESTORE_LAST_SCHEDULE
  1149. #define SCHEDULER_RESTORE_LAST_SCHEDULE 0 // Restore the last schedule state on the device boot
  1150. #endif
  1151. #ifndef SCHEDULER_WEEKDAYS
  1152. #define SCHEDULER_WEEKDAYS "1,2,3,4,5,6,7" // (Default - Run the schedules every day)
  1153. #endif
  1154. // -----------------------------------------------------------------------------
  1155. // RPN RULES
  1156. // -----------------------------------------------------------------------------
  1157. #ifndef RPN_RULES_SUPPORT
  1158. #define RPN_RULES_SUPPORT 0 // Enable RPN Rules (8.6Kb)
  1159. #endif
  1160. #ifndef RPN_DELAY
  1161. #define RPN_DELAY 100 // Execute rules after 100ms without messages
  1162. #endif
  1163. #ifndef RPN_STICKY
  1164. #define RPN_STICKY 1 // Keeps variable after rule execution
  1165. #endif
  1166. // -----------------------------------------------------------------------------
  1167. // NTP
  1168. // -----------------------------------------------------------------------------
  1169. #ifndef NTP_SUPPORT
  1170. #define NTP_SUPPORT 1 // Build with NTP support by default (depends on Core version)
  1171. #endif
  1172. #ifndef NTP_SERVER
  1173. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  1174. #endif
  1175. #ifndef NTP_TIMEZONE
  1176. #define NTP_TIMEZONE TZ_Etc_UTC // POSIX TZ variable. Default to UTC from TZ.h (which is PSTR("UTC0"))
  1177. // For the format documentation, see:
  1178. // - https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
  1179. // ESP8266 Core provides human-readable aliases for POSIX format, see:
  1180. // - Latest: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
  1181. // - PlatformIO: ~/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/TZ.h
  1182. // (or, possibly, c:\.platformio\... on Windows)
  1183. // - Arduino IDE: depends on platform, see `/dist/arduino_ide/README.md`
  1184. #endif
  1185. #ifndef NTP_UPDATE_INTERVAL
  1186. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  1187. #endif
  1188. #ifndef NTP_START_DELAY
  1189. #define NTP_START_DELAY 3 // Delay NTP start for 3 seconds
  1190. #endif
  1191. #ifndef NTP_WAIT_FOR_SYNC
  1192. #define NTP_WAIT_FOR_SYNC 1 // Do not report any datetime until NTP sync'ed
  1193. #endif
  1194. #ifndef NTP_DHCP_SERVER
  1195. #define NTP_DHCP_SERVER 1 // Automatically replace the NTP server value with the one received with the DHCP packet
  1196. #endif
  1197. // -----------------------------------------------------------------------------
  1198. // ALEXA
  1199. // -----------------------------------------------------------------------------
  1200. // This setting defines whether Alexa support should be built into the firmware
  1201. #ifndef ALEXA_SUPPORT
  1202. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  1203. #endif
  1204. // This is default value for the alexaEnabled setting that defines whether
  1205. // this device should be discoberable and respond to Alexa commands.
  1206. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  1207. #ifndef ALEXA_ENABLED
  1208. #define ALEXA_ENABLED 1
  1209. #endif
  1210. #ifndef ALEXA_HOSTNAME
  1211. #define ALEXA_HOSTNAME ""
  1212. #endif
  1213. // -----------------------------------------------------------------------------
  1214. // RF BRIDGE
  1215. // -----------------------------------------------------------------------------
  1216. #ifndef RFB_SUPPORT
  1217. #define RFB_SUPPORT 0
  1218. #endif
  1219. #ifndef RFB_SEND_REPEATS
  1220. #define RFB_SEND_REPEATS 1 // How many times to send the message
  1221. #endif
  1222. // - RFB_PROVIDER_EFM8BB1
  1223. // Default option for the ITEAD_SONOFF_RFBRIDGE or any custom firmware implementing the protocol
  1224. // - RFB_PROVIDER_RCSWITCH
  1225. // Originally implemented for SONOFF BASIC
  1226. // https://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  1227. // Also possible to use with SONOFF RF BRIDGE, thanks to @wildwiz
  1228. // https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack
  1229. #ifndef RFB_PROVIDER
  1230. #define RFB_PROVIDER RFB_PROVIDER_RCSWITCH
  1231. #endif
  1232. #ifndef RFB_RX_PIN
  1233. #define RFB_RX_PIN GPIO_NONE
  1234. #endif
  1235. #ifndef RFB_TX_PIN
  1236. #define RFB_TX_PIN GPIO_NONE
  1237. #endif
  1238. #ifndef RFB_LEARN_TIMEOUT
  1239. #define RFB_LEARN_TIMEOUT 15000
  1240. #endif
  1241. #ifndef RFB_SEND_DELAY
  1242. #define RFB_SEND_DELAY 500 // Interval between sendings in ms
  1243. #endif
  1244. #ifndef RFB_RECEIVE_DELAY
  1245. #define RFB_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid bouncing)
  1246. #endif
  1247. #ifndef RFB_TRANSMIT_REPEATS
  1248. #define RFB_TRANSMIT_REPEATS 5 // How many times RCSwitch will repeat the message
  1249. #endif
  1250. // -----------------------------------------------------------------------------
  1251. // IR Bridge
  1252. // -----------------------------------------------------------------------------
  1253. #ifndef IR_SUPPORT
  1254. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  1255. #endif
  1256. //#define IR_RX_PIN 5 // GPIO the receiver is connected to
  1257. //#define IR_TX_PIN 4 // GPIO the transmitter is connected to
  1258. #ifndef IR_USE_RAW
  1259. #define IR_USE_RAW 0 // Use raw codes
  1260. #endif
  1261. #ifndef IR_BUFFER_SIZE
  1262. #define IR_BUFFER_SIZE 1024
  1263. #endif
  1264. #ifndef IR_TIMEOUT
  1265. #define IR_TIMEOUT 15U
  1266. #endif
  1267. #ifndef IR_REPEAT
  1268. #define IR_REPEAT 1
  1269. #endif
  1270. #ifndef IR_DELAY
  1271. #define IR_DELAY 100
  1272. #endif
  1273. #ifndef IR_DEBOUNCE
  1274. #define IR_DEBOUNCE 500 // IR debounce time in milliseconds
  1275. #endif
  1276. #ifndef IR_BUTTON_SET
  1277. #define IR_BUTTON_SET 0 // IR button set to use (see ../ir_button.h)
  1278. #endif
  1279. //--------------------------------------------------------------------------------
  1280. // Custom RFM69 to MQTT bridge
  1281. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1282. // Enable support by passing RFM69_SUPPORT=1 build flag
  1283. //--------------------------------------------------------------------------------
  1284. #ifndef RFM69_SUPPORT
  1285. #define RFM69_SUPPORT 0
  1286. #endif
  1287. #ifndef RFM69_MAX_TOPICS
  1288. #define RFM69_MAX_TOPICS 50
  1289. #endif
  1290. #ifndef RFM69_MAX_NODES
  1291. #define RFM69_MAX_NODES 255
  1292. #endif
  1293. #ifndef RFM69_DEFAULT_TOPIC
  1294. #define RFM69_DEFAULT_TOPIC "/rfm69gw/{node}/{key}"
  1295. #endif
  1296. #ifndef RFM69_NODE_ID
  1297. #define RFM69_NODE_ID 1
  1298. #endif
  1299. #ifndef RFM69_GATEWAY_ID
  1300. #define RFM69_GATEWAY_ID 1
  1301. #endif
  1302. #ifndef RFM69_NETWORK_ID
  1303. #define RFM69_NETWORK_ID 164
  1304. #endif
  1305. #ifndef RFM69_PROMISCUOUS
  1306. #define RFM69_PROMISCUOUS 0
  1307. #endif
  1308. #ifndef RFM69_PROMISCUOUS_SENDS
  1309. #define RFM69_PROMISCUOUS_SENDS 0
  1310. #endif
  1311. #ifndef RFM69_FREQUENCY
  1312. #define RFM69_FREQUENCY RF69_868MHZ
  1313. #endif
  1314. #ifndef RFM69_ENCRYPTKEY
  1315. #define RFM69_ENCRYPTKEY "fibonacci0123456"
  1316. #endif
  1317. #ifndef RFM69_CS_PIN
  1318. #define RFM69_CS_PIN SS
  1319. #endif
  1320. #ifndef RFM69_IRQ_PIN
  1321. #define RFM69_IRQ_PIN 5
  1322. #endif
  1323. #ifndef RFM69_RESET_PIN
  1324. #define RFM69_RESET_PIN 7
  1325. #endif
  1326. #ifndef RFM69_IS_RFM69HW
  1327. #define RFM69_IS_RFM69HW 0
  1328. #endif
  1329. //--------------------------------------------------------------------------------
  1330. // TUYA switch & dimmer support
  1331. //--------------------------------------------------------------------------------
  1332. #ifndef TUYA_SUPPORT
  1333. #define TUYA_SUPPORT 0
  1334. #endif
  1335. #ifndef TUYA_SERIAL
  1336. #define TUYA_SERIAL Serial
  1337. #endif
  1338. #ifndef TUYA_FILTER_ENABLED
  1339. #define TUYA_FILTER_ENABLED 1
  1340. #endif
  1341. #ifndef TUYA_DEBUG_ENABLED
  1342. #define TUYA_DEBUG_ENABLED 1
  1343. #endif
  1344. //--------------------------------------------------------------------------------
  1345. // Support expander MCP23S08
  1346. //--------------------------------------------------------------------------------
  1347. #ifndef MCP23S08_SUPPORT
  1348. #define MCP23S08_SUPPORT 0
  1349. #endif
  1350. //--------------------------------------------------------------------------------
  1351. // Support prometheus metrics export
  1352. //--------------------------------------------------------------------------------
  1353. #ifndef PROMETHEUS_SUPPORT
  1354. #define PROMETHEUS_SUPPORT 0
  1355. #endif
  1356. //--------------------------------------------------------------------------------
  1357. // ITEAD iFan support
  1358. //--------------------------------------------------------------------------------
  1359. #ifndef IFAN_SUPPORT
  1360. #define IFAN_SUPPORT 0
  1361. #endif
  1362. // =============================================================================
  1363. // Configuration helpers to help detect features
  1364. // =============================================================================
  1365. #ifndef DEBUG_SUPPORT
  1366. #define DEBUG_SUPPORT ( \
  1367. DEBUG_SERIAL_SUPPORT || \
  1368. DEBUG_UDP_SUPPORT || \
  1369. DEBUG_TELNET_SUPPORT || \
  1370. DEBUG_WEB_SUPPORT \
  1371. )
  1372. #endif
  1373. #ifndef FAN_SUPPORT
  1374. #define FAN_SUPPORT IFAN_SUPPORT
  1375. #endif