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.

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