Skip to contentSkip to conversation

meshctl: Subscription Delete message added to configuration client

PATCH In review Daniele Biagetti 2 participants 2 messages May 16, 2019 – May 20, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 meshctl: Subscription Delete message added to configuration client

Subscription delete command/message added to the
configuration client model.

---
 tools/mesh/config-client.c | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
tools/mesh/config-client.c +40 -0
index df2643622..bff38e7a3 100644
@@ -1042,6 +1042,44 @@ static void cmd_sub_get(int argc, char *argv[])
 	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
+static void cmd_sub_del(int argc, char *argv[])
+{
+        uint16_t n;
+        uint8_t msg[32];
+        int parm_cnt;
+
+        if (IS_UNASSIGNED(target)) {
+                bt_shell_printf("Destination not set\n");
+                return bt_shell_noninteractive_quit(EXIT_FAILURE);
+        }
+
+        n = mesh_opcode_set(OP_CONFIG_MODEL_SUB_DELETE, msg);
+
+        parm_cnt = read_input_parameters(argc, argv);
+        if (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.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)) {
+                bt_shell_printf("Failed to send \"ADD SUBSCRIPTION\"\n");
+                return bt_shell_noninteractive_quit(EXIT_FAILURE);
+        }
+
+        return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
 static void cmd_mod_appidx_get(int argc, char *argv[])
 {
 	uint16_t n;
@@ -1237,6 +1275,8 @@ static const struct bt_shell_menu cfg_menu = {
 				cmd_sub_add,    "Add subscription"},
 	{"sub-get", "<ele_addr> <model id>",
 				cmd_sub_get,    "Get subscription"},
+	{"sub-del", "<ele_addr> <sub_addr> <model id>",
+				cmd_sub_del,    "Delete subscription"},
 	{"node-reset",		NULL,                    cmd_node_reset,
 				"Reset a node and remove it from network"},
 	{} },
Signature · 1 line
2.19.2.windows.1
#1 lore raw

Hi Daniele,

Quoted 4 lines · Daniele Biagetti

Subscription delete command/message added to the
configuration client model.

The submitted patches should not contain "Signed-off-by"

Quoted 66 lines
---
 tools/mesh/config-client.c | 40
++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
tools/mesh/config-client.c +38 -0
index df2643622..bff38e7a3 100644
@@ -1042,6 +1042,44 @@ static void cmd_sub_get(int argc, char
 *argv[])
 	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
+static void cmd_sub_del(int argc, char *argv[])
+{
+        uint16_t n;
+        uint8_t msg[32];
+        int parm_cnt;
+
+        if (IS_UNASSIGNED(target)) {
+                bt_shell_printf("Destination not set\n");
+                return bt_shell_noninteractive_quit(EXIT_FAILURE);
+        }
+
+        n = mesh_opcode_set(OP_CONFIG_MODEL_SUB_DELETE, msg);
+
+        parm_cnt = read_input_parameters(argc, argv);
+        if (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.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)) {
+                bt_shell_printf("Failed to send \"ADD
 SUBSCRIPTION\"\n");
+                return bt_shell_noninteractive_quit(EXIT_FAILURE);
+        }
+
+        return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
 static void cmd_mod_appidx_get(int argc, char *argv[])

{

tools/mesh/config-client.c +2 -0
 	uint16_t n;
@@ -1237,6 +1275,8 @@ static const struct bt_shell_menu cfg_menu = {
 				cmd_sub_add,    "Add subscription"},
 	{"sub-get", "<ele_addr> <model id>",
 				cmd_sub_get,    "Get subscription"},
+	{"sub-del", "<ele_addr> <sub_addr> <model id>",
+				cmd_sub_del,    "Delete subscription"},
 	{"node-reset",		NULL,                    cmd_node_res
 et,
 				"Reset a node and remove it from
Quoted 2 lines

network"},
{} },

Could you please re-format your patches so they do not contain DOS style end-of-line (^M)?

Please make sure that you follow the guidelines from bluez/doc/coding-style.txt

Also, a general comment about commit message style: it is strongly preferred that the commit subject line statement is in imprerative mood, see good description here:
https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53

Ome more thing. In general, when submitting a patch set, i.e., more than one patch, it's a good practice to precede the set with a cover letter (i.e., use --cover-letter option with your "git format-patch" command) that describes what is the purpose of this patch set. When submitting a single patch, a descriptive commit message is normally sufficient enough.

Best regards,

Inga