|
25 | 25 | #include <zephyr/bluetooth/conn.h>
|
26 | 26 | #include <zephyr/bluetooth/gatt.h>
|
27 | 27 | #include <zephyr/bluetooth/uuid.h>
|
28 |
| -#include <zephyr/device.h> |
29 | 28 | #include <zephyr/init.h>
|
30 | 29 | #include <zephyr/kernel.h>
|
31 | 30 | #include <zephyr/logging/log.h>
|
|
38 | 37 | #include <zephyr/sys/util.h>
|
39 | 38 | #include <zephyr/sys/util_macro.h>
|
40 | 39 |
|
41 |
| -#include "../host/conn_internal.h" |
42 |
| -#include "../host/hci_core.h" |
| 40 | +#include "host/hci_core.h" |
43 | 41 | #include "common/bt_str.h"
|
44 | 42 |
|
45 | 43 | #include "audio_internal.h"
|
@@ -102,11 +100,11 @@ struct pacs_client {
|
102 | 100 | #endif /* CONFIG_BT_PAC_SRC */
|
103 | 101 |
|
104 | 102 | /* Pending notification flags */
|
105 |
| - ATOMIC_DEFINE(flags, PACS_FLAG_NUM); |
| 103 | + ATOMIC_DEFINE(flags, FLAG_NUM); |
106 | 104 | };
|
107 | 105 |
|
108 | 106 | static struct pacs {
|
109 |
| - ATOMIC_DEFINE(flags, BT_ADV_NUM_FLAGS); |
| 107 | + ATOMIC_DEFINE(flags, PACS_FLAG_NUM); |
110 | 108 |
|
111 | 109 | struct pacs_client clients[CONFIG_BT_MAX_PAIRED];
|
112 | 110 | } pacs;
|
@@ -272,7 +270,7 @@ static ssize_t available_contexts_read(struct bt_conn *conn,
|
272 | 270 | pacs_get_available_contexts_for_conn(conn, BT_AUDIO_DIR_SOURCE)),
|
273 | 271 | };
|
274 | 272 |
|
275 |
| - LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); |
| 273 | + LOG_DBG("conn %p attr %p buf %p len %u offset %u", (void *)conn, attr, buf, len, offset); |
276 | 274 |
|
277 | 275 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &context,
|
278 | 276 | sizeof(context));
|
@@ -317,7 +315,7 @@ static ssize_t supported_context_read(struct bt_conn *conn,
|
317 | 315 | .src = sys_cpu_to_le16(supported_context_get(BT_AUDIO_DIR_SOURCE)),
|
318 | 316 | };
|
319 | 317 |
|
320 |
| - LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); |
| 318 | + LOG_DBG("conn %p attr %p buf %p len %u offset %u", (void *)conn, attr, buf, len, offset); |
321 | 319 |
|
322 | 320 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &context,
|
323 | 321 | sizeof(context));
|
@@ -384,7 +382,7 @@ static ssize_t snk_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
384 | 382 | ssize_t ret_val;
|
385 | 383 | int err;
|
386 | 384 |
|
387 |
| - LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); |
| 385 | + LOG_DBG("conn %p attr %p buf %p len %u offset %u", (void *)conn, attr, buf, len, offset); |
388 | 386 |
|
389 | 387 | err = k_sem_take(&read_buf_sem, READ_BUF_SEM_TIMEOUT);
|
390 | 388 | if (err != 0) {
|
@@ -420,7 +418,7 @@ static ssize_t snk_loc_read(struct bt_conn *conn,
|
420 | 418 | {
|
421 | 419 | uint32_t location = sys_cpu_to_le32(pacs_snk_location);
|
422 | 420 |
|
423 |
| - LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); |
| 421 | + LOG_DBG("conn %p attr %p buf %p len %u offset %u", (void *)conn, attr, buf, len, offset); |
424 | 422 |
|
425 | 423 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &location,
|
426 | 424 | sizeof(location));
|
@@ -491,7 +489,7 @@ static ssize_t src_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
491 | 489 | ssize_t ret_val;
|
492 | 490 | int err;
|
493 | 491 |
|
494 |
| - LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); |
| 492 | + LOG_DBG("conn %p attr %p buf %p len %u offset %u", (void *)conn, attr, buf, len, offset); |
495 | 493 |
|
496 | 494 | err = k_sem_take(&read_buf_sem, READ_BUF_SEM_TIMEOUT);
|
497 | 495 | if (err != 0) {
|
@@ -527,7 +525,7 @@ static ssize_t src_loc_read(struct bt_conn *conn,
|
527 | 525 | {
|
528 | 526 | uint32_t location = sys_cpu_to_le32(pacs_src_location);
|
529 | 527 |
|
530 |
| - LOG_DBG("conn %p attr %p buf %p len %u offset %u", conn, attr, buf, len, offset); |
| 528 | + LOG_DBG("conn %p attr %p buf %p len %u offset %u", (void *)conn, attr, buf, len, offset); |
531 | 529 |
|
532 | 530 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &location,
|
533 | 531 | sizeof(location));
|
@@ -1162,15 +1160,24 @@ static void pacs_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
|
1162 | 1160 | }
|
1163 | 1161 |
|
1164 | 1162 | static void pacs_security_changed(struct bt_conn *conn, bt_security_t level,
|
1165 |
| - enum bt_security_err err) |
| 1163 | + enum bt_security_err sec_err) |
1166 | 1164 | {
|
| 1165 | + struct bt_conn_info info; |
| 1166 | + int err; |
| 1167 | + |
1167 | 1168 | LOG_DBG("%s changed security level to %d", bt_addr_le_str(bt_conn_get_dst(conn)), level);
|
1168 | 1169 |
|
1169 |
| - if (err != 0 || conn->encrypt == 0) { |
| 1170 | + if (sec_err != BT_SECURITY_ERR_SUCCESS || level <= BT_SECURITY_L1) { |
| 1171 | + return; |
| 1172 | + } |
| 1173 | + |
| 1174 | + err = bt_conn_get_info(conn, &info); |
| 1175 | + if (err < 0) { |
| 1176 | + __ASSERT_NO_MSG(false); |
1170 | 1177 | return;
|
1171 | 1178 | }
|
1172 | 1179 |
|
1173 |
| - if (!bt_addr_le_is_bonded(conn->id, &conn->le.dst)) { |
| 1180 | + if (!bt_addr_le_is_bonded(info.id, info.le.dst)) { |
1174 | 1181 | return;
|
1175 | 1182 | }
|
1176 | 1183 |
|
@@ -1225,7 +1232,7 @@ static void pacs_disconnected(struct bt_conn *conn, uint8_t reason)
|
1225 | 1232 | #endif /* CONFIG_BT_PAC_SRC */
|
1226 | 1233 | }
|
1227 | 1234 |
|
1228 |
| -static struct bt_conn_cb conn_callbacks = { |
| 1235 | +BT_CONN_CB_DEFINE(conn_callbacks) = { |
1229 | 1236 | .security_changed = pacs_security_changed,
|
1230 | 1237 | .disconnected = pacs_disconnected,
|
1231 | 1238 | };
|
@@ -1295,7 +1302,6 @@ int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
|
1295 | 1302 | sys_slist_append(pac, &cap->_node);
|
1296 | 1303 |
|
1297 | 1304 | if (!callbacks_registered) {
|
1298 |
| - bt_conn_cb_register(&conn_callbacks); |
1299 | 1305 | bt_conn_auth_info_cb_register(&auth_callbacks);
|
1300 | 1306 |
|
1301 | 1307 | callbacks_registered = true;
|
|
0 commit comments