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.

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