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.

1873 lines
64 KiB

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