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.

1320 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
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 // NOT USED (yet)! // Default to the Philips Hue value that HA has always assumed
  707. //#define LIGHT_MAX_MIREDS 500 // NOT USED (yet)! // https://developers.meethue.com/documentation/core-concepts
  708. #ifndef LIGHT_DEFAULT_MIREDS
  709. #define LIGHT_DEFAULT_MIREDS 153 // Default value used by MQTT. This value is __NEVRER__ applied!
  710. #endif
  711. #ifndef LIGHT_STEP
  712. #define LIGHT_STEP 32 // Step size
  713. #endif
  714. #ifndef LIGHT_USE_COLOR
  715. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  716. #endif
  717. #ifndef LIGHT_USE_WHITE
  718. #define LIGHT_USE_WHITE 0 // Use white channel whenever RGB have the same value
  719. #endif
  720. #ifndef LIGHT_USE_GAMMA
  721. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  722. #endif
  723. #ifndef LIGHT_USE_CSS
  724. #define LIGHT_USE_CSS 1 // Use CSS style to report colors (1=> "#FF0000", 0=> "255,0,0")
  725. #endif
  726. #ifndef LIGHT_USE_RGB
  727. #define LIGHT_USE_RGB 0 // Use RGB color selector (1=> RGB, 0=> HSV)
  728. #endif
  729. #ifndef LIGHT_WHITE_FACTOR
  730. #define LIGHT_WHITE_FACTOR 1 // When using LIGHT_USE_WHITE with uneven brightness LEDs,
  731. // this factor is used to scale the white channel to match brightness
  732. #endif
  733. #ifndef LIGHT_USE_TRANSITIONS
  734. #define LIGHT_USE_TRANSITIONS 1 // Transitions between colors
  735. #endif
  736. #ifndef LIGHT_TRANSITION_STEP
  737. #define LIGHT_TRANSITION_STEP 10 // Time in millis between each transtion step
  738. #endif
  739. #ifndef LIGHT_TRANSITION_TIME
  740. #define LIGHT_TRANSITION_TIME 500 // Time in millis from color to color
  741. #endif
  742. // -----------------------------------------------------------------------------
  743. // DOMOTICZ
  744. // -----------------------------------------------------------------------------
  745. #ifndef DOMOTICZ_SUPPORT
  746. #define DOMOTICZ_SUPPORT MQTT_SUPPORT // Build with domoticz (if MQTT) support (1.72Kb)
  747. #endif
  748. #if DOMOTICZ_SUPPORT
  749. #undef MQTT_SUPPORT
  750. #define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT
  751. #endif
  752. #define DOMOTICZ_ENABLED 0 // Disable domoticz by default
  753. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  754. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  755. // -----------------------------------------------------------------------------
  756. // HOME ASSISTANT
  757. // -----------------------------------------------------------------------------
  758. #ifndef HOMEASSISTANT_SUPPORT
  759. #define HOMEASSISTANT_SUPPORT MQTT_SUPPORT // Build with home assistant support (if MQTT, 1.64Kb)
  760. #endif
  761. #if HOMEASSISTANT_SUPPORT
  762. #undef MQTT_SUPPORT
  763. #define MQTT_SUPPORT 1 // If Home Assistant enabled enable MQTT
  764. #endif
  765. #define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
  766. #define HOMEASSISTANT_PREFIX "homeassistant" // Default MQTT prefix
  767. // -----------------------------------------------------------------------------
  768. // INFLUXDB
  769. // -----------------------------------------------------------------------------
  770. #ifndef INFLUXDB_SUPPORT
  771. #define INFLUXDB_SUPPORT 0 // Disable InfluxDB support by default (4.38Kb)
  772. #endif
  773. #ifndef INFLUXDB_ENABLED
  774. #define INFLUXDB_ENABLED 0 // InfluxDB disabled by default
  775. #endif
  776. #ifndef INFLUXDB_HOST
  777. #define INFLUXDB_HOST "" // Default server
  778. #endif
  779. #ifndef INFLUXDB_PORT
  780. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  781. #endif
  782. #ifndef INFLUXDB_DATABASE
  783. #define INFLUXDB_DATABASE "" // Default database
  784. #endif
  785. #ifndef INFLUXDB_USERNAME
  786. #define INFLUXDB_USERNAME "" // Default username
  787. #endif
  788. #ifndef INFLUXDB_PASSWORD
  789. #define INFLUXDB_PASSWORD "" // Default password
  790. #endif
  791. // -----------------------------------------------------------------------------
  792. // THINGSPEAK
  793. // -----------------------------------------------------------------------------
  794. #ifndef THINGSPEAK_SUPPORT
  795. #define THINGSPEAK_SUPPORT 1 // Enable Thingspeak support by default (2.56Kb)
  796. #endif
  797. #define THINGSPEAK_ENABLED 0 // Thingspeak disabled by default
  798. #define THINGSPEAK_APIKEY "" // Default API KEY
  799. #define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
  800. // THINGSPEAK OVER SSL
  801. // Using THINGSPEAK over SSL works well but generates problems with the web interface,
  802. // so you should compile it with WEB_SUPPORT to 0.
  803. // When THINGSPEAK_USE_ASYNC is 1, requires ASYNC_TCP_SSL_ENABLED to 1 and ESP8266 Arduino Core 2.4.0.
  804. #define THINGSPEAK_USE_SSL 0 // Use secure connection
  805. #define THINGSPEAK_FINGERPRINT "78 60 18 44 81 35 BF DF 77 84 D4 0A 22 0D 9B 4E 6C DC 57 2C"
  806. #define THINGSPEAK_HOST "api.thingspeak.com"
  807. #if THINGSPEAK_USE_SSL
  808. #define THINGSPEAK_PORT 443
  809. #else
  810. #define THINGSPEAK_PORT 80
  811. #endif
  812. #define THINGSPEAK_URL "/update"
  813. #define THINGSPEAK_MIN_INTERVAL 15000 // Minimum interval between POSTs (in millis)
  814. #ifndef ASYNC_TCP_SSL_ENABLED
  815. #if THINGSPEAK_USE_SSL && THINGSPEAK_USE_ASYNC
  816. #undef THINGSPEAK_SUPPORT // Thingspeak in ASYNC mode requires ASYNC_TCP_SSL_ENABLED
  817. #endif
  818. #endif
  819. // -----------------------------------------------------------------------------
  820. // SCHEDULER
  821. // -----------------------------------------------------------------------------
  822. #define SCHEDULER_TYPE_SWITCH 1
  823. #define SCHEDULER_TYPE_DIM 2
  824. #ifndef SCHEDULER_SUPPORT
  825. #define SCHEDULER_SUPPORT 1 // Enable scheduler (1.77Kb)
  826. #endif
  827. #if SCHEDULER_SUPPORT
  828. #undef NTP_SUPPORT
  829. #define NTP_SUPPORT 1 // Scheduler needs NTP
  830. #endif
  831. #define SCHEDULER_MAX_SCHEDULES 10 // Max schedules alowed
  832. // -----------------------------------------------------------------------------
  833. // NTP
  834. // -----------------------------------------------------------------------------
  835. #ifndef NTP_SUPPORT
  836. #define NTP_SUPPORT 1 // Build with NTP support by default (6.78Kb)
  837. #endif
  838. #ifndef NTP_SERVER
  839. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  840. #endif
  841. #ifndef NTP_TIMEOUT
  842. #define NTP_TIMEOUT 2000 // Set NTP request timeout to 2 seconds (issue #452)
  843. #endif
  844. #ifndef NTP_TIME_OFFSET
  845. #define NTP_TIME_OFFSET 60 // Default timezone offset (GMT+1)
  846. #endif
  847. #ifndef NTP_DAY_LIGHT
  848. #define NTP_DAY_LIGHT true // Enable daylight time saving by default
  849. #endif
  850. #ifndef NTP_SYNC_INTERVAL
  851. #define NTP_SYNC_INTERVAL 60 // NTP initial check every minute
  852. #endif
  853. #ifndef NTP_UPDATE_INTERVAL
  854. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  855. #endif
  856. #ifndef NTP_START_DELAY
  857. #define NTP_START_DELAY 1000 // Delay NTP start 1 second
  858. #endif
  859. #ifndef NTP_DST_REGION
  860. #define NTP_DST_REGION 0 // 0 for Europe, 1 for USA (defined in NtpClientLib)
  861. #endif
  862. // -----------------------------------------------------------------------------
  863. // ALEXA
  864. // -----------------------------------------------------------------------------
  865. // This setting defines whether Alexa support should be built into the firmware
  866. #ifndef ALEXA_SUPPORT
  867. #define ALEXA_SUPPORT 1 // Enable Alexa support by default (10.84Kb)
  868. #endif
  869. // This is default value for the alexaEnabled setting that defines whether
  870. // this device should be discoberable and respond to Alexa commands.
  871. // Both ALEXA_SUPPORT and alexaEnabled should be 1 for Alexa support to work.
  872. #define ALEXA_ENABLED 1
  873. // -----------------------------------------------------------------------------
  874. // RFBRIDGE
  875. // This module is not compatible with RF_SUPPORT=1
  876. // -----------------------------------------------------------------------------
  877. #ifndef RF_SEND_TIMES
  878. #define RF_SEND_TIMES 4 // How many times to send the message
  879. #endif
  880. #ifndef RF_SEND_DELAY
  881. #define RF_SEND_DELAY 500 // Interval between sendings in ms
  882. #endif
  883. #ifndef RF_RECEIVE_DELAY
  884. #define RF_RECEIVE_DELAY 500 // Interval between recieving in ms (avoid debouncing)
  885. #endif
  886. #ifndef RF_RAW_SUPPORT
  887. #define RF_RAW_SUPPORT 0 // RF raw codes require a specific firmware for the EFM8BB1
  888. // https://github.com/rhx/RF-Bridge-EFM8BB1
  889. #endif
  890. // -----------------------------------------------------------------------------
  891. // IR
  892. // -----------------------------------------------------------------------------
  893. #ifndef IR_SUPPORT
  894. #define IR_SUPPORT 0 // Do not build with IR support by default (10.25Kb)
  895. #endif
  896. #ifndef IR_PIN
  897. #define IR_PIN 4 // IR LED
  898. #endif
  899. // 24 Buttons Set of the IR Remote
  900. #ifndef IR_BUTTON_SET
  901. #define IR_BUTTON_SET 1 // IR button set to use (see below)
  902. #endif
  903. // IR Button modes
  904. #define IR_BUTTON_MODE_NONE 0
  905. #define IR_BUTTON_MODE_RGB 1
  906. #define IR_BUTTON_MODE_HSV 2
  907. #define IR_BUTTON_MODE_BRIGHTER 3
  908. #define IR_BUTTON_MODE_STATE 4
  909. #define IR_BUTTON_MODE_EFFECT 5
  910. #define LIGHT_EFFECT_SOLID 0
  911. #define LIGHT_EFFECT_FLASH 1
  912. #define LIGHT_EFFECT_STROBE 2
  913. #define LIGHT_EFFECT_FADE 3
  914. #define LIGHT_EFFECT_SMOOTH 4
  915. //Remote Buttons SET 1 (for the original Remote shipped with the controller)
  916. #if IR_SUPPORT
  917. #if IR_BUTTON_SET == 1
  918. /*
  919. +------+------+------+------+
  920. | UP | Down | OFF | ON |
  921. +------+------+------+------+
  922. | R | G | B | W |
  923. +------+------+------+------+
  924. | 1 | 2 | 3 |FLASH |
  925. +------+------+------+------+
  926. | 4 | 5 | 6 |STROBE|
  927. +------+------+------+------+
  928. | 7 | 8 | 9 | FADE |
  929. +------+------+------+------+
  930. | 10 | 11 | 12 |SMOOTH|
  931. +------+------+------+------+
  932. */
  933. #define IR_BUTTON_COUNT 24
  934. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  935. { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 },
  936. { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 },
  937. { 0xFFF807, IR_BUTTON_MODE_STATE, 0 },
  938. { 0xFFB04F, IR_BUTTON_MODE_STATE, 1 },
  939. { 0xFF9867, IR_BUTTON_MODE_RGB, 0xFF0000 },
  940. { 0xFFD827, IR_BUTTON_MODE_RGB, 0x00FF00 },
  941. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x0000FF },
  942. { 0xFFA857, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  943. { 0xFFE817, IR_BUTTON_MODE_RGB, 0xD13A01 },
  944. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x00E644 },
  945. { 0xFF6897, IR_BUTTON_MODE_RGB, 0x0040A7 },
  946. { 0xFFB24D, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  947. { 0xFF02FD, IR_BUTTON_MODE_RGB, 0xE96F2A },
  948. { 0xFF32CD, IR_BUTTON_MODE_RGB, 0x00BEBF },
  949. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0x56406F },
  950. { 0xFF00FF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  951. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0xEE9819 },
  952. { 0xFF7887, IR_BUTTON_MODE_RGB, 0x00799A },
  953. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x944E80 },
  954. { 0xFF58A7, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  955. { 0xFF38C7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  956. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0x0060A1 },
  957. { 0xFFF00F, IR_BUTTON_MODE_RGB, 0xEF45AD },
  958. { 0xFF30CF, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  959. };
  960. #endif
  961. //Remote Buttons SET 2 (another identical IR Remote shipped with another controller)
  962. #if IR_BUTTON_SET == 2
  963. /*
  964. +------+------+------+------+
  965. | UP | Down | OFF | ON |
  966. +------+------+------+------+
  967. | R | G | B | W |
  968. +------+------+------+------+
  969. | 1 | 2 | 3 |FLASH |
  970. +------+------+------+------+
  971. | 4 | 5 | 6 |STROBE|
  972. +------+------+------+------+
  973. | 7 | 8 | 9 | FADE |
  974. +------+------+------+------+
  975. | 10 | 11 | 12 |SMOOTH|
  976. +------+------+------+------+
  977. */
  978. #define IR_BUTTON_COUNT 24
  979. const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = {
  980. { 0xFF00FF, IR_BUTTON_MODE_BRIGHTER, 1 },
  981. { 0xFF807F, IR_BUTTON_MODE_BRIGHTER, 0 },
  982. { 0xFF40BF, IR_BUTTON_MODE_STATE, 0 },
  983. { 0xFFC03F, IR_BUTTON_MODE_STATE, 1 },
  984. { 0xFF20DF, IR_BUTTON_MODE_RGB, 0xFF0000 },
  985. { 0xFFA05F, IR_BUTTON_MODE_RGB, 0x00FF00 },
  986. { 0xFF609F, IR_BUTTON_MODE_RGB, 0x0000FF },
  987. { 0xFFE01F, IR_BUTTON_MODE_RGB, 0xFFFFFF },
  988. { 0xFF10EF, IR_BUTTON_MODE_RGB, 0xD13A01 },
  989. { 0xFF906F, IR_BUTTON_MODE_RGB, 0x00E644 },
  990. { 0xFF50AF, IR_BUTTON_MODE_RGB, 0x0040A7 },
  991. { 0xFFD02F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FLASH },
  992. { 0xFF30CF, IR_BUTTON_MODE_RGB, 0xE96F2A },
  993. { 0xFFB04F, IR_BUTTON_MODE_RGB, 0x00BEBF },
  994. { 0xFF708F, IR_BUTTON_MODE_RGB, 0x56406F },
  995. { 0xFFF00F, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_STROBE },
  996. { 0xFF08F7, IR_BUTTON_MODE_RGB, 0xEE9819 },
  997. { 0xFF8877, IR_BUTTON_MODE_RGB, 0x00799A },
  998. { 0xFF48B7, IR_BUTTON_MODE_RGB, 0x944E80 },
  999. { 0xFFC837, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_FADE },
  1000. { 0xFF28D7, IR_BUTTON_MODE_RGB, 0xFFFF00 },
  1001. { 0xFFA857, IR_BUTTON_MODE_RGB, 0x0060A1 },
  1002. { 0xFF6897, IR_BUTTON_MODE_RGB, 0xEF45AD },
  1003. { 0xFFE817, IR_BUTTON_MODE_EFFECT, LIGHT_EFFECT_SMOOTH }
  1004. };
  1005. #endif
  1006. #endif // IR_SUPPORT
  1007. //--------------------------------------------------------------------------------
  1008. // Custom RF module
  1009. // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
  1010. // Enable support by passing RF_SUPPORT=1 build flag
  1011. // This module is not compatible with RFBRIDGE
  1012. //--------------------------------------------------------------------------------
  1013. #ifndef RF_SUPPORT
  1014. #define RF_SUPPORT 0
  1015. #endif
  1016. #ifndef RF_PIN
  1017. #define RF_PIN 14
  1018. #endif
  1019. #define RF_DEBOUNCE 500
  1020. #define RF_LEARN_TIMEOUT 60000