1 /*
2 * Copyright (c) 2022 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <stdlib.h>
8 #include <zephyr/shell/shell.h>
9 #include <zephyr/bluetooth/mesh.h>
10 #include <zephyr/bluetooth/mesh/shell.h>
11
12 #include "utils.h"
13
cmd_od_priv_gatt_proxy_set(const struct shell * sh,size_t argc,char * argv[])14 static int cmd_od_priv_gatt_proxy_set(const struct shell *sh, size_t argc,
15 char *argv[])
16 {
17 uint8_t val, val_rsp;
18 uint16_t net_idx = bt_mesh_shell_target_ctx.net_idx;
19 uint16_t addr = bt_mesh_shell_target_ctx.dst;
20 int err = 0;
21
22 if (argc < 2) {
23 err = bt_mesh_od_priv_proxy_cli_get(net_idx, addr, &val_rsp);
24 } else {
25 val = shell_strtoul(argv[1], 0, &err);
26
27 if (err) {
28 shell_warn(sh, "Unable to parse input string argument");
29 return err;
30 }
31
32 err = bt_mesh_od_priv_proxy_cli_set(net_idx, addr, val, &val_rsp);
33 }
34
35 if (err) {
36 shell_print(sh, "Unable to send On-Demand Private GATT Proxy Get/Set (err %d)",
37 err);
38 return 0;
39 }
40
41 shell_print(sh, "On-Demand Private GATT Proxy is set to 0x%02x", val_rsp);
42
43 return 0;
44 }
45
46 SHELL_STATIC_SUBCMD_SET_CREATE(
47 od_priv_proxy_cmds,
48 SHELL_CMD_ARG(gatt-proxy, NULL, "[Dur(s)]", cmd_od_priv_gatt_proxy_set, 1, 1),
49 SHELL_SUBCMD_SET_END);
50
51 SHELL_SUBCMD_ADD((mesh, models), od_priv_proxy, &od_priv_proxy_cmds,
52 "On-Demand Private Proxy Cli commands",
53 bt_mesh_shell_mdl_cmds_help, 1, 1);
54