Skip to content

Commit 5568620

Browse files
committed
samples: Enable end-to-end commissioning
Make ETS6 and the OpenThread Joiner the default sample flow and provide optional hardcoded and shell-based profiles. Signed-off-by: Adam Maciuga <adam.maciuga@nordicsemi.no>
1 parent 2a60099 commit 5568620

14 files changed

Lines changed: 226 additions & 82 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2026 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
# Use fixed KNX group bindings and a group OSCORE key instead of ETS6.
5+
6+
CONFIG_KNX_HARDCODED_COMMISSIONING=y
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2026 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
# Optional Thread profile for a fixed dataset.
5+
6+
CONFIG_OPENTHREAD_JOINER=n
7+
CONFIG_OPENTHREAD_JOINER_AUTOSTART=n
8+
CONFIG_OPENTHREAD_MANUAL_START=n
9+
10+
# Fixed dataset.
11+
CONFIG_OPENTHREAD_PANID=4813
12+
CONFIG_OPENTHREAD_CHANNEL=20
13+
CONFIG_OPENTHREAD_NETWORK_NAME="knx-lab"
14+
CONFIG_OPENTHREAD_XPANID="de:ad:00:be:ef:00:ca:fe"
15+
CONFIG_OPENTHREAD_NETWORKKEY="ae:f0:08:f1:9a:cb:ad:8b:9e:a3:7e:74:90:dd:8c:04"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2026 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
# Disables automatic network bring up, allowing for manual setup from shell
5+
6+
CONFIG_OPENTHREAD_JOINER=y
7+
CONFIG_OPENTHREAD_JOINER_AUTOSTART=n
8+
CONFIG_OPENTHREAD_MANUAL_START=y

‎samples/common/thread_hardcoded.conf‎

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* KNX Stack sends a lot of logs speed needs to be increased to avoid dropping them.
9+
*/
10+
11+
&uart20 {
12+
current-speed = <1000000>;
13+
};

‎samples/light_switch_actuator/knx_actuator.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
LOG_MODULE_REGISTER(knx_actuator, LOG_LEVEL_INF);
2929

30-
static void actuator_set_light(bool on)
30+
static void actuator_set_light(uint8_t channel, bool on)
3131
{
32-
knx_board_set_app_led(on);
32+
knx_board_set_app_led((enum knx_board_app_led)channel, on);
3333
}
3434

3535
/* Datapoint indices within a switching channel. */
@@ -139,20 +139,22 @@ static void actuator_on_write(const knx_datapoint_t *dp)
139139
return;
140140
}
141141

142-
actuator_set_light(value);
142+
actuator_set_light(KNX_DP_CHANNEL(dp->id), value);
143143
LOG_INF("Light turned %s", value ? "on" : "off");
144144
}
145145
}
146146

147147
static void actuator_on_init(void)
148148
{
149-
bool value = false;
149+
for (uint8_t channel = 0; channel < NUM_CHANNELS; channel++) {
150+
bool value = false;
150151

151-
if (knx_datapoint_get_bool(KNX_DP_ID(0, SOO), &value) < 0) {
152-
LOG_ERR("failed to read initial actuator SOO");
153-
}
152+
if (knx_datapoint_get_bool(KNX_DP_ID(channel, SOO), &value) < 0) {
153+
LOG_ERR("failed to read initial actuator SOO");
154+
}
154155

155-
actuator_set_light(value);
156+
actuator_set_light(channel, value);
157+
}
156158
}
157159

158160
static const knx_device_t actuator_device = {

‎samples/light_switch_actuator/main.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@
88

99
#include <knx/knx_app.h>
1010
#include <stdlib.h>
11-
#include <zephyr/kernel.h>
1211
#include <zephyr/logging/log.h>
1312

1413
LOG_MODULE_REGISTER(light_switch_actuator, LOG_LEVEL_INF);
1514

1615
int main(void)
1716
{
17+
int err;
18+
1819
LOG_INF("KNX IoT light switch actuator");
1920

2021
app_register_device();
2122

22-
if (knx_app_start()) {
23-
LOG_ERR("Error Initiating KNX App");
23+
err = knx_app_start();
24+
25+
if (err) {
26+
LOG_ERR("Failed to start KNX application: %d", err);
2427
return EXIT_FAILURE;
2528
}
29+
2630
return EXIT_SUCCESS;
2731
}
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,50 @@
11
# Copyright (c) 2026 Nordic Semiconductor ASA
22
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
33

4+
# Debug configuration with shell and logs enabled
5+
6+
# KNX ETS commissioning.
47
CONFIG_KNX_IOT_ADD_ON=y
58

6-
# MVP: hardcode identity + group tables + a shared group OSCORE key so the
7-
# sensor and actuator talk with no ETS / commissioner (subsys/knx/knx_presets.c).
8-
CONFIG_KNX_HARDCODED_COMMISSIONING=y
9+
CONFIG_KNX_PROGRAMMING_MODE_AUTOSTART=n
10+
11+
# Sleepy End Device operation.
12+
CONFIG_OPENTHREAD=y
13+
CONFIG_OPENTHREAD_MTD=y
14+
CONFIG_OPENTHREAD_MTD_SED=y
15+
CONFIG_OPENTHREAD_POLL_PERIOD=500
16+
CONFIG_OPENTHREAD_SRP_CLIENT=y
17+
CONFIG_OPENTHREAD_SLAAC=y
18+
CONFIG_OPENTHREAD_SHELL=y
19+
20+
# Automatically join a Commissioner-authorized Thread network.
21+
CONFIG_OPENTHREAD_JOINER=y
22+
CONFIG_OPENTHREAD_JOINER_AUTOSTART=y
23+
CONFIG_OPENTHREAD_JOINER_PSKD="N0RD1C"
24+
CONFIG_OPENTHREAD_MANUAL_START=n
25+
26+
# Keep retained multicast echo messages within the available heap.
27+
CONFIG_KNXIOT_ECHO_RING_SIZE=16
928

1029
CONFIG_MAIN_STACK_SIZE=4096
1130

1231
# Persistent storage backend.
1332
CONFIG_ZMS=y
1433
CONFIG_SETTINGS_ZMS=y
1534

35+
# User interface.
1636
CONFIG_GPIO=y
1737
CONFIG_DK_LIBRARY=y
1838

39+
# Development shell and diagnostics.
1940
CONFIG_SHELL=y
41+
CONFIG_SHELL_STACK_SIZE=8192
42+
CONFIG_SHELL_CMD_BUFF_SIZE=512
2043

2144
CONFIG_MBEDTLS_HEAP_SIZE=30000
2245

2346
CONFIG_LOG=y
47+
CONFIG_LOG_BACKEND_UART=n
48+
CONFIG_SHELL_LOG_BACKEND=y
2449

2550
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
sample:
22
name: KNX IoT Light Switch Actuator
33
description: KNX IoT light switch actuator sample
4+
common:
5+
sysbuild: true
6+
build_only: true
7+
integration_platforms:
8+
- nrf54l15dk/nrf54l15/cpuapp
9+
- nrf54lm20dk/nrf54lm20a/cpuapp
10+
- nrf54lm20dk/nrf54lm20b/cpuapp
11+
platform_allow:
12+
- nrf54l15dk/nrf54l15/cpuapp
13+
- nrf54lm20dk/nrf54lm20a/cpuapp
14+
- nrf54lm20dk/nrf54lm20b/cpuapp
15+
tags:
16+
- ci_build
417
tests:
5-
samples.knx_iot.light_switch_actuator:
6-
sysbuild: true
7-
build_only: true
8-
integration_platforms:
9-
- nrf54l15dk/nrf54l15/cpuapp
10-
- nrf54lm20dk/nrf54lm20a/cpuapp
11-
- nrf54lm20dk/nrf54lm20b/cpuapp
12-
platform_allow:
13-
- nrf54l15dk/nrf54l15/cpuapp
14-
- nrf54lm20dk/nrf54lm20a/cpuapp
15-
- nrf54lm20dk/nrf54lm20b/cpuapp
18+
# Default: ETS6 commissioning + automatic Thread Joiner.
19+
samples.knx_iot.light_switch_actuator: {}
20+
samples.knx_iot.light_switch_actuator.release:
1621
extra_args:
17-
- EXTRA_CONF_FILE=../common/thread_hardcoded.conf
18-
tags:
19-
- ci_build
20-
22+
- FILE_SUFFIX=release
23+
samples.knx_iot.light_switch_actuator.knx_hardcoded:
24+
extra_args:
25+
- EXTRA_CONF_FILE=../common/overlay-knx-hardcoded.conf
26+
samples.knx_iot.light_switch_actuator.thread_hardcoded:
27+
extra_args:
28+
- EXTRA_CONF_FILE=../common/overlay-thread-hardcoded.conf
29+
samples.knx_iot.light_switch_actuator.thread_otshell:
30+
extra_args:
31+
- EXTRA_CONF_FILE=../common/overlay-thread-otshell.conf
32+
samples.knx_iot.light_switch_actuator.hardcoded:
33+
extra_args:
34+
- EXTRA_CONF_FILE=../common/overlay-knx-hardcoded.conf;../common/overlay-thread-hardcoded.conf
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2026 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/*
8+
* KNX Stack sends a lot of logs speed needs to be increased to avoid dropping them.
9+
*/
10+
11+
&uart20 {
12+
current-speed = <1000000>;
13+
};

0 commit comments

Comments
 (0)