From patchwork Thu Feb 24 00:30:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E3A5C433F5 for ; Thu, 24 Feb 2022 00:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiBXAbD (ORCPT ); Wed, 23 Feb 2022 19:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiBXAbA (ORCPT ); Wed, 23 Feb 2022 19:31:00 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CB36D94C for ; Wed, 23 Feb 2022 16:30:32 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id m13-20020a17090aab0d00b001bbe267d4d1so4644374pjq.0 for ; Wed, 23 Feb 2022 16:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5+rBSTF3sbYgAZ1sTD//Ehy88r9kNGpqp/Y56gyqolU=; b=Q2gRiI5OUYsIMY/8NAeaqna9sX1WhX4Xzr62c4GdpcOedIRCygTt9lFKGtCdmfPUIm GmOEReVS2Q/Py8R36LOwSQsV15BzeTSp9WlAyFSW0TNMotvVH9o91+bsycoTDhCxwvYU 16cs5LQIMHD8/ZTB0jR6xSB7idzd7Bg+xJouLQ7ICNI1hRHAZ6XOmqH594quP7M0aQRx mXFvaL6qwi8A0t+i6ou8xxhY2SAEkmlp2xHcCBiBK3VYOO3hJmeY9ugLfhNDllW8FHUS wgtTUtL51UcAT/V1jj3G1Gk7CBw4A+mIRsRlLTEzd/SkMyx6sCrTExdu3SScLg2z54/a TLXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5+rBSTF3sbYgAZ1sTD//Ehy88r9kNGpqp/Y56gyqolU=; b=70Z2eVRyu2gVQabR3ntBHbmhtKjwdhHb7upbGsoPbDaBGSC5nO8Eih1obm3EBMgXdq Bgn2gjuir0nXBBRZOYKcOK6fyojxBnHbt6GXjxFzjmAGOG8CjXzGVaPS2bDlcpIuNIx0 xqc2ukimsR6dthK5/ZcPCpo5hp13SQAfjor1sOBtigqPOxbZPgsvMLWQf4JW3lgZyoo9 TCO8HnHHZJN90xRzNRMwy9Yg7PZmEjNsl0wJXOEDp4fXWTxDp9dM7elWC5HJ0/ZoMAAp s+aLV9UVQXIOLEc1/fwDsuSfysOSMtVabnoZ7la9gZepjKALq6znMMwvXMlMgjT3Hkx4 EmbA== X-Gm-Message-State: AOAM531LTVl4AbZbRP69ny+1oPS7n1rAGsOyg2kcwyhXC+jItmp/tdE5 +/yTk9I3NSYh1SSQam76j/PkaicfPJg= X-Google-Smtp-Source: ABdhPJxLIeI12qHm5SMJYPzoYUtIaqBHV1Rt1ciEx1WOaEVXxFeGIvAJ1lj4/wmnDkFMjGCIrbYHew== X-Received: by 2002:a17:902:8bc2:b0:14d:6d13:a389 with SMTP id r2-20020a1709028bc200b0014d6d13a389mr70669plo.2.1645662631747; Wed, 23 Feb 2022 16:30:31 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:31 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 01/11] monitor: Fix Create BIG PDU Date: Wed, 23 Feb 2022 16:30:19 -0800 Message-Id: <20220224003029.706163-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz The PDU of Create BIG is actually fixed size as the num_bis is related to the number of indexes to be connected and not the BIS parameters. --- emulator/btdev.c | 2 +- monitor/bt.h | 2 +- monitor/packet.c | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 378674010..9189e8082 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -5692,10 +5692,10 @@ static int cmd_create_big_complete(struct btdev *dev, const void *data, uint8_t len) { const struct bt_hci_cmd_le_create_big *cmd = data; + const struct bt_hci_bis *bis = &cmd->bis; int i; for (i = 0; i < cmd->num_bis; i++) { - const struct bt_hci_bis *bis = &cmd->bis[i]; struct btdev_conn *conn; struct { struct bt_hci_evt_le_big_complete evt; diff --git a/monitor/bt.h b/monitor/bt.h index 66ed3ef5a..51b1833dc 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -2758,7 +2758,7 @@ struct bt_hci_cmd_le_create_big { uint8_t handle; uint8_t adv_handle; uint8_t num_bis; - struct bt_hci_bis bis[0]; + struct bt_hci_bis bis; } __attribute__ ((packed)); #define BT_HCI_CMD_LE_CREATE_BIG_TEST 0x2069 diff --git a/monitor/packet.c b/monitor/packet.c index ec779a9d5..a17c632a7 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -8200,10 +8200,8 @@ static void le_reject_cis_req_cmd(const void *data, uint8_t size) print_reason(cmd->reason); } -static void print_bis(const void *data, int i) +static void print_bis(const struct bt_hci_bis *bis) { - const struct bt_hci_bis *bis = data; - print_usec_interval("SDU Interval", bis->sdu_interval); print_field("Maximum SDU size: %u", le16_to_cpu(bis->sdu)); print_field("Maximum Latency: %u ms (0x%4.4x)", @@ -8223,10 +8221,7 @@ static void le_create_big_cmd(const void *data, uint8_t size) print_field("Handle: 0x%2.2x", cmd->handle); print_field("Advertising Handle: 0x%2.2x", cmd->adv_handle); print_field("Number of BIS: %u", cmd->num_bis); - - size -= sizeof(*cmd); - - print_list(cmd->bis, size, cmd->num_bis, sizeof(*cmd->bis), print_bis); + print_bis(&cmd->bis); } static void print_bis_test(const void *data, int i) From patchwork Thu Feb 24 00:30:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31339C433FE for ; Thu, 24 Feb 2022 00:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229955AbiBXAbF (ORCPT ); Wed, 23 Feb 2022 19:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiBXAbB (ORCPT ); Wed, 23 Feb 2022 19:31:01 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A35A6D96A for ; Wed, 23 Feb 2022 16:30:33 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id o8so299249pgf.9 for ; Wed, 23 Feb 2022 16:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5GrbTgGybIX7VE+dUMBOi9DeNkU5nTUZSPVbLy7V1tY=; b=ibF51VTF3FeXh8q6MWp5ToQ8705jRdam8byOB2Ug9Mp9VkH+VVjiS02GDf0lYd4/IC DfskWJrkC3SHjuvrF4xyDwdWdGbjmds4ToIdKTnR01iq92G8CmY8C4+0CX9i3JZV9lRx RRt8PZlnqTcUs/booD4mzPH72zfuogC4/VtdCKhPJTa2Csxaa8KvmIn3dJGW4w2kvo+V XgZwZZ+WJf6oV64nO2D+0y1ZJoUNm72ak8PbFDigpQBgMuBjT7KFauN9X5rqI+Bztiid tR3EUfzO/C2ET2KAsgFO2jOMzg7KmcwKlurX4UpHPqoaVpEWcMXKX31ZagzDmAI4fUcE D6iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5GrbTgGybIX7VE+dUMBOi9DeNkU5nTUZSPVbLy7V1tY=; b=qtG/jNeVoKr31Q5Oc2Q5lsycP18A6o9d0iT/d/D3T8i/+g8Wn6qHMjmp2IKysirTEw sgc90bNWZe52oXgVxQ31vnvMXqPnX8ag6YkJ4obGZtFgaoEpnL/leWuHcum/rlZ7OjTH fYtmXf1XjH8kN1riB+rH9zohqspf2qU4KneTkrG7C+OgWiPSSLE2++g+H99Ub/98m6N+ Iata7ydLu9oiFqgZothBTVPjeczt7AqNpInzuMEWK9qIMLLvpUsrCRr/vjoQ7RUJgazd bw0vzdVuRaLYy1Nj2xH3w2kWQA/1yJiHYPQzlhcMwRCqNlsrcPh/Ho2Km2mbUo7YqXrR mSXg== X-Gm-Message-State: AOAM530uWzxt/QloA5v63EsQnLgsFhJ+6ndruY1GCuAKhbJfp1VKr7iI zDQEm1NBG+EeYqISHbYhZgIgxI7/A0U= X-Google-Smtp-Source: ABdhPJxweJsaulfMnP+WgS53NTnYUdQuz7zql4TL+3nFqKOo08/gf+Vj+IF2I8yBWXaVcErUKlfV6g== X-Received: by 2002:a05:6a00:15d6:b0:4f1:4a86:b3b with SMTP id o22-20020a056a0015d600b004f14a860b3bmr209616pfu.60.1645662632521; Wed, 23 Feb 2022 16:30:32 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:32 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 02/11] btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC Date: Wed, 23 Feb 2022 16:30:20 -0800 Message-Id: <20220224003029.706163-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC generating BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED and BT_HCI_EVT_LE_PER_ADV_REPORT. --- emulator/btdev.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 9189e8082..34469d986 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -47,6 +47,7 @@ #define ACL_HANDLE 42 #define ISO_HANDLE 257 #define SCO_HANDLE 257 +#define SYC_HANDLE 1 struct hook { btdev_hook_func handler; @@ -195,6 +196,7 @@ struct btdev { uint16_t le_periodic_max_interval; uint8_t le_periodic_data_len; uint8_t le_periodic_data[31]; + uint16_t le_periodic_sync_handle; uint8_t le_ltk[16]; struct { struct bt_hci_cmd_le_set_cig_params params; @@ -5294,8 +5296,99 @@ static int cmd_ext_create_conn_complete(struct btdev *dev, const void *data, static int cmd_per_adv_create_sync(struct btdev *dev, const void *data, uint8_t len) { - /* TODO */ - return -ENOTSUP; + uint8_t status = BT_HCI_ERR_SUCCESS; + + if (dev->le_periodic_sync_handle) + status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; + else + dev->le_periodic_sync_handle = SYC_HANDLE; + + cmd_status(dev, status, BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC); + + return 0; +} + +static void send_per_adv(struct btdev *dev, const struct btdev *remote, + uint8_t offset) +{ + struct __packed { + struct bt_hci_le_per_adv_report ev; + uint8_t data[31]; + } pdu; + + memset(&pdu.ev, 0, sizeof(pdu.ev)); + pdu.ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + pdu.ev.tx_power = 127; + pdu.ev.rssi = 127; + pdu.ev.cte_type = 0x0ff; + + if ((size_t) remote->le_periodic_data_len - offset > sizeof(pdu.data)) { + pdu.ev.data_status = 0x01; + pdu.ev.data_len = sizeof(pdu.data); + } else { + pdu.ev.data_status = 0x00; + pdu.ev.data_len = remote->le_periodic_data_len - offset; + } + + memcpy(pdu.data, remote->le_periodic_data + offset, pdu.ev.data_len); + + le_meta_event(dev, BT_HCI_EVT_LE_PER_ADV_REPORT, &pdu, + sizeof(pdu.ev) + pdu.ev.data_len); + + if (pdu.ev.data_status == 0x01) { + offset += pdu.ev.data_len; + send_per_adv(dev, remote, offset); + } +} + +static void le_per_adv_sync_estabilished(struct btdev *dev, + const struct bt_hci_cmd_le_periodic_adv_create_sync *cmd, + struct btdev *remote, uint8_t status) +{ + struct bt_hci_evt_le_per_sync_established ev; + + memset(&ev, 0, sizeof(ev)); + ev.status = status; + + if (status) { + le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, + sizeof(ev)); + return; + } + + ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + ev.addr_type = cmd->addr_type; + memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); + ev.phy = 0x01; + ev.interval = remote->le_periodic_min_interval; + ev.clock_accuracy = 0x07; + + le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); + send_per_adv(dev, remote, 0); +} + +static int cmd_per_adv_create_sync_complete(struct btdev *dev, const void *data, + uint8_t len) +{ + const struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = data; + struct btdev *remote; + + /* This command may be issued whether or not scanning is enabled and + * scanning may be enabled and disabled (see the LE Set Extended Scan + * Enable command) while this command is pending. However, + * synchronization can only occur when scanning is enabled. While + * scanning is disabled, no attempt to synchronize will take place. + */ + if (!dev->scan_enable) + return 0; + + remote = find_btdev_by_bdaddr_type(cmd->addr, cmd->addr_type); + if (!remote || !remote->le_periodic_adv_enable) + return 0; + + le_per_adv_sync_estabilished(dev, cmd, remote, BT_HCI_ERR_SUCCESS); + + return 0; } static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, @@ -5420,7 +5513,7 @@ done: CMD(BT_HCI_CMD_LE_EXT_CREATE_CONN, cmd_ext_create_conn, \ cmd_ext_create_conn_complete), \ CMD(BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC, cmd_per_adv_create_sync, \ - NULL), \ + cmd_per_adv_create_sync_complete), \ CMD(BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL, \ cmd_per_adv_create_sync_cancel, NULL), \ CMD(BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC, cmd_per_adv_term_sync, \ From patchwork Thu Feb 24 00:30:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7796BC433F5 for ; Thu, 24 Feb 2022 00:30:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbiBXAbG (ORCPT ); Wed, 23 Feb 2022 19:31:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiBXAbC (ORCPT ); Wed, 23 Feb 2022 19:31:02 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD4D6D972 for ; Wed, 23 Feb 2022 16:30:33 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id m11so277574pls.5 for ; Wed, 23 Feb 2022 16:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gkECUbgP6SwJ+vdtBxsDCIGBwm8Bgzi3GVBj8I4iC20=; b=lADeQW0+uazQZiVv13RVFaGooeH/NSUCHK/vGmzPBnYzFmPb1DGoxu0Am1R7rbfpwE Yvz81y1ujZKF5kwjmBNQkcIQUl5epwtxW20SrkaOTvh23F0/Ux4aZphdSHKvWbxQ1XT/ E1iV80+v1s7qooAXhonWYkKGJZpTWD+j400QiXRHNLzT6yFFyTxynSdU6O5W6Mqu3K/L R7SaA6E68lrCMhG3XV69/ukpf2aZ1wwSUMngyKBGKNQzwdMl+NB+WNKVPDo9+FrsfbXR ElAdqy07SrjjDp0F8gb6GTuUmxlxifmb71sdrCVuINZt2m+7ezYc0sPhUDZOHz2g8Z56 0Zjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gkECUbgP6SwJ+vdtBxsDCIGBwm8Bgzi3GVBj8I4iC20=; b=a1vQKod+DeiKjOCRew/2LZLI7vBBamQVvRfuT+sMmXnr9dGMbaepAmuX0fvpGzUWT8 Fd/ZUKvzGhM+cnPH03JP+63vu/E9se1WjUXAMhn0vCm6udivfWCaXdOey1Yj/5I+U2T4 B+U5gEXVCwpUV5ljtlmUs1mfzXGFSLg5JIRD0PzzAtOZeX2nwYdo79CwSLLw4jCN5mVp VKKtKs+ma4Kz7tf39yLufcjBz8bWuqIuPEkg2WRIdbs3+H+c0VPeXsTqHzPmQnFR6IEe CVbhQzNtOJPZ8sWw5OUYo2JBifwZ9YRI3ViqxMTjZhfdgFb7ZRr/KyxZo960C+BS3sTz 1qQQ== X-Gm-Message-State: AOAM533j4dZ9MFIy6Gyvgs0g207jskEIwTyNiKQDfkqPugP0bGRCN9TV DeBAxojTL6BbsYBUGB7Ft/U4rdvdojI= X-Google-Smtp-Source: ABdhPJxNo48beDmRZ1OX9LZ4AxCTkEXOqKLZUJn8s6vmjbGVBz40XL6XmICJvsSk81LZW6kBYFmlAg== X-Received: by 2002:a17:902:ccd2:b0:14f:8182:96c4 with SMTP id z18-20020a170902ccd200b0014f818296c4mr326120ple.67.1645662633173; Wed, 23 Feb 2022 16:30:33 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:32 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 03/11] btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL Date: Wed, 23 Feb 2022 16:30:21 -0800 Message-Id: <20220224003029.706163-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL generating BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if necessary. --- emulator/btdev.c | 30 +++++++++++++++++++++++++++--- monitor/bt.h | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 34469d986..09101a5df 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -48,6 +48,7 @@ #define ISO_HANDLE 257 #define SCO_HANDLE 257 #define SYC_HANDLE 1 +#define INV_HANDLE 0xffff struct hook { btdev_hook_func handler; @@ -5301,7 +5302,7 @@ static int cmd_per_adv_create_sync(struct btdev *dev, const void *data, if (dev->le_periodic_sync_handle) status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; else - dev->le_periodic_sync_handle = SYC_HANDLE; + dev->le_periodic_sync_handle = INV_HANDLE; cmd_status(dev, status, BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC); @@ -5351,11 +5352,14 @@ static void le_per_adv_sync_estabilished(struct btdev *dev, ev.status = status; if (status) { + dev->le_periodic_sync_handle = 0x0000; le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); return; } + dev->le_periodic_sync_handle = SYC_HANDLE; + ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); ev.addr_type = cmd->addr_type; memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); @@ -5394,8 +5398,28 @@ static int cmd_per_adv_create_sync_complete(struct btdev *dev, const void *data, static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, uint8_t len) { - /* TODO */ - return -ENOTSUP; + uint8_t status = BT_HCI_ERR_SUCCESS; + + /* If the Host issues this command while no + * HCI_LE_Periodic_Advertising_Create_Sync command is pending, the + * Controller shall return the error code Command Disallowed (0x0C). + */ + if (dev->le_periodic_sync_handle != INV_HANDLE) + status = BT_HCI_ERR_COMMAND_DISALLOWED; + + cmd_complete(dev, BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL, + &status, sizeof(status)); + + /* After the HCI_Command_Complete is sent and if the cancellation was + * successful, the Controller sends an + * HCI_LE_Periodic_Advertising_Sync_Established event to the Host with + * the error code Operation Cancelled by Host (0x44). + */ + if (!status) + le_per_adv_sync_estabilished(dev, NULL, NULL, + BT_HCI_ERR_CANCELLED); + + return 0; } static int cmd_per_adv_term_sync(struct btdev *dev, const void *data, diff --git a/monitor/bt.h b/monitor/bt.h index 51b1833dc..b6b6c49e1 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -3660,6 +3660,7 @@ struct bt_hci_evt_le_req_peer_sca_complete { #define BT_HCI_ERR_ADV_TIMEOUT 0x3c #define BT_HCI_ERR_CONN_FAILED_TO_ESTABLISH 0x3e #define BT_HCI_ERR_UNKNOWN_ADVERTISING_ID 0x42 +#define BT_HCI_ERR_CANCELLED 0x44 struct bt_l2cap_hdr { uint16_t len; From patchwork Thu Feb 24 00:30:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3318C4332F for ; Thu, 24 Feb 2022 00:30:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbiBXAbH (ORCPT ); Wed, 23 Feb 2022 19:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiBXAbE (ORCPT ); Wed, 23 Feb 2022 19:31:04 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 022456E28F for ; Wed, 23 Feb 2022 16:30:35 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id c1so289535pgk.11 for ; Wed, 23 Feb 2022 16:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9Y5pgaVkXyazSAz0gklrbyoOTE7TwpdgHa0U0KeOhL0=; b=DIfpqa1brQh/XV0qXuGqXcKcqxDYhehyt91wLo4+DB2G7I3nm4hPfmNs/N1G3kOtVj TLyVZmaTQeQAdU1rhSEOhSTPR6TisxCQYLUtFhVN7ahNVlOI+nOarTqrKtJOS+da690T UEQt+gaLP28baM/FOcqZd1Sa8q9Z+s1xp9DyvL3dM5lVX9dEcMEcwJdGOoa20ftjtqry nlqm3QJtgCHO7757+ZY75t2nWB8n+krIMLn5eThpz8y/2wMU5qlQHryThzk8BbNaxK8q 2xdYh0vf/bbpkfBVZo+ZK1wfDgIMj4cTYvgjxlm86AF7p6d+Gi3LoSn56mCfaMHhsB2U Ai8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Y5pgaVkXyazSAz0gklrbyoOTE7TwpdgHa0U0KeOhL0=; b=gaYTxK+CtLND7A5M2HV81D3NNd/lcLqvwUMvyNNoh9kKNojs86qjdtm7ZJvUlb+oWc rm5tPMCb88t2DWnFz6fhHWjyE/nSl2JUPcrO/kx4CMt95OUzObTjAdaEuSinEY8mzis3 tz3yeVvoKEvl6hQ3drKl5rIo1lA095AIWZxTldkUPIMIG4GMKLm1CVwr8qifl5a5KmO7 ogjBX5fSw8Nt8p3pMK58XouV1RVWryH5UcJhLWt4z1XO+1u2tou1GBkjXUrbTaYaZK3O 9S6GC1EriXsTW8bgm7ZGPf2jsqrrATxn5aeGdHZ3oRpdd5GlmRBXb0IlnLwNX498JDE7 wFMg== X-Gm-Message-State: AOAM532OhsezJiWL6wlQeGgrUmSReaDmPSDsw3C+paRNzTtQHPSe0djT /ukuryFWkV25L0Bk/vJPFBSVWoEffqg= X-Google-Smtp-Source: ABdhPJxFxgqxsqsIC3JqZvdPSsDLOH1aFHhgTtlwZoG+KUA2uoZAXaTG7aoFmjtZ/RKsWylJKNAQAg== X-Received: by 2002:a62:1757:0:b0:4f3:9654:2815 with SMTP id 84-20020a621757000000b004f396542815mr45064pfx.52.1645662634211; Wed, 23 Feb 2022 16:30:34 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:33 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 04/11] btdev: Implement BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC Date: Wed, 23 Feb 2022 16:30:22 -0800 Message-Id: <20220224003029.706163-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds implementation of BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC. --- emulator/btdev.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 09101a5df..15689137c 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -5425,8 +5425,21 @@ static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, static int cmd_per_adv_term_sync(struct btdev *dev, const void *data, uint8_t len) { - /* TODO */ - return -ENOTSUP; + uint8_t status = BT_HCI_ERR_SUCCESS; + + /* If the periodic advertising train corresponding to the Sync_Handle + * parameter does not exist, then the Controller shall return the error + * code Unknown Advertising Identifier (0x42). + */ + if (dev->le_periodic_sync_handle != SYC_HANDLE) + status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID; + else + dev->le_periodic_sync_handle = 0x0000; + + cmd_complete(dev, BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC, + &status, sizeof(status)); + + return 0; } static int cmd_per_adv_add(struct btdev *dev, const void *data, uint8_t len) From patchwork Thu Feb 24 00:30:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF8CC433FE for ; Thu, 24 Feb 2022 00:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbiBXAbH (ORCPT ); Wed, 23 Feb 2022 19:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbiBXAbE (ORCPT ); Wed, 23 Feb 2022 19:31:04 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17986E284 for ; Wed, 23 Feb 2022 16:30:35 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id j10-20020a17090a94ca00b001bc2a9596f6so549046pjw.5 for ; Wed, 23 Feb 2022 16:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CB84GU+65qC35bo/M0ozl8Z6qSqDAdXZpXKDOuBUTfg=; b=Htw1oY/CJE7Xn7jDLa/yvuA/LDVVU+TLOvbOOsRmgm3yZvbNIxrGXAruT6muEhOWT8 PM97EzLkFcm6igjeSPHDKtZ4hgOMafo0YI/1rJ1UINTzII9Gvw7hp8+h2G3WD1Dpy3oc ewjqJPvYrX62U3xOL7MwZW78+P3ufcGbGbNf0IqMjmJLSYhGyzZ4Dp2Or3J1VD6KD4Ca Lqrb+obpfpU3elOAZmmkJnoIeJyBe//SkNNhg9BUa3oH7vECQUdry2LXEIN3vXiP39uO 0wdAfESV47i6UKWguLcrRw2x7aBTKAyYsoYLXetFd+dl7/+4n+E5rLzwOsOlF4zA1Emq P9Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CB84GU+65qC35bo/M0ozl8Z6qSqDAdXZpXKDOuBUTfg=; b=Pzj9P+P2QeqTg+70+PGjN2kPjlc4wMwDbUMFjTPQ17SZ04PxWWzOfQgFcYIw9EvwIq 9ZGSCKP2EhMSBz4NlP47NI3xehEJKnLEMvZwTPvq5OMT0A/ea8wPs78pjT7CtvzEZyqu x+RlNDnWfKhanXJHXLHwsBmzbqtRmc2hGtaMmKcmZKDr3XAn8LsvuLYOfj0kwgINtpBg Ed5VRw8glGOV/Fe0ZtBTGKjH8SLDEds0jq6AC6Po4d06Yo56dK7g2mv1lKwAFZnijoUH qdvRaKrGilCypp/l5QSheSIWGmWpvbd8yWrcBRwcvZsK6JtlfC3U9eh5GOGOpdpwljRD JFlQ== X-Gm-Message-State: AOAM5334zEEbl4niwy/ntJ1G4o5199w0WDZ76lXEByPhhLw5a0RNlM5m Y5Rzm7TLTr/Opk0q7N7oIAdkuoxDLns= X-Google-Smtp-Source: ABdhPJwnzInCYKP2gmpVhABYSgZnKPSMLtG/+QQzeAz7XbKl+4NbvEWOvTe4uJsZDysL7O8i22x/+w== X-Received: by 2002:a17:902:b485:b0:14d:77eb:1675 with SMTP id y5-20020a170902b48500b0014d77eb1675mr165117plr.147.1645662635188; Wed, 23 Feb 2022 16:30:35 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:34 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 05/11] btdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED when scan is initiated Date: Wed, 23 Feb 2022 16:30:23 -0800 Message-Id: <20220224003029.706163-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This sends BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if scan is initiated while BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC is pending. --- emulator/btdev.c | 152 +++++++++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 66 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 15689137c..59014b535 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -197,6 +197,7 @@ struct btdev { uint16_t le_periodic_max_interval; uint8_t le_periodic_data_len; uint8_t le_periodic_data[31]; + struct bt_hci_cmd_le_periodic_adv_create_sync pa_sync_cmd; uint16_t le_periodic_sync_handle; uint8_t le_ltk[16]; struct { @@ -5160,6 +5161,85 @@ static void scan_ext_adv(struct btdev *dev, struct btdev *remote) } } +static void send_per_adv(struct btdev *dev, const struct btdev *remote, + uint8_t offset) +{ + struct __packed { + struct bt_hci_le_per_adv_report ev; + uint8_t data[31]; + } pdu; + + memset(&pdu.ev, 0, sizeof(pdu.ev)); + pdu.ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + pdu.ev.tx_power = 127; + pdu.ev.rssi = 127; + pdu.ev.cte_type = 0x0ff; + + if ((size_t) remote->le_periodic_data_len - offset > sizeof(pdu.data)) { + pdu.ev.data_status = 0x01; + pdu.ev.data_len = sizeof(pdu.data); + } else { + pdu.ev.data_status = 0x00; + pdu.ev.data_len = remote->le_periodic_data_len - offset; + } + + memcpy(pdu.data, remote->le_periodic_data + offset, pdu.ev.data_len); + + le_meta_event(dev, BT_HCI_EVT_LE_PER_ADV_REPORT, &pdu, + sizeof(pdu.ev) + pdu.ev.data_len); + + if (pdu.ev.data_status == 0x01) { + offset += pdu.ev.data_len; + send_per_adv(dev, remote, offset); + } +} + +static void le_per_adv_sync_estabilished(struct btdev *dev, + struct btdev *remote, uint8_t status) +{ + struct bt_hci_evt_le_per_sync_established ev; + struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = &dev->pa_sync_cmd; + + memset(&ev, 0, sizeof(ev)); + ev.status = status; + + if (status) { + memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); + dev->le_periodic_sync_handle = 0x0000; + le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, + sizeof(ev)); + return; + } + + dev->le_periodic_sync_handle = SYC_HANDLE; + + ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + ev.addr_type = cmd->addr_type; + memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); + ev.phy = 0x01; + ev.interval = remote->le_periodic_min_interval; + ev.clock_accuracy = 0x07; + + memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); + + le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); + send_per_adv(dev, remote, 0); +} + +static void scan_per_adv(struct btdev *dev, struct btdev *remote) +{ + if (dev->le_periodic_sync_handle != INV_HANDLE || + !remote->le_periodic_adv_enable) + return; + + + if (remote != find_btdev_by_bdaddr_type(dev->pa_sync_cmd.addr, + dev->pa_sync_cmd.addr_type)) + return; + + le_per_adv_sync_estabilished(dev, remote, BT_HCI_ERR_SUCCESS); +} + static int cmd_set_ext_scan_enable_complete(struct btdev *dev, const void *data, uint8_t len) { @@ -5174,6 +5254,7 @@ static int cmd_set_ext_scan_enable_complete(struct btdev *dev, const void *data, continue; scan_ext_adv(dev, btdev_list[i]); + scan_per_adv(dev, btdev_list[i]); } return 0; @@ -5301,76 +5382,16 @@ static int cmd_per_adv_create_sync(struct btdev *dev, const void *data, if (dev->le_periodic_sync_handle) status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; - else + else { dev->le_periodic_sync_handle = INV_HANDLE; + memcpy(&dev->pa_sync_cmd, data, len); + } cmd_status(dev, status, BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC); return 0; } -static void send_per_adv(struct btdev *dev, const struct btdev *remote, - uint8_t offset) -{ - struct __packed { - struct bt_hci_le_per_adv_report ev; - uint8_t data[31]; - } pdu; - - memset(&pdu.ev, 0, sizeof(pdu.ev)); - pdu.ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); - pdu.ev.tx_power = 127; - pdu.ev.rssi = 127; - pdu.ev.cte_type = 0x0ff; - - if ((size_t) remote->le_periodic_data_len - offset > sizeof(pdu.data)) { - pdu.ev.data_status = 0x01; - pdu.ev.data_len = sizeof(pdu.data); - } else { - pdu.ev.data_status = 0x00; - pdu.ev.data_len = remote->le_periodic_data_len - offset; - } - - memcpy(pdu.data, remote->le_periodic_data + offset, pdu.ev.data_len); - - le_meta_event(dev, BT_HCI_EVT_LE_PER_ADV_REPORT, &pdu, - sizeof(pdu.ev) + pdu.ev.data_len); - - if (pdu.ev.data_status == 0x01) { - offset += pdu.ev.data_len; - send_per_adv(dev, remote, offset); - } -} - -static void le_per_adv_sync_estabilished(struct btdev *dev, - const struct bt_hci_cmd_le_periodic_adv_create_sync *cmd, - struct btdev *remote, uint8_t status) -{ - struct bt_hci_evt_le_per_sync_established ev; - - memset(&ev, 0, sizeof(ev)); - ev.status = status; - - if (status) { - dev->le_periodic_sync_handle = 0x0000; - le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, - sizeof(ev)); - return; - } - - dev->le_periodic_sync_handle = SYC_HANDLE; - - ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); - ev.addr_type = cmd->addr_type; - memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); - ev.phy = 0x01; - ev.interval = remote->le_periodic_min_interval; - ev.clock_accuracy = 0x07; - - le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); - send_per_adv(dev, remote, 0); -} - static int cmd_per_adv_create_sync_complete(struct btdev *dev, const void *data, uint8_t len) { @@ -5390,7 +5411,7 @@ static int cmd_per_adv_create_sync_complete(struct btdev *dev, const void *data, if (!remote || !remote->le_periodic_adv_enable) return 0; - le_per_adv_sync_estabilished(dev, cmd, remote, BT_HCI_ERR_SUCCESS); + le_per_adv_sync_estabilished(dev, remote, BT_HCI_ERR_SUCCESS); return 0; } @@ -5416,8 +5437,7 @@ static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, * the error code Operation Cancelled by Host (0x44). */ if (!status) - le_per_adv_sync_estabilished(dev, NULL, NULL, - BT_HCI_ERR_CANCELLED); + le_per_adv_sync_estabilished(dev, NULL, BT_HCI_ERR_CANCELLED); return 0; } From patchwork Thu Feb 24 00:30:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7D01C433EF for ; Thu, 24 Feb 2022 00:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbiBXAbI (ORCPT ); Wed, 23 Feb 2022 19:31:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiBXAbF (ORCPT ); Wed, 23 Feb 2022 19:31:05 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6F06E2A8 for ; Wed, 23 Feb 2022 16:30:36 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id i1so288866plr.2 for ; Wed, 23 Feb 2022 16:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9UiSChX/MlhykLBJGD3Js3tynaUAJ9b+hYqI4IfTwkA=; b=RXESZudrYFuUD4PHiOgvzTJgdQpp/uHNWhlLtwXW+mpkQbLTJmfcduAJ6yVkStjhri 1LMiJ+tXuFlkcXTUdmJeaEp4eHE2ogxaODfJXE8/B68OfNbngOdTJF9E39YbR8mdaqOe vEyUu3ZoH8Kpj2u3lspZmI3iXhDLN3spPf3dvg8wpTyB9XIla3xOsqL+Rc6mAjDr1Ynk hZksKwsi1Yp2zu3jUMg28d2kyOUBenZITGg9AxaPWa3e9zBiadG0VHSNXbrVK8k56Vyh bAaYN+9cSXrQFTdQ8wHElkshmkMSMEHg8yNplp//pPlkjdt0McNUsADnMjJ4wQHxPDGl aBrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9UiSChX/MlhykLBJGD3Js3tynaUAJ9b+hYqI4IfTwkA=; b=o4E9lmBiKxLBfD13Leca851CS7Qr9dCzadY9l4j6KvRoacjxKCDSXOrl2qroOdquKA mUOzGmD+Rjt8PUpp7SAA3fhG1JlxWuJcYrAlbVidcIiwISPY3AOpFNDZazQKmNeIkJfK 1LqzaH5OVFLYF6AP5J5PhRKyLK7rz48T/l4dqFSeLp3E4h6zlkTXil2KEPUuY2H6B5ON q0orItNWHhAAshP+QLZB/nu9tFCUI/IYTi9UMurP9B6h326ookEr9Cjw86DNbKWZzpix fsjUaxEnm0Rif9Lz01Os9jF2aJQOnR4qEihuVoTv4IUp5p/Fgg4d6Q6IRw/1lJ5+/4aA AV3Q== X-Gm-Message-State: AOAM5318EcQ2ZAKiDwYlAI6iYrEUCSHASh5RtSl1d/bb693TA3QsSfpV ZgQ5UOrX5L9DWLPCRIi61fJh9COI7gQ= X-Google-Smtp-Source: ABdhPJxn8CE0g5X5KZEPwM0iyNQdJKxlpStymxLDbkMB7nSno6wopXw48sIV/K/Jx5t9JZzyqCLlKw== X-Received: by 2002:a17:902:8b8c:b0:14e:d959:7bdb with SMTP id ay12-20020a1709028b8c00b0014ed9597bdbmr326054plb.41.1645662636156; Wed, 23 Feb 2022 16:30:36 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:35 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 06/11] btdev: Send BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if remote start pa Date: Wed, 23 Feb 2022 16:30:24 -0800 Message-Id: <20220224003029.706163-7-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This sends BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED if remote device start to periodic advertise when BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC is pending. --- emulator/btdev.c | 144 +++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 66 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 59014b535..e79b0dc67 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -5044,11 +5044,77 @@ static int cmd_set_per_adv_data(struct btdev *dev, const void *data, return 0; } +static void send_per_adv(struct btdev *dev, const struct btdev *remote, + uint8_t offset) +{ + struct __packed { + struct bt_hci_le_per_adv_report ev; + uint8_t data[31]; + } pdu; + + memset(&pdu.ev, 0, sizeof(pdu.ev)); + pdu.ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + pdu.ev.tx_power = 127; + pdu.ev.rssi = 127; + pdu.ev.cte_type = 0x0ff; + + if ((size_t) remote->le_periodic_data_len - offset > sizeof(pdu.data)) { + pdu.ev.data_status = 0x01; + pdu.ev.data_len = sizeof(pdu.data); + } else { + pdu.ev.data_status = 0x00; + pdu.ev.data_len = remote->le_periodic_data_len - offset; + } + + memcpy(pdu.data, remote->le_periodic_data + offset, pdu.ev.data_len); + + le_meta_event(dev, BT_HCI_EVT_LE_PER_ADV_REPORT, &pdu, + sizeof(pdu.ev) + pdu.ev.data_len); + + if (pdu.ev.data_status == 0x01) { + offset += pdu.ev.data_len; + send_per_adv(dev, remote, offset); + } +} + +static void le_per_adv_sync_estabilished(struct btdev *dev, + struct btdev *remote, uint8_t status) +{ + struct bt_hci_evt_le_per_sync_established ev; + struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = &dev->pa_sync_cmd; + + memset(&ev, 0, sizeof(ev)); + ev.status = status; + + if (status) { + memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); + dev->le_periodic_sync_handle = 0x0000; + le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, + sizeof(ev)); + return; + } + + dev->le_periodic_sync_handle = SYC_HANDLE; + + ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + ev.addr_type = cmd->addr_type; + memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); + ev.phy = 0x01; + ev.interval = remote->le_periodic_min_interval; + ev.clock_accuracy = 0x07; + + memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); + + le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); + send_per_adv(dev, remote, 0); +} + static int cmd_set_per_adv_enable(struct btdev *dev, const void *data, uint8_t len) { const struct bt_hci_cmd_le_set_periodic_adv_enable *cmd = data; uint8_t status; + int i; if (dev->le_periodic_adv_enable == cmd->enable) { status = BT_HCI_ERR_COMMAND_DISALLOWED; @@ -5060,6 +5126,18 @@ static int cmd_set_per_adv_enable(struct btdev *dev, const void *data, cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_ENABLE, &status, sizeof(status)); + for (i = 0; i < MAX_BTDEV_ENTRIES; i++) { + struct btdev *remote = btdev_list[i]; + + if (!remote || remote == dev) + continue; + + if (remote->le_scan_enable && + remote->le_periodic_sync_handle == INV_HANDLE) + le_per_adv_sync_estabilished(remote, dev, + BT_HCI_ERR_SUCCESS); + } + return 0; } @@ -5161,78 +5239,12 @@ static void scan_ext_adv(struct btdev *dev, struct btdev *remote) } } -static void send_per_adv(struct btdev *dev, const struct btdev *remote, - uint8_t offset) -{ - struct __packed { - struct bt_hci_le_per_adv_report ev; - uint8_t data[31]; - } pdu; - - memset(&pdu.ev, 0, sizeof(pdu.ev)); - pdu.ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); - pdu.ev.tx_power = 127; - pdu.ev.rssi = 127; - pdu.ev.cte_type = 0x0ff; - - if ((size_t) remote->le_periodic_data_len - offset > sizeof(pdu.data)) { - pdu.ev.data_status = 0x01; - pdu.ev.data_len = sizeof(pdu.data); - } else { - pdu.ev.data_status = 0x00; - pdu.ev.data_len = remote->le_periodic_data_len - offset; - } - - memcpy(pdu.data, remote->le_periodic_data + offset, pdu.ev.data_len); - - le_meta_event(dev, BT_HCI_EVT_LE_PER_ADV_REPORT, &pdu, - sizeof(pdu.ev) + pdu.ev.data_len); - - if (pdu.ev.data_status == 0x01) { - offset += pdu.ev.data_len; - send_per_adv(dev, remote, offset); - } -} - -static void le_per_adv_sync_estabilished(struct btdev *dev, - struct btdev *remote, uint8_t status) -{ - struct bt_hci_evt_le_per_sync_established ev; - struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = &dev->pa_sync_cmd; - - memset(&ev, 0, sizeof(ev)); - ev.status = status; - - if (status) { - memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); - dev->le_periodic_sync_handle = 0x0000; - le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, - sizeof(ev)); - return; - } - - dev->le_periodic_sync_handle = SYC_HANDLE; - - ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); - ev.addr_type = cmd->addr_type; - memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); - ev.phy = 0x01; - ev.interval = remote->le_periodic_min_interval; - ev.clock_accuracy = 0x07; - - memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); - - le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); - send_per_adv(dev, remote, 0); -} - static void scan_per_adv(struct btdev *dev, struct btdev *remote) { if (dev->le_periodic_sync_handle != INV_HANDLE || !remote->le_periodic_adv_enable) return; - if (remote != find_btdev_by_bdaddr_type(dev->pa_sync_cmd.addr, dev->pa_sync_cmd.addr_type)) return; From patchwork Thu Feb 24 00:30:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A8E9C433F5 for ; Thu, 24 Feb 2022 00:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231210AbiBXAbM (ORCPT ); Wed, 23 Feb 2022 19:31:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbiBXAbJ (ORCPT ); Wed, 23 Feb 2022 19:31:09 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B7BB6E2BB for ; Wed, 23 Feb 2022 16:30:38 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id bx5so516248pjb.3 for ; Wed, 23 Feb 2022 16:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=00tpi3ubMc39x6VvlyEVIwLH2tXd1gkjhv4j61ryDfc=; b=qrQZ6VFsshBBLKd4e7+4TzgWINCd74clH4AjLFEXs3WOTCG+imdAfx/HiaxFJcuLMc GRTmDQh1RHZGwuRnegivlszm42aAt7OhFo/X+C4u5NSkS9QcPGogDLZcMDT6JS15aPOu mOQoAou9PniLTGIYH5Grv75e7Dr58VaWOD5KJOK9v5tjb05i95aPYkpO50Y6U8Re7SRH SFzVqmy+mS2TFYRKTRJLMN+3xz8KtbIHyH68S9Z1u5JPZ/JHWY2ZXRVi0kPJ2p/yWBtH Cuq+OvXyP0r8efDPcW/1gL5EDrR9Q3vA+LnI10Au307F0ThuWXhTWPcwtuZMfBxmoDhX eAsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=00tpi3ubMc39x6VvlyEVIwLH2tXd1gkjhv4j61ryDfc=; b=a2ImGxALO1KXYS3vzNYvhS7ckTzzp53uwci17IU0TqigNxCeToAxf98LRslk/hZsJk hcODKTZ/toWy+Mnr+2GAH3fj8etuX5oHl/bH+b+v3DC1JmenwiGMbBBCLYHSD/PCJNRb lDXzaTWkbU3Fr+Eubwqitbd3/6NdHpbuxzSRm2ehNx8X1nqqXseLpIKLkhrP3FFUoEjP iPJeOGaNjX1746Uxaf2q7q77PIa5lQhakQ2GFrEMXMxv9hZfTDym6IyLhbf/YemWVd2e A3hKWsNp6d54RC7EVOny2PFNlJOJQvFiNIZaJqo+XM/q/hJg31VzPX739pG3cIpR9kMK s+Kg== X-Gm-Message-State: AOAM532CAwv9UbBXQG7RHCJB/QIPXNPgFFmkqnt6EselnjoQT2R2lLXl hq01Q4AkH/ZT5RK2OGybhlhA0nIPcXI= X-Google-Smtp-Source: ABdhPJzcUP1qmMTXyHcAhvSLCZkpLULoL/vD0/BxHQcUmTKYvRJBg1w0WEhWli/oRBlfW8UvL5oFmw== X-Received: by 2002:a17:902:da84:b0:14f:deb1:8f6d with SMTP id j4-20020a170902da8400b0014fdeb18f6dmr16118plx.103.1645662637022; Wed, 23 Feb 2022 16:30:37 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:36 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 07/11] monitor: Rename Periodic Advertising terms to PA/pa Date: Wed, 23 Feb 2022 16:30:25 -0800 Message-Id: <20220224003029.706163-8-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This renames the use of Periodic Advertising in the API to just PA. --- emulator/btdev.c | 168 ++++++++++++++++++++++------------------------- monitor/bt.h | 82 +++++++++++------------ monitor/packet.c | 104 ++++++++++++++--------------- 3 files changed, 173 insertions(+), 181 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index e79b0dc67..10fa046bc 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -191,14 +191,14 @@ struct btdev { uint8_t le_scan_filter_policy; uint8_t le_filter_dup; uint8_t le_adv_enable; - uint8_t le_periodic_adv_enable; - uint16_t le_periodic_adv_properties; - uint16_t le_periodic_min_interval; - uint16_t le_periodic_max_interval; - uint8_t le_periodic_data_len; - uint8_t le_periodic_data[31]; - struct bt_hci_cmd_le_periodic_adv_create_sync pa_sync_cmd; - uint16_t le_periodic_sync_handle; + uint8_t le_pa_enable; + uint16_t le_pa_properties; + uint16_t le_pa_min_interval; + uint16_t le_pa_max_interval; + uint8_t le_pa_data_len; + uint8_t le_pa_data[31]; + struct bt_hci_cmd_le_pa_create_sync pa_sync_cmd; + uint16_t le_pa_sync_handle; uint8_t le_ltk[16]; struct { struct bt_hci_cmd_le_set_cig_params params; @@ -5010,120 +5010,119 @@ static int cmd_clear_adv_sets(struct btdev *dev, const void *data, return 0; } -static int cmd_set_per_adv_params(struct btdev *dev, const void *data, +static int cmd_set_pa_params(struct btdev *dev, const void *data, uint8_t len) { - const struct bt_hci_cmd_le_set_periodic_adv_params *cmd = data; + const struct bt_hci_cmd_le_set_pa_params *cmd = data; uint8_t status; - if (dev->le_periodic_adv_enable) { + if (dev->le_pa_enable) { status = BT_HCI_ERR_COMMAND_DISALLOWED; } else { status = BT_HCI_ERR_SUCCESS; - dev->le_periodic_adv_properties = le16_to_cpu(cmd->properties); - dev->le_periodic_min_interval = cmd->min_interval; - dev->le_periodic_max_interval = cmd->max_interval; + dev->le_pa_properties = le16_to_cpu(cmd->properties); + dev->le_pa_min_interval = cmd->min_interval; + dev->le_pa_max_interval = cmd->max_interval; } - cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_PARAMS, &status, + cmd_complete(dev, BT_HCI_CMD_LE_SET_PA_PARAMS, &status, sizeof(status)); return 0; } -static int cmd_set_per_adv_data(struct btdev *dev, const void *data, +static int cmd_set_pa_data(struct btdev *dev, const void *data, uint8_t len) { - const struct bt_hci_cmd_le_set_periodic_adv_data *cmd = data; + const struct bt_hci_cmd_le_set_pa_data *cmd = data; uint8_t status = BT_HCI_ERR_SUCCESS; - dev->le_periodic_data_len = cmd->data_len; - memcpy(dev->le_periodic_data, cmd->data, 31); - cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_DATA, &status, + dev->le_pa_data_len = cmd->data_len; + memcpy(dev->le_pa_data, cmd->data, 31); + cmd_complete(dev, BT_HCI_CMD_LE_SET_PA_DATA, &status, sizeof(status)); return 0; } -static void send_per_adv(struct btdev *dev, const struct btdev *remote, +static void send_pa(struct btdev *dev, const struct btdev *remote, uint8_t offset) { struct __packed { - struct bt_hci_le_per_adv_report ev; + struct bt_hci_le_pa_report ev; uint8_t data[31]; } pdu; memset(&pdu.ev, 0, sizeof(pdu.ev)); - pdu.ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + pdu.ev.handle = cpu_to_le16(dev->le_pa_sync_handle); pdu.ev.tx_power = 127; pdu.ev.rssi = 127; pdu.ev.cte_type = 0x0ff; - if ((size_t) remote->le_periodic_data_len - offset > sizeof(pdu.data)) { + if ((size_t) remote->le_pa_data_len - offset > sizeof(pdu.data)) { pdu.ev.data_status = 0x01; pdu.ev.data_len = sizeof(pdu.data); } else { pdu.ev.data_status = 0x00; - pdu.ev.data_len = remote->le_periodic_data_len - offset; + pdu.ev.data_len = remote->le_pa_data_len - offset; } - memcpy(pdu.data, remote->le_periodic_data + offset, pdu.ev.data_len); + memcpy(pdu.data, remote->le_pa_data + offset, pdu.ev.data_len); - le_meta_event(dev, BT_HCI_EVT_LE_PER_ADV_REPORT, &pdu, + le_meta_event(dev, BT_HCI_EVT_LE_PA_REPORT, &pdu, sizeof(pdu.ev) + pdu.ev.data_len); if (pdu.ev.data_status == 0x01) { offset += pdu.ev.data_len; - send_per_adv(dev, remote, offset); + send_pa(dev, remote, offset); } } -static void le_per_adv_sync_estabilished(struct btdev *dev, - struct btdev *remote, uint8_t status) +static void le_pa_sync_estabilished(struct btdev *dev, struct btdev *remote, + uint8_t status) { struct bt_hci_evt_le_per_sync_established ev; - struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = &dev->pa_sync_cmd; + struct bt_hci_cmd_le_pa_create_sync *cmd = &dev->pa_sync_cmd; memset(&ev, 0, sizeof(ev)); ev.status = status; if (status) { memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); - dev->le_periodic_sync_handle = 0x0000; - le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, + dev->le_pa_sync_handle = 0x0000; + le_meta_event(dev, BT_HCI_EVT_LE_PA_SYNC_ESTABLISHED, &ev, sizeof(ev)); return; } - dev->le_periodic_sync_handle = SYC_HANDLE; + dev->le_pa_sync_handle = SYC_HANDLE; - ev.handle = cpu_to_le16(dev->le_periodic_sync_handle); + ev.handle = cpu_to_le16(dev->le_pa_sync_handle); ev.addr_type = cmd->addr_type; memcpy(ev.addr, cmd->addr, sizeof(ev.addr)); ev.phy = 0x01; - ev.interval = remote->le_periodic_min_interval; + ev.interval = remote->le_pa_min_interval; ev.clock_accuracy = 0x07; memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); - le_meta_event(dev, BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED, &ev, sizeof(ev)); - send_per_adv(dev, remote, 0); + le_meta_event(dev, BT_HCI_EVT_LE_PA_SYNC_ESTABLISHED, &ev, sizeof(ev)); + send_pa(dev, remote, 0); } -static int cmd_set_per_adv_enable(struct btdev *dev, const void *data, - uint8_t len) +static int cmd_set_pa_enable(struct btdev *dev, const void *data, uint8_t len) { - const struct bt_hci_cmd_le_set_periodic_adv_enable *cmd = data; + const struct bt_hci_cmd_le_set_pa_enable *cmd = data; uint8_t status; int i; - if (dev->le_periodic_adv_enable == cmd->enable) { + if (dev->le_pa_enable == cmd->enable) { status = BT_HCI_ERR_COMMAND_DISALLOWED; } else { - dev->le_periodic_adv_enable = cmd->enable; + dev->le_pa_enable = cmd->enable; status = BT_HCI_ERR_SUCCESS; } - cmd_complete(dev, BT_HCI_CMD_LE_SET_PERIODIC_ADV_ENABLE, &status, + cmd_complete(dev, BT_HCI_CMD_LE_SET_PA_ENABLE, &status, sizeof(status)); for (i = 0; i < MAX_BTDEV_ENTRIES; i++) { @@ -5133,8 +5132,8 @@ static int cmd_set_per_adv_enable(struct btdev *dev, const void *data, continue; if (remote->le_scan_enable && - remote->le_periodic_sync_handle == INV_HANDLE) - le_per_adv_sync_estabilished(remote, dev, + remote->le_pa_sync_handle == INV_HANDLE) + le_pa_sync_estabilished(remote, dev, BT_HCI_ERR_SUCCESS); } @@ -5239,17 +5238,16 @@ static void scan_ext_adv(struct btdev *dev, struct btdev *remote) } } -static void scan_per_adv(struct btdev *dev, struct btdev *remote) +static void scan_pa(struct btdev *dev, struct btdev *remote) { - if (dev->le_periodic_sync_handle != INV_HANDLE || - !remote->le_periodic_adv_enable) + if (dev->le_pa_sync_handle != INV_HANDLE || !remote->le_pa_enable) return; if (remote != find_btdev_by_bdaddr_type(dev->pa_sync_cmd.addr, dev->pa_sync_cmd.addr_type)) return; - le_per_adv_sync_estabilished(dev, remote, BT_HCI_ERR_SUCCESS); + le_pa_sync_estabilished(dev, remote, BT_HCI_ERR_SUCCESS); } static int cmd_set_ext_scan_enable_complete(struct btdev *dev, const void *data, @@ -5266,7 +5264,7 @@ static int cmd_set_ext_scan_enable_complete(struct btdev *dev, const void *data, continue; scan_ext_adv(dev, btdev_list[i]); - scan_per_adv(dev, btdev_list[i]); + scan_pa(dev, btdev_list[i]); } return 0; @@ -5387,27 +5385,26 @@ static int cmd_ext_create_conn_complete(struct btdev *dev, const void *data, return 0; } -static int cmd_per_adv_create_sync(struct btdev *dev, const void *data, - uint8_t len) +static int cmd_pa_create_sync(struct btdev *dev, const void *data, uint8_t len) { uint8_t status = BT_HCI_ERR_SUCCESS; - if (dev->le_periodic_sync_handle) + if (dev->le_pa_sync_handle) status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; else { - dev->le_periodic_sync_handle = INV_HANDLE; + dev->le_pa_sync_handle = INV_HANDLE; memcpy(&dev->pa_sync_cmd, data, len); } - cmd_status(dev, status, BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC); + cmd_status(dev, status, BT_HCI_CMD_LE_PA_CREATE_SYNC); return 0; } -static int cmd_per_adv_create_sync_complete(struct btdev *dev, const void *data, +static int cmd_pa_create_sync_complete(struct btdev *dev, const void *data, uint8_t len) { - const struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = data; + const struct bt_hci_cmd_le_pa_create_sync *cmd = data; struct btdev *remote; /* This command may be issued whether or not scanning is enabled and @@ -5420,15 +5417,15 @@ static int cmd_per_adv_create_sync_complete(struct btdev *dev, const void *data, return 0; remote = find_btdev_by_bdaddr_type(cmd->addr, cmd->addr_type); - if (!remote || !remote->le_periodic_adv_enable) + if (!remote || !remote->le_pa_enable) return 0; - le_per_adv_sync_estabilished(dev, remote, BT_HCI_ERR_SUCCESS); + le_pa_sync_estabilished(dev, remote, BT_HCI_ERR_SUCCESS); return 0; } -static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, +static int cmd_pa_create_sync_cancel(struct btdev *dev, const void *data, uint8_t len) { uint8_t status = BT_HCI_ERR_SUCCESS; @@ -5437,10 +5434,10 @@ static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, * HCI_LE_Periodic_Advertising_Create_Sync command is pending, the * Controller shall return the error code Command Disallowed (0x0C). */ - if (dev->le_periodic_sync_handle != INV_HANDLE) + if (dev->le_pa_sync_handle != INV_HANDLE) status = BT_HCI_ERR_COMMAND_DISALLOWED; - cmd_complete(dev, BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL, + cmd_complete(dev, BT_HCI_CMD_LE_PA_CREATE_SYNC_CANCEL, &status, sizeof(status)); /* After the HCI_Command_Complete is sent and if the cancellation was @@ -5449,13 +5446,12 @@ static int cmd_per_adv_create_sync_cancel(struct btdev *dev, const void *data, * the error code Operation Cancelled by Host (0x44). */ if (!status) - le_per_adv_sync_estabilished(dev, NULL, BT_HCI_ERR_CANCELLED); + le_pa_sync_estabilished(dev, NULL, BT_HCI_ERR_CANCELLED); return 0; } -static int cmd_per_adv_term_sync(struct btdev *dev, const void *data, - uint8_t len) +static int cmd_pa_term_sync(struct btdev *dev, const void *data, uint8_t len) { uint8_t status = BT_HCI_ERR_SUCCESS; @@ -5463,36 +5459,36 @@ static int cmd_per_adv_term_sync(struct btdev *dev, const void *data, * parameter does not exist, then the Controller shall return the error * code Unknown Advertising Identifier (0x42). */ - if (dev->le_periodic_sync_handle != SYC_HANDLE) + if (dev->le_pa_sync_handle != SYC_HANDLE) status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID; else - dev->le_periodic_sync_handle = 0x0000; + dev->le_pa_sync_handle = 0x0000; - cmd_complete(dev, BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC, + cmd_complete(dev, BT_HCI_CMD_LE_PA_TERM_SYNC, &status, sizeof(status)); return 0; } -static int cmd_per_adv_add(struct btdev *dev, const void *data, uint8_t len) +static int cmd_pa_add(struct btdev *dev, const void *data, uint8_t len) { /* TODO */ return -ENOTSUP; } -static int cmd_per_adv_remove(struct btdev *dev, const void *data, uint8_t len) +static int cmd_pa_remove(struct btdev *dev, const void *data, uint8_t len) { /* TODO */ return -ENOTSUP; } -static int cmd_per_adv_clear(struct btdev *dev, const void *data, uint8_t len) +static int cmd_pa_clear(struct btdev *dev, const void *data, uint8_t len) { /* TODO */ return -ENOTSUP; } -static int cmd_read_per_adv_list_size(struct btdev *dev, const void *data, +static int cmd_read_pa_list_size(struct btdev *dev, const void *data, uint8_t len) { /* TODO */ @@ -5571,28 +5567,24 @@ done: NULL), \ CMD(BT_HCI_CMD_LE_REMOVE_ADV_SET, cmd_remove_adv_set, NULL), \ CMD(BT_HCI_CMD_LE_CLEAR_ADV_SETS, cmd_clear_adv_sets, NULL), \ - CMD(BT_HCI_CMD_LE_SET_PERIODIC_ADV_PARAMS, cmd_set_per_adv_params, \ - NULL), \ - CMD(BT_HCI_CMD_LE_SET_PERIODIC_ADV_DATA, cmd_set_per_adv_data, NULL), \ - CMD(BT_HCI_CMD_LE_SET_PERIODIC_ADV_ENABLE, cmd_set_per_adv_enable, \ + CMD(BT_HCI_CMD_LE_SET_PA_PARAMS, cmd_set_pa_params, \ NULL), \ + CMD(BT_HCI_CMD_LE_SET_PA_DATA, cmd_set_pa_data, NULL), \ + CMD(BT_HCI_CMD_LE_SET_PA_ENABLE, cmd_set_pa_enable, NULL), \ CMD(BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS, cmd_set_ext_scan_params, NULL), \ CMD(BT_HCI_CMD_LE_SET_EXT_SCAN_ENABLE, cmd_set_ext_scan_enable, \ cmd_set_ext_scan_enable_complete), \ CMD(BT_HCI_CMD_LE_EXT_CREATE_CONN, cmd_ext_create_conn, \ cmd_ext_create_conn_complete), \ - CMD(BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC, cmd_per_adv_create_sync, \ - cmd_per_adv_create_sync_complete), \ - CMD(BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL, \ - cmd_per_adv_create_sync_cancel, NULL), \ - CMD(BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC, cmd_per_adv_term_sync, \ - NULL), \ - CMD(BT_HCI_CMD_LE_ADD_DEV_PERIODIC_ADV_LIST, cmd_per_adv_add, NULL), \ - CMD(BT_HCI_CMD_LE_REMOVE_DEV_PERIODIC_ADV_LIST, cmd_per_adv_remove, \ + CMD(BT_HCI_CMD_LE_PA_CREATE_SYNC, cmd_pa_create_sync, \ + cmd_pa_create_sync_complete), \ + CMD(BT_HCI_CMD_LE_PA_CREATE_SYNC_CANCEL, cmd_pa_create_sync_cancel, \ NULL), \ - CMD(BT_HCI_CMD_LE_CLEAR_PERIODIC_ADV_LIST, cmd_per_adv_clear, NULL), \ - CMD(BT_HCI_CMD_LE_READ_PERIODIC_ADV_LIST_SIZE, \ - cmd_read_per_adv_list_size, NULL), \ + CMD(BT_HCI_CMD_LE_PA_TERM_SYNC, cmd_pa_term_sync, NULL), \ + CMD(BT_HCI_CMD_LE_ADD_DEV_PA_LIST, cmd_pa_add, NULL), \ + CMD(BT_HCI_CMD_LE_REMOVE_DEV_PA_LIST, cmd_pa_remove, NULL), \ + CMD(BT_HCI_CMD_LE_CLEAR_PA_LIST, cmd_pa_clear, NULL), \ + CMD(BT_HCI_CMD_LE_READ_PA_LIST_SIZE, cmd_read_pa_list_size, NULL), \ CMD(BT_HCI_CMD_LE_READ_TX_POWER, cmd_read_tx_power, NULL), \ CMD(BT_HCI_CMD_LE_SET_PRIV_MODE, cmd_set_privacy_mode, NULL) diff --git a/monitor/bt.h b/monitor/bt.h index b6b6c49e1..5c2acee67 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -2427,24 +2427,24 @@ struct bt_hci_cmd_le_remove_adv_set { #define BT_HCI_CMD_LE_CLEAR_ADV_SETS 0x203d -#define BT_HCI_CMD_LE_SET_PERIODIC_ADV_PARAMS 0x203e -struct bt_hci_cmd_le_set_periodic_adv_params { +#define BT_HCI_CMD_LE_SET_PA_PARAMS 0x203e +struct bt_hci_cmd_le_set_pa_params { uint8_t handle; uint16_t min_interval; uint16_t max_interval; uint16_t properties; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_SET_PERIODIC_ADV_DATA 0x203f -struct bt_hci_cmd_le_set_periodic_adv_data { +#define BT_HCI_CMD_LE_SET_PA_DATA 0x203f +struct bt_hci_cmd_le_set_pa_data { uint8_t handle; uint8_t operation; uint8_t data_len; uint8_t data[0]; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_SET_PERIODIC_ADV_ENABLE 0x2040 -struct bt_hci_cmd_le_set_periodic_adv_enable { +#define BT_HCI_CMD_LE_SET_PA_ENABLE 0x2040 +struct bt_hci_cmd_le_set_pa_enable { uint8_t enable; uint8_t handle; } __attribute__ ((packed)); @@ -2490,8 +2490,8 @@ struct bt_hci_le_ext_create_conn { uint16_t max_length; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC 0x2044 -struct bt_hci_cmd_le_periodic_adv_create_sync { +#define BT_HCI_CMD_LE_PA_CREATE_SYNC 0x2044 +struct bt_hci_cmd_le_pa_create_sync { uint8_t options; uint8_t sid; uint8_t addr_type; @@ -2501,31 +2501,31 @@ struct bt_hci_cmd_le_periodic_adv_create_sync { uint8_t sync_cte_type; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL 0x2045 +#define BT_HCI_CMD_LE_PA_CREATE_SYNC_CANCEL 0x2045 -#define BT_HCI_CMD_LE_PERIODIC_ADV_TERM_SYNC 0x2046 -struct bt_hci_cmd_le_periodic_adv_term_sync { +#define BT_HCI_CMD_LE_PA_TERM_SYNC 0x2046 +struct bt_hci_cmd_le_pa_term_sync { uint16_t sync_handle; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_ADD_DEV_PERIODIC_ADV_LIST 0x2047 -struct bt_hci_cmd_le_add_dev_periodic_adv_list { +#define BT_HCI_CMD_LE_ADD_DEV_PA_LIST 0x2047 +struct bt_hci_cmd_le_add_dev_pa_list { uint8_t addr_type; uint8_t addr[6]; uint8_t sid; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_REMOVE_DEV_PERIODIC_ADV_LIST 0x2048 -struct bt_hci_cmd_le_remove_dev_periodic_adv_list { +#define BT_HCI_CMD_LE_REMOVE_DEV_PA_LIST 0x2048 +struct bt_hci_cmd_le_remove_dev_pa_list { uint8_t addr_type; uint8_t addr[6]; uint8_t sid; } __attribute__ ((packed)); -#define BT_HCI_CMD_LE_CLEAR_PERIODIC_ADV_LIST 0x2049 +#define BT_HCI_CMD_LE_CLEAR_PA_LIST 0x2049 -#define BT_HCI_CMD_LE_READ_PERIODIC_ADV_LIST_SIZE 0x204a -struct bt_hci_rsp_le_read_dev_periodic_adv_list_size { +#define BT_HCI_CMD_LE_READ_PA_LIST_SIZE 0x204a +struct bt_hci_rsp_le_read_dev_pa_list_size { uint8_t status; uint8_t list_size; } __attribute__ ((packed)); @@ -2582,28 +2582,28 @@ struct bt_hci_cmd_le_tx_test_v3 { uint8_t antenna_ids[0]; } __attribute__ ((packed)); -#define BT_HCI_CMD_SET_PERIODIC_ADV_REC_ENABLE 0x2059 -struct bt_hci_cmd_set_periodic_adv_rec_enable { +#define BT_HCI_CMD_SET_PA_REC_ENABLE 0x2059 +struct bt_hci_cmd_set_pa_rec_enable { uint16_t sync_handle; uint8_t enable; } __attribute__ ((packed)); -#define BT_HCI_CMD_PERIODIC_SYNC_TRANS 0x205a +#define BT_HCI_CMD_PERIODIC_SYNC_TRANS 0x205a struct bt_hci_cmd_periodic_sync_trans { uint16_t handle; uint16_t service_data; uint16_t sync_handle; } __attribute__ ((packed)); -#define BT_HCI_CMD_PERIODIC_ADV_SET_INFO_TRANS 0x205b -struct bt_hci_cmd_periodic_adv_set_info_trans { +#define BT_HCI_CMD_PA_SET_INFO_TRANS 0x205b +struct bt_hci_cmd_pa_set_info_trans { uint16_t handle; uint16_t service_data; uint16_t adv_handle; } __attribute__ ((packed)); -#define BT_HCI_CMD_PERIODIC_ADV_SYNC_TRANS_PARAMS 0x205c -struct bt_hci_cmd_periodic_adv_sync_trans_params { +#define BT_HCI_CMD_PA_SYNC_TRANS_PARAMS 0x205c +struct bt_hci_cmd_pa_sync_trans_params { uint16_t handle; uint8_t mode; uint16_t skip; @@ -2611,8 +2611,8 @@ struct bt_hci_cmd_periodic_adv_sync_trans_params { uint8_t cte_type; } __attribute__ ((packed)); -#define BT_HCI_CMD_DEFAULT_PERIODIC_ADV_SYNC_TRANS_PARAMS 0x205d -struct bt_hci_cmd_default_periodic_adv_sync_trans_params { +#define BT_HCI_CMD_DEFAULT_PA_SYNC_TRANS_PARAMS 0x205d +struct bt_hci_cmd_default_pa_sync_trans_params { uint8_t mode; uint16_t skip; uint16_t sync_timeout; @@ -3497,7 +3497,7 @@ struct bt_hci_le_ext_adv_report { uint8_t data[0]; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_PER_SYNC_ESTABLISHED 0x0e +#define BT_HCI_EVT_LE_PA_SYNC_ESTABLISHED 0x0e struct bt_hci_evt_le_per_sync_established { uint8_t status; uint16_t handle; @@ -3509,8 +3509,8 @@ struct bt_hci_evt_le_per_sync_established { uint8_t clock_accuracy; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_PER_ADV_REPORT 0x0f -struct bt_hci_le_per_adv_report { +#define BT_HCI_EVT_LE_PA_REPORT 0x0f +struct bt_hci_le_pa_report { uint16_t handle; uint8_t tx_power; int8_t rssi; @@ -3520,7 +3520,7 @@ struct bt_hci_le_per_adv_report { uint8_t data[0]; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_PER_SYNC_LOST 0x10 +#define BT_HCI_EVT_LE_PA_SYNC_LOST 0x10 struct bt_hci_evt_le_per_sync_lost { uint16_t handle; } __attribute__ ((packed)); @@ -3552,8 +3552,8 @@ struct bt_hci_evt_le_cte_request_failed { uint16_t handle; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_PER_ADV_SYNC_TRANS_REC 0x18 -struct bt_hci_evt_le_per_adv_sync_trans_rec { +#define BT_HCI_EVT_LE_PA_SYNC_TRANS_REC 0x18 +struct bt_hci_evt_le_pa_sync_trans_rec { uint8_t status; uint16_t handle; uint16_t service_data; @@ -3566,7 +3566,7 @@ struct bt_hci_evt_le_per_adv_sync_trans_rec { uint8_t clock_accuracy; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_CIS_ESTABLISHED 0x19 +#define BT_HCI_EVT_LE_CIS_ESTABLISHED 0x19 struct bt_hci_evt_le_cis_established { uint8_t status; uint16_t conn_handle; @@ -3586,7 +3586,7 @@ struct bt_hci_evt_le_cis_established { uint16_t interval; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_CIS_REQ 0x1a +#define BT_HCI_EVT_LE_CIS_REQ 0x1a struct bt_hci_evt_le_cis_req { uint16_t acl_handle; uint16_t cis_handle; @@ -3594,7 +3594,7 @@ struct bt_hci_evt_le_cis_req { uint8_t cis_id; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_BIG_COMPLETE 0x1b +#define BT_HCI_EVT_LE_BIG_COMPLETE 0x1b struct bt_hci_evt_le_big_complete { uint8_t status; uint8_t handle; @@ -3611,13 +3611,13 @@ struct bt_hci_evt_le_big_complete { uint16_t bis_handle[0]; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_BIG_TERMINATE 0x1c +#define BT_HCI_EVT_LE_BIG_TERMINATE 0x1c struct bt_hci_evt_le_big_terminate { uint8_t reason; uint8_t handle; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED 0x1d +#define BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED 0x1d struct bt_hci_evt_le_big_sync_estabilished { uint8_t status; uint8_t handle; @@ -3632,13 +3632,13 @@ struct bt_hci_evt_le_big_sync_estabilished { uint16_t bis[0]; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_BIG_SYNC_LOST 0x1e +#define BT_HCI_EVT_LE_BIG_SYNC_LOST 0x1e struct bt_hci_evt_le_big_sync_lost { uint8_t big_id; uint8_t reason; } __attribute__ ((packed)); -#define BT_HCI_EVT_LE_REQ_PEER_SCA_COMPLETE 0x1f +#define BT_HCI_EVT_LE_REQ_PEER_SCA_COMPLETE 0x1f struct bt_hci_evt_le_req_peer_sca_complete { uint8_t status; uint16_t handle; @@ -3657,7 +3657,7 @@ struct bt_hci_evt_le_req_peer_sca_complete { #define BT_HCI_ERR_UNSUPPORTED_FEATURE 0x11 #define BT_HCI_ERR_INVALID_PARAMETERS 0x12 #define BT_HCI_ERR_UNSPECIFIED_ERROR 0x1f -#define BT_HCI_ERR_ADV_TIMEOUT 0x3c +#define BT_HCI_ERR_ADV_TIMEOUT 0x3c #define BT_HCI_ERR_CONN_FAILED_TO_ESTABLISH 0x3e #define BT_HCI_ERR_UNKNOWN_ADVERTISING_ID 0x42 #define BT_HCI_ERR_CANCELLED 0x44 diff --git a/monitor/packet.c b/monitor/packet.c index a17c632a7..b7431b57d 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -7400,37 +7400,37 @@ static void le_remove_adv_set_cmd(const void *data, uint8_t size) print_handle(cmd->handle); } -static const struct bitfield_data periodic_adv_properties_table[] = { +static const struct bitfield_data pa_properties_table[] = { { 6, "Include TxPower" }, { } }; -static void print_periodic_adv_properties(uint16_t flags) +static void print_pa_properties(uint16_t flags) { uint16_t mask; print_field("Properties: 0x%4.4x", flags); - mask = print_bitfield(2, flags, periodic_adv_properties_table); + mask = print_bitfield(2, flags, pa_properties_table); if (mask) print_text(COLOR_UNKNOWN_ADV_FLAG, " Unknown advertising properties (0x%4.4x)", mask); } -static void le_set_periodic_adv_params_cmd(const void *data, uint8_t size) +static void le_set_pa_params_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_set_periodic_adv_params *cmd = data; + const struct bt_hci_cmd_le_set_pa_params *cmd = data; print_handle(cmd->handle); print_slot_125("Min interval", cmd->min_interval); print_slot_125("Max interval", cmd->max_interval); - print_periodic_adv_properties(cmd->properties); + print_pa_properties(cmd->properties); } -static void le_set_periodic_adv_data_cmd(const void *data, uint8_t size) +static void le_set_pa_data_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_set_periodic_adv_data *cmd = data; + const struct bt_hci_cmd_le_set_pa_data *cmd = data; const char *str; print_handle(cmd->handle); @@ -7458,9 +7458,9 @@ static void le_set_periodic_adv_data_cmd(const void *data, uint8_t size) print_eir(cmd->data, cmd->data_len, true); } -static void le_set_periodic_adv_enable_cmd(const void *data, uint8_t size) +static void le_set_pa_enable_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_set_periodic_adv_enable *cmd = data; + const struct bt_hci_cmd_le_set_pa_enable *cmd = data; print_enable("Periodic advertising", cmd->enable); print_handle(cmd->handle); @@ -7657,9 +7657,9 @@ static void print_create_sync_options(uint8_t flags) } } -static void le_periodic_adv_create_sync_cmd(const void *data, uint8_t size) +static void le_pa_create_sync_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_periodic_adv_create_sync *cmd = data; + const struct bt_hci_cmd_le_pa_create_sync *cmd = data; print_create_sync_options(cmd->options); print_field("SID: 0x%2.2x", cmd->sid); @@ -7672,34 +7672,34 @@ static void le_periodic_adv_create_sync_cmd(const void *data, uint8_t size) print_create_sync_cte_type(cmd->sync_cte_type); } -static void le_periodic_adv_term_sync_cmd(const void *data, uint8_t size) +static void le_pa_term_sync_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_periodic_adv_term_sync *cmd = data; + const struct bt_hci_cmd_le_pa_term_sync *cmd = data; print_field("Sync handle: 0x%4.4x", cmd->sync_handle); } -static void le_add_dev_periodic_adv_list_cmd(const void *data, uint8_t size) +static void le_add_dev_pa_list_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_add_dev_periodic_adv_list *cmd = data; + const struct bt_hci_cmd_le_add_dev_pa_list *cmd = data; print_addr_type("Adv address type", cmd->addr_type); print_addr("Adv address", cmd->addr, cmd->addr_type); print_field("SID: 0x%2.2x", cmd->sid); } -static void le_remove_dev_periodic_adv_list_cmd(const void *data, uint8_t size) +static void le_remove_dev_pa_list_cmd(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_remove_dev_periodic_adv_list *cmd = data; + const struct bt_hci_cmd_le_remove_dev_pa_list *cmd = data; print_addr_type("Adv address type", cmd->addr_type); print_addr("Adv address", cmd->addr, cmd->addr_type); print_field("SID: 0x%2.2x", cmd->sid); } -static void le_read_periodic_adv_list_size_rsp(const void *data, uint8_t size) +static void le_read_pa_list_size_rsp(const void *data, uint8_t size) { - const struct bt_hci_rsp_le_read_dev_periodic_adv_list_size *rsp = data; + const struct bt_hci_rsp_le_read_dev_pa_list_size *rsp = data; print_status(rsp->status); print_field("List size: 0x%2.2x", rsp->list_size); @@ -7861,15 +7861,15 @@ static void le_tx_test_cmd_v3(const void *data, uint8_t size) print_field(" Antenna ID: %u", cmd->antenna_ids[i]); } -static void le_periodic_adv_rec_enable(const void *data, uint8_t size) +static void le_pa_rec_enable(const void *data, uint8_t size) { - const struct bt_hci_cmd_le_set_periodic_adv_enable *cmd = data; + const struct bt_hci_cmd_le_set_pa_enable *cmd = data; print_field("Sync handle: %d", cmd->handle); print_enable("Reporting", cmd->enable); } -static void le_periodic_adv_sync_trans(const void *data, uint8_t size) +static void le_pa_sync_trans(const void *data, uint8_t size) { const struct bt_hci_cmd_periodic_sync_trans *cmd = data; @@ -7878,9 +7878,9 @@ static void le_periodic_adv_sync_trans(const void *data, uint8_t size) print_field("Sync handle: %d", cmd->sync_handle); } -static void le_periodic_adv_set_info_trans(const void *data, uint8_t size) +static void le_pa_set_info_trans(const void *data, uint8_t size) { - const struct bt_hci_cmd_periodic_adv_set_info_trans *cmd = data; + const struct bt_hci_cmd_pa_set_info_trans *cmd = data; print_field("Connection handle: %d", cmd->handle); print_field("Service data: 0x%4.4x", cmd->service_data); @@ -7909,9 +7909,9 @@ static void print_sync_mode(uint8_t mode) print_field("Mode: %s (0x%2.2x)", str, mode); } -static void le_periodic_adv_sync_trans_params(const void *data, uint8_t size) +static void le_pa_sync_trans_params(const void *data, uint8_t size) { - const struct bt_hci_cmd_periodic_adv_sync_trans_params *cmd = data; + const struct bt_hci_cmd_pa_sync_trans_params *cmd = data; print_field("Connection handle: %d", cmd->handle); print_sync_mode(cmd->mode); @@ -7922,10 +7922,10 @@ static void le_periodic_adv_sync_trans_params(const void *data, uint8_t size) print_create_sync_cte_type(cmd->cte_type); } -static void le_set_default_periodic_adv_sync_trans_params(const void *data, +static void le_set_default_pa_sync_trans_params(const void *data, uint8_t size) { - const struct bt_hci_cmd_default_periodic_adv_sync_trans_params *cmd = data; + const struct bt_hci_cmd_default_pa_sync_trans_params *cmd = data; print_sync_mode(cmd->mode); print_field("Skip: 0x%2.2x", cmd->skip); @@ -9141,13 +9141,13 @@ static const struct opcode_data opcode_table[] = { null_cmd, 0, true, status_rsp, 1, true }, { 0x203e, 298, "LE Set Periodic Advertising Parameters", - le_set_periodic_adv_params_cmd, 7, true, + le_set_pa_params_cmd, 7, true, status_rsp, 1, true }, { 0x203f, 299, "LE Set Periodic Advertising Data", - le_set_periodic_adv_data_cmd, 3, false, + le_set_pa_data_cmd, 3, false, status_rsp, 1, true }, { 0x2040, 300, "LE Set Periodic Advertising Enable", - le_set_periodic_adv_enable_cmd, 2, true, + le_set_pa_enable_cmd, 2, true, status_rsp, 1, true }, { 0x2041, 301, "LE Set Extended Scan Parameters", le_set_ext_scan_params_cmd, 3, false, @@ -9159,26 +9159,26 @@ static const struct opcode_data opcode_table[] = { le_ext_create_conn_cmd, 10, false, status_rsp, 1, true }, { 0x2044, 304, "LE Periodic Advertising Create Sync", - le_periodic_adv_create_sync_cmd, 14, true, + le_pa_create_sync_cmd, 14, true, status_rsp, 1, true }, { 0x2045, 305, "LE Periodic Advertising Create Sync Cancel", null_cmd, 0, true, status_rsp, 1, true }, { 0x2046, 306, "LE Periodic Advertising Terminate Sync", - le_periodic_adv_term_sync_cmd, 2, true, + le_pa_term_sync_cmd, 2, true, status_rsp, 1, true }, { 0x2047, 307, "LE Add Device To Periodic Advertiser List", - le_add_dev_periodic_adv_list_cmd, 8, true, + le_add_dev_pa_list_cmd, 8, true, status_rsp, 1, true }, { 0x2048, 308, "LE Remove Device From Periodic Advertiser List", - le_remove_dev_periodic_adv_list_cmd, 8, true, + le_remove_dev_pa_list_cmd, 8, true, status_rsp, 1, true }, { 0x2049, 309, "LE Clear Periodic Advertiser List", null_cmd, 0, true, status_rsp, 1, true }, { 0x204a, 310, "LE Read Periodic Advertiser List Size", null_cmd, 0, true, - le_read_periodic_adv_list_size_rsp, 2, true }, + le_read_pa_list_size_rsp, 2, true }, { 0x204b, 311, "LE Read Transmit Power", null_cmd, 0, true, le_read_tx_power_rsp, 3, true }, @@ -9198,20 +9198,20 @@ static const struct opcode_data opcode_table[] = { le_tx_test_cmd_v3, 9, false, status_rsp, 1, true }, { 0x2059, 325, "LE Periodic Advertising Receive Enable", - le_periodic_adv_rec_enable, 3, true, + le_pa_rec_enable, 3, true, status_rsp, 1, true }, { 0x205a, 326, "LE Periodic Advertising Sync Transfer", - le_periodic_adv_sync_trans, 6, true, + le_pa_sync_trans, 6, true, status_handle_rsp, 3, true }, { 0x205b, 327, "LE Periodic Advertising Set Info Transfer", - le_periodic_adv_set_info_trans, 5, true, + le_pa_set_info_trans, 5, true, status_handle_rsp, 3, true }, { 0x205c, 328, "LE Periodic Advertising Sync Transfer Parameters", - le_periodic_adv_sync_trans_params, 8, true, + le_pa_sync_trans_params, 8, true, status_handle_rsp, 3, true}, { 0x205d, 329, "LE Set Default Periodic Advertisng Sync Transfer " "Parameters", - le_set_default_periodic_adv_sync_trans_params, + le_set_default_pa_sync_trans_params, 6, true, status_rsp, 1, true}, { BT_HCI_CMD_LE_READ_BUFFER_SIZE_V2, BT_HCI_BIT_LE_READ_BUFFER_SIZE_V2, @@ -10631,7 +10631,7 @@ static void le_ext_adv_report_evt(const void *data, uint8_t size) } } -static void le_per_adv_sync(const void *data, uint8_t size) +static void le_pa_sync(const void *data, uint8_t size) { const struct bt_hci_evt_le_per_sync_established *evt = data; @@ -10649,9 +10649,9 @@ static void le_per_adv_sync(const void *data, uint8_t size) print_field("Advertiser clock accuracy: 0x%2.2x", evt->clock_accuracy); } -static void le_per_adv_report_evt(const void *data, uint8_t size) +static void le_pa_report_evt(const void *data, uint8_t size) { - const struct bt_hci_le_per_adv_report *evt = data; + const struct bt_hci_le_pa_report *evt = data; const char *color_on; const char *str; @@ -10710,7 +10710,7 @@ static void le_per_adv_report_evt(const void *data, uint8_t size) packet_hexdump(evt->data, evt->data_len); } -static void le_per_adv_sync_lost(const void *data, uint8_t size) +static void le_pa_sync_lost(const void *data, uint8_t size) { const struct bt_hci_evt_le_per_sync_lost *evt = data; @@ -10768,9 +10768,9 @@ static void le_cte_request_failed_evt(const void *data, uint8_t size) print_field("Connection handle: %d", evt->handle); } -static void le_per_adv_sync_trans_rec_evt(const void *data, uint8_t size) +static void le_pa_sync_trans_rec_evt(const void *data, uint8_t size) { - const struct bt_hci_evt_le_per_adv_sync_trans_rec *evt = data; + const struct bt_hci_evt_le_pa_sync_trans_rec *evt = data; print_status(evt->status); print_field("Handle: %d", evt->handle); @@ -10957,11 +10957,11 @@ static const struct subevent_data le_meta_event_table[] = { { 0x0d, "LE Extended Advertising Report", le_ext_adv_report_evt, 1, false}, { 0x0e, "LE Periodic Advertising Sync Established", - le_per_adv_sync, 15, true }, + le_pa_sync, 15, true }, { 0x0f, "LE Periodic Advertising Report", - le_per_adv_report_evt, 7, false}, + le_pa_report_evt, 7, false}, { 0x10, "LE Periodic Advertising Sync Lost", - le_per_adv_sync_lost, 2, true}, + le_pa_sync_lost, 2, true}, { 0x11, "LE Scan Timeout" }, { 0x12, "LE Advertising Set Terminated", le_adv_set_term_evt, 5, true}, @@ -10972,7 +10972,7 @@ static const struct subevent_data le_meta_event_table[] = { { 0x17, "LE CTE Request Failed", le_cte_request_failed_evt, 3, true}, { 0x18, "LE Periodic Advertising Sync Transfer Received", - le_per_adv_sync_trans_rec_evt, 19, + le_pa_sync_trans_rec_evt, 19, true}, { BT_HCI_EVT_LE_CIS_ESTABLISHED, "LE Connected Isochronous Stream Established", From patchwork Thu Feb 24 00:30:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD047C433F5 for ; Thu, 24 Feb 2022 00:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbiBXAbJ (ORCPT ); Wed, 23 Feb 2022 19:31:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiBXAbI (ORCPT ); Wed, 23 Feb 2022 19:31:08 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A94E56D976 for ; Wed, 23 Feb 2022 16:30:38 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id x11so262036pll.10 for ; Wed, 23 Feb 2022 16:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=S3XNC5obP+w/h0Z9WSaAkiva6CDaOCeNCUkMcPJpXoQ=; b=JsNldMp0ES1m3ifS8VxZDytS0WGcEpvHur1ZbovLiUOHDKep2vwDvTKHVqTPfEaT4+ Lb1iUqV8y4FaSCBUXsMTjxNFGER5I3R13E/Eh5HLcZDTyTepQwEYN5xbAWzV795SMd8r HO4qpDvcW7/KGEuzvacNeBjL25umFqPbdXX1s5S3RZbCbEOEWniat8JXyKXiitM5IkKK FiPu7Yc8LNnZkiQbbrBi5IDoVL66sa1ZVqCb0wygXfPFT8njZCRIhBr0pymtD40/8BpJ 9Rh94KI6NtjInr5Eu/hEM6Xjie6zWOheVs1ZxLXFe51CkeW8/Zr0EnI0h5uE2PO4sbiU Lgxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3XNC5obP+w/h0Z9WSaAkiva6CDaOCeNCUkMcPJpXoQ=; b=PkYoNLJIgKgYLAzlPOn6br8DCxSr6lqftnAE//YxVW+5Fy55rHNJJgthfz97Ruw1VL gVx/1nxN1tNKurCEGCEgA/XNVT3Glv5lzehu2WhO0z3u2PhIvp3WSbzFO0dEHQb95izU 39cFRcEUebSSMpmXK9WAB7OD147Ktv0gwmgTfRsqYc/OIitRZsCgPaSrBbr1ids/3dIg XLlLCVPubPCI6BkbUz6qKZezYINms7qQYJLIrkhKeNkTOHhLmZ6dVFjHaTlaAK3fu6SP 0fbB7/f+e6kFnKN6lzFLH0ulGKCUk2VyozrJ6Q7zY2C7zPKAE4HGXqbLQBUfZ7Z2/8Mj Cbpg== X-Gm-Message-State: AOAM531L2yLmR1Bj4kf+OycAGqn3FYbtuJoGEmVmkAW5/sahTl6tr9dN d1wsPUjl4u6r6PdO10g3/agVmt412Ng= X-Google-Smtp-Source: ABdhPJw82MvpBpVCVohgngQC8/ui+rn3CBeHYsJrOVCK0GzmdT/XPLuDkjRlxBOZTT+AWn3WVkQFLg== X-Received: by 2002:a17:902:8492:b0:14d:5ddc:9df6 with SMTP id c18-20020a170902849200b0014d5ddc9df6mr325150plo.15.1645662637710; Wed, 23 Feb 2022 16:30:37 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:37 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 08/11] btdev: Implements BT_HCI_CMD_LE_BIG_CREATE_SYNC Date: Wed, 23 Feb 2022 16:30:26 -0800 Message-Id: <20220224003029.706163-9-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This sends BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED when handling BT_HCI_CMD_LE_BIG_CREATE_SYNC. --- emulator/btdev.c | 158 ++++++++++++++++++++++++++++++++++++++++++++--- monitor/bt.h | 1 + 2 files changed, 150 insertions(+), 9 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 10fa046bc..567377caa 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -40,6 +40,7 @@ #define AL_SIZE 16 #define RL_SIZE 16 #define CIS_SIZE 3 +#define BIS_SIZE 3 #define has_bredr(btdev) (!((btdev)->features[4] & 0x20)) #define has_le(btdev) (!!((btdev)->features[4] & 0x40)) @@ -65,6 +66,7 @@ struct btdev_conn { uint8_t type; struct btdev *dev; struct btdev_conn *link; + void *data; }; struct btdev_al { @@ -199,6 +201,7 @@ struct btdev { uint8_t le_pa_data[31]; struct bt_hci_cmd_le_pa_create_sync pa_sync_cmd; uint16_t le_pa_sync_handle; + uint8_t big_handle; uint8_t le_ltk[16]; struct { struct bt_hci_cmd_le_set_cig_params params; @@ -690,6 +693,7 @@ static void conn_remove(void *data) queue_remove(conn->dev->conns, conn); + free(conn->data); free(conn); } @@ -1121,9 +1125,65 @@ static struct btdev_conn *conn_add_cis(struct btdev_conn *acl, uint16_t handle) return conn_link(acl->dev, acl->link->dev, handle, HCI_ISODATA_PKT); } -static struct btdev_conn *conn_add_bis(struct btdev *dev, uint16_t handle) +static struct btdev_conn *conn_add_bis(struct btdev *dev, uint16_t handle, + const struct bt_hci_bis *bis) { - return conn_new(dev, handle, HCI_ISODATA_PKT); + struct btdev_conn *conn; + + conn = conn_new(dev, handle, HCI_ISODATA_PKT); + if (!conn) + return conn; + + conn->data = util_memdup(bis, sizeof(*bis)); + + return conn; +} + +static struct btdev_conn *find_bis_index(struct btdev *remote, uint8_t index) +{ + struct btdev_conn *conn; + const struct queue_entry *entry; + + for (entry = queue_get_entries(remote->conns); entry; + entry = entry->next) { + conn = entry->data; + + /* Skip if not a broadcast */ + if (conn->type != HCI_ISODATA_PKT || conn->link) + continue; + + if (!index) + return conn; + + index--; + } + + return NULL; +} + +static struct btdev_conn *conn_link_bis(struct btdev *dev, struct btdev *remote, + uint8_t index) +{ + struct btdev_conn *conn; + struct btdev_conn *bis; + + bis = find_bis_index(remote, index); + if (!bis) + return NULL; + + conn = conn_add_bis(dev, ISO_HANDLE, bis->data); + if (!conn) + return NULL; + + bis->link = conn; + conn->link = bis; + + util_debug(dev->debug_callback, dev->debug_data, + "bis %p handle 0x%04x", bis, bis->handle); + util_debug(dev->debug_callback, dev->debug_data, + "conn %p handle 0x%04x", conn, conn->handle); + + return conn; } static void conn_complete(struct btdev *btdev, @@ -5103,8 +5163,6 @@ static void le_pa_sync_estabilished(struct btdev *dev, struct btdev *remote, ev.interval = remote->le_pa_min_interval; ev.clock_accuracy = 0x07; - memset(&dev->pa_sync_cmd, 0, sizeof(dev->pa_sync_cmd)); - le_meta_event(dev, BT_HCI_EVT_LE_PA_SYNC_ESTABLISHED, &ev, sizeof(ev)); send_pa(dev, remote, 0); } @@ -5858,14 +5916,14 @@ static int cmd_create_big_complete(struct btdev *dev, const void *data, memset(&pdu, 0, sizeof(pdu)); - conn = conn_add_bis(dev, ISO_HANDLE); + conn = conn_add_bis(dev, ISO_HANDLE, bis); if (!conn) { pdu.evt.status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; goto done; } pdu.evt.handle = cmd->handle; - pdu.evt.num_bis = 0x01; + pdu.evt.num_bis++; pdu.evt.phy = bis->phy; pdu.evt.max_pdu = bis->sdu; memcpy(pdu.evt.sync_delay, bis->sdu_interval, 3); @@ -5910,8 +5968,89 @@ static int cmd_term_big_complete(struct btdev *dev, const void *data, static int cmd_big_create_sync(struct btdev *dev, const void *data, uint8_t len) { - /* TODO */ - return -ENOTSUP; + const struct bt_hci_cmd_le_big_create_sync *cmd = data; + uint8_t status = BT_HCI_ERR_SUCCESS; + + /* If the Sync_Handle does not exist, the Controller shall return the + * error code Unknown Advertising Identifier (0x42). + */ + if (dev->le_pa_sync_handle != le16_to_cpu(cmd->sync_handle)) + status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID; + + /* If the Host sends this command with a BIG_Handle that is already + * allocated, the Controller shall return the error code Command + * Disallowed (0x0C). + */ + if (dev->big_handle == cmd->handle) + status = BT_HCI_ERR_COMMAND_DISALLOWED; + + /* If the Num_BIS parameter is greater than the total number of BISes + * in the BIG, the Controller shall return the error code Unsupported + * Feature or Parameter Value (0x11). + */ + if (cmd->num_bis != len - sizeof(*cmd)) + status = BT_HCI_ERR_UNSUPPORTED_FEATURE; + + if (status) + return status; + + cmd_status(dev, status, BT_HCI_CMD_LE_BIG_CREATE_SYNC); + + return status; +} + +static int cmd_big_create_sync_complete(struct btdev *dev, const void *data, + uint8_t len) +{ + const struct bt_hci_cmd_le_big_create_sync *cmd = data; + struct __packed { + struct bt_hci_evt_le_big_sync_estabilished ev; + uint16_t bis[BIS_SIZE]; + } pdu; + struct btdev *remote; + struct btdev_conn *conn = NULL; + struct bt_hci_bis *bis; + int i; + + remote = find_btdev_by_bdaddr_type(dev->pa_sync_cmd.addr, + dev->pa_sync_cmd.addr_type); + if (!remote) + return 0; + + memset(&pdu.ev, 0, sizeof(pdu.ev)); + + for (i = 0; i < cmd->num_bis; i++) { + conn = conn_link_bis(dev, remote, i); + if (!conn) + break; + + pdu.bis[i] = cpu_to_le16(conn->handle); + } + + if (i != cmd->num_bis || !conn) { + pdu.ev.status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED; + le_meta_event(dev, BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED, &pdu, + sizeof(pdu.ev)); + return 0; + } + + dev->big_handle = cmd->handle; + bis = conn->data; + + pdu.ev.handle = cmd->handle; + memcpy(pdu.ev.latency, bis->sdu_interval, sizeof(pdu.ev.interval)); + pdu.ev.nse = 0x01; + pdu.ev.bn = 0x01; + pdu.ev.pto = 0x00; + pdu.ev.irc = 0x01; + pdu.ev.max_pdu = bis->sdu; + pdu.ev.interval = bis->latency; + pdu.ev.num_bis = cmd->num_bis; + + le_meta_event(dev, BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED, &pdu, + sizeof(pdu.ev) + (cmd->num_bis * sizeof(uint16_t))); + + return 0; } static int cmd_big_term_sync(struct btdev *dev, const void *data, uint8_t len) @@ -6125,7 +6264,8 @@ static int cmd_config_data_path(struct btdev *dev, const void *data, cmd_create_big_complete), \ CMD(BT_HCI_CMD_LE_CREATE_BIG_TEST, cmd_create_big_test, NULL), \ CMD(BT_HCI_CMD_LE_TERM_BIG, cmd_term_big, cmd_term_big_complete), \ - CMD(BT_HCI_CMD_LE_BIG_CREATE_SYNC, cmd_big_create_sync, NULL), \ + CMD(BT_HCI_CMD_LE_BIG_CREATE_SYNC, cmd_big_create_sync, \ + cmd_big_create_sync_complete), \ CMD(BT_HCI_CMD_LE_BIG_TERM_SYNC, cmd_big_term_sync, NULL), \ CMD(BT_HCI_CMD_LE_REQ_PEER_SCA, cmd_req_peer_sca, NULL), \ CMD(BT_HCI_CMD_LE_SETUP_ISO_PATH, cmd_setup_iso_path, NULL), \ diff --git a/monitor/bt.h b/monitor/bt.h index 5c2acee67..3bee11868 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -2797,6 +2797,7 @@ struct bt_hci_cmd_le_term_big { #define BT_HCI_CMD_LE_BIG_CREATE_SYNC 0x206b #define BT_HCI_BIT_LE_BIG_CREATE_SYNC BT_HCI_CMD_BIT(43, 0) struct bt_hci_bis_sync { + uint8_t index; } __attribute__ ((packed)); struct bt_hci_cmd_le_big_create_sync { From patchwork Thu Feb 24 00:30:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B964C433EF for ; Thu, 24 Feb 2022 00:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbiBXAbK (ORCPT ); Wed, 23 Feb 2022 19:31:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiBXAbI (ORCPT ); Wed, 23 Feb 2022 19:31:08 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D8F56E2AE for ; Wed, 23 Feb 2022 16:30:39 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id g7-20020a17090a708700b001bb78857ccdso4233200pjk.1 for ; Wed, 23 Feb 2022 16:30:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Hl0evxxrqp/Qfdb5sN8zGAfs6IrTTpCQEbp1CLx/B74=; b=beu4BcSo2bK/loLJ3zPIxQIcs9S16Wdz0JUo3KsFKtWL6NxvF12Il3VOuENnvnNIvK xkCSp3nawBrBS1zvz0j6lg3hupmhnO1N2Wwn7Sbch4x2WwJP3FvFBXFGd02PWbyF4xPu YXKhYin4Sow1WgNV2rjpAZngIzVw0P+2+AkifO6rAD8LnfCD0HdiI3GzrxifaWYLMxJQ 2FoGk+sELJUK/mrc8+9G2foECAWEtwfg7OvSLq5BfZEQ4lzsnpENRmA+PgKGV6SzMpNT dYhBsT7Jv0RTpzcmF1rrSQ9bjkR70zSCGoX9LoBpcuzmFYzu/jjbhncustoZwDumcijw i8YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hl0evxxrqp/Qfdb5sN8zGAfs6IrTTpCQEbp1CLx/B74=; b=KT8RXAIfqZvd32J56SI4MYLTt51z8IZxGC3QT7dRIuRjbaQA7vlxVxwbR2PSXP1noz i1Q2eR8ZzYV0UugKK+1yEf0M4rK49IfWAWWYQ7EkJmIVLCzVLEIDK1JEYqDL3xqrpABR nY8NKIsk32NOZBLotQKyJgNHA55A4VjZ8dxR3CEyeHYUrJsgCaXWcIvkUDbt/qlSWpo2 lsdQMUoHVmoMOCI8oPn86w9GM6DjxvX9zahj7Z9BtgP5620Iwwbmn/fhRygxNaFAVmCM 0mOW7jmL4WbZFwPz6nWseK/YkeEauGn6gbTHco4ObYTcZ0joSomUlXme+820oyt3oW6l 3Kvw== X-Gm-Message-State: AOAM5308Xf0ZOMg9A2Je0+lmaoRzxk5Na7Ttr4fILNz3oIVxH6GRA/df pX4WJQhcMGgWzQ11mpcDGHv+H5UKXtQ= X-Google-Smtp-Source: ABdhPJwDGyxLY6M4yzRHwDD8irOyMZ0mUI4ANFbN7OkgQwbvcB+2UnDy6BUMKdTzTGjVtkQTubmKxA== X-Received: by 2002:a17:90a:10d0:b0:1bc:a943:b6e5 with SMTP id b16-20020a17090a10d000b001bca943b6e5mr3856855pje.86.1645662638801; Wed, 23 Feb 2022 16:30:38 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:38 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 09/11] btdev: Implements BT_HCI_CMD_LE_BIG_TERM_SYNC Date: Wed, 23 Feb 2022 16:30:27 -0800 Message-Id: <20220224003029.706163-10-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This sends BT_HCI_EVT_DISCONNECT_COMPLETE when handling BT_HCI_CMD_LE_BIG_TERM_SYNC. --- emulator/btdev.c | 39 +++++++++++++++++++++++++++++++++++++-- monitor/bt.h | 5 +++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 567377caa..6834ec1c2 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -6055,8 +6055,43 @@ static int cmd_big_create_sync_complete(struct btdev *dev, const void *data, static int cmd_big_term_sync(struct btdev *dev, const void *data, uint8_t len) { - /* TODO */ - return -ENOTSUP; + const struct bt_hci_cmd_le_big_term_sync *cmd = data; + struct bt_hci_rsp_le_big_term_sync rsp; + const struct queue_entry *entry; + + memset(&rsp, 0, sizeof(rsp)); + + /* If the Host issues this command with a BIG_Handle that does not + * exist, the Controller shall return the error code Unknown + * Advertising Identifier (0x42). + */ + if (dev->big_handle != cmd->handle) { + rsp.status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID; + goto done; + } + + rsp.status = BT_HCI_ERR_COMMAND_DISALLOWED; + rsp.handle = cmd->handle; + + /* Cleanup existing connections */ + for (entry = queue_get_entries(dev->conns); entry; + entry = entry->next) { + struct btdev_conn *conn = entry->data; + + if (!conn->data) + continue; + + rsp.status = BT_HCI_ERR_SUCCESS; + disconnect_complete(dev, conn->handle, BT_HCI_ERR_SUCCESS, + 0x16); + + conn_remove(conn); + } + +done: + cmd_complete(dev, BT_HCI_CMD_LE_BIG_TERM_SYNC, &rsp, sizeof(rsp)); + + return 0; } static int cmd_req_peer_sca(struct btdev *dev, const void *data, uint8_t len) diff --git a/monitor/bt.h b/monitor/bt.h index 3bee11868..6ce6384a4 100644 --- a/monitor/bt.h +++ b/monitor/bt.h @@ -2817,6 +2817,11 @@ struct bt_hci_cmd_le_big_term_sync { uint8_t handle; } __attribute__ ((packed)); +struct bt_hci_rsp_le_big_term_sync { + uint8_t status; + uint8_t handle; +} __attribute__ ((packed)); + #define BT_HCI_CMD_LE_REQ_PEER_SCA 0x206d #define BT_HCI_BIT_LE_REQ_PEER_SCA BT_HCI_CMD_BIT(43, 2) struct bt_hci_cmd_le_req_peer_sca { From patchwork Thu Feb 24 00:30:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF11C433FE for ; Thu, 24 Feb 2022 00:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231158AbiBXAbL (ORCPT ); Wed, 23 Feb 2022 19:31:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbiBXAbJ (ORCPT ); Wed, 23 Feb 2022 19:31:09 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 811226E34D for ; Wed, 23 Feb 2022 16:30:40 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id v4so529866pjh.2 for ; Wed, 23 Feb 2022 16:30:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bes3roHlNFOFnWbovj/EDVIKI3u6AKmdoM06/CCIA4Q=; b=HRm0jEfXxqZoJqUld4+rhfSpqyjAfAsuWqS6qBTFnfAQdBg3rETOdjz+fkTkZn3tm8 CYuL1BMGjWnMyEI5qLlRwX4zQaAmlw3OHqSu5gtJnCLNRenwPLVAe8ESTblSUQ7gQrER 8nnPfpVEm4IyDpIk6pQxC72DNonqLtBNiUpxKdTC8I41HQaEn9HwwLEfUWLkVfCD7SFX k3/i5unMPa9IfFCF9NuPoRiOncTiBCypS0b3Li75jSC+S6lN9tHtmaoWGRY4IUsI7izR fcEEvzRIB++dSdAtW4s7/4ILjGIZdDwr+OZs87+4bslUEb7Wt+xGHC7+Cjb2zBfn6ItA r+nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bes3roHlNFOFnWbovj/EDVIKI3u6AKmdoM06/CCIA4Q=; b=Jsh5AYawdwHrAjLil+Ai1TKrkNIckBTA8uqUjfQyAC1qWth5XZWIvtgESOKpo/0Vq+ IdlF7/dwgogTfmp2fSXc6ay5Bjoyy3+vLjUJqYGmdtekIcxBUPcfT0WSpu00xM5fvijB ksa+KWAKh8dSfzkUVrXiOZ/ikCrPGzW0Gt/uCpZ7BlZAFaINg77oCBXUwY5pXbV5idT6 f2aWmsLMBatXp4N8cn9ZunbjLjvBpa3KQjox9f8FEqkDDxVqBvKjPuoZilGb/hFsIyYy yJALzOzJjTUi8eXN3AXUIVf3At1wELBojbTFZ3tPdJx9DMwnzH1VMoU4pL1vV8XYGXtm 0ypA== X-Gm-Message-State: AOAM531rWPLewKc3Zhjr+09va13WXULeT/qM66+YeUDNlx5xcGh+hLqC nPw4p2DeFjsblzUftG1XrgwkZT71nWs= X-Google-Smtp-Source: ABdhPJwi2ukGrHR2fKhO0/24BzkmHJhiMZ5AMBF6PHwmChu/x8GAaUvQSb5njynKJZ+eh/pgFUjlFg== X-Received: by 2002:a17:903:4084:b0:14f:cf98:5515 with SMTP id z4-20020a170903408400b0014fcf985515mr50487plc.124.1645662639621; Wed, 23 Feb 2022 16:30:39 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:39 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 10/11] bthost: Add support for Periodic Advertising Date: Wed, 23 Feb 2022 16:30:28 -0800 Message-Id: <20220224003029.706163-11-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds bthost_set_pa_params and bthost_set_pa_enable. --- emulator/bthost.c | 19 +++++++++++++++++++ emulator/bthost.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/emulator/bthost.c b/emulator/bthost.c index d751e7dd4..fef542236 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -2801,6 +2801,25 @@ void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable) send_command(bthost, BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE, cp, 6); } +void bthost_set_pa_params(struct bthost *bthost) +{ + struct bt_hci_cmd_le_set_pa_params cp; + + memset(&cp, 0, sizeof(cp)); + cp.handle = 0x01; + send_command(bthost, BT_HCI_CMD_LE_SET_PA_PARAMS, &cp, sizeof(cp)); +} + +void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable) +{ + struct bt_hci_cmd_le_set_pa_enable cp; + + memset(&cp, 0, sizeof(cp)); + cp.enable = enable; + cp.handle = 0x01; + send_command(bthost, BT_HCI_CMD_LE_SET_PA_ENABLE, &cp, sizeof(cp)); +} + bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr) { const struct queue_entry *entry; diff --git a/emulator/bthost.h b/emulator/bthost.h index 868af5469..55a7adf26 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -84,6 +84,8 @@ void bthost_set_ext_adv_data(struct bthost *bthost, const uint8_t *data, uint8_t len); void bthost_set_ext_adv_params(struct bthost *bthost); void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable); +void bthost_set_pa_params(struct bthost *bthost); +void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable); bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr); void bthost_set_scan_params(struct bthost *bthost, uint8_t scan_type, From patchwork Thu Feb 24 00:30:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 545954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7BCAC4332F for ; Thu, 24 Feb 2022 00:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbiBXAbN (ORCPT ); Wed, 23 Feb 2022 19:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiBXAbK (ORCPT ); Wed, 23 Feb 2022 19:31:10 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B94A6D976 for ; Wed, 23 Feb 2022 16:30:41 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id c9so315372pll.0 for ; Wed, 23 Feb 2022 16:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bN72KDA/URR+CXci2mzM3peVK0aNrF9ntA5ysSCg1Jg=; b=Hwxy+h1WWPv68+GPj0AtbKcUXuQnflS7s6LgL6+tsHspp9oHVSqhE9iMlypigCeQ6K GhiUB5ZOy0GKKNG/DGNZkUSj2bXO2aSTOi1i5uD4QzBLgQ8jiEqV/78VB5TAs3gf20Lu 4vT6+eVjbZnDAx22qRStGu7H1KkWjCW+ene5OcstU9RcKVncVgwwgikwNj3mbev6oFrc WtWmG3PDkfxRf33k77xINGLSeg+JRv/2n+rQ7B7fPyNDmXbd5JUBQccGrgm2T/f79xen x6RJKOLEhVJl6ZSmka9EhBmm+VA8Jf9oVQiHWVkMMpztqq/Xh8Ir2Zok61QgcMi7mc8X /Liw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bN72KDA/URR+CXci2mzM3peVK0aNrF9ntA5ysSCg1Jg=; b=tMMtTPNhkSTgR6wADWiXeJbpxYc/RcPtQqcqPmvk84cdCxfZXcj7nHgcVsEPxudf5M 0MK3F7DMUq0tSR/BUqNU5X2ZNz7H9p5QxJDPw0cSNVLYOarXwhpCnxZCOidppo001a5O 02C8hqPYaf2dl3ooNL38Tv4xpI8tofPCwbmQ1rb4ROEy9gl5VZUvQg4mxkLL4J3+lSNO QF0cebA0PyYOOdn9fiFK1oq5Y3RCK0NjmEOiHcus4wbQJsRk4aHELjqG555fgLLBt5sW NC76Gjx9axkC1vjZBkpLLSgH7F8Aklfn32D9hwkamKARZalr64gnNtUpg08pU7dG4kCd 3q3A== X-Gm-Message-State: AOAM532i2EuM3Mtk0ElOCmyOw9UgMgQQ/hdpmUNhKZHupgbt3R9nfXm4 i+mOw73CgvTp+U0WUqEjywSCtZHepNM= X-Google-Smtp-Source: ABdhPJykEpmkbq/AzIlYijgxwg6pKxIxIilYogiMkBcymdIRkR3smmXfNntSA/in2BCrgytGgDqjKA== X-Received: by 2002:a17:90a:ca8d:b0:1bc:649c:6dd1 with SMTP id y13-20020a17090aca8d00b001bc649c6dd1mr121268pjt.165.1645662640253; Wed, 23 Feb 2022 16:30:40 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t19sm574570pjs.54.2022.02.23.16.30.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:30:39 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 11/11] bthost: Add support for Create BIG Date: Wed, 23 Feb 2022 16:30:29 -0800 Message-Id: <20220224003029.706163-12-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220224003029.706163-1-luiz.dentz@gmail.com> References: <20220224003029.706163-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds bthost_create_big --- emulator/bthost.c | 13 +++++++++++++ emulator/bthost.h | 1 + 2 files changed, 14 insertions(+) diff --git a/emulator/bthost.c b/emulator/bthost.c index fef542236..43434387c 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -2820,6 +2820,19 @@ void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable) send_command(bthost, BT_HCI_CMD_LE_SET_PA_ENABLE, &cp, sizeof(cp)); } +void bthost_create_big(struct bthost *bthost, uint8_t num_bis) +{ + struct bt_hci_cmd_le_create_big cp; + + memset(&cp, 0, sizeof(cp)); + cp.handle = 0x01; + cp.adv_handle = 0x01; + cp.num_bis = num_bis; + cp.bis.sdu = 40; + cp.bis.phy = 0x01; + send_command(bthost, BT_HCI_CMD_LE_CREATE_BIG, &cp, sizeof(cp)); +} + bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr) { const struct queue_entry *entry; diff --git a/emulator/bthost.h b/emulator/bthost.h index 55a7adf26..18e7b98e3 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -86,6 +86,7 @@ void bthost_set_ext_adv_params(struct bthost *bthost); void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable); void bthost_set_pa_params(struct bthost *bthost); void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable); +void bthost_create_big(struct bthost *bthost, uint8_t num_bis); bool bthost_search_ext_adv_addr(struct bthost *bthost, const uint8_t *addr); void bthost_set_scan_params(struct bthost *bthost, uint8_t scan_type,