Skip to content
Draft
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
4 changes: 2 additions & 2 deletions drivers/bluetooth/hci/hci_stm32wba.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static int bt_hci_stm32wba_open(const struct device *dev, bt_hci_recv_t recv)
struct hci_data *data = dev->data;
int ret = 0;

link_layer_register_isr();
link_layer_register_isr(0);

ret = bt_ble_ctlr_init();
if (ret == 0) {
Expand Down Expand Up @@ -563,7 +563,7 @@ static int radio_pm_action(const struct device *dev, enum pm_device_action actio
#if defined(CONFIG_PM_S2RAM)
if (LL_PWR_IsActiveFlag_SB() == 1U) {
/* Put the radio in active state */
link_layer_register_isr();
link_layer_register_isr(1);
}
#endif /* CONFIG_PM_S2RAM */
LINKLAYER_PLAT_NotifyWFIExit();
Expand Down
4 changes: 2 additions & 2 deletions drivers/ieee802154/ieee802154_stm32wba.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ static void stm32wba_802154_iface_init(struct net_if *iface)
.stm32wba_802154_ral_cbk_tx_ack_started = stm32wba_802154_tx_ack_started,
};

link_layer_register_isr();
link_layer_register_isr(0);

#if !defined(CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA)
ll_sys_thread_init();
Expand Down Expand Up @@ -995,7 +995,7 @@ static int radio_pm_action(const struct device *dev, enum pm_device_action actio
if (LL_PWR_IsActiveFlag_SB() == 1U) {
/* Put the radio in active state */
LL_AHB5_GRP1_EnableClock(LL_AHB5_GRP1_PERIPH_RADIO);
link_layer_register_isr();
link_layer_register_isr(1);
}
LINKLAYER_PLAT_NotifyWFIExit();
ll_sys_dp_slp_exit();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sockets_echo_client)

if(CONFIG_NET_SOCKETS_SOCKOPT_TLS AND
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED AND
(CONFIG_NET_SAMPLE_PSK_HEADER_FILE STREQUAL "dummy_psk.h"))
add_custom_target(development_psk
COMMAND ${CMAKE_COMMAND} -E echo "----------------------------------------------------------"
COMMAND ${CMAKE_COMMAND} -E echo "--- WARNING: Using dummy PSK! Only suitable for ---"
COMMAND ${CMAKE_COMMAND} -E echo "--- development. Set NET_SAMPLE_PSK_HEADER_FILE to use ---"
COMMAND ${CMAKE_COMMAND} -E echo "--- own pre-shared key. ---"
COMMAND ${CMAKE_COMMAND} -E echo "----------------------------------------------------------"
)
add_dependencies(app development_psk)
endif()

target_sources( app PRIVATE src/echo-client.c)
target_sources( app PRIVATE src/app_ble.c)
target_sources_ifdef(CONFIG_NET_UDP app PRIVATE src/udp.c)
target_sources_ifdef(CONFIG_NET_TCP app PRIVATE src/tcp.c)

include(${ZEPHYR_BASE}/samples/net/common/common.cmake)

set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/)

generate_inc_file_for_target(
app
src/echo-apps-cert.der
${gen_dir}/echo-apps-cert.der.inc
)
61 changes: 61 additions & 0 deletions samples/boards/st/ble_802154/ble_hr_802154_echo_client/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Private config options for ble HR - Networking echo-client sample app

# Copyright (c) 2018 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

mainmenu "Ble Heart Rate - Networking echo-client sample application"

config NET_SAMPLE_IFACE2_MY_IPV6_ADDR
string "My IPv6 address for second interface"
help
The value depends on your network setup.

config NET_SAMPLE_IFACE2_MY_IPV4_ADDR
string "My IPv4 address for second interface"
help
The value depends on your network setup.

config NET_SAMPLE_IFACE2_VLAN_TAG
int "VLAN tag for second interface"
default 100
range 0 4094
depends on NET_VLAN
help
Set VLAN (virtual LAN) tag (id) that is used in the sample
application.

config NET_SAMPLE_IFACE3_MY_IPV6_ADDR
string "My IPv6 address for third interface"
help
The value depends on your network setup.

config NET_SAMPLE_IFACE3_MY_IPV4_ADDR
string "My IPv4 address for third interface"
help
The value depends on your network setup.

config NET_SAMPLE_IFACE3_VLAN_TAG
int "VLAN tag for third interface"
default 200
range 0 4094
depends on NET_VLAN
help
Set VLAN (virtual LAN) tag (id) that is used in the sample
application.

config NET_SAMPLE_PSK_HEADER_FILE
string "Header file containing PSK"
default "dummy_psk.h"
depends on MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
help
Name of a header file containing a
pre-shared key.

config NET_SAMPLE_SEND_ITERATIONS
int "Send sample data this many times"
default 0
help
Send sample data this many times before exiting. A value of
zero means that the sample application is run forever.

source "Kconfig.zephyr"
68 changes: 68 additions & 0 deletions samples/boards/st/ble_802154/ble_hr_802154_echo_client/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.. zephyr:code-sample:: stm32_ble_hr_802154_echo_client
:name: Ble HR - 802154 Echo client (advanced)

Implement a Bluetooth Heart Rate - 802154 client.
The Bluetooth Heart Rate (HR) GATT Service generates dummy heart-rate
values and the 802154 echo client sends IP packets, waits for data
to be sent back, and verifies it.

Overview
********

The sample application for Zephyr implements a concurrent mode
BLE - IEEE802.15.4.
The 802.15.4 part implements UDP/TCP client that will send IPv4
or IPv6 packets, wait for the data to be sent back, and then verify
it matches the data that was sent.
The BLE part exposes the HR (Heart Rate) GATT Service. Once a device
connects it will generate dummy heart-rate values.

The source code for this sample application can be found at:
:zephyr_file:`samples/boards/st/ble_802154/ble_hr_802154_echo_client`.

Requirements
************

- :ref:`networking_with_host`
* BlueZ running on the host, or
* A board with Bluetooth LE support

Building and Running
********************


There are configuration files for different boards and setups in the
samplet directory:

- :file:`prj.conf`
Generic config file, normally you should use this.

- :file:`overlay-802154.conf`
This overlay config enables support for native IEEE 802.15.4 connectivity.
Note, that by default IEEE 802.15.4 L2 uses unacknowledged communication. To
improve connection reliability, acknowledgments can be enabled with shell
command: ``ieee802154 ack set``.

Build sample application like this:

.. zephyr-app-commands::
:zephyr-app: samples/boards/st/ble_802154/ble_hr_802154_echo_client
:board: <board to use>
:conf: <config file to use>
:goals: build
:compact:

Example building for the IEEE 802.15.4 on nucleo_wba65ri:

.. zephyr-app-commands::
:zephyr-app: samples/boards/st/ble_802154/ble_hr_802154_echo_client
:board: nucleo_wba65ri
:gen-args: -DEXTRA_CONF_FILE=overlay-802154.conf
:goals: build
:compact:

In a terminal window you can check if communication is happen:

.. code-block:: console

$ minicom -D /dev/ttyACM1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2020 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

if [ -z "$RUNNING_FROM_MAIN_SCRIPT" ]; then
echo "Do not run this script directly!"
echo "Run $ZEPHYR_BASE/scripts/net/run-sample-tests.sh instead."
exit 1
fi

start_configuration "--ip=192.0.2.1 --ip6=2001:db8::1" || return $?
start_docker "/net-tools/echo-server -i eth0" || return $?

start_zephyr "$overlay" "-DCONFIG_NET_SAMPLE_SEND_ITERATIONS=10"

wait_zephyr
result=$?

stop_docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Disable TCP and IPv4 (TCP disabled to avoid heavy traffic)
CONFIG_NET_TCP=n
CONFIG_NET_IPV4=n
CONFIG_NET_CONFIG_AUTO_INIT=n

CONFIG_NET_CONFIG_NEED_IPV6=y
CONFIG_NET_CONFIG_NEED_IPV4=n
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1"

CONFIG_NET_L2_IEEE802154=y
CONFIG_NET_L2_IEEE802154_SHELL=y
CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y

CONFIG_NET_CONFIG_IEEE802154_CHANNEL=26

CONFIG_NET_L2_IEEE802154_FRAGMENT_REASS_CACHE_SIZE=5
65 changes: 65 additions & 0 deletions samples/boards/st/ble_802154/ble_hr_802154_echo_client/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Generic networking options
CONFIG_NETWORKING=y
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_ZVFS_POLL_MAX=5
CONFIG_NET_CONNECTION_MANAGER=y

CONFIG_POSIX_API=y

# Kernel options
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_INIT_STACKS=y
CONFIG_MAX_THREAD_BYTES=3

# Logging
CONFIG_NET_LOG=y
CONFIG_LOG=y
CONFIG_NET_STATISTICS=y
CONFIG_PRINTK=y

# Network buffers
CONFIG_NET_PKT_RX_COUNT=16
CONFIG_NET_PKT_TX_COUNT=16
CONFIG_NET_BUF_RX_COUNT=80
CONFIG_NET_BUF_TX_COUNT=80
CONFIG_NET_CONTEXT_NET_PKT_POOL=y

# IP address options
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_IF_MAX_IPV6_COUNT=3
CONFIG_NET_IF_MAX_IPV4_COUNT=3

# Network shell
CONFIG_NET_SHELL=y

# The addresses are selected so that qemu<->qemu connectivity works ok.
# For linux<->qemu connectivity, create a new conf file and swap the
# addresses (so that peer address is ending to 2).
CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_NEED_IPV6=y
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::2"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_NEED_IPV4=y
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.2"
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.1"
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Bluetootn configuration
CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=n
CONFIG_BT_BAS=y
CONFIG_BT_HRS=y
CONFIG_BT_DEVICE_NAME="Zephyr HR 802154 Echo Client"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB=y
12 changes: 12 additions & 0 deletions samples/boards/st/ble_802154/ble_hr_802154_echo_client/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sample:
description: Test concurrent mode Ble HeartRate - IEEE802.15.4 echo client
name: Ble Heart Rate - Socket Echo Client
tests:
sample.boards.stm32.ble_802154.ble_hr_802154_echo_client:
harness: net
extra_args: EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow: nucleo_wba65ri
tags:
- bluetooth
- net
- socket
Loading