Skip to content

Commit 84053a4

Browse files
committed
Merge branch 'bugfix/fix_some_bugs_in_bluedroid' into 'release/v5.4'
fix(bt/bluedroid): Fixed some avrcp cover art related bugs See merge request espressif/esp-idf!35505
2 parents a1c8f06 + 76dbdaa commit 84053a4

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

components/bt/host/bluedroid/bta/av/bta_av_ca_act.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ void bta_av_ca_api_get(tBTA_AV_RCB *p_rcb, tBTA_AV_DATA *p_data)
278278
GOEPC_RequestAddHeader(p_rcb->cover_art_goep_hdl, COVER_ART_HEADER_ID_IMG_HANDLE, (UINT8 *)image_handle_utf16, BTA_AV_CA_IMG_HDL_UTF16_LEN);
279279
if (p_data->api_ca_get.type == BTA_AV_CA_GET_IMAGE) {
280280
GOEPC_RequestAddHeader(p_rcb->cover_art_goep_hdl, COVER_ART_HEADER_ID_IMG_DESCRIPTOR, (UINT8 *)p_data->api_ca_get.image_descriptor, p_data->api_ca_get.image_descriptor_len);
281+
osi_free(p_data->api_ca_get.image_descriptor);
281282
}
282283
/* always request to enable srm */
283284
GOEPC_RequestSetSRM(p_rcb->cover_art_goep_hdl, TRUE, FALSE);

components/bt/host/bluedroid/stack/goep/goepc_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ UINT16 GOEPC_RequestAddHeader(UINT16 handle, UINT8 header_id, const UINT8 *data,
359359
break;
360360
}
361361

362-
if (data == NULL || data_len == 0) {
362+
if ((data == NULL && data_len != 0) || (data != NULL && data_len == 0)) {
363363
ret = GOEP_INVALID_PARAM;
364364
break;
365365
}

components/bt/host/bluedroid/stack/include/stack/goep_common.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
#include "common/bt_target.h"
1010

11-
#define GOEP_SUCCESS 0 /* Operation successful */
12-
#define GOEP_FAILURE 1 /* Operation failed */
13-
#define GOEP_NO_RESOURCES 3 /* Not enough resources */
14-
#define GOEP_BAD_HANDLE 4 /* Bad handle */
15-
#define GOEP_INVALID_PARAM 5 /* Invalid parameter */
16-
#define GOEP_INVALID_STATE 6 /* Operation not allow in current state */
17-
#define GOEP_CONGEST 7 /* Congest */
18-
#define GOEP_TL_ERROR 8 /* Lower transport layer error */
11+
/* GOEP Client or Server(not supported yet) API return code */
12+
#define GOEP_SUCCESS 0x00 /* Operation successful */
13+
#define GOEP_FAILURE 0x01 /* Operation failed */
14+
#define GOEP_NO_RESOURCES 0x02 /* Not enough resources */
15+
#define GOEP_BAD_HANDLE 0x04 /* Bad handle */
16+
#define GOEP_INVALID_PARAM 0x08 /* Invalid parameter */
17+
#define GOEP_INVALID_STATE 0x10 /* Operation not allow in current state */
18+
#define GOEP_CONGEST 0x20 /* Congest */
19+
#define GOEP_TL_ERROR 0x40 /* Lower transport layer error */

components/bt/host/bluedroid/stack/obex/include/obex_int.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#define OBEX_STATE_OPENING 1 /* Starting to open a connection */
2525
#define OBEX_STATE_OPENED 2 /* Connection opened */
2626

27-
/* Store 16 bits data in big endian format, not modify the p_buf */
28-
#define STORE16BE(p_buf, data) do { *p_buf = ((data)>>8)&0xff; \
29-
*(p_buf+1) = (data)&0xff;} while(0)
30-
3127
/* OBEX Connection Control block */
3228
typedef struct {
3329
tOBEX_MSG_CBACK *callback; /* Connection msg callback function */

components/bt/host/bluedroid/stack/obex/obex_api.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline void obex_server_to_tl_server(tOBEX_SVR_INFO *server, tOBEX_TL_SVR
3434
static inline void obex_updata_packet_length(BT_HDR *p_buf, UINT16 len)
3535
{
3636
UINT8 *p_pkt_len = (UINT8 *)(p_buf + 1) + p_buf->offset + 1;
37-
STORE16BE(p_pkt_len, len);
37+
UINT16_TO_BE_FIELD(p_pkt_len, len);
3838
}
3939

4040
/*******************************************************************************
@@ -343,7 +343,7 @@ UINT16 OBEX_BuildRequest(tOBEX_PARSE_INFO *info, UINT16 buff_size, BT_HDR **out_
343343
/* byte 4: flags */
344344
*p_data++ = info->flags;
345345
/* byte 5, 6: maximum OBEX packet length, recommend to set as our mtu*/
346-
STORE16BE(p_data, info->max_packet_length);
346+
UINT16_TO_BE_FIELD(p_data, info->max_packet_length);
347347
pkt_len += 4;
348348
break;
349349
case OBEX_OPCODE_SETPATH:
@@ -357,7 +357,7 @@ UINT16 OBEX_BuildRequest(tOBEX_PARSE_INFO *info, UINT16 buff_size, BT_HDR **out_
357357
break;
358358
}
359359

360-
STORE16BE(p_pkt_len, pkt_len);
360+
UINT16_TO_BE_FIELD(p_pkt_len, pkt_len);
361361
p_buf->len = pkt_len;
362362
*out_pkt = p_buf;
363363
return OBEX_SUCCESS;
@@ -405,14 +405,14 @@ UINT16 OBEX_BuildResponse(tOBEX_PARSE_INFO *info, UINT16 buff_size, BT_HDR **out
405405
/* byte 4: flags */
406406
*p_data++ = info->flags;
407407
/* byte 5, 6: maximum OBEX packet length, recommend to set as our mtu */
408-
STORE16BE(p_data, info->max_packet_length);
408+
UINT16_TO_BE_FIELD(p_data, info->max_packet_length);
409409
pkt_len += 4;
410410
break;
411411
default:
412412
break;
413413
}
414414

415-
STORE16BE(p_pkt_len, pkt_len);
415+
UINT16_TO_BE_FIELD(p_pkt_len, pkt_len);
416416
p_buf->len = pkt_len;
417417
*out_pkt = p_buf;
418418
return OBEX_SUCCESS;
@@ -465,7 +465,7 @@ UINT16 OBEX_AppendHeader(BT_HDR *pkt, const UINT8 *header)
465465
pkt->len += header_len;
466466
/* point to packet len */
467467
p_data++;
468-
STORE16BE(p_data, pkt->len);
468+
UINT16_TO_BE_FIELD(p_data, pkt->len);
469469
return OBEX_SUCCESS;
470470
}
471471

@@ -481,7 +481,11 @@ UINT16 OBEX_AppendHeader(BT_HDR *pkt, const UINT8 *header)
481481
*******************************************************************************/
482482
UINT16 OBEX_AppendHeaderRaw(BT_HDR *pkt, UINT8 header_id, const UINT8 *data, UINT16 data_len)
483483
{
484-
if (pkt == NULL || data == NULL) {
484+
if (pkt == NULL) {
485+
return OBEX_INVALID_PARAM;
486+
}
487+
488+
if ((data == NULL && data_len != 0) || (data != NULL && data_len == 0)) {
485489
return OBEX_INVALID_PARAM;
486490
}
487491

@@ -524,15 +528,17 @@ UINT16 OBEX_AppendHeaderRaw(BT_HDR *pkt, UINT8 header_id, const UINT8 *data, UIN
524528
*p_start++ = header_id;
525529
if (store_header_len) {
526530
/* store header length */
527-
STORE16BE(p_start, header_len);
531+
UINT16_TO_BE_FIELD(p_start, header_len);
528532
p_start+= 2;
529533
}
530-
/* store data */
531-
memcpy(p_start, data, data_len);
534+
if (data != NULL) {
535+
/* store data */
536+
memcpy(p_start, data, data_len);
537+
}
532538
pkt->len += header_len;
533539
/* point to packet len */
534540
p_data++;
535-
STORE16BE(p_data, pkt->len);
541+
UINT16_TO_BE_FIELD(p_data, pkt->len);
536542
return OBEX_SUCCESS;
537543
}
538544

components/bt/host/bluedroid/stack/obex/obex_tl_l2cap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ void obex_tl_l2cap_disconnect_ind(UINT16 lcid, BOOLEAN is_conf_needed)
484484
return;
485485
}
486486

487+
if (p_ccb->initiator && find_scb_by_psm(p_ccb->vpsm) == NULL) {
488+
L2CA_Deregister(p_ccb->vpsm);
489+
}
490+
487491
tOBEX_TL_MSG msg = {0};
488492
msg.any.hdl = p_ccb->allocated;
489493
obex_tl_l2cap_cb.callback(OBEX_TL_DIS_CONN_EVT, &msg);

0 commit comments

Comments
 (0)