Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp8845878pxu; Sun, 27 Dec 2020 22:50:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhPCv0ViKdkJhaiGKXAQeIUsu8wIN9OHZGTWQbIw1m5kftjfKW3/1+ebbDbmgPiajzvhyH X-Received: by 2002:aa7:cd71:: with SMTP id ca17mr42372835edb.25.1609138218680; Sun, 27 Dec 2020 22:50:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609138218; cv=none; d=google.com; s=arc-20160816; b=njxIMUIomidX6tbuevB7TP961R9Dz48InqlPQ2BnHvBabYMoNgCf4d8+onuvhpLryx gtas8NHQBqp8n+C+WSojcsX/fr/9fiVPTbZTF6CwucFd3h0lEFM08Tl9rygGaaGh+hAo 4iGmSz4xMz/rjmKPt8bo3sQAoi9F/x/g/RWhOZ7kWSlxUWRYMM2s4f2QGgcbQlI2VYaW B4fenS/CT0ivr1AZiR8oHtr35C7QrxF+IkgKJgT7b0NBm8sJZ0o7uFFVk5Dh2cyVdmfL BCC8YkAcQymmGFSf4ZWXAKt+zs7aV/kD0Du58qjJT/k1RJXDCk0zC7HBOOuxwRn4gcch ZzHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=LC6KJs6vajpeJsp5rgqNYIF+TrIBrc+h9wkJUlDzBSY=; b=etPqTOFiOvqKvVH4wdXsJy/Zx2K848xqrfovgDeQl/Vdk1i0y/FmsHEVmS/K5Hc/JJ dwdv9CFCblLzc1OPS+Bf5zkyBMfh4WnB6pykTU6w0YnbdDn6zLEz8e2VtLFjq9iYkkKQ szaErdBPqgzKm3Flc6l57M85n2nFStokoUKi0WPGRq8dVagHvQYXpyk0NGxwOfCSFeIf MB/lHHxdJPwRhwsWUMfcASbcPpTb+jC6kZIRea19dvyTrxojoEGT6djEE3gOZsopSAcF ErFpjPN0UmAo/6zspvP7E7C5fnyoKzbMO7DRCGPFEhyB+MKXrx8QlJZ5Jw2iPWMzLeNO hkfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mrErIfRe; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 96si21450960edq.111.2020.12.27.22.49.56; Sun, 27 Dec 2020 22:50:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mrErIfRe; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726327AbgL1GrM (ORCPT + 99 others); Mon, 28 Dec 2020 01:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbgL1GrM (ORCPT ); Mon, 28 Dec 2020 01:47:12 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21FC9C061795 for ; Sun, 27 Dec 2020 22:46:32 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id n205so16682018ybf.20 for ; Sun, 27 Dec 2020 22:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=LC6KJs6vajpeJsp5rgqNYIF+TrIBrc+h9wkJUlDzBSY=; b=mrErIfReCZAw+wNBMefjU1dGD5mVHKJiP6G3uSqDixBGTIEPxB6lhQPA1c9vxhv/Ab f41JXJZf5QBUwCVJXrCKv+I79Tv+brooRhzUYtMPi5LL3FV88U+MOBwJVKv9zw4QsD8o Prvn1OVMg9zYVaXnMZFtK5/3S/+Xrby7pvt1XtG6cyY59oEp6HMaOpQjFWYDvwbIdgVB I0INTmlPxdw38ZN5P6f2Y0TAK699PVDEELc0e75ORkk5ejgT+8FKI4A/JNSobJ8jKHIJ WKUTTu0J0Px/MF7w5jmxeL4LyI9eLm8WmdEb4MB78We6iyrx5gyKu7pmCDdJIsMB/auI Zeqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=LC6KJs6vajpeJsp5rgqNYIF+TrIBrc+h9wkJUlDzBSY=; b=Pa3TfWxU/2eKvL9joYOuFtACD/S/J74ChEnnrWO3XE1ACLifsgMjXt7ccOOOCOKqQi 2NK1+covDrdz30yrqOOVJKB9zugw7Z9zarInqSE3SLfhiAbI75CCA3fl7l0I4//HIwrO kiSAF2bXu8/0vKTSV5CSzuJ8GOd15rEmuNfjiilITTzU0Or+UOq7TsNEeKXhKDYeLloq o3FLFN0kzl4NAnILE0tzkmuwp3b0inN2xi1u5D+WXgOVSP85CAA3qGQs2H72Xp1A832b B8TqRNYLp9UwwwZkC8So8oq4nAn7rD4BOEOkAdyJ4wfB/3dLsx1B3UWx9qgPF7WF2XpD eDnw== X-Gm-Message-State: AOAM531fVGgN8aCRm+pA0yi9ZIdX0NsFKm+rw2K/5mSXD1qwhV9KhipI gJWa68cQEckN3wMIGGq2drTAPvhA78zUVbFoBaBwlniatWxarP9Hv2R1d3laBZCRCFQy0gFSENM sP1GpyB3aTrQfhrA2W3XqxaqsIJhtwsHe6f46xXulp2QBcpLve9vJVIyJMIGkbQRCX2QTjmbh9j FnTj33CPE8qJY= Sender: "howardchung via sendgmr" X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a25:ad93:: with SMTP id z19mr61939262ybi.486.1609137991351; Sun, 27 Dec 2020 22:46:31 -0800 (PST) Date: Mon, 28 Dec 2020 14:46:11 +0800 In-Reply-To: <20201228144543.Bluez.v1.1.Ie32770d0eed2e7739ce9d17d920766fb6aee8583@changeid> Message-Id: <20201228144543.Bluez.v1.2.I0c07c297925f838138b42674ab244572e6ea361b@changeid> Mime-Version: 1.0 References: <20201228144543.Bluez.v1.1.Ie32770d0eed2e7739ce9d17d920766fb6aee8583@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [Bluez PATCH v1 2/4] btmgmt: Add command read-sysconfig From: Howard Chung To: linux-bluetooth , luiz.dentz@gmail.com Cc: mmandlik@chromium.org, mcchou@chromium.org, apusaka@chromium.org, Howard Chung Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Add command read-sysconfig in btmgmt Example usage: localhost ~ # btmgmt [mgmt]# read-sysconfig Type: 0x0000 Length: 02 Value: 0000 Type: 0x0001 Length: 02 Value: 0008 ... Type: 0x001f Length: 01 Value: 01 Reviewed-by: apusaka@chromium.org --- tools/btmgmt.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 2f7cb2efcc38..c766de862a12 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1752,6 +1752,53 @@ static void cmd_exp_debug(int argc, char **argv) } } +static void print_mgmt_tlv(void *data, void *user_data) +{ + const struct mgmt_tlv *entry = data; + char buf[256]; + + bin2hex(entry->value, entry->length, buf, sizeof(buf)); + print("Type: 0x%04x\tLength: %02hhu\tValue: %s", entry->type, + entry->length, buf); +} + +static void read_sysconfig_rsp(uint8_t status, uint16_t len, const void *param, + void *user_data) +{ + struct mgmt_tlv_list *tlv_list; + struct mgmt_tlv *entry; + + if (status != 0) { + error("Read system configuration failed with status " + "0x%02x (%s)", status, mgmt_errstr(status)); + return; + } + + tlv_list = mgmt_tlv_list_load_from_buf(param, len); + if (!tlv_list) { + error("Unable to parse response of read system configuration"); + return; + } + + mgmt_tlv_list_foreach(tlv_list, print_mgmt_tlv, NULL); + mgmt_tlv_list_free(tlv_list); +} + +static void cmd_read_sysconfig(int argc, char **argv) +{ + uint16_t index; + + index = mgmt_index; + if (index == MGMT_INDEX_NONE) + index = 0; + + if (!mgmt_send(mgmt, MGMT_OP_READ_DEF_SYSTEM_CONFIG, index, + 0, NULL, read_sysconfig_rsp, NULL, NULL)) { + error("Unable to send read system configuration cmd"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + static void auto_power_enable_rsp(uint8_t status, uint16_t len, const void *param, void *user_data) { @@ -5030,6 +5077,8 @@ static const struct bt_shell_menu main_menu = { cmd_expinfo, "Show experimental features" }, { "exp-debug", "", cmd_exp_debug, "Set debug feature" }, + { "read-sysconfig", NULL, + cmd_read_sysconfig, "Read System Configuration" }, {} }, }; -- 2.29.2.729.g45daf8777d-goog