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.

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