Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp142458ybl; Fri, 17 Jan 2020 20:25:48 -0800 (PST) X-Google-Smtp-Source: APXvYqzcuTEO0gdQMKP8bwVCAm5vtJlTxctv7nMgPFsYG+YXi10d5JBbKgV1bfEicbmzgibapSMU X-Received: by 2002:aca:48cd:: with SMTP id v196mr6266178oia.102.1579321548435; Fri, 17 Jan 2020 20:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579321548; cv=none; d=google.com; s=arc-20160816; b=tXMdsa5lW2bVWLmOQdNvzW3u//3Lxh23W8R4wFxSDEvf2sgYI9KWUdztHMemYwozVk o97If7tLmHKlujzKg9omjLgeWQN5EoKYOSrcOlCYsaUBGZei05OI9IJ0G87ZV+E/PYKU i694d5Ghwg07sqVJtK92EAzGizHohpH7o1evzVieTwFcjEq7BsfTklNywKzw2wu2cZHT bK1aUCdhbmULTu0dya+LH+CRukwyKD5EtClQbj95RVuA/L9HPT2palY8ak5CI057KmW8 nGgC7DXRr1+8DfRMAiwi1gvkIgLJxmetbpRY8gRk+B4jJ/cc3KOLTae4qZniu/4udzm7 mXjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Pvv7WBp65W0pXD2+ZgzJ9msOMnTVhcPwGV1X0KuGHdc=; b=aHwu7JXU4jxXjrxUaW1lG1YNTrSPrsR/8jlFdk7blj0hhqKWAuz92spL/k1ibbados +c/k4df7s693uYExZgXz0rVjgPC66X+IvzhMxuMUaGlC4pQjwRONzYSedY/5hKtX3H6n QWYN4tEke2bcdn8qyLmmD2CTx2CKx4pcU+UveIoXSA4AZkveOUvlH3poLBpQHv5QbxZp 6c8+8yeF03jlMop4f7HW0Iuv1NPE+uni1Zlb6v74biNwP6Ix3MbEzsOEDGJ48id1119+ OdmF8NZXbbO7De53IwHluL3sMzsFp3ZBdfhEF2GVDbmlBEcPScSkOoyDxuGFadIgVp9R KSqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si15019548otl.213.2020.01.17.20.25.37; Fri, 17 Jan 2020 20:25:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbgAREWi (ORCPT + 99 others); Fri, 17 Jan 2020 23:22:38 -0500 Received: from mga11.intel.com ([192.55.52.93]:11361 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbgAREWi (ORCPT ); Fri, 17 Jan 2020 23:22:38 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2020 20:22:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,332,1574150400"; d="scan'208";a="220926461" Received: from ingas-nuc1.sea.intel.com ([10.251.138.89]) by fmsmga008.fm.intel.com with ESMTP; 17 Jan 2020 20:22:37 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 4/4] tools/mesh: Implement model group subscription commands Date: Fri, 17 Jan 2020 20:22:33 -0800 Message-Id: <20200118042233.15338-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200118042233.15338-1-inga.stotland@intel.com> References: <20200118042233.15338-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds implementation for: Config Model Subscription Delete Config Model Subscription Delete All Config Model Subscription Overwrite and adds handling vendor model IDs for Config Model Subscription Add Config Model Subscription Get --- tools/mesh/cfgcli.c | 105 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 19 deletions(-) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index f9aaf137d..cfa573de3 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -246,14 +246,15 @@ static uint32_t print_mod_id(uint8_t *data, bool vendor, const char *offset) 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; } @@ -606,13 +607,29 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, 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) @@ -1241,60 +1258,104 @@ static void cmd_pub_get(int argc, char *argv[]) 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); @@ -1564,9 +1625,15 @@ static const struct bt_shell_menu cfg_menu = { "Set heartbeat subscribe"}, {"hb-sub-get", NULL, cmd_hb_sub_get, "Get heartbeat subscribe"}, - {"sub-add", " ", cmd_sub_add, + {"sub-add", " [vendor]", cmd_sub_add, "Add subscription"}, - {"sub-get", " ", cmd_sub_get, + {"sub-del", " [vendor]", cmd_sub_del, + "Delete subscription"}, + {"sub-wrt", " [vendor]", cmd_sub_ovwrt, + "Overwrite subscription"}, + {"sub-del-all", " [vendor]", cmd_sub_del_all, + "Delete subscription"}, + {"sub-get", " [vendor]", cmd_sub_get, "Get subscription"}, {"node-reset", NULL, cmd_node_reset, "Reset a node and remove it from network"}, -- 2.21.1