Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14284234pxu; Mon, 4 Jan 2021 19:16:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8eByrcs6ezsQdIbS57SYfQ6jrLrPYPOtfqrh9oP1aiRszsgg++2w5wN928HsonD2kc3ik X-Received: by 2002:a50:fb1a:: with SMTP id d26mr73681959edq.101.1609816602311; Mon, 04 Jan 2021 19:16:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609816602; cv=none; d=google.com; s=arc-20160816; b=h1H51tT4W+5VLF/iT4+qLniQaBS+RKNQYVJtbB9/X21/s09lkMRb2LnQXE13+f3gCD 7WS2zNhFKGHhZwRM5irVJnNCOmtpxBS5E5Rf7tDyUWjYHyqxw3mvUTtvTjj26UJNhQfL dtjUmukZDUkCxiDk7TJAdT9SCC28upPu+7YO+nlOuiwXG1YQrJbC1fsmI0DywDEDrB1Y TGW+SDAqHJ0ZDnPkaNKc5pTTf/ojBg5kxokpSG3RBUEqxEfluaS44PDrMW8crtVSiIJw INISZ+LmXc640gzLN7muUWCxRsJJR1Y6cuevf3plgZlg3IUO9W+0ZKobnGmouckWe7y4 4OEw== 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=kiatny/Rcuc64s8UOi4ZGZPPONmshKs7gN1XYmzrd+4=; b=HgH6kdiR962JcXIV5b/V7H2HFYAsu7TyEVzU8QKuB4/z2e5qk6jpuHIL7aZQNs5uP3 kbSKcaiVXU16rrEPX5ld0AMRPOsSIr7zhp4dPYNSEIh8wUXFx8eb5mKNXkJxC9BXXckO R1HCK892so3RjMXRndMk2gCurSqbTWwVvc/M2Qq8/K3WRnDfHkqPcUAdooQhNEBwAo4z FYMXVm6BXkUV2mcpo5SfDgHdofd2/eDgtGySEnwlSb+C0tiRG2Hdy4Rrv7Zns3TVM6f5 9OlOe4r2u4ufL6fE8yEVtug3f00ne8j7Ot1Z/Jc4wfIw0r1kmo7lScVDW84lzmnToY6O z72Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jo1eR4vP; 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 hs12si31661354ejc.74.2021.01.04.19.16.20; Mon, 04 Jan 2021 19:16:42 -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=jo1eR4vP; 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 S1728116AbhAEDNw (ORCPT + 99 others); Mon, 4 Jan 2021 22:13:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727716AbhAEDNw (ORCPT ); Mon, 4 Jan 2021 22:13:52 -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 F2255C061796 for ; Mon, 4 Jan 2021 19:13:11 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id w17so54437542ybl.15 for ; Mon, 04 Jan 2021 19:13:11 -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=kiatny/Rcuc64s8UOi4ZGZPPONmshKs7gN1XYmzrd+4=; b=jo1eR4vPYZMe3ZOptORJvRBF5xJMnOlvUUTU+nPSw3tGe/t1vsxEnudXODbd5Jq111 eYTLanXBvjdd8pFxCKYn21R61OeCkJXSXo8n9TZBxOPSZkeloCBGwZTG4m3PdtaxUdY2 SQ9DYVYwPfviurVY1THCg2LXkGnkrsDoaSYoikJvd9Le9o1AdCLPNwXLcy1LE8op4oOo iP9APGtWxzGinTPqCc9b5EelOa0dt4MfVbpwj6WXH9NZMvpUHdNmfkSJ79LFjKYOZWGq md/cOygS6i5YfXdxH0+hSjXOm2vzBikXSD2mwZ3cmvMEjwSvYnXbJtB7TgLLT7ZizKPP TNPA== 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=kiatny/Rcuc64s8UOi4ZGZPPONmshKs7gN1XYmzrd+4=; b=pkwgPIbMUbAfBQosSiTO6lN3KPMt5e4Tx6oDJuw7KldRCmwwqR7ZKDOTitKM8JPciq TjvDunrEmIRHOFpXExgvFo7t3O7BnO46H7kHHEfMTlInpsUfcFXSkJT7PLqMUSoNObvH gEsFY9LfDFdy7RreOvSR7v4frMI9+lhY7avhYibqqD1C6YY+6UuUhHGfph++jlhk/YzL d7Icx/uPowGDLVj68QKAumfvuApU+1MmOswAG5QyS336Ymdbtmce3koUjuUGiFxKWgcB sLadbJlaTLyGcGBaIqS38ciwSJqsO0KuRGo2J4YVfVO0VSlH7qmGI8O+0pO30c9CXqMg npTA== X-Gm-Message-State: AOAM530K6THQ7KgcmBH/GtQ4eH8FwDHPAEooWXChjE5Ym5nKI0jbpAxS YrpNj3ny92sC6w3cvRpVcQC/TS857cfjK87/i9PIk/DgHX8KdyrMef9b8fYc4zdstqW1dxx7kJV /E25DfcgbHgLRwMduC9SOyZJgAZM0JrdVwZPbtmup2no2pyCL69VzUiPOOQUKFzwcfLZ5ZuNTbK XE6DWEG0cDh5I= 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:2c58:: with SMTP id s85mr110965846ybs.366.1609816391125; Mon, 04 Jan 2021 19:13:11 -0800 (PST) Date: Tue, 5 Jan 2021 11:12:55 +0800 In-Reply-To: <20210105111219.Bluez.v4.1.Ie32770d0eed2e7739ce9d17d920766fb6aee8583@changeid> Message-Id: <20210105111219.Bluez.v4.2.I0c07c297925f838138b42674ab244572e6ea361b@changeid> Mime-Version: 1.0 References: <20210105111219.Bluez.v4.1.Ie32770d0eed2e7739ce9d17d920766fb6aee8583@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [Bluez PATCH v4 2/4] btmgmt: Add command read-sysconfig From: Howard Chung To: linux-bluetooth , luiz.dentz@gmail.com Cc: mcchou@chromium.org, apusaka@chromium.org, mmandlik@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 --- (no changes since v3) Changes in v3: - Removed unused variable in read_sysconfig_rsp tools/btmgmt.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 2f7cb2efcc38..7d83d3ee6bd5 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1752,6 +1752,52 @@ 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; + + 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 +5076,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