diff --git a/subsys/bluetooth/audio/ascs.c b/subsys/bluetooth/audio/ascs.c index 632af001964..23ed2bb85ce 100644 --- a/subsys/bluetooth/audio/ascs.c +++ b/subsys/bluetooth/audio/ascs.c @@ -381,9 +381,9 @@ static void ascs_ep_get_status_config(struct bt_audio_ep *ep, cfg->codec.cid = sys_cpu_to_le16(ep->codec.cid); cfg->codec.vid = sys_cpu_to_le16(ep->codec.vid); - LOG_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u " + LOG_DBG("dir %s unframed_supported 0x%02x phy 0x%02x rtn %u " "latency %u pd_min %u pd_max %u codec 0x%02x", - ep->dir, pref->unframed_supported, pref->phy, + bt_audio_dir_str(ep->dir), pref->unframed_supported, pref->phy, pref->rtn, pref->latency, pref->pd_min, pref->pd_max, ep->stream->codec->id); @@ -408,9 +408,9 @@ static void ascs_ep_get_status_qos(struct bt_audio_ep *ep, qos->latency = sys_cpu_to_le16(ep->stream->qos->latency); sys_put_le24(ep->stream->qos->pd, qos->pd); - LOG_DBG("dir 0x%02x codec 0x%02x interval %u framing 0x%02x phy 0x%02x " + LOG_DBG("dir %s codec 0x%02x interval %u framing 0x%02x phy 0x%02x " "rtn %u latency %u pd %u", - ep->dir, ep->stream->codec->id, + bt_audio_dir_str(ep->dir), ep->stream->codec->id, ep->stream->qos->interval, ep->stream->qos->framing, ep->stream->qos->phy, ep->stream->qos->rtn, ep->stream->qos->latency, ep->stream->qos->pd); @@ -429,7 +429,8 @@ static void ascs_ep_get_status_enable(struct bt_audio_ep *ep, ascs_codec_data_add(buf, "meta", ep->codec.meta_count, ep->codec.meta); enable->metadata_len = buf->len - enable->metadata_len; - LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir %s cig 0x%02x cis 0x%02x", + bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id); } static int ascs_ep_get_status_idle(uint8_t ase_id, struct net_buf_simple *buf) @@ -1207,14 +1208,14 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid, return -EINVAL; } - LOG_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, ep->dir, id, cid, - vid, len); + LOG_DBG("ep %p dir %s codec id 0x%02x cid 0x%04x vid 0x%04x len %u", + ep, bt_audio_dir_str(ep->dir), id, cid, vid, len); bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data); if (lookup_data.codec == NULL) { - LOG_DBG("Codec with id %u for dir %u is not supported by our capabilities", - id, ep->dir); + LOG_DBG("Codec with id %u for dir %s is not supported by our capabilities", + id, bt_audio_dir_str(ep->dir)); return -ENOENT; } @@ -1504,8 +1505,8 @@ static int ase_stream_qos(struct bt_audio_stream *stream, } if (bt_audio_iso_get_ep(false, iso, ep->dir) != NULL) { - LOG_ERR("iso %p already in use in dir %u", - &iso->chan, ep->dir); + LOG_ERR("iso %p already in use in dir %s", + &iso->chan, bt_audio_dir_str(ep->dir)); bt_audio_iso_unref(iso); return -EALREADY; } diff --git a/subsys/bluetooth/audio/audio_internal.h b/subsys/bluetooth/audio/audio_internal.h index 2f440c64ace..52a88fae526 100644 --- a/subsys/bluetooth/audio/audio_internal.h +++ b/subsys/bluetooth/audio/audio_internal.h @@ -58,3 +58,15 @@ ssize_t bt_audio_ccc_cfg_write(struct bt_conn *conn, const struct bt_gatt_attr * BT_GATT_CCC_MANAGED(((struct _bt_gatt_ccc[]) \ {BT_GATT_CCC_INITIALIZER(_changed, bt_audio_ccc_cfg_write, NULL)}), \ (BT_GATT_PERM_READ | BT_GATT_PERM_WRITE_ENCRYPT)) + +static inline const char *bt_audio_dir_str(enum bt_audio_dir dir) +{ + switch (dir) { + case BT_AUDIO_DIR_SINK: + return "sink"; + case BT_AUDIO_DIR_SOURCE: + return "source"; + } + + return "Unknown"; +} diff --git a/subsys/bluetooth/audio/audio_iso.c b/subsys/bluetooth/audio/audio_iso.c index d9098b85d9a..263faacfd83 100644 --- a/subsys/bluetooth/audio/audio_iso.c +++ b/subsys/bluetooth/audio/audio_iso.c @@ -7,6 +7,7 @@ */ #include "audio_iso.h" +#include "audio_internal.h" #include "endpoint.h" #include @@ -151,7 +152,7 @@ void bt_audio_iso_bind_ep(struct bt_audio_iso *iso, struct bt_audio_ep *ep) __ASSERT(ep->dir == BT_AUDIO_DIR_SINK || ep->dir == BT_AUDIO_DIR_SOURCE, "invalid dir: %u", ep->dir); - LOG_DBG("iso %p ep %p dir %u", iso, ep, ep->dir); + LOG_DBG("iso %p ep %p dir %s", iso, ep, bt_audio_dir_str(ep->dir)); if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_CLIENT) && bt_audio_ep_is_unicast_client(ep)) { @@ -189,7 +190,7 @@ void bt_audio_iso_unbind_ep(struct bt_audio_iso *iso, struct bt_audio_ep *ep) __ASSERT(ep->dir == BT_AUDIO_DIR_SINK || ep->dir == BT_AUDIO_DIR_SOURCE, "Invalid dir: %u", ep->dir); - LOG_DBG("iso %p ep %p dir %u", iso, ep, ep->dir); + LOG_DBG("iso %p ep %p dir %s", iso, ep, bt_audio_dir_str(ep->dir)); if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_CLIENT) && bt_audio_ep_is_unicast_client(ep)) { @@ -226,7 +227,7 @@ struct bt_audio_ep *bt_audio_iso_get_ep(bool unicast_client, __ASSERT(dir == BT_AUDIO_DIR_SINK || dir == BT_AUDIO_DIR_SOURCE, "invalid dir: %u", dir); - LOG_DBG("iso %p dir %u", iso, dir); + LOG_DBG("iso %p dir %s", iso, bt_audio_dir_str(dir)); /* TODO FIX FOR CLIENT */ if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_CLIENT) && unicast_client) { @@ -257,8 +258,8 @@ void bt_audio_iso_bind_stream(struct bt_audio_iso *audio_iso, "stream %p bound with audio_iso %p already", stream, stream->audio_iso); - LOG_DBG("audio_iso %p stream %p dir %u", - audio_iso, stream, stream->dir); + LOG_DBG("audio_iso %p stream %p dir %s", + audio_iso, stream, bt_audio_dir_str(stream->dir)); /* For the unicast client, the direction and tx/rx is reversed */ if (stream->dir == BT_AUDIO_DIR_SOURCE) { @@ -286,8 +287,8 @@ void bt_audio_iso_unbind_stream(struct bt_audio_iso *audio_iso, "stream %p not bound with an audio_iso", stream); - LOG_DBG("audio_iso %p stream %p dir %u", - audio_iso, stream, stream->dir); + LOG_DBG("audio_iso %p stream %p dir %s", + audio_iso, stream, bt_audio_dir_str(stream->dir)); /* For the unicast client, the direction and tx/rx is reversed */ if (stream->dir == BT_AUDIO_DIR_SOURCE) { @@ -311,7 +312,7 @@ struct bt_audio_stream *bt_audio_iso_get_stream(struct bt_audio_iso *iso, __ASSERT(dir == BT_AUDIO_DIR_SINK || dir == BT_AUDIO_DIR_SOURCE, "invalid dir: %u", dir); - LOG_DBG("iso %p dir %u", iso, dir); + LOG_DBG("iso %p dir %s", iso, bt_audio_dir_str(dir)); /* For the unicast client, the direction and tx/rx is reversed */ if (dir == BT_AUDIO_DIR_SOURCE) { diff --git a/subsys/bluetooth/audio/pacs.c b/subsys/bluetooth/audio/pacs.c index 5fe61560595..8fbb87f9f07 100644 --- a/subsys/bluetooth/audio/pacs.c +++ b/subsys/bluetooth/audio/pacs.c @@ -662,8 +662,8 @@ int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap) return -EINVAL; } - LOG_DBG("cap %p dir 0x%02x codec 0x%02x codec cid 0x%04x " - "codec vid 0x%04x", cap, dir, cap->codec->id, + LOG_DBG("cap %p dir %s codec 0x%02x codec cid 0x%04x " + "codec vid 0x%04x", cap, bt_audio_dir_str(dir), cap->codec->id, cap->codec->cid, cap->codec->vid); sys_slist_append(&pac->list, &cap->_node); @@ -687,7 +687,7 @@ int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap) return -EINVAL; } - LOG_DBG("cap %p dir 0x%02x", cap, dir); + LOG_DBG("cap %p dir %s", cap, bt_audio_dir_str(dir)); if (!sys_slist_find_and_remove(&pac->list, &cap->_node)) { return -ENOENT; diff --git a/subsys/bluetooth/audio/stream.c b/subsys/bluetooth/audio/stream.c index 2669ba41953..917396dd584 100644 --- a/subsys/bluetooth/audio/stream.c +++ b/subsys/bluetooth/audio/stream.c @@ -22,6 +22,7 @@ #include "../host/iso_internal.h" #include "audio_iso.h" +#include "audio_internal.h" #include "endpoint.h" #include "unicast_client_internal.h" #include "unicast_server.h" @@ -872,7 +873,8 @@ static int unicast_group_add_stream(struct bt_audio_unicast_group *group, __ASSERT_NO_MSG(stream->ep == NULL || (stream->ep != NULL && stream->ep->iso == NULL)); - LOG_DBG("group %p stream %p dir %u", group, stream, dir); + LOG_DBG("group %p stream %p dir %s", + group, stream, bt_audio_dir_str(dir)); iso = get_new_iso(group, stream->conn, dir); if (iso == NULL) { diff --git a/subsys/bluetooth/audio/unicast_client.c b/subsys/bluetooth/audio/unicast_client.c index 9922f1eed93..18a7b3d290b 100644 --- a/subsys/bluetooth/audio/unicast_client.c +++ b/subsys/bluetooth/audio/unicast_client.c @@ -23,6 +23,7 @@ #include "../host/conn_internal.h" #include "audio_iso.h" +#include "audio_internal.h" #include "endpoint.h" #include "pacs_internal.h" #include "unicast_client_internal.h" @@ -177,7 +178,8 @@ static void unicast_client_ep_iso_connected(struct bt_audio_ep *ep) return; } - LOG_DBG("stream %p ep %p dir %u", stream, ep, ep->dir); + LOG_DBG("stream %p ep %p dir %s", + stream, ep, bt_audio_dir_str(ep->dir)); } static void unicast_client_iso_connected(struct bt_iso_chan *chan) @@ -270,7 +272,8 @@ static void unicast_client_ep_init(struct bt_audio_ep *ep, uint16_t handle, { struct bt_unicast_client_ep *client_ep; - LOG_DBG("ep %p dir 0x%02x handle 0x%04x", ep, dir, handle); + LOG_DBG("ep %p dir %s handle 0x%04x", + ep, bt_audio_dir_str(dir), handle); client_ep = CONTAINER_OF(ep, struct bt_unicast_client_ep, ep); @@ -407,7 +410,8 @@ static void unicast_client_ep_qos_update(struct bt_audio_ep *ep, { struct bt_iso_chan_io_qos *iso_io_qos; - LOG_DBG("ep %p dir %u audio_iso %p", ep, ep->dir, ep->iso); + LOG_DBG("ep %p dir %s audio_iso %p", + ep, bt_audio_dir_str(ep->dir), ep->iso); if (ep->dir == BT_AUDIO_DIR_SOURCE) { /* If the endpoint is a source, then we need to @@ -479,10 +483,11 @@ static void unicast_client_ep_config_state(struct bt_audio_ep *ep, pref->pref_pd_min = sys_get_le24(cfg->prefer_pd_min); pref->pref_pd_max = sys_get_le24(cfg->prefer_pd_max); - LOG_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u " + LOG_DBG("dir %s unframed_supported 0x%02x phy 0x%02x rtn %u " "latency %u pd_min %u pd_max %u codec 0x%02x ", - ep->dir, pref->unframed_supported, pref->phy, pref->rtn, - pref->latency, pref->pd_min, pref->pd_max, stream->codec->id); + bt_audio_dir_str(ep->dir), pref->unframed_supported, pref->phy, + pref->rtn, pref->latency, pref->pd_min, pref->pd_max, + stream->codec->id); unicast_client_ep_set_codec(ep, cfg->codec.id, sys_le16_to_cpu(cfg->codec.cid), @@ -531,10 +536,10 @@ static void unicast_client_ep_qos_state(struct bt_audio_ep *ep, (void)memcpy(&stream->qos->pd, sys_le24_to_cpu(qos->pd), sizeof(qos->pd)); - LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x codec 0x%02x interval %u " + LOG_DBG("dir %s cig 0x%02x cis 0x%02x codec 0x%02x interval %u " "framing 0x%02x phy 0x%02x rtn %u latency %u pd %u", - ep->dir, ep->cig_id, ep->cis_id, stream->codec->id, - stream->qos->interval, stream->qos->framing, + bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id, + stream->codec->id, stream->qos->interval, stream->qos->framing, stream->qos->phy, stream->qos->rtn, stream->qos->latency, stream->qos->pd); @@ -598,7 +603,8 @@ static void unicast_client_ep_enabling_state(struct bt_audio_ep *ep, metadata = net_buf_simple_pull_mem(buf, enable->metadata_len); - LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir %s cig 0x%02x cis 0x%02x", + bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id); unicast_client_ep_set_metadata(ep, metadata, enable->metadata_len, NULL); @@ -642,7 +648,8 @@ static void unicast_client_ep_streaming_state(struct bt_audio_ep *ep, stream_status = net_buf_simple_pull_mem(buf, sizeof(*stream_status)); - LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir %s cig 0x%02x cis 0x%02x", + bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id); /* Notify upper layer * @@ -683,7 +690,8 @@ static void unicast_client_ep_disabling_state(struct bt_audio_ep *ep, disable = net_buf_simple_pull_mem(buf, sizeof(*disable)); - LOG_DBG("dir 0x%02x cig 0x%02x cis 0x%02x", ep->dir, ep->cig_id, ep->cis_id); + LOG_DBG("dir %s cig 0x%02x cis 0x%02x", + bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id); /* Notify upper layer */ if (stream->ops != NULL && stream->ops->disabled != NULL) { @@ -704,7 +712,7 @@ static void unicast_client_ep_releasing_state(struct bt_audio_ep *ep, return; } - LOG_DBG("dir 0x%02x", ep->dir); + LOG_DBG("dir %s", bt_audio_dir_str(ep->dir)); /* The Unicast Client shall terminate any CIS established for that ASE * by following the Connected Isochronous Stream Terminate procedure @@ -734,8 +742,9 @@ static void unicast_client_ep_set_status(struct bt_audio_ep *ep, ep->status = *status; state_changed = old_state != ep->status.state; - LOG_DBG("ep %p handle 0x%04x id 0x%02x dir %u state %s -> %s", ep, client_ep->handle, - status->id, ep->dir, bt_audio_ep_state_str(old_state), + LOG_DBG("ep %p handle 0x%04x id 0x%02x dir %s state %s -> %s", + ep, client_ep->handle, status->id, bt_audio_dir_str(ep->dir), + bt_audio_ep_state_str(old_state), bt_audio_ep_state_str(status->state)); switch (status->state) { @@ -1254,7 +1263,8 @@ static int unicast_client_ep_config(struct bt_audio_ep *ep, return -EINVAL; } - LOG_DBG("id 0x%02x dir 0x%02x codec 0x%02x", ep->status.id, ep->dir, codec->id); + LOG_DBG("id 0x%02x dir %s codec 0x%02x", + ep->status.id, bt_audio_dir_str(ep->dir), codec->id); req = net_buf_simple_add(buf, sizeof(*req)); req->ase = ep->status.id; @@ -2086,8 +2096,8 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, LOG_DBG("conn %p err 0x%02x len %u", conn, err, length); if (err || data == NULL || length != sizeof(location)) { - LOG_DBG("Unable to read PACS location for dir %u: %u, %p, %u", params->dir, err, - data, length); + LOG_DBG("Unable to read PACS location for dir %s: %u, %p, %u", + bt_audio_dir_str(params->dir), err, data, length); params->func(conn, NULL, NULL, params); @@ -2097,7 +2107,7 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); location = net_buf_simple_pull_le32(&buf); - LOG_DBG("dir %u loc %X", params->dir, location); + LOG_DBG("dir %s loc %X", bt_audio_dir_str(params->dir), location); if (unicast_client_cbs != NULL && unicast_client_cbs->location != NULL) { unicast_client_cbs->location(conn, params->dir, @@ -2156,7 +2166,7 @@ static uint8_t unicast_client_pacs_location_notify_cb(struct bt_conn *conn, net_buf_simple_init_with_data(&buf, (void *)data, length); location = net_buf_simple_pull_le32(&buf); - LOG_DBG("dir %u loc %X", dir, location); + LOG_DBG("dir %s loc %X", bt_audio_dir_str(dir), location); if (unicast_client_cbs != NULL && unicast_client_cbs->location != NULL) { unicast_client_cbs->location(conn, dir,