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.

406 lines
17 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 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. // DEBUG
  7. //------------------------------------------------------------------------------
  8. // Serial debug log
  9. #ifndef ENABLE_SERIAL_DEBUG
  10. #define ENABLE_SERIAL_DEBUG 1 // Enable serial debug log
  11. #endif
  12. #ifndef DEBUG_PORT
  13. #define DEBUG_PORT Serial // Default debugging port
  14. #endif
  15. //------------------------------------------------------------------------------
  16. // UDP debug log
  17. // To receive the message son the destination computer use nc:
  18. // nc -ul 8111
  19. #ifndef ENABLE_UDP_DEBUG
  20. #define ENABLE_UDP_DEBUG 0 // Enable UDP debug log
  21. #endif
  22. #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100)
  23. #define DEBUG_UDP_PORT 8113
  24. //------------------------------------------------------------------------------
  25. // General debug options and macros
  26. #define DEBUG_MESSAGE_MAX_LENGTH 80
  27. #if ENABLE_SERIAL_DEBUG | ENABLE_UDP_DEBUG
  28. #define DEBUG_MSG(...) debugSend(__VA_ARGS__)
  29. #define DEBUG_MSG_P(...) debugSend_P(__VA_ARGS__)
  30. #endif
  31. #ifndef DEBUG_MSG
  32. #define DEBUG_MSG(...)
  33. #define DEBUG_MSG_P(...)
  34. #endif
  35. //------------------------------------------------------------------------------
  36. // TERMINAL
  37. //------------------------------------------------------------------------------
  38. #ifndef ENABLE_TERMINAL
  39. #define ENABLE_TERMINAL 1 // Enable terminal commands
  40. #endif
  41. //------------------------------------------------------------------------------
  42. // EEPROM
  43. //------------------------------------------------------------------------------
  44. #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte)
  45. #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes)
  46. #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte)
  47. #define EEPROM_DATA_END 6 // End of custom EEPROM data block
  48. //------------------------------------------------------------------------------
  49. // HEARTBEAT
  50. //------------------------------------------------------------------------------
  51. #define HEARTBEAT_INTERVAL 300000 // Interval between heartbeat messages (in ms)
  52. #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value
  53. // Topics that will be reported in heartbeat
  54. #define HEARTBEAT_REPORT_STATUS 1
  55. #define HEARTBEAT_REPORT_IP 1
  56. #define HEARTBEAT_REPORT_MAC 1
  57. #define HEARTBEAT_REPORT_RSSI 1
  58. #define HEARTBEAT_REPORT_UPTIME 1
  59. #define HEARTBEAT_REPORT_FREEHEAP 1
  60. #define HEARTBEAT_REPORT_VCC 1
  61. #define HEARTBEAT_REPORT_RELAY 1
  62. #define HEARTBEAT_REPORT_LIGHT 1
  63. #define HEARTBEAT_REPORT_HOSTNAME 1
  64. #define HEARTBEAT_REPORT_APP 1
  65. #define HEARTBEAT_REPORT_VERSION 1
  66. #define HEARTBEAT_REPORT_INTERVAL 0
  67. //------------------------------------------------------------------------------
  68. // RESET
  69. //------------------------------------------------------------------------------
  70. #define CUSTOM_RESET_HARDWARE 1 // Reset from hardware button
  71. #define CUSTOM_RESET_WEB 2 // Reset from web interface
  72. #define CUSTOM_RESET_TERMINAL 3 // Reset from terminal
  73. #define CUSTOM_RESET_MQTT 4 // Reset via MQTT
  74. #define CUSTOM_RESET_RPC 5 // Reset via RPC (HTTP)
  75. #define CUSTOM_RESET_OTA 6 // Reset after successful OTA update
  76. #define CUSTOM_RESET_NOFUSS 8 // Reset after successful NOFUSS update
  77. #define CUSTOM_RESET_UPGRADE 9 // Reset after update from web interface
  78. #define CUSTOM_RESET_FACTORY 10 // Factory reset from terminal
  79. #define CUSTOM_RESET_MAX 10
  80. #include <pgmspace.h>
  81. PROGMEM const char custom_reset_hardware[] = "Hardware button";
  82. PROGMEM const char custom_reset_web[] = "Reset from web interface";
  83. PROGMEM const char custom_reset_terminal[] = "Reset from terminal";
  84. PROGMEM const char custom_reset_mqtt[] = "Reset from MQTT";
  85. PROGMEM const char custom_reset_rpc[] = "Reset from RPC";
  86. PROGMEM const char custom_reset_ota[] = "Reset after successful OTA update";
  87. PROGMEM const char custom_reset_nofuss[] = "Reset after successful NoFUSS update";
  88. PROGMEM const char custom_reset_upgrade[] = "Reset after successful web update";
  89. PROGMEM const char custom_reset_factory[] = "Factory reset";
  90. PROGMEM const char* const custom_reset_string[] = {
  91. custom_reset_hardware, custom_reset_web, custom_reset_terminal,
  92. custom_reset_mqtt, custom_reset_rpc, custom_reset_ota,
  93. custom_reset_nofuss, custom_reset_upgrade, custom_reset_factory
  94. };
  95. //------------------------------------------------------------------------------
  96. // BUTTON
  97. //------------------------------------------------------------------------------
  98. #define BUTTON_DEBOUNCE_DELAY 50 // Debounce delay (ms)
  99. #define BUTTON_DBLCLICK_DELAY 500 // Time in ms to wait for a second (or third...) click
  100. #define BUTTON_LNGCLICK_DELAY 1000 // Time in ms holding the button down to get a long click
  101. #define BUTTON_LNGLNGCLICK_DELAY 10000 // Time in ms holding the button down to get a long-long click
  102. #define BUTTON_EVENT_NONE 0
  103. #define BUTTON_EVENT_PRESSED 1
  104. #define BUTTON_EVENT_RELEASED 2
  105. #define BUTTON_EVENT_CLICK 2
  106. #define BUTTON_EVENT_DBLCLICK 3
  107. #define BUTTON_EVENT_LNGCLICK 4
  108. #define BUTTON_EVENT_LNGLNGCLICK 5
  109. #define BUTTON_MODE_NONE 0
  110. #define BUTTON_MODE_TOGGLE 1
  111. #define BUTTON_MODE_ON 2
  112. #define BUTTON_MODE_OFF 3
  113. #define BUTTON_MODE_AP 4
  114. #define BUTTON_MODE_RESET 5
  115. #define BUTTON_MODE_PULSE 6
  116. #define BUTTON_MODE_FACTORY 7
  117. //------------------------------------------------------------------------------
  118. // RELAY
  119. //------------------------------------------------------------------------------
  120. #define RELAY_MODE_OFF 0
  121. #define RELAY_MODE_ON 1
  122. #define RELAY_MODE_SAME 2
  123. #define RELAY_MODE_TOOGLE 3
  124. #define RELAY_SYNC_ANY 0
  125. #define RELAY_SYNC_NONE_OR_ONE 1
  126. #define RELAY_SYNC_ONE 2
  127. #define RELAY_SYNC_SAME 3
  128. #define RELAY_PULSE_NONE 0
  129. #define RELAY_PULSE_OFF 1
  130. #define RELAY_PULSE_ON 2
  131. #define RELAY_PROVIDER_RELAY 0
  132. #define RELAY_PROVIDER_DUAL 1
  133. #define RELAY_PROVIDER_LIGHT 2
  134. #define RELAY_PROVIDER_RFBRIDGE 3
  135. // Pulse time in milliseconds
  136. #define RELAY_PULSE_TIME 1.0
  137. // 0 means OFF, 1 ON and 2 whatever was before
  138. #define RELAY_MODE RELAY_MODE_OFF
  139. // 0 means ANY, 1 zero or one and 2 one and only one
  140. #define RELAY_SYNC RELAY_SYNC_ANY
  141. // 0 means no pulses, 1 means normally off, 2 normally on
  142. #define RELAY_PULSE_MODE RELAY_PULSE_NONE
  143. // Relay requests flood protection window - in seconds
  144. #define RELAY_FLOOD_WINDOW 3
  145. // Allowed actual relay changes inside requests flood protection window
  146. #define RELAY_FLOOD_CHANGES 5
  147. //------------------------------------------------------------------------------
  148. // I18N
  149. //------------------------------------------------------------------------------
  150. #define TMP_CELSIUS 0
  151. #define TMP_FAHRENHEIT 1
  152. #define TMP_UNITS TMP_CELSIUS // Temperature units (TMP_CELSIUS | TMP_FAHRENHEIT)
  153. //------------------------------------------------------------------------------
  154. // LED
  155. //------------------------------------------------------------------------------
  156. // All defined LEDs in the board can be managed through MQTT
  157. // except the first one when LED_AUTO is set to 1.
  158. // If LED_AUTO is set to 1 the board will a defined LED to show wifi status.
  159. #define LED_AUTO 1
  160. // LED # to use as WIFI status indicator
  161. #ifndef WIFI_LED
  162. #define WIFI_LED 1
  163. #endif
  164. // -----------------------------------------------------------------------------
  165. // WIFI & WEB
  166. // -----------------------------------------------------------------------------
  167. #define WIFI_CONNECT_TIMEOUT 30000 // Connecting timeout for WIFI in ms
  168. #define WIFI_RECONNECT_INTERVAL 120000 // If could not connect to WIFI, retry after this time in ms
  169. #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
  170. #define HTTP_USERNAME "admin" // HTTP username
  171. #define ADMIN_PASS "fibonacci" // Default password
  172. #define FORCE_CHANGE_PASS 1 // Force the user to change the password if default one
  173. #define WS_BUFFER_SIZE 5 // Max number of secured websocket connections
  174. #define WS_TIMEOUT 1800000 // Timeout for secured websocket
  175. #define WEBSERVER_PORT 80 // HTTP port
  176. #define DNS_PORT 53 // MDNS port
  177. #define ENABLE_MDNS 1 // Enable MDNS by default
  178. #define ENABLE_API 0 // Do not enable API by default
  179. #define API_BUFFER_SIZE 10 // Size of the buffer for HTTP GET API responses
  180. #define WEB_MODE_NORMAL 0
  181. #define WEB_MODE_PASSWORD 1
  182. #define AP_MODE AP_MODE_ALONE
  183. // This option builds the firmware with the web interface embedded.
  184. #ifndef EMBEDDED_WEB
  185. #define EMBEDDED_WEB 1
  186. #endif
  187. // -----------------------------------------------------------------------------
  188. // SPIFFS
  189. // -----------------------------------------------------------------------------
  190. // Do not add support for SPIFFS by default
  191. #ifndef ENABLE_SPIFFS
  192. #define ENABLE_SPIFFS 0
  193. #endif
  194. // -----------------------------------------------------------------------------
  195. // OTA & NOFUSS
  196. // -----------------------------------------------------------------------------
  197. #define OTA_PORT 8266 // OTA port
  198. #define NOFUSS_SERVER "" // Default NoFuss Server
  199. #define NOFUSS_INTERVAL 3600000 // Check for updates every hour
  200. // -----------------------------------------------------------------------------
  201. // MQTT
  202. // -----------------------------------------------------------------------------
  203. #ifndef MQTT_USE_ASYNC
  204. #define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0)
  205. #endif
  206. #define MQTT_SERVER "" // Default MQTT broker address
  207. #define MQTT_PORT 1883 // MQTT broker port
  208. #define MQTT_TOPIC "/test/switch/{identifier}" // Default MQTT base topic
  209. #define MQTT_RETAIN true // MQTT retain flag
  210. #define MQTT_QOS 0 // MQTT QoS value for all messages
  211. #define MQTT_KEEPALIVE 30 // MQTT keepalive value
  212. #define MQTT_RECONNECT_DELAY 10000 // Try to reconnect after 10s
  213. #define MQTT_TRY_INTERVAL 30000 // Timeframe for disconnect retries
  214. #define MQTT_MAX_TRIES 12 // After these many retries during the previous MQTT_TRY_INTERVAL the board will reset
  215. #define MQTT_SKIP_RETAINED 1 // Skip retained messages on connection
  216. #define MQTT_SKIP_TIME 1000 // Skip messages for 1 second anter connection
  217. #define MQTT_USE_JSON 0 // Group messages in a JSON body
  218. #define MQTT_USE_JSON_DELAY 100 // Wait this many ms before grouping messages
  219. // These particles will be concatenated to the MQTT_TOPIC base to form the actual topic
  220. #define MQTT_TOPIC_JSON "data"
  221. #define MQTT_TOPIC_ACTION "action"
  222. #define MQTT_TOPIC_RELAY "relay"
  223. #define MQTT_TOPIC_LED "led"
  224. #define MQTT_TOPIC_BUTTON "button"
  225. #define MQTT_TOPIC_IP "ip"
  226. #define MQTT_TOPIC_VERSION "version"
  227. #define MQTT_TOPIC_UPTIME "uptime"
  228. #define MQTT_TOPIC_FREEHEAP "freeheap"
  229. #define MQTT_TOPIC_VCC "vcc"
  230. #define MQTT_TOPIC_STATUS "status"
  231. #define MQTT_TOPIC_MAC "mac"
  232. #define MQTT_TOPIC_RSSI "rssi"
  233. #define MQTT_TOPIC_APP "app"
  234. #define MQTT_TOPIC_INTERVAL "interval"
  235. #define MQTT_TOPIC_HOSTNAME "host"
  236. #define MQTT_TOPIC_TIME "time"
  237. #define MQTT_TOPIC_ANALOG "analog"
  238. #define MQTT_TOPIC_RFOUT "rfout"
  239. #define MQTT_TOPIC_RFIN "rfin"
  240. #define MQTT_TOPIC_RFLEARN "rflearn"
  241. // Lights
  242. #define MQTT_TOPIC_CHANNEL "channel"
  243. #define MQTT_TOPIC_COLOR "color"
  244. #define MQTT_TOPIC_BRIGHTNESS "brightness"
  245. #define MQTT_TOPIC_MIRED "mired"
  246. #define MQTT_TOPIC_KELVIN "kelvin"
  247. #define MQTT_STATUS_ONLINE "1" // Value for the device ON message
  248. #define MQTT_STATUS_OFFLINE "0" // Value for the device OFF message (will)
  249. #define MQTT_ACTION_RESET "reset" // RESET MQTT topic particle
  250. // Internal MQTT events (do not change)
  251. #define MQTT_CONNECT_EVENT 0
  252. #define MQTT_DISCONNECT_EVENT 1
  253. #define MQTT_MESSAGE_EVENT 2
  254. // Custom get and set postfixes
  255. // Use something like "/status" or "/set", with leading slash
  256. #define MQTT_USE_GETTER ""
  257. #define MQTT_USE_SETTER "/set"
  258. // -----------------------------------------------------------------------------
  259. // I2C
  260. // -----------------------------------------------------------------------------
  261. #define ENABLE_I2C 0 // I2C enabled
  262. #define I2C_SDA_PIN 4 // SDA GPIO
  263. #define I2C_SCL_PIN 14 // SCL GPIO
  264. #define I2C_CLOCK_STRETCH_TIME 200 // BRZO clock stretch time
  265. #define I2C_SCL_FREQUENCY 1000 // BRZO SCL frequency
  266. // -----------------------------------------------------------------------------
  267. // LIGHT
  268. // -----------------------------------------------------------------------------
  269. #define LIGHT_PROVIDER_NONE 0
  270. #define LIGHT_PROVIDER_MY9192 1
  271. #define LIGHT_PROVIDER_DIMMER 2
  272. // LIGHT_PROVIDER_DIMMER can have from 1 to 5 different channels.
  273. // They have to be defined for each device in the hardware.h file.
  274. // If 3 or more channels first 3 will be considered RGB.
  275. // Usual configurations are:
  276. // 1 channels => W
  277. // 2 channels => WW
  278. // 3 channels => RGB
  279. // 4 channels => RGBW
  280. // 5 channels => RGBWW
  281. #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out
  282. #define LIGHT_PWM_FREQUENCY 1000 // PWM frequency
  283. #define LIGHT_MAX_PWM 4095 // Maximum PWM value
  284. #define LIGHT_MAX_VALUE 255 // Maximum light value
  285. #define LIGHT_MAX_BRIGHTNESS 255 // Maximun brightness value
  286. #define LIGHT_USE_COLOR 1 // Use 3 first channels as RGB
  287. #define LIGHT_USE_WHITE 0 // Use white channel whenever RGB have the same value
  288. #define LIGHT_USE_GAMMA 0 // Use gamma correction for color channels
  289. // -----------------------------------------------------------------------------
  290. // DOMOTICZ
  291. // -----------------------------------------------------------------------------
  292. #ifndef ENABLE_DOMOTICZ
  293. #define ENABLE_DOMOTICZ 1 // Build with domoticz support
  294. #endif
  295. #define DOMOTICZ_ENABLED 1 // Enable domoticz by default
  296. #define DOMOTICZ_IN_TOPIC "domoticz/in" // Default subscription topic
  297. #define DOMOTICZ_OUT_TOPIC "domoticz/out" // Default publication topic
  298. // -----------------------------------------------------------------------------
  299. // INFLUXDB
  300. // -----------------------------------------------------------------------------
  301. #ifndef ENABLE_INFLUXDB
  302. #define ENABLE_INFLUXDB 1 // Enable InfluxDB support by default
  303. #endif
  304. #define INFLUXDB_PORT 8086 // Default InfluxDB port
  305. // -----------------------------------------------------------------------------
  306. // NTP
  307. // -----------------------------------------------------------------------------
  308. #define NTP_SERVER "pool.ntp.org" // Default NTP server
  309. #define NTP_TIME_OFFSET 1 // Default timezone offset (GMT+1)
  310. #define NTP_DAY_LIGHT true // Enable daylight time saving by default
  311. #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes
  312. // -----------------------------------------------------------------------------
  313. // FAUXMO
  314. // -----------------------------------------------------------------------------
  315. // This setting defines whether Alexa support should be built into the firmware
  316. #ifndef ENABLE_FAUXMO
  317. #define ENABLE_FAUXMO 1
  318. #endif
  319. // This is default value for the fauxmoEnabled setting that defines whether
  320. // this device should be discoberable and respond to Alexa commands.
  321. // Both ENABLE_FAUXMO and fauxmoEnabled should be 1 for Alexa support to work.
  322. #define FAUXMO_ENABLED 1
  323. // -----------------------------------------------------------------------------
  324. // RFBRIDGE
  325. // -----------------------------------------------------------------------------
  326. #define RF_SEND_TIMES 4 // How many times to send the message
  327. #define RF_SEND_DELAY 250 // Interval between sendings in ms