Skip to content

Commit 8856fdb

Browse files
samples: combained Matter + Zigbee Application rework
- Created two separate app tasks for Matter and Zigbee. - Combained two protocols in the main.cpp file. - Rework of configuration to be compliant with Matter. - Added a variant to sample.yaml. - Fixed nrf54lm20 configuration. Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
1 parent 6ba420c commit 8856fdb

19 files changed

Lines changed: 1056 additions & 1630 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99

1010
# build
1111
/build*
12+
/samples/**/build*
1213
/twister-out*
1314

1415
# docs

samples/light_bulb/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ project("Zigbee + Matter Light Bulb with FOTA")
1818
if(CONFIG_CHIP)
1919
# Enable GNU STD support for Matter
2020
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
21-
21+
22+
# Include all source files that are located in the Matter common directory.
23+
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/source_common.cmake)
24+
2225
# Include Data Model utils (simplified for Zigbee coexistence)
2326
include(${ZEPHYR_NRF_MODULE_DIR}/samples/matter/common/cmake/data_model.cmake)
2427

@@ -35,16 +38,19 @@ if(CONFIG_CHIP)
3538

3639
# NORDIC SDK APP START
3740
target_sources(app PRIVATE
38-
src/main_matter.c
39-
src/matter_init.cpp
41+
src/main.cpp
42+
src/app_task_zigbee.cpp
43+
src/app_task_matter.cpp
44+
${CHIP_ROOT}/src/app/persistence/DeferredAttributePersistenceProvider.cpp
4045
)
4146

4247
ncs_configure_data_model()
4348
# NORDIC SDK APP END
4449
else()
4550
# Zigbee-only build
4651
target_sources(app PRIVATE
47-
src/main.c
52+
src/main.cpp
53+
src/app_task_zigbee.cpp
4854
)
4955

5056
target_include_directories(app PRIVATE include)

samples/light_bulb/CMakeLists_matter.txt

Lines changed: 0 additions & 51 deletions
This file was deleted.

samples/light_bulb/Kconfig

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
source "Kconfig.zephyr"
7+
# Sample configuration used for Thread networking
8+
if OPENTHREAD
9+
10+
choice OPENTHREAD_NORDIC_LIBRARY_CONFIGURATION
11+
default OPENTHREAD_NORDIC_LIBRARY_FTD
12+
endchoice
13+
14+
choice OPENTHREAD_DEVICE_TYPE
15+
default OPENTHREAD_FTD
16+
endchoice
17+
18+
endif # OPENTHREAD
819

9-
# Include Matter common sample Kconfig if Matter is enabled
10-
rsource "$(ZEPHYR_NRF_MODULE_DIR)/samples/matter/common/src/Kconfig"
20+
config MPSL_THREAD_COOP_PRIO
21+
default 8
22+
23+
if CHIP
24+
source "$(ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR)/config/nrfconnect/chip-module/Kconfig.features"
25+
source "$(ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR)/config/nrfconnect/chip-module/Kconfig.defaults"
26+
source "$(ZEPHYR_NRF_MODULE_DIR)/samples/matter/common/src/Kconfig"
27+
endif
28+
29+
source "Kconfig.zephyr"

samples/light_bulb/Kconfig_sysbuild_matter_fota

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,3 @@ config DFU_MULTI_IMAGE_PACKAGE_NET
6969
endif # SOC_SERIES_NRF53X
7070

7171
endif # BOOTLOADER_MCUBOOT
72-
73-
#### Enable generating Matter factory data
74-
config MATTER_FACTORY_DATA_GENERATE
75-
default y

samples/light_bulb/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66

77
/ {
88
chosen {
9-
ncs,zigbee-timer = &timer24;
9+
ncs,zigbee-timer = &timer23;
10+
ncs,zboss-trace-uart = &uart20;
11+
};
12+
13+
aliases {
14+
/* Configure PWM module for led1 (LED2 on the board) */
15+
pwm-led1 = &pwm_led3;
1016
};
1117

1218
pwmleds {
@@ -17,16 +23,6 @@
1723
};
1824
};
1925

20-
// restore full RRAM and SRAM space - by default some parts are dedicated to FLRP
21-
&cpuapp_rram {
22-
reg = <0x0 DT_SIZE_K(2036)>;
23-
};
24-
25-
&cpuapp_sram {
26-
reg = <0x20000000 DT_SIZE_K(512)>;
27-
ranges = <0x0 0x20000000 DT_SIZE_K(512)>;
28-
};
29-
3026
&pwm20 {
3127
status = "okay";
3228
pinctrl-0 = <&pwm_default>;
@@ -48,6 +44,6 @@
4844
};
4945
};
5046

51-
&timer24 {
47+
&timer23 {
5248
status = "okay";
5349
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#pragma once
8+
9+
#include "board/board.h"
10+
#include "pwm/pwm_device.h"
11+
12+
#include <platform/CHIPDeviceLayer.h>
13+
14+
struct k_timer;
15+
struct Identify;
16+
17+
enum class LightingActor : uint8_t { Remote, Button };
18+
19+
struct LightingEvent {
20+
uint8_t Action;
21+
LightingActor Actor;
22+
};
23+
24+
class AppTask {
25+
public:
26+
static AppTask &Instance() {
27+
static AppTask sAppTask;
28+
return sAppTask;
29+
};
30+
31+
CHIP_ERROR StartApp();
32+
33+
void UpdateClusterState();
34+
void InitPWMDDevice();
35+
Nrf::PWMDevice &GetPWMDevice() { return mPWMDevice; }
36+
37+
private:
38+
CHIP_ERROR Init();
39+
40+
static void LightingActionEventHandler(const LightingEvent &event);
41+
static void ButtonEventHandler(Nrf::ButtonState state,
42+
Nrf::ButtonMask hasChanged);
43+
44+
static void ActionInitiated(Nrf::PWMDevice::Action_t action, int32_t actor);
45+
static void ActionCompleted(Nrf::PWMDevice::Action_t action, int32_t actor);
46+
47+
Nrf::PWMDevice mPWMDevice;
48+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef APP_TASK_ZIGBEE_H
8+
#define APP_TASK_ZIGBEE_H 1
9+
10+
void ZigbeeStart(void);
11+
12+
#endif /* APP_TASK_ZIGBEE_H */
File renamed without changes.

0 commit comments

Comments
 (0)