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.

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