if (!vendor) {
mod_id = get_le16(data);
- bt_shell_printf("%sModel Id\t%4.4x\n", offset, mod_id);
+ bt_shell_printf("%sModel ID\t%4.4x\n", offset, mod_id);
mod_id = VENDOR_ID_MASK | mod_id;
} else {
mod_id = get_le16(data + 2);
- bt_shell_printf("%sModel Id\t%4.4x %4.4x\n", offset,
+ bt_shell_printf("%sModel ID\t%4.4x %4.4x\n", offset,
get_le16(data), mod_id);
mod_id = get_le16(data) << 16 | mod_id;
}
+
return mod_id;
}
src, mesh_status_str(data[0]));
bt_shell_printf("Element Addr\t%4.4x\n", get_le16(data + 1));
- bt_shell_printf("Model ID\t%4.4x\n", get_le16(data + 3));
+ print_mod_id(data + 3, false, "");
for (i = 5; i < len; i += 2)
bt_shell_printf("Subscr Addr\t%4.4x\n",
get_le16(data + i));
break;
+ case OP_CONFIG_VEND_MODEL_SUB_LIST:
+ if (len < 7)
+ return true;
+
+ bt_shell_printf("\nNode %4.4x Subscription List status %s\n",
+ src, mesh_status_str(data[0]));
+
+ bt_shell_printf("Element Addr\t%4.4x\n", get_le16(data + 1));
+ print_mod_id(data + 3, true, "");
+
+ for (i = 7; i < len; i += 2)
+ bt_shell_printf("Subscr Addr\t%4.4x\n",
+ get_le16(data + i));
+ break;
+
+
/* Per Mesh Profile 4.3.2.50 */
case OP_MODEL_APP_LIST:
if (len < 5)
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
-static void cmd_sub_add(int argc, char *argv[])
+static void subscription_cmd(int argc, char *argv[], uint32_t opcode)
{
uint16_t n;
uint8_t msg[32];
int parm_cnt;
- n = mesh_opcode_set(OP_CONFIG_MODEL_SUB_ADD, msg);
+ n = mesh_opcode_set(opcode, msg);
parm_cnt = read_input_parameters(argc, argv);
- if (parm_cnt != 3) {
+ if (parm_cnt != 3 && parm_cnt != 4) {
bt_shell_printf("Bad arguments: %s\n", argv[1]);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- /* Per Mesh Profile 4.3.2.19 */
/* Element Address */
put_le16(parms[0], msg + n);
n += 2;
/* Subscription Address */
put_le16(parms[1], msg + n);
n += 2;
- /* SIG Model ID */
- put_le16(parms[2], msg + n);
- n += 2;
- if (!config_send(msg, n, OP_CONFIG_MODEL_SUB_ADD))
+ /* Model ID */
+ n += put_model_id(msg + n, &parms[2], parm_cnt == 4);
+
+ if (!config_send(msg, n, opcode))
return bt_shell_noninteractive_quit(EXIT_FAILURE);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
-static void cmd_sub_get(int argc, char *argv[])
+static void cmd_sub_add(int argc, char *argv[])
+{
+ subscription_cmd(argc, argv, OP_CONFIG_MODEL_SUB_ADD);
+}
+
+static void cmd_sub_del(int argc, char *argv[])
+{
+ subscription_cmd(argc, argv, OP_CONFIG_MODEL_SUB_DELETE);
+}
+
+static void cmd_sub_ovwrt(int argc, char *argv[])
+{
+ subscription_cmd(argc, argv, OP_CONFIG_MODEL_SUB_OVERWRITE);
+}
+
+static void cmd_sub_del_all(int argc, char *argv[])
{
uint16_t n;
uint8_t msg[32];
int parm_cnt;
- n = mesh_opcode_set(OP_CONFIG_MODEL_SUB_GET, msg);
+ n = mesh_opcode_set(OP_CONFIG_MODEL_SUB_DELETE_ALL, msg);
parm_cnt = read_input_parameters(argc, argv);
- if (parm_cnt != 2) {
+ if (parm_cnt != 2 && parm_cnt != 3) {
bt_shell_printf("Bad arguments: %s\n", argv[1]);
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}
- /* Per Mesh Profile 4.3.2.27 */
/* Element Address */
put_le16(parms[0], msg + n);
n += 2;
+
/* Model ID */
- put_le16(parms[1], msg + n);
+ n += put_model_id(msg + n, &parms[1], parm_cnt == 3);
+
+ if (!config_send(msg, n, OP_CONFIG_MODEL_SUB_DELETE_ALL))
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
+static void cmd_sub_get(int argc, char *argv[])
+{
+ uint16_t n;
+ uint8_t msg[32];
+ int parm_cnt;
+ bool vendor;
+ uint32_t opcode;
+
+ parm_cnt = read_input_parameters(argc, argv);
+ if (parm_cnt != 2 && parm_cnt != 3) {
+ bt_shell_printf("Bad arguments: %s\n", argv[1]);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ vendor = (parm_cnt == 3);
+ opcode = !vendor ? OP_CONFIG_MODEL_SUB_GET :
+ OP_CONFIG_VEND_MODEL_SUB_GET;
+ n = mesh_opcode_set(opcode, msg);
+
+ /* Element Address */
+ put_le16(parms[0], msg + n);
n += 2;
+ /* Model ID */
+ n += put_model_id(msg + n, &parms[1], vendor);
- if (!config_send(msg, n, OP_CONFIG_MODEL_SUB_GET))
+ if (!config_send(msg, n, opcode))
return bt_shell_noninteractive_quit(EXIT_FAILURE);
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
"Set heartbeat subscribe"},
{"hb-sub-get", NULL, cmd_hb_sub_get,
"Get heartbeat subscribe"},
- {"sub-add", "<ele_addr> <sub_addr> <model_id>", cmd_sub_add,
+ {"sub-add", "<ele_addr> <sub_addr> <model_id> [vendor]", cmd_sub_add,
"Add subscription"},
- {"sub-get", "<ele_addr> <model_id>", cmd_sub_get,
+ {"sub-del", "<ele_addr> <sub_addr> <model_id> [vendor]", cmd_sub_del,
+ "Delete subscription"},
+ {"sub-wrt", "<ele_addr> <sub_addr> <model_id> [vendor]", cmd_sub_ovwrt,
+ "Overwrite subscription"},
+ {"sub-del-all", "<ele_addr> <model_id> [vendor]", cmd_sub_del_all,
+ "Delete subscription"},
+ {"sub-get", "<ele_addr> <model_id> [vendor]", cmd_sub_get,
"Get subscription"},
{"node-reset", NULL, cmd_node_reset,
"Reset a node and remove it from network"},