Separation Of Roles And Responsibilities
The connection manager is only responsible for a single broker session, CONNECT / SUBSCRIBE / PUBLISH, and the process path (RX + keep-alive) that must run every loop iteration; broker nickname or subscription table state is not kept there.
This service holds broker address, credentials, the topic list to subscribe to (limited slots), the incoming-message callback and optional link callback; all heavy work runs in a separate task on a fixed-period loop.
flowchart TB
subgraph App["Application / protocol module"]
APP[RigelMq or other consumer]
end
subgraph Svc["MQTT Connection Service"]
T[Task loop]
B[Task flags]
T --> B
end
subgraph Mng["MQTT connection manager"]
C[CONNECT / DISCONNECT]
P[process — RX and keep-alive]
S[SUBSCRIBE / PUBLISH]
end
subgraph Net["Network stack"]
CY[CycloneTCP mqtt_client]
end
APP -->|request: connect / publish / subscribe| Svc
Svc --> Mng
Mng --> CY
CY -->|PUBLISH payload| Svc
Svc -->|IncomingCb topic + data| APP
Svc -->|LinkCb isUp| APP