Emit BasicInformation::StartUp event after data model startup#41
Open
snabb wants to merge 2 commits into
Open
Conversation
Matter 1.5.1 Core §11.1.6.1 requires (SHALL) every Node to emit BasicInformation::StartUp after boot, with SoftwareVersion matching the BasicInformation attribute. Stack-level emission means every downstream project gets spec compliance without per-app wiring. Emitted at the top of run_dm / run_dm_with_bump because by that point the DataModel (and its event ringbuf + EventNumber persistence) is ready, and every wireless / Ethernet run-loop funnels through one of those two paths. SoftwareVersion is pulled from matter.dev_det().sw_ver. Failures are logged, not propagated.
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
Emit
BasicInformation::StartUpon the root endpoint fromrun_dm/run_dm_with_bump, as required by Matter 1.5.1 Core §11.1.6.1 (SHALL).Every Node has to emit it "as soon as reasonable after completing a
boot or reboot process," with
SoftwareVersionmatching theBasicInformation attribute of the same name.
Today, applications built on
rs-matter-stackget no help with this —each one has to wire its own
Handlerimpl into the chain just to emitone mandatory event. Stack-level emission means every downstream
project is spec-compliant without per-app boilerplate.
Implementation
A small
emit_startup_event_once(dm)helper is called at the top ofrun_dmandrun_dm_with_bump, before the responder and DMrun()future start. By that point the
DataModel(and its event ringbuf +EventNumberpersistence from #39) is fully initialised, and everyEthernet / wireless run-loop in the crate funnels through one of those
two paths.
run_dmis called more than once per boot in the wireless flow — oncefrom the commissioning task (
wireless/thread.rs:507,wireless/wifi.rs:504) and once from the operational task(
wireless/thread.rs:579,wireless/wifi.rs:576). §11.1.6.1's "bootor reboot process" wording is per process boot, not per network attach,
so the helper is gated by a
startup_event_emitted: IfMutex<bool>field on
MatterStackthat flips totrueon the first successfulemission and short-circuits subsequent calls. On
Errthe flag staysfalseso a transient KV failure on theEventNumberepoch-boundarywrite gets retried on the next
run_dm.SoftwareVersionis pulled fromself.matter().dev_det().sw_ver.Failures are logged at
warn!, not propagated — a zero-sized eventsringbuf already silently drops events on emission, and there's no
reason to fail the run loop over a missing observability event.
If the device boots uncommissioned, StartUp fires during the
commissioning
run_dm, before any controller is bound. It lands inthe ringbuf and the commissioner picks it up on its first subscribe
after CASE — which is correct per the buffered event-subscription
model and consistent with §11.1.6.1's silence on who must receive
the event.
Test plan
cargo build/cargo clippy --no-depsclean onnextHEAD.device-side log shows
BasicInformation::StartUp emitted (sw_ver=1, event_number=50000)~2.3 s after boot; controller-side log showsClientEventEmitter Received event basicInformation.startUp on server-2-134b.@1:37 softwareVersion: 1after the next subscribe.EventNumberincrements byEVENT_NUMBER_EPOCH_SIZE(10000) perreboot, confirming persist EventNumber across restarts (Matter Core §7.14.1.1) #39's persistence still works through this path.