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.

1326 lines
44 KiB

7 years ago
7 years ago
7 years ago
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
8 years ago
8 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
8 years ago
6 years ago
6 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. #ifndef ADMIN_PASS
  10. #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI)
  11. #endif
  12. #ifndef USE_PASSWORD
  13. #define USE_PASSWORD 1 // Insecurity caution! Disabling this will disable password querying completely.
  14. #endif
  15. #ifndef LOOP_DELAY_TIME
  16. #define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250]
  17. #endif
  18. #define ARRAYINIT(type, name, ...) \
  19. type name[] = {__VA_ARGS__};
  20. //------------------------------------------------------------------------------
  21. // TELNET
  22. //------------------------------------------------------------------------------
  23. #ifndef TELNET_SUPPORT
  24. #define TELNET_SUPPORT 1 // Enable telnet support by default (3.34Kb)
  25. #endif
  26. #ifndef TELNET_STA
  27. #define TELNET_STA 0 // By default, disallow connections via STA interface
  28. #endif
  29. #define TELNET_PORT 23 // Port to listen to telnet clients
  30. #define TELNET_MAX_CLIENTS 1 // Max number of concurrent telnet clients
  31. //------------------------------------------------------------------------------
  32. // DEBUG
  33. //------------------------------------------------------------------------------
  34. // Serial debug log
  35. #ifndef DEBUG_SERIAL_SUPPORT
  36. #define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log
  37. #endif
  38. #ifndef DEBUG_PORT
  39. #define DEBUG_PORT Serial // Default debugging port
  40. #endif
  41. #ifndef SERIAL_BAUDRATE
  42. #define SERIAL_BAUDRATE 115200 // Default baudrate
  43. #endif
  44. #ifndef DEBUG_ADD_TIMESTAMP
  45. #define DEBUG_ADD_TIMESTAMP 1 // Add timestamp to debug messages
  46. // (in millis overflowing every 1000 seconds)
  47. #endif
  48. // Second serial port (used for RX)
  49. #ifndef SERIAL_RX_ENABLED
  50. #define SERIAL_RX_ENABLED 0 // Secondary serial port for RX
  51. #endif
  52. #ifndef SERIAL_RX_PORT
  53. #define SERIAL_RX_PORT Serial // This setting is usually defined
  54. // in the hardware.h file for those
  55. // boards that require it
  56. #endif
  57. #ifndef SERIAL_RX_BAUDRATE
  58. #define SERIAL_RX_BAUDRATE 115200 // Default baudrate
  59. #endif
  60. //------------------------------------------------------------------------------
  61. // UDP debug log
  62. // To receive the message son the destination computer use nc:
  63. // nc -ul 8113
  64. #ifndef DEBUG_UDP_SUPPORT
  65. #define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log
  66. #endif
  67. #ifndef DEBUG_UDP_IP
  68. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  69. #endif
  70. #ifndef DEBUG_UDP_PORT
  71. #define DEBUG_UDP_PORT 8113
  72. #endif
  73. //------------------------------------------------------------------------------
  74. #ifndef DEBUG_TELNET_SUPPORT
  75. #define DEBUG_TELNET_SUPPORT TELNET_SUPPORT // Enable telnet debug log if telnet is enabled too
  76. #endif
  77. #if DEBUG_TELNET_SUPPORT
  78. #undef TELNET_SUPPORT
  79. #define TELNET_SUPPORT 1
  80. #endif
  81. //------------------------------------------------------------------------------
  82. #ifndef DEBUG_WEB_SUPPORT
  83. #define DEBUG_WEB_SUPPORT WEB_SUPPORT // Enable web debug log if web is enabled too
  84. #endif
  85. #if DEBUG_WEB_SUPPORT
  86. #undef WEB_SUPPORT
  87. #define WEB_SUPPORT 1 // Chicken and egg :)
  88. #endif
  89. #ifndef DEBUG_WEB_ENABLED
  90. #define DEBUG_WEB_ENABLED 1 // Enable debug output by default
  91. #endif
  92. //------------------------------------------------------------------------------
  93. // General debug options and macros
  94. #define DEBUG_SUPPORT DEBUG_SERIAL_SUPPORT || DEBUG_UDP_SUPPORT || DEBUG_TELNET_SUPPORT
  95. #if DEBUG_SUPPORT
  96. #define DEBUG_MSG(...) debugSend(__VA_ARGS__)
  97. #define DEBUG_MSG_P(...) debugSend_P(__VA_ARGS__)
  98. #endif
  99. #ifndef DEBUG_MSG
  100. #define DEBUG_MSG(...)
  101. #define DEBUG_MSG_P(...)
  102. #endif
  103. //------------------------------------------------------------------------------
  104. // TERMINAL
  105. //------------------------------------------------------------------------------
  106. #ifndef TERMINAL_SUPPORT
  107. #define TERMINAL_SUPPORT 1 // Enable terminal commands (0.97Kb)
  108. #endif
  109. #define TERMINAL_BUFFER_SIZE 128 // Max size for commands commands
  110. //------------------------------------------------------------------------------
  111. // SYSTEM CHECK
  112. //------------------------------------------------------------------------------
  113. #ifndef SYSTEM_CHECK_ENABLED
  114. #define SYSTEM_CHECK_ENABLED 1 // Enable crash check by default
  115. #endif
  116. #define SYSTEM_CHECK_TIME 60000 // The system is considered stable after these many millis
  117. #ifndef SYSTEM_CHECK_MAX
  118. #define SYSTEM_CHECK_MAX 5 // After this many crashes on boot
  119. // the system is flagged as unstable
  120. #endif
  121. //------------------------------------------------------------------------------
  122. // EEPROM
  123. //------------------------------------------------------------------------------
  124. #define EEPROM_SIZE 4096 // EEPROM size in bytes
  125. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  126. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  127. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  128. #define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte)
  129. #define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes)
  130. #define EEPROM_DATA_END 11 // End of custom EEPROM data block
  131. //------------------------------------------------------------------------------
  132. // HEARTBEAT
  133. //------------------------------------------------------------------------------
  134. #ifndef HEARTBEAT_ENABLED
  135. #define HEARTBEAT_ENABLED 1
  136. #endif
  137. #define HEARTBEAT_INTERVAL 300000 // Interval between heartbeat messages (in ms)
  138. #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
  139. // Topics that will be reported in heartbeat
  140. #define HEARTBEAT_REPORT_STATUS 1
  141. #define HEARTBEAT_REPORT_IP 1
  142. #define HEARTBEAT_REPORT_MAC 1
  143. #define HEARTBEAT_REPORT_RSSI 1
  144. #define HEARTBEAT_REPORT_UPTIME 1
  145. #define HEARTBEAT_REPORT_DATETIME 1
  146. #define HEARTBEAT_REPORT_FREEHEAP 1
  147. #define HEARTBEAT_REPORT_VCC 1
  148. #define HEARTBEAT_REPORT_RELAY 1
  149. #define HEARTBEAT_REPORT_LIGHT 1
  150. #define HEARTBEAT_REPORT_HOSTNAME 1
  151. #define HEARTBEAT_REPORT_APP 1
  152. #define HEARTBEAT_REPORT_VERSION 1
  153. #define HEARTBEAT_REPORT_BOARD 1
  154. #define HEARTBEAT_REPORT_INTERVAL 0
  155. //------------------------------------------------------------------------------
  156. // Load average
  157. //------------------------------------------------------------------------------
  158. #ifndef LOADAVG_INTERVAL
  159. #define LOADAVG_INTERVAL 30000 // Interval between calculating load average (in ms)
  160. #endif
  161. #ifndef LOADAVG_REPORT
  162. #define LOADAVG_REPORT 1 // Should we report Load average over MQTT?
  163. #endif
  164. //------------------------------------------------------------------------------
  165. // RESET
  166. //------------------------------------------------------------------------------
  167. #define CUSTOM_RESET_HARDWARE 1 // Reset from hardware button
  168. #define CUSTOM_RESET_WEB 2 // Reset from web interface
  169. #define CUSTOM_RESET_TERMINAL 3 // Reset from terminal
  170. #define CUSTOM_RESET_MQTT 4 // Reset via MQTT
  171. #define CUSTOM_RESET_RPC 5 // Reset via RPC (HTTP)
  172. #define CUSTOM_RESET_OTA 6 // Reset after successful OTA update
  173. #define CUSTOM_RESET_HTTP 7 // Reset via HTTP GET
  174. #define CUSTOM_RESET_NOFUSS 8 // Reset after successful NOFUSS update
  175. #define CUSTOM_RESET_UPGRADE 9 // Reset after update from web interface
  176. #define CUSTOM_RESET_FACTORY 10 // Factory reset from terminal
  177. #define CUSTOM_RESET_MAX 10
  178. PROGMEM const char custom_reset_hardware[] = "Hardware button";
  179. PROGMEM const char custom_reset_web[] = "Reboot from web interface";
  180. PROGMEM const char custom_reset_terminal[] = "Reboot from terminal";
  181. PROGMEM const char custom_reset_mqtt[] = "Reboot from MQTT";
  182. PROGMEM const char custom_reset_rpc[] = "Reboot from RPC";
  183. PROGMEM const char custom_reset_ota[] = "Reboot after successful OTA update";
  184. PROGMEM const char custom_reset_http[] = "Reboot from HTTP";
  185. PROGMEM const char custom_reset_nofuss[] = "Reboot after successful NoFUSS update";
  186. PROGMEM const char custom_reset_upgrade[] = "Reboot after successful web update";
  187. PROGMEM const char custom_reset_factory[] = "Factory reset";
  188. PROGMEM const char* const custom_reset_string[] = {
  189. custom_reset_hardware, custom_reset_web, custom_reset_terminal,
  190. custom_reset_mqtt, custom_reset_rpc, custom_reset_ota,
  191. custom_reset_http, custom_reset_nofuss, custom_reset_upgrade,
  192. custom_reset_factory
  193. };
  194. //------------------------------------------------------------------------------
  195. // BUTTON
  196. //------------------------------------------------------------------------------
  197. #ifndef BUTTON_DEBOUNCE_DELAY
  198. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  199. #endif
  200. #ifndef BUTTON_DBLCLICK_DELAY
  201. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  202. #endif
  203. #ifndef BUTTON_LNGCLICK_DELAY
  204. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  205. #endif
  206. #ifndef BUTTON_LNGLNGCLICK_DELAY
  207. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  208. #endif
  209. #define BUTTON_EVENT_NONE 0
  210. #define BUTTON_EVENT_PRESSED 1
  211. #define BUTTON_EVENT_RELEASED 2
  212. #define BUTTON_EVENT_CLICK 2
  213. #define BUTTON_EVENT_DBLCLICK 3
  214. #define BUTTON_EVENT_LNGCLICK 4
  215. #define BUTTON_EVENT_LNGLNGCLICK 5
  216. #define BUTTON_MODE_NONE 0
  217. #define BUTTON_MODE_TOGGLE 1
  218. #define BUTTON_MODE_ON 2
  219. #define BUTTON_MODE_OFF 3
  220. #define BUTTON_MODE_AP 4
  221. #define BUTTON_MODE_RESET 5
  222. #define BUTTON_MODE_PULSE 6
  223. #define BUTTON_MODE_FACTORY 7
  224. //------------------------------------------------------------------------------
  225. // RELAY
  226. //------------------------------------------------------------------------------
  227. #define RELAY_BOOT_OFF 0
  228. #define RELAY_BOOT_ON 1
  229. #define RELAY_BOOT_SAME 2
  230. #define RELAY_BOOT_TOGGLE 3
  231. #define RELAY_TYPE_NORMAL 0
  232. #define RELAY_TYPE_INVERSE 1
  233. #define RELAY_TYPE_LATCHED 2
  234. #define RELAY_TYPE_LATCHED_INVERSE 3
  235. #define RELAY_SYNC_ANY 0
  236. #define RELAY_SYNC_NONE_OR_ONE 1
  237. #define RELAY_SYNC_ONE 2
  238. #define RELAY_SYNC_SAME 3
  239. #define RELAY_PULSE_NONE 0
  240. #define RELAY_PULSE_OFF 1
  241. #define RELAY_PULSE_ON 2
  242. #define RELAY_PROVIDER_RELAY 0
  243. #define RELAY_PROVIDER_DUAL 1
  244. #define RELAY_PROVIDER_LIGHT 2
  245. #define RELAY_PROVIDER_RFBRIDGE 3
  246. #define RELAY_PROVIDER_STM 4
  247. // Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
  248. #ifndef RELAY_BOOT_MODE
  249. #define RELAY_BOOT_MODE RELAY_BOOT_OFF
  250. #endif
  251. // 0 means ANY, 1 zero or one and 2 one and only one
  252. #ifndef RELAY_SYNC
  253. #define RELAY_SYNC RELAY_SYNC_ANY
  254. #endif
  255. // Default pulse mode: 0 means no pulses, 1 means normally off, 2 normally on
  256. #ifndef RELAY_PULSE_MODE
  257. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  258. #endif
  259. // Default pulse time in seconds
  260. #ifndef RELAY_PULSE_TIME
  261. #define RELAY_PULSE_TIME 1.0
  262. #endif
  263. // Relay requests flood protection window - in seconds
  264. #ifndef RELAY_FLOOD_WINDOW
  265. #define RELAY_FLOOD_WINDOW 3
  266. #endif
  267. // Allowed actual relay changes inside requests flood protection window
  268. #ifndef RELAY_FLOOD_CHANGES
  269. #define RELAY_FLOOD_CHANGES 5
  270. #endif
  271. // Pulse with in milliseconds for a latched relay
  272. #ifndef RELAY_LATCHING_PULSE
  273. #define RELAY_LATCHING_PULSE 10
  274. #endif
  275. // Do not save relay state after these many milliseconds
  276. #ifndef RELAY_SAVE_DELAY
  277. #define RELAY_SAVE_DELAY 1000
  278. #endif
  279. //------------------------------------------------------------------------------
  280. // LED
  281. //------------------------------------------------------------------------------
  282. #define LED_MODE_MQTT 0 // LED will be managed from MQTT (OFF by default)
  283. #define LED_MODE_WIFI 1 // LED will blink according to the WIFI status
  284. #define LED_MODE_FOLLOW 2 // LED will follow state of linked relay (check RELAY#_LED)
  285. #define LED_MODE_FOLLOW_INVERSE 3 // LED will follow the opposite state of linked relay (check RELAY#_LED)
  286. #define LED_MODE_FINDME 4 // LED will be ON if all relays are OFF
  287. #define LED_MODE_FINDME_WIFI 5 // A mixture between WIFI and FINDME
  288. #define LED_MODE_ON 6 // LED always ON
  289. #define LED_MODE_OFF 7 // LED always OFF
  290. #define LED_MODE_RELAY 8 // If any relay is ON, LED will be ON, otherwise OFF
  291. #define LED_MODE_RELAY_WIFI 9 // A mixture between WIFI and RELAY, the reverse of MIXED
  292. // -----------------------------------------------------------------------------
  293. // WIFI
  294. // -----------------------------------------------------------------------------
  295. #ifndef WIFI_CONNECT_TIMEOUT
  296. #define WIFI_CONNECT_TIMEOUT 60000 // Connecting timeout for WIFI in ms
  297. #endif
  298. #ifndef WIFI_RECONNECT_INTERVAL
  299. #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
  300. #endif
  301. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  302. #ifndef WIFI_AP_MODE
  303. #define WIFI_AP_MODE AP_MODE_ALONE
  304. #endif
  305. #ifndef WIFI_SLEEP_MODE
  306. #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP
  307. #endif
  308. #ifndef WIFI_SCAN_NETWORKS
  309. #define WIFI_SCAN_NETWORKS 1 // Perform a network scan before connecting
  310. #endif
  311. // Optional hardcoded configuration (up to 2 networks)
  312. #ifndef WIFI1_SSID
  313. #define WIFI1_SSID ""
  314. #endif
  315. #ifndef WIFI1_PASS
  316. #define WIFI1_PASS ""
  317. #endif
  318. #ifndef WIFI1_IP
  319. #define WIFI1_IP ""
  320. #endif
  321. #ifndef WIFI1_GW
  322. #define WIFI1_GW ""
  323. #endif
  324. #ifndef WIFI1_MASK
  325. #define WIFI1_MASK ""
  326. #endif
  327. #ifndef WIFI1_DNS
  328. #define WIFI1_DNS ""
  329. #endif
  330. #ifndef WIFI2_SSID
  331. #define WIFI2_SSID ""
  332. #endif
  333. #ifndef WIFI2_PASS
  334. #define WIFI2_PASS ""
  335. #endif
  336. #ifndef WIFI2_IP
  337. #define WIFI2_IP ""
  338. #endif
  339. #ifndef WIFI2_GW
  340. #define WIFI2_GW ""
  341. #endif
  342. #ifndef WIFI2_MASK
  343. #define WIFI2_MASK ""
  344. #endif
  345. #ifndef WIFI2_DNS
  346. #define WIFI2_DNS ""
  347. #endif
  348. #ifndef WIFI_RSSI_1M
  349. #define WIFI_RSSI_1M -30 // Calibrate it with your router reading the RSSI at 1m
  350. #endif
  351. #ifndef WIFI_PROPAGATION_CONST
  352. #define WIFI_PROPAGATION_CONST 4 // This is typically something between 2.7 to 4.3 (free space is 2)
  353. #endif
  354. // -----------------------------------------------------------------------------
  355. // WEB
  356. // -----------------------------------------------------------------------------
  357. #ifndef WEB_SUPPORT
  358. #define WEB_SUPPORT 1 // Enable web support (http, api, 121.65Kb)
  359. #endif
  360. #ifndef WEB_EMBEDDED
  361. #define WEB_EMBEDDED 1 // Build the firmware with the web interface embedded in
  362. #endif
  363. // This is not working at the moment!!
  364. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0
  365. #ifndef WEB_SSL_ENABLED
  366. #define WEB_SSL_ENABLED 0 // Use HTTPS web interface
  367. #endif
  368. #define WEB_MODE_NORMAL 0
  369. #define WEB_MODE_PASSWORD 1
  370. #ifndef WEB_USERNAME
  371. #define WEB_USERNAME "admin" // HTTP username
  372. #endif
  373. #ifndef WEB_FORCE_PASS_CHANGE
  374. #define WEB_FORCE_PASS_CHANGE 1 // Force the user to change the password if default one
  375. #endif
  376. #ifndef WEB_PORT
  377. #define WEB_PORT 80 // HTTP port
  378. #endif
  379. // -----------------------------------------------------------------------------
  380. // WEBSOCKETS
  381. // -----------------------------------------------------------------------------
  382. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  383. #ifndef WS_AUTHENTICATION
  384. #define WS_AUTHENTICATION 1 // WS authentication ON by default (see #507)
  385. #endif
  386. #ifndef WS_BUFFER_SIZE
  387. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  388. #endif
  389. #ifndef WS_TIMEOUT
  390. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  391. #endif
  392. #ifndef WS_UPDATE_INTERVAL
  393. #define WS_UPDATE_INTERVAL 30000 // Update clients every 30 seconds
  394. #endif
  395. // -----------------------------------------------------------------------------
  396. // API
  397. // -----------------------------------------------------------------------------
  398. // This will only be enabled if WEB_SUPPORT is 1 (this is the default value)
  399. #ifndef API_ENABLED
  400. #define API_ENABLED 0 // Do not enable API by default
  401. #endif
  402. #ifndef API_BUFFER_SIZE
  403. #define API_BUFFER_SIZE 15 // Size of the buffer for HTTP GET API responses
  404. #endif
  405. #ifndef API_REAL_TIME_VALUES
  406. #define API_REAL_TIME_VALUES 0 // Show filtered/median values by default (0 => median, 1 => real time)
  407. #endif
  408. // -----------------------------------------------------------------------------
  409. // UI
  410. // -----------------------------------------------------------------------------
  411. #define UI_TAG_INPUT 0
  412. #define UI_TAG_CHECKBOX 1
  413. #define UI_TAG_SELECT 2
  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. #if WEB_SUPPORT == 0
  438. #undef SSDP_SUPPORT
  439. #define SSDP_SUPPORT 0 // SSDP support requires web support
  440. #endif
  441. // -----------------------------------------------------------------------------
  442. // SPIFFS
  443. // -----------------------------------------------------------------------------
  444. #ifndef SPIFFS_SUPPORT
  445. #define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default
  446. #endif
  447. // -----------------------------------------------------------------------------
  448. // OTA
  449. // -----------------------------------------------------------------------------
  450. #ifndef OTA_PORT
  451. #define OTA_PORT 8266 // OTA port
  452. #endif
  453. #define OTA_GITHUB_FP "D7:9F:07:61:10:B3:92:93:E3:49:AC:89:84:5B:03:80:C1:9E:2F:8B"
  454. // -----------------------------------------------------------------------------
  455. // NOFUSS
  456. // -----------------------------------------------------------------------------
  457. #ifndef NOFUSS_SUPPORT
  458. #define NOFUSS_SUPPORT 0 // Do not enable support for NoFuss by default (12.65Kb)
  459. #endif
  460. #ifndef NOFUSS_ENABLED
  461. #define NOFUSS_ENABLED 0 // Do not perform NoFUSS updates by default
  462. #endif
  463. #ifndef NOFUSS_SERVER
  464. #define NOFUSS_SERVER "" // Default NoFuss Server
  465. #endif
  466. #ifndef NOFUSS_INTERVAL
  467. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  468. #endif
  469. // -----------------------------------------------------------------------------
  470. // UART <-> MQTT
  471. // -----------------------------------------------------------------------------
  472. #ifndef UART_MQTT_SUPPORT
  473. #define UART_MQTT_SUPPORT 0 // No support by default
  474. #endif
  475. #ifndef UART_MQTT_USE_SOFT
  476. #define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial
  477. #endif
  478. #ifndef UART_MQTT_HW_PORT
  479. #define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0)
  480. #endif
  481. #ifndef UART_MQTT_RX_PIN
  482. #define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1)
  483. #endif
  484. #ifndef UART_MQTT_TX_PIN
  485. #define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1)
  486. #endif
  487. #ifndef UART_MQTT_BAUDRATE
  488. #define UART_MQTT_BAUDRATE 115200 // Serial speed
  489. #endif
  490. #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size
  491. #if UART_MQTT_SUPPORT
  492. #define MQTT_SUPPORT 1
  493. #undef TERMINAL_SUPPORT
  494. #define TERMINAL_SUPPORT 0
  495. #undef DEBUG_SERIAL_SUPPORT
  496. #define DEBUG_SERIAL_SUPPORT 0
  497. #endif
  498. // -----------------------------------------------------------------------------
  499. // MQTT
  500. // -----------------------------------------------------------------------------
  501. #ifndef MQTT_SUPPORT
  502. #define MQTT_SUPPORT 1 // MQTT support (22.38Kb async, 12.48Kb sync)
  503. #endif
  504. #ifndef MQTT_USE_ASYNC
  505. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  506. #endif
  507. // MQTT OVER SSL
  508. // Using MQTT over SSL works pretty well but generates problems with the web interface.
  509. // It could be a good idea to use it in conjuntion with WEB_SUPPORT=0.
  510. // Requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  511. //
  512. // You can use SSL with MQTT_USE_ASYNC=1 (AsyncMqttClient library)
  513. // but you might experience hiccups on the web interface, so my recommendation is:
  514. // WEB_SUPPORT=0
  515. //
  516. // If you use SSL with MQTT_USE_ASYNC=0 (PubSubClient library)
  517. // you will have to disable all the modules that use ESPAsyncTCP, that is:
  518. // ALEXA_SUPPORT=0, INFLUXDB_SUPPORT=0, TELNET_SUPPORT=0, THINGSPEAK_SUPPORT=0 and WEB_SUPPORT=0
  519. //
  520. // You will need the fingerprint for your MQTT server, example for CloudMQTT:
  521. // $ echo -n | openssl s_client -connect m11.cloudmqtt.com:24055 > cloudmqtt.pem
  522. // $ openssl x509 -noout -in cloudmqtt.pem -fingerprint -sha1
  523. #ifndef MQTT_SSL_ENABLED
  524. #define MQTT_SSL_ENABLED 0 // By default MQTT over SSL will not be enabled
  525. #endif
  526. #ifndef MQTT_SSL_FINGERPRINT
  527. #define MQTT_SSL_FINGERPRINT "" // SSL fingerprint of the server
  528. #endif
  529. #ifndef MQTT_ENABLED
  530. #define MQTT_ENABLED 0 // Do not enable MQTT connection by default
  531. #endif
  532. #ifndef MQTT_AUTOCONNECT
  533. #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SERVER_SUPPORT=1 will perform an autodiscover and
  534. #endif
  535. // autoconnect to the first MQTT broker found if none defined
  536. #ifndef MQTT_SERVER
  537. #define MQTT_SERVER "" // Default MQTT broker address
  538. #endif
  539. #ifndef MQTT_USER
  540. #define MQTT_USER "" // Default MQTT broker usename
  541. #endif
  542. #ifndef MQTT_PASS
  543. #define MQTT_PASS "" // Default MQTT broker password
  544. #endif
  545. #ifndef MQTT_PORT
  546. #define MQTT_PORT 1883 // MQTT broker port
  547. #endif
  548. #ifndef MQTT_TOPIC
  549. #define MQTT_TOPIC "{hostname}" // Default MQTT base topic
  550. #endif
  551. #ifndef MQTT_RETAIN
  552. #define MQTT_RETAIN true // MQTT retain flag
  553. #endif
  554. #ifndef MQTT_QOS
  555. #define MQTT_QOS 0 // MQTT QoS value for all messages
  556. #endif
  557. #ifndef MQTT_KEEPALIVE
  558. #define MQTT_KEEPALIVE 30 // MQTT keepalive value
  559. #endif
  560. #ifndef MQTT_RECONNECT_DELAY_MIN
  561. #define MQTT_RECONNECT_DELAY_MIN 5000 // Try to reconnect in 5 seconds upon disconnection
  562. #endif
  563. #ifndef MQTT_RECONNECT_DELAY_STEP
  564. #define MQTT_RECONNECT_DELAY_STEP 5000 // Increase the reconnect delay in 5 seconds after each failed attempt
  565. #endif
  566. #ifndef MQTT_RECONNECT_DELAY_MAX
  567. #define MQTT_RECONNECT_DELAY_MAX 120000 // Set reconnect time to 2 minutes at most
  568. #endif
  569. #ifndef MQTT_SKIP_RETAINED
  570. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  571. #endif
  572. #ifndef MQTT_SKIP_TIME
  573. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  574. #endif
  575. #ifndef MQTT_USE_JSON
  576. #define MQTT_USE_JSON 0 // Group messages in a JSON body
  577. #endif
  578. #ifndef MQTT_USE_JSON_DELAY
  579. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  580. #endif
  581. #ifndef MQTT_QUEUE_MAX_SIZE
  582. #define MQTT_QUEUE_MAX_SIZE 20 // Size of the MQTT queue when MQTT_USE_JSON is enabled
  583. #endif
  584. // These are the properties that will be sent when useJson is true
  585. #ifndef MQTT_ENQUEUE_IP
  586. #define MQTT_ENQUEUE_IP 1
  587. #endif
  588. #ifndef MQTT_ENQUEUE_MAC
  589. #define MQTT_ENQUEUE_MAC 1
  590. #endif
  591. #ifndef MQTT_ENQUEUE_HOSTNAME
  592. #define MQTT_ENQUEUE_HOSTNAME 1
  593. #endif
  594. #ifndef MQTT_ENQUEUE_DATETIME
  595. #define MQTT_ENQUEUE_DATETIME 1
  596. #endif
  597. #ifndef MQTT_ENQUEUE_MESSAGE_ID
  598. #define MQTT_ENQUEUE_MESSAGE_ID 1
  599. #endif
  600. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  601. #define MQTT_TOPIC_JSON "data"
  602. #define MQTT_TOPIC_ACTION "action"
  603. #define MQTT_TOPIC_RELAY "relay"
  604. #define MQTT_TOPIC_LED "led"
  605. #define MQTT_TOPIC_BUTTON "button"
  606. #define MQTT_TOPIC_IP "ip"
  607. #define MQTT_TOPIC_VERSION "version"
  608. #define MQTT_TOPIC_UPTIME "uptime"
  609. #define MQTT_TOPIC_DATETIME "datetime"
  610. #define MQTT_TOPIC_FREEHEAP "freeheap"
  611. #define MQTT_TOPIC_VCC "vcc"
  612. #define MQTT_TOPIC_STATUS "status"
  613. #define MQTT_TOPIC_MAC "mac"
  614. #define MQTT_TOPIC_RSSI "rssi"
  615. #define MQTT_TOPIC_MESSAGE_ID "id"
  616. #define MQTT_TOPIC_APP "app"
  617. #define MQTT_TOPIC_INTERVAL "interval"
  618. #define MQTT_TOPIC_HOSTNAME "host"
  619. #define MQTT_TOPIC_TIME "time"
  620. #define MQTT_TOPIC_RFOUT "rfout"
  621. #define MQTT_TOPIC_RFIN "rfin"
  622. #define MQTT_TOPIC_RFLEARN "rflearn"
  623. #define MQTT_TOPIC_RFRAW "rfraw"
  624. #define MQTT_TOPIC_UARTIN "uartin"
  625. #define MQTT_TOPIC_UARTOUT "uartout"
  626. #define MQTT_TOPIC_LOADAVG "loadavg"
  627. #define MQTT_TOPIC_BOARD "board"
  628. // Light module
  629. #define MQTT_TOPIC_CHANNEL "channel"
  630. #define MQTT_TOPIC_COLOR_RGB "rgb"
  631. #define MQTT_TOPIC_COLOR_HSV "hsv"
  632. #define MQTT_TOPIC_ANIM_MODE "anim_mode"
  633. #define MQTT_TOPIC_ANIM_SPEED "anim_speed"
  634. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  635. #define MQTT_TOPIC_MIRED "mired"
  636. #define MQTT_TOPIC_KELVIN "kelvin"
  637. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  638. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  639. #define MQTT_ACTION_RESET "reboot" // RESET MQTT topic particle
  640. // Internal MQTT events (do not change)
  641. #define MQTT_CONNECT_EVENT 0
  642. #define MQTT_DISCONNECT_EVENT 1
  643. #define MQTT_MESSAGE_EVENT 2
  644. #define MQTT_MESSAGE_ID_SHIFT 1000 // Store MQTT message id into EEPROM every these many
  645. // Custom get and set postfixes
  646. // Use something like "/status" or "/set", with leading slash
  647. // Since 1.9.0 the default value is "" for getter and "/set" for setter
  648. #ifndef MQTT_GETTER
  649. #define MQTT_GETTER ""
  650. #endif
  651. #ifndef MQTT_SETTER
  652. #define MQTT_SETTER "/set"
  653. #endif
  654. // -----------------------------------------------------------------------------
  655. // BROKER
  656. // -----------------------------------------------------------------------------
  657. #ifndef BROKER_SUPPORT
  658. #define BROKER_SUPPORT 1 // The broker is a poor-man's pubsub manager
  659. #endif
  660. // -----------------------------------------------------------------------------
  661. // SETTINGS
  662. // -----------------------------------------------------------------------------
  663. #ifndef SETTINGS_AUTOSAVE
  664. #define SETTINGS_AUTOSAVE 1 // Autosave settings o force manual commit
  665. #endif
  666. #define SETTINGS_MAX_LIST_COUNT 10 // Maximum index for settings lists
  667. // -----------------------------------------------------------------------------
  668. // LIGHT
  669. // -----------------------------------------------------------------------------
  670. // Available light providers (do not change)
  671. #define LIGHT_PROVIDER_NONE 0
  672. #define LIGHT_PROVIDER_MY92XX 1 // works with MY9291 and MY9231
  673. #define LIGHT_PROVIDER_DIMMER 2
  674. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  675. // They have to be defined for each device in the hardware.h file.
  676. // If 3 or more channels first 3 will be considered RGB.
  677. // Usual configurations are:
  678. // 1 channels => W
  679. // 2 channels => WW
  680. // 3 channels => RGB
  681. // 4 channels => RGBW
  682. // 5 channels => RGBWW
  683. #ifndef LIGHT_SAVE_ENABLED
  684. #define LIGHT_SAVE_ENABLED 1 // Light channel values saved by default after each change
  685. #endif
  686. #ifndef LIGHT_SAVE_DELAY
  687. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  688. #endif
  689. #ifndef LIGHT_MAX_PWM
  690. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  691. #define LIGHT_MAX_PWM 255
  692. #endif
  693. #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER
  694. #define LIGHT_MAX_PWM 10000 // 5000 * 200ns => 1 kHz
  695. #endif
  696. #endif // LIGHT_MAX_PWM
  697. #ifndef LIGHT_LIMIT_PWM
  698. #define LIGHT_LIMIT_PWM LIGHT_MAX_PWM // Limit PWM to this value (prevent 100% power)
  699. #endif
  700. #ifndef LIGHT_MAX_VALUE
  701. #define LIGHT_MAX_VALUE 255 // Maximum light value
  702. #endif
  703. #ifndef LIGHT_MAX_BRIGHTNESS
  704. #define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
  705. #endif
  706. #define LIGHT_MIN_MIREDS 153 // Default to the Philips Hue value that HA also use.
  707. #define LIGHT_MAX_MIREDS 500 // https://developers.meethue.com/documentation/core-concepts
  708. #ifndef LIGHT_STEP
  709. #define LIGHT_STEP 32 // Step size
  710. #endif
  711. #ifndef LIGHT_USE_COLOR
  712. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  713. #endif
  714. #ifndef LIGHT_USE_WHITE
  715. #define LIGHT_USE_WHITE 0 // Use the 4th channel as (Warm-)White LEDs
  716. #endif
  717. #ifndef LIGHT_USE_COLD_WHITE
  718. #define LIGHT_USE_COLD_WHITE 0 // Use the 5th channel as Coldwhite LEDs, LIGHT_USE_WHITE must be 1.
  719. #endif
  720. // Used when LIGHT_USE_WHITE AND LIGHT_USE_COLD_WHITE is 1 - (1000000/Kelvin = MiReds)
  721. // Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
  722. #define LIGHT_MIRED_W1 500 // Warmwhite Strip, Value must be __ABOVE__ W2!! (Default: 2000 Kelvin/500 MiRed)
  723. #define LIGHT_MIRED_W2 153 // Coldwhite Strip, Value must be __BELOW__ W1!! (Default: 6535 Kelvin/153 MiRed)
  724. #ifndef LIGHT_USE_GAMMA
  725. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  726. #endif
  727. #ifndef LIGHT_USE_CSS
  728. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  729. #endif
  730. #ifndef LIGHT_USE_RGB
  731. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  732. #endif
  733. #ifndef LIGHT_WHITE_FACTOR
  734. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  735. // this factor is used to scale the white channel to match brightness
  736. #endif
  737. #ifndef LIGHT_USE_TRANSITIONS
  738. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  739. #endif
  740. #ifndef LIGHT_TRANSITION_STEP
  741. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  742. #endif
  743. #ifndef LIGHT_TRANSITION_TIME
  744. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  745. #endif
  746. // -----------------------------------------------------------------------------
  747. // DOMOTICZ
  748. // -----------------------------------------------------------------------------
  749. #ifndef DOMOTICZ_SUPPORT
  750. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  751. #endif
  752. #if DOMOTICZ_SUPPORT
  753. #undef MQTT_SUPPORT
  754. #define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT
  755. #endif
  756. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  757. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  758. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  759. // -----------------------------------------------------------------------------
  760. // HOME ASSISTANT
  761. // -----------------------------------------------------------------------------
  762. #ifndef HOMEASSISTANT_SUPPORT
  763. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  764. #endif
  765. #if HOMEASSISTANT_SUPPORT
  766. #undef MQTT_SUPPORT
  767. #define MQTT_SUPPORT 1 // If Home Assistant enabled enable MQTT
  768. #endif
  769. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  770. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  771. // -----------------------------------------------------------------------------
  772. // INFLUXDB
  773. // -----------------------------------------------------------------------------
  774. #ifndef INFLUXDB_SUPPORT
  775. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  776. #endif
  777. #ifndef INFLUXDB_ENABLED
  778. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  779. #endif
  780. #ifndef INFLUXDB_HOST
  781. #define INFLUXDB_HOST "" // Default server
  782. #endif
  783. #ifndef INFLUXDB_PORT
  784. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  785. #endif
  786. #ifndef INFLUXDB_DATABASE
  787. #define INFLUXDB_DATABASE "" // Default database
  788. #endif
  789. #ifndef INFLUXDB_USERNAME
  790. #define INFLUXDB_USERNAME "" // Default username
  791. #endif
  792. #ifndef INFLUXDB_PASSWORD
  793. #define INFLUXDB_PASSWORD "" // Default password
  794. #endif
  795. // -----------------------------------------------------------------------------
  796. // THINGSPEAK
  797. // -----------------------------------------------------------------------------
  798. #ifndef THINGSPEAK_SUPPORT
  799. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  800. #endif
  801. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  802. #define THINGSPEAK_APIKEY "" // Default API KEY
  803. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  804. // THINGSPEAK OVER SSL
  805. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  806. // so you should compile it with WEB_SUPPORT to 0.
  807. // When THINGSPEAK_USE_ASYNC is 1, requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  808. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  809. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  810. #define THINGSPEAK_HOST "api.thingspeak.com"
  811. #if THINGSPEAK_USE_SSL
  812. #define THINGSPEAK_PORT 443
  813. #else
  814. #define THINGSPEAK_PORT 80
  815. #endif
  816. #define THINGSPEAK_URL "/update"
  817. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  818. #ifndef ASYNC_TCP_SSL_ENABLED
  819. #if THINGSPEAK_USE_SSL && THINGSPEAK_USE_ASYNC
  820. #undef THINGSPEAK_SUPPORT // Thingspeak in ASYNC mode requires ASYNC_TCP_SSL_ENABLED
  821. #endif
  822. #endif
  823. // -----------------------------------------------------------------------------
  824. // SCHEDULER
  825. // -----------------------------------------------------------------------------
  826. #define SCHEDULER_TYPE_SWITCH 1
  827. #define SCHEDULER_TYPE_DIM 2
  828. #ifndef SCHEDULER_SUPPORT
  829. #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
  830. #endif
  831. #if SCHEDULER_SUPPORT
  832. #undef NTP_SUPPORT
  833. #define NTP_SUPPORT 1 // Scheduler needs NTP
  834. #endif
  835. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  836. // -----------------------------------------------------------------------------
  837. // NTP
  838. // -----------------------------------------------------------------------------
  839. #ifndef NTP_SUPPORT
  840. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  841. #endif
  842. #ifndef NTP_SERVER
  843. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  844. #endif
  845. #ifndef NTP_TIMEOUT
  846. #define NTP_TIMEOUT 2000 // Set NTP request timeout to 2 seconds (issue #452)
  847. #endif
  848. #ifndef NTP_TIME_OFFSET
  849. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  850. #endif
  851. #ifndef NTP_DAY_LIGHT
  852. #define NTP_DAY_LIGHT true // Enable daylight time saving by default
  853. #endif
  854. #ifndef NTP_SYNC_INTERVAL
  855. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  856. #endif
  857. #ifndef NTP_UPDATE_INTERVAL
  858. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  859. #endif
  860. #ifndef NTP_START_DELAY
  861. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  862. #endif
  863. #ifndef NTP_DST_REGION
  864. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  865. #endif
  866. // -----------------------------------------------------------------------------
  867. // ALEXA
  868. // -----------------------------------------------------------------------------
  869. // This setting defines whether Alexa support should be built into the firmware
  870. #ifndef ALEXA_SUPPORT
  871. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  872. #endif
  873. // This is default value for the alexaEnabled setting that defines whether
  874. // this device should be discoberable and respond to Alexa commands.
  875. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  876. #define ALEXA_ENABLED 1
  877. // -----------------------------------------------------------------------------
  878. // RFBRIDGE
  879. // This module is not compatible with RF_SUPPORT=1
  880. // -----------------------------------------------------------------------------
  881. #ifndef RF_SEND_TIMES
  882. #define RF_SEND_TIMES 4 // How many times to send the message
  883. #endif
  884. #ifndef RF_SEND_DELAY
  885. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  886. #endif
  887. #ifndef RF_RECEIVE_DELAY
  888. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  889. #endif
  890. #ifndef RF_RAW_SUPPORT
  891. #define RF_RAW_SUPPORT 0 // RF raw codes require a specific firmware for the EFM8BB1
  892. // https://github.com/rhx/RF-Bridge-EFM8BB1
  893. #endif
  894. // -----------------------------------------------------------------------------
  895. // IR
  896. // -----------------------------------------------------------------------------
  897. #ifndef IR_SUPPORT
  898. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  899. #endif
  900. #ifndef IR_PIN
  901. #define IR_PIN 4 // IR LED
  902. #endif
  903. // 24 Buttons Set of the IR Remote
  904. #ifndef IR_BUTTON_SET
  905. #define IR_BUTTON_SET 1 // IR button set to use (see below)
  906. #endif
  907. // IR Button modes
  908. #define IR_BUTTON_MODE_NONE 0
  909. #define IR_BUTTON_MODE_RGB 1
  910. #define IR_BUTTON_MODE_HSV 2
  911. #define IR_BUTTON_MODE_BRIGHTER 3
  912. #define IR_BUTTON_MODE_STATE 4
  913. #define IR_BUTTON_MODE_EFFECT 5
  914. #define LIGHT_EFFECT_SOLID 0
  915. #define LIGHT_EFFECT_FLASH 1
  916. #define LIGHT_EFFECT_STROBE 2
  917. #define LIGHT_EFFECT_FADE 3
  918. #define LIGHT_EFFECT_SMOOTH 4
  919. //Remote Buttons SET 1 (for the original Remote shipped with the controller)
  920. #if IR_SUPPORT
  921. #if IR_BUTTON_SET == 1
  922. /*
  923. +------+------+------+------+
  924. | UP | Down | OFF | ON |
  925. +------+------+------+------+
  926. | R | G | B | W |
  927. +------+------+------+------+
  928. | 1 | 2 | 3 |FLASH |
  929. +------+------+------+------+
  930. | 4 | 5 | 6 |STROBE|
  931. +------+------+------+------+
  932. | 7 | 8 | 9 | FADE |
  933. +------+------+------+------+
  934. | 10 | 11 | 12 |SMOOTH|
  935. +------+------+------+------+
  936. */
  937. #define IR_BUTTON_COUNT 24
  938. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  939. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  940. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  941. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  942. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  943. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  944. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  945. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  946. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  947. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  948. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  949. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  950. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  951. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  952. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  953. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  954. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  955. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  956. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  957. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  958. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  959. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  960. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  961. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  962. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  963. };
  964. #endif
  965. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  966. #if IR_BUTTON_SET == 2
  967. /*
  968. +------+------+------+------+
  969. | UP | Down | OFF | ON |
  970. +------+------+------+------+
  971. | R | G | B | W |
  972. +------+------+------+------+
  973. | 1 | 2 | 3 |FLASH |
  974. +------+------+------+------+
  975. | 4 | 5 | 6 |STROBE|
  976. +------+------+------+------+
  977. | 7 | 8 | 9 | FADE |
  978. +------+------+------+------+
  979. | 10 | 11 | 12 |SMOOTH|
  980. +------+------+------+------+
  981. */
  982. #define IR_BUTTON_COUNT 24
  983. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  984. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  985. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  986. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  987. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  988. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  989. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  990. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  991. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  992. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  993. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  994. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  995. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  996. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  997. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  998. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  999. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  1000. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  1001. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  1002. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  1003. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1004. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1005. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1006. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1007. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1008. };
  1009. #endif
  1010. #endif // IR_SUPPORT
  1011. //--------------------------------------------------------------------------------
  1012. // Custom RF module
  1013. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  1014. // Enable support by passing RF_SUPPORT=1 build flag
  1015. // This module is not compatible with RFBRIDGE
  1016. //--------------------------------------------------------------------------------
  1017. #ifndef RF_SUPPORT
  1018. #define RF_SUPPORT 0
  1019. #endif
  1020. #ifndef RF_PIN
  1021. #define RF_PIN 14
  1022. #endif
  1023. #define RF_DEBOUNCE 500
  1024. #define RF_LEARN_TIMEOUT 60000