Repository navigation
refactor(examples): shared MQTT demo crate on publish / subscribe (#391, stage 2) - #401
Merged
lxsaah merged 1 commit intoNov 2, 2026
Conversation
mqtt-connector-demo-common is now the runtime-agnostic home of what both MQTT demos share: - contracts that are always Linkable (JSON derive, no_std + alloc); the data-contracts / serde / alloc / derive features and the hand-rolled no_std JSON helpers are gone - the keys with their #[link_address] topics - SimThermometers / Thermometer: owned, non-Clone sensor channels and one Input for every T: From<Reading>, replacing three producer functions in each demo - the monitors Both demos register MQTT with connect and link with publish / subscribe; the serial remote-access server stays on with_connector. Tokio payloads are unchanged (the derive uses serde_json::to_vec, as to_json_vec did). Embassy release .text shrinks by 17,600 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 2, 2026
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.
Description
Stage 2 of #391, into the #392 feature branch.
mqtt-connector-demo-commonbecomes the runtime-agnostic home of everything both MQTT demos share, and both demos move toconnect+publish/subscribe.mqtt-connector-demo-commonTemperatureandTemperatureCommandare alwaysSerialize/Deserialize/ JSON#[derive(Linkable)], onno_std + alloctoo. Thedata-contracts,serde,allocandderivefeatures are gone, along with the hand-rolled no_std JSON (to_json_vec,from_json,parse_json_no_std).sim.rs(new):SimThermometers { indoor, outdoor, server_room }hands out ownedSimChannels that are neitherClonenorCopy.Thermometer::on(channel)is anInput<T>for everyT: From<Reading>, with.every_secs(n)and.readings(n).impl From<Reading> for Temperaturelives next to the contract.RuntimeContext, so the same input runs on Tokio and Embassy and replaces the three producer functions in each demo.tokio-mqtt-connector-demolet mqtt = builder.connect(..),.input(Thermometer::on(indoor).readings(5)),publish/subscribewith the keys'#[link_address]topics.main.rswent from 215 to 154 lines; most of the rest is the module docs.serde_json::to_vec, asto_json_vecdid on stdembassy-mqtt-connector-demoThe records use the shared thermometers, which keep cycling endlessly as before, plus
publish/subscribe.The serial remote-access server stays on
with_connector, since it takes no links.Payloads now come from serde_json instead of the hand-rolled one-decimal formatter, so they're identical to the Tokio demo's.
Release size for
thumbv8m.main-none-eabihf(arm-none-eabi-size -A):.text.rodata.data.bssThe board module and the B1
PushButtonfollow in stage 3.Checks
CI doesn't run on PRs into the feature branch, so I ran these locally:
mqtt-connector-demo-commontests withstd, and the no_std buildcargo clippy -D warningson the common crate (no_std and std), the tokio demo, and the embassy demo forthumbv8m.main-none-eabihfthumbv8m.main-none-eabihfbuild()succeedsNot done: a run against a real broker, because Docker's daemon wasn't running. The embassy demo was not flashed.
Related Issue
🤖 Generated with Claude Code