feat: MQTT client connectivity - #12
Merged
Merged
Conversation
Add the mqtt component to the app component requirements for the MQTT client module.
Add connectivity/mqtt following the hexagonal structure: the IMqttClient port, MqttService (reads broker settings from IMqttConfig and the client id from IDeviceConfig, with client_id = device_id), the esp-mqtt adapter and the Mqtt facade. Connects asynchronously over plaintext mqtt://, exposes publish/subscribe and a message callback, reports connection status and relies on esp-mqtt auto-reconnect. Wire it in main to start after Wi-Fi.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
connectivity/mqtt: an MQTT client that connects to the broker using the provisioned settings (IMqttConfig: host/port/user/password) withclient_id = device_id(IDeviceConfig), and exposes publish/subscribe primitives for the future app logic. Same hexagonal structure asconnectivity/wifiandconnectivity/provisioning.IMqttClient(domain) +Status,Message{topic,payload},StatusHandler/MessageHandler,ClientConfig.MqttService(application) — reads broker settings + device id, buildsmqtt://host:port, connects; thin pass-throughs for publish/subscribe/stop. Missing host or device id → logs and returns without crashing. Port defaults to1883when unset.EspMqttClient(infrastructure) — esp-mqtt adapter. Event-driven (MQTT_EVENT_*), non-blocking, relies on esp-mqtt's built-in auto-reconnect. MapsMQTT_EVENT_DATAto the message callback.Mqtt(facade) —start()/stop()/publish()/subscribe()/isConnected()/onStatusChange()/onMessage(); wired inmainto start after Wi-Fi.Design decisions: transport-only (connect + pub/sub + status; topic/command logic deferred to the future orchestrator), plaintext
mqtt://, independent start with esp-mqtt auto-reconnect.Notes
Connectedstatus callback and the broker re-delivers the retained last value toonMessage. esp-mqtt does not auto-resubscribe, so re-subscription belongs in the consumer/App.retainedflag is not surfaced onMessage(can be added later)..envfiles in.gitignore.Build
mqttcomponent toREQUIRES. Flash ~38.8% of the 3 MB partition, RAM ~11.8%.Verification
make -C firmwarebuilds cleanly.connectivity/mqttreachConnected; the broker shows a client withclient_id = device_id; publish/subscribe round-trip; drop the broker and confirm auto-reconnect.