bt: fix SDP event status overwritten by handle

This commit is contained in:
AlbertWDev 2023-01-24 20:39:33 +01:00 committed by xiongweichao
parent 885e501d99
commit a16896af68
3 changed files with 19 additions and 13 deletions

View File

@ -40,12 +40,12 @@ typedef UINT8 tBTA_SDP_STATUS;
/* SDP I/F callback events */ /* SDP I/F callback events */
/* events received by tBTA_SDP_DM_CBACK */ /* events received by tBTA_SDP_DM_CBACK */
#define BTA_SDP_ENABLE_EVT 0 /* SDP service enabled*/ #define BTA_SDP_ENABLE_EVT 0 /* SDP service enabled */
#define BTA_SDP_DISENABLE_EVT 1 /* SDP service disenabled*/ #define BTA_SDP_DISENABLE_EVT 1 /* SDP service disenabled */
#define BTA_SDP_SEARCH_EVT 2 /* SDP search started */ #define BTA_SDP_SEARCH_EVT 2 /* SDP search started */
#define BTA_SDP_SEARCH_COMP_EVT 3 /* SDP search complete */ #define BTA_SDP_SEARCH_COMP_EVT 3 /* SDP search complete */
#define BTA_SDP_CREATE_RECORD_USER_EVT 4 /* SDP create record complete */ #define BTA_SDP_CREATE_RECORD_USER_EVT 4 /* SDP create record complete */
#define BTA_SDP_REMOVE_RECORD_USER_EVT 5 /* SDP remove reocrd complete */ #define BTA_SDP_REMOVE_RECORD_USER_EVT 5 /* SDP remove record complete */
#define BTA_SDP_MAX_EVT 6 /* max number of SDP events */ #define BTA_SDP_MAX_EVT 6 /* max number of SDP events */
#define BTA_SDP_MAX_RECORDS 15 #define BTA_SDP_MAX_RECORDS 15
@ -61,10 +61,16 @@ typedef struct {
bluetooth_sdp_record records[BTA_SDP_MAX_RECORDS]; bluetooth_sdp_record records[BTA_SDP_MAX_RECORDS];
} tBTA_SDP_SEARCH_COMP; } tBTA_SDP_SEARCH_COMP;
/* data associated with BTA_SDP_CREATE_RECORD_USER_EVT */
typedef struct {
tBTA_SDP_STATUS status;
int handle;
} tBTA_SDP_CREATE_RECORD_USER;
typedef union { typedef union {
tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */ tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */
tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */ tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */
int handle; tBTA_SDP_CREATE_RECORD_USER sdp_create_record; /* BTA_SDP_CREATE_RECORD_USER_EVT */
} tBTA_SDP; } tBTA_SDP;
/* SDP DM Interface callback */ /* SDP DM Interface callback */

View File

@ -546,9 +546,9 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data)
/******************************************************************************* /*******************************************************************************
** **
** Function bta_sdp_record ** Function bta_sdp_create_record
** **
** Description Discovers all sdp records for an uuid on remote device ** Description Creates an SDP record for a handle
** **
** Returns void ** Returns void
** **
@ -556,19 +556,19 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data)
void bta_sdp_create_record(tBTA_SDP_MSG *p_data) void bta_sdp_create_record(tBTA_SDP_MSG *p_data)
{ {
APPL_TRACE_DEBUG("%s() event: %d\n", __func__, p_data->record.hdr.event); APPL_TRACE_DEBUG("%s() event: %d\n", __func__, p_data->record.hdr.event);
tBTA_SDP bta_sdp; tBTA_SDP_CREATE_RECORD_USER bta_sdp = {0};
bta_sdp.status = BTA_SDP_SUCCESS; bta_sdp.status = BTA_SDP_SUCCESS;
bta_sdp.handle = (int)p_data->record.user_data; bta_sdp.handle = (int)p_data->record.user_data;
if (bta_sdp_cb.p_dm_cback) { if (bta_sdp_cb.p_dm_cback) {
bta_sdp_cb.p_dm_cback(BTA_SDP_CREATE_RECORD_USER_EVT, &bta_sdp, p_data->record.user_data); bta_sdp_cb.p_dm_cback(BTA_SDP_CREATE_RECORD_USER_EVT, (tBTA_SDP *)&bta_sdp, p_data->record.user_data);
} }
} }
/******************************************************************************* /*******************************************************************************
** **
** Function bta_sdp_create_record ** Function bta_sdp_remove_record
** **
** Description Discovers all sdp records for an uuid on remote device ** Description Removes an SDP record
** **
** Returns void ** Returns void
** **

View File

@ -1111,7 +1111,7 @@ void btc_sdp_cb_handler(btc_msg_t *msg)
btc_sdp_cb_to_app(ESP_SDP_DEINIT_EVT, &param); btc_sdp_cb_to_app(ESP_SDP_DEINIT_EVT, &param);
break; break;
case BTA_SDP_SEARCH_COMP_EVT: case BTA_SDP_SEARCH_COMP_EVT:
param.search.status = p_data->status; param.search.status = p_data->sdp_search_comp.status;
if (param.search.status == ESP_SDP_SUCCESS) { if (param.search.status == ESP_SDP_SUCCESS) {
memcpy(param.search.remote_addr, p_data->sdp_search_comp.remote_addr, sizeof(BD_ADDR)); memcpy(param.search.remote_addr, p_data->sdp_search_comp.remote_addr, sizeof(BD_ADDR));
memcpy(&param.search.sdp_uuid, &p_data->sdp_search_comp.uuid, sizeof(tSDP_UUID)); memcpy(&param.search.sdp_uuid, &p_data->sdp_search_comp.uuid, sizeof(tSDP_UUID));
@ -1131,8 +1131,8 @@ void btc_sdp_cb_handler(btc_msg_t *msg)
} }
break; break;
case BTA_SDP_CREATE_RECORD_USER_EVT: case BTA_SDP_CREATE_RECORD_USER_EVT:
param.create_record.status = p_data->status; param.create_record.status = p_data->sdp_create_record.status;
param.create_record.record_handle = p_data->handle; param.create_record.record_handle = p_data->sdp_create_record.handle;
btc_sdp_cb_to_app(ESP_SDP_CREATE_RECORD_COMP_EVT, &param); btc_sdp_cb_to_app(ESP_SDP_CREATE_RECORD_COMP_EVT, &param);
break; break;
case BTA_SDP_REMOVE_RECORD_USER_EVT: case BTA_SDP_REMOVE_RECORD_USER_EVT: