Skip to content

Commit 0f6287d

Browse files
Cameron Sovierocjoverbay42
Cameron Soviero
authored andcommitted
samples: bluetooth: mesh: Add new mesh_blob_shell sample, Fix mesh private key generation starvation
- Add new example samples/bluetooth/mesh_blob_shell showing how to use mesh BLOB feature - Bugfix for mesh private key generation causing starvation of other tasks Signed-off-by: Cameron Soviero <cam@ti.com> Signed-off-by: Caleb Overbay <c-overbay@ti.com> Signed-off-by: Ging Gonzalez <g-gonzalez@ti.com>
1 parent 33a4f02 commit 0f6287d

File tree

10 files changed

+525
-3
lines changed

10 files changed

+525
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
set(QEMU_EXTRA_FLAGS -s)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
project(mesh)
8+
9+
target_sources(app PRIVATE src/main.c)
10+
11+
target_sources(app PRIVATE src/board.c)
12+
13+
if (CONFIG_BUILD_WITH_TFM)
14+
target_include_directories(app PRIVATE
15+
$<TARGET_PROPERTY:tfm,TFM_BINARY_DIR>/api_ns/interface/include
16+
)
17+
endif()
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
.. _ble_mesh_blob_shell:
2+
3+
Bluetooth: Mesh BLOB Shell
4+
##########################
5+
6+
Overview
7+
********
8+
9+
This sample demonstrates Bluetooth Mesh's BLOB Models. It has the BLOB Client
10+
Model and the BLOB Server Model in addition to standard mesh models, and it
11+
supports provisioning over both the Advertising and the GATT Provisioning Bearers
12+
(i.e. PB-ADV and PB-GATT). The Mesh BLOB Shell sample is designed for transfering
13+
Binary Large OBjects (BLOB) in the mesh network using the standard BLOB Models.
14+
It includes a serial console built to allow sending of commands, such as to setup
15+
and start a BLOB transfer from a BLOB Client to a BLOB Server.
16+
17+
18+
Requirements
19+
************
20+
21+
* 2 boards with Bluetooth LE support
22+
* Terminal Emulator (i.e., PuTTY or Tera Term)
23+
24+
User Interface
25+
**************
26+
LEDs:
27+
Used to identify the device being provisioned.
28+
29+
Terminal Emulator:
30+
Used to interacting with the sample's Mesh Shell.
31+
32+
Building and Running
33+
********************
34+
35+
This sample can be found under :zephyr_file:`samples/bluetooth/mesh_blob_shell` in the
36+
Zephyr tree.
37+
38+
See :ref:`bluetooth samples section <bluetooth-samples>` for details on how
39+
to run the sample inside QEMU.
40+
41+
For other boards, build and flash the application as follows:
42+
43+
.. zephyr-app-commands::
44+
:zephyr-app: samples/bluetooth/mesh_blob_shell
45+
:board: <board>
46+
:goals: flash
47+
:compact:
48+
49+
Refer to your :ref:`board's documentation <boards>` for alternative
50+
flash instructions if your board doesn't support the ``flash`` target.
51+
52+
Interacting with the sample
53+
***************************
54+
55+
1. Use PuTTY (or other serial terminal) to open a serial connection to the boards.
56+
2. From there, you can send mesh commands to the boards using the Bluetooth Mesh
57+
Shell. For full reference on supported commands, refer to this
58+
`page <https://docs.zephyrproject.org/latest/connectivity/bluetooth/api/mesh/shell.html>`_.
59+
60+
To provision and test, continue to the sections below.
61+
62+
.. _provisioning-section:
63+
64+
Provisioning
65+
************
66+
67+
The sample can be provisioned into an existing mesh network with an external
68+
provisioner device. The provisioner must give the device an Application Key and
69+
bind it to the BLOB Client and BLOB Server models.
70+
71+
If using Texas Instrument's SimpleLink Connect Mobile App, refer to the
72+
`SimpleLink Mesh Guide <simplelink_connect_mesh_guide>`_ for information on how
73+
to provision and configure a mesh device.
74+
75+
Before getting started:
76+
* Add an Application Key
77+
78+
The first device will act as the BLOB Client
79+
* Bind the BLOB Client Model to the Application Key
80+
81+
The second device will act as the BLOB Server
82+
* Bind the BLOB Server Model to the Application Key
83+
84+
.. _testing-section:
85+
86+
Testing
87+
*******
88+
89+
After provisioning the mesh nodes and configuring the BLOB models, you can start
90+
a BLOB transfer from the BLOB Client to the BLOB Server. With serial terminals (PuTTY)
91+
open for both of the nodes, follow the steps below:
92+
93+
NOTE: The following commands are just examples. To get more information on the
94+
blob command parameters, refer to this
95+
`page <https://docs.zephyrproject.org/latest/connectivity/bluetooth/api/mesh/shell.html>`_.
96+
97+
BLOB Server
98+
===========
99+
1. Initialize the mesh shell
100+
101+
.. code-block:: bash
102+
103+
mesh init
104+
105+
2. Prepare node for receiving a BLOB
106+
107+
.. code-block:: bash
108+
109+
mesh models blob srv rx 1 10
110+
111+
BLOB Client
112+
===========
113+
1. Initialize the mesh shell
114+
115+
.. code-block:: bash
116+
117+
mesh init
118+
119+
2. Add the BLOB Server as a target
120+
121+
.. code-block:: bash
122+
123+
mesh models blob cli target 0x0004
124+
125+
3. Start BLOB transfer
126+
127+
.. code-block:: bash
128+
129+
mesh models blob cli tx 1 4096 10 65 0x0000 pull 10
130+
131+
NOTE: It may take several minutes to finish the BLOB transfer.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. _simplelink_connect_mesh_guide:
2+
3+
SimpleLink Connect Mesh Feature Guide
4+
#####################################
5+
6+
Configuring Mesh Network
7+
************************
8+
9+
On the landing page, tap on the `Mesh Network` button. This will take you to the
10+
mesh network page where you can add nodes and make configurations.
11+
12+
Adding a Network Key
13+
====================
14+
1. Tap on the menu button (three dots icon on the top right)
15+
2. Tap `Configure network keys`
16+
3. Tap `Add new key`
17+
4. On the pop-up, tap `Save`
18+
19+
Adding an Application Key
20+
=========================
21+
1. Tap on the menu button (three dots icon on the top right)
22+
2. Tap `Configure app keys`
23+
3. Tap `Add new key`
24+
4. On the pop-up, tap `Save`
25+
26+
Adding a Provisioner
27+
====================
28+
29+
1. Tap on the menu button (three dots icon on the top right)
30+
2. Tap `Provisioners`
31+
3. Tap `Add new provisioner`
32+
4. On the pop-up, confirm information and tap `Save`
33+
34+
Adding a Mesh Node
35+
==================
36+
1. In the Mesh Network, tap on the `Add Node` button
37+
2. Tap the node you want to provision
38+
3. Tap on the `Provision` button
39+
40+
Configuring a Mesh Node
41+
***********************
42+
43+
Binding an Application Key to a Model
44+
=====================================
45+
46+
1. In the Mesh Network, tap on the node you want to configure
47+
2. At the bottom section, select the Element that contains the Model
48+
you want to configure
49+
3. Select the Model
50+
4. Under `Bind Application Key`, select the Application Key to bind to the model
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
2+
3+
CONFIG_BT_SETTINGS=y
4+
CONFIG_FLASH=y
5+
CONFIG_FLASH_MAP=y
6+
CONFIG_NVS=y
7+
CONFIG_SETTINGS=y
8+
CONFIG_HWINFO=y
9+
10+
CONFIG_BT=y
11+
CONFIG_BT_L2CAP_TX_BUF_COUNT=5
12+
CONFIG_BT_PERIPHERAL=y
13+
CONFIG_BT_OBSERVER=y
14+
CONFIG_BT_BROADCASTER=y
15+
16+
CONFIG_BT_CTLR_DUP_FILTER_LEN=0
17+
CONFIG_BT_CTLR_LE_ENC=n
18+
CONFIG_BT_CTLR_LE_PING=n
19+
CONFIG_BT_DATA_LEN_UPDATE=n
20+
CONFIG_BT_PHY_UPDATE=n
21+
CONFIG_BT_CTLR_MIN_USED_CHAN=n
22+
CONFIG_BT_CTLR_PRIVACY=n
23+
CONFIG_BT_CTLR_CHAN_SEL_2=n
24+
25+
CONFIG_BT_MESH=y
26+
CONFIG_BT_MESH_MODEL_EXTENSIONS=y
27+
CONFIG_BT_MESH_RELAY=y
28+
CONFIG_BT_MESH_FRIEND=y
29+
CONFIG_BT_MESH_PB_GATT=y
30+
CONFIG_BT_MESH_PB_ADV=y
31+
CONFIG_BT_MESH_GATT_PROXY=y
32+
33+
CONFIG_BT_MESH_SUBNET_COUNT=2
34+
CONFIG_BT_MESH_APP_KEY_COUNT=2
35+
CONFIG_BT_MESH_MODEL_GROUP_COUNT=2
36+
CONFIG_BT_MESH_LABEL_COUNT=3
37+
38+
CONFIG_BT_DEVICE_NAME="Zephyr BLOB"
39+
CONFIG_SHELL=y
40+
CONFIG_LOG_CMDS=y
41+
CONFIG_BT_EXT_ADV=n
42+
CONFIG_BT_MESH_SHELL=y
43+
CONFIG_BT_MESH_BLOB_CLI=y
44+
CONFIG_BT_MESH_SHELL_BLOB_CLI=y
45+
CONFIG_BT_MESH_BLOB_SRV=y
46+
CONFIG_BT_MESH_SHELL_BLOB_SRV=y
47+
CONFIG_BT_MESH_RX_SEG_MAX=10
48+
CONFIG_BT_MESH_TX_SEG_MAX=10
49+
CONFIG_BT_MESH_BLOB_BLOCK_SIZE_MIN=1024
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sample:
2+
name: Bluetooth Mesh BLOB Shell
3+
tests:
4+
sample.bluetooth.mesh_blob_shell:
5+
harness: bluetooth
6+
platform_allow:
7+
- lp_em_cc2340r53
8+
integration_platforms:
9+
- qemu_x86
10+
tags: bluetooth
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* board.c - Generic HW interaction hooks */
2+
3+
/*
4+
* Copyright (c) 2021 Nordic Semiconductor
5+
* Copyright (c) 2025 Texas Instruments Incorporated
6+
*
7+
* SPDX-License-Identifier: Apache-2.0
8+
*/
9+
10+
#include <zephyr/bluetooth/mesh.h>
11+
#include <zephyr/drivers/gpio.h>
12+
#include "board.h"
13+
14+
/* Locate led0 as alias or label by that name */
15+
#if DT_NODE_EXISTS(DT_ALIAS(led0))
16+
#define LED0 DT_ALIAS(led0)
17+
#elif DT_NODE_EXISTS(DT_NODELABEL(led0))
18+
#define LED0 DT_NODELABEL(led0)
19+
#else
20+
#define LED0 DT_INVALID_NODE
21+
#endif
22+
23+
#if DT_NODE_EXISTS(LED0)
24+
#define LED0_DEV DT_PHANDLE(LED0, gpios)
25+
#define LED0_PIN DT_PHA(LED0, gpios, pin)
26+
#define LED0_FLAGS DT_PHA(LED0, gpios, flags)
27+
28+
static const struct device *const led_dev = DEVICE_DT_GET(LED0_DEV);
29+
#endif /* LED0 */
30+
31+
static int led_init(void)
32+
{
33+
#if DT_NODE_EXISTS(LED0)
34+
int err;
35+
36+
if (!device_is_ready(led_dev)) {
37+
return -ENODEV;
38+
}
39+
40+
err = gpio_pin_configure(led_dev, LED0_PIN,
41+
LED0_FLAGS | GPIO_OUTPUT_INACTIVE);
42+
if (err) {
43+
return err;
44+
}
45+
#else
46+
printk("WARNING: LEDs not supported on this board.\n");
47+
#endif
48+
49+
return 0;
50+
}
51+
52+
int board_init()
53+
{
54+
int err;
55+
56+
err = led_init();
57+
if (err) {
58+
return err;
59+
}
60+
61+
return 0;
62+
}
63+
64+
void board_led_set(bool val)
65+
{
66+
#if DT_NODE_EXISTS(LED0)
67+
gpio_pin_set(led_dev, LED0_PIN, val);
68+
#endif
69+
}
70+
71+
void board_output_number(bt_mesh_output_action_t action, uint32_t number)
72+
{
73+
}
74+
75+
void board_prov_complete(void)
76+
{
77+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* board.h - Board-specific hooks */
2+
3+
/*
4+
* Copyright (c) 2017 Intel Corporation
5+
* Copyright (c) 2025 Texas Instruments Incorporated
6+
*
7+
* SPDX-License-Identifier: Apache-2.0
8+
*/
9+
10+
void board_output_number(bt_mesh_output_action_t action, uint32_t number);
11+
12+
void board_prov_complete(void);
13+
14+
int board_init();
15+
16+
void board_led_set(bool val);

0 commit comments

Comments
 (0)