Skip to content

Dynamic protocols switching#113

Open
edmont wants to merge 5 commits into
nrfconnect:mainfrom
edmont:pr/dynamic-switch
Open

Dynamic protocols switching#113
edmont wants to merge 5 commits into
nrfconnect:mainfrom
edmont:pr/dynamic-switch

Conversation

@edmont
Copy link
Copy Markdown
Collaborator

@edmont edmont commented Jun 3, 2026

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 added 5 commits June 3, 2026 13:42
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>
Make CHIPoBLE during the Zigbee phase, user button switching, and hold
time independently configurable.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
@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
Copy link
Copy Markdown

Copilot AI left a comment

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 on lines +57 to +61
static zb_bool_t bdb_start_commissioning_tracked(zb_uint8_t mode_mask)
{
zigbee_network_join_commissioning_set_active(true);
return bdb_start_top_level_commissioning(mode_mask);
}
Comment on lines +87 to +89
* Detects a long press on @p switch_button and requests a protocol switch
* when @kconfig_ZIGBEE_MATTER_COEXISTENCE_SWITCH_BUTTON_PRESS_TIME_SECONDS
* expires.
Comment on lines +1149 to 1150
if (bdb_start_commissioning_tracked(ZB_BDB_NETWORK_STEERING) != ZB_TRUE) {
LOG_WRN("Network steering: bdb_start_top_level_commissioning rejected");
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.

2 participants