1 /* 2 * Copyright (c) 2022 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <stdint.h> 8 #include <zephyr/shell/shell.h> 9 10 #define BT_MESH_SHELL_MDL_INSTANCE_CMDS(cmd_set_name, mod_id, mod_ptr) \ 11 static int cmd_##cmd_set_name##_get_all(const struct shell *sh, size_t argc, char *argv[]) \ 12 { \ 13 return bt_mesh_shell_mdl_print_all(sh, (mod_id)); \ 14 } \ 15 \ 16 static int cmd_##cmd_set_name##_set(const struct shell *sh, size_t argc, \ 17 char *argv[]) \ 18 { \ 19 int err = 0; \ 20 uint8_t elem_idx = shell_strtoul(argv[1], 0, &err); \ 21 \ 22 if (err) { \ 23 shell_warn(sh, "Unable to parse input string arg"); \ 24 return err; \ 25 } \ 26 \ 27 return bt_mesh_shell_mdl_instance_set(sh, &(mod_ptr), (mod_id), elem_idx); \ 28 } \ 29 \ 30 SHELL_STATIC_SUBCMD_SET_CREATE(cmd_set_name, \ 31 SHELL_CMD_ARG(set, NULL, "<ElemIdx>", cmd_##cmd_set_name##_set, 2,\ 32 0), \ 33 SHELL_CMD_ARG(get-all, NULL, NULL, cmd_##cmd_set_name##_get_all, 1,\ 34 0), \ 35 SHELL_SUBCMD_SET_END); 36 37 bool bt_mesh_shell_mdl_first_get(uint16_t id, const struct bt_mesh_model **mod); 38 39 int bt_mesh_shell_mdl_instance_set(const struct shell *sh, const struct bt_mesh_model **mod, 40 uint16_t mod_id, uint8_t elem_idx); 41 42 int bt_mesh_shell_mdl_print_all(const struct shell *sh, uint16_t mod_id); 43 44 int bt_mesh_shell_mdl_cmds_help(const struct shell *sh, size_t argc, char **argv); 45