forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bluetooth: mesh: add unit tests for new sensor API
This tests the new APIs in sensor.h/sensor_types.h: * For each sensor format, test `bt_mesh_sensor_value_to_micro`, `bt_mesh_sensor_value_to_float`, `bt_mesh_sensor_value_from_micro` and `bt_mesh_sensor_value_from_float` according to GSS. Tests min value, max value, values out of range, prohibited values and special values. * For each sensor type defined in `sensor_types.c`, test that: * Property ID lookup returns the correct sensor type. * During decoding, the raw data is partitioned correctly into `bt_mesh_sensor_value`s according to channel widths, and the correct format is pointed to in each value. * During encoding, the raw data is correctly added to the buffer according to channel widths. Signed-off-by: Ludvig Jordet <[email protected]>
- Loading branch information
1 parent
2cce69b
commit ffd08bb
Showing
5 changed files
with
1,035 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
tests/subsys/bluetooth/mesh/sensor_subsys_new/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(bt_mesh_sensor_subsystem_new_test) | ||
|
||
target_include_directories(app PUBLIC | ||
${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh | ||
) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE | ||
${app_sources} | ||
${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/sensor_types.c | ||
${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/sensor.c | ||
) | ||
|
||
target_compile_options(app | ||
PRIVATE | ||
-DCONFIG_BT_MESH_MODEL_KEY_COUNT=5 | ||
-DCONFIG_BT_MESH_MODEL_GROUP_COUNT=5 | ||
-DCONFIG_BT_MESH_SENSOR_ALL_TYPES=1 | ||
-DCONFIG_BT_MESH_SENSOR_LABELS=1 | ||
-DCONFIG_BT_MESH_SENSOR_CHANNELS_MAX=5 | ||
-DCONFIG_BT_MESH_SENSOR_CHANNEL_ENCODED_SIZE_MAX=4 | ||
-DCONFIG_BT_LOG_LEVEL=0 | ||
-DCONFIG_BT_MESH_USES_TINYCRYPT | ||
) | ||
|
||
zephyr_linker_sources(SECTIONS sensor_types.ld) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
# Ztest configuration | ||
CONFIG_ZTEST=y | ||
CONFIG_CBPRINTF_FP_SUPPORT=y | ||
CONFIG_NET_BUF=y |
6 changes: 6 additions & 0 deletions
6
tests/subsys/bluetooth/mesh/sensor_subsys_new/sensor_types.ld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SECTION_DATA_PROLOGUE(bt_mesh_sensor_types_sections,,SUBALIGN(4)) | ||
{ | ||
_bt_mesh_sensor_type_list_start = .; | ||
KEEP(*(SORT_BY_NAME("._bt_mesh_sensor_type.static.*"))); | ||
_bt_mesh_sensor_type_list_end = .; | ||
} GROUP_LINK_IN(ROMABLE_REGION) |
Oops, something went wrong.