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.

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