Repository navigation
Add the ebus_mqtt target: transport interface, PublishHold, reconnect order - #6
Merged
Merged
Conversation
ebus_mqtt is the first component of the split: mqtt/include/ebus/mqtt/ and mqtt/src/, built by mqtt/CMakeLists.txt with only its own include directory and no dependency. ebus_core links it, so consumers keep one target. PublishHold moves from ports/posix/ unchanged in behavior. Its sizes are now EBUS_MQTT_HOLD_ENTRIES, EBUS_MQTT_HOLD_TOPIC_MAX and EBUS_MQTT_HOLD_PAYLOAD_MAX, and it no longer logs: hold() reports EVICTED_OLDEST and DROPPED_TOO_LARGE and the POSIX port logs them. Its test becomes the Unity suite test_mqtt_publish_hold, which links ebus_mqtt alone. The header check compiles each component's headers against that component's target. library.json compiles src/ and mqtt/src/ and adds mqtt/include to the include path, which PlatformIO passes on to the library's dependents. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
…X port After every connect a port flushes the hold, re-subscribes, then notifies the application, as ebus-mqtt-client does. ebus/mqtt/reconnect.h documents that contract and mqtt_after_connect() runs it from three hooks, stopping before the later steps when the flush is interrupted or the link drops during the re-subscribe. PahoTransport::try_connect() now calls it; its log lines, which the e2e reconnect test checks, are unchanged. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
ebus/mqtt/transport.h holds the Homie-agnostic interface: publish(), subscribe(), connected(), last_error(), and a queue_publish() that takes an explicit QoS and a completion callback (mqtt_publish_done_fn plus a void* context) in place of Homie's Property*. HomieTransport, in homie/homie_transport.h as before, derives from it and keeps the Property overload as the Homie adapter: by default it forwards to the generic overload with a callback that calls Property::queued_publish_done(), so the publish-on-change memo works over either. A port overrides one of the two; a port written against 0.1.0 (esp32-sdk's MqttClientTransport overrides the Property overload) builds and behaves as before. MAX_DATA_LEN, mqtt_qos and homie_qos() stay on the Homie side. The POSIX port and the test FakeTransport now implement the generic overload. New tests cover a transport that overrides only the Property overload and one that overrides neither. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
Each mqtt/src/ source and mqtt/include/ header is compiled with -I mqtt/include as the only include path, with GCC and Clang, so an include of a Homie or ArduinoJson header in ebus_mqtt fails the build. Part of #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
…rder doc/mqtt.md covers MqttTransport and the HomieTransport adapter (which overload a port overrides), PublishHold's rules and sizes, and mqtt_after_connect(). The README gains a table of the CMake targets and the PlatformIO layout; doc/core.md, the POSIX port README and CONTRIBUTING point to the new pieces; CHANGELOG has an Unreleased entry. Closes #4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz
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.
Adds
ebus_mqtt, the first component of the split in #3: the Homie-agnostic MQTT layer, with no dependency and only its own include directory.ebus_corelinks it, and PlatformIO still builds one library.What moved
homie/homie_transport.hMqttTransportinmqtt/include/ebus/mqtt/transport.h;HomieTransportstays inhomie/homie_transport.has a subclass with the Homie adapterports/posix/include/ebus_posix/publish_hold.h,ports/posix/src/publish_hold.cppmqtt/include/ebus/mqtt/publish_hold.h,mqtt/src/publish_hold.cppports/posix/test/test_publish_hold.cpp(hand-rolled checks)test/test_mqtt_publish_hold/(Unity under CTest)PahoTransport::try_connect()mqtt_after_connect()inmqtt/include/ebus/mqtt/reconnect.h,mqtt/src/reconnect.cpp, withtest/test_mqtt_reconnect/Layout: each component gets
<name>/include/ebus/<name>/and<name>/src/with its ownCMakeLists.txt, sodiscovery/andhomie/can follow the same shape. Naming stays namespace-free like the rest of the core, withMqtt/mqtt_prefixes andEBUS_MQTT_macros.Interface change
Before:
After:
Property still calls the
Property*overload. Its default forwards to the generic one with a callback that callsProperty::queued_publish_done(), so the publish-on-change memo works either way. A port overrides one of the two.PublishHoldno longer logs;hold()returnsEVICTED_OLDEST/DROPPED_TOO_LARGEand the port logs. Sizes areEBUS_MQTT_HOLD_ENTRIES(64),EBUS_MQTT_HOLD_TOPIC_MAX(127),EBUS_MQTT_HOLD_PAYLOAD_MAX(1024).esp32-sdk compatibility
MqttClientTransportoverrides theProperty*overload, which is still virtual, so esp32-sdk builds with no source change. Checked in a scratch worktree of esp32-sdkmainwithlib/ebus_corepointed at this branch (nothing committed there):./ebus-esp32 build(esp32-poe-iso): builds with no warnings.firmware.bin1,436,352 bytes onmain(cpp-sdk v0.1.0), 1,436,480 with this branch, so +128 bytes (.flash.text+32,.flash.rodata+80, RAM sections unchanged)../ebus-esp32 test: 11/11 suites pass, including the two newtest_mqtt_*suites under PlatformIO's native env. That confirmslibrary.json's-I mqtt/includereaches the library's dependents.Tests
cmake -S . -B build, warnings as errors): 10/10 CTest suites pass with Apple Clang and GCC 16.-DEBUS_POSIX_WERROR=ON): 6/6 e2e tests pass against a local mosquitto on 127.0.0.1. The reconnect test checks the flush, re-subscribe, notify order from the log, and those log lines are unchanged.ebus_mqttalone: every source and header compiled with-I mqtt/includeonly (Clang and GCC), plusadd_subdirectory(cpp-sdk/mqtt)from a scratch project.core-host-build.Part of #3. Closes #4.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Npk6WmkpnBRzWkuhK6uCuz