Skip to content

Commit aa217e1

Browse files
authored
refactoring, bugfixes, generic device scanning (#21603)
1 parent d046f9c commit aa217e1

File tree

2 files changed

+125
-36
lines changed

2 files changed

+125
-36
lines changed

tasmota/include/xsns_62_esp32_mi.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ struct {
199199
uint32_t updateScan:1;
200200
uint32_t deleteScanTask:1;
201201

202+
202203
uint32_t canConnect:1;
203204
uint32_t willConnect:1;
204205
uint32_t readingDone:1;
@@ -230,7 +231,7 @@ struct {
230231
uint32_t directBridgeMode:1; // send every received BLE-packet as a MQTT-message in real-time
231232
uint32_t activeScan:1;
232233
uint32_t ignoreBogusBattery:1;
233-
uint32_t minimalSummary:1; // DEPRECATED!!
234+
uint32_t handleEveryDevice:1;
234235
} option;
235236
#ifdef USE_MI_EXT_GUI
236237
uint32_t widgetSlot;
@@ -271,6 +272,7 @@ struct mi_sensor_t{
271272
uint32_t knob:1;
272273
uint32_t door:1;
273274
uint32_t leak:1;
275+
uint32_t payload:1;
274276
};
275277
uint32_t raw;
276278
} feature;
@@ -291,6 +293,7 @@ struct mi_sensor_t{
291293
uint32_t longpress:1; //needs no extra feature bit, because knob is sufficient
292294
uint32_t door:1;
293295
uint32_t leak:1;
296+
uint32_t payload:1;
294297
};
295298
uint32_t raw;
296299
} eventType;
@@ -331,10 +334,15 @@ struct mi_sensor_t{
331334
uint8_t longpress; // dimmer knob pressed without rotating
332335
};
333336
uint8_t door;
337+
334338
};
335339
union {
336340
uint8_t bat; // many values seem to be hard-coded garbage (LYWSD0x, GCD1)
337341
};
342+
struct {
343+
uint8_t * payload = nullptr;
344+
uint8_t payload_len;
345+
};
338346
};
339347

340348
/*********************************************************************************************\
@@ -475,8 +483,9 @@ enum MI32_BLEInfoMsg {
475483
const char HTTP_BTN_MENU_MI32[] PROGMEM = "<p><form action='m32' method='get'><button>Mi Dashboard</button></form></p>";
476484

477485
const char HTTP_MI32_SCRIPT_1[] PROGMEM =
478-
"function setUp(){setInterval(countUp,1000); setInterval(update,1000);}"
479-
"function countUp(){let ti=document.querySelectorAll('.Ti');"
486+
"function setUp(){setInterval(countUp,1000); setInterval(update,200);}"
487+
"function countUp(){let ti=document.querySelectorAll('.Ti');eb('clock').innerText=Date().slice(4,24);"
488+
"eb('numDev').innerText=eb('pr').childElementCount-1;"
480489
"for(const el of ti){var t=parseInt(el.innerText);el.innerText=t+1;}}"
481490
"function update(){"
482491
"fetch('/m32?wi=1').then(r=>r.text())"
@@ -499,7 +508,7 @@ const char HTTP_MI32_STYLE[] PROGMEM =
499508
".parent{display:grid;grid-template-columns:repeat(auto-fill,350px);grid-template-rows:repeat(auto-fill,220px);"
500509
"grid-auto-rows:220px;grid-auto-columns:350px;gap:1rem;justify-content:center;}"
501510
"svg{float:inline-end;}"
502-
".box{padding:10px;border-radius:0.8rem;background-color:rgba(221, 221, 221, 0.2);}"
511+
".box{padding:10px;border-radius:0.8rem;background-color:rgba(221, 221, 221, 0.2);overflow-y:auto;}"
503512
"@media screen and (min-width: 720px){.wide{grid-column:span 2;grid-row:span 1;}.big {grid-column:span 2;grid-row:span 2;}}"
504513
".tall {grid-column:span 1;grid-row:span 2;}"
505514
"</style>";
@@ -515,6 +524,7 @@ const char HTTP_MI32_PARENT_BLE_ROLE[] PROGMEM = "None|Observer|Peripheral|Centr
515524
const char HTTP_MI32_PARENT_START[] PROGMEM =
516525
"<div class='parent'id='pr'>"
517526
"<div class='box tall'><h2>MI32 Bridge</h2>"
527+
"<span id='clock'></span><br><br>"
518528
"Observing <span id='numDev'>%u</span> devices<br><br>"
519529
"Uptime: <span class='Ti'>%u</span> seconds<br><br>"
520530
"Free Heap: %u kB<br><br>"

0 commit comments

Comments
 (0)