bluetooth: mesh: shell: eliminate ctx_shell
usage
This change aims to eliminate the dependency on `ctx_shell` in the Bluetooth `mesh/shell/*`, making the code more maintainable. Replaced `shell_*` functions that depended on `ctx_shell` with the appropriate `bt_shell_*` functions. Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This commit is contained in:
parent
f1516c960a
commit
f70359bc7c
8 changed files with 112 additions and 150 deletions
|
@ -6,6 +6,7 @@
|
|||
menuconfig BT_MESH_SHELL
|
||||
bool "Bluetooth Mesh shell"
|
||||
select SHELL
|
||||
select BT_PRIVATE_SHELL
|
||||
help
|
||||
Activate shell module that provides Bluetooth Mesh commands to
|
||||
the console.
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
#include <zephyr/bluetooth/mesh.h>
|
||||
#include <zephyr/bluetooth/mesh/shell.h>
|
||||
|
||||
#include "common/bt_shell_private.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern const struct shell *bt_mesh_shell_ctx_shell;
|
||||
|
||||
/***************************************************************************************************
|
||||
* Implementation of models' instances
|
||||
**************************************************************************************************/
|
||||
|
@ -85,8 +84,7 @@ static void blob_cli_lost_target(struct bt_mesh_blob_cli *cli,
|
|||
struct bt_mesh_blob_target *target,
|
||||
enum bt_mesh_blob_status reason)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Mesh Blob: Lost target 0x%04x (reason: %u)",
|
||||
target->addr, reason);
|
||||
bt_shell_print("Mesh Blob: Lost target 0x%04x (reason: %u)", target->addr, reason);
|
||||
}
|
||||
|
||||
static void blob_cli_caps(struct bt_mesh_blob_cli *cli,
|
||||
|
@ -100,30 +98,29 @@ static void blob_cli_caps(struct bt_mesh_blob_cli *cli,
|
|||
};
|
||||
|
||||
if (!caps) {
|
||||
shell_print(bt_mesh_shell_ctx_shell,
|
||||
"None of the targets can be used for BLOB transfer");
|
||||
bt_shell_print("None of the targets can be used for BLOB transfer");
|
||||
return;
|
||||
}
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Mesh BLOB: capabilities:");
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tMax BLOB size: %u bytes", caps->max_size);
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tBlock size: %u-%u (%u-%u bytes)",
|
||||
caps->min_block_size_log, caps->max_block_size_log,
|
||||
1 << caps->min_block_size_log,
|
||||
1 << caps->max_block_size_log);
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tMax chunks: %u", caps->max_chunks);
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tChunk size: %u", caps->max_chunk_size);
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tMTU size: %u", caps->mtu_size);
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tModes: %s", modes[caps->modes]);
|
||||
bt_shell_print("Mesh BLOB: capabilities:");
|
||||
bt_shell_print("\tMax BLOB size: %u bytes", caps->max_size);
|
||||
bt_shell_print("\tBlock size: %u-%u (%u-%u bytes)",
|
||||
caps->min_block_size_log, caps->max_block_size_log,
|
||||
1 << caps->min_block_size_log,
|
||||
1 << caps->max_block_size_log);
|
||||
bt_shell_print("\tMax chunks: %u", caps->max_chunks);
|
||||
bt_shell_print("\tChunk size: %u", caps->max_chunk_size);
|
||||
bt_shell_print("\tMTU size: %u", caps->mtu_size);
|
||||
bt_shell_print("\tModes: %s", modes[caps->modes]);
|
||||
}
|
||||
|
||||
static void blob_cli_end(struct bt_mesh_blob_cli *cli,
|
||||
const struct bt_mesh_blob_xfer *xfer, bool success)
|
||||
{
|
||||
if (success) {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Mesh BLOB transfer complete.");
|
||||
bt_shell_print("Mesh BLOB transfer complete.");
|
||||
} else {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Mesh BLOB transfer failed.");
|
||||
bt_shell_print("Mesh BLOB transfer failed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +139,7 @@ static uint8_t get_progress(const struct bt_mesh_blob_xfer_info *info)
|
|||
blocks_not_rxed += info->missing_blocks[i % 8] & (1 << (i % 8));
|
||||
}
|
||||
|
||||
return (total_blocks - blocks_not_rxed) / total_blocks;
|
||||
return (total_blocks - blocks_not_rxed) / total_blocks;
|
||||
}
|
||||
|
||||
static void xfer_progress(struct bt_mesh_blob_cli *cli,
|
||||
|
@ -151,16 +148,15 @@ static void xfer_progress(struct bt_mesh_blob_cli *cli,
|
|||
{
|
||||
uint8_t progress = get_progress(info);
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell,
|
||||
"BLOB transfer progress received from target 0x%04x:\n"
|
||||
"\tphase: %d\n"
|
||||
"\tprogress: %u%%",
|
||||
target->addr, info->phase, progress);
|
||||
bt_shell_print("BLOB transfer progress received from target 0x%04x:\n"
|
||||
"\tphase: %d\n"
|
||||
"\tprogress: %u%%",
|
||||
target->addr, info->phase, progress);
|
||||
}
|
||||
|
||||
static void xfer_progress_complete(struct bt_mesh_blob_cli *cli)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Determine BLOB transfer progress procedure complete");
|
||||
bt_shell_print("Determine BLOB transfer progress procedure complete");
|
||||
}
|
||||
|
||||
static const struct bt_mesh_blob_cli_cb blob_cli_handlers = {
|
||||
|
@ -185,7 +181,7 @@ static int blob_srv_start(struct bt_mesh_blob_srv *srv,
|
|||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct bt_mesh_blob_xfer *xfer)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "BLOB start");
|
||||
bt_shell_print("BLOB start");
|
||||
blob_time = k_uptime_get();
|
||||
return 0;
|
||||
}
|
||||
|
@ -196,11 +192,11 @@ static void blob_srv_end(struct bt_mesh_blob_srv *srv, uint64_t id,
|
|||
if (success) {
|
||||
int64_t duration = k_uptime_delta(&blob_time);
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell, "BLOB completed in %u.%03u s",
|
||||
(uint32_t)(duration / MSEC_PER_SEC),
|
||||
(uint32_t)(duration % MSEC_PER_SEC));
|
||||
bt_shell_print("BLOB completed in %u.%03u s",
|
||||
(uint32_t)(duration / MSEC_PER_SEC),
|
||||
(uint32_t)(duration % MSEC_PER_SEC));
|
||||
} else {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "BLOB cancelled");
|
||||
bt_shell_print("BLOB cancelled");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <zephyr/dfu/mcuboot.h>
|
||||
#include <zephyr/storage/flash_map.h>
|
||||
|
||||
#include "common/bt_shell_private.h"
|
||||
#include "utils.h"
|
||||
#include "blob.h"
|
||||
#include "../dfu_slot.h"
|
||||
|
@ -24,30 +25,28 @@
|
|||
* Implementation of models' instances
|
||||
**************************************************************************************************/
|
||||
|
||||
extern const struct shell *bt_mesh_shell_ctx_shell;
|
||||
|
||||
#if defined(CONFIG_BT_MESH_SHELL_DFU_CLI)
|
||||
|
||||
static void dfu_cli_ended(struct bt_mesh_dfu_cli *cli,
|
||||
enum bt_mesh_dfu_status reason)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "DFU ended: %u", reason);
|
||||
bt_shell_print("DFU ended: %u", reason);
|
||||
}
|
||||
|
||||
static void dfu_cli_applied(struct bt_mesh_dfu_cli *cli)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "DFU applied.");
|
||||
bt_shell_print("DFU applied.");
|
||||
}
|
||||
|
||||
static void dfu_cli_lost_target(struct bt_mesh_dfu_cli *cli,
|
||||
struct bt_mesh_dfu_target *target)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "DFU target lost: 0x%04x", target->blob.addr);
|
||||
bt_shell_print("DFU target lost: 0x%04x", target->blob.addr);
|
||||
}
|
||||
|
||||
static void dfu_cli_confirmed(struct bt_mesh_dfu_cli *cli)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "DFU confirmed");
|
||||
bt_shell_print("DFU confirmed");
|
||||
}
|
||||
|
||||
const struct bt_mesh_dfu_cli_cb dfu_cli_cb = {
|
||||
|
@ -86,7 +85,7 @@ static int dfu_start(struct bt_mesh_dfu_srv *srv,
|
|||
struct net_buf_simple *metadata,
|
||||
const struct bt_mesh_blob_io **io)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "DFU setup");
|
||||
bt_shell_print("DFU setup");
|
||||
|
||||
*io = bt_mesh_shell_blob_io;
|
||||
|
||||
|
@ -96,7 +95,7 @@ static int dfu_start(struct bt_mesh_dfu_srv *srv,
|
|||
static void dfu_end(struct bt_mesh_dfu_srv *srv, const struct bt_mesh_dfu_img *img, bool success)
|
||||
{
|
||||
if (!success) {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "DFU failed");
|
||||
bt_shell_print("DFU failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,7 @@ static int dfu_apply(struct bt_mesh_dfu_srv *srv,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Applying DFU transfer...");
|
||||
bt_shell_print("Applying DFU transfer...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -620,10 +619,10 @@ static enum bt_mesh_dfu_iter dfu_img_cb(struct bt_mesh_dfu_cli *cli,
|
|||
len = bin2hex(img->fwid, img->fwid_len, fwid, sizeof(fwid));
|
||||
fwid[len] = '\0';
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Image %u:", idx);
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tFWID: %s", fwid);
|
||||
bt_shell_print("Image %u:", idx);
|
||||
bt_shell_print("\tFWID: %s", fwid);
|
||||
if (img->uri) {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tURI: %s", img->uri);
|
||||
bt_shell_print("\tURI: %s", img->uri);
|
||||
}
|
||||
|
||||
return BT_MESH_DFU_ITER_CONTINUE;
|
||||
|
|
|
@ -9,22 +9,19 @@
|
|||
#include <zephyr/bluetooth/mesh.h>
|
||||
#include <zephyr/bluetooth/mesh/shell.h>
|
||||
|
||||
#include "common/bt_shell_private.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern const struct shell *bt_mesh_shell_ctx_shell;
|
||||
|
||||
static void status_print(int err, char *msg, uint16_t addr, struct bt_mesh_large_comp_data_rsp *rsp)
|
||||
{
|
||||
if (err) {
|
||||
shell_error(bt_mesh_shell_ctx_shell,
|
||||
"Failed to send %s Get message (err %d)", msg, err);
|
||||
bt_shell_error("Failed to send %s Get message (err %d)", msg, err);
|
||||
return;
|
||||
}
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell,
|
||||
"%s [0x%04x]: page: %u offset: %u total size: %u", msg, addr, rsp->page,
|
||||
rsp->offset, rsp->total_size);
|
||||
shell_hexdump(bt_mesh_shell_ctx_shell, rsp->data->data, rsp->data->len);
|
||||
bt_shell_print("%s [0x%04x]: page: %u offset: %u total size: %u", msg, addr, rsp->page,
|
||||
rsp->offset, rsp->total_size);
|
||||
bt_shell_hexdump(rsp->data->data, rsp->data->len);
|
||||
}
|
||||
|
||||
static int cmd_large_comp_data_get(const struct shell *sh, size_t argc, char *argv[])
|
||||
|
|
|
@ -17,8 +17,6 @@ static const struct bt_mesh_model *mod;
|
|||
* Implementation of the model's instance
|
||||
**************************************************************************************************/
|
||||
|
||||
extern const struct shell *bt_mesh_shell_ctx_shell;
|
||||
|
||||
static void rpr_scan_report(struct bt_mesh_rpr_cli *cli,
|
||||
const struct bt_mesh_rpr_node *srv,
|
||||
struct bt_mesh_rpr_unprov *unprov,
|
||||
|
@ -28,11 +26,10 @@ static void rpr_scan_report(struct bt_mesh_rpr_cli *cli,
|
|||
|
||||
bin2hex(unprov->uuid, 16, uuid_hex_str, sizeof(uuid_hex_str));
|
||||
|
||||
shell_print(bt_mesh_shell_ctx_shell,
|
||||
"Server 0x%04x:\n"
|
||||
"\tuuid: %s\n"
|
||||
"\tOOB: 0x%04x",
|
||||
srv->addr, uuid_hex_str, unprov->oob);
|
||||
bt_shell_print("Server 0x%04x:\n"
|
||||
"\tuuid: %s\n"
|
||||
"\tOOB: 0x%04x",
|
||||
srv->addr, uuid_hex_str, unprov->oob);
|
||||
|
||||
while (adv_data && adv_data->len > 2) {
|
||||
uint8_t len, type;
|
||||
|
@ -61,15 +58,14 @@ static void rpr_scan_report(struct bt_mesh_rpr_cli *cli,
|
|||
data[len] = '\0';
|
||||
|
||||
if (type == BT_DATA_URI) {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tURI: \"\\x%02x%s\"",
|
||||
data[0], &data[1]);
|
||||
bt_shell_print("\tURI: \"\\x%02x%s\"", data[0], &data[1]);
|
||||
} else if (type == BT_DATA_NAME_COMPLETE) {
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\tName: \"%s\"", data);
|
||||
bt_shell_print("\tName: \"%s\"", data);
|
||||
} else {
|
||||
char string[64 + 1];
|
||||
|
||||
bin2hex(data, len, string, sizeof(string));
|
||||
shell_print(bt_mesh_shell_ctx_shell, "\t0x%02x: %s", type, string);
|
||||
bt_shell_print("\t0x%02x: %s", type, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "mesh/foundation.h"
|
||||
#include "mesh/settings.h"
|
||||
#include "mesh/access.h"
|
||||
#include "common/bt_shell_private.h"
|
||||
#include "utils.h"
|
||||
#include "dfu.h"
|
||||
#include "blob.h"
|
||||
|
@ -33,19 +34,10 @@
|
|||
#define COMPANY_ID_LF 0x05F1
|
||||
#define COMPANY_ID_NORDIC_SEMI 0x05F9
|
||||
|
||||
const struct shell *bt_mesh_shell_ctx_shell;
|
||||
|
||||
struct bt_mesh_shell_target bt_mesh_shell_target_ctx = {
|
||||
.dst = BT_MESH_ADDR_UNASSIGNED,
|
||||
};
|
||||
|
||||
#define shell_print_ctx(_ft, ...) \
|
||||
do { \
|
||||
if (bt_mesh_shell_ctx_shell != NULL) { \
|
||||
shell_print(bt_mesh_shell_ctx_shell, _ft, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Default net, app & dev key values, unless otherwise specified */
|
||||
const uint8_t bt_mesh_shell_default_key[16] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
|
@ -71,7 +63,7 @@ static void get_faults(uint8_t *faults, uint8_t faults_size, uint8_t *dst, uint8
|
|||
static int fault_get_cur(const struct bt_mesh_model *model, uint8_t *test_id,
|
||||
uint16_t *company_id, uint8_t *faults, uint8_t *fault_count)
|
||||
{
|
||||
shell_print_ctx("Sending current faults");
|
||||
bt_shell_print("Sending current faults");
|
||||
|
||||
*test_id = 0x00;
|
||||
*company_id = BT_COMP_ID_LF;
|
||||
|
@ -85,12 +77,11 @@ static int fault_get_reg(const struct bt_mesh_model *model, uint16_t cid,
|
|||
uint8_t *test_id, uint8_t *faults, uint8_t *fault_count)
|
||||
{
|
||||
if (cid != CONFIG_BT_COMPANY_ID) {
|
||||
shell_print_ctx("Faults requested for unknown Company ID"
|
||||
" 0x%04x", cid);
|
||||
bt_shell_print("Faults requested for unknown Company ID 0x%04x", cid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
shell_print_ctx("Sending registered faults");
|
||||
bt_shell_print("Sending registered faults");
|
||||
|
||||
*test_id = 0x00;
|
||||
|
||||
|
@ -126,12 +117,12 @@ static int fault_test(const struct bt_mesh_model *model, uint8_t test_id,
|
|||
|
||||
static void attention_on(const struct bt_mesh_model *model)
|
||||
{
|
||||
shell_print_ctx("Attention On");
|
||||
bt_shell_print("Attention On");
|
||||
}
|
||||
|
||||
static void attention_off(const struct bt_mesh_model *model)
|
||||
{
|
||||
shell_print_ctx("Attention Off");
|
||||
bt_shell_print("Attention Off");
|
||||
}
|
||||
|
||||
static const struct bt_mesh_health_srv_cb health_srv_cb = {
|
||||
|
@ -168,16 +159,16 @@ static void show_faults(uint8_t test_id, uint16_t cid, uint8_t *faults, size_t f
|
|||
size_t i;
|
||||
|
||||
if (!fault_count) {
|
||||
shell_print_ctx("Health Test ID 0x%02x Company ID "
|
||||
"0x%04x: no faults", test_id, cid);
|
||||
bt_shell_print("Health Test ID 0x%02x Company ID 0x%04x: no faults",
|
||||
test_id, cid);
|
||||
return;
|
||||
}
|
||||
|
||||
shell_print_ctx("Health Test ID 0x%02x Company ID 0x%04x Fault "
|
||||
"Count %zu:", test_id, cid, fault_count);
|
||||
bt_shell_print("Health Test ID 0x%02x Company ID 0x%04x Fault Count %zu:",
|
||||
test_id, cid, fault_count);
|
||||
|
||||
for (i = 0; i < fault_count; i++) {
|
||||
shell_print_ctx("\t0x%02x", faults[i]);
|
||||
bt_shell_print("\t0x%02x", faults[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,7 +176,7 @@ static void health_current_status(struct bt_mesh_health_cli *cli, uint16_t addr,
|
|||
uint8_t test_id, uint16_t cid, uint8_t *faults,
|
||||
size_t fault_count)
|
||||
{
|
||||
shell_print_ctx("Health Current Status from 0x%04x", addr);
|
||||
bt_shell_print("Health Current Status from 0x%04x", addr);
|
||||
show_faults(test_id, cid, faults, fault_count);
|
||||
}
|
||||
|
||||
|
@ -193,20 +184,20 @@ static void health_fault_status(struct bt_mesh_health_cli *cli, uint16_t addr,
|
|||
uint8_t test_id, uint16_t cid, uint8_t *faults,
|
||||
size_t fault_count)
|
||||
{
|
||||
shell_print_ctx("Health Fault Status from 0x%04x", addr);
|
||||
bt_shell_print("Health Fault Status from 0x%04x", addr);
|
||||
show_faults(test_id, cid, faults, fault_count);
|
||||
}
|
||||
|
||||
static void health_attention_status(struct bt_mesh_health_cli *cli,
|
||||
uint16_t addr, uint8_t attention)
|
||||
{
|
||||
shell_print_ctx("Health Attention Status from 0x%04x: %u", addr, attention);
|
||||
bt_shell_print("Health Attention Status from 0x%04x: %u", addr, attention);
|
||||
}
|
||||
|
||||
static void health_period_status(struct bt_mesh_health_cli *cli, uint16_t addr,
|
||||
uint8_t period)
|
||||
{
|
||||
shell_print_ctx("Health Fast Period Divisor Status from 0x%04x: %u", addr, period);
|
||||
bt_shell_print("Health Fast Period Divisor Status from 0x%04x: %u", addr, period);
|
||||
}
|
||||
|
||||
struct bt_mesh_health_cli bt_mesh_shell_health_cli = {
|
||||
|
@ -219,8 +210,6 @@ struct bt_mesh_health_cli bt_mesh_shell_health_cli = {
|
|||
|
||||
static int cmd_init(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
|
||||
bt_mesh_shell_ctx_shell = sh;
|
||||
shell_print(sh, "Mesh shell initialized");
|
||||
|
||||
#if defined(CONFIG_BT_MESH_SHELL_DFU_CLI) || defined(CONFIG_BT_MESH_SHELL_DFU_SRV)
|
||||
|
@ -242,7 +231,7 @@ static int cmd_reset(const struct shell *sh, size_t argc, char *argv[])
|
|||
{
|
||||
#if defined(CONFIG_BT_MESH_CDB)
|
||||
bt_mesh_cdb_clear();
|
||||
# endif
|
||||
#endif
|
||||
bt_mesh_reset();
|
||||
shell_print(sh, "Local node reset complete");
|
||||
|
||||
|
@ -311,15 +300,14 @@ static int cmd_poll(const struct shell *sh, size_t argc, char *argv[])
|
|||
static void lpn_established(uint16_t net_idx, uint16_t friend_addr,
|
||||
uint8_t queue_size, uint8_t recv_win)
|
||||
{
|
||||
shell_print_ctx("Friendship (as LPN) established to "
|
||||
"Friend 0x%04x Queue Size %d Receive Window %d",
|
||||
friend_addr, queue_size, recv_win);
|
||||
bt_shell_print("Friendship (as LPN) established to "
|
||||
"Friend 0x%04x Queue Size %d Receive Window %d",
|
||||
friend_addr, queue_size, recv_win);
|
||||
}
|
||||
|
||||
static void lpn_terminated(uint16_t net_idx, uint16_t friend_addr)
|
||||
{
|
||||
shell_print_ctx("Friendship (as LPN) lost with Friend "
|
||||
"0x%04x", friend_addr);
|
||||
bt_shell_print("Friendship (as LPN) lost with Friend 0x%04x", friend_addr);
|
||||
}
|
||||
|
||||
BT_MESH_LPN_CB_DEFINE(lpn_cb) = {
|
||||
|
@ -461,17 +449,15 @@ static uint8_t dev_uuid[16] = { 0xdd, 0xdd };
|
|||
static void prov_complete(uint16_t net_idx, uint16_t addr)
|
||||
{
|
||||
|
||||
shell_print_ctx("Local node provisioned, net_idx 0x%04x address "
|
||||
"0x%04x", net_idx, addr);
|
||||
bt_shell_print("Local node provisioned, net_idx 0x%04x address 0x%04x", net_idx, addr);
|
||||
|
||||
bt_mesh_shell_target_ctx.net_idx = net_idx,
|
||||
bt_mesh_shell_target_ctx.net_idx = net_idx;
|
||||
bt_mesh_shell_target_ctx.dst = addr;
|
||||
}
|
||||
|
||||
static void reprovisioned(uint16_t addr)
|
||||
{
|
||||
shell_print(bt_mesh_shell_ctx_shell, "Local node re-provisioned, new address 0x%04x",
|
||||
addr);
|
||||
bt_shell_print("Local node re-provisioned, new address 0x%04x", addr);
|
||||
|
||||
if (bt_mesh_shell_target_ctx.dst == bt_mesh_primary_addr()) {
|
||||
bt_mesh_shell_target_ctx.dst = addr;
|
||||
|
@ -481,10 +467,10 @@ static void reprovisioned(uint16_t addr)
|
|||
static void prov_node_added(uint16_t net_idx, uint8_t uuid[16], uint16_t addr,
|
||||
uint8_t num_elem)
|
||||
{
|
||||
shell_print_ctx("Node provisioned, net_idx 0x%04x address "
|
||||
"0x%04x elements %d", net_idx, addr, num_elem);
|
||||
bt_shell_print("Node provisioned, net_idx 0x%04x address 0x%04x elements %d",
|
||||
net_idx, addr, num_elem);
|
||||
|
||||
bt_mesh_shell_target_ctx.net_idx = net_idx,
|
||||
bt_mesh_shell_target_ctx.net_idx = net_idx;
|
||||
bt_mesh_shell_target_ctx.dst = addr;
|
||||
}
|
||||
|
||||
|
@ -506,22 +492,22 @@ static const char *const input_meth_string[] = {
|
|||
|
||||
static void capabilities(const struct bt_mesh_dev_capabilities *cap)
|
||||
{
|
||||
shell_print_ctx("Provisionee capabilities:");
|
||||
shell_print_ctx("\tStatic OOB is %ssupported", cap->oob_type & 1 ? "" : "not ");
|
||||
bt_shell_print("Provisionee capabilities:");
|
||||
bt_shell_print("\tStatic OOB is %ssupported", cap->oob_type & 1 ? "" : "not ");
|
||||
|
||||
shell_print_ctx("\tAvailable output actions (%d bytes max):%s", cap->output_size,
|
||||
cap->output_actions ? "" : "\n\t\tNone");
|
||||
bt_shell_print("\tAvailable output actions (%d bytes max):%s", cap->output_size,
|
||||
cap->output_actions ? "" : "\n\t\tNone");
|
||||
for (int i = 0; i < ARRAY_SIZE(output_meth_string); i++) {
|
||||
if (cap->output_actions & BIT(i)) {
|
||||
shell_print_ctx("\t\t%s", output_meth_string[i]);
|
||||
bt_shell_print("\t\t%s", output_meth_string[i]);
|
||||
}
|
||||
}
|
||||
|
||||
shell_print_ctx("\tAvailable input actions (%d bytes max):%s", cap->input_size,
|
||||
cap->input_actions ? "" : "\n\t\tNone");
|
||||
bt_shell_print("\tAvailable input actions (%d bytes max):%s", cap->input_size,
|
||||
cap->input_actions ? "" : "\n\t\tNone");
|
||||
for (int i = 0; i < ARRAY_SIZE(input_meth_string); i++) {
|
||||
if (cap->input_actions & BIT(i)) {
|
||||
shell_print_ctx("\t\t%s", input_meth_string[i]);
|
||||
bt_shell_print("\t\t%s", input_meth_string[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -529,36 +515,32 @@ static void capabilities(const struct bt_mesh_dev_capabilities *cap)
|
|||
|
||||
static void prov_input_complete(void)
|
||||
{
|
||||
shell_print_ctx("Input complete");
|
||||
bt_shell_print("Input complete");
|
||||
}
|
||||
|
||||
static void prov_reset(void)
|
||||
{
|
||||
shell_print_ctx("The local node has been reset and needs "
|
||||
"reprovisioning");
|
||||
bt_shell_print("The local node has been reset and needs reprovisioning");
|
||||
}
|
||||
|
||||
static int output_number(bt_mesh_output_action_t action, uint32_t number)
|
||||
{
|
||||
switch (action) {
|
||||
case BT_MESH_BLINK:
|
||||
shell_print_ctx("OOB blink Number: %u", number);
|
||||
bt_shell_print("OOB blink Number: %u", number);
|
||||
break;
|
||||
case BT_MESH_BEEP:
|
||||
shell_print_ctx("OOB beep Number: %u", number);
|
||||
bt_shell_print("OOB beep Number: %u", number);
|
||||
break;
|
||||
case BT_MESH_VIBRATE:
|
||||
shell_print_ctx("OOB vibrate Number: %u", number);
|
||||
bt_shell_print("OOB vibrate Number: %u", number);
|
||||
break;
|
||||
case BT_MESH_DISPLAY_NUMBER:
|
||||
shell_print_ctx("OOB display Number: %u", number);
|
||||
bt_shell_print("OOB display Number: %u", number);
|
||||
break;
|
||||
default:
|
||||
if (bt_mesh_shell_ctx_shell != NULL) {
|
||||
shell_error(bt_mesh_shell_ctx_shell,
|
||||
"Unknown Output action %u (number %u) requested!",
|
||||
action, number);
|
||||
}
|
||||
bt_shell_error("Unknown Output action %u (number %u) requested!",
|
||||
action, number);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -567,7 +549,7 @@ static int output_number(bt_mesh_output_action_t action, uint32_t number)
|
|||
|
||||
static int output_string(const char *str)
|
||||
{
|
||||
shell_print_ctx("OOB String: %s", str);
|
||||
bt_shell_print("OOB String: %s", str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -576,22 +558,19 @@ static int input(bt_mesh_input_action_t act, uint8_t size)
|
|||
|
||||
switch (act) {
|
||||
case BT_MESH_ENTER_NUMBER:
|
||||
shell_print_ctx("Enter a number (max %u digits) with: Input-num <num>", size);
|
||||
bt_shell_print("Enter a number (max %u digits) with: Input-num <num>", size);
|
||||
break;
|
||||
case BT_MESH_ENTER_STRING:
|
||||
shell_print_ctx("Enter a string (max %u chars) with: Input-str <str>", size);
|
||||
bt_shell_print("Enter a string (max %u chars) with: Input-str <str>", size);
|
||||
break;
|
||||
case BT_MESH_TWIST:
|
||||
shell_print_ctx("\"Twist\" a number (max %u digits) with: Input-num <num>", size);
|
||||
bt_shell_print("\"Twist\" a number (max %u digits) with: Input-num <num>", size);
|
||||
break;
|
||||
case BT_MESH_PUSH:
|
||||
shell_print_ctx("\"Push\" a number (max %u digits) with: Input-num <num>", size);
|
||||
bt_shell_print("\"Push\" a number (max %u digits) with: Input-num <num>", size);
|
||||
break;
|
||||
default:
|
||||
if (bt_mesh_shell_ctx_shell != NULL) {
|
||||
shell_error(bt_mesh_shell_ctx_shell,
|
||||
"Unknown Input action %u (size %u) requested!", act, size);
|
||||
}
|
||||
bt_shell_error("Unknown Input action %u (size %u) requested!", act, size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -600,12 +579,12 @@ static int input(bt_mesh_input_action_t act, uint8_t size)
|
|||
|
||||
static void link_open(bt_mesh_prov_bearer_t bearer)
|
||||
{
|
||||
shell_print_ctx("Provisioning link opened on %s", bearer2str(bearer));
|
||||
bt_shell_print("Provisioning link opened on %s", bearer2str(bearer));
|
||||
}
|
||||
|
||||
static void link_close(bt_mesh_prov_bearer_t bearer)
|
||||
{
|
||||
shell_print_ctx("Provisioning link closed on %s", bearer2str(bearer));
|
||||
bt_shell_print("Provisioning link closed on %s", bearer2str(bearer));
|
||||
}
|
||||
|
||||
static uint8_t static_val[32];
|
||||
|
@ -670,7 +649,7 @@ static int cmd_uuid(const struct shell *sh, size_t argc, char *argv[])
|
|||
|
||||
bin2hex(dev_uuid, 16, uuid_hex_str, sizeof(uuid_hex_str));
|
||||
|
||||
shell_print_ctx("Device UUID: %s", uuid_hex_str);
|
||||
bt_shell_print("Device UUID: %s", uuid_hex_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -695,9 +674,9 @@ static void print_unprovisioned_beacon(uint8_t uuid[16],
|
|||
|
||||
bin2hex(uuid, 16, uuid_hex_str, sizeof(uuid_hex_str));
|
||||
|
||||
shell_print_ctx("PB-ADV UUID %s, OOB Info 0x%04x, URI Hash 0x%x",
|
||||
uuid_hex_str, oob_info,
|
||||
(uri_hash == NULL ? 0 : *uri_hash));
|
||||
bt_shell_print("PB-ADV UUID %s, OOB Info 0x%04x, URI Hash 0x%x",
|
||||
uuid_hex_str, oob_info,
|
||||
(uri_hash == NULL ? 0 : *uri_hash));
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_MESH_PB_GATT_CLIENT)
|
||||
|
@ -708,7 +687,7 @@ static void pb_gatt_unprovisioned(uint8_t uuid[16],
|
|||
|
||||
bin2hex(uuid, 16, uuid_hex_str, sizeof(uuid_hex_str));
|
||||
|
||||
shell_print_ctx("PB-GATT UUID %s, OOB Info 0x%04x", uuid_hex_str, oob_info);
|
||||
bt_shell_print("PB-GATT UUID %s, OOB Info 0x%04x", uuid_hex_str, oob_info);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,22 +18,21 @@
|
|||
#include <zephyr/bluetooth/services/ias.h>
|
||||
|
||||
#include "host/shell/bt.h"
|
||||
|
||||
extern const struct shell *ctx_shell;
|
||||
#include "common/bt_shell_private.h"
|
||||
|
||||
static void alert_stop(void)
|
||||
{
|
||||
shell_print(ctx_shell, "Alert stopped\n");
|
||||
bt_shell_print("Alert stopped\n");
|
||||
}
|
||||
|
||||
static void alert_start(void)
|
||||
{
|
||||
shell_print(ctx_shell, "Mild alert started\n");
|
||||
bt_shell_print("Mild alert started\n");
|
||||
}
|
||||
|
||||
static void alert_high_start(void)
|
||||
{
|
||||
shell_print(ctx_shell, "High alert started\n");
|
||||
bt_shell_print("High alert started\n");
|
||||
}
|
||||
|
||||
BT_IAS_CB_DEFINE(ias_callbacks) = {
|
||||
|
|
|
@ -16,15 +16,14 @@
|
|||
#include <zephyr/bluetooth/services/ias.h>
|
||||
|
||||
#include "host/shell/bt.h"
|
||||
|
||||
extern const struct shell *ctx_shell;
|
||||
#include "common/bt_shell_private.h"
|
||||
|
||||
static void ias_discover_cb(struct bt_conn *conn, int err)
|
||||
{
|
||||
if (err != 0) {
|
||||
shell_error(ctx_shell, "Failed to discover IAS err: %d\n", err);
|
||||
bt_shell_error("Failed to discover IAS err: %d\n", err);
|
||||
} else {
|
||||
shell_print(ctx_shell, "IAS discover success\n");
|
||||
bt_shell_print("IAS discover success\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,10 +35,6 @@ static int cmd_ias_client_init(const struct shell *sh, size_t argc, char **argv)
|
|||
{
|
||||
int err;
|
||||
|
||||
if (!ctx_shell) {
|
||||
ctx_shell = sh;
|
||||
}
|
||||
|
||||
err = bt_ias_client_cb_register(&ias_client_callbacks);
|
||||
if (err != 0) {
|
||||
shell_print(sh, "IAS client init failed");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue