Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp156994ybl; Thu, 9 Jan 2020 19:05:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyJhyZB+NP8pi/CudRQ0ZOWqr2OyKL1x1eEXW0freMCM7ZkrJ5w4QMdAkVrXVEUjpu1wfC1 X-Received: by 2002:aca:ed57:: with SMTP id l84mr583255oih.8.1578625513545; Thu, 09 Jan 2020 19:05:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578625513; cv=none; d=google.com; s=arc-20160816; b=QohHpSL/wrswtrUE4YkNxaf4b6j3Oto90Eo6FBUay/HdgDPSXo589RHnQXVIFWEIh0 EUMSG9R+pYtxrEfciwAhOxnhghLQ/sjGxHe/W79uZhnrRtVU8vGwesy+O918Mpab15+M BiHv0DzSEkDCmSXSH9TSLDSFwQqRED/3Aesjngi8ohqJWqep4xzvrMYtxi3K7SMLFTeF ikVTMqciUXtNn+EIKDKNALhTko2baBKQ4UqlPcj/XyF6mTIBIVB/zYUQbWRgC23rQ7AS G7mZ8kKmDC9hGIlEr5rnT/TLGdKkOLGiyL6viZsB/lPV/XJ3JQGgUCxto+tlovcQ6SXg Y9uQ== 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 :message-id:date:subject:cc:to:from; bh=JiNEsk2hQHG1l0odbfSQmOHQv+yvrusGPeDZSHGpUkU=; b=o+8pAZPPcB1pATtQ3PuIuViqVwe6kUG8/jw/nmGYVU2ShmjHa+8Si43KQ73hi1giJh /StvTgpzPvTblps6pd5pS+DAXDGpztGgnOOd/0cGtE5ZsIv9FQgwHRIeHQxG+Nk2BOTq 4ABhLQGT1G39C32hl195nKE+d2IADxFikvWEUGqw1aoPk4ExlcoTEv0K/eu/QKaeypV0 Coll/RCwuBQof8v5Itq1tI8af970WEzpv6h0rs+FJOrNZ4QG3llU50iWAo81AeWjuWbD 3pyVuT1SJ7oBurEO6eQ2M3gWkIEm4W7IsOP4woi5qGjtyVrx3VuRnKFLbvGV/DmZATSV 6SaA== 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 k7si286607oib.115.2020.01.09.19.04.43; Thu, 09 Jan 2020 19:05:13 -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 S1730965AbgAJDEm (ORCPT + 99 others); Thu, 9 Jan 2020 22:04:42 -0500 Received: from mga05.intel.com ([192.55.52.43]:55361 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730952AbgAJDEm (ORCPT ); Thu, 9 Jan 2020 22:04:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2020 19:04:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,415,1571727600"; d="scan'208";a="396293606" Received: from ingas-nuc1.sea.intel.com ([10.254.104.252]) by orsmga005.jf.intel.com with ESMTP; 09 Jan 2020 19:04:41 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] tools/mesh: add commands for AppKey Get and NetKey Get Date: Thu, 9 Jan 2020 19:04:40 -0800 Message-Id: <20200110030440.5725-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.1 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 implements commands to send AppKey Get and NetKey Get messages and to process AppKey List and NetKey List reponses --- tools/mesh/cfgcli.c | 100 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 9 deletions(-) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index 2403c9293..50d2ce706 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -2,7 +2,7 @@ * * BlueZ - Bluetooth protocol stack for Linux * - * Copyright (C) 2019 Intel Corporation. All rights reserved. + * Copyright (C) 2019-2020 Intel Corporation. All rights reserved. * * * This library is free software; you can redistribute it and/or @@ -406,6 +406,33 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, break; + case OP_APPKEY_LIST: + if (len < 3) + break; + + bt_shell_printf("AppKey List (node %4.4x) Status %s\n", + src, mesh_status_str(data[0])); + bt_shell_printf("NetKey %3.3x\n", l_get_le16(&data[1])); + len -= 3; + + if (data[0] != MESH_STATUS_SUCCESS) + break; + + bt_shell_printf("AppKeys:\n"); + data += 3; + + while (len >= 3) { + bt_shell_printf("\t%3.3x\n", l_get_le16(data) & 0xfff); + bt_shell_printf("\t%3.3x\n", l_get_le16(data + 1) >> 4); + len -= 3; + data += 3; + } + + if (len == 2) + bt_shell_printf("\t%3.3x\n", l_get_le16(data)); + + break; + case OP_NETKEY_STATUS: if (len != 3) break; @@ -432,6 +459,26 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, break; + case OP_NETKEY_LIST: + if (len < 2) + break; + + bt_shell_printf("NetKey List (node %4.4x):\n", src); + + while (len >= 3) { + net_idx = l_get_le16(data) & 0xfff; + bt_shell_printf("\t%3.3x\n", net_idx); + net_idx = l_get_le16(data + 1) >> 4; + bt_shell_printf("\t%3.3x\n", net_idx); + data += 3; + len -= 3; + } + + if (len == 2) + bt_shell_printf("\t%3.3x\n", l_get_le16(data) & 0xfff); + + break; + case OP_MODEL_APP_STATUS: if (len != 7 && len != 9) break; @@ -818,6 +865,32 @@ static void cmd_appkey_del(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static void cmd_appkey_get(int argc, char *argv[]) +{ + uint16_t n; + uint8_t msg[32]; + + if (IS_UNASSIGNED(target)) { + bt_shell_printf("Destination not set\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + n = mesh_opcode_set(OP_APPKEY_GET, msg); + + if (read_input_parameters(argc, argv) != 1) { + bt_shell_printf("Bad arguments %s\n", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + put_le16(parms[0], msg + n); + n += 2; + + if (!config_send(msg, n, OP_APPKEY_GET)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + static void cmd_key_add(uint32_t opcode, int argc, char *argv[]) { uint16_t key_idx; @@ -1382,6 +1455,11 @@ static void cmd_node_reset(int argc, char *argv[]) cmd_default(OP_NODE_RESET); } +static void cmd_netkey_get(int argc, char *argv[]) +{ + cmd_default(OP_NETKEY_GET); +} + static bool tx_setup(model_send_msg_func_t send_func, void *user_data) { if (!send_func) @@ -1404,21 +1482,25 @@ static const struct bt_shell_menu cfg_menu = { {"composition-get", "[page_num]", cmd_composition_get, "Get composition data"}, {"netkey-add", "", cmd_netkey_add, - "Add network key"}, + "Add NetKey"}, {"netkey-update", "", cmd_netkey_update, - "Update network key"}, + "Update NetKey"}, {"netkey-del", "", cmd_netkey_del, - "Delete network key"}, + "Delete NetKey"}, + {"netkey-get", NULL, cmd_netkey_get, + "List NetKeys known to the node"}, {"appkey-add", "", cmd_appkey_add, - "Add application key"}, + "Add AppKey"}, {"appkey-update", "", cmd_appkey_update, - "Add application key"}, + "Add AppKey"}, {"appkey-del", "", cmd_appkey_del, - "Delete application key"}, + "Delete AppKey"}, + {"appkey-get", "", cmd_appkey_get, + "List AppKeys bound to the NetKey"}, {"bind", " [vendor_id]", cmd_add_binding, - "Bind app key to a model"}, + "Bind AppKey to a model"}, {"unbind", " [vendor_id]", cmd_del_binding, - "Remove app key from a model"}, + "Remove AppKey from a model"}, {"mod-appidx-get", " ", cmd_mod_appidx_get, "Get model app_idx"}, {"ttl-set", "", cmd_ttl_set, -- 2.21.1