Skip to content

Dynamic protocols switching#113

Merged
edmont merged 6 commits into
nrfconnect:mainfrom
edmont:pr/dynamic-switch
Jun 10, 2026
Merged

Dynamic protocols switching#113
edmont merged 6 commits into
nrfconnect:mainfrom
edmont:pr/dynamic-switch

Conversation

@edmont

@edmont edmont commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Add the option to switch between Matter and Zigbee (and vice-versa) on a long button press.
Also allow to disable Matter commissioning advertisement while Zigbee is running.

TODO:

  • Docs

@edmont edmont requested a review from Copilot June 3, 2026 14:33
@edmont edmont requested a review from a team as a code owner June 3, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Zigbee+Matter coexistence runtime to support user-triggered protocol switching (via long button press) and adds configuration options for (a) choosing the default protocol on factory-fresh boot and (b) optionally avoiding Matter BLE commissioning advertisement while Zigbee is active.

Changes:

  • Add Kconfig-controlled default protocol selection on first boot (before any persisted state exists).
  • Add coexistence options and APIs for long-press protocol switching and for gating the “Matter ready” signal (BLE-advertising event vs explicit app signal).
  • Track “Zigbee commissioning/join active” state to block protocol switching during commissioning operations.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
subsys/lib/zigbee_matter_protocol_state/matter_protocol_state.c Applies a configurable default protocol when no persisted state is present.
subsys/lib/zigbee_matter_protocol_state/Kconfig Adds a choice for selecting the default protocol on first boot.
subsys/lib/zigbee_matter_coexistence/Kconfig Adds options for BLE commissioning while Zigbee is active and for button-based protocol switching.
subsys/lib/zigbee_matter_coexistence/coexistence.cpp Implements long-press switch handling, Zigbee reboot switch path, and “Matter init done” signaling.
subsys/lib/zigbee_app_utils/zigbee_app_utils.c Introduces a global commissioning-active flag and integrates it into commissioning/rejoin flows.
samples/light_switch/src/app_task.cpp Signals Matter board init completion to coexistence runtime when BLE-based signaling is disabled.
samples/light_switch/src/app_task_zigbee.c Adds long-press switch button handling and commissioning tracking for Touchlink initiation.
samples/light_switch/prj_matter_fota.conf Enables coexistence runtime logging level in the sample config.
samples/light_bulb/src/app_task_zigbee.cpp Adds long-press switch button handling for the Zigbee button callback path.
samples/light_bulb/src/app_task_matter.cpp Signals Matter board init completion to coexistence runtime when BLE-based signaling is disabled.
samples/light_bulb/prj_matter_fota.conf Enables coexistence runtime logging level in the sample config.
include/zigbee/zigbee_app_utils.h Exposes commissioning-active query/set APIs for samples and runtime coordination.
include/zigbee/matter_protocol_state.h Updates module documentation to reference configurable first-boot default behavior.
include/zigbee/matter_coexistence.h Adds new coexistence APIs and updates documentation for Matter-init signaling and button switching.
Comments suppressed due to low confidence (1)

samples/light_switch/src/app_task_zigbee.c:270

  • zigbee_network_join_commissioning_set_active(true) is set before starting Touchlink commissioning, but if bdb_start_top_level_commissioning() rejects the request the flag is never restored/cleared. This can leave the global commissioning-active state stuck true.
	zigbee_network_join_commissioning_set_active(true);
	zigbee_touchlink_initiator_prepare_scan_channels();
	if (!bdb_start_top_level_commissioning(ZB_BDB_TOUCHLINK_COMMISSIONING)) {
		LOG_WRN("Touchlink commissioning rejected (already in progress?)");
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread subsys/lib/zigbee_app_utils/zigbee_app_utils.c
Comment thread include/zigbee/matter_coexistence.h
Comment thread subsys/lib/zigbee_app_utils/zigbee_app_utils.c Outdated
@edmont edmont force-pushed the pr/dynamic-switch branch from 193a009 to a4567cf Compare June 4, 2026 07:20
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Documentation Preview

The documentation has been built successfully. You can view the preview here: preview

Generated at: 2026-06-10 09:41:17 UTC with commit 14d6768.

Expand to view changed pages
File Preview
docs/architectures.rst View
samples/light_bulb/README.rst View
samples/light_switch/README.rst View

Note: The preview will be available after GitHub Pages deployment completes (usually 1-2 minutes). Ensure that generated at timestamp is up to date. If the Pull Request is stale for more than 30 days, the preview may be deleted. In this case, please update the Pull Request, or re-run the Build Documentation workflow to generate a new preview.

@ArekBalysNordic ArekBalysNordic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall lgtm, some comments to consider.

Comment thread docs/includes/matter_extension_limitations.txt Outdated
Comment thread docs/includes/matter_extension_limitations.txt Outdated
Comment thread docs/includes/matter_extension_protocol_switch.txt Outdated
Comment thread subsys/lib/zigbee_matter_protocol_state/matter_protocol_state.c Outdated
@edmont edmont force-pushed the pr/dynamic-switch branch from a4567cf to d17cfd3 Compare June 5, 2026 11:04
@edmont edmont requested a review from annwoj June 5, 2026 11:52
edmont added 4 commits June 10, 2026 08:54
Add an atomic flag set while top-level BDB commissioning runs so
coexistence can block protocol switches during join without treating
idle unjoined devices as always pairing.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Wire coexistence button handling on the light switch and light bulb
combined samples.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Let combined builds choose Zigbee or Matter as the initial protocol when
no persisted settings entry exists yet.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Comment thread docs/includes/matter_extension_protocol_switch.txt Outdated
@edmont edmont force-pushed the pr/dynamic-switch branch from d17cfd3 to 317c773 Compare June 10, 2026 08:53
Comment thread docs/includes/matter_extension_limitations.txt Outdated
Comment thread docs/includes/matter_extension_limitations.txt Outdated
Comment thread docs/includes/matter_extension_protocol_switch.txt Outdated
Comment thread docs/includes/matter_extension_protocol_switch.txt Outdated
Comment thread docs/includes/matter_extension_protocol_switch.txt Outdated
Comment thread docs/includes/matter_extension_protocol_switch.txt Outdated
Comment thread docs/architectures.rst Outdated
Document the behavior of `CONFIG_ZIGBEE_MATTER_PROTOCOL_STATE_DEFAULT_PROTOCOL`
and `CONFIG_ZIGBEE_MATTER_COEXISTENCE_BUTTON_SWITCH`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
@edmont edmont force-pushed the pr/dynamic-switch branch from 317c773 to 14d6768 Compare June 10, 2026 09:39
@edmont edmont merged commit 12f7ce6 into nrfconnect:main Jun 10, 2026
4 checks passed
@edmont edmont deleted the pr/dynamic-switch branch June 10, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants