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.

681 lines
16 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. #if SI1145_SUPPORT
  289. "SI1145 "
  290. #endif
  291. "";
  292. #endif // SENSOR_SUPPORT == 1
  293. //--------------------------------------------------------------------------------
  294. const String& getChipId() {
  295. static String value;
  296. if (!value.length()) {
  297. char buffer[7];
  298. value.reserve(sizeof(buffer));
  299. snprintf_P(buffer, sizeof(buffer), PSTR("%06X"), ESP.getChipId());
  300. value = buffer;
  301. }
  302. return value;
  303. }
  304. const String& getIdentifier() {
  305. static String value;
  306. if (!value.length()) {
  307. value += APP_NAME;
  308. value += '-';
  309. value += getChipId();
  310. }
  311. return value;
  312. }
  313. String getEspurnaModules() {
  314. return FPSTR(espurna_modules);
  315. }
  316. String getEspurnaOTAModules() {
  317. return FPSTR(espurna_ota_modules);
  318. }
  319. #if SENSOR_SUPPORT
  320. String getEspurnaSensors() {
  321. return FPSTR(espurna_sensors);
  322. }
  323. #endif // SENSOR_SUPPORT == 1
  324. String getEspurnaWebUI() {
  325. return FPSTR(espurna_webui);
  326. }
  327. bool isEspurnaCore() {
  328. #if defined(ESPURNA_CORE) || defined(ESPURNA_CORE_WEBUI)
  329. return true;
  330. #else
  331. return false;
  332. #endif
  333. }
  334. bool haveRelaysOrSensors() {
  335. bool result = false;
  336. result = (relayCount() > 0);
  337. #if SENSOR_SUPPORT
  338. result = result || (magnitudeCount() > 0);
  339. #endif
  340. return result;
  341. }
  342. int getBoardId() {
  343. #if defined(ESPURNA_CORE) || defined(ESPURNA_CORE_WEBUI)
  344. return 0;
  345. #elif defined(NODEMCU_LOLIN)
  346. return 2;
  347. #elif defined(NODEMCU_BASIC)
  348. return 3;
  349. #elif defined(WEMOS_D1_MINI)
  350. return 4;
  351. #elif defined(WEMOS_D1_MINI_RELAYSHIELD)
  352. return 5;
  353. #elif defined(WEMOS_D1_TARPUNA_SHIELD)
  354. return 6;
  355. #elif defined(TINKERMAN_ESPURNA_H06)
  356. return 7;
  357. #elif defined(TINKERMAN_ESPURNA_H08)
  358. return 8;
  359. #elif defined(TINKERMAN_ESPURNA_SWITCH)
  360. return 9;
  361. #elif defined(TINKERMAN_RFM69GW)
  362. return 10;
  363. #elif defined(ITEAD_SONOFF_BASIC)
  364. return 11;
  365. #elif defined(ITEAD_SONOFF_RF)
  366. return 12;
  367. #elif defined(ITEAD_SONOFF_MINI)
  368. return 13;
  369. #elif defined(ITEAD_SONOFF_TH)
  370. return 14;
  371. #elif defined(ITEAD_SONOFF_SV)
  372. return 15;
  373. #elif defined(ITEAD_SLAMPHER)
  374. return 16;
  375. #elif defined(ITEAD_S20)
  376. return 17;
  377. #elif defined(ITEAD_SONOFF_TOUCH)
  378. return 18;
  379. #elif defined(ITEAD_SONOFF_POW)
  380. return 19;
  381. #elif defined(ITEAD_SONOFF_POW_R2)
  382. return 20;
  383. #elif defined(ITEAD_SONOFF_DUAL)
  384. return 21;
  385. #elif defined(ITEAD_SONOFF_DUAL_R2)
  386. return 22;
  387. #elif defined(ITEAD_SONOFF_4CH)
  388. return 23;
  389. #elif defined(ITEAD_SONOFF_4CH_PRO)
  390. return 24;
  391. #elif defined(ITEAD_1CH_INCHING)
  392. return 25;
  393. #elif defined(ITEAD_MOTOR)
  394. return 26;
  395. #elif defined(ITEAD_BNSZ01)
  396. return 27;
  397. #elif defined(ITEAD_SONOFF_RFBRIDGE)
  398. return 28;
  399. #elif defined(ITEAD_SONOFF_B1)
  400. return 29;
  401. #elif defined(ITEAD_SONOFF_LED)
  402. return 30;
  403. #elif defined(ITEAD_SONOFF_T1_1CH)
  404. return 31;
  405. #elif defined(ITEAD_SONOFF_T1_2CH)
  406. return 32;
  407. #elif defined(ITEAD_SONOFF_T1_3CH)
  408. return 33;
  409. #elif defined(ITEAD_SONOFF_S31)
  410. return 34;
  411. #elif defined(ITEAD_SONOFF_S31_LITE)
  412. return 35;
  413. #elif defined(ITEAD_SONOFF_IFAN02)
  414. return 36;
  415. #elif defined(ORVIBO_B25)
  416. return 37;
  417. #elif defined(YJZK_SWITCH_1CH)
  418. return 38;
  419. #elif defined(YJZK_SWITCH_2CH)
  420. return 39;
  421. #elif defined(YJZK_SWITCH_3CH)
  422. return 40;
  423. #elif defined(ELECTRODRAGON_WIFI_IOT)
  424. return 41;
  425. #elif defined(WORKCHOICE_ECOPLUG)
  426. return 42;
  427. #elif defined(AITHINKER_AI_LIGHT)
  428. return 43;
  429. #elif defined(LYASI_LIGHT)
  430. return 44;
  431. #elif defined(MAGICHOME_LED_CONTROLLER)
  432. return 45;
  433. #elif defined(MAGICHOME_LED_CONTROLLER_20)
  434. return 46;
  435. #elif defined(MAGICHOME_ZJ_WFMN_A_11)
  436. return 47;
  437. #elif defined(MAGICHOME_ZJ_WFMN_B_11)
  438. return 48;
  439. #elif defined(MAGICHOME_ZJ_WFMN_C_11)
  440. return 49;
  441. #elif defined(MAGICHOME_ZJ_ESPM_5CH_B_13)
  442. return 50;
  443. #elif defined(MAGICHOME_ZJ_LB_RGBWW_L)
  444. return 51;
  445. #elif defined(HUACANXING_H801)
  446. return 52;
  447. #elif defined(HUACANXING_H802)
  448. return 53;
  449. #elif defined(JANGOE_WIFI_RELAY_NC)
  450. return 54;
  451. #elif defined(JANGOE_WIFI_RELAY_NO)
  452. return 55;
  453. #elif defined(JORGEGARCIA_WIFI_RELAYS)
  454. return 56;
  455. #elif defined(OPENENERGYMONITOR_MQTT_RELAY)
  456. return 57;
  457. #elif defined(WION_50055)
  458. return 58;
  459. #elif defined(EXS_WIFI_RELAY_V31)
  460. return 59;
  461. #elif defined(EXS_WIFI_RELAY_V50)
  462. return 60;
  463. #elif defined(GENERIC_V9261F)
  464. return 61;
  465. #elif defined(GENERIC_ECH1560)
  466. return 62;
  467. #elif defined(MANCAVEMADE_ESPLIVE)
  468. return 63;
  469. #elif defined(INTERMITTECH_QUINLED)
  470. return 64;
  471. #elif defined(ARILUX_AL_LC01)
  472. return 65;
  473. #elif defined(ARILUX_AL_LC02)
  474. return 66;
  475. #elif defined(ARILUX_AL_LC02_V14)
  476. return 67;
  477. #elif defined(ARILUX_AL_LC06)
  478. return 68;
  479. #elif defined(ARILUX_AL_LC11)
  480. return 69;
  481. #elif defined(ARILUX_E27)
  482. return 70;
  483. #elif defined(XENON_SM_PW702U)
  484. return 71;
  485. #elif defined(ISELECTOR_SM_PW702)
  486. return 72;
  487. #elif defined(AUTHOMETION_LYT8266)
  488. return 73;
  489. #elif defined(GIZWITS_WITTY_CLOUD)
  490. return 74;
  491. #elif defined(KMC_70011)
  492. return 75;
  493. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO)
  494. return 76;
  495. #elif defined(EUROMATE_WIFI_STECKER_SCHUKO_V2)
  496. return 77;
  497. #elif defined(GENERIC_8CH)
  498. return 78;
  499. #elif defined(STM_RELAY)
  500. return 79;
  501. #elif defined(TONBUX_POWERSTRIP02)
  502. return 80;
  503. #elif defined(LINGAN_SWA1)
  504. return 81;
  505. #elif defined(HEYGO_HY02)
  506. return 82;
  507. #elif defined(MAXCIO_WUS002S)
  508. return 83;
  509. #elif defined(MAXCIO_WDE004)
  510. return 84;
  511. #elif defined(OUKITEL_P1)
  512. return 85;
  513. #elif defined(YIDIAN_XSSSA05)
  514. return 86;
  515. #elif defined(TONBUX_XSSSA01)
  516. return 87;
  517. #elif defined(TONBUX_XSSSA06)
  518. return 88;
  519. #elif defined(GREEN_ESP8266RELAY)
  520. return 89;
  521. #elif defined(IKE_ESPIKE)
  522. return 90;
  523. #elif defined(ARNIEX_SWIFITCH)
  524. return 91;
  525. #elif defined(GENERIC_ESP01S_RELAY_V40)
  526. return 92;
  527. #elif defined(GENERIC_ESP01S_RGBLED_V10)
  528. return 93;
  529. #elif defined(GENERIC_ESP01S_DHT11_V10)
  530. return 94;
  531. #elif defined(GENERIC_ESP01S_DS18B20_V10)
  532. return 95;
  533. #elif defined(PILOTAK_ESP_DIN_V1)
  534. return 96;
  535. #elif defined(HELTEC_TOUCHRELAY)
  536. return 97;
  537. #elif defined(ZHILDE_EU44_W)
  538. return 98;
  539. #elif defined(ALLNET_4DUINO_IOT_WLAN_RELAIS)
  540. return 99;
  541. #elif defined(LUANI_HVIO)
  542. return 100;
  543. #elif defined(TONBUX_MOSQUITO_KILLER)
  544. return 101;
  545. #elif defined(NEO_COOLCAM_NAS_WR01W)
  546. return 102;
  547. #elif defined(DELTACO_SH_P01)
  548. return 103;
  549. #elif defined(DELTACO_SH_P03USB)
  550. return 104;
  551. #elif defined(FORNORM_ZLD_34EU)
  552. return 105;
  553. #elif defined(BH_ONOFRE)
  554. return 106;
  555. #elif defined(BLITZWOLF_BWSHPX)
  556. return 107;
  557. #elif defined(BLITZWOLF_BWSHPX_V23)
  558. return 108;
  559. #elif defined(BLITZWOLF_BWSHP5)
  560. return 109;
  561. #elif defined(TECKIN_SP21)
  562. return 110;
  563. #elif defined(TECKIN_SP22_V14)
  564. return 111;
  565. #elif defined(GOSUND_WS1)
  566. return 112;
  567. #elif defined(HOMECUBE_16A)
  568. return 113;
  569. #elif defined(VANZAVANZU_SMART_WIFI_PLUG_MINI)
  570. return 114;
  571. #elif defined(GENERIC_AG_L4)
  572. return 115;
  573. #elif defined(ALLTERCO_SHELLY1)
  574. return 116;
  575. #elif defined(ALLTERCO_SHELLY2)
  576. return 117;
  577. #elif defined(ALLTERCO_SHELLY1PM)
  578. return 118;
  579. #elif defined(ALLTERCO_SHELLY25)
  580. return 119;
  581. #elif defined(LOHAS_E27_9W)
  582. return 120;
  583. #elif defined(LOHAS_E26_A19)
  584. return 121;
  585. #elif defined(TECKIN_SB53)
  586. return 122;
  587. #elif defined(XIAOMI_SMART_DESK_LAMP)
  588. return 123;
  589. #elif defined(PHYX_ESP12_RGB)
  590. return 124;
  591. #elif defined(IWOOLE_LED_TABLE_LAMP)
  592. return 125;
  593. #elif defined(GENERIC_GU10)
  594. return 126;
  595. #elif defined(GENERIC_E14)
  596. return 127;
  597. #elif defined(DELTACO_SH_LEXXW)
  598. return 128;
  599. #elif defined(DELTACO_SH_LEXXRGB)
  600. return 129;
  601. #elif defined(NEXETE_A19)
  602. return 130;
  603. #elif defined(LOMBEX_LUX_NOVA2_TUNABLE_WHITE)
  604. return 131;
  605. #elif defined(LOMBEX_LUX_NOVA2_WHITE_COLOR)
  606. return 132;
  607. #elif defined(BESTEK_MRJ1011)
  608. return 133;
  609. #elif defined(GBLIFE_RGBW_SOCKET)
  610. return 134;
  611. #elif defined(SMARTLIFE_MINI_SMART_SOCKET)
  612. return 135;
  613. #elif defined(HAMA_WIFI_STECKDOSE_00176533)
  614. return 136;
  615. #elif defined(DIGOO_NX_SP202)
  616. return 137;
  617. #elif defined(FOXEL_LIGHTFOX_DUAL)
  618. return 138;
  619. #elif defined(TECKIN_SP20)
  620. return 139;
  621. #elif defined(LITESUN_LA_WF3)
  622. return 140;
  623. #elif defined(PSH_WIFI_PLUG)
  624. return 141;
  625. #elif defined(PSH_RGBW_CONTROLLER)
  626. return 142;
  627. #elif defined(PSH_WIFI_SENSOR)
  628. return 143;
  629. #elif defined(JINVOO_VALVE_SM_AW713)
  630. return 144;
  631. #elif defined(TUYA_GENERIC_DIMMER)
  632. return 145;
  633. #elif defined(ETEKCITY_ESW01_USA)
  634. return 146;
  635. #elif defined(FS_UAP1)
  636. return 147;
  637. #elif defined(TFLAG_NX_SMX00)
  638. return 148;
  639. #elif defined(MUVIT_IO_MIOBULB001)
  640. return 149;
  641. #elif defined(HYKKER_SMART_HOME_POWER_PLUG)
  642. return 150;
  643. #elif defined(KOGAN_SMARTER_HOME_PLUG_W_POW)
  644. return 151;
  645. #elif defined(LSC_SMART_LED_LIGHT_STRIP)
  646. return 152;
  647. #elif defined(EHOMEDIY_WT02)
  648. return 153;
  649. #elif defined(EHOMEDIY_WT03)
  650. return 154;
  651. #elif defined(LINKSPRITE_LINKNODE_R4)
  652. return 155;
  653. #elif defined(GENERIC_ESP01_512KB)
  654. return 156;
  655. #elif defined(GOSUND_WP3)
  656. return 157;
  657. #else
  658. return -1; // CUSTOM
  659. #endif
  660. }