Skip to content

Commit 5f73e4a

Browse files
committed
samples: boards: st: ble ieee802.15.4 concurrent mode
Add sample Bluetooth Heart Rate - 802154 Echo Client Signed-off-by: Vincent Tardy <[email protected]>
1 parent 793eee4 commit 5f73e4a

File tree

8 files changed

+1321
-1
lines changed

8 files changed

+1321
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(st_ble_802154_echo_client)
7+
8+
target_sources(app PRIVATE src/echo-client.c)
9+
target_sources(app PRIVATE src/app_ble.c)
10+
target_sources(app PRIVATE src/udp.c)
11+
12+
include(${ZEPHYR_BASE}/samples/net/common/common.cmake)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. zephyr:code-sample:: stm32_ble_hr_802154_echo_client
2+
:name: BLE HR - 802154 Echo client (advanced)
3+
4+
Implement a Bluetooth |reg| Energy Heart Rate - IEEE 802154 client.
5+
The BLE Heart Rate (HR) GATT Service generates dummy heart-rate
6+
values and the 802154 echo client sends IP packets, waits for data
7+
to be sent back, and verifies it.
8+
9+
Overview
10+
********
11+
12+
The sample application implements a concurrent mode BLE - IEEE 802.15.4.
13+
Both wireless protocols Bluetooth |reg| Energy and IEEE 802.15.4 coexist:
14+
the application supports simultaneously one Bluetooth |reg| Energy connection
15+
and one IEEE 802.15.4 connection.
16+
The 802.15.4 part implements UDP client that will send IPv6 packets,
17+
wait for the data to be sent back, and then verify it matches
18+
the data that was sent.
19+
The BLE part exposes the HR (Heart Rate) GATT Service. Once a device
20+
connects, it will generate dummy heart-rate values.
21+
22+
The source code for this sample application can be found at:
23+
:zephyr_file:`samples/boards/st/bluetooth/ble_hr_802154_echo_client`.
24+
25+
The IEEE 802.15.4 config of the sample enables support for native
26+
IEEE 802.15.4 connectivity.
27+
Note that by default IEEE 802.15.4 L2 uses unacknowledged communication.
28+
To improve connection reliability, acknowledgments can be enabled with
29+
shell command: ``ieee802154 ack set``.
30+
31+
Environment Setup
32+
*****************
33+
34+
This sample has been tested on the STMicroelectonics NUCLEO-WBA65RI board
35+
(nucleo_wba65ri).
36+
This board interacts simultaneously with another board embedding an
37+
echo-server sample with the 802.15.4 overlay (nucleo_wba65ri) and a
38+
smartphone supporting BLE Heart Rate.
39+
40+
Building and Running
41+
********************
42+
43+
Build sample application like this:
44+
45+
.. zephyr-app-commands::
46+
:zephyr-app: samples/boards/st/bluetooth/ble_hr_802154_echo_client
47+
:board: nucleo_wba65ri
48+
:goals: build
49+
:compact:
50+
51+
The LED 1 toggles while application is BLE advertising. Once a remote device
52+
connects, the LED 1 turns ON and application will generate dummy heart-rate values.
53+
Once remote device disconnects, the application restarts BLE advertising and LED 1
54+
toggles.
55+
56+
Simultaneously, IEEE 802.15.4 feature is enabled. To validate behavior, use another
57+
board that will be used as a remote server.
58+
This can be done using echo-server sample application with :file:`overlay-802154.conf`.
59+
60+
.. zephyr-app-commands::
61+
:zephyr-app: samples/net/sockets/echo_server
62+
:board: nucleo_wba65ri
63+
:gen-args: -DEXTRA_CONF_FILE=overlay-802154.conf
64+
:goals: build flash
65+
:compact:
66+
67+
Once both devices are connected, local device will send IPv6 packets, wait for
68+
the data to be sent back from the remote echo-server device, and then verify it
69+
matches the data that was sent.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Generic networking options
2+
CONFIG_NETWORKING=y
3+
CONFIG_NET_UDP=y
4+
CONFIG_NET_IPV6=y
5+
CONFIG_NET_IPV4=n
6+
CONFIG_NET_SOCKETS=y
7+
CONFIG_ZVFS_POLL_MAX=5
8+
CONFIG_NET_CONNECTION_MANAGER=y
9+
10+
CONFIG_POSIX_API=y
11+
12+
# Kernel options
13+
CONFIG_MAIN_STACK_SIZE=2048
14+
CONFIG_ENTROPY_GENERATOR=y
15+
CONFIG_TEST_RANDOM_GENERATOR=y
16+
CONFIG_INIT_STACKS=y
17+
18+
# Logging
19+
CONFIG_NET_LOG=y
20+
CONFIG_LOG=y
21+
CONFIG_NET_STATISTICS=y
22+
CONFIG_PRINTK=y
23+
24+
# Network buffers
25+
CONFIG_NET_PKT_RX_COUNT=16
26+
CONFIG_NET_PKT_TX_COUNT=16
27+
CONFIG_NET_BUF_RX_COUNT=80
28+
CONFIG_NET_BUF_TX_COUNT=80
29+
CONFIG_NET_CONTEXT_NET_PKT_POOL=y
30+
31+
# IP address options
32+
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
33+
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
34+
CONFIG_NET_MAX_CONTEXTS=10
35+
CONFIG_NET_IF_MAX_IPV6_COUNT=3
36+
CONFIG_NET_IF_MAX_IPV4_COUNT=3
37+
38+
# Network shell
39+
CONFIG_NET_SHELL=y
40+
41+
# Network Config
42+
CONFIG_NET_CONFIG_SETTINGS=y
43+
CONFIG_NET_CONFIG_NEED_IPV6=y
44+
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2"
45+
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1"
46+
CONFIG_NET_CONFIG_NEED_IPV4=n
47+
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
48+
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
49+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
50+
CONFIG_NET_RX_STACK_SIZE=2048
51+
52+
CONFIG_NET_L2_IEEE802154=y
53+
CONFIG_NET_L2_IEEE802154_SHELL=y
54+
CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y
55+
56+
CONFIG_NET_CONFIG_IEEE802154_CHANNEL=26
57+
58+
CONFIG_NET_L2_IEEE802154_FRAGMENT_REASS_CACHE_SIZE=5
59+
60+
61+
# Bluetootn configuration
62+
CONFIG_BT=y
63+
CONFIG_BT_SMP=y
64+
CONFIG_BT_PERIPHERAL=y
65+
CONFIG_BT_DIS=y
66+
CONFIG_BT_DIS_PNP=n
67+
CONFIG_BT_BAS=y
68+
CONFIG_BT_HRS=y
69+
CONFIG_BT_DEVICE_NAME="Zephyr HR 802154 Echo Client"
70+
CONFIG_BT_DEVICE_APPEARANCE=833
71+
CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB=y

0 commit comments

Comments
 (0)