feat(mqtt): enhance packet filter functionality with named types
Add support for named packet types in per-slot filters, allowing users to specify packet types using descriptive names alongside numeric values. This improves usability and clarity in configuring MQTT slot filters. Updates include modifications to the parsing logic, WebConfig interface, and related documentation to reflect the new naming conventions.
This commit is contained in:
1 parent
e00b29b4b8
commit
52bd27190f
17 files changed
+830
-87
No files matched your search
@@ -1310,9 +1310,17 @@ void MyMesh::buildStatsJson(char* buf, size_t buf_size) {
|
||||
for (int i = 0; i < RUNTIME_MQTT_SLOTS; i++) {
|
||||
MQTTBridge::SlotStatusSnapshot s;
|
||||
if (!MQTTBridge::getSlotStatusSnapshot(i, &s)) continue;
|
||||
// "filt" is omitted for the all-types default, so the portal only has to
|
||||
// render the exception and the JSON stays inside the stats buffer.
|
||||
char filt[24];
|
||||
filt[0] = '\0';
|
||||
if (s.filter_mask != MQTTPacketFilter::kAllPacketTypes) {
|
||||
snprintf(filt, sizeof(filt), ",\"filt\":%u", (unsigned)s.filter_mask);
|
||||
}
|
||||
int n = snprintf(buf + pos, buf_size - pos,
|
||||
"%s{\"n\":%d,\"name\":\"%s\",\"state\":\"%s\",\"ok\":%lu,\"err\":%lu}",
|
||||
first ? "" : ",", i + 1, s.name, s.state, s.publish_ok, s.publish_err);
|
||||
"%s{\"n\":%d,\"name\":\"%s\",\"state\":\"%s\",\"ok\":%lu,\"err\":%lu%s}",
|
||||
first ? "" : ",", i + 1, s.name, s.state, s.publish_ok, s.publish_err,
|
||||
filt);
|
||||
if (n < 0 || n >= (int)(buf_size - pos)) break;
|
||||
pos += n;
|
||||
first = false;
|
||||
|
||||
Reference in new issue
Block a user