Skip to content

Commit

Permalink
Bluetooth: AVRCP: expose macros to upper layer.
Browse files Browse the repository at this point in the history
This patch expose BT_AVRCP_COMPANY_ID_SIZE to applications.

Signed-off-by: Zihao Gao <[email protected]>
  • Loading branch information
gzh-terry committed Feb 27, 2025
1 parent e26766e commit 49cb95c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion include/zephyr/bluetooth/classic/avrcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
extern "C" {
#endif

#define BT_AVRCP_COMPANY_ID_BLUETOOTH_SIG 0x001958
#define BT_AVRCP_COMPANY_ID_SIZE (3)
#define BT_AVRCP_COMPANY_ID_BLUETOOTH_SIG (0x001958)

/** @brief AVRCP Capability ID */
typedef enum __packed {
Expand Down
18 changes: 9 additions & 9 deletions subsys/bluetooth/host/classic/avrcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct avrcp_handler {
void (*func)(struct bt_avrcp *avrcp, struct net_buf *buf, bt_avctp_cr_t cr);
};

#define AVRCP_TIMEOUT K_SECONDS(3) /* Shell be greater than TMTP (1000ms) */
#define AVRCP_TIMEOUT K_SECONDS(3) /* Shall be greater than TMTP (1000ms) */
#define AVRCP_AVCTP(_avctp) CONTAINER_OF(_avctp, struct bt_avrcp, session)
#define AVRCP_KWORK(_work) \
CONTAINER_OF(CONTAINER_OF(_work, struct k_work_delayable, work), struct bt_avrcp, \
Expand Down Expand Up @@ -277,7 +277,7 @@ static void process_get_cap_rsp(struct bt_avrcp *avrcp, struct net_buf *buf)

switch (rsp->cap_id) {
case BT_AVRCP_CAP_COMPANY_ID:
expected_len = rsp->cap_cnt * AVRCP_COMPANY_ID_SIZE;
expected_len = rsp->cap_cnt * BT_AVRCP_COMPANY_ID_SIZE;
break;
case BT_AVRCP_CAP_EVENTS_SUPPORTED:
expected_len = rsp->cap_cnt;
Expand All @@ -303,7 +303,7 @@ static void avrcp_vendor_dependent_handler(struct bt_avrcp *avrcp, struct net_bu
uint32_t company_id;
uint8_t pdu_id;

if (buf->len < (sizeof(*avrcp_hdr) + AVRCP_COMPANY_ID_SIZE + sizeof(pdu_id))) {
if (buf->len < (sizeof(*avrcp_hdr) + BT_AVRCP_COMPANY_ID_SIZE + sizeof(pdu_id))) {
LOG_ERR("Invalid vendor frame length: %d", buf->len);
return;
}
Expand Down Expand Up @@ -399,7 +399,7 @@ static void avrcp_pass_through_handler(struct bt_avrcp *avrcp, struct net_buf *b
/* ToDo */
} else { /* BT_AVCTP_RESPONSE */
if ((avrcp_cb != NULL) && (avrcp_cb->subunit_info_rsp != NULL)) {
if (buf->len < 2) {
if (buf->len < sizeof(*rsp)) {
LOG_ERR("Invalid passthrough length: %d", buf->len);
return;
}
Expand Down Expand Up @@ -692,18 +692,18 @@ static int avrcp_send(struct bt_avrcp *avrcp, struct net_buf *buf)
int bt_avrcp_get_cap(struct bt_avrcp *avrcp, bt_avrcp_cap_t cap_id)
{
struct net_buf *buf;
struct bt_avrcp_avc_pdu pdu;
struct bt_avrcp_avc_pdu *pdu;

buf = avrcp_create_vendor_pdu(avrcp, BT_AVCTP_CMD, BT_AVRCP_CTYPE_STATUS);
if (!buf) {
return -ENOMEM;
}

net_buf_add_be24(buf, BT_AVRCP_COMPANY_ID_BLUETOOTH_SIG);
pdu.pdu_id = BT_AVRCP_PDU_ID_GET_CAPS;
BT_AVRCP_AVC_PDU_SET_PACKET_TYPE(&pdu, BT_AVRVP_PKT_TYPE_SINGLE);
pdu.param_len = sys_cpu_to_be16(sizeof(cap_id));
net_buf_add_mem(buf, &pdu, sizeof(pdu));
pdu = net_buf_add(buf, sizeof(*pdu));
pdu->pdu_id = BT_AVRCP_PDU_ID_GET_CAPS;
BT_AVRCP_AVC_PDU_SET_PACKET_TYPE(pdu, BT_AVRVP_PKT_TYPE_SINGLE);
pdu->param_len = sys_cpu_to_be16(sizeof(cap_id));
net_buf_add_u8(buf, cap_id);

return avrcp_send(avrcp, buf);
Expand Down
1 change: 0 additions & 1 deletion subsys/bluetooth/host/classic/avrcp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#define AVRCP_SUBUNIT_PAGE (0) /* Fixed value according to AVRCP */
#define AVRCP_SUBUNIT_EXTENSION_CODE (7) /* Fixed value according to TA Document 2001012 */
#define AVRCP_COMPANY_ID_SIZE (3) /* Length for each company ID */

typedef enum __packed {
BT_AVRCP_SUBUNIT_ID_ZERO = 0x0,
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/host/classic/shell/avrcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ static void avrcp_get_cap_rsp(struct bt_avrcp *avrcp, const struct bt_avrcp_get_
switch (rsp->cap_id) {
case BT_AVRCP_CAP_COMPANY_ID:
for (i = 0; i < rsp->cap_cnt; i++) {
bt_shell_print("Remote CompanyID = 0x%02x%02x%02x", rsp->cap[3 * i],
rsp->cap[3 * i + 1], rsp->cap[3 * i + 2]);
bt_shell_print("Remote CompanyID = 0x%06x",
sys_get_be24(&rsp->cap[BT_AVRCP_COMPANY_ID_SIZE * i]));
}
break;
case BT_AVRCP_CAP_EVENTS_SUPPORTED:
Expand Down

0 comments on commit 49cb95c

Please sign in to comment.