Skip to content

Commit 23f3aa1

Browse files
Thalleycfriedt
authored andcommitted
Bluetooth: sample: Update central_iso to use new ISO API
Update the central_iso sample to use the new ISO API. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 7037b11 commit 23f3aa1

File tree

1 file changed

+16
-10
lines changed
  • samples/bluetooth/central_iso/src

1 file changed

+16
-10
lines changed

samples/bluetooth/central_iso/src/main.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,13 @@ static struct bt_iso_chan_ops iso_ops = {
145145
};
146146

147147
static struct bt_iso_chan_io_qos iso_tx = {
148-
.interval = 10 * USEC_PER_MSEC, /* us */
149-
.latency = 10,
150148
.sdu = CONFIG_BT_ISO_TX_MTU,
151149
.phy = BT_GAP_LE_PHY_2M,
152150
.rtn = 1,
153151
.path = NULL,
154152
};
155153

156154
static struct bt_iso_chan_qos iso_qos = {
157-
.sca = BT_GAP_SCA_UNKNOWN,
158-
.packing = 0,
159-
.framing = 0,
160155
.tx = &iso_tx,
161156
.rx = NULL,
162157
};
@@ -165,8 +160,10 @@ static void connected(struct bt_conn *conn, uint8_t err)
165160
{
166161
char addr[BT_ADDR_LE_STR_LEN];
167162
int iso_err;
168-
struct bt_conn *conns[1];
169-
struct bt_iso_chan *channels[1];
163+
static struct bt_iso_chan *channels[1];
164+
struct bt_iso_cig_create_param param;
165+
struct bt_iso_connect_param connect_param;
166+
struct bt_iso_cig *cig;
170167

171168
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
172169

@@ -186,17 +183,26 @@ static void connected(struct bt_conn *conn, uint8_t err)
186183

187184
printk("Connected: %s\n", addr);
188185

189-
conns[0] = default_conn;
190186
channels[0] = &iso_chan;
187+
param.cis_channels = channels;
188+
param.num_cis = ARRAY_SIZE(channels);
189+
param.sca = BT_GAP_SCA_UNKNOWN;
190+
param.packing = 0;
191+
param.framing = 0;
192+
param.latency = 10; /* ms */
193+
param.interval = 10 * USEC_PER_MSEC; /* us */
191194

192-
iso_err = bt_iso_chan_bind(conns, ARRAY_SIZE(conns), channels);
195+
iso_err = bt_iso_cig_create(&param, &cig);
193196

194197
if (iso_err) {
195198
printk("Failed to bind iso to connection (%d)\n", iso_err);
196199
return;
197200
}
198201

199-
iso_err = bt_iso_chan_connect(channels, ARRAY_SIZE(channels));
202+
connect_param.conn = conn;
203+
connect_param.iso = &iso_chan;
204+
205+
iso_err = bt_iso_chan_connect(&connect_param, ARRAY_SIZE(channels));
200206

201207
if (iso_err) {
202208
printk("Failed to connect iso (%d)\n", iso_err);

0 commit comments

Comments
 (0)