Skip to content

Commit 4c9f893

Browse files
wopu-otnashif
authored andcommitted
Bluetooth: controller: CIS HCI event generation
Implement generation of CIS Request and CIS Established events in HCI layer. Signed-off-by: Wolfgang Puffitsch <[email protected]>
1 parent adaf45c commit 4c9f893

File tree

2 files changed

+99
-4
lines changed

2 files changed

+99
-4
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
#include "ll_sw/lll_scan.h"
3434
#include "ll_sw/lll_sync.h"
3535
#include "ll_sw/lll_conn.h"
36+
#include "ll_sw/lll_conn_iso.h"
3637
#include "ll_sw/ull_adv_types.h"
3738
#include "ll_sw/ull_scan_types.h"
3839
#include "ll_sw/ull_sync_types.h"
3940
#include "ll_sw/ull_conn_types.h"
41+
#include "ll_sw/ull_conn_iso_types.h"
4042
#include "ll.h"
4143
#include "ll_feat.h"
4244
#include "ll_settings.h"
@@ -3135,7 +3137,21 @@ static void le_cis_request(struct pdu_data *pdu_data,
31353137
struct node_rx_pdu *node_rx,
31363138
struct net_buf *buf)
31373139
{
3138-
/* TODO: generate event and fill in data from LL */
3140+
struct bt_hci_evt_le_cis_req *sep;
3141+
struct node_rx_conn_iso_req *req;
3142+
3143+
if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
3144+
!(le_event_mask & BT_EVT_MASK_LE_CIS_REQ)) {
3145+
return;
3146+
}
3147+
3148+
req = (void *)pdu_data;
3149+
3150+
sep = meta_evt(buf, BT_HCI_EVT_LE_CIS_REQ, sizeof(*sep));
3151+
sep->acl_handle = sys_cpu_to_le16(node_rx->hdr.handle);
3152+
sep->cis_handle = sys_cpu_to_le16(req->cis_handle);
3153+
sep->cig_id = req->cig_id;
3154+
sep->cis_id = req->cis_id;
31393155
}
31403156
#endif /* CONFIG_BT_CTLR_PERIPHERAL_ISO */
31413157

@@ -3145,11 +3161,52 @@ static void le_cis_established(struct pdu_data *pdu_data,
31453161
struct node_rx_pdu *node_rx,
31463162
struct net_buf *buf)
31473163
{
3164+
struct lll_conn_iso_stream_rxtx *lll_cis_c;
3165+
struct lll_conn_iso_stream_rxtx *lll_cis_p;
3166+
struct bt_hci_evt_le_cis_established *sep;
3167+
struct lll_conn_iso_stream *lll_cis;
3168+
struct node_rx_conn_iso_estab *est;
3169+
struct ll_conn_iso_stream *cis;
3170+
struct ll_conn_iso_group *cig;
3171+
bool is_central;
3172+
3173+
if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
3174+
!(le_event_mask & BT_EVT_MASK_LE_CIS_ESTABLISHED)) {
3175+
return;
3176+
}
3177+
3178+
cis = node_rx->hdr.rx_ftr.param;
3179+
cig = cis->group;
3180+
lll_cis = &cis->lll;
3181+
is_central = lll_cis->conn->role == BT_CONN_ROLE_MASTER;
3182+
lll_cis_c = is_central ? &lll_cis->tx : &lll_cis->rx;
3183+
lll_cis_p = is_central ? &lll_cis->rx : &lll_cis->tx;
3184+
est = (void *)pdu_data;
3185+
3186+
sep = meta_evt(buf, BT_HCI_EVT_LE_CIS_ESTABLISHED, sizeof(*sep));
3187+
3188+
sep->status = est->status;
3189+
sep->conn_handle = sys_cpu_to_le16(est->cis_handle);
3190+
sys_put_le24(cig->sync_delay, sep->cig_sync_delay);
3191+
sys_put_le24(cis->sync_delay, sep->cis_sync_delay);
3192+
sys_put_le24(cig->c_latency, sep->m_latency);
3193+
sys_put_le24(cig->p_latency, sep->s_latency);
3194+
sep->m_phy = lll_cis_c->phy;
3195+
sep->s_phy = lll_cis_p->phy;
3196+
sep->nse = lll_cis->num_subevents;
3197+
sep->m_bn = lll_cis_c->burst_number;
3198+
sep->s_bn = lll_cis_p->burst_number;
3199+
sep->m_ft = lll_cis_c->flush_timeout;
3200+
sep->s_ft = lll_cis_p->flush_timeout;
3201+
sep->m_max_pdu = sys_cpu_to_le16(lll_cis_c->max_octets);
3202+
sep->s_max_pdu = sys_cpu_to_le16(lll_cis_p->max_octets);
3203+
sep->interval = sys_cpu_to_le16(cig->iso_interval);
3204+
31483205
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO)
3149-
cis_pending_count--;
3206+
if (is_central) {
3207+
cis_pending_count--;
3208+
}
31503209
#endif /* CONFIG_BT_CTLR_CENTRAL_ISO */
3151-
3152-
/* TODO: generate event and fill in data from LL */
31533210
}
31543211
#endif /* CONFIG_BT_CTLR_CENTRAL_ISO || CONFIG_BT_CTLR_PERIPHERAL_ISO */
31553212

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2021 Demant
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
struct ll_conn_iso_stream {
8+
struct ll_conn_iso_group *group;
9+
struct lll_conn_iso_stream lll;
10+
uint32_t sync_delay;
11+
};
12+
13+
struct ll_conn_iso_group {
14+
struct evt_hdr evt;
15+
struct ull_hdr ull;
16+
struct lll_conn_iso_group lll;
17+
18+
uint32_t sync_delay;
19+
uint32_t c_latency;
20+
uint32_t p_latency;
21+
uint16_t iso_interval;
22+
23+
#if defined(CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP)
24+
struct ll_conn_iso_stream *streams
25+
[CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP];
26+
#endif /* CONFIG_BT_CTLR_CONN_ISO_STREAMS */
27+
};
28+
29+
struct node_rx_conn_iso_req {
30+
uint16_t cis_handle;
31+
uint8_t cig_id;
32+
uint8_t cis_id;
33+
};
34+
35+
struct node_rx_conn_iso_estab {
36+
uint16_t cis_handle;
37+
uint8_t status;
38+
};

0 commit comments

Comments
 (0)