Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions include/zigbee/zigbee_bt_dfu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2026 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/**
* @file zigbee_bt_dfu.h
*
* @brief DFU over Bluetooth LE SMP helpers for Zigbee applications.
*/

#ifndef ZIGBEE_BT_DFU_H_
#define ZIGBEE_BT_DFU_H_

#ifdef __cplusplus
extern "C" {
#endif

void zigbee_bt_dfu_init(void);

#ifdef __cplusplus
}
#endif

#endif /* ZIGBEE_BT_DFU_H_ */
2 changes: 1 addition & 1 deletion samples/light_switch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(CONFIG_CHIP)

target_sources(app PRIVATE
src/main.cpp
src/app_task.cpp
src/app_task_matter.cpp
src/app_task_zigbee.c
src/light_switch.cpp
src/shell_commands.cpp
Expand Down
7 changes: 7 additions & 0 deletions samples/light_switch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ config LIGHT_SWITCH_LOW_POWER
help
Enable low power mode for the Light Switch sample.
This enables sleepy behavior and disables LEDs for power savings.

if CONFIG_ZIGBEE_BT_DFU

config BT_DEVICE_NAME
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.

Maybe we should start using configdefault to not remove dependencies from the original kconfigs, but I will not push you to do it :)

default "Zigbee_Switch"

endif # CONFIG_ZIGBEE_BT_DFU
Comment on lines +60 to +65
6 changes: 5 additions & 1 deletion samples/light_switch/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ Source file setup

This sample is split into the following source files:

* The :file:`main` file to handle initialization and light switch basic behavior.
* The :file:`main` file is the application entry point only.
* The :file:`app_task_zigbee` file manages the application task flow, user input handling, and Zigbee-specific startup and control logic.
* The :file:`app_task_matter` file is used in the Matter extension build only.
It implements the application tasks flow: button input, timers, and delegating control actions to bound lighting devices.
* The :file:`light_switch` file to implement the light switch application logic and interaction with Zigbee clusters.
* An additional :file:`nus_cmd` file for handling NUS commands.

.. _zigbee_light_switch_activating_variants:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
* Copyright (c) 2026 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
Expand Down
42 changes: 42 additions & 0 deletions samples/light_switch/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ tests:
- smoke
- sysbuild
- ci_samples_zigbee
sample.zigbee.light_switch.matter.bt_dfu:
sysbuild: true
build_only: true
extra_args:
- FILE_SUFFIX=matter_fota
- CONFIG_CHIP_DFU_OVER_BT_SMP=y
integration_platforms:
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54lm20dk/nrf54lm20b/cpuapp
platform_allow:
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54lm20dk/nrf54lm20b/cpuapp
tags:
- ci_build
- smoke
- sysbuild
- ci_samples_zigbee
sample.zigbee.light_switch:
sysbuild: true
build_only: true
Expand Down Expand Up @@ -148,6 +165,31 @@ tests:
- smoke
- sysbuild
- ci_samples_zigbee
sample.zigbee.light_switch.fota_and_bt_dfu:
sysbuild: true
build_only: true
extra_args:
- FILE_SUFFIX=fota
- CONFIG_ZIGBEE_BT_DFU=y
integration_platforms:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l10/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54lm20dk/nrf54lm20b/cpuapp
platform_allow:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l10/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54lm20dk/nrf54lm20b/cpuapp
tags:
- ci_build
- smoke
- sysbuild
- ci_samples_zigbee
sample.zigbee.light_switch.low_power:
sysbuild: true
build_only: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
* Copyright (c) 2026 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "app_task.h"
#include "app_task_matter.h"

#include "light_switch.h"

Expand Down
25 changes: 21 additions & 4 deletions samples/light_switch/src/app_task_zigbee.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@
#if CONFIG_ZIGBEE_FOTA
#include <zigbee/zigbee_fota.h>
#include <zephyr/sys/reboot.h>
#endif /* CONFIG_ZIGBEE_FOTA */

#if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
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.

NIT, AFAIR we've not used IS_ENABLED anywhere.

Suggested change
#if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU)

#include <zephyr/dfu/mcuboot.h>
#endif

#if CONFIG_ZIGBEE_FOTA
/* LED indicating OTA Client Activity. */
#define OTA_ACTIVITY_LED DK_LED2
#endif /* CONFIG_ZIGBEE_FOTA */

#if IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
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.

Suggested change
#if IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
#ifdef CONFIG_ZIGBEE_BT_DFU

#include <zigbee/zigbee_bt_dfu.h>
#endif

#if CONFIG_BT_NUS
#include "nus_cmd.h"

Expand Down Expand Up @@ -623,7 +632,7 @@ static void light_switch_button_handler(struct k_timer *timer)
}
}

#ifdef CONFIG_ZIGBEE_FOTA
#if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
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.

Suggested change
#if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU)

static void confirm_image(void)
{
if (!boot_is_img_confirmed()) {
Expand All @@ -636,7 +645,9 @@ static void confirm_image(void)
}
}
}
#endif

#ifdef CONFIG_ZIGBEE_FOTA
static void ota_evt_handler(const struct zigbee_fota_evt *evt)
{
switch (evt->id) {
Expand Down Expand Up @@ -940,17 +951,23 @@ int ZigbeeStart(void)
power_down_unused_ram();
}

#if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
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.

Suggested change
#if IS_ENABLED(CONFIG_ZIGBEE_FOTA) || IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
#if defined(CONFIG_ZIGBEE_FOTA) || defined(CONFIG_ZIGBEE_BT_DFU)

/* Mark the current firmware as valid. */
confirm_image();
#endif

#ifdef CONFIG_ZIGBEE_FOTA
/* Initialize Zigbee FOTA download service. */
zigbee_fota_init(ota_evt_handler);

/* Mark the current firmware as valid. */
confirm_image();

/* Register callback for handling ZCL commands. */
ZB_ZCL_REGISTER_DEVICE_CB(zcl_device_cb);
#endif /* CONFIG_ZIGBEE_FOTA */

#if IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
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.

Suggested change
#if IS_ENABLED(CONFIG_ZIGBEE_BT_DFU)
#if defined(CONFIG_ZIGBEE_BT_DFU)

zigbee_bt_dfu_init();
#endif

/* Register dimmer switch device context (endpoints). */
ZB_AF_REGISTER_DEVICE_CTX(&dimmer_switch_ctx);

Expand Down
2 changes: 1 addition & 1 deletion samples/light_switch/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#ifdef CONFIG_ZIGBEE_MATTER_COEXISTENCE

#include "app_task.h"
#include "app_task_matter.h"

#include <zigbee/matter_coexistence.h>

Expand Down
1 change: 1 addition & 0 deletions subsys/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#

add_subdirectory_ifdef(CONFIG_ZIGBEE_FOTA zigbee_fota)
add_subdirectory_ifdef(CONFIG_ZIGBEE_BT_DFU zigbee_bt_dfu)
add_subdirectory_ifdef(CONFIG_ZIGBEE_APP_UTILS zigbee_app_utils)
add_subdirectory_ifdef(CONFIG_ZIGBEE_LOGGER_EP zigbee_logger_ep)
add_subdirectory_ifdef(CONFIG_ZIGBEE_MATTER_COEXISTENCE zigbee_matter_coexistence)
Expand Down
1 change: 1 addition & 0 deletions subsys/lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
menu "Zigbee libraries"

rsource "zigbee_fota/Kconfig"
rsource "zigbee_bt_dfu/Kconfig"
rsource "zigbee_app_utils/Kconfig"
rsource "zigbee_logger_ep/Kconfig"
rsource "zigbee_matter_coexistence/Kconfig"
Expand Down
10 changes: 10 additions & 0 deletions subsys/lib/zigbee_bt_dfu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2026 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

zephyr_library()
zephyr_library_sources(zigbee_bt_dfu.c)

zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)
88 changes: 88 additions & 0 deletions subsys/lib/zigbee_bt_dfu/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#
# Copyright (c) 2026 Nordic Semiconductor ASA
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.

Similar suggestion for configdefaults as above.

#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config ZIGBEE_BT_DFU
bool "Enable DFU over Bluetooth LE SMP feature set"
depends on !CHIP
imply BOOTLOADER_MCUBOOT
select BT
select BT_PERIPHERAL
select MCUMGR
select MCUMGR_TRANSPORT_BT
select IMG_MANAGER
select STREAM_FLASH
select ZCBOR
select MCUMGR_GRP_IMG
select MCUMGR_GRP_OS
select MCUMGR_GRP_IMG_STATUS_HOOKS
# Enable custom SMP request to erase settings partition.
select MCUMGR_GRP_ZBASIC
select MCUMGR_GRP_ZBASIC_STORAGE_ERASE
select MCUMGR_TRANSPORT_BT_REASSEMBLY
help
Enables Device Firmware Upgrade over Bluetooth LE with SMP and configures
the set of options related to that feature.

Cannot be combined with Matter (CONFIG_CHIP), as it requires different Bluetooth LE orchestration.
Use Matter's CONFIG_CHIP_DFU_OVER_BT_SMP instead.

if ZIGBEE_BT_DFU

config BT_MAX_CONN
default 1

# MCU Manager and SMP configuration
choice MCUMGR_TRANSPORT_BT_PERM
default MCUMGR_TRANSPORT_BT_PERM_RW
endchoice

config MCUMGR_TRANSPORT_NETBUF_COUNT
default 6

config MCUMGR_MGMT_NOTIFICATION_HOOKS
bool
default y

config MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK
bool
default y

config MCUMGR_SMP_COMMAND_STATUS_HOOKS
bool
default y

# Increase BT MTU and RX buffer sizes to improve DFU throughput on non-RAM-constrained devices
config BT_L2CAP_TX_MTU
default 498 if !SOC_NRF54L10

config BT_BUF_ACL_RX_SIZE
default 502 if !SOC_NRF54L10

# Increase MCUMGR_TRANSPORT_NETBUF_SIZE, as it must be big enough to fit MAX MTU + overhead and for single-image DFU default is 384 B
config MCUMGR_TRANSPORT_NETBUF_SIZE
default 1024

# Increase system workqueue size, as SMP is processed within it
config SYSTEM_WORKQUEUE_STACK_SIZE
default 2800

if SOC_SERIES_NRF53

# Enable custom SMP request to erase settings partition.
config MCUMGR_GRP_ZBASIC
default y

config MCUMGR_GRP_ZBASIC_STORAGE_ERASE
default y

endif # SOC_SERIES_NRF53

module = ZIGBEE_BT_DFU
module-str = Zigbee Bluetooth LE DFU
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

endif # ZIGBEE_BT_DFU

Loading
Loading