diff --git a/tasmota/include/xsns_62_esp32_mi.h b/tasmota/include/xsns_62_esp32_mi.h index e7e603fd1..09413a9fa 100644 --- a/tasmota/include/xsns_62_esp32_mi.h +++ b/tasmota/include/xsns_62_esp32_mi.h @@ -226,6 +226,7 @@ struct { void *beServerCB; uint8_t *beAdvBuf; uint8_t infoMsg = 0; + uint8_t role = 0; } MI32; struct mi_sensor_t{ @@ -473,8 +474,14 @@ const char HTTP_MI32_SCRIPT_1[] PROGMEM = ; const char HTTP_MI32_STYLE[] PROGMEM = - ""; + ""; const char HTTP_MI32_STYLE_SVG[] PROGMEM = "" @@ -482,12 +489,15 @@ const char HTTP_MI32_STYLE_SVG[] PROGMEM = "" ; +const char HTTP_MI32_PARENT_BLE_ROLE[] PROGMEM = "None|Observer|Peripheral|Central"; + const char HTTP_MI32_PARENT_START[] PROGMEM = "
" - "

MI32 Bridge

" - "Observing %u devices
" - "Uptime: %u seconds
" - "Free Heap: %u kB" + "

MI32 Bridge

" + "Observing %u devices

" + "Uptime: %u seconds

" + "Free Heap: %u kB

" + "BLE Role: %s" "
"; const char HTTP_MI32_WIDGET[] PROGMEM = diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index d81e5e03c..a890dae17 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -726,6 +726,9 @@ bool HttpCheckPriviledgedAccess(bool autorequestauth = true) AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP "Referer '%s' denied. Use 'SO128 1' for HTTP API commands. 'Webpassword' is recommended."), referer.c_str()); return false; } else { +#if defined(USE_MI_ESP32) && !defined(USE_BLE_ESP32) + MI32suspendScanTask(); +#endif // defined(USE_MI_ESP32) && !defined(USE_BLE_ESP32) return true; } } @@ -997,6 +1000,9 @@ void WSContentEnd(void) { WSContentFlush(); // Flush chunk buffer _WSContentSend(""); // Signal end of chunked content Webserver->client().stop(); +#if defined(USE_MI_ESP32) && !defined(USE_BLE_ESP32) + MI32resumeScanTask(); +#endif // defined(USE_MI_ESP32) && !defined(USE_BLE_ESP32) } void WSContentStop(void) { diff --git a/tasmota/tasmota_xsns_sensor/xsns_62_esp32_mi.ino b/tasmota/tasmota_xsns_sensor/xsns_62_esp32_mi.ino index f99cc73c3..c10a559c7 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_62_esp32_mi.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_62_esp32_mi.ino @@ -1019,6 +1019,7 @@ void MI32resumeScanTask(void){ void MI32StartTask(uint32_t task){ if (MI32.mode.willConnect == 1) return; // we are in the middle of connecting to something ... do not interrupt this. + MI32.role = 0; switch(task){ case MI32_TASK_SCAN: if (MI32.mode.connected == 1) return; @@ -1045,6 +1046,7 @@ void MI32StartScanTask(){ if(MI32.ScanTask!=nullptr) vTaskDelete(MI32.ScanTask); MI32.mode.runningScan = 1; MI32.mode.deleteScanTask = 0; + MI32.role = 1; xTaskCreatePinnedToCore( MI32ScanTask, /* Function to implement the task */ "MI32ScanTask", /* Name of the task */ @@ -1199,6 +1201,7 @@ bool MI32StartConnectionTask(){ MI32.mode.willConnect = 1; MI32Scan->stop(); MI32suspendScanTask(); + MI32.role = 2; xTaskCreatePinnedToCore( MI32ConnectionTask, /* Function to implement the task */ "MI32ConnectionTask", /* Name of the task */ @@ -1387,6 +1390,7 @@ bool MI32StartServerTask(){ return false; } } + MI32.role = 3; xTaskCreatePinnedToCore( MI32ServerTask, /* Function to implement the task */ "MI32ServerTask", /* Name of the task */ @@ -2125,7 +2129,11 @@ void MI32sendEnergyWidget(){ #ifdef USE_WEBCAM void MI32sendCamWidget(){ if (Wc.CamServer && Wc.up) { - WSContentSend_P(PSTR(""), + WSContentSend_P(PSTR("
"), (uint32_t)WiFi.localIP()); } } @@ -2242,7 +2250,6 @@ void MI32sendWidget(uint32_t slot){ } void MI32InitGUI(void){ - MI32suspendScanTask(); MI32.widgetSlot=0; WSContentStart_P("m32"); WSContentSend_P(HTTP_MI32_SCRIPT_1); @@ -2252,11 +2259,15 @@ void MI32InitGUI(void){ WSContentSend_P(HTTP_MI32_STYLE_SVG,2,151,190,216,151,190,216); WSContentSend_P(HTTP_MI32_STYLE_SVG,3,242,240,176,242,240,176); - WSContentSend_P((HTTP_MI32_PARENT_START),MIBLEsensors.size(),UpTime(),ESP.getFreeHeap()/1024); + char _role[16]; + GetTextIndexed(_role, sizeof(_role), MI32.role, HTTP_MI32_PARENT_BLE_ROLE); + WSContentSend_P((HTTP_MI32_PARENT_START),MIBLEsensors.size(),UpTime(),ESP.getFreeHeap()/1024,_role); - for(uint32_t _slot = 0;_slot")); WSContentSpaceButton(BUTTON_MAIN); WSContentStop(); - MI32resumeScanTask(); } void MI32HandleWebGUI(void){