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.

340 lines
12 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
7 years ago
8 years ago
8 years ago
  1. //------------------------------------------------------------------------------
  2. // GENERAL
  3. //------------------------------------------------------------------------------
  4. #define SERIAL_BAUDRATE 115200
  5. #define HOSTNAME DEVICE
  6. #define BUFFER_SIZE 1024
  7. #define HEARTBEAT_INTERVAL 300000
  8. #define UPTIME_OVERFLOW 4294967295
  9. //--------------------------------------------------------------------------------
  10. // DEBUG
  11. //--------------------------------------------------------------------------------
  12. #ifndef DEBUG_PORT
  13. #define DEBUG_PORT Serial
  14. #endif
  15. // Uncomment and configure these lines to enable remote debug via udpDebug
  16. // To receive the message son the destination computer use nc:
  17. // nc -ul 8111
  18. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  19. #define DEBUG_UDP_PORT 8113
  20. //--------------------------------------------------------------------------------
  21. // EEPROM
  22. //--------------------------------------------------------------------------------
  23. #define EEPROM_RELAY_STATUS 0
  24. #define EEPROM_ENERGY_COUNT 1
  25. #define EEPROM_CUSTOM_RESET 5
  26. #define EEPROM_DATA_END 6
  27. //--------------------------------------------------------------------------------
  28. // RESET
  29. //--------------------------------------------------------------------------------
  30. #define CUSTOM_RESET_HARDWARE 1
  31. #define CUSTOM_RESET_WEB 2
  32. #define CUSTOM_RESET_TERMINAL 3
  33. #define CUSTOM_RESET_MQTT 4
  34. #define CUSTOM_RESET_RPC 5
  35. #define CUSTOM_RESET_OTA 6
  36. #define CUSTOM_RESET_NOFUSS 8
  37. #define CUSTOM_RESET_UPGRADE 9
  38. #define CUSTOM_RESET_FACTORY 10
  39. #define CUSTOM_RESET_MAX 10
  40. #include <pgmspace.h>
  41. PROGMEM const char custom_reset_hardware[] = "Hardware button";
  42. PROGMEM const char custom_reset_web[] = "Reset from web interface";
  43. PROGMEM const char custom_reset_terminal[] = "Reset from terminal";
  44. PROGMEM const char custom_reset_mqtt[] = "Reset from MQTT";
  45. PROGMEM const char custom_reset_rpc[] = "Reset from RPC";
  46. PROGMEM const char custom_reset_ota[] = "Reset after successful OTA update";
  47. PROGMEM const char custom_reset_nofuss[] = "Reset after successful NoFUSS update";
  48. PROGMEM const char custom_reset_upgrade[] = "Reset after successful web update";
  49. PROGMEM const char custom_reset_factory[] = "Factory reset";
  50. PROGMEM const char* const custom_reset_string[] = {
  51. custom_reset_hardware, custom_reset_web, custom_reset_terminal,
  52. custom_reset_mqtt, custom_reset_rpc, custom_reset_ota,
  53. custom_reset_nofuss, custom_reset_upgrade, custom_reset_factory
  54. };
  55. //--------------------------------------------------------------------------------
  56. // BUTTON
  57. //--------------------------------------------------------------------------------
  58. #define BUTTON_DEBOUNCE_DELAY 50
  59. #define BUTTON_DBLCLICK_DELAY 500
  60. #define BUTTON_LNGCLICK_DELAY 1000
  61. #define BUTTON_LNGLNGCLICK_DELAY 10000
  62. #define BUTTON_EVENT_NONE 0
  63. #define BUTTON_EVENT_PRESSED 1
  64. #define BUTTON_EVENT_CLICK 2
  65. #define BUTTON_EVENT_DBLCLICK 3
  66. #define BUTTON_EVENT_LNGCLICK 4
  67. #define BUTTON_EVENT_LNGLNGCLICK 5
  68. #define BUTTON_MODE_NONE 0
  69. #define BUTTON_MODE_TOGGLE 1
  70. #define BUTTON_MODE_AP 2
  71. #define BUTTON_MODE_RESET 3
  72. #define BUTTON_MODE_PULSE 4
  73. #define BUTTON_MODE_FACTORY 5
  74. #define BUTTON_DEFAULT_MODE BUTTON_MODE_TOGGLE
  75. //--------------------------------------------------------------------------------
  76. // RELAY
  77. //--------------------------------------------------------------------------------
  78. #define RELAY_MODE_OFF 0
  79. #define RELAY_MODE_ON 1
  80. #define RELAY_MODE_SAME 2
  81. #define RELAY_MODE_TOOGLE 3
  82. #define RELAY_SYNC_ANY 0
  83. #define RELAY_SYNC_NONE_OR_ONE 1
  84. #define RELAY_SYNC_ONE 2
  85. #define RELAY_SYNC_SAME 3
  86. #define RELAY_PULSE_NONE 0
  87. #define RELAY_PULSE_OFF 1
  88. #define RELAY_PULSE_ON 2
  89. #define RELAY_PROVIDER_RELAY 0
  90. #define RELAY_PROVIDER_DUAL 1
  91. #define RELAY_PROVIDER_LIGHT 2
  92. #define RELAY_PROVIDER_RFBRIDGE 3
  93. // Pulse time in milliseconds
  94. #define RELAY_PULSE_TIME 1.0
  95. // 0 means OFF, 1 ON and 2 whatever was before
  96. #define RELAY_MODE RELAY_MODE_OFF
  97. // 0 means ANY, 1 zero or one and 2 one and only one
  98. #define RELAY_SYNC RELAY_SYNC_ANY
  99. // 0 means no pulses, 1 means normally off, 2 normally on
  100. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  101. // Relay requests flood protection window - in seconds
  102. #define RELAY_FLOOD_WINDOW 3
  103. // Allowed actual relay changes inside requests flood protection window
  104. #define RELAY_FLOOD_CHANGES 5
  105. //--------------------------------------------------------------------------------
  106. // I18N
  107. //--------------------------------------------------------------------------------
  108. #define TMP_CELSIUS 0
  109. #define TMP_FAHRENHEIT 1
  110. #define TMP_UNITS TMP_CELSIUS
  111. //--------------------------------------------------------------------------------
  112. // LED
  113. //--------------------------------------------------------------------------------
  114. // All defined LEDs in the board can be managed through MQTT
  115. // except the first one when LED_AUTO is set to 1.
  116. // If LED_AUTO is set to 1 the board will use first defined LED to show wifi status.
  117. #define LED_AUTO 1
  118. // -----------------------------------------------------------------------------
  119. // WIFI & WEB
  120. // -----------------------------------------------------------------------------
  121. #define WIFI_RECONNECT_INTERVAL 120000
  122. #define WIFI_CONNECT_TIMEOUT 30000
  123. #define WIFI_MAX_NETWORKS 5
  124. #define ADMIN_PASS "fibonacci"
  125. #define FORCE_CHANGE_PASS 1
  126. #define HTTP_USERNAME "admin"
  127. #define WS_BUFFER_SIZE 5
  128. #define WS_TIMEOUT 1800000
  129. #define WEBSERVER_PORT 80
  130. #define DNS_PORT 53
  131. #define ENABLE_MDNS 1
  132. #define WEB_MODE_NORMAL 0
  133. #define WEB_MODE_PASSWORD 1
  134. #define AP_MODE AP_MODE_ALONE
  135. // This option builds the firmware with the web interface embedded.
  136. // You first have to build the data.h file that holds the contents
  137. // of the web interface by running "gulp buildfs_embed"
  138. #ifndef EMBEDDED_WEB
  139. #define EMBEDDED_WEB 1
  140. #endif
  141. // -----------------------------------------------------------------------------
  142. // OTA & NOFUSS
  143. // -----------------------------------------------------------------------------
  144. #define OTA_PORT 8266
  145. #define NOFUSS_SERVER ""
  146. #define NOFUSS_INTERVAL 3600000
  147. // -----------------------------------------------------------------------------
  148. // MQTT
  149. // -----------------------------------------------------------------------------
  150. #ifndef MQTT_USE_ASYNC
  151. #define MQTT_USE_ASYNC 1
  152. #endif
  153. #define MQTT_SERVER ""
  154. #define MQTT_PORT 1883
  155. #define MQTT_TOPIC "/test/switch/{identifier}"
  156. #define MQTT_RETAIN true
  157. #define MQTT_QOS 0
  158. #define MQTT_KEEPALIVE 30
  159. #define MQTT_RECONNECT_DELAY 10000
  160. #define MQTT_TRY_INTERVAL 30000
  161. #define MQTT_MAX_TRIES 12
  162. #define MQTT_SKIP_RETAINED 1
  163. #define MQTT_SKIP_TIME 1000
  164. #define MQTT_USE_JSON 0
  165. #define MQTT_TOPIC_JSON "data"
  166. #define MQTT_TOPIC_ACTION "action"
  167. #define MQTT_TOPIC_RELAY "relay"
  168. #define MQTT_TOPIC_LED "led"
  169. #define MQTT_TOPIC_COLOR "color"
  170. #define MQTT_TOPIC_BUTTON "button"
  171. #define MQTT_TOPIC_IP "ip"
  172. #define MQTT_TOPIC_VERSION "version"
  173. #define MQTT_TOPIC_UPTIME "uptime"
  174. #define MQTT_TOPIC_FREEHEAP "freeheap"
  175. #define MQTT_TOPIC_VCC "vcc"
  176. #define MQTT_TOPIC_STATUS "status"
  177. #define MQTT_TOPIC_MAC "mac"
  178. #define MQTT_TOPIC_RSSI "rssi"
  179. #define MQTT_TOPIC_APP "app"
  180. #define MQTT_TOPIC_INTERVAL "interval"
  181. #define MQTT_TOPIC_HOSTNAME "host"
  182. #define MQTT_TOPIC_TIME "time"
  183. #define MQTT_TOPIC_ANALOG "analog"
  184. #define MQTT_TOPIC_RFOUT "rfout"
  185. #define MQTT_TOPIC_RFIN "rfin"
  186. #define MQTT_TOPIC_RFLEARN "rflearn"
  187. // Periodic reports
  188. #define MQTT_REPORT_STATUS 1
  189. #define MQTT_REPORT_IP 1
  190. #define MQTT_REPORT_MAC 1
  191. #define MQTT_REPORT_RSSI 1
  192. #define MQTT_REPORT_UPTIME 1
  193. #define MQTT_REPORT_FREEHEAP 1
  194. #define MQTT_REPORT_VCC 1
  195. #define MQTT_REPORT_RELAY 1
  196. #define MQTT_REPORT_COLOR 1
  197. #define MQTT_REPORT_HOSTNAME 1
  198. #define MQTT_REPORT_APP 1
  199. #define MQTT_REPORT_VERSION 1
  200. #define MQTT_REPORT_INTERVAL 0
  201. #define MQTT_STATUS_ONLINE "1"
  202. #define MQTT_STATUS_OFFLINE "0"
  203. #define MQTT_ACTION_RESET "reset"
  204. #define MQTT_CONNECT_EVENT 0
  205. #define MQTT_DISCONNECT_EVENT 1
  206. #define MQTT_MESSAGE_EVENT 2
  207. // Custom get and set postfixes6+
  208. // Use something like "/status" or "/set", with leading slash
  209. #define MQTT_USE_GETTER ""
  210. #define MQTT_USE_SETTER ""
  211. // -----------------------------------------------------------------------------
  212. // I2C
  213. // -----------------------------------------------------------------------------
  214. #define ENABLE_I2C 0
  215. #define I2C_SDA_PIN 4
  216. #define I2C_SCL_PIN 14
  217. #define I2C_CLOCK_STRETCH_TIME 200
  218. #define I2C_SCL_FREQUENCY 1000
  219. // -----------------------------------------------------------------------------
  220. // LIGHT
  221. // -----------------------------------------------------------------------------
  222. #define ENABLE_GAMMA_CORRECTION 0
  223. #define LIGHT_PROVIDER_NONE 0
  224. #define LIGHT_PROVIDER_WS2812 1
  225. #define LIGHT_PROVIDER_RGB 2
  226. #define LIGHT_PROVIDER_RGBW 3
  227. #define LIGHT_PROVIDER_MY9192 4
  228. #define LIGHT_PROVIDER_RGB2W 5
  229. #define LIGHT_DEFAULT_COLOR "#000080"
  230. #define LIGHT_SAVE_DELAY 5
  231. #define LIGHT_MAX_VALUE 255
  232. #define MY9291_DI_PIN 13
  233. #define MY9291_DCKI_PIN 15
  234. #define MY9291_COMMAND MY9291_COMMAND_DEFAULT
  235. // Shared settings between RGB and RGBW lights
  236. #define RGBW_INVERSE_LOGIC 1
  237. #define RGBW_RED_PIN 14
  238. #define RGBW_GREEN_PIN 5
  239. #define RGBW_BLUE_PIN 12
  240. #define RGBW_WHITE_PIN 13
  241. // -----------------------------------------------------------------------------
  242. // DOMOTICZ
  243. // -----------------------------------------------------------------------------
  244. #ifndef ENABLE_DOMOTICZ
  245. #define ENABLE_DOMOTICZ 1
  246. #endif
  247. #define DOMOTICZ_IN_TOPIC "domoticz/in"
  248. #define DOMOTICZ_OUT_TOPIC "domoticz/out"
  249. // -----------------------------------------------------------------------------
  250. // INFLUXDB
  251. // -----------------------------------------------------------------------------
  252. #ifndef ENABLE_INFLUXDB
  253. #define ENABLE_INFLUXDB 1
  254. #endif
  255. #define INFLUXDB_PORT 8086
  256. // -----------------------------------------------------------------------------
  257. // NTP
  258. // -----------------------------------------------------------------------------
  259. #define NTP_SERVER "pool.ntp.org"
  260. #define NTP_TIME_OFFSET 1
  261. #define NTP_DAY_LIGHT true
  262. #define NTP_UPDATE_INTERVAL 1800
  263. // -----------------------------------------------------------------------------
  264. // FAUXMO
  265. // -----------------------------------------------------------------------------
  266. // This setting defines whether Alexa support should be built into the firmware
  267. #ifndef ENABLE_FAUXMO
  268. #define ENABLE_FAUXMO 1
  269. #endif
  270. // This is default value for the fauxmoEnabled setting that defines whether
  271. // this device should be discoberable and respond to Alexa commands.
  272. // Both ENABLE_FAUXMO and fauxmoEnabled should be 1 for Alexa support to work.
  273. #define FAUXMO_ENABLED 1