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.

1494 lines
48 KiB

8 years ago
8 years ago
6 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
6 years ago
6 years ago
6 years ago
7 years ago
8 years ago
8 years ago
7 years ago
6 years ago
6 years ago
6 years ago
8 years ago
7 years ago
  1. // // //------------------------------------------------------------------------------
  2. // Do not change this file unless you know what you are doing
  3. // Configuration settings are in the settings.h file
  4. //------------------------------------------------------------------------------
  5. //------------------------------------------------------------------------------
  6. // GENERAL
  7. //------------------------------------------------------------------------------
  8. #define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name
  9. // When defined, ADMIN_PASS must be 8..63 printable ASCII characters. See:
  10. // https://en.wikipedia.org/wiki/Wi-Fi_Protected_Access#Target_users_(authentication_key_distribution)
  11. // https://github.com/xoseperez/espurna/issues/1151
  12. #ifndef ADMIN_PASS
  13. #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI SoftAP)
  14. #endif
  15. #ifndef USE_PASSWORD
  16. #define USE_PASSWORD 1 // Insecurity caution! Disabling this will disable password querying completely.
  17. #endif
  18. #ifndef LOOP_DELAY_TIME
  19. #define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250]
  20. #endif
  21. //------------------------------------------------------------------------------
  22. // DEBUG
  23. //------------------------------------------------------------------------------
  24. // Serial debug log
  25. #ifndef DEBUG_SERIAL_SUPPORT
  26. #define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log
  27. #endif
  28. #ifndef DEBUG_PORT
  29. #define DEBUG_PORT Serial // Default debugging port
  30. #endif
  31. #ifndef SERIAL_BAUDRATE
  32. #define SERIAL_BAUDRATE 115200 // Default baudrate
  33. #endif
  34. #ifndef DEBUG_ADD_TIMESTAMP
  35. #define DEBUG_ADD_TIMESTAMP 1 // Add timestamp to debug messages
  36. // (in millis overflowing every 1000 seconds)
  37. #endif
  38. // Second serial port (used for RX)
  39. #ifndef SERIAL_RX_ENABLED
  40. #define SERIAL_RX_ENABLED 0 // Secondary serial port for RX
  41. #endif
  42. #ifndef SERIAL_RX_PORT
  43. #define SERIAL_RX_PORT Serial // This setting is usually defined
  44. // in the hardware.h file for those
  45. // boards that require it
  46. #endif
  47. #ifndef SERIAL_RX_BAUDRATE
  48. #define SERIAL_RX_BAUDRATE 115200 // Default baudrate
  49. #endif
  50. //------------------------------------------------------------------------------
  51. // UDP debug log
  52. // To receive the message son the destination computer use nc:
  53. // nc -ul 8113
  54. #ifndef DEBUG_UDP_SUPPORT
  55. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  56. #endif
  57. #ifndef DEBUG_UDP_IP
  58. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  59. #endif
  60. #ifndef DEBUG_UDP_PORT
  61. #define DEBUG_UDP_PORT 514
  62. #endif
  63. // If DEBUG_UDP_PORT is set to 514 syslog format is assumed
  64. // (https://tools.ietf.org/html/rfc3164)
  65. // DEBUG_UDP_FAC_PRI is the facility+priority
  66. #define DEBUG_UDP_FAC_PRI (SYSLOG_LOCAL0 | SYSLOG_DEBUG)
  67. //------------------------------------------------------------------------------
  68. #ifndef DEBUG_TELNET_SUPPORT
  69. #define DEBUG_TELNET_SUPPORT 1 // Enable telnet debug log (will only work if TELNET_SUPPORT is also 1)
  70. #endif
  71. //------------------------------------------------------------------------------
  72. #ifndef DEBUG_WEB_SUPPORT
  73. #define DEBUG_WEB_SUPPORT 1 // Enable web debug log (will only work if WEB_SUPPORT is also 1)
  74. #endif
  75. //------------------------------------------------------------------------------
  76. // TELNET
  77. //------------------------------------------------------------------------------
  78. #ifndef TELNET_SUPPORT
  79. #define TELNET_SUPPORT 1 // Enable telnet support by default (3.34Kb)
  80. #endif
  81. #ifndef TELNET_STA
  82. #define TELNET_STA 0 // By default, disallow connections via STA interface
  83. #endif
  84. #ifndef TELNET_AUTHENTICATION
  85. #define TELNET_AUTHENTICATION 1 // Request password to start telnet session by default
  86. #endif
  87. #define TELNET_PORT 23 // Port to listen to telnet clients
  88. #define TELNET_MAX_CLIENTS 1 // Max number of concurrent telnet clients
  89. //------------------------------------------------------------------------------
  90. // TERMINAL
  91. //------------------------------------------------------------------------------
  92. #ifndef TERMINAL_SUPPORT
  93. #define TERMINAL_SUPPORT 1 // Enable terminal commands (0.97Kb)
  94. #endif
  95. #define TERMINAL_BUFFER_SIZE 128 // Max size for commands commands
  96. //------------------------------------------------------------------------------
  97. // SYSTEM CHECK
  98. //------------------------------------------------------------------------------
  99. #ifndef SYSTEM_CHECK_ENABLED
  100. #define SYSTEM_CHECK_ENABLED 1 // Enable crash check by default
  101. #endif
  102. #ifndef SYSTEM_CHECK_TIME
  103. #define SYSTEM_CHECK_TIME 60000 // The system is considered stable after these many millis
  104. #endif
  105. #ifndef SYSTEM_CHECK_MAX
  106. #define SYSTEM_CHECK_MAX 5 // After this many crashes on boot
  107. // the system is flagged as unstable
  108. #endif
  109. //------------------------------------------------------------------------------
  110. // EEPROM
  111. //------------------------------------------------------------------------------
  112. #define EEPROM_SIZE SPI_FLASH_SEC_SIZE // EEPROM size in bytes (1 sector = 4096 bytes)
  113. //#define EEPROM_RORATE_SECTORS 2 // Number of sectors to use for EEPROM rotation
  114. // If not defined the firmware will use a number based
  115. // on the number of available sectors
  116. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  117. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  118. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  119. #define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte)
  120. #define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes)
  121. #define EEPROM_ROTATE_DATA 11 // Reserved for the EEPROM_ROTATE library (3 bytes)
  122. #define EEPROM_DATA_END 14 // End of custom EEPROM data block
  123. //------------------------------------------------------------------------------
  124. // HEARTBEAT
  125. //------------------------------------------------------------------------------
  126. #define HEARTBEAT_NONE 0 // Never send heartbeat
  127. #define HEARTBEAT_ONCE 1 // Send it only once upon MQTT connection
  128. #define HEARTBEAT_REPEAT 2 // Send it upon MQTT connection and every HEARTBEAT_INTERVAL
  129. #define HEARTBEAT_REPEAT_STATUS 3 // Send it upon MQTT connection and every HEARTBEAT_INTERVAL only STATUS report
  130. // Backwards compatibility check
  131. #if defined(HEARTBEAT_ENABLED) && (HEARTBEAT_ENABLED == 0)
  132. #define HEARTBEAT_MODE HEARTBEAT_NONE
  133. #endif
  134. #ifndef HEARTBEAT_MODE
  135. #define HEARTBEAT_MODE HEARTBEAT_REPEAT
  136. #endif
  137. #ifndef HEARTBEAT_INTERVAL
  138. #define HEARTBEAT_INTERVAL 300 // Interval between heartbeat messages (in sec)
  139. #endif
  140. #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
  141. // Values that will be reported in heartbeat
  142. #ifndef HEARTBEAT_REPORT_STATUS
  143. #define HEARTBEAT_REPORT_STATUS 1
  144. #endif
  145. #ifndef HEARTBEAT_REPORT_SSID
  146. #define HEARTBEAT_REPORT_SSID 1
  147. #endif
  148. #ifndef HEARTBEAT_REPORT_IP
  149. #define HEARTBEAT_REPORT_IP 1
  150. #endif
  151. #ifndef HEARTBEAT_REPORT_MAC
  152. #define HEARTBEAT_REPORT_MAC 1
  153. #endif
  154. #ifndef HEARTBEAT_REPORT_RSSI
  155. #define HEARTBEAT_REPORT_RSSI 1
  156. #endif
  157. #ifndef HEARTBEAT_REPORT_UPTIME
  158. #define HEARTBEAT_REPORT_UPTIME 1
  159. #endif
  160. #ifndef HEARTBEAT_REPORT_DATETIME
  161. #define HEARTBEAT_REPORT_DATETIME 1
  162. #endif
  163. #ifndef HEARTBEAT_REPORT_FREEHEAP
  164. #define HEARTBEAT_REPORT_FREEHEAP 1
  165. #endif
  166. #ifndef HEARTBEAT_REPORT_VCC
  167. #define HEARTBEAT_REPORT_VCC 1
  168. #endif
  169. #ifndef HEARTBEAT_REPORT_RELAY
  170. #define HEARTBEAT_REPORT_RELAY 1
  171. #endif
  172. #ifndef HEARTBEAT_REPORT_LIGHT
  173. #define HEARTBEAT_REPORT_LIGHT 1
  174. #endif
  175. #ifndef HEARTBEAT_REPORT_HOSTNAME
  176. #define HEARTBEAT_REPORT_HOSTNAME 1
  177. #endif
  178. #ifndef HEARTBEAT_REPORT_DESCRIPTION
  179. #define HEARTBEAT_REPORT_DESCRIPTION 1
  180. #endif
  181. #ifndef HEARTBEAT_REPORT_APP
  182. #define HEARTBEAT_REPORT_APP 1
  183. #endif
  184. #ifndef HEARTBEAT_REPORT_VERSION
  185. #define HEARTBEAT_REPORT_VERSION 1
  186. #endif
  187. #ifndef HEARTBEAT_REPORT_BOARD
  188. #define HEARTBEAT_REPORT_BOARD 1
  189. #endif
  190. #ifndef HEARTBEAT_REPORT_LOADAVG
  191. #define HEARTBEAT_REPORT_LOADAVG 1
  192. #endif
  193. #ifndef HEARTBEAT_REPORT_INTERVAL
  194. #define HEARTBEAT_REPORT_INTERVAL 0
  195. #endif
  196. //------------------------------------------------------------------------------
  197. // Load average
  198. //------------------------------------------------------------------------------
  199. #ifndef LOADAVG_INTERVAL
  200. #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
  201. #endif
  202. //------------------------------------------------------------------------------
  203. // BUTTON
  204. //------------------------------------------------------------------------------
  205. #ifndef BUTTON_SUPPORT
  206. #define BUTTON_SUPPORT 1
  207. #endif
  208. #ifndef BUTTON_DEBOUNCE_DELAY
  209. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  210. #endif
  211. #ifndef BUTTON_DBLCLICK_DELAY
  212. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  213. #endif
  214. #ifndef BUTTON_LNGCLICK_DELAY
  215. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  216. #endif
  217. #ifndef BUTTON_LNGLNGCLICK_DELAY
  218. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  219. #endif
  220. #ifndef BUTTON_MQTT_SEND_ALL_EVENTS
  221. #define BUTTON_MQTT_SEND_ALL_EVENTS 0 // 0 - to send only events the are bound to actions
  222. // 1 - to send all button events to MQTT
  223. #endif
  224. //------------------------------------------------------------------------------
  225. // ENCODER
  226. //------------------------------------------------------------------------------
  227. #ifndef ENCODER_SUPPORT
  228. #define ENCODER_SUPPORT 0
  229. #endif
  230. //------------------------------------------------------------------------------
  231. // LED
  232. //------------------------------------------------------------------------------
  233. #ifndef LED_SUPPORT
  234. #define LED_SUPPORT 1
  235. #endif
  236. //------------------------------------------------------------------------------
  237. // RELAY
  238. //------------------------------------------------------------------------------
  239. // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
  240. #ifndef RELAY_BOOT_MODE
  241. #define RELAY_BOOT_MODE RELAY_BOOT_OFF
  242. #endif
  243. // 0 means ANY, 1 zero or one and 2 one and only one
  244. #ifndef RELAY_SYNC
  245. #define RELAY_SYNC RELAY_SYNC_ANY
  246. #endif
  247. // Default pulse mode: 0 means no pulses, 1 means normally off, 2 normally on
  248. #ifndef RELAY_PULSE_MODE
  249. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  250. #endif
  251. // Default pulse time in seconds
  252. #ifndef RELAY_PULSE_TIME
  253. #define RELAY_PULSE_TIME 1.0
  254. #endif
  255. // Relay requests flood protection window - in seconds
  256. #ifndef RELAY_FLOOD_WINDOW
  257. #define RELAY_FLOOD_WINDOW 3
  258. #endif
  259. // Allowed actual relay changes inside requests flood protection window
  260. #ifndef RELAY_FLOOD_CHANGES
  261. #define RELAY_FLOOD_CHANGES 5
  262. #endif
  263. // Pulse with in milliseconds for a latched relay
  264. #ifndef RELAY_LATCHING_PULSE
  265. #define RELAY_LATCHING_PULSE 10
  266. #endif
  267. // Do not save relay state after these many milliseconds
  268. #ifndef RELAY_SAVE_DELAY
  269. #define RELAY_SAVE_DELAY 1000
  270. #endif
  271. // Configure the MQTT payload for ON/OFF
  272. #ifndef RELAY_MQTT_ON
  273. #define RELAY_MQTT_ON "1"
  274. #endif
  275. #ifndef RELAY_MQTT_OFF
  276. #define RELAY_MQTT_OFF "0"
  277. #endif
  278. // -----------------------------------------------------------------------------
  279. // WIFI
  280. // -----------------------------------------------------------------------------
  281. #ifndef WIFI_CONNECT_TIMEOUT
  282. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  283. #endif
  284. #ifndef WIFI_RECONNECT_INTERVAL
  285. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  286. #endif
  287. #ifndef WIFI_MAX_NETWORKS
  288. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  289. #endif
  290. #ifndef WIFI_AP_CAPTIVE
  291. #define WIFI_AP_CAPTIVE 1 // Captive portal enabled when in AP mode
  292. #endif
  293. #ifndef WIFI_FALLBACK_APMODE
  294. #define WIFI_FALLBACK_APMODE 1 // Fallback to AP mode if no STA connection
  295. #endif
  296. #ifndef WIFI_SLEEP_MODE
  297. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  298. #endif
  299. #ifndef WIFI_SCAN_NETWORKS
  300. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  301. #endif
  302. // Optional hardcoded configuration (up to 2 networks)
  303. #ifndef WIFI1_SSID
  304. #define WIFI1_SSID ""
  305. #endif
  306. #ifndef WIFI1_PASS
  307. #define WIFI1_PASS ""
  308. #endif
  309. #ifndef WIFI1_IP
  310. #define WIFI1_IP ""
  311. #endif
  312. #ifndef WIFI1_GW
  313. #define WIFI1_GW ""
  314. #endif
  315. #ifndef WIFI1_MASK
  316. #define WIFI1_MASK ""
  317. #endif
  318. #ifndef WIFI1_DNS
  319. #define WIFI1_DNS ""
  320. #endif
  321. #ifndef WIFI2_SSID
  322. #define WIFI2_SSID ""
  323. #endif
  324. #ifndef WIFI2_PASS
  325. #define WIFI2_PASS ""
  326. #endif
  327. #ifndef WIFI2_IP
  328. #define WIFI2_IP ""
  329. #endif
  330. #ifndef WIFI2_GW
  331. #define WIFI2_GW ""
  332. #endif
  333. #ifndef WIFI2_MASK
  334. #define WIFI2_MASK ""
  335. #endif
  336. #ifndef WIFI2_DNS
  337. #define WIFI2_DNS ""
  338. #endif
  339. #ifndef WIFI_RSSI_1M
  340. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  341. #endif
  342. #ifndef WIFI_PROPAGATION_CONST
  343. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  344. #endif
  345. // -----------------------------------------------------------------------------
  346. // WEB
  347. // -----------------------------------------------------------------------------
  348. #ifndef WEB_SUPPORT
  349. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  350. #endif
  351. #ifndef WEB_EMBEDDED
  352. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  353. #endif
  354. // This is not working at the moment!!
  355. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0
  356. #ifndef WEB_SSL_ENABLED
  357. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  358. #endif
  359. #ifndef WEB_USERNAME
  360. #define WEB_USERNAME "admin" // HTTP username
  361. #endif
  362. #ifndef WEB_FORCE_PASS_CHANGE
  363. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  364. #endif
  365. #ifndef WEB_PORT
  366. #define WEB_PORT 80 // HTTP port
  367. #endif
  368. // Defining a WEB_REMOTE_DOMAIN will enable Cross-Origin Resource Sharing (CORS)
  369. // so you will be able to login to this device from another domain. This will allow
  370. // you to manage all ESPurna devices in your local network from a unique installation
  371. // of the web UI. This installation could be in a local server (a Raspberry Pi, for instance)
  372. // or in the Internet. Since the WebUI is just one compressed file with HTML, CSS and JS
  373. // there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...).
  374. // The only requirement is that the resource must be available under this domain.
  375. #ifndef WEB_REMOTE_DOMAIN
  376. #define WEB_REMOTE_DOMAIN "http://tinkerman.cat"
  377. #endif
  378. // -----------------------------------------------------------------------------
  379. // WEBSOCKETS
  380. // -----------------------------------------------------------------------------
  381. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  382. #ifndef WS_AUTHENTICATION
  383. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  384. #endif
  385. #ifndef WS_BUFFER_SIZE
  386. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  387. #endif
  388. #ifndef WS_TIMEOUT
  389. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  390. #endif
  391. #ifndef WS_UPDATE_INTERVAL
  392. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  393. #endif
  394. // -----------------------------------------------------------------------------
  395. // API
  396. // -----------------------------------------------------------------------------
  397. #ifndef API_SUPPORT
  398. #define API_SUPPORT 1 // API (REST & RPC) support built in
  399. #endif
  400. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  401. #ifndef API_ENABLED
  402. #define API_ENABLED 0 // Do not enable API by default
  403. #endif
  404. #ifndef API_RESTFUL
  405. #define API_RESTFUL 1 // A restful API requires changes to be issued as PUT requests
  406. // Setting this to 0 will allow using GET to change relays, for instance
  407. #endif
  408. #ifndef API_BUFFER_SIZE
  409. #define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses
  410. #endif
  411. #ifndef API_REAL_TIME_VALUES
  412. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  413. #endif
  414. // -----------------------------------------------------------------------------
  415. // MDNS / LLMNR / NETBIOS / SSDP
  416. // -----------------------------------------------------------------------------
  417. #ifndef MDNS_SERVER_SUPPORT
  418. #define MDNS_SERVER_SUPPORT 1 // Publish services using mDNS by default (1.48Kb)
  419. #endif
  420. #ifndef MDNS_CLIENT_SUPPORT
  421. #define MDNS_CLIENT_SUPPORT 0 // Resolve mDNS names (3.44Kb)
  422. #endif
  423. #ifndef LLMNR_SUPPORT
  424. #define LLMNR_SUPPORT 0 // Publish device using LLMNR protocol by default (1.95Kb) - requires 2.4.0
  425. #endif
  426. #ifndef NETBIOS_SUPPORT
  427. #define NETBIOS_SUPPORT 0 // Publish device using NetBIOS protocol by default (1.26Kb) - requires 2.4.0
  428. #endif
  429. #ifndef SSDP_SUPPORT
  430. #define SSDP_SUPPORT 0 // Publish device using SSDP protocol by default (4.59Kb)
  431. // Not compatible with ALEXA_SUPPORT at the moment
  432. #endif
  433. #ifndef SSDP_DEVICE_TYPE
  434. #define SSDP_DEVICE_TYPE "upnp:rootdevice"
  435. //#define SSDP_DEVICE_TYPE "urn:schemas-upnp-org:device:BinaryLight:1"
  436. #endif
  437. // -----------------------------------------------------------------------------
  438. // SPIFFS
  439. // -----------------------------------------------------------------------------
  440. #ifndef SPIFFS_SUPPORT
  441. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  442. #endif
  443. // -----------------------------------------------------------------------------
  444. // OTA
  445. // -----------------------------------------------------------------------------
  446. #ifndef OTA_PORT
  447. #define OTA_PORT 8266 // OTA port
  448. #endif
  449. #ifndef OTA_MQTT_SUPPORT
  450. #define OTA_MQTT_SUPPORT 0 // No support by default
  451. #endif
  452. #define OTA_GITHUB_FP "D7:9F:07:61:10:B3:92:93:E3:49:AC:89:84:5B:03:80:C1:9E:2F:8B"
  453. // -----------------------------------------------------------------------------
  454. // NOFUSS
  455. // -----------------------------------------------------------------------------
  456. #ifndef NOFUSS_SUPPORT
  457. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  458. #endif
  459. #ifndef NOFUSS_ENABLED
  460. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  461. #endif
  462. #ifndef NOFUSS_SERVER
  463. #define NOFUSS_SERVER "" // Default NoFuss Server
  464. #endif
  465. #ifndef NOFUSS_INTERVAL
  466. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  467. #endif
  468. // -----------------------------------------------------------------------------
  469. // UART <-> MQTT
  470. // -----------------------------------------------------------------------------
  471. #ifndef UART_MQTT_SUPPORT
  472. #define UART_MQTT_SUPPORT 0 // No support by default
  473. #endif
  474. #ifndef UART_MQTT_USE_SOFT
  475. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  476. #endif
  477. #ifndef UART_MQTT_HW_PORT
  478. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  479. #endif
  480. #ifndef UART_MQTT_RX_PIN
  481. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  482. #endif
  483. #ifndef UART_MQTT_TX_PIN
  484. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  485. #endif
  486. #ifndef UART_MQTT_BAUDRATE
  487. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  488. #endif
  489. #ifndef UART_MQTT_TERMINATION
  490. #define UART_MQTT_TERMINATION '\n' // Termination character
  491. #endif
  492. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  493. // -----------------------------------------------------------------------------
  494. // MQTT
  495. // -----------------------------------------------------------------------------
  496. #ifndef MQTT_SUPPORT
  497. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  498. #endif
  499. #ifndef MQTT_USE_ASYNC
  500. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  501. #endif
  502. // MQTT OVER SSL
  503. // Using MQTT over SSL works pretty well but generates problems with the web interface.
  504. // It could be a good idea to use it in conjuntion with WEB_SUPPORT=0.
  505. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  506. //
  507. // You can use SSL with MQTT_USE_ASYNC=1 (AsyncMqttClient library)
  508. // but you might experience hiccups on the web interface, so my recommendation is:
  509. // WEB_SUPPORT=0
  510. //
  511. // If you use SSL with MQTT_USE_ASYNC=0 (PubSubClient library)
  512. // you will have to disable all the modules that use ESPAsyncTCP, that is:
  513. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0 and WEB_SUPPORT=0
  514. //
  515. // You will need the fingerprint for your MQTT server, example for CloudMQTT:
  516. // $ echo -n | openssl s_client -connect m11.cloudmqtt.com:24055 > cloudmqtt.pem
  517. // $ openssl x509 -noout -in cloudmqtt.pem -fingerprint -sha1
  518. #ifndef MQTT_SSL_ENABLED
  519. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  520. #endif
  521. #ifndef MQTT_SSL_FINGERPRINT
  522. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  523. #endif
  524. #ifndef MQTT_ENABLED
  525. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  526. #endif
  527. #ifndef MQTT_AUTOCONNECT
  528. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  529. // autoconnect to the first MQTT broker found if none defined
  530. #endif
  531. #ifndef MQTT_SERVER
  532. #define MQTT_SERVER "" // Default MQTT broker address
  533. #endif
  534. #ifndef MQTT_USER
  535. #define MQTT_USER "" // Default MQTT broker usename
  536. #endif
  537. #ifndef MQTT_PASS
  538. #define MQTT_PASS "" // Default MQTT broker password
  539. #endif
  540. #ifndef MQTT_PORT
  541. #define MQTT_PORT 1883 // MQTT broker port
  542. #endif
  543. #ifndef MQTT_TOPIC
  544. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  545. #endif
  546. #ifndef MQTT_RETAIN
  547. #define MQTT_RETAIN true // MQTT retain flag
  548. #endif
  549. #ifndef MQTT_QOS
  550. #define MQTT_QOS 0 // MQTT QoS value for all messages
  551. #endif
  552. #ifndef MQTT_KEEPALIVE
  553. #define MQTT_KEEPALIVE 300 // MQTT keepalive value
  554. #endif
  555. #ifndef MQTT_RECONNECT_DELAY_MIN
  556. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  557. #endif
  558. #ifndef MQTT_RECONNECT_DELAY_STEP
  559. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  560. #endif
  561. #ifndef MQTT_RECONNECT_DELAY_MAX
  562. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  563. #endif
  564. #ifndef MQTT_SKIP_RETAINED
  565. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  566. #endif
  567. #ifndef MQTT_SKIP_TIME
  568. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  569. #endif
  570. #ifndef MQTT_USE_JSON
  571. #define MQTT_USE_JSON 0 // Group messages in a JSON body
  572. #endif
  573. #ifndef MQTT_USE_JSON_DELAY
  574. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  575. #endif
  576. #ifndef MQTT_QUEUE_MAX_SIZE
  577. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  578. #endif
  579. // These are the properties that will be sent when useJson is true
  580. #ifndef MQTT_ENQUEUE_IP
  581. #define MQTT_ENQUEUE_IP 1
  582. #endif
  583. #ifndef MQTT_ENQUEUE_MAC
  584. #define MQTT_ENQUEUE_MAC 1
  585. #endif
  586. #ifndef MQTT_ENQUEUE_HOSTNAME
  587. #define MQTT_ENQUEUE_HOSTNAME 1
  588. #endif
  589. #ifndef MQTT_ENQUEUE_DATETIME
  590. #define MQTT_ENQUEUE_DATETIME 1
  591. #endif
  592. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  593. #define MQTT_ENQUEUE_MESSAGE_ID 1
  594. #endif
  595. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  596. #define MQTT_TOPIC_JSON "data"
  597. #define MQTT_TOPIC_ACTION "action"
  598. #define MQTT_TOPIC_RELAY "relay"
  599. #define MQTT_TOPIC_LED "led"
  600. #define MQTT_TOPIC_BUTTON "button"
  601. #define MQTT_TOPIC_IP "ip"
  602. #define MQTT_TOPIC_SSID "ssid"
  603. #define MQTT_TOPIC_VERSION "version"
  604. #define MQTT_TOPIC_UPTIME "uptime"
  605. #define MQTT_TOPIC_DATETIME "datetime"
  606. #define MQTT_TOPIC_FREEHEAP "freeheap"
  607. #define MQTT_TOPIC_VCC "vcc"
  608. #define MQTT_TOPIC_STATUS "status"
  609. #define MQTT_TOPIC_MAC "mac"
  610. #define MQTT_TOPIC_RSSI "rssi"
  611. #define MQTT_TOPIC_MESSAGE_ID "id"
  612. #define MQTT_TOPIC_APP "app"
  613. #define MQTT_TOPIC_INTERVAL "interval"
  614. #define MQTT_TOPIC_HOSTNAME "host"
  615. #define MQTT_TOPIC_DESCRIPTION "desc"
  616. #define MQTT_TOPIC_TIME "time"
  617. #define MQTT_TOPIC_RFOUT "rfout"
  618. #define MQTT_TOPIC_RFIN "rfin"
  619. #define MQTT_TOPIC_RFLEARN "rflearn"
  620. #define MQTT_TOPIC_RFRAW "rfraw"
  621. #define MQTT_TOPIC_UARTIN "uartin"
  622. #define MQTT_TOPIC_UARTOUT "uartout"
  623. #define MQTT_TOPIC_LOADAVG "loadavg"
  624. #define MQTT_TOPIC_BOARD "board"
  625. #define MQTT_TOPIC_PULSE "pulse"
  626. #define MQTT_TOPIC_SPEED "speed"
  627. #define MQTT_TOPIC_IRIN "irin"
  628. #define MQTT_TOPIC_IROUT "irout"
  629. #define MQTT_TOPIC_OTA "ota"
  630. // Light module
  631. #define MQTT_TOPIC_CHANNEL "channel"
  632. #define MQTT_TOPIC_COLOR_RGB "rgb"
  633. #define MQTT_TOPIC_COLOR_HSV "hsv"
  634. #define MQTT_TOPIC_ANIM_MODE "anim_mode"
  635. #define MQTT_TOPIC_ANIM_SPEED "anim_speed"
  636. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  637. #define MQTT_TOPIC_MIRED "mired"
  638. #define MQTT_TOPIC_KELVIN "kelvin"
  639. #define MQTT_TOPIC_TRANSITION "transition"
  640. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  641. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  642. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  643. #define MQTT_MESSAGE_ID_SHIFT 1000 // Store MQTT message id into EEPROM every these many
  644. // Custom get and set postfixes
  645. // Use something like "/status" or "/set", with leading slash
  646. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  647. #ifndef MQTT_GETTER
  648. #define MQTT_GETTER ""
  649. #endif
  650. #ifndef MQTT_SETTER
  651. #define MQTT_SETTER "/set"
  652. #endif
  653. // -----------------------------------------------------------------------------
  654. // BROKER
  655. // -----------------------------------------------------------------------------
  656. #ifndef BROKER_SUPPORT
  657. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  658. #endif
  659. // -----------------------------------------------------------------------------
  660. // SETTINGS
  661. // -----------------------------------------------------------------------------
  662. #ifndef SETTINGS_AUTOSAVE
  663. #define SETTINGS_AUTOSAVE 1 // Autosave settings or force manual commit
  664. #endif
  665. #define SETTINGS_MAX_LIST_COUNT 10 // Maximum index for settings lists
  666. // -----------------------------------------------------------------------------
  667. // LIGHT
  668. // -----------------------------------------------------------------------------
  669. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  670. // They have to be defined for each device in the hardware.h file.
  671. // If 3 or more channels first 3 will be considered RGB.
  672. // Usual configurations are:
  673. // 1 channels => W
  674. // 2 channels => WW
  675. // 3 channels => RGB
  676. // 4 channels => RGBW
  677. // 5 channels => RGBWW
  678. #ifndef LIGHT_SAVE_ENABLED
  679. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  680. #endif
  681. #ifndef LIGHT_COMMS_DELAY
  682. #define LIGHT_COMMS_DELAY 100 // Delay communication after light update (in ms)
  683. #endif
  684. #ifndef LIGHT_SAVE_DELAY
  685. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  686. #endif
  687. #ifndef LIGHT_MAX_PWM
  688. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  689. #define LIGHT_MAX_PWM 255
  690. #endif
  691. #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  692. #define LIGHT_MAX_PWM 10000 // 10000 * 200ns => 2 kHz
  693. #endif
  694. #endif // LIGHT_MAX_PWM
  695. #ifndef LIGHT_LIMIT_PWM
  696. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  697. #endif
  698. #ifndef LIGHT_MAX_VALUE
  699. #define LIGHT_MAX_VALUE 255 // Maximum light value
  700. #endif
  701. #ifndef LIGHT_MAX_BRIGHTNESS
  702. #define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
  703. #endif
  704. #define LIGHT_MIN_MIREDS 153 // Default to the Philips Hue value that HA also use.
  705. #define LIGHT_MAX_MIREDS 500 // https://developers.meethue.com/documentation/core-concepts
  706. #ifndef LIGHT_STEP
  707. #define LIGHT_STEP 32 // Step size
  708. #endif
  709. #ifndef LIGHT_USE_COLOR
  710. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  711. #endif
  712. #ifndef LIGHT_USE_WHITE
  713. #define LIGHT_USE_WHITE 0 // Use the 4th channel as (Warm-)White LEDs
  714. #endif
  715. #ifndef LIGHT_USE_CCT
  716. #define LIGHT_USE_CCT 0 // Use the 5th channel as Coldwhite LEDs, LIGHT_USE_WHITE must be 1.
  717. #endif
  718. // Used when LIGHT_USE_WHITE AND LIGHT_USE_CCT is 1 - (1000000/Kelvin = MiReds)
  719. // Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
  720. #define LIGHT_COLDWHITE_MIRED 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
  721. #define LIGHT_WARMWHITE_MIRED 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
  722. #ifndef LIGHT_USE_GAMMA
  723. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  724. #endif
  725. #ifndef LIGHT_USE_CSS
  726. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  727. #endif
  728. #ifndef LIGHT_USE_RGB
  729. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  730. #endif
  731. #ifndef LIGHT_WHITE_FACTOR
  732. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  733. // this factor is used to scale the white channel to match brightness
  734. #endif
  735. #ifndef LIGHT_USE_TRANSITIONS
  736. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  737. #endif
  738. #ifndef LIGHT_TRANSITION_STEP
  739. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  740. #endif
  741. #ifndef LIGHT_TRANSITION_TIME
  742. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  743. #endif
  744. // -----------------------------------------------------------------------------
  745. // DOMOTICZ
  746. // -----------------------------------------------------------------------------
  747. #ifndef DOMOTICZ_SUPPORT
  748. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  749. #endif
  750. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  751. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  752. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  753. // -----------------------------------------------------------------------------
  754. // HOME ASSISTANT
  755. // -----------------------------------------------------------------------------
  756. #ifndef HOMEASSISTANT_SUPPORT
  757. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  758. #endif
  759. #ifndef HOMEASSISTANT_ENABLED
  760. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  761. #endif
  762. #ifndef HOMEASSISTANT_PREFIX
  763. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  764. #endif
  765. #ifndef HOMEASSISTANT_PAYLOAD_ON
  766. #define HOMEASSISTANT_PAYLOAD_ON "1" // Payload for ON and available messages
  767. #endif
  768. #ifndef HOMEASSISTANT_PAYLOAD_OFF
  769. #define HOMEASSISTANT_PAYLOAD_OFF "0" // Payload for OFF and unavailable messages
  770. #endif
  771. #ifndef HOMEASSISTANT_PAYLOAD_AVAILABLE
  772. #define HOMEASSISTANT_PAYLOAD_AVAILABLE "1" // Payload for available messages
  773. #endif
  774. #ifndef HOMEASSISTANT_PAYLOAD_NOT_AVAILABLE
  775. #define HOMEASSISTANT_PAYLOAD_NOT_AVAILABLE "0" // Payload for available messages
  776. #endif
  777. // -----------------------------------------------------------------------------
  778. // INFLUXDB
  779. // -----------------------------------------------------------------------------
  780. #ifndef INFLUXDB_SUPPORT
  781. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  782. #endif
  783. #ifndef INFLUXDB_ENABLED
  784. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  785. #endif
  786. #ifndef INFLUXDB_HOST
  787. #define INFLUXDB_HOST "" // Default server
  788. #endif
  789. #ifndef INFLUXDB_PORT
  790. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  791. #endif
  792. #ifndef INFLUXDB_DATABASE
  793. #define INFLUXDB_DATABASE "" // Default database
  794. #endif
  795. #ifndef INFLUXDB_USERNAME
  796. #define INFLUXDB_USERNAME "" // Default username
  797. #endif
  798. #ifndef INFLUXDB_PASSWORD
  799. #define INFLUXDB_PASSWORD "" // Default password
  800. #endif
  801. // -----------------------------------------------------------------------------
  802. // THINGSPEAK
  803. // -----------------------------------------------------------------------------
  804. #ifndef THINGSPEAK_SUPPORT
  805. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  806. #endif
  807. #ifndef THINGSPEAK_ENABLED
  808. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  809. #endif
  810. #ifndef THINGSPEAK_APIKEY
  811. #define THINGSPEAK_APIKEY "" // Default API KEY
  812. #endif
  813. #ifndef THINGSPEAK_CLEAR_CACHE
  814. #define THINGSPEAK_CLEAR_CACHE 1 // Clear cache after sending values
  815. // Not clearing it will result in latest values for each field being sent every time
  816. #endif
  817. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  818. // THINGSPEAK OVER SSL
  819. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  820. // so you should compile it with WEB_SUPPORT to 0.
  821. // When THINGSPEAK_USE_ASYNC is 1, requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  822. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  823. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  824. #define THINGSPEAK_HOST "api.thingspeak.com"
  825. #if THINGSPEAK_USE_SSL
  826. #define THINGSPEAK_PORT 443
  827. #else
  828. #define THINGSPEAK_PORT 80
  829. #endif
  830. #define THINGSPEAK_URL "/update"
  831. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  832. #define THINGSPEAK_FIELDS 8 // Number of fields
  833. #ifndef THINGSPEAK_TRIES
  834. #define THINGSPEAK_TRIES 3 // Number of tries when sending data (minimum 1)
  835. #endif
  836. // -----------------------------------------------------------------------------
  837. // SCHEDULER
  838. // -----------------------------------------------------------------------------
  839. #ifndef SCHEDULER_SUPPORT
  840. #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
  841. #endif
  842. #ifndef SCHEDULER_MAX_SCHEDULES
  843. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  844. #endif
  845. // -----------------------------------------------------------------------------
  846. // NTP
  847. // -----------------------------------------------------------------------------
  848. #ifndef NTP_SUPPORT
  849. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  850. #endif
  851. #ifndef NTP_SERVER
  852. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  853. #endif
  854. #ifndef NTP_TIMEOUT
  855. #define NTP_TIMEOUT 1000 // Set NTP request timeout to 2 seconds (issue #452)
  856. #endif
  857. #ifndef NTP_TIME_OFFSET
  858. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  859. #endif
  860. #ifndef NTP_DAY_LIGHT
  861. #define NTP_DAY_LIGHT 1 // Enable daylight time saving by default
  862. #endif
  863. #ifndef NTP_SYNC_INTERVAL
  864. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  865. #endif
  866. #ifndef NTP_UPDATE_INTERVAL
  867. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  868. #endif
  869. #ifndef NTP_START_DELAY
  870. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  871. #endif
  872. #ifndef NTP_DST_REGION
  873. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  874. #endif
  875. #ifndef NTP_WAIT_FOR_SYNC
  876. #define NTP_WAIT_FOR_SYNC 1 // Do not report any datetime until NTP sync'ed
  877. #endif
  878. // -----------------------------------------------------------------------------
  879. // ALEXA
  880. // -----------------------------------------------------------------------------
  881. // This setting defines whether Alexa support should be built into the firmware
  882. #ifndef ALEXA_SUPPORT
  883. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  884. #endif
  885. // This is default value for the alexaEnabled setting that defines whether
  886. // this device should be discoberable and respond to Alexa commands.
  887. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  888. #ifndef ALEXA_ENABLED
  889. #define ALEXA_ENABLED 1
  890. #endif
  891. // -----------------------------------------------------------------------------
  892. // RFBRIDGE
  893. // This module is not compatible with RF_SUPPORT=1
  894. // -----------------------------------------------------------------------------
  895. #ifndef RF_SEND_TIMES
  896. #define RF_SEND_TIMES 4 // How many times to send the message
  897. #endif
  898. #ifndef RF_SEND_DELAY
  899. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  900. #endif
  901. #ifndef RF_RECEIVE_DELAY
  902. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  903. #endif
  904. #ifndef RF_RAW_SUPPORT
  905. #define RF_RAW_SUPPORT 0 // RF raw codes require a specific firmware for the EFM8BB1
  906. // https://github.com/rhx/RF-Bridge-EFM8BB1
  907. #endif
  908. // -----------------------------------------------------------------------------
  909. // IR Bridge
  910. // -----------------------------------------------------------------------------
  911. #ifndef IR_SUPPORT
  912. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  913. #endif
  914. //#define IR_RX_PIN 5 // GPIO the receiver is connected to
  915. //#define IR_TX_PIN 4 // GPIO the transmitter is connected to
  916. #ifndef IR_USE_RAW
  917. #define IR_USE_RAW 0 // Use raw codes
  918. #endif
  919. #ifndef IR_BUFFER_SIZE
  920. #define IR_BUFFER_SIZE 1024
  921. #endif
  922. #ifndef IR_TIMEOUT
  923. #define IR_TIMEOUT 15U
  924. #endif
  925. #ifndef IR_REPEAT
  926. #define IR_REPEAT 1
  927. #endif
  928. #ifndef IR_DELAY
  929. #define IR_DELAY 100
  930. #endif
  931. #ifndef IR_DEBOUNCE
  932. #define IR_DEBOUNCE 500 // IR debounce time in milliseconds
  933. #endif
  934. #ifndef IR_BUTTON_SET
  935. #define IR_BUTTON_SET 0 // IR button set to use (see below)
  936. #endif
  937. // -----------------------------------------------------------------------------
  938. // Remote Buttons SET 1 (for the original Remote shipped with the controller)
  939. #if IR_BUTTON_SET == 1
  940. /*
  941. +------+------+------+------+
  942. | UP | Down | OFF | ON |
  943. +------+------+------+------+
  944. | R | G | B | W |
  945. +------+------+------+------+
  946. | 1 | 2 | 3 |FLASH |
  947. +------+------+------+------+
  948. | 4 | 5 | 6 |STROBE|
  949. +------+------+------+------+
  950. | 7 | 8 | 9 | FADE |
  951. +------+------+------+------+
  952. | 10 | 11 | 12 |SMOOTH|
  953. +------+------+------+------+
  954. */
  955. #define IR_BUTTON_COUNT 24
  956. const uint32_t IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  957. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  958. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  959. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  960. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  961. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  962. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  963. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  964. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  965. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  966. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  967. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  968. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  969. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  970. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  971. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  972. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  973. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  974. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  975. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  976. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  977. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  978. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  979. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  980. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  981. };
  982. #endif
  983. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  984. #if IR_BUTTON_SET == 2
  985. /*
  986. +------+------+------+------+
  987. | UP | Down | OFF | ON |
  988. +------+------+------+------+
  989. | R | G | B | W |
  990. +------+------+------+------+
  991. | 1 | 2 | 3 |FLASH |
  992. +------+------+------+------+
  993. | 4 | 5 | 6 |STROBE|
  994. +------+------+------+------+
  995. | 7 | 8 | 9 | FADE |
  996. +------+------+------+------+
  997. | 10 | 11 | 12 |SMOOTH|
  998. +------+------+------+------+
  999. */
  1000. #define IR_BUTTON_COUNT 24
  1001. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1002. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  1003. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  1004. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  1005. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  1006. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  1007. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  1008. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  1009. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  1010. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  1011. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  1012. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  1013. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  1014. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  1015. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  1016. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  1017. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1018. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1019. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  1020. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  1021. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1022. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1023. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1024. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1025. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1026. };
  1027. #endif
  1028. //Remote Buttons SET 3 (samsung AA59-00608A 8 Toggle Buttons for generic 8CH module)
  1029. #if IR_BUTTON_SET == 3
  1030. /*
  1031. +------+------+------+
  1032. | 1 | 2 | 3 |
  1033. +------+------+------+
  1034. | 4 | 5 | 6 |
  1035. +------+------+------+
  1036. | 7 | 8 | 9 |
  1037. +------+------+------+
  1038. | | 0 | |
  1039. +------+------+------+
  1040. */
  1041. #define IR_BUTTON_COUNT 10
  1042. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1043. { 0xE0E020DF, IR_BUTTON_MODE_TOGGLE, 0 }, // Toggle Relay #0
  1044. { 0xE0E0A05F, IR_BUTTON_MODE_TOGGLE, 1 }, // Toggle Relay #1
  1045. { 0xE0E0609F, IR_BUTTON_MODE_TOGGLE, 2 }, // Toggle Relay #2
  1046. { 0xE0E010EF, IR_BUTTON_MODE_TOGGLE, 3 }, // Toggle Relay #3
  1047. { 0xE0E0906F, IR_BUTTON_MODE_TOGGLE, 4 }, // Toggle Relay #4
  1048. { 0xE0E050AF, IR_BUTTON_MODE_TOGGLE, 5 }, // Toggle Relay #5
  1049. { 0xE0E030CF, IR_BUTTON_MODE_TOGGLE, 6 }, // Toggle Relay #6
  1050. { 0xE0E0B04F, IR_BUTTON_MODE_TOGGLE, 7 } // Toggle Relay #7
  1051. //{ 0xE0E0708F, IR_BUTTON_MODE_TOGGLE, 8 } //Extra Button
  1052. //{ 0xE0E08877, IR_BUTTON_MODE_TOGGLE, 9 } //Extra Button
  1053. };
  1054. #endif
  1055. //Remote Buttons SET 4
  1056. #if IR_BUTTON_SET == 4
  1057. /*
  1058. +------+------+------+
  1059. | OFF | SRC | MUTE |
  1060. +------+------+------+
  1061. ...
  1062. +------+------+------+
  1063. */
  1064. #define IR_BUTTON_COUNT 1
  1065. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  1066. { 0xFFB24D, IR_BUTTON_MODE_TOGGLE, 0 } // Toggle Relay #0
  1067. };
  1068. #endif
  1069. #ifndef IR_BUTTON_COUNT
  1070. #define IR_BUTTON_COUNT 0
  1071. #endif
  1072. //--------------------------------------------------------------------------------
  1073. // Custom RF module
  1074. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  1075. // Enable support by passing RF_SUPPORT=1 build flag
  1076. // This module is not compatible with RFBRIDGE or SONOFF RF
  1077. //--------------------------------------------------------------------------------
  1078. #ifndef RF_SUPPORT
  1079. #define RF_SUPPORT 0
  1080. #endif
  1081. #ifndef RF_PIN
  1082. #define RF_PIN 14
  1083. #endif
  1084. #ifndef RF_DEBOUNCE
  1085. #define RF_DEBOUNCE 500
  1086. #endif
  1087. #ifndef RF_LEARN_TIMEOUT
  1088. #define RF_LEARN_TIMEOUT 60000
  1089. #endif
  1090. //--------------------------------------------------------------------------------
  1091. // Custom RFM69 to MQTT bridge
  1092. // Check http://tinkerman.cat/rfm69-wifi-gateway/
  1093. // Enable support by passing RFM69_SUPPORT=1 build flag
  1094. //--------------------------------------------------------------------------------
  1095. #ifndef RFM69_SUPPORT
  1096. #define RFM69_SUPPORT 0
  1097. #endif
  1098. #ifndef RFM69_MAX_TOPICS
  1099. #define RFM69_MAX_TOPICS 50
  1100. #endif
  1101. #ifndef RFM69_MAX_NODES
  1102. #define RFM69_MAX_NODES 255
  1103. #endif
  1104. #ifndef RFM69_DEFAULT_TOPIC
  1105. #define RFM69_DEFAULT_TOPIC "/rfm69gw/{node}/{key}"
  1106. #endif
  1107. #ifndef RFM69_NODE_ID
  1108. #define RFM69_NODE_ID 1
  1109. #endif
  1110. #ifndef RFM69_GATEWAY_ID
  1111. #define RFM69_GATEWAY_ID 1
  1112. #endif
  1113. #ifndef RFM69_NETWORK_ID
  1114. #define RFM69_NETWORK_ID 164
  1115. #endif
  1116. #ifndef RFM69_PROMISCUOUS
  1117. #define RFM69_PROMISCUOUS 0
  1118. #endif
  1119. #ifndef RFM69_PROMISCUOUS_SENDS
  1120. #define RFM69_PROMISCUOUS_SENDS 0
  1121. #endif
  1122. #ifndef RFM69_FREQUENCY
  1123. #define RFM69_FREQUENCY RF69_868MHZ
  1124. #endif
  1125. #ifndef RFM69_ENCRYPTKEY
  1126. #define RFM69_ENCRYPTKEY "fibonacci0123456"
  1127. #endif
  1128. #ifndef RFM69_CS_PIN
  1129. #define RFM69_CS_PIN SS
  1130. #endif
  1131. #ifndef RFM69_IRQ_PIN
  1132. #define RFM69_IRQ_PIN 5
  1133. #endif
  1134. #ifndef RFM69_RESET_PIN
  1135. #define RFM69_RESET_PIN 7
  1136. #endif
  1137. #ifndef RFM69_IS_RFM69HW
  1138. #define RFM69_IS_RFM69HW 0
  1139. #endif