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.

655 lines
15 KiB

  1. /*
  2. BOARD MODULE
  3. */
  4. #include "board.h"
  5. //--------------------------------------------------------------------------------
  6. PROGMEM const char espurna_modules[] =
  7. #if ALEXA_SUPPORT
  8. "ALEXA "
  9. #endif
  10. #if API_SUPPORT
  11. "API "
  12. #endif
  13. #if BROKER_SUPPORT
  14. "BROKER "
  15. #endif
  16. #if BUTTON_SUPPORT
  17. #if BUTTON_EVENTS_SOURCE == BUTTON_EVENTS_SOURCE_GENERIC
  18. "BUTTON "
  19. #else
  20. "BUTTON_DUAL "
  21. #endif
  22. #endif
  23. #if DEBUG_SERIAL_SUPPORT
  24. "DEBUG_SERIAL "
  25. #endif
  26. #if DEBUG_TELNET_SUPPORT
  27. "DEBUG_TELNET "
  28. #endif
  29. #if DEBUG_UDP_SUPPORT
  30. "DEBUG_UDP "
  31. #endif
  32. #if DEBUG_WEB_SUPPORT
  33. "DEBUG_WEB "
  34. #endif
  35. #if DOMOTICZ_SUPPORT
  36. "DOMOTICZ "
  37. #endif
  38. #if ENCODER_SUPPORT
  39. "ENCODER "
  40. #endif
  41. #if HOMEASSISTANT_SUPPORT
  42. "HOMEASSISTANT "
  43. #endif
  44. #if I2C_SUPPORT
  45. "I2C "
  46. #endif
  47. #if INFLUXDB_SUPPORT
  48. "INFLUXDB "
  49. #endif
  50. #if IR_SUPPORT
  51. "IR "
  52. #endif
  53. #if LED_SUPPORT
  54. "LED "
  55. #endif
  56. #if LLMNR_SUPPORT
  57. "LLMNR "
  58. #endif
  59. #if MDNS_CLIENT_SUPPORT
  60. "MDNS_CLIENT "
  61. #endif
  62. #if MDNS_SERVER_SUPPORT
  63. "MDNS_SERVER "
  64. #endif
  65. #if MQTT_SUPPORT
  66. "MQTT "
  67. #endif
  68. #if NETBIOS_SUPPORT
  69. "NETBIOS "
  70. #endif
  71. #if NOFUSS_SUPPORT
  72. "NOFUSS "
  73. #endif
  74. #if NTP_SUPPORT
  75. "NTP "
  76. #endif
  77. #if RFM69_SUPPORT
  78. "RFM69 "
  79. #endif
  80. #if RF_SUPPORT
  81. "RF "
  82. #endif
  83. #if RPN_RULES_SUPPORT
  84. "RPN_RULES "
  85. #endif
  86. #if SCHEDULER_SUPPORT
  87. "SCHEDULER "
  88. #endif
  89. #if SENSOR_SUPPORT
  90. "SENSOR "
  91. #endif
  92. #if SPIFFS_SUPPORT
  93. "SPIFFS "
  94. #endif
  95. #if SSDP_SUPPORT
  96. "SSDP "
  97. #endif
  98. #if TELNET_SUPPORT
  99. #if TELNET_SERVER == TELNET_SERVER_WIFISERVER
  100. "TELNET_SYNC "
  101. #else
  102. "TELNET "
  103. #endif // TELNET_SERVER == TELNET_SERVER_WIFISERVER
  104. #endif
  105. #if TERMINAL_SUPPORT
  106. "TERMINAL "
  107. #endif
  108. #if THERMOSTAT_SUPPORT
  109. "THERMOSTAT "
  110. #endif
  111. #if THERMOSTAT_DISPLAY_SUPPORT
  112. "THERMOSTAT_DISPLAY "
  113. #endif
  114. #if THINGSPEAK_SUPPORT
  115. "THINGSPEAK "
  116. #endif
  117. #if UART_MQTT_SUPPORT
  118. "UART_MQTT "
  119. #endif
  120. #if WEB_SUPPORT
  121. "WEB "
  122. #endif
  123. "";
  124. PROGMEM const char espurna_ota_modules[] =
  125. #if OTA_ARDUINOOTA_SUPPORT
  126. "ARDUINO "
  127. #endif
  128. #if (OTA_CLIENT == OTA_CLIENT_ASYNCTCP)
  129. "ASYNCTCP "
  130. #endif
  131. #if (OTA_CLIENT == OTA_CLIENT_HTTPUPDATE)
  132. #if (SECURE_CLIENT == SECURE_CLIENT_NONE)
  133. "*HTTPUPDATE "
  134. #endif
  135. #if (SECURE_CLIENT == SECURE_CLIENT_AXTLS)
  136. "*HTTPUPDATE_AXTLS "
  137. #endif
  138. #if (SECURE_CLIENT == SECURE_CLIENT_BEARSSL)
  139. "*HTTPUPDATE_BEARSSL "
  140. #endif
  141. #endif // OTA_CLIENT_HTTPUPDATE
  142. #if OTA_MQTT_SUPPORT
  143. "MQTT "
  144. #endif
  145. #if WEB_SUPPORT
  146. "WEB "
  147. #endif
  148. "";
  149. PROGMEM const char espurna_webui[] =
  150. #if WEBUI_IMAGE == WEBUI_IMAGE_SMALL
  151. "SMALL"
  152. #endif
  153. #if WEBUI_IMAGE == WEBUI_IMAGE_LIGHT
  154. "LIGHT"
  155. #endif
  156. #if WEBUI_IMAGE == WEBUI_IMAGE_SENSOR
  157. "SENSOR"
  158. #endif
  159. #if WEBUI_IMAGE == WEBUI_IMAGE_RFBRIDGE
  160. "RFBRIDGE"
  161. #endif
  162. #if WEBUI_IMAGE == WEBUI_IMAGE_RFM69
  163. "RFM69"
  164. #endif
  165. #if WEBUI_IMAGE == WEBUI_IMAGE_LIGHTFOX
  166. "LIGHTFOX"
  167. #endif
  168. #if WEBUI_IMAGE == WEBUI_IMAGE_THERMOSTAT
  169. "THERMOSTAT"
  170. #endif
  171. #if WEBUI_IMAGE == WEBUI_IMAGE_FULL
  172. "FULL"
  173. #endif
  174. "";
  175. #if SENSOR_SUPPORT
  176. PROGMEM const char espurna_sensors[] =
  177. #if AM2320_SUPPORT
  178. "AM2320_I2C "
  179. #endif
  180. #if ANALOG_SUPPORT
  181. "ANALOG "
  182. #endif
  183. #if BH1750_SUPPORT
  184. "BH1750 "
  185. #endif
  186. #if BMP180_SUPPORT
  187. "BMP180 "
  188. #endif
  189. #if BMX280_SUPPORT
  190. "BMX280 "
  191. #endif
  192. #if CSE7766_SUPPORT
  193. "CSE7766 "
  194. #endif
  195. #if DALLAS_SUPPORT
  196. "DALLAS "
  197. #endif
  198. #if DHT_SUPPORT
  199. "DHTXX "
  200. #endif
  201. #if DIGITAL_SUPPORT
  202. "DIGITAL "
  203. #endif
  204. #if ECH1560_SUPPORT
  205. "ECH1560 "
  206. #endif
  207. #if EMON_ADC121_SUPPORT
  208. "EMON_ADC121 "
  209. #endif
  210. #if EMON_ADS1X15_SUPPORT
  211. "EMON_ADX1X15 "
  212. #endif
  213. #if EMON_ANALOG_SUPPORT
  214. "EMON_ANALOG "
  215. #endif
  216. #if EVENTS_SUPPORT
  217. "EVENTS "
  218. #endif
  219. #if GEIGER_SUPPORT
  220. "GEIGER "
  221. #endif
  222. #if GUVAS12SD_SUPPORT
  223. "GUVAS12SD "
  224. #endif
  225. #if HLW8012_SUPPORT
  226. "HLW8012 "
  227. #endif
  228. #if LDR_SUPPORT
  229. "LDR "
  230. #endif
  231. #if MHZ19_SUPPORT
  232. "MHZ19 "
  233. #endif
  234. #if MICS2710_SUPPORT
  235. "MICS2710 "
  236. #endif
  237. #if MICS5525_SUPPORT
  238. "MICS5525 "
  239. #endif
  240. #if NTC_SUPPORT
  241. "NTC "
  242. #endif
  243. #if PMSX003_SUPPORT
  244. "PMSX003 "
  245. #endif
  246. #if PULSEMETER_SUPPORT
  247. "PULSEMETER "
  248. #endif
  249. #if PZEM004T_SUPPORT
  250. "PZEM004T "
  251. #endif
  252. #if SDS011_SUPPORT
  253. "SDS011 "
  254. #endif
  255. #if SENSEAIR_SUPPORT
  256. "SENSEAIR "
  257. #endif
  258. #if SHT3X_I2C_SUPPORT
  259. "SHT3X_I2C "
  260. #endif
  261. #if SI7021_SUPPORT
  262. "SI7021 "
  263. #endif
  264. #if SONAR_SUPPORT
  265. "SONAR "
  266. #endif
  267. #if T6613_SUPPORT
  268. "T6613 "
  269. #endif
  270. #if TMP3X_SUPPORT
  271. "TMP3X "
  272. #endif
  273. #if V9261F_SUPPORT
  274. "V9261F "
  275. #endif
  276. #if VEML6075_SUPPORT
  277. "VEML6075 "
  278. #endif
  279. #if VL53L1X_SUPPORT
  280. "VL53L1X "
  281. #endif
  282. #if EZOPH_SUPPORT
  283. "EZOPH "
  284. #endif
  285. #if ADE7953_SUPPORT
  286. "ADE7953 "
  287. #endif
  288. "";
  289. #endif // SENSOR_SUPPORT == 1
  290. //--------------------------------------------------------------------------------
  291. String getIdentifier() {
  292. char buffer[20];
  293. snprintf_P(buffer, sizeof(buffer), PSTR("%s-%06X"), APP_NAME, ESP.getChipId());
  294. return String(buffer);
  295. }
  296. String getEspurnaModules() {
  297. return FPSTR(espurna_modules);
  298. }
  299. String getEspurnaOTAModules() {
  300. return FPSTR(espurna_ota_modules);
  301. }
  302. #if SENSOR_SUPPORT
  303. String getEspurnaSensors() {
  304. return FPSTR(espurna_sensors);
  305. }
  306. #endif // SENSOR_SUPPORT == 1
  307. String getEspurnaWebUI() {
  308. return FPSTR(espurna_webui);
  309. }
  310. bool haveRelaysOrSensors() {
  311. bool result = false;
  312. result = (relayCount() > 0);
  313. #if SENSOR_SUPPORT
  314. result = result || (magnitudeCount() > 0);
  315. #endif
  316. return result;
  317. }
  318. int getBoardId() {
  319. #if defined(ESPURNA_CORE)
  320. return 0;
  321. #elif defined(ESPURNA_BASE)
  322. return 1;
  323. #elif defined(NODEMCU_LOLIN)
  324. return 2;
  325. #elif defined(NODEMCU_BASIC)
  326. return 3;
  327. #elif defined(WEMOS_D1_MINI)
  328. return 4;
  329. #elif defined(WEMOS_D1_MINI_RELAYSHIELD)
  330. return 5;
  331. #elif defined(WEMOS_D1_TARPUNA_SHIELD)
  332. return 6;
  333. #elif defined(TINKERMAN_ESPURNA_H06)
  334. return 7;
  335. #elif defined(TINKERMAN_ESPURNA_H08)
  336. return 8;
  337. #elif defined(TINKERMAN_ESPURNA_SWITCH)
  338. return 9;
  339. #elif defined(TINKERMAN_RFM69GW)
  340. return 10;
  341. #elif defined(ITEAD_SONOFF_BASIC)
  342. return 11;
  343. #elif defined(ITEAD_SONOFF_RF)
  344. return 12;
  345. #elif defined(ITEAD_SONOFF_MINI)
  346. return 13;
  347. #elif defined(ITEAD_SONOFF_TH)
  348. return 14;
  349. #elif defined(ITEAD_SONOFF_SV)
  350. return 15;
  351. #elif defined(ITEAD_SLAMPHER)
  352. return 16;
  353. #elif defined(ITEAD_S20)
  354. return 17;
  355. #elif defined(ITEAD_SONOFF_TOUCH)
  356. return 18;
  357. #elif defined(ITEAD_SONOFF_POW)
  358. return 19;
  359. #elif defined(ITEAD_SONOFF_POW_R2)
  360. return 20;
  361. #elif defined(ITEAD_SONOFF_DUAL)
  362. return 21;
  363. #elif defined(ITEAD_SONOFF_DUAL_R2)
  364. return 22;
  365. #elif defined(ITEAD_SONOFF_4CH)
  366. return 23;
  367. #elif defined(ITEAD_SONOFF_4CH_PRO)
  368. return 24;
  369. #elif defined(ITEAD_1CH_INCHING)
  370. return 25;
  371. #elif defined(ITEAD_MOTOR)
  372. return 26;
  373. #elif defined(ITEAD_BNSZ01)
  374. return 27;
  375. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  376. return 28;
  377. #elif defined(ITEAD_SONOFF_B1)
  378. return 29;
  379. #elif defined(ITEAD_SONOFF_LED)
  380. return 30;
  381. #elif defined(ITEAD_SONOFF_T1_1CH)
  382. return 31;
  383. #elif defined(ITEAD_SONOFF_T1_2CH)
  384. return 32;
  385. #elif defined(ITEAD_SONOFF_T1_3CH)
  386. return 33;
  387. #elif defined(ITEAD_SONOFF_S31)
  388. return 34;
  389. #elif defined(ITEAD_SONOFF_S31_LITE)
  390. return 35;
  391. #elif defined(ITEAD_SONOFF_IFAN02)
  392. return 36;
  393. #elif defined(ORVIBO_B25)
  394. return 37;
  395. #elif defined(YJZK_SWITCH_1CH)
  396. return 38;
  397. #elif defined(YJZK_SWITCH_2CH)
  398. return 39;
  399. #elif defined(YJZK_SWITCH_3CH)
  400. return 40;
  401. #elif defined(ELECTRODRAGON_WIFI_IOT)
  402. return 41;
  403. #elif defined(WORKCHOICE_ECOPLUG)
  404. return 42;
  405. #elif defined(AITHINKER_AI_LIGHT)
  406. return 43;
  407. #elif defined(LYASI_LIGHT)
  408. return 44;
  409. #elif defined(MAGICHOME_LED_CONTROLLER)
  410. return 45;
  411. #elif defined(MAGICHOME_LED_CONTROLLER_20)
  412. return 46;
  413. #elif defined(MAGICHOME_ZJ_WFMN_A_11)
  414. return 47;
  415. #elif defined(MAGICHOME_ZJ_WFMN_B_11)
  416. return 48;
  417. #elif defined(MAGICHOME_ZJ_WFMN_C_11)
  418. return 49;
  419. #elif defined(MAGICHOME_ZJ_ESPM_5CH_B_13)
  420. return 50;
  421. #elif defined(MAGICHOME_ZJ_LB_RGBWW_L)
  422. return 51;
  423. #elif defined(HUACANXING_H801)
  424. return 52;
  425. #elif defined(HUACANXING_H802)
  426. return 53;
  427. #elif defined(JANGOE_WIFI_RELAY_NC)
  428. return 54;
  429. #elif defined(JANGOE_WIFI_RELAY_NO)
  430. return 55;
  431. #elif defined(JORGEGARCIA_WIFI_RELAYS)
  432. return 56;
  433. #elif defined(OPENENERGYMONITOR_MQTT_RELAY)
  434. return 57;
  435. #elif defined(WION_50055)
  436. return 58;
  437. #elif defined(EXS_WIFI_RELAY_V31)
  438. return 59;
  439. #elif defined(EXS_WIFI_RELAY_V50)
  440. return 60;
  441. #elif defined(GENERIC_V9261F)
  442. return 61;
  443. #elif defined(GENERIC_ECH1560)
  444. return 62;
  445. #elif defined(MANCAVEMADE_ESPLIVE)
  446. return 63;
  447. #elif defined(INTERMITTECH_QUINLED)
  448. return 64;
  449. #elif defined(ARILUX_AL_LC01)
  450. return 65;
  451. #elif defined(ARILUX_AL_LC02)
  452. return 66;
  453. #elif defined(ARILUX_AL_LC02_V14)
  454. return 67;
  455. #elif defined(ARILUX_AL_LC06)
  456. return 68;
  457. #elif defined(ARILUX_AL_LC11)
  458. return 69;
  459. #elif defined(ARILUX_E27)
  460. return 70;
  461. #elif defined(XENON_SM_PW702U)
  462. return 71;
  463. #elif defined(ISELECTOR_SM_PW702)
  464. return 72;
  465. #elif defined(AUTHOMETION_LYT8266)
  466. return 73;
  467. #elif defined(GIZWITS_WITTY_CLOUD)
  468. return 74;
  469. #elif defined(KMC_70011)
  470. return 75;
  471. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO)
  472. return 76;
  473. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO_V2)
  474. return 77;
  475. #elif defined(GENERIC_8CH)
  476. return 78;
  477. #elif defined(STM_RELAY)
  478. return 79;
  479. #elif defined(TONBUX_POWERSTRIP02)
  480. return 80;
  481. #elif defined(LINGAN_SWA1)
  482. return 81;
  483. #elif defined(HEYGO_HY02)
  484. return 82;
  485. #elif defined(MAXCIO_WUS002S)
  486. return 83;
  487. #elif defined(MAXCIO_WDE004)
  488. return 84;
  489. #elif defined(OUKITEL_P1)
  490. return 85;
  491. #elif defined(YIDIAN_XSSSA05)
  492. return 86;
  493. #elif defined(TONBUX_XSSSA01)
  494. return 87;
  495. #elif defined(TONBUX_XSSSA06)
  496. return 88;
  497. #elif defined(GREEN_ESP8266RELAY)
  498. return 89;
  499. #elif defined(IKE_ESPIKE)
  500. return 90;
  501. #elif defined(ARNIEX_SWIFITCH)
  502. return 91;
  503. #elif defined(GENERIC_ESP01S_RELAY_V40)
  504. return 92;
  505. #elif defined(GENERIC_ESP01S_RGBLED_V10)
  506. return 93;
  507. #elif defined(GENERIC_ESP01S_DHT11_V10)
  508. return 94;
  509. #elif defined(GENERIC_ESP01S_DS18B20_V10)
  510. return 95;
  511. #elif defined(PILOTAK_ESP_DIN_V1)
  512. return 96;
  513. #elif defined(HELTEC_TOUCHRELAY)
  514. return 97;
  515. #elif defined(ZHILDE_EU44_W)
  516. return 98;
  517. #elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
  518. return 99;
  519. #elif defined(LUANI_HVIO)
  520. return 100;
  521. #elif defined(TONBUX_MOSQUITO_KILLER)
  522. return 101;
  523. #elif defined(NEO_COOLCAM_NAS_WR01W)
  524. return 102;
  525. #elif defined(DELTACO_SH_P01)
  526. return 103;
  527. #elif defined(DELTACO_SH_P03USB)
  528. return 104;
  529. #elif defined(FORNORM_ZLD_34EU)
  530. return 105;
  531. #elif defined(BH_ONOFRE)
  532. return 106;
  533. #elif defined(BLITZWOLF_BWSHPX)
  534. return 107;
  535. #elif defined(BLITZWOLF_BWSHPX_V23)
  536. return 108;
  537. #elif defined(BLITZWOLF_BWSHP5)
  538. return 109;
  539. #elif defined(TECKIN_SP21)
  540. return 110;
  541. #elif defined(TECKIN_SP22_V14)
  542. return 111;
  543. #elif defined(GOSUND_WS1)
  544. return 112;
  545. #elif defined(HOMECUBE_16A)
  546. return 113;
  547. #elif defined(VANZAVANZU_SMART_WIFI_PLUG_MINI)
  548. return 114;
  549. #elif defined(GENERIC_AG_L4)
  550. return 115;
  551. #elif defined(ALLTERCO_SHELLY1)
  552. return 116;
  553. #elif defined(ALLTERCO_SHELLY2)
  554. return 117;
  555. #elif defined(ALLTERCO_SHELLY1PM)
  556. return 118;
  557. #elif defined(ALLTERCO_SHELLY25)
  558. return 119;
  559. #elif defined(LOHAS_E27_9W)
  560. return 120;
  561. #elif defined(LOHAS_E26_A19)
  562. return 121;
  563. #elif defined(TECKIN_SB53)
  564. return 122;
  565. #elif defined(XIAOMI_SMART_DESK_LAMP)
  566. return 123;
  567. #elif defined(PHYX_ESP12_RGB)
  568. return 124;
  569. #elif defined(IWOOLE_LED_TABLE_LAMP)
  570. return 125;
  571. #elif defined(GENERIC_GU10)
  572. return 126;
  573. #elif defined(GENERIC_E14)
  574. return 127;
  575. #elif defined(DELTACO_SH_LEXXW)
  576. return 128;
  577. #elif defined(DELTACO_SH_LEXXRGB)
  578. return 129;
  579. #elif defined(NEXETE_A19)
  580. return 130;
  581. #elif defined(LOMBEX_LUX_NOVA2_TUNABLE_WHITE)
  582. return 131;
  583. #elif defined(LOMBEX_LUX_NOVA2_WHITE_COLOR)
  584. return 132;
  585. #elif defined(BESTEK_MRJ1011)
  586. return 133;
  587. #elif defined(GBLIFE_RGBW_SOCKET)
  588. return 134;
  589. #elif defined(SMARTLIFE_MINI_SMART_SOCKET)
  590. return 135;
  591. #elif defined(HAMA_WIFI_STECKDOSE_00176533)
  592. return 136;
  593. #elif defined(DIGOO_NX_SP202)
  594. return 137;
  595. #elif defined(FOXEL_LIGHTFOX_DUAL)
  596. return 138;
  597. #elif defined(TECKIN_SP20)
  598. return 139;
  599. #elif defined(LITESUN_LA_WF3)
  600. return 140;
  601. #elif defined(PSH_WIFI_PLUG)
  602. return 141;
  603. #elif defined(PSH_RGBW_CONTROLLER)
  604. return 142;
  605. #elif defined(PSH_WIFI_SENSOR)
  606. return 143;
  607. #elif defined(JINVOO_VALVE_SM_AW713)
  608. return 144;
  609. #elif defined(TUYA_GENERIC_DIMMER)
  610. return 145;
  611. #elif defined(ETEKCITY_ESW01_USA)
  612. return 146;
  613. #elif defined(FS_UAP1)
  614. return 147;
  615. #elif defined(TFLAG_NX_SMX00)
  616. return 148;
  617. #elif defined(MUVIT_IO_MIOBULB001)
  618. return 149;
  619. #elif defined(HYKKER_SMART_HOME_POWER_PLUG)
  620. return 150;
  621. #elif defined(KOGAN_SMARTER_HOME_PLUG_W_POW)
  622. return 151;
  623. #elif defined(LSC_SMART_LED_LIGHT_STRIP)
  624. return 152;
  625. #elif defined(EHOMEDIY_WT02)
  626. return 153;
  627. #elif defined(EHOMEDIY_WT03)
  628. return 154;
  629. #elif defined(LINKSPRITE_LINKNODE_R4)
  630. return 155;
  631. #elif defined(GENERIC_ESP01_512KB)
  632. return 156;
  633. #else
  634. return -1; // CUSTOM
  635. #endif
  636. }