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.

339 lines
14 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 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 SERIAL_BAUDRATE 115200 // Debugging console boud rate
  9. #define HOSTNAME DEVICE // Hostname
  10. #define HEARTBEAT_INTERVAL 300000 // Report status every 5 minutes
  11. #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
  12. //--------------------------------------------------------------------------------
  13. // DEBUG
  14. //--------------------------------------------------------------------------------
  15. #ifndef DEBUG_PORT
  16. #define DEBUG_PORT Serial // Default debugging port
  17. #endif
  18. // Uncomment and configure these lines to enable remote debug via udpDebug
  19. // To receive the message son the destination computer use nc:
  20. // nc -ul 8111
  21. //#define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  22. //#define DEBUG_UDP_PORT 8111
  23. //--------------------------------------------------------------------------------
  24. // EEPROM
  25. //--------------------------------------------------------------------------------
  26. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  27. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  28. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  29. #define EEPROM_DATA_END 6 // End of custom EEPROM data block
  30. //--------------------------------------------------------------------------------
  31. // RESET
  32. //--------------------------------------------------------------------------------
  33. #define CUSTOM_RESET_HARDWARE 1 // Reset from hardware button
  34. #define CUSTOM_RESET_WEB 2 // Reset from web interface
  35. #define CUSTOM_RESET_TERMINAL 3 // Reset from terminal
  36. #define CUSTOM_RESET_MQTT 4 // Reset via MQTT
  37. #define CUSTOM_RESET_RPC 5 // Reset via RPC (HTTP)
  38. #define CUSTOM_RESET_OTA 6 // Reset after successful OTA update
  39. #define CUSTOM_RESET_NOFUSS 8 // Reset after successful NOFUSS update
  40. #define CUSTOM_RESET_UPGRADE 9 // Reset after update from web interface
  41. #define CUSTOM_RESET_FACTORY 10 // Factory reset from terminal
  42. #define CUSTOM_RESET_MAX 10
  43. #include <pgmspace.h>
  44. PROGMEM const char custom_reset_hardware[] = "Hardware button";
  45. PROGMEM const char custom_reset_web[] = "Reset from web interface";
  46. PROGMEM const char custom_reset_terminal[] = "Reset from terminal";
  47. PROGMEM const char custom_reset_mqtt[] = "Reset from MQTT";
  48. PROGMEM const char custom_reset_rpc[] = "Reset from RPC";
  49. PROGMEM const char custom_reset_ota[] = "Reset after successful OTA update";
  50. PROGMEM const char custom_reset_nofuss[] = "Reset after successful NoFUSS update";
  51. PROGMEM const char custom_reset_upgrade[] = "Reset after successful web update";
  52. PROGMEM const char custom_reset_factory[] = "Factory reset";
  53. PROGMEM const char* const custom_reset_string[] = {
  54. custom_reset_hardware, custom_reset_web, custom_reset_terminal,
  55. custom_reset_mqtt, custom_reset_rpc, custom_reset_ota,
  56. custom_reset_nofuss, custom_reset_upgrade, custom_reset_factory
  57. };
  58. //--------------------------------------------------------------------------------
  59. // BUTTON
  60. //--------------------------------------------------------------------------------
  61. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  62. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  63. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  64. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  65. #define BUTTON_EVENT_NONE 0
  66. #define BUTTON_EVENT_PRESSED 1
  67. #define BUTTON_EVENT_CLICK 2
  68. #define BUTTON_EVENT_DBLCLICK 3
  69. #define BUTTON_EVENT_LNGCLICK 4
  70. #define BUTTON_EVENT_LNGLNGCLICK 5
  71. #define BUTTON_MODE_NONE 0
  72. #define BUTTON_MODE_TOGGLE 1
  73. #define BUTTON_MODE_AP 2
  74. #define BUTTON_MODE_RESET 3
  75. #define BUTTON_MODE_PULSE 4
  76. #define BUTTON_MODE_FACTORY 5
  77. //--------------------------------------------------------------------------------
  78. // RELAY
  79. //--------------------------------------------------------------------------------
  80. #define RELAY_MODE_OFF 0
  81. #define RELAY_MODE_ON 1
  82. #define RELAY_MODE_SAME 2
  83. #define RELAY_MODE_TOOGLE 3
  84. #define RELAY_SYNC_ANY 0
  85. #define RELAY_SYNC_NONE_OR_ONE 1
  86. #define RELAY_SYNC_ONE 2
  87. #define RELAY_SYNC_SAME 3
  88. #define RELAY_PULSE_NONE 0
  89. #define RELAY_PULSE_OFF 1
  90. #define RELAY_PULSE_ON 2
  91. #define RELAY_PROVIDER_RELAY 0
  92. #define RELAY_PROVIDER_DUAL 1
  93. #define RELAY_PROVIDER_LIGHT 2
  94. // Pulse time in milliseconds
  95. #define RELAY_PULSE_TIME 1.0
  96. // 0 means OFF, 1 ON and 2 whatever was before
  97. #define RELAY_MODE RELAY_MODE_OFF
  98. // 0 means ANY, 1 zero or one and 2 one and only one
  99. #define RELAY_SYNC RELAY_SYNC_ANY
  100. // 0 means no pulses, 1 means normally off, 2 normally on
  101. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  102. // Relay requests flood protection window - in seconds
  103. #define RELAY_FLOOD_WINDOW 3
  104. // Allowed actual relay changes inside requests flood protection window
  105. #define RELAY_FLOOD_CHANGES 5
  106. //--------------------------------------------------------------------------------
  107. // I18N
  108. //--------------------------------------------------------------------------------
  109. #define TMP_CELSIUS 0
  110. #define TMP_FAHRENHEIT 1
  111. #define TMP_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
  112. //--------------------------------------------------------------------------------
  113. // LED
  114. //--------------------------------------------------------------------------------
  115. // All defined LEDs in the board can be managed through MQTT
  116. // except the first one when LED_AUTO is set to 1.
  117. // If LED_AUTO is set to 1 the board will use first defined LED to show wifi status.
  118. #define LED_AUTO 1
  119. // -----------------------------------------------------------------------------
  120. // WIFI & WEB
  121. // -----------------------------------------------------------------------------
  122. #define WIFI_CONNECT_TIMEOUT 30000 // Connecting timeout for WIFI in ms
  123. #define WIFI_RECONNECT_INTERVAL 120000 // If could not connect to WIFI, retry after this time in ms
  124. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  125. #define HTTP_USERNAME "admin" // HTTP username
  126. #define ADMIN_PASS "fibonacci" // Default password
  127. #define FORCE_CHANGE_PASS 1 // Force the user to change the password if default one
  128. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  129. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  130. #define WEBSERVER_PORT 80 // HTTP port
  131. #define DNS_PORT 53 // MDNS port
  132. #define ENABLE_MDNS 1 // Enabled MDNS
  133. #define WEB_MODE_NORMAL 0
  134. #define WEB_MODE_PASSWORD 1
  135. #define AP_MODE AP_MODE_ALONE
  136. // This option builds the firmware with the web interface embedded.
  137. #ifndef EMBEDDED_WEB
  138. #define EMBEDDED_WEB 1
  139. #endif
  140. // -----------------------------------------------------------------------------
  141. // OTA & NOFUSS
  142. // -----------------------------------------------------------------------------
  143. #define OTA_PORT 8266 // OTA port
  144. #define NOFUSS_SERVER "" // Default NoFuss Server
  145. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  146. // -----------------------------------------------------------------------------
  147. // MQTT
  148. // -----------------------------------------------------------------------------
  149. #ifndef MQTT_USE_ASYNC
  150. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  151. #endif
  152. #define MQTT_SERVER "" // Default MQTT broker address
  153. #define MQTT_PORT 1883 // MQTT broker port
  154. #define MQTT_TOPIC "/test/switch/{identifier}" // Default MQTT base topic
  155. #define MQTT_RETAIN true // MQTT retain flag
  156. #define MQTT_QOS 0 // MQTT QoS value for all messages
  157. #define MQTT_KEEPALIVE 30 // MQTT keepalive value
  158. #define MQTT_RECONNECT_DELAY 10000 // Try to reconnect after 10s
  159. #define MQTT_TRY_INTERVAL 30000 // Timeframe for disconnect retries
  160. #define MQTT_MAX_TRIES 12 // After these many retries during the previous MQTT_TRY_INTERVAL the board will reset
  161. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  162. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  163. #define MQTT_USE_JSON 0 // Group messages in a JSON body
  164. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  165. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  166. #define MQTT_TOPIC_JSON "data"
  167. #define MQTT_TOPIC_ACTION "action"
  168. #define MQTT_TOPIC_RELAY "relay"
  169. #define MQTT_TOPIC_LED "led"
  170. #define MQTT_TOPIC_COLOR "color"
  171. #define MQTT_TOPIC_BUTTON "button"
  172. #define MQTT_TOPIC_IP "ip"
  173. #define MQTT_TOPIC_VERSION "version"
  174. #define MQTT_TOPIC_UPTIME "uptime"
  175. #define MQTT_TOPIC_FREEHEAP "freeheap"
  176. #define MQTT_TOPIC_VCC "vcc"
  177. #define MQTT_TOPIC_STATUS "status"
  178. #define MQTT_TOPIC_MAC "mac"
  179. #define MQTT_TOPIC_RSSI "rssi"
  180. #define MQTT_TOPIC_APP "app"
  181. #define MQTT_TOPIC_INTERVAL "interval"
  182. #define MQTT_TOPIC_HOSTNAME "host"
  183. #define MQTT_TOPIC_TIME "time"
  184. #define MQTT_TOPIC_ANALOG "analog"
  185. // These massages will be reported on heartbeat
  186. #define MQTT_REPORT_STATUS 1
  187. #define MQTT_REPORT_IP 1
  188. #define MQTT_REPORT_MAC 1
  189. #define MQTT_REPORT_RSSI 1
  190. #define MQTT_REPORT_UPTIME 1
  191. #define MQTT_REPORT_FREEHEAP 1
  192. #define MQTT_REPORT_VCC 1
  193. #define MQTT_REPORT_RELAY 1
  194. #define MQTT_REPORT_COLOR 1
  195. #define MQTT_REPORT_HOSTNAME 1
  196. #define MQTT_REPORT_APP 1
  197. #define MQTT_REPORT_VERSION 1
  198. #define MQTT_REPORT_INTERVAL 0
  199. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  200. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  201. #define MQTT_ACTION_RESET "reset" // RESET MQTT topic particle
  202. // Internal MQTT events (do not change)
  203. #define MQTT_CONNECT_EVENT 0
  204. #define MQTT_DISCONNECT_EVENT 1
  205. #define MQTT_MESSAGE_EVENT 2
  206. // Custom get and set postfixes
  207. // Use something like "/status" or "/set", with leading slash
  208. #define MQTT_USE_GETTER ""
  209. #define MQTT_USE_SETTER ""
  210. // -----------------------------------------------------------------------------
  211. // I2C
  212. // -----------------------------------------------------------------------------
  213. #define ENABLE_I2C 0 // I2C enabled
  214. #define I2C_SDA_PIN 4 // SDA GPIO
  215. #define I2C_SCL_PIN 14 // SCL GPIO
  216. #define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
  217. #define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
  218. // -----------------------------------------------------------------------------
  219. // LIGHT
  220. // -----------------------------------------------------------------------------
  221. #define ENABLE_GAMMA_CORRECTION 0
  222. #define LIGHT_PROVIDER_NONE 0
  223. #define LIGHT_PROVIDER_WS2812 1
  224. #define LIGHT_PROVIDER_RGB 2
  225. #define LIGHT_PROVIDER_RGBW 3
  226. #define LIGHT_PROVIDER_MY9192 4
  227. #define LIGHT_PROVIDER_RGB2W 5
  228. #define LIGHT_DEFAULT_COLOR "#000080"
  229. #define LIGHT_SAVE_DELAY 5
  230. #define LIGHT_MAX_VALUE 255
  231. // Settings for MY9291 bulbs (AI Light)
  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 // Enable Domoticz support by default
  246. #endif
  247. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  248. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  249. // -----------------------------------------------------------------------------
  250. // INFLUXDB
  251. // -----------------------------------------------------------------------------
  252. #ifndef ENABLE_INFLUXDB
  253. #define ENABLE_INFLUXDB 1 // Enable InfluxDB support by default
  254. #endif
  255. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  256. // -----------------------------------------------------------------------------
  257. // NTP
  258. // -----------------------------------------------------------------------------
  259. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  260. #define NTP_TIME_OFFSET 1 // Default timezone offset (GMT+1)
  261. #define NTP_DAY_LIGHT true // Enable daylight time saving by default
  262. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  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