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.

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