mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(ble_audio): Support running ISO & LE Audio with Bluedroid Host
This commit is contained in:
@@ -517,8 +517,11 @@ void bt_le_gap_handle_event(uint8_t *data, size_t data_len)
|
||||
|
||||
void bt_le_gap_app_post_event(uint8_t type, void *param)
|
||||
{
|
||||
/* Currently type is not used */
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* For Bluedroid, post the typed event to the ISO task instead. */
|
||||
bt_le_bluedroid_gap_post_event(type, param);
|
||||
#else
|
||||
ARG_UNUSED(type);
|
||||
|
||||
bt_le_nimble_gap_post_event(param);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ void bt_le_gatts_app_subscribe_event(struct bt_le_gatts_subscribe_event *param)
|
||||
bt_le_gatt_app_cb_evt(&event);
|
||||
}
|
||||
|
||||
#if !CONFIG_BT_BLUEDROID_ENABLED
|
||||
void bt_le_gatt_app_post_event(uint8_t type, void *param)
|
||||
{
|
||||
/* Currently type is not used */
|
||||
@@ -113,3 +114,24 @@ void bt_le_gatt_app_post_event(uint8_t type, void *param)
|
||||
|
||||
bt_le_nimble_gatt_post_event(param);
|
||||
}
|
||||
#endif /* !CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* Bluedroid-only: GATTC open completion carries the BTA gattc_if, which has
|
||||
* no NimBLE analogue. MTU and disc-cmpl events reuse the host-agnostic
|
||||
* helpers above (bt_le_gatt_app_mtu_change_event / bt_le_gattc_app_disc_cmpl_event). */
|
||||
void bt_le_gattc_app_open_event(struct bt_le_gattc_open_event *param, uint8_t gattc_if)
|
||||
{
|
||||
struct bt_le_gatt_app_event event = {
|
||||
.type = BT_LE_GATT_APP_EVENT_GATTC_OPEN,
|
||||
};
|
||||
|
||||
LOG_DBG("GattcOpenAppEvt[%u][%02x][%u]", param->conn_handle, param->status, gattc_if);
|
||||
|
||||
event.gattc_open.status = param->status;
|
||||
event.gattc_open.conn_handle = param->conn_handle;
|
||||
event.gattc_open.gattc_if = gattc_if;
|
||||
|
||||
bt_le_gatt_app_cb_evt(&event);
|
||||
}
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
@@ -382,11 +382,12 @@ int bt_le_acl_conn_delete(uint16_t conn_handle)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
||||
LOG_DBG("AclConnDel[%u]", conn_handle);
|
||||
LOG_INF("AclConnDel[%u]", conn_handle);
|
||||
|
||||
/* disconnected_listener already flipped state to DISCONNECTED. */
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
if (conn == NULL || conn->state != BT_CONN_DISCONNECTED) {
|
||||
LOG_ERR("AclConnDelNotDisc[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -406,7 +407,7 @@ int bt_le_acl_conn_update(uint16_t conn_handle,
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("AclConnUpdNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -543,7 +544,7 @@ int bt_le_acl_conn_connected_listener(uint16_t conn_handle)
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("AclConnConnectedListenerNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -566,10 +567,15 @@ int bt_le_acl_conn_disconnected_listener(uint16_t conn_handle, uint8_t reason)
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("AclConnDisconnectedListenerNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
/* Flip before dispatch — lib disconnect cbs guard late notifies on
|
||||
* bt_conn_get_info().state. Otherwise BTA queues the send and the conn
|
||||
* is gone by the time BTU drains it ("Unknown connection ID"). */
|
||||
conn->state = BT_CONN_DISCONNECTED;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&conn_cbs, listener, _node) {
|
||||
if (listener->disconnected) {
|
||||
listener->disconnected(conn, reason);
|
||||
@@ -593,7 +599,7 @@ int bt_le_acl_conn_security_changed_listener(uint16_t conn_handle, bt_security_t
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("AclConnSecChgListenerNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -621,7 +627,7 @@ int bt_le_acl_conn_identity_resolved_listener(uint16_t conn_handle,
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("AclConnIdResolvedListenerNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -644,7 +650,7 @@ int bt_le_acl_conn_pairing_completed_listener(uint16_t conn_handle, bool bonded)
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("AclConnPairingCompletedListenerNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,11 @@ uint16_t bt_gatt_get_mtu(struct bt_conn *conn)
|
||||
|
||||
assert(conn);
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
mtu = bt_le_bluedroid_gatt_get_mtu(conn);
|
||||
#else
|
||||
mtu = bt_le_nimble_gatt_get_mtu(conn);
|
||||
#endif
|
||||
|
||||
LOG_DBG("GattGetMtu[%u]", mtu);
|
||||
|
||||
@@ -141,13 +145,12 @@ uint16_t bt_gatt_attr_get_handle(const struct bt_gatt_attr *attr)
|
||||
{
|
||||
uint16_t handle = 0;
|
||||
|
||||
LOG_DBG("GattAttrGetHdl");
|
||||
|
||||
if (attr && attr->handle) {
|
||||
handle = attr->handle;
|
||||
}
|
||||
|
||||
LOG_DBG("Hdl[%u]", handle);
|
||||
LOG_DBG("GattAttrGetHdl[%u]", handle);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -162,32 +165,29 @@ uint16_t bt_gatt_attr_value_handle(const struct bt_gatt_attr *attr)
|
||||
* Currently this function is only used by TMAP.
|
||||
*/
|
||||
|
||||
LOG_DBG("GattAttrValHdl");
|
||||
|
||||
if (attr) {
|
||||
LOG_DBG("GattAttrUuid[%s]", attr->uuid ? bt_uuid_str(attr->uuid) : "Null");
|
||||
|
||||
if (attr->uuid == NULL) {
|
||||
handle = (attr->handle + 1);
|
||||
} else {
|
||||
LOG_DBG("Uuid[%s]", bt_uuid_str(attr->uuid));
|
||||
|
||||
if (bt_uuid_cmp(attr->uuid, BT_UUID_GATT_CHRC) == 0) {
|
||||
struct bt_gatt_chrc *chrc = attr->user_data;
|
||||
|
||||
assert(chrc);
|
||||
handle = chrc->value_handle;
|
||||
|
||||
LOG_DBG("ValHdl[%u]", handle);
|
||||
|
||||
if (handle == 0) {
|
||||
/* Fall back to Zephyr value handle policy */
|
||||
handle = bt_gatt_attr_get_handle(attr) + 1;
|
||||
LOG_INF("ValHdlNew[%u]", handle);
|
||||
LOG_INF("GattAttrValHdlNew[%u]", handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DBG("Hdl[%u]", handle);
|
||||
LOG_DBG("GattAttrValHdl[%u]", handle);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -401,8 +401,13 @@ ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gatts_attr_read(conn, attr, buf, buf_len,
|
||||
offset, value, value_len);
|
||||
#else
|
||||
return bt_le_nimble_gatts_attr_read(conn, attr, buf, buf_len,
|
||||
offset, value, value_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIB_ONLY
|
||||
@@ -415,11 +420,15 @@ int bt_gatt_notify_cb(struct bt_conn *conn, struct bt_gatt_notify_params *params
|
||||
LOG_DBG("GattNtfCb[%u]", params->len);
|
||||
|
||||
if (conn && conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattNtfNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
err = bt_le_bluedroid_gatts_notify(conn, params);
|
||||
#else
|
||||
err = bt_le_nimble_gatts_notify(conn, params);
|
||||
#endif
|
||||
|
||||
/* gatts_notify is synchronous (mbuf-copy + dispatch on return); fire the
|
||||
* caller's completion cb here so state machines like PACS_FLAG_NOTIFY_RDY
|
||||
@@ -440,7 +449,7 @@ int bt_gatt_indicate(struct bt_conn *conn, struct bt_gatt_indicate_params *param
|
||||
LOG_DBG("GattInd[%s]", bt_uuid_str(params->attr->uuid));
|
||||
|
||||
if (conn && conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattIndNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -454,7 +463,11 @@ int bt_gatt_indicate(struct bt_conn *conn, struct bt_gatt_indicate_params *param
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gatts_indicate(conn, params);
|
||||
#else
|
||||
return bt_le_nimble_gatts_indicate(conn, params);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIB_IDF
|
||||
@@ -774,7 +787,8 @@ bool bt_gatt_is_subscribed(struct bt_conn *conn,
|
||||
LOG_DBG("GattIsSub[%04x][%s]", ccc_type, bt_uuid_str(attr->uuid));
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
/* Query — disconnected conn is "not subscribed", not an error. */
|
||||
LOG_INF("GattIsSubNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -952,7 +966,7 @@ int bt_gatts_sub_changed(uint16_t conn_handle,
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattsSubChgNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -975,7 +989,11 @@ int bt_gattc_disc_start_safe(uint16_t conn_handle)
|
||||
int err;
|
||||
LOG_DBG("GattcDiscStart[%u]", conn_handle);
|
||||
bt_le_host_lock();
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
err = bt_le_bluedroid_gattc_disc_start(conn_handle);
|
||||
#else
|
||||
err = bt_le_nimble_gattc_disc_start(conn_handle);
|
||||
#endif
|
||||
bt_le_host_unlock();
|
||||
return err;
|
||||
}
|
||||
@@ -991,7 +1009,7 @@ int bt_gatt_discover(struct bt_conn *conn, struct bt_gatt_discover_params *param
|
||||
LOG_DBG("GattDisc[%u][%u]", params->start_handle, params->end_handle);
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattDiscNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -1000,7 +1018,11 @@ int bt_gatt_discover(struct bt_conn *conn, struct bt_gatt_discover_params *param
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gattc_discover(conn, params);
|
||||
#else
|
||||
return bt_le_nimble_gattc_discover(conn, params);
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct gattc_sub *gattc_sub_find(struct bt_conn *conn)
|
||||
@@ -1141,7 +1163,11 @@ static int gattc_write_ccc(struct bt_conn *conn, struct bt_gatt_subscribe_params
|
||||
{
|
||||
LOG_DBG("GattcWrCcc[%u][%04x]", params->ccc_handle, params->value);
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gattc_write_ccc(conn, params);
|
||||
#else
|
||||
return bt_le_nimble_gattc_write_ccc(conn, params);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIB_ONLY
|
||||
@@ -1167,7 +1193,7 @@ int bt_gatt_subscribe(struct bt_conn *conn, struct bt_gatt_subscribe_params *par
|
||||
* can resubscribe.
|
||||
*/
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattSubNotConn[%u][%u]", conn->handle, conn->state);
|
||||
params->value_handle = 0; /* unlinked: clear retry guard */
|
||||
return -ENOTCONN;
|
||||
}
|
||||
@@ -1251,7 +1277,7 @@ int bt_gatt_unsubscribe(struct bt_conn *conn, struct bt_gatt_subscribe_params *p
|
||||
params->value, params->value_handle, params->ccc_handle, params->end_handle);
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattUnsubNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -1327,7 +1353,7 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params)
|
||||
LOG_DBG("GattRd[%u]", params->handle_count);
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattRdNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -1345,7 +1371,11 @@ int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params)
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gattc_read(conn, params);
|
||||
#else
|
||||
return bt_le_nimble_gattc_read(conn, params);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIB_IDF
|
||||
@@ -1360,7 +1390,7 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params)
|
||||
LOG_DBG("GattWr[%u][%u][%u]", params->handle, params->length, params->offset);
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattWrNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -1369,7 +1399,11 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params)
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gattc_write(conn, params);
|
||||
#else
|
||||
return bt_le_nimble_gattc_write(conn, params);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIB_ONLY
|
||||
@@ -1388,7 +1422,7 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
|
||||
LOG_DBG("GattWrCmd[%u][%u][%u]", handle, length, sign);
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_ERR("GattWrCmdNotConn[%u][%u]", conn->handle, conn->state);
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
@@ -1397,7 +1431,11 @@ int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_gattc_write_without_rsp(conn, handle, data, length);
|
||||
#else
|
||||
return bt_le_nimble_gattc_write_without_rsp(conn, handle, data, length);
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIB_ONLY
|
||||
@@ -1407,6 +1445,7 @@ void bt_le_acl_conn_disconnected_gatt_listener(uint16_t conn_handle)
|
||||
|
||||
LOG_DBG("AclConnDisconnectedGattListener[%u]", conn_handle);
|
||||
|
||||
#if !CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_le_nimble_gatt_nrp_clear(conn_handle);
|
||||
|
||||
/* Drop the cached GATT client database so the next connection runs a
|
||||
@@ -1420,10 +1459,12 @@ void bt_le_acl_conn_disconnected_gatt_listener(uint16_t conn_handle)
|
||||
* and Service Changed handling end-to-end.
|
||||
*/
|
||||
bt_le_nimble_gattc_db_remove(conn_handle);
|
||||
#endif
|
||||
|
||||
/* The cached DB is dropped above, so the app will rediscover and call
|
||||
* bt_gatt_subscribe() again on reconnect with the BAP library's reused
|
||||
* `bt_gatt_subscribe_params` pointers. Drop those nodes from the
|
||||
/* On NimBLE the cached DB was dropped above; on Bluedroid no client-side
|
||||
* DB cache cleanup is performed here. Either way the app will rediscover
|
||||
* and call bt_gatt_subscribe() again on reconnect with the BAP library's
|
||||
* reused `bt_gatt_subscribe_params` pointers. Drop those nodes from the
|
||||
* tracking list (and zero their value) so the duplicate check in
|
||||
* bt_gatt_subscribe() doesn't short-circuit with -EALREADY, which
|
||||
* would otherwise skip the CCCD write and starve notifications.
|
||||
@@ -1438,5 +1479,9 @@ void bt_le_gatt_handle_event(uint8_t *data, size_t data_len)
|
||||
{
|
||||
assert(data && data_len);
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_le_bluedroid_gatt_handle_event(data, data_len);
|
||||
#else
|
||||
bt_le_nimble_gatt_handle_event(data, data_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -70,5 +70,9 @@ int bt_hci_cmd_send_sync(uint16_t opcode,
|
||||
{
|
||||
LOG_DBG("HciCmdSendSync[%04x]", opcode);
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_hci_iso_cmd_send_sync(opcode, buf, rsp);
|
||||
#else
|
||||
return bt_le_nimble_iso_cmd_send_sync(opcode, buf, rsp);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
#include "common/app/gap.h"
|
||||
#include "common/app/gatt.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "bluedroid/gap.h"
|
||||
#include "bluedroid/gatt.h"
|
||||
#endif
|
||||
|
||||
LOG_MODULE_REGISTER(ISO_HOST, CONFIG_BT_ISO_LOG_LEVEL);
|
||||
|
||||
static struct k_mutex host_mutex;
|
||||
|
||||
#define TIMEOUT_MS (5000 / portTICK_PERIOD_MS) /* 5s */
|
||||
|
||||
#if HOST_LOCK_DEBUG
|
||||
void bt_le_host_lock_debug(const char *func, int line)
|
||||
#else /* HOST_LOCK_DEBUG */
|
||||
@@ -31,9 +34,9 @@ void bt_le_host_lock(void)
|
||||
{
|
||||
/* LOG_DBG("%s: %d", func, line); */
|
||||
|
||||
int err = k_mutex_lock(&host_mutex, TIMEOUT_MS);
|
||||
int err = k_mutex_lock(&host_mutex, K_MUTEX_SHORT);
|
||||
if (err) {
|
||||
/* 5s wait failed: the host stack is wedged. k_mutex_lock has
|
||||
/* K_MUTEX_SHORT wait failed: the host stack is wedged. k_mutex_lock has
|
||||
* already logged self/holder task names. Use libc abort() rather
|
||||
* than assert(0) — assert is a no-op under NDEBUG, which would
|
||||
* let the caller enter the critical section without the mutex
|
||||
@@ -84,11 +87,23 @@ int bt_le_host_init(void)
|
||||
}
|
||||
#endif /* CONFIG_BT_OTS || CONFIG_BT_OTS_CLIENT */
|
||||
|
||||
err = bt_le_iso_init();
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
err = bt_le_bluedroid_gap_init();
|
||||
if (err) {
|
||||
goto deinit_l2cap;
|
||||
}
|
||||
|
||||
err = bt_le_bluedroid_gatt_init();
|
||||
if (err) {
|
||||
goto deinit_bluedroid_gatt;
|
||||
}
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
err = bt_le_iso_init();
|
||||
if (err) {
|
||||
goto deinit_bluedroid_gatt;
|
||||
}
|
||||
|
||||
err = bt_le_iso_task_init();
|
||||
if (err) {
|
||||
goto deinit_iso;
|
||||
@@ -98,7 +113,11 @@ int bt_le_host_init(void)
|
||||
|
||||
deinit_iso:
|
||||
bt_le_iso_deinit();
|
||||
deinit_bluedroid_gatt:
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_le_bluedroid_gatt_deinit();
|
||||
deinit_l2cap:
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
#if CONFIG_BT_OTS || CONFIG_BT_OTS_CLIENT
|
||||
bt_le_l2cap_deinit();
|
||||
deinit_scan: /* only reachable when OTS path is compiled in */
|
||||
@@ -116,6 +135,9 @@ void bt_le_host_deinit(void)
|
||||
|
||||
bt_le_iso_task_deinit();
|
||||
bt_le_iso_deinit();
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_le_bluedroid_gatt_deinit();
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
#if CONFIG_BT_OTS || CONFIG_BT_OTS_CLIENT
|
||||
bt_le_l2cap_deinit();
|
||||
#endif /* CONFIG_BT_OTS || CONFIG_BT_OTS_CLIENT */
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "bluedroid/gap.h"
|
||||
#else
|
||||
#include "nimble/gap.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* ref bluedroid/app/gatt.h was an empty header; nothing to include here. */
|
||||
#else
|
||||
#include "nimble/gatt.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -37,6 +41,14 @@ struct bt_le_gatt_app_event_gatts_subscribe {
|
||||
uint8_t reason;
|
||||
};
|
||||
|
||||
/* Bluedroid-only: surfaces the GATTC open completion (carries the gattc_if
|
||||
* the BTA dispatcher used, which NimBLE has no analogue of). */
|
||||
struct bt_le_gatt_app_event_gattc_open {
|
||||
uint8_t status;
|
||||
uint16_t conn_handle;
|
||||
uint8_t gattc_if;
|
||||
};
|
||||
|
||||
struct bt_le_gatt_app_event {
|
||||
uint8_t type;
|
||||
|
||||
@@ -44,6 +56,7 @@ struct bt_le_gatt_app_event {
|
||||
struct bt_le_gatt_app_event_gatt_mtu_change gatt_mtu_change;
|
||||
struct bt_le_gatt_app_event_gattc_disc_cmpl gattc_disc_cmpl;
|
||||
struct bt_le_gatt_app_event_gatts_subscribe gatts_subscribe;
|
||||
struct bt_le_gatt_app_event_gattc_open gattc_open;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -51,6 +64,7 @@ enum bt_le_gatt_app_event_type {
|
||||
BT_LE_GATT_APP_EVENT_GATT_MTU_CHANGE,
|
||||
BT_LE_GATT_APP_EVENT_GATTC_DISC_CMPL,
|
||||
BT_LE_GATT_APP_EVENT_GATTS_SUBSCRIBE,
|
||||
BT_LE_GATT_APP_EVENT_GATTC_OPEN,
|
||||
|
||||
BT_LE_GATT_APP_EVENT_MAX,
|
||||
};
|
||||
@@ -67,7 +81,18 @@ void bt_le_gattc_app_disc_cmpl_event(struct bt_le_gattc_disc_cmpl_event *param);
|
||||
|
||||
void bt_le_gatts_app_subscribe_event(struct bt_le_gatts_subscribe_event *param);
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
void bt_le_gattc_app_open_event(struct bt_le_gattc_open_event *param, uint8_t gattc_if);
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
#if !CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* NimBLE-only: callers post the raw ble_gap_event so the adapter can
|
||||
* translate it into the host-agnostic bt_le_gatt_app_event. Bluedroid has
|
||||
* no analogous app-level event stream (BTA dispatches directly to BTC),
|
||||
* so this is hidden from the API surface to make misuse a compile error.
|
||||
*/
|
||||
void bt_le_gatt_app_post_event(uint8_t type, void *param);
|
||||
#endif /* !CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -13,13 +13,21 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* TODO */
|
||||
#else
|
||||
#include "nimble/gap.h"
|
||||
#include "nimble/iso.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 0xff is out of bt_conn_state_t range — distinguishes NULL conn from any
|
||||
* real state in logs. */
|
||||
#define BT_CONN_STATE_GET(_c) ((_c) ? (_c)->state : 0xff)
|
||||
|
||||
void bt_conn_get_acl_conns(struct bt_conn **conns, uint8_t *count);
|
||||
|
||||
struct bt_conn *bt_le_acl_conn_find(uint16_t conn_handle);
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
#include <zephyr/autoconf.h>
|
||||
#include <zephyr/bluetooth/gatt.h>
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "bluedroid/gatt.h"
|
||||
#else
|
||||
#include "nimble/gatt.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -73,16 +77,115 @@ struct bt_le_gatts_notify_tx_event {
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
/* Bluedroid-side adapter events. NimBLE produces ACL connect/disconnect via
|
||||
* the GAP event path (BT_LE_GAP_APP_PARAM_ACL_*), but Bluedroid's BTA
|
||||
* surfaces these through GATTS/GATTC callbacks. The bluedroid adapter posts
|
||||
* these typed events into the iso task and translates them into ACL/MTU/
|
||||
* discovery events for the LE Audio profile dispatcher. */
|
||||
|
||||
struct bt_le_addr_simple {
|
||||
uint8_t type;
|
||||
uint8_t val[6];
|
||||
};
|
||||
|
||||
struct bt_le_gattc_connect_event {
|
||||
uint16_t conn_handle;
|
||||
uint8_t role;
|
||||
struct bt_le_addr_simple peer;
|
||||
};
|
||||
|
||||
struct bt_le_gattc_disconnect_event {
|
||||
uint16_t conn_handle;
|
||||
uint8_t reason;
|
||||
};
|
||||
|
||||
struct bt_le_gattc_open_event {
|
||||
uint8_t status;
|
||||
uint16_t conn_handle;
|
||||
};
|
||||
|
||||
struct bt_le_gattc_mtu_event {
|
||||
uint8_t status;
|
||||
uint16_t conn_handle;
|
||||
uint16_t mtu;
|
||||
};
|
||||
|
||||
struct bt_le_gattc_read_chrc_event {
|
||||
uint8_t status;
|
||||
uint16_t conn_handle;
|
||||
uint16_t attr_handle;
|
||||
uint16_t len;
|
||||
uint8_t *value;
|
||||
};
|
||||
|
||||
struct bt_le_gattc_write_chrc_event {
|
||||
uint8_t status;
|
||||
uint16_t conn_handle;
|
||||
uint16_t attr_handle;
|
||||
uint16_t offset;
|
||||
};
|
||||
|
||||
struct bt_le_gatts_connect_event {
|
||||
uint16_t conn_handle;
|
||||
uint8_t role;
|
||||
struct bt_le_addr_simple peer;
|
||||
};
|
||||
|
||||
struct bt_le_gatts_disconnect_event {
|
||||
uint16_t conn_handle;
|
||||
uint8_t reason;
|
||||
};
|
||||
|
||||
struct bt_le_gatts_mtu_event {
|
||||
uint16_t conn_handle;
|
||||
uint16_t mtu;
|
||||
};
|
||||
|
||||
struct bt_le_gatts_read_event {
|
||||
uint16_t conn_handle;
|
||||
uint32_t trans_id;
|
||||
uint8_t peer[6];
|
||||
uint16_t attr_handle;
|
||||
uint16_t offset;
|
||||
bool is_long;
|
||||
bool need_rsp;
|
||||
};
|
||||
|
||||
struct bt_le_gatts_write_event {
|
||||
uint16_t conn_handle;
|
||||
uint32_t trans_id;
|
||||
uint8_t peer[6];
|
||||
uint16_t attr_handle;
|
||||
uint16_t offset;
|
||||
bool is_prep;
|
||||
bool need_rsp;
|
||||
uint16_t len;
|
||||
uint8_t *value;
|
||||
};
|
||||
|
||||
struct bt_le_gatt_event_param {
|
||||
uint8_t type;
|
||||
|
||||
union {
|
||||
struct bt_le_gatt_mtu_change_event gatt_mtu_change;
|
||||
struct bt_le_gattc_discover_event gattc_discover;
|
||||
struct bt_le_gattc_disc_cmpl_event gattc_disc_cmpl;
|
||||
struct bt_le_gatts_subscribe_event gatts_subscribe;
|
||||
struct bt_le_gattc_notify_rx_event gattc_notify_rx;
|
||||
struct bt_le_gatts_notify_tx_event gatts_notify_tx;
|
||||
struct bt_le_gatt_mtu_change_event gatt_mtu_change;
|
||||
struct bt_le_gattc_discover_event gattc_discover;
|
||||
struct bt_le_gattc_disc_cmpl_event gattc_disc_cmpl;
|
||||
struct bt_le_gatts_subscribe_event gatts_subscribe;
|
||||
struct bt_le_gattc_notify_rx_event gattc_notify_rx;
|
||||
struct bt_le_gatts_notify_tx_event gatts_notify_tx;
|
||||
|
||||
/* Bluedroid-only paths (see comment above). */
|
||||
struct bt_le_gattc_connect_event gattc_connect;
|
||||
struct bt_le_gattc_disconnect_event gattc_disconnect;
|
||||
struct bt_le_gattc_open_event gattc_open;
|
||||
struct bt_le_gattc_mtu_event gattc_mtu;
|
||||
struct bt_le_gattc_read_chrc_event gattc_read_chrc;
|
||||
struct bt_le_gattc_write_chrc_event gattc_write_chrc;
|
||||
struct bt_le_gatts_connect_event gatts_connect;
|
||||
struct bt_le_gatts_disconnect_event gatts_disconnect;
|
||||
struct bt_le_gatts_mtu_event gatts_mtu;
|
||||
struct bt_le_gatts_read_event gatts_read;
|
||||
struct bt_le_gatts_write_event gatts_write;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -94,231 +197,22 @@ enum {
|
||||
BT_LE_GATTC_NOTIFY_RX_EVENT,
|
||||
BT_LE_GATTS_NOTIFY_TX_EVENT,
|
||||
|
||||
/* Bluedroid-only paths (see comment above). */
|
||||
BT_LE_GATTC_CONNECT_EVENT,
|
||||
BT_LE_GATTC_DISCONNECT_EVENT,
|
||||
BT_LE_GATTC_OPEN_EVENT,
|
||||
BT_LE_GATTC_MTU_EVENT,
|
||||
BT_LE_GATTC_READ_CHRC_EVENT,
|
||||
BT_LE_GATTC_WRITE_CHRC_EVENT,
|
||||
BT_LE_GATTS_CONNECT_EVENT,
|
||||
BT_LE_GATTS_DISCONNECT_EVENT,
|
||||
BT_LE_GATTS_MTU_EVENT,
|
||||
BT_LE_GATTS_READ_EVENT,
|
||||
BT_LE_GATTS_WRITE_EVENT,
|
||||
|
||||
BT_LE_GATT_EVENT_MAX,
|
||||
};
|
||||
|
||||
static inline char *audio_svc_uuid_to_str(uint16_t uuid)
|
||||
{
|
||||
switch (uuid) {
|
||||
case BT_UUID_GAP_VAL:
|
||||
return "GAP";
|
||||
case BT_UUID_GATT_VAL:
|
||||
return "GATT";
|
||||
case BT_UUID_AICS_VAL:
|
||||
return "AICS";
|
||||
case BT_UUID_CAS_VAL:
|
||||
return "CAS";
|
||||
case BT_UUID_VCS_VAL:
|
||||
return "VCS";
|
||||
case BT_UUID_VOCS_VAL:
|
||||
return "VOCS";
|
||||
case BT_UUID_CSIS_VAL:
|
||||
return "CSIS";
|
||||
case BT_UUID_MCS_VAL:
|
||||
return "MCS";
|
||||
case BT_UUID_GMCS_VAL:
|
||||
return "GMCS";
|
||||
case BT_UUID_TBS_VAL:
|
||||
return "TBS";
|
||||
case BT_UUID_GTBS_VAL:
|
||||
return "GTBS";
|
||||
case BT_UUID_MICS_VAL:
|
||||
return "MICS";
|
||||
case BT_UUID_ASCS_VAL:
|
||||
return "ASCS";
|
||||
case BT_UUID_BASS_VAL:
|
||||
return "BASS";
|
||||
case BT_UUID_PACS_VAL:
|
||||
return "PACS";
|
||||
case BT_UUID_BASIC_AUDIO_VAL:
|
||||
return "BASIC_AUDIO";
|
||||
case BT_UUID_HAS_VAL:
|
||||
return "HAS";
|
||||
case BT_UUID_TMAS_VAL:
|
||||
return "TMAS";
|
||||
case BT_UUID_PBA_VAL:
|
||||
return "PBA";
|
||||
case BT_UUID_GMAS_VAL:
|
||||
return "GMAS";
|
||||
case BT_UUID_OTS_VAL:
|
||||
return "OTS";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static inline char *audio_chrc_uuid_to_str(uint16_t uuid)
|
||||
{
|
||||
switch (uuid) {
|
||||
case BT_UUID_OTS_FEATURE_VAL:
|
||||
return "OTS_FEATURE";
|
||||
case BT_UUID_OTS_NAME_VAL:
|
||||
return "OTS_NAME";
|
||||
case BT_UUID_OTS_TYPE_VAL:
|
||||
return "OTS_TYPE";
|
||||
case BT_UUID_OTS_SIZE_VAL:
|
||||
return "OTS_SIZE";
|
||||
case BT_UUID_OTS_FIRST_CREATED_VAL:
|
||||
return "OTS_FIRST_CREATED";
|
||||
case BT_UUID_OTS_LAST_MODIFIED_VAL:
|
||||
return "OTS_LAST_MODIFIED";
|
||||
case BT_UUID_OTS_ID_VAL:
|
||||
return "OTS_ID";
|
||||
case BT_UUID_OTS_PROPERTIES_VAL:
|
||||
return "OTS_PROPERTIES";
|
||||
case BT_UUID_OTS_ACTION_CP_VAL:
|
||||
return "OTS_ACTION_CP";
|
||||
case BT_UUID_OTS_LIST_CP_VAL:
|
||||
return "OTS_LIST_CP";
|
||||
case BT_UUID_OTS_LIST_FILTER_VAL:
|
||||
return "OTS_LIST_FILTER";
|
||||
case BT_UUID_OTS_CHANGED_VAL:
|
||||
return "OTS_CHANGED";
|
||||
case BT_UUID_GATT_TMAPR_VAL:
|
||||
return "TMAP_ROLE";
|
||||
case BT_UUID_AICS_STATE_VAL:
|
||||
return "AICS_STATE";
|
||||
case BT_UUID_AICS_GAIN_SETTINGS_VAL:
|
||||
return "AICS_GAIN_SETTINGS";
|
||||
case BT_UUID_AICS_INPUT_TYPE_VAL:
|
||||
return "AICS_INPUT_TYPE";
|
||||
case BT_UUID_AICS_INPUT_STATUS_VAL:
|
||||
return "AICS_INPUT_STATUS";
|
||||
case BT_UUID_AICS_CONTROL_VAL:
|
||||
return "AICS_CONTROL";
|
||||
case BT_UUID_AICS_DESCRIPTION_VAL:
|
||||
return "AICS_DESCRIPTION";
|
||||
case BT_UUID_VCS_STATE_VAL:
|
||||
return "VCS_STATE";
|
||||
case BT_UUID_VCS_CONTROL_VAL:
|
||||
return "VCS_CONTROL";
|
||||
case BT_UUID_VCS_FLAGS_VAL:
|
||||
return "VCS_FLAGS";
|
||||
case BT_UUID_VOCS_STATE_VAL:
|
||||
return "VOCS_STATE";
|
||||
case BT_UUID_VOCS_LOCATION_VAL:
|
||||
return "VOCS_LOCATION";
|
||||
case BT_UUID_VOCS_CONTROL_VAL:
|
||||
return "VOCS_CONTROL";
|
||||
case BT_UUID_VOCS_DESCRIPTION_VAL:
|
||||
return "VOCS_DESCRIPTION";
|
||||
case BT_UUID_CSIS_SIRK_VAL:
|
||||
return "CSIS_SIRK";
|
||||
case BT_UUID_CSIS_SET_SIZE_VAL:
|
||||
return "CSIS_SET_SIZE";
|
||||
case BT_UUID_CSIS_SET_LOCK_VAL:
|
||||
return "CSIS_SET_LOCK";
|
||||
case BT_UUID_CSIS_RANK_VAL:
|
||||
return "CSIS_RANK";
|
||||
case BT_UUID_MCS_PLAYER_NAME_VAL:
|
||||
return "MCS_PLAYER_NAME";
|
||||
case BT_UUID_MCS_ICON_OBJ_ID_VAL:
|
||||
return "MCS_ICON_OBJ_ID";
|
||||
case BT_UUID_MCS_ICON_URL_VAL:
|
||||
return "MCS_ICON_URL";
|
||||
case BT_UUID_MCS_TRACK_CHANGED_VAL:
|
||||
return "MCS_TRACK_CHANGED";
|
||||
case BT_UUID_MCS_TRACK_TITLE_VAL:
|
||||
return "MCS_TRACK_TITLE";
|
||||
case BT_UUID_MCS_TRACK_DURATION_VAL:
|
||||
return "MCS_TRACK_DURATION";
|
||||
case BT_UUID_MCS_TRACK_POSITION_VAL:
|
||||
return "MCS_TRACK_POSITION";
|
||||
case BT_UUID_MCS_PLAYBACK_SPEED_VAL:
|
||||
return "MCS_PLAYBACK_SPEED";
|
||||
case BT_UUID_MCS_SEEKING_SPEED_VAL:
|
||||
return "MCS_SEEKING_SPEED";
|
||||
case BT_UUID_MCS_TRACK_SEGMENTS_OBJ_ID_VAL:
|
||||
return "MCS_TRACK_SEGMENTS_OBJ_ID";
|
||||
case BT_UUID_MCS_CURRENT_TRACK_OBJ_ID_VAL:
|
||||
return "MCS_CURRENT_TRACK_OBJ_ID";
|
||||
case BT_UUID_MCS_NEXT_TRACK_OBJ_ID_VAL:
|
||||
return "MCS_NEXT_TRACK_OBJ_ID";
|
||||
case BT_UUID_MCS_PARENT_GROUP_OBJ_ID_VAL:
|
||||
return "MCS_PARENT_GROUP_OBJ_ID";
|
||||
case BT_UUID_MCS_CURRENT_GROUP_OBJ_ID_VAL:
|
||||
return "MCS_CURRENT_GROUP_OBJ_ID";
|
||||
case BT_UUID_MCS_PLAYING_ORDER_VAL:
|
||||
return "MCS_PLAYING_ORDER";
|
||||
case BT_UUID_MCS_PLAYING_ORDERS_VAL:
|
||||
return "MCS_PLAYING_ORDERS";
|
||||
case BT_UUID_MCS_MEDIA_STATE_VAL:
|
||||
return "MCS_MEDIA_STATE";
|
||||
case BT_UUID_MCS_MEDIA_CONTROL_POINT_VAL:
|
||||
return "MCS_MEDIA_CONTROL_POINT";
|
||||
case BT_UUID_MCS_MEDIA_CONTROL_OPCODES_VAL:
|
||||
return "MCS_MEDIA_CONTROL_OPCODES";
|
||||
case BT_UUID_MCS_SEARCH_RESULTS_OBJ_ID_VAL:
|
||||
return "MCS_SEARCH_RESULTS_OBJ_ID";
|
||||
case BT_UUID_MCS_SEARCH_CONTROL_POINT_VAL:
|
||||
return "MCS_SEARCH_CONTROL_POINT";
|
||||
case BT_UUID_TBS_PROVIDER_NAME_VAL:
|
||||
return "TBS_PROVIDER_NAME";
|
||||
case BT_UUID_TBS_UCI_VAL:
|
||||
return "TBS_UCI";
|
||||
case BT_UUID_TBS_TECHNOLOGY_VAL:
|
||||
return "TBS_TECHNOLOGY";
|
||||
case BT_UUID_TBS_URI_LIST_VAL:
|
||||
return "TBS_URI_LIST";
|
||||
case BT_UUID_TBS_SIGNAL_STRENGTH_VAL:
|
||||
return "TBS_SIGNAL_STRENGTH";
|
||||
case BT_UUID_TBS_SIGNAL_INTERVAL_VAL:
|
||||
return "TBS_SIGNAL_INTERVAL";
|
||||
case BT_UUID_TBS_LIST_CURRENT_CALLS_VAL:
|
||||
return "TBS_LIST_CURRENT_CALLS";
|
||||
case BT_UUID_CCID_VAL:
|
||||
return "CCID";
|
||||
case BT_UUID_TBS_STATUS_FLAGS_VAL:
|
||||
return "TBS_STATUS_FLAGS";
|
||||
case BT_UUID_TBS_INCOMING_URI_VAL:
|
||||
return "TBS_INCOMING_URI";
|
||||
case BT_UUID_TBS_CALL_STATE_VAL:
|
||||
return "TBS_CALL_STATE";
|
||||
case BT_UUID_TBS_CALL_CONTROL_POINT_VAL:
|
||||
return "TBS_CALL_CONTROL_POINT";
|
||||
case BT_UUID_TBS_OPTIONAL_OPCODES_VAL:
|
||||
return "TBS_OPTIONAL_OPCODES";
|
||||
case BT_UUID_TBS_TERMINATE_REASON_VAL:
|
||||
return "TBS_TERMINATE_REASON";
|
||||
case BT_UUID_TBS_INCOMING_CALL_VAL:
|
||||
return "TBS_INCOMING_CALL";
|
||||
case BT_UUID_TBS_FRIENDLY_NAME_VAL:
|
||||
return "TBS_FRIENDLY_NAME";
|
||||
case BT_UUID_MICS_MUTE_VAL:
|
||||
return "MICS_MUTE";
|
||||
case BT_UUID_ASCS_ASE_SNK_VAL:
|
||||
return "ASCS_ASE_SNK";
|
||||
case BT_UUID_ASCS_ASE_SRC_VAL:
|
||||
return "ASCS_ASE_SRC";
|
||||
case BT_UUID_ASCS_ASE_CP_VAL:
|
||||
return "ASCS_ASE_CP";
|
||||
case BT_UUID_BASS_CONTROL_POINT_VAL:
|
||||
return "BASS_CP";
|
||||
case BT_UUID_BASS_RECV_STATE_VAL:
|
||||
return "BASS_RECV_STATE";
|
||||
case BT_UUID_PACS_SNK_VAL:
|
||||
return "PACS_SNK";
|
||||
case BT_UUID_PACS_SNK_LOC_VAL:
|
||||
return "PACS_SNK_LOC";
|
||||
case BT_UUID_PACS_SRC_VAL:
|
||||
return "PACS_SRC";
|
||||
case BT_UUID_PACS_SRC_LOC_VAL:
|
||||
return "PACS_SRC_LOC";
|
||||
case BT_UUID_PACS_AVAILABLE_CONTEXT_VAL:
|
||||
return "PACS_AVAILABLE_CONTEXT";
|
||||
case BT_UUID_PACS_SUPPORTED_CONTEXT_VAL:
|
||||
return "PACS_SUPPORTED_CONTEXT";
|
||||
case BT_UUID_HAS_HEARING_AID_FEATURES_VAL:
|
||||
return "HAS_HEARING_AID_FEATURES";
|
||||
case BT_UUID_HAS_PRESET_CONTROL_POINT_VAL:
|
||||
return "HAS_PRESET_CONTROL_POINT";
|
||||
case BT_UUID_HAS_ACTIVE_PRESET_INDEX_VAL:
|
||||
return "HAS_ACTIVE_PRESET_INDEX";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
struct gattc_sub {
|
||||
uint8_t id;
|
||||
bt_addr_le_t peer;
|
||||
|
||||
@@ -13,12 +13,18 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "bluedroid/iso.h"
|
||||
#else
|
||||
#include "nimble/iso.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct net_buf;
|
||||
|
||||
struct bt_le_iso_cb {
|
||||
void (*cis_dis)(struct net_buf *buf);
|
||||
void (*cis_est)(struct net_buf *buf);
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* TODO */
|
||||
#else
|
||||
#include "nimble/l2cap.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "bluedroid/gap.h"
|
||||
#else
|
||||
#include "nimble/gap.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -20,18 +20,32 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#if CONFIG_BT_BLUEDROID_PINNED_TO_CORE
|
||||
#define ISO_TASK_CORE CONFIG_BT_BLUEDROID_PINNED_TO_CORE
|
||||
#else /* CONFIG_BT_BLUEDROID_PINNED_TO_CORE */
|
||||
#define ISO_TASK_CORE (0)
|
||||
#endif /* CONFIG_BT_BLUEDROID_PINNED_TO_CORE */
|
||||
#else /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
#if CONFIG_BT_NIMBLE_PINNED_TO_CORE
|
||||
#define ISO_TASK_CORE CONFIG_BT_NIMBLE_PINNED_TO_CORE
|
||||
#else /* CONFIG_BT_NIMBLE_PINNED_TO_CORE */
|
||||
#define ISO_TASK_CORE (0)
|
||||
#endif /* CONFIG_BT_NIMBLE_PINNED_TO_CORE */
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
#define ISO_TASK_STACK_SIZE 4096
|
||||
#define ISO_TASK_NAME "iso_task"
|
||||
/* Ref:
|
||||
* - Bluedroid BTC task: configMAX_PRIORITIES - 6
|
||||
* - Bluedroid BTU task: configMAX_PRIORITIES - 5
|
||||
* - NimBLE Host task: configMAX_PRIORITIES - 4
|
||||
*/
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#define ISO_TASK_PRIO (configMAX_PRIORITIES - 5)
|
||||
#else
|
||||
#define ISO_TASK_PRIO (configMAX_PRIORITIES - 4)
|
||||
#endif
|
||||
|
||||
enum iso_queue_item_type {
|
||||
ISO_QUEUE_ITEM_TYPE_TIMER_EVENT,
|
||||
|
||||
@@ -25,11 +25,19 @@
|
||||
|
||||
LOG_MODULE_REGISTER(ISO_SHIM, CONFIG_BT_ISO_LOG_LEVEL);
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
#ifdef CONFIG_BT_BLE_ISO_STD_FLOW_CTRL
|
||||
#define ISO_STD_FLOW_CTRL true
|
||||
#else /* CONFIG_BT_BLE_ISO_STD_FLOW_CTRL */
|
||||
#define ISO_STD_FLOW_CTRL false
|
||||
#endif /* CONFIG_BT_BLE_ISO_STD_FLOW_CTRL */
|
||||
#else /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
#ifdef CONFIG_BT_NIMBLE_ISO_STD_FLOW_CTRL
|
||||
#define ISO_STD_FLOW_CTRL true
|
||||
#else /* CONFIG_BT_NIMBLE_ISO_STD_FLOW_CTRL */
|
||||
#define ISO_STD_FLOW_CTRL false
|
||||
#endif /* CONFIG_BT_NIMBLE_ISO_STD_FLOW_CTRL */
|
||||
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
|
||||
|
||||
#define ISO_PKT_FIRST_FRAG (0b00)
|
||||
#define ISO_PKT_CONT_FRAG (0b01)
|
||||
@@ -757,7 +765,11 @@ void bt_le_iso_handle_rx_data(uint8_t *data, size_t data_len)
|
||||
|
||||
int bt_le_iso_disconnect(uint16_t conn_handle, uint8_t reason)
|
||||
{
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return bt_le_bluedroid_iso_disconnect(conn_handle, reason);
|
||||
#else
|
||||
return bt_le_nimble_iso_disconnect(conn_handle, reason);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void iso_features_set(void)
|
||||
@@ -819,7 +831,11 @@ int bt_le_iso_init(void)
|
||||
r_ble_ll_isoal_tx_comp_cb_set(iso_tx_comp_cb);
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
err = bt_le_bluedroid_iso_init();
|
||||
#else
|
||||
err = bt_le_nimble_iso_init();
|
||||
#endif
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
@@ -839,5 +855,9 @@ void bt_le_iso_deinit(void)
|
||||
r_ble_ll_isoal_tx_comp_cb_set(NULL);
|
||||
#endif /* CONFIG_BT_ISO_TX */
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
bt_le_bluedroid_iso_deinit();
|
||||
#else
|
||||
bt_le_nimble_iso_deinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ int bt_le_l2cap_accept(uint16_t conn_handle, uint16_t psm,
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_INF("L2capAcceptNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
|
||||
*result = L2CAP_LE_ERR_INVALID_PARAMS;
|
||||
return -ENOTCONN;
|
||||
@@ -219,7 +219,7 @@ void bt_le_l2cap_connected(uint16_t conn_handle, uint16_t psm,
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_INF("L2capConnectedNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ void bt_le_l2cap_disconnected(uint16_t conn_handle, uint16_t psm)
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_INF("L2capDisconnectedNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ void bt_le_l2cap_received(uint16_t conn_handle, uint16_t psm,
|
||||
|
||||
conn = bt_le_acl_conn_find(conn_handle);
|
||||
if (conn == NULL || conn->state != BT_CONN_CONNECTED) {
|
||||
LOG_ERR("NotConn[%d]", __LINE__);
|
||||
LOG_INF("L2capReceivedNotConn[%u][%u]", conn_handle, BT_CONN_STATE_GET(conn));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -315,7 +315,9 @@ void bt_le_l2cap_received(uint16_t conn_handle, uint16_t psm,
|
||||
_IDF_ONLY
|
||||
int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, uint16_t psm)
|
||||
{
|
||||
#if !CONFIG_BT_BLUEDROID_ENABLED
|
||||
int err;
|
||||
#endif
|
||||
|
||||
LOG_DBG("L2capChanConnect[%04x]", psm);
|
||||
|
||||
@@ -334,6 +336,12 @@ int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, uint
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* L2CAP COC is not yet implemented in the Bluedroid adapter (no
|
||||
* bt_le_bluedroid_l2cap_chan_connect exists). Return early so callers
|
||||
* like bt_gatt_ots_l2cap_connect see a clean -ENOTSUP. */
|
||||
return -ENOTSUP;
|
||||
#else
|
||||
err = bt_le_nimble_l2cap_chan_connect(conn->handle);
|
||||
if (err) {
|
||||
return err;
|
||||
@@ -342,12 +350,15 @@ int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, uint
|
||||
l2cap_chan_add(conn, chan, psm);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
_IDF_ONLY
|
||||
int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
#if !CONFIG_BT_BLUEDROID_ENABLED
|
||||
int err;
|
||||
#endif
|
||||
|
||||
LOG_DBG("L2capChanDisconnect");
|
||||
|
||||
@@ -361,6 +372,9 @@ int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan)
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return -ENOTSUP;
|
||||
#else
|
||||
err = bt_le_nimble_l2cap_chan_disconnect(chan);
|
||||
if (err) {
|
||||
/* If the disconnect failed, remove the channel from the connection.
|
||||
@@ -371,6 +385,7 @@ int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan)
|
||||
}
|
||||
|
||||
return err;
|
||||
#endif
|
||||
}
|
||||
|
||||
_IDF_ONLY
|
||||
@@ -393,7 +408,11 @@ int bt_l2cap_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
return -ENOTSUP;
|
||||
#else
|
||||
return bt_le_nimble_l2cap_chan_send(chan, buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
_IDF_ONLY
|
||||
@@ -490,10 +509,18 @@ int bt_le_l2cap_init(void)
|
||||
}
|
||||
#endif /* CONFIG_BT_OTS || CONFIG_BT_OTS_CLIENT */
|
||||
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
/* No adapter-level L2CAP init exists (COC not implemented). Don't fail
|
||||
* host init here — the host-agnostic OTS registrations above are still
|
||||
* valid; any actual COC connect attempt later returns -ENOTSUP in
|
||||
* bt_l2cap_chan_connect, so OTS features fail gracefully at use time
|
||||
* instead of preventing the whole host from coming up. */
|
||||
#else
|
||||
err = bt_le_nimble_l2cap_init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,12 @@ int bt_le_scan_start(const struct bt_le_scan_param *param, void *cb)
|
||||
int err = 0;
|
||||
|
||||
if (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) == false) {
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
ARG_UNUSED(cb);
|
||||
err = bt_le_bluedroid_scan_start(param);
|
||||
#else
|
||||
err = bt_le_nimble_scan_start(param, cb);
|
||||
#endif
|
||||
if (err == 0) {
|
||||
atomic_set_bit(bt_dev.flags, BT_DEV_SCANNING);
|
||||
}
|
||||
@@ -501,7 +506,11 @@ int bt_le_scan_stop(void)
|
||||
int err = 0;
|
||||
|
||||
if (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING)) {
|
||||
#if CONFIG_BT_BLUEDROID_ENABLED
|
||||
err = bt_le_bluedroid_scan_stop();
|
||||
#else
|
||||
err = bt_le_nimble_scan_stop();
|
||||
#endif
|
||||
if (err == 0) {
|
||||
atomic_clear_bit(bt_dev.flags, BT_DEV_SCANNING);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user