shell: Add Large Composition Data Server
- Adds Large Comp Data Server and Client - Defines some dummy metadata for Health Server Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no> Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl> Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
parent
df65592d94
commit
8a60dfcd51
@ -9,6 +9,8 @@ zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL_HEALTH_CLI health.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL_CFG_CLI cfg.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL_LARGE_COMP_DATA_CLI large_comp_data.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL_RPR_CLI rpr.c)
|
||||
|
||||
if(CONFIG_BT_MESH_SHELL_BLOB_CLI OR CONFIG_BT_MESH_SHELL_BLOB_SRV OR
|
||||
|
||||
@ -143,4 +143,11 @@ config BT_MESH_SHELL_RPR_CLI
|
||||
help
|
||||
Remote Provisioning Client shell support.
|
||||
|
||||
config BT_MESH_SHELL_LARGE_COMP_DATA_CLI
|
||||
bool "Support for Large Composition Data Client shell commands"
|
||||
depends on BT_MESH_LARGE_COMP_DATA_CLI
|
||||
default y
|
||||
help
|
||||
Large Composition Data Client shell support.
|
||||
|
||||
endif # BT_MESH_SHELL
|
||||
|
||||
82
subsys/bluetooth/mesh/shell/large_comp_data.c
Normal file
82
subsys/bluetooth/mesh/shell/large_comp_data.c
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <zephyr/shell/shell.h>
|
||||
#include <zephyr/bluetooth/mesh.h>
|
||||
#include <zephyr/bluetooth/mesh/shell.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
static int cmd_large_comp_data_get(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
NET_BUF_SIMPLE_DEFINE(comp, 64);
|
||||
uint8_t page;
|
||||
uint16_t offset;
|
||||
int err = 0;
|
||||
|
||||
net_buf_simple_init(&comp, 0);
|
||||
|
||||
page = shell_strtoul(argv[1], 0, &err);
|
||||
offset = shell_strtoul(argv[2], 0, &err);
|
||||
|
||||
if (err) {
|
||||
shell_warn(sh, "Unable to parse input string argument");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_large_comp_data_get(bt_mesh_shell_target_ctx.net_idx,
|
||||
bt_mesh_shell_target_ctx.dst, page, offset,
|
||||
&comp);
|
||||
if (err) {
|
||||
shell_print(sh, "Failed to send Large Composition Data Get (err=%d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
shell_print(sh, "Large Composition Data Get len=%d", comp.len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_models_metadata_get(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
NET_BUF_SIMPLE_DEFINE(metadata, 64);
|
||||
uint8_t page;
|
||||
uint16_t offset;
|
||||
int err = 0;
|
||||
|
||||
net_buf_simple_init(&metadata, 0);
|
||||
|
||||
page = shell_strtoul(argv[1], 0, &err);
|
||||
offset = shell_strtoul(argv[2], 0, &err);
|
||||
|
||||
if (err) {
|
||||
shell_warn(sh, "Unable to parse input string argument");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_mesh_models_metadata_get(bt_mesh_shell_target_ctx.net_idx,
|
||||
bt_mesh_shell_target_ctx.dst, page, offset,
|
||||
&metadata);
|
||||
if (err) {
|
||||
shell_print(sh, "Failed to send Models Metadata Get (err=%d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
shell_print(sh, "Models Metadata Get len=%d", metadata.len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(
|
||||
large_comp_data_cmds,
|
||||
SHELL_CMD_ARG(large-comp-data-get, NULL, "<page> <offset>", cmd_large_comp_data_get, 3, 0),
|
||||
SHELL_CMD_ARG(models-metadata-get, NULL, "<page> <offset>", cmd_models_metadata_get, 3, 0),
|
||||
SHELL_SUBCMD_SET_END);
|
||||
|
||||
SHELL_SUBCMD_ADD((mesh, models), lcd, &large_comp_data_cmds,
|
||||
"Large Comp Data Cli commands",
|
||||
bt_mesh_shell_mdl_cmds_help, 1, 1);
|
||||
@ -30,6 +30,8 @@
|
||||
#include "blob.h"
|
||||
|
||||
#define CID_NVAL 0xffff
|
||||
#define COMPANY_ID_LF 0x05F1
|
||||
#define COMPANY_ID_NORDIC_SEMI 0x05F9
|
||||
|
||||
const struct shell *bt_mesh_shell_ctx_shell;
|
||||
|
||||
@ -142,10 +144,25 @@ static const struct bt_mesh_health_srv_cb health_srv_cb = {
|
||||
};
|
||||
#endif /* CONFIG_BT_MESH_SHELL_HEALTH_SRV_INSTANCE */
|
||||
|
||||
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
|
||||
static uint8_t health_tests[] = {
|
||||
BT_MESH_HEALTH_TEST_INFO(COMPANY_ID_LF, 6, 0x01, 0x02, 0x03, 0x04, 0x34, 0x15),
|
||||
BT_MESH_HEALTH_TEST_INFO(COMPANY_ID_NORDIC_SEMI, 3, 0x01, 0x02, 0x03),
|
||||
};
|
||||
|
||||
static struct bt_mesh_models_metadata_entry health_srv_meta[] = {
|
||||
BT_MESH_HEALTH_TEST_INFO_METADATA(health_tests),
|
||||
BT_MESH_MODELS_METADATA_END,
|
||||
};
|
||||
#endif
|
||||
|
||||
struct bt_mesh_health_srv bt_mesh_shell_health_srv = {
|
||||
#if defined(CONFIG_BT_MESH_SHELL_HEALTH_SRV_INSTANCE)
|
||||
.cb = &health_srv_cb,
|
||||
#endif
|
||||
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
|
||||
.metadata = health_srv_meta,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(CONFIG_BT_MESH_SHELL_HEALTH_CLI)
|
||||
|
||||
@ -47,6 +47,13 @@ static struct bt_mesh_model root_models[] = {
|
||||
#if defined(CONFIG_BT_MESH_RPR_SRV)
|
||||
BT_MESH_MODEL_RPR_SRV,
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
|
||||
BT_MESH_MODEL_LARGE_COMP_DATA_SRV,
|
||||
#endif
|
||||
#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_CLI)
|
||||
BT_MESH_MODEL_LARGE_COMP_DATA_CLI,
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct bt_mesh_elem elements[] = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user