From patchwork Sat Jul 10 00:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 12368201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65280C07E99 for ; Sat, 10 Jul 2021 00:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36F84611ED for ; Sat, 10 Jul 2021 00:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231609AbhGJAku (ORCPT ); Fri, 9 Jul 2021 20:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbhGJAkt (ORCPT ); Fri, 9 Jul 2021 20:40:49 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4022C0613DD for ; Fri, 9 Jul 2021 17:38:04 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id j9so4604966pfc.5 for ; Fri, 09 Jul 2021 17:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XN5MUhZT1XhXTFqsPEQj8kO+1UMDEkMXUWwcUFVE5pE=; b=OmU4gmxILDbNrZzhVQihYD3ZGGjGgoNCpx+37rFAGuxlNIIFslhr5rUD6R65uXSi3+ t3rkF2ZsPgixdQSLhBGJxpHueQpYQn8zqxJf9WA89jAR/jXYZC8XbRaqCJTaETj64gLU tEtYMxW8IRTQrsETWtPGHplvZ68fI9OMDFG5CdXa0A1vEtN7kou3uD2nVVd1Og/uK/aK pAAV5OborAiCKqa9s5bh621oihpViVLuT6w7zNlQa94Ln446W5Rbobz983UXy8FdlON0 2WbGiGKE3AUQgdE0jfCq+A9xS77eeOLXyJO4IK1UcQbZpZTdnXcV+lgZV6Ek1xe2YHef YUDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XN5MUhZT1XhXTFqsPEQj8kO+1UMDEkMXUWwcUFVE5pE=; b=XQI/Tk0Vmwy90TelT7cQs+hZ+Pk5ARo5cThp+VkbL9YXltoFJo5cr8nyBjZnYQsd6s Fodg2AAPh+7jq1SsTUKvRd9me/sm5xRIQdUeeDfL2iUZtENTxDI6SQQ+wvtRIhKOL/Xv rZlLVs8uYYwH00OSdS6As8bNvwoZ1FCI2jLh6CB8LCyMeXuSAx2HJnpePpfDZkozIJVv VC4z4v2M2gf5ic0cvfUkV5w4Gs5IkUQldcURjGvlu7EyD9BUDvhQODry1IcaS/M22s9q Ru7MCS7c9LWuY5UPD5Ksp4W/RrLceyU8k+uMoy8X4vLIdFr6LDIcNnrLCRWeYCj84NLg OmnA== X-Gm-Message-State: AOAM530onPSc50HuGOTnyfLbZRBb9UCocqbyar8k7rqPKJSl0rA6phSY oDIaDoXtw0hzXi69qRLiqo45EQfn7dY= X-Google-Smtp-Source: ABdhPJzRl76NZkTX3kLDzYQP/G1Kc1HrDzsE90F3gTfnXX7xETXjXSOzRlljNWMEbciwrKjHilxa/Q== X-Received: by 2002:a62:30c5:0:b029:31e:fa6d:1738 with SMTP id w188-20020a6230c50000b029031efa6d1738mr30715643pfw.55.1625877484095; Fri, 09 Jul 2021 17:38:04 -0700 (PDT) Received: from han1-mobl3.intel.com ([2601:1c0:6a01:d830::512a]) by smtp.gmail.com with ESMTPSA id u13sm7278219pfi.54.2021.07.09.17.38.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 17:38:03 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH 1/2] emulator/btdev: Add support HCI_READ_CLOCK command Date: Fri, 9 Jul 2021 17:38:00 -0700 Message-Id: <20210710003801.941787-1-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch adds support HCI_READ_CLOCK command in btdev. --- emulator/btdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/emulator/btdev.c b/emulator/btdev.c index a7fda2c89..a863a0799 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -2296,6 +2296,22 @@ static int cmd_read_rssi(struct btdev *dev, const void *data, return 0; } +static int cmd_read_clock(struct btdev *dev, const void *data, + uint8_t len) +{ + const struct bt_hci_cmd_read_clock *cmd = data; + struct bt_hci_rsp_read_clock rsp; + + memset(&rsp, 0, sizeof(rsp)); + rsp.status = BT_HCI_ERR_SUCCESS; + rsp.handle = le16_to_cpu(cmd->handle); + rsp.clock = 0x11223344; + rsp.accuracy = 0x5566; + cmd_complete(dev, BT_HCI_CMD_READ_CLOCK, &rsp, sizeof(rsp)); + + return 0; +} + static int cmd_enable_dut_mode(struct btdev *dev, const void *data, uint8_t len) { @@ -2389,6 +2405,7 @@ static int cmd_enable_dut_mode(struct btdev *dev, const void *data, NULL), \ CMD(BT_HCI_CMD_READ_COUNTRY_CODE, cmd_read_country_code, NULL), \ CMD(BT_HCI_CMD_READ_RSSI, cmd_read_rssi, NULL), \ + CMD(BT_HCI_CMD_READ_CLOCK, cmd_read_clock, NULL), \ CMD(BT_HCI_CMD_ENABLE_DUT_MODE, cmd_enable_dut_mode, NULL) static void set_common_commands_bredr20(struct btdev *btdev) @@ -2448,6 +2465,7 @@ static void set_common_commands_bredr20(struct btdev *btdev) btdev->commands[14] |= 0x40; /* Read Local Extended Features */ btdev->commands[15] |= 0x01; /* Read Country Code */ btdev->commands[15] |= 0x20; /* Read RSSI */ + btdev->commands[15] |= 0x80; /* Read Clock */ btdev->commands[16] |= 0x04; /* Enable Device Under Test Mode */ } From patchwork Sat Jul 10 00:38:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 12368199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E00CBC07E99 for ; Sat, 10 Jul 2021 00:38:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0D85611ED for ; Sat, 10 Jul 2021 00:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbhGJAku (ORCPT ); Fri, 9 Jul 2021 20:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231547AbhGJAkt (ORCPT ); Fri, 9 Jul 2021 20:40:49 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C69C4C0613E5 for ; Fri, 9 Jul 2021 17:38:05 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id p36so545489pfw.11 for ; Fri, 09 Jul 2021 17:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Zxz84MZik6tQH6NSkK9edzfoiXIstAHSh7FRcIqU+Dg=; b=C9lRDLfW8kVjyVwNPWUnKfQTzN9h1T6x3K4WkfZ4t4W6+CZlzeHPCmcSuqgoGgpLlD DpbqYuEz/2EU1zIzqOaXsptpr73d3P5y8X8B2woEqQDhWz5/vbwPcObxNf4o047jLrN3 +0gov/+vaIaa26EGMLTqSiPoKJ+ujs5XP4vRJadljYjz3qnqBLjZGHIG/QJ1xyMPD0ff bkSvhczvY9d8aEnr4rTlmoBwKGLKsz4u5+exIE20kyoy/BO/wImOSSsGNOgRff3oZBxW Vn9AW9tHaRPigZQFrmTIm/43kWyikZOwoka4n5ahPY2mXyDEv4L6c49/sXrjG18785HC /rZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zxz84MZik6tQH6NSkK9edzfoiXIstAHSh7FRcIqU+Dg=; b=M+ivnxpM6gjj03PkKSCjp1udAnuWAseqr0dDaHc0yDIBaJTyJdHow941zJem5CkiD2 Yeh9lTf+Jt2nbr5MGjaYST5DZkOj9Wv7RLpowkwjv6FbnanRWRAY6YJA6uk41Tq4eM1E SYNDm+g4NKYFrfguVa6EoqSEi6Kauw3oa0noYq98t33LdkLermM/PC01lXRVwEKI+j7A 6tj3SRYn9h9yHOYWkHy6ptdGGmgENvq9KSRQMPy1jjKVkTb5GtPqx3w9+aJOh3HYyaYQ snrddcERzysHOPYT3qVp+6L4vMsFJWqxdTwKaC+hbpjUYG8CKvNzycH4J2elnCeQ/Opt W1xQ== X-Gm-Message-State: AOAM531dEOUD8mf4ClQLWvW7GU3oAqnNlfl0E7injH2JE+EBoHc3jhdt KgCBBKXoZ6tFlhsGflUJYyKBR+PXjl8= X-Google-Smtp-Source: ABdhPJxD6g655z+ZLvLNUC+JIhKTcFfEe7XA8fSugErbMQg69uOTzT9O73+JZpan95wAEhFx9nl04g== X-Received: by 2002:a62:1782:0:b029:2f7:dcbe:c292 with SMTP id 124-20020a6217820000b02902f7dcbec292mr40796949pfx.63.1625877485174; Fri, 09 Jul 2021 17:38:05 -0700 (PDT) Received: from han1-mobl3.intel.com ([2601:1c0:6a01:d830::512a]) by smtp.gmail.com with ESMTPSA id u13sm7278219pfi.54.2021.07.09.17.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 17:38:04 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH 2/2] tool/mgmt-tester: Add test cases for Read Clock Information API Date: Fri, 9 Jul 2021 17:38:01 -0700 Message-Id: <20210710003801.941787-2-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210710003801.941787-1-hj.tedd.an@gmail.com> References: <20210710003801.941787-1-hj.tedd.an@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Brian Gix This patch adds test cases for Read Clock Information management API. --- tools/mgmt-tester.c | 71 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index d2ded574e..5def0d83c 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -3917,6 +3917,53 @@ static const struct generic_data set_privacy_nval_param_test = { .expect_status = MGMT_STATUS_INVALID_PARAMS, }; +static const void *get_clock_info_send_param_func(uint16_t *len) +{ + struct test_data *data = tester_get_data(); + static uint8_t param[7]; + + memcpy(param, hciemu_get_client_bdaddr(data->hciemu), 6); + param[6] = 0x00; /* Address type */ + + *len = sizeof(param); + + return param; +} + +static const void *get_clock_info_expect_param_func(uint16_t *len) +{ + struct test_data *data = tester_get_data(); + static uint8_t param[17]; + struct mgmt_rp_get_clock_info *rp; + + rp = (struct mgmt_rp_get_clock_info *)param; + memset(param, 0, sizeof(param)); + memcpy(param, hciemu_get_client_bdaddr(data->hciemu), 6); + param[6] = 0x00; /* Address type */ + + rp->local_clock = 0x11223344; + rp->piconet_clock = 0x11223344; + rp->accuracy = 0x5566; + + *len = sizeof(param); + + return param; +} + +static const void *get_clock_info_expect_param_not_powered_func(uint16_t *len) +{ + struct test_data *data = tester_get_data(); + static uint8_t param[17]; + + memset(param, 0, sizeof(param)); + memcpy(param, hciemu_get_client_bdaddr(data->hciemu), 6); + param[6] = 0x00; /* Address type */ + + *len = sizeof(param); + + return param; +} + static const void *get_conn_info_send_param_func(uint16_t *len) { struct test_data *data = tester_get_data(); @@ -3962,6 +4009,21 @@ static const void *get_conn_info_error_expect_param_func(uint16_t *len) return param; } +static const struct generic_data get_clock_info_succes1_test = { + .setup_settings = settings_powered_connectable_bondable_ssp, + .send_opcode = MGMT_OP_GET_CLOCK_INFO, + .send_func = get_clock_info_send_param_func, + .expect_status = MGMT_STATUS_SUCCESS, + .expect_func = get_clock_info_expect_param_func, +}; + +static const struct generic_data get_clock_info_fail1_test = { + .send_opcode = MGMT_OP_GET_CLOCK_INFO, + .send_func = get_clock_info_send_param_func, + .expect_status = MGMT_STATUS_NOT_POWERED, + .expect_func = get_clock_info_expect_param_not_powered_func, +}; + static const struct generic_data get_conn_info_succes1_test = { .setup_settings = settings_powered_connectable_bondable_ssp, .send_opcode = MGMT_OP_GET_CONN_INFO, @@ -9780,7 +9842,7 @@ static void test_command_generic_connect(const void *test_data) addr_type = data->hciemu_type == HCIEMU_TYPE_BREDRLE ? BDADDR_BREDR : BDADDR_LE_PUBLIC; - + tester_print("ADDR TYPE: %d", addr_type); bthost = hciemu_client_get_host(data->hciemu); bthost_hci_connect(bthost, master_bdaddr, addr_type); } @@ -10755,6 +10817,13 @@ int main(int argc, char *argv[]) &set_privacy_nval_param_test, NULL, test_command_generic); + test_bredr("Get Clock Info - Success", + &get_clock_info_succes1_test, NULL, + test_command_generic_connect); + test_bredrle("Get Clock Info - Fail (Power Off)", + &get_clock_info_fail1_test, NULL, + test_command_generic); + test_bredrle("Get Conn Info - Success", &get_conn_info_succes1_test, NULL, test_command_generic_connect);