Merge branch 'feature/btdm_modify_bt_gap_structure' into 'master'

component/bt: modify BT GAP structure

See merge request idf/esp-idf!2364
pull/1880/merge
Angus Gratton 2018-05-16 19:46:55 +08:00
commit 4058ce71ce
4 zmienionych plików z 187 dodań i 137 usunięć

Wyświetl plik

@ -1022,7 +1022,7 @@ typedef struct {
/* If the device name is known to application BTA skips the remote name request */
BOOLEAN is_limited; /* TRUE, if the limited inquiry bit is set in the CoD */
INT8 rssi; /* The rssi value */
UINT8 *p_eir; /* received EIR */
UINT8 *p_eir; /* Received EIR */
#if (BLE_INCLUDED == TRUE)
UINT8 inq_result_type;
UINT8 ble_addr_type;
@ -1054,7 +1054,7 @@ typedef struct {
tBTA_SERVICE_MASK services; /* Services found on peer device. */
// btla-specific ++
UINT8 *p_raw_data; /* Raw data for discovery DB */
UINT32 raw_data_size; /* size of raw data */
UINT32 raw_data_size; /* Size of raw data */
tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
UINT32 num_uuids;
UINT8 *p_uuid_list;
@ -1075,11 +1075,17 @@ typedef union {
tBTA_DM_INQ_RES inq_res; /* Inquiry result for a peer device. */
tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
tBTA_DM_DISC_BLE_RES disc_ble_res; /* discovery result for GATT based service */
tBTA_DM_DISC_BLE_RES disc_ble_res; /* Discovery result for GATT based service */
tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
} tBTA_DM_SEARCH;
/* Structure of search callback event and structures */
typedef struct {
tBTA_DM_SEARCH_EVT event; /* Search callback events */
UINT16 len; /* Length of p_data */
tBTA_DM_SEARCH *p_data; /* Union of all search callback structures */
} tBTA_DM_SEARCH_PARAM;
/* Search callback */
typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
@ -1089,7 +1095,7 @@ typedef void (tBTA_DM_EXEC_CBACK) (void *p_param);
/* Encryption callback*/
typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS result);
/* relate to ESP_BLE_SEC_xxx in esp_gatt_defs.h */
/* Relate to ESP_BLE_SEC_xxx in esp_gatt_defs.h */
#if BLE_INCLUDED == TRUE
#define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
#define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT

Wyświetl plik

@ -32,14 +32,6 @@
#if (BTC_GAP_BT_INCLUDED == TRUE)
#include "btc_gap_bt.h"
static inline void btc_gap_bt_cb_to_app(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
{
esp_bt_gap_cb_t cb = (esp_bt_gap_cb_t)btc_profile_cb_get(BTC_PID_GAP_BT);
if (cb) {
cb(event, param);
}
}
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
/******************************************************************************
** Constants & Macros
@ -360,10 +352,22 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
}
#if (BTC_GAP_BT_INCLUDED == TRUE)
esp_bt_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_AUTH_CMPL_EVT;
param.auth_cmpl.stat = status;
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, &param);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_DEBUG("%s btc_transfer_context failed\n", __func__);
}
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
(void) status;
}

Wyświetl plik

@ -138,31 +138,35 @@ static void btc_gap_bt_get_remote_service_record(btc_gap_bt_args_t *arg)
*******************************************************************************/
static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
{
tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest;
tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src;
tBTA_DM_SEARCH_PARAM *p_dest_data = (tBTA_DM_SEARCH_PARAM *) p_dest;
tBTA_DM_SEARCH_PARAM *p_src_data = (tBTA_DM_SEARCH_PARAM *) p_src;
if (!p_src) {
return;
}
p_dest_data->p_data = (void *)osi_malloc(p_dest_data->len);
memset(p_dest_data->p_data, 0x00, p_dest_data->len);
memcpy(p_dest_data->p_data, p_src_data->p_data, p_dest_data->len);
switch (msg->aid) {
case BTA_DM_INQ_RES_EVT: {
if (p_src_data->inq_res.p_eir) {
p_dest_data->inq_res.p_eir = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->inq_res.p_eir, p_src_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN);
if ( p_dest_data->len > sizeof(tBTA_DM_SEARCH)){
switch (p_dest_data->event) {
case BTA_DM_INQ_RES_EVT: {
if (p_src_data->p_data->inq_res.p_eir) {
p_dest_data->p_data->inq_res.p_eir = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->p_data->inq_res.p_eir, p_src_data->p_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN);
}
}
}
break;
break;
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->disc_res.raw_data_size && p_src_data->disc_res.p_raw_data) {
p_dest_data->disc_res.p_raw_data = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->disc_res.p_raw_data,
p_src_data->disc_res.p_raw_data,
p_src_data->disc_res.raw_data_size);
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->p_data->disc_res.raw_data_size && p_src_data->p_data->disc_res.p_raw_data) {
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.raw_data_size);
}
}
break;
}
}
break;
}
}
@ -177,26 +181,30 @@ static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
*******************************************************************************/
static void search_service_record_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
{
tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest;
tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src;
tBTA_DM_SEARCH_PARAM *p_dest_data = (tBTA_DM_SEARCH_PARAM *) p_dest;
tBTA_DM_SEARCH_PARAM *p_src_data = (tBTA_DM_SEARCH_PARAM *) p_src;
if (!p_src) {
return;
}
switch (msg->aid) {
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->disc_res.p_raw_data && p_src_data->disc_res.raw_data_size > 0) {
p_dest_data->disc_res.p_raw_data = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->disc_res.p_raw_data,
p_src_data->disc_res.p_raw_data,
p_src_data->disc_res.raw_data_size);
p_dest_data->p_data = osi_malloc(p_dest_data->len);
memset(p_dest_data->p_data, 0x00, p_dest_data->len);
memcpy(p_dest_data->p_data, p_src_data->p_data, p_dest_data->len);
if ( p_dest_data->len > sizeof(tBTA_DM_SEARCH)){
switch (p_dest_data->event) {
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->p_data->disc_res.p_raw_data && p_src_data->p_data->disc_res.raw_data_size > 0) {
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.raw_data_size);
}
}
}
break;
default:
break;
default:
break;
}
}
}
@ -255,6 +263,10 @@ static BOOLEAN check_eir_remote_name(tBTA_DM_SEARCH *p_search_data,
*******************************************************************************/
static void bte_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
{
tBTA_DM_SEARCH_PARAM search;
search.event = event;
search.p_data = p_data;
UINT16 param_len = 0;
if (p_data) {
@ -282,31 +294,30 @@ static void bte_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_d
p_data->inq_res.remt_name_not_required = check_eir_remote_name(p_data, NULL, NULL);
}
search.len = param_len;
do {
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SEARCH_DEVICES;
msg.aid = event;
msg.act = BTC_GAP_BT_SEARCH_DEVICES_EVT;
btc_transfer_context(&msg, p_data, param_len,
(param_len > sizeof(tBTA_DM_SEARCH)) ? search_devices_copy_cb : NULL);
btc_transfer_context(&msg, &search, sizeof(tBTA_DM_SEARCH_PARAM), search_devices_copy_cb);
} while (0);
}
static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_PARAM *p_data)
{
switch (event) {
switch (p_data->event) {
case BTA_DM_DISC_RES_EVT: {
/* remote name update */
uint32_t bdname_len = strlen((const char *)p_data->disc_res.bd_name);
uint32_t bdname_len = strlen((const char *)p_data->p_data->disc_res.bd_name);
if (bdname_len) {
esp_bt_gap_dev_prop_t prop[1];
BTC_STORAGE_FILL_PROPERTY(&prop[0], ESP_BT_GAP_DEV_PROP_BDNAME, bdname_len + 1, p_data->disc_res.bd_name);
BTC_STORAGE_FILL_PROPERTY(&prop[0], ESP_BT_GAP_DEV_PROP_BDNAME, bdname_len + 1, p_data->p_data->disc_res.bd_name);
esp_bt_gap_cb_param_t param;
bdcpy(param.disc_res.bda, p_data->disc_res.bd_addr);
bdcpy(param.disc_res.bda, p_data->p_data->disc_res.bd_addr);
param.disc_res.num_prop = 1;
param.disc_res.prop = prop;
btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_RES_EVT, &param);
@ -315,7 +326,7 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR
}
case BTA_DM_INQ_RES_EVT: {
/* inquiry result */
uint32_t cod = devclass2uint (p_data->inq_res.dev_class);
uint32_t cod = devclass2uint (p_data->p_data->inq_res.dev_class);
if (cod == 0) {
BTC_TRACE_DEBUG("%s cod is 0, set as unclassified", __func__);
@ -330,17 +341,17 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR
BTC_STORAGE_FILL_PROPERTY(&prop[0], ESP_BT_GAP_DEV_PROP_COD, sizeof(cod), &cod);
num_prop++;
BTC_STORAGE_FILL_PROPERTY(&prop[1], ESP_BT_GAP_DEV_PROP_RSSI, 1, &(p_data->inq_res.rssi));
BTC_STORAGE_FILL_PROPERTY(&prop[1], ESP_BT_GAP_DEV_PROP_RSSI, 1, &(p_data->p_data->inq_res.rssi));
num_prop++;
if (p_data->inq_res.p_eir) {
BTC_STORAGE_FILL_PROPERTY(&prop[2], ESP_BT_GAP_DEV_PROP_EIR, HCI_EXT_INQ_RESPONSE_LEN, p_data->inq_res.p_eir);
if (p_data->p_data->inq_res.p_eir) {
BTC_STORAGE_FILL_PROPERTY(&prop[2], ESP_BT_GAP_DEV_PROP_EIR, HCI_EXT_INQ_RESPONSE_LEN, p_data->p_data->inq_res.p_eir);
num_prop++;
}
/* Callback to notify upper layer of device */
esp_bt_gap_cb_param_t param;
bdcpy(param.disc_res.bda, p_data->inq_res.bd_addr);
bdcpy(param.disc_res.bda, p_data->p_data->inq_res.bd_addr);
param.disc_res.num_prop = num_prop;
param.disc_res.prop = prop;
btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_RES_EVT, &param);
@ -382,18 +393,18 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR
** Returns void
**
*******************************************************************************/
static void btc_gap_bt_search_service_record(UINT16 event, char *p_param)
static void btc_gap_bt_search_service_record(char *p_param)
{
tBTA_DM_SEARCH *p_data = (tBTA_DM_SEARCH *)p_param;
tBTA_DM_SEARCH_PARAM *p_data = (tBTA_DM_SEARCH_PARAM *)p_param;
switch (event) {
switch (p_data->event) {
case BTA_DM_DISC_RES_EVT: {
esp_bt_gap_cb_param_t param;
memcpy(param.rmt_srvcs.bda, p_data->disc_res.bd_addr, BD_ADDR_LEN);
if (p_data->disc_res.p_raw_data && p_data->disc_res.raw_data_size > 0) {
memcpy(param.rmt_srvcs.bda, p_data->p_data->disc_res.bd_addr, BD_ADDR_LEN);
if (p_data->p_data->disc_res.p_raw_data && p_data->p_data->disc_res.raw_data_size > 0) {
param.rmt_srvc_rec.stat = ESP_BT_STATUS_SUCCESS;
// param.rmt_srvc_rec.raw_data_size = p_data->disc_res.raw_data_size;
// param.rmt_srvc_rec.raw_data = p_data->disc_res.p_raw_data;
// param.rmt_srvc_rec.raw_data_size = p_data->p_data->disc_res.raw_data_size;
// param.rmt_srvc_rec.raw_data = p_data->p_data->disc_res.p_raw_data;
} else {
param.rmt_srvc_rec.stat = ESP_BT_STATUS_FAIL;
// param.rmt_srvc_rec.raw_data_size = 0;
@ -421,6 +432,9 @@ static void btc_gap_bt_search_service_record(UINT16 event, char *p_param)
*******************************************************************************/
static void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
{
tBTA_DM_SEARCH_PARAM search;
search.event = event;
search.p_data = p_data;
UINT16 param_len = 0;
if (p_data) {
@ -432,17 +446,13 @@ static void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_S
param_len += p_data->disc_res.raw_data_size;
}
}
search.len = param_len;
do {
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SEARCH_SERVICE_RECORD;
msg.aid = event;
btc_transfer_context(&msg, p_data, param_len,
(param_len > sizeof(tBTA_DM_SEARCH)) ? search_service_record_copy_cb : NULL);
msg.act = BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT;
btc_transfer_context(&msg, &search, sizeof(tBTA_DM_SEARCH_PARAM), search_service_record_copy_cb);
} while (0);
}
@ -456,27 +466,27 @@ static void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_S
** Returns void
**
*******************************************************************************/
static void btc_gap_bt_search_services(UINT16 event, char *p_param)
static void btc_gap_bt_search_services(char *p_param)
{
tBTA_DM_SEARCH *p_data = (tBTA_DM_SEARCH *)p_param;
tBTA_DM_SEARCH_PARAM *p_data = (tBTA_DM_SEARCH_PARAM *)p_param;
switch (event) {
switch (p_data->event) {
case BTA_DM_DISC_RES_EVT: {
esp_bt_gap_cb_param_t param;
esp_bt_uuid_t *uuid_list = NULL;
memcpy(param.rmt_srvcs.bda, p_data->disc_res.bd_addr, BD_ADDR_LEN);
memcpy(param.rmt_srvcs.bda, p_data->p_data->disc_res.bd_addr, BD_ADDR_LEN);
param.rmt_srvcs.stat = ESP_BT_STATUS_FAIL;
if (p_data->disc_res.result == BTA_SUCCESS) {
uuid_list = malloc(sizeof(esp_bt_uuid_t) * p_data->disc_res.num_uuids);
if (p_data->p_data->disc_res.result == BTA_SUCCESS) {
uuid_list = malloc(sizeof(esp_bt_uuid_t) * p_data->p_data->disc_res.num_uuids);
if (uuid_list) {
param.rmt_srvcs.stat = ESP_BT_STATUS_SUCCESS;
param.rmt_srvcs.num_uuids = p_data->disc_res.num_uuids;
param.rmt_srvcs.num_uuids = p_data->p_data->disc_res.num_uuids;
param.rmt_srvcs.uuid_list = uuid_list;
// copy UUID list
uint8_t *i_uu = (uint8_t *)p_data->disc_res.p_uuid_list;
uint8_t *i_uu = (uint8_t *)p_data->p_data->disc_res.p_uuid_list;
esp_bt_uuid_t *o_uu = uuid_list;
for (int i = 0; i < p_data->disc_res.num_uuids; i++, i_uu += ESP_UUID_LEN_128, o_uu++) {
for (int i = 0; i < p_data->p_data->disc_res.num_uuids; i++, i_uu += ESP_UUID_LEN_128, o_uu++) {
uuid128_be_to_esp_uuid(o_uu, i_uu);
}
}
@ -513,6 +523,10 @@ static void btc_gap_bt_search_services(UINT16 event, char *p_param)
*******************************************************************************/
static void bte_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
{
tBTA_DM_SEARCH_PARAM search;
search.event = event;
search.p_data = p_data;
UINT16 param_len = 0;
if (p_data) {
param_len += sizeof(tBTA_DM_SEARCH);
@ -525,46 +539,46 @@ static void bte_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH
}
} break;
}
/* TODO: The only other member that needs a deep copy is the p_raw_data. But not sure
* if raw_data is needed. */
search.len = param_len;
do {
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_ACT_SEARCH_SERVICES;
msg.aid = event;
btc_transfer_context(&msg, p_data, param_len,
(param_len > sizeof(tBTA_DM_SEARCH)) ? search_services_copy_cb : NULL);
msg.act = BTC_GAP_BT_SEARCH_SERVICES_EVT;
btc_transfer_context(&msg, &search, sizeof(tBTA_DM_SEARCH_PARAM), search_services_copy_cb);
} while (0);
}
static void search_services_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
{
tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest;
tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src;
tBTA_DM_SEARCH_PARAM *p_dest_data = (tBTA_DM_SEARCH_PARAM *) p_dest;
tBTA_DM_SEARCH_PARAM *p_src_data = (tBTA_DM_SEARCH_PARAM *) p_src;
if (!p_src) {
return;
}
p_dest_data->p_data = osi_malloc(p_dest_data->len);
memset(p_dest_data->p_data, 0x00, p_dest_data->len);
memcpy(p_dest_data->p_data, p_src_data->p_data, p_dest_data->len);
switch (msg->aid) {
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->disc_res.result == BTA_SUCCESS) {
if (p_src_data->disc_res.num_uuids > 0) {
p_dest_data->disc_res.p_uuid_list = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->disc_res.p_uuid_list, p_src_data->disc_res.p_uuid_list,
p_src_data->disc_res.num_uuids * MAX_UUID_SIZE);
osi_free(p_src_data->disc_res.p_uuid_list);
p_src_data->disc_res.p_uuid_list = NULL;
}
if (p_src_data->disc_res.p_raw_data != NULL) {
osi_free(p_src_data->disc_res.p_raw_data);
p_src_data->disc_res.p_raw_data = NULL;
if ( p_dest_data->len > sizeof(tBTA_DM_SEARCH)){
switch (p_dest_data->event) {
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->p_data->disc_res.result == BTA_SUCCESS) {
if (p_src_data->p_data->disc_res.num_uuids > 0) {
p_dest_data->p_data->disc_res.p_uuid_list = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
memcpy(p_dest_data->p_data->disc_res.p_uuid_list, p_src_data->p_data->disc_res.p_uuid_list,
p_src_data->p_data->disc_res.num_uuids * MAX_UUID_SIZE);
osi_free(p_src_data->p_data->disc_res.p_uuid_list);
p_src_data->p_data->disc_res.p_uuid_list = NULL;
}
if (p_src_data->p_data->disc_res.p_raw_data != NULL) {
osi_free(p_src_data->p_data->disc_res.p_raw_data);
p_src_data->p_data->disc_res.p_raw_data = NULL;
}
}
} break;
}
} break;
}
}
@ -603,7 +617,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = ESP_BT_GAP_READ_RSSI_DELTA_EVT;
msg.act = BTC_GAP_BT_READ_RSSI_DELTA_EVT;
memcpy(param.read_rssi_delta.bda, result->rem_bda, sizeof(BD_ADDR));
param.read_rssi_delta.stat = btc_btm_status_to_esp_status(result->status);
param.read_rssi_delta.rssi_delta = result->rssi;
@ -612,7 +626,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
sizeof(esp_bt_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
@ -645,10 +659,6 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
btc_gap_bt_start_discovery(msg->arg);
break;
}
case BTC_GAP_BT_ACT_SEARCH_DEVICES: {
btc_gap_bt_search_devices_evt(msg->aid, msg->arg);
break;
}
case BTC_GAP_BT_ACT_CANCEL_DISCOVERY: {
btc_gap_bt_cancel_discovery();
break;
@ -657,18 +667,10 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
btc_gap_bt_get_remote_services(msg->arg);
break;
}
case BTC_GAP_BT_ACT_SEARCH_SERVICES: {
btc_gap_bt_search_services(msg->aid, msg->arg);
break;
}
case BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD: {
btc_gap_bt_get_remote_service_record(msg->arg);
break;
}
case BTC_GAP_BT_ACT_SEARCH_SERVICE_RECORD: {
btc_gap_bt_search_service_record(msg->aid, msg->arg);
break;
}
case BTC_GAP_BT_ACT_SET_COD: {
btc_gap_bt_set_cod(msg->arg);
break;
@ -704,15 +706,50 @@ void btc_gap_bt_busy_level_updated(uint8_t bl_flags)
}
}
void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
{
switch (msg->act) {
case BTC_GAP_BT_SEARCH_DEVICES_EVT:
case BTC_GAP_BT_SEARCH_SERVICES_EVT:
case BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT:
osi_free(((tBTA_DM_SEARCH_PARAM *) (msg->arg)) ->p_data);
break;
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
case BTC_GAP_BT_AUTH_CMPL_EVT:
break;
default:
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
break;
}
}
void btc_gap_bt_cb_handler(btc_msg_t *msg)
{
esp_bt_gap_cb_param_t *param = (esp_bt_gap_cb_param_t *)msg->arg;
if (msg->act < ESP_BT_GAP_EVT_MAX) {
btc_gap_bt_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknow msg->act = %d", __func__, msg->act);
switch (msg->act) {
case BTC_GAP_BT_SEARCH_DEVICES_EVT: {
btc_gap_bt_search_devices_evt(msg->arg);
break;
}
case BTC_GAP_BT_SEARCH_SERVICES_EVT: {
btc_gap_bt_search_services(msg->arg);
break;
}
case BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT: {
btc_gap_bt_search_service_record(msg->arg);
break;
}
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:{
btc_gap_bt_cb_to_app(ESP_BT_GAP_READ_RSSI_DELTA_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
case BTC_GAP_BT_AUTH_CMPL_EVT:{
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
default:
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
break;
}
btc_gap_bt_cb_deep_free(msg);
}
#endif /* (BTC_GAP_BT_INCLUDED == TRUE) */

Wyświetl plik

@ -22,17 +22,20 @@
#include "bta/utl.h"
#if (BTC_GAP_BT_INCLUDED == TRUE)
typedef enum {
BTC_GAP_BT_SEARCH_DEVICES_EVT = 0,
BTC_GAP_BT_SEARCH_SERVICES_EVT,
BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT,
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
BTC_GAP_BT_AUTH_CMPL_EVT,
}btc_gap_bt_evt_t;
typedef enum {
BTC_GAP_BT_ACT_SET_SCAN_MODE = 0,
BTC_GAP_BT_ACT_REG_CB,
BTC_GAP_BT_ACT_START_DISCOVERY,
BTC_GAP_BT_ACT_SEARCH_DEVICES,
BTC_GAP_BT_ACT_CANCEL_DISCOVERY,
BTC_GAP_BT_ACT_GET_REMOTE_SERVICES,
BTC_GAP_BT_ACT_SEARCH_SERVICES,
BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD,
BTC_GAP_BT_ACT_SEARCH_SERVICE_RECORD,
BTC_GAP_BT_ACT_SET_COD,
BTC_GAP_BT_ACT_READ_RSSI_DELTA,
BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE,
@ -52,10 +55,10 @@ typedef union {
uint8_t num_rsps;
} start_disc;
// BTC_BT_GAP_ACT_GET_REMOTE_SERVICES
// BTC_GAP_BT_ACT_GET_REMOTE_SERVICES
bt_bdaddr_t bda;
// BTC_BT_GAP_ACT_GET_REMTOE_SERVICE_RECORD
// BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD
struct get_rmt_srv_rcd_args {
bt_bdaddr_t bda;
esp_bt_uuid_t uuid;