feat(mqtt): add neighbors publish path to MQTTBridge
Port the periodic-neighbors publication from mqtt-bridge-implementation-flex,
adapted to this branch's structure:
- Add MQTT_PUBLICATION_NEIGHBORS ("neighbors") to the pure MQTTTopicRouter
instead of flex's messageTypeSuffix() helper (this branch already routes
every publication type through mqttBuildPublicationTopic()). Neighbors is a
MeshCore/custom publication type, so it resolves to
meshcore/{iata}/{device}/neighbors and honors custom templates.
- Deliberately do NOT port flex's "all message types to MeshRank" change:
this branch documents and host-tests a packets-only MeshRank contract
(MQTTPresets.h, MQTT_IMPLEMENTATION.md, MeshRankContractIsPacketsOnly). So
neighbors follows status/raw and is rejected on MeshRank slots.
- WITH_MQTT_NEIGHBORS guard (PSRAM + MAX_NEIGHBOURS) gates all new surface.
- MSG_NEIGHBORS message type + enum-drift static_assert.
- Persistent ~10KB PSRAM neighbors buffer allocated/freed via the existing
MQTTRuntimeBufferLifecycle path (allocate/release), not the ctor as flex did.
- Core1->Core0 handoff: requestPublishNeighbors() (mesh) fills the buffer with
a release store; the MQTT task consumes it with an acquire load, publishes
via publishNeighbors() (QoS1, retain = preset->allow_retain, custom=false),
and clears the pending flag. A second snapshot is dropped while one is
in flight.
- setNeighborsSchedule()/NeighborsPhase let the mesh report the timer summary;
formatMqttStatusReply() gains a "nbr: <when>/<last>" field via formatDuration.
Also fix the on-connect status publish (publishStatusToSlot) to honor
preset->allow_retain instead of hardcoding retain=true, matching the periodic
publishStatus() path. Brokers with allow_retain=false (e.g. the waev MeshCore
preset) reject retained publishes, so the on-connect status was being dropped
there. This is flex followup 028a5dca, reconciled to this branch's custom-slot
default of non-retained.
Extends the host topic-router test to cover the neighbors type across all
routes and freezes the new enum value. Bridge itself is on-target only.
This commit is contained in:
1 parent
e36aee04d4
commit
de320bc4df
4 files changed
+210
-5
No files matched your search
@@ -14,6 +14,7 @@ enum MQTTPublicationType {
|
||||
MQTT_PUBLICATION_STATUS = 0,
|
||||
MQTT_PUBLICATION_PACKETS = 1,
|
||||
MQTT_PUBLICATION_RAW = 2,
|
||||
MQTT_PUBLICATION_NEIGHBORS = 3,
|
||||
};
|
||||
|
||||
enum MQTTTopicRouteStyle {
|
||||
@@ -31,6 +32,7 @@ static inline const char* mqttPublicationTypeName(int type) {
|
||||
case MQTT_PUBLICATION_STATUS: return "status";
|
||||
case MQTT_PUBLICATION_PACKETS: return "packets";
|
||||
case MQTT_PUBLICATION_RAW: return "raw";
|
||||
case MQTT_PUBLICATION_NEIGHBORS: return "neighbors";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +47,8 @@ static inline bool mqttWriteTopic(char* buf, size_t buf_size, const char* format
|
||||
}
|
||||
|
||||
// Build the complete topic for one publication. MeshRank is deliberately
|
||||
// packets-only; status and raw are unsupported by the current broker contract.
|
||||
// packets-only; status, raw, and neighbors are unsupported by the current
|
||||
// broker contract (the type != PACKETS guard below rejects them all).
|
||||
// MeshCore routes require a configured IATA and device id. Custom templates may
|
||||
// omit either placeholder, so their individual values are allowed to be empty.
|
||||
static inline bool mqttBuildPublicationTopic(MQTTTopicRouteStyle style, int type,
|
||||
|
||||
Reference in new issue
Block a user