|
7 | 7 | */ |
8 | 8 |
|
9 | 9 | #include <stddef.h> |
| 10 | +#include <stdint.h> |
10 | 11 | #include <errno.h> |
11 | 12 |
|
| 13 | +#include <zephyr/bluetooth/addr.h> |
12 | 14 | #include <zephyr/bluetooth/audio/bap.h> |
13 | 15 | #include <zephyr/bluetooth/bluetooth.h> |
14 | 16 | #include <zephyr/bluetooth/conn.h> |
15 | 17 | #include <zephyr/bluetooth/iso.h> |
| 18 | +#include <zephyr/sys/__assert.h> |
16 | 19 | #include <zephyr/types.h> |
17 | 20 | #include <zephyr/kernel.h> |
18 | 21 | #include <zephyr/sys/ring_buffer.h> |
@@ -168,6 +171,37 @@ static void btp_send_ascs_ase_state_changed_ev(struct bt_conn *conn, uint8_t ase |
168 | 171 | tester_event(BTP_SERVICE_ID_ASCS, BTP_ASCS_EV_ASE_STATE_CHANGED, &ev, sizeof(ev)); |
169 | 172 | } |
170 | 173 |
|
| 174 | +static void btp_send_ascs_cis_connected_ev(const struct bt_bap_stream *stream) |
| 175 | +{ |
| 176 | + struct btp_bap_unicast_stream *u_stream; |
| 177 | + struct btp_ascs_cis_connected_ev ev; |
| 178 | + |
| 179 | + u_stream = stream_bap_to_unicast(stream); |
| 180 | + __ASSERT(u_stream != NULL, "Failed to get unicast_stream from %p", stream); |
| 181 | + |
| 182 | + bt_addr_le_copy(&ev.address, bt_conn_get_dst(stream->conn)); |
| 183 | + ev.ase_id = u_stream->ase_id; |
| 184 | + ev.cis_id = u_stream->cis_id; |
| 185 | + |
| 186 | + tester_event(BTP_SERVICE_ID_ASCS, BTP_ASCS_EV_CIS_CONNECTED, &ev, sizeof(ev)); |
| 187 | +} |
| 188 | + |
| 189 | +static void btp_send_ascs_cis_disconnected_ev(const struct bt_bap_stream *stream, uint8_t reason) |
| 190 | +{ |
| 191 | + struct btp_bap_unicast_stream *u_stream; |
| 192 | + struct btp_ascs_cis_disconnected_ev ev; |
| 193 | + |
| 194 | + u_stream = stream_bap_to_unicast(stream); |
| 195 | + __ASSERT(u_stream != NULL, "Failed to get unicast_stream from %p", stream); |
| 196 | + |
| 197 | + bt_addr_le_copy(&ev.address, bt_conn_get_dst(stream->conn)); |
| 198 | + ev.ase_id = u_stream->ase_id; |
| 199 | + ev.cis_id = u_stream->cis_id; |
| 200 | + ev.reason = reason; |
| 201 | + |
| 202 | + tester_event(BTP_SERVICE_ID_ASCS, BTP_ASCS_EV_CIS_DISCONNECTED, &ev, sizeof(ev)); |
| 203 | +} |
| 204 | + |
171 | 205 | static void btp_send_ascs_operation_completed_ev(struct bt_conn *conn, uint8_t ase_id, |
172 | 206 | uint8_t opcode, uint8_t status) |
173 | 207 | { |
@@ -669,6 +703,15 @@ static void stream_connected_cb(struct bt_bap_stream *stream) |
669 | 703 | BTP_ASCS_STATUS_SUCCESS); |
670 | 704 | } |
671 | 705 | } |
| 706 | + |
| 707 | + btp_send_ascs_cis_connected_ev(stream); |
| 708 | +} |
| 709 | + |
| 710 | +static void stream_disconnected_cb(struct bt_bap_stream *stream, uint8_t reason) |
| 711 | +{ |
| 712 | + LOG_DBG("Disconnected stream %p: 0x%02X", stream, reason); |
| 713 | + |
| 714 | + btp_send_ascs_cis_disconnected_ev(stream, reason); |
672 | 715 | } |
673 | 716 |
|
674 | 717 | static void stream_stopped_cb(struct bt_bap_stream *stream, uint8_t reason) |
@@ -749,6 +792,7 @@ static struct bt_bap_stream_ops stream_ops = { |
749 | 792 | .recv = stream_recv_cb, |
750 | 793 | .sent = btp_bap_audio_stream_sent_cb, |
751 | 794 | .connected = stream_connected_cb, |
| 795 | + .disconnected = stream_disconnected_cb, |
752 | 796 | }; |
753 | 797 |
|
754 | 798 | struct btp_bap_unicast_stream *btp_bap_unicast_stream_alloc( |
|
0 commit comments