mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/get_remote_name' into 'master'
Feature/ Read Remote Device's Name See merge request espressif/esp-idf!6562
This commit is contained in:
commit
a9c162664c
@ -398,4 +398,22 @@ esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels)
|
||||
arg.set_afh_channels.channels[ESP_BT_GAP_AFH_CHANNELS_LEN -1] &= 0x7F;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_read_remote_name(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_READ_REMOTE_NAME;
|
||||
|
||||
memcpy(&arg.rmt_name_bda, remote_bda, sizeof(bt_bdaddr_t));
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
@ -207,6 +207,7 @@ typedef enum {
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_CONFIG_EIR_DATA_EVT, /*!< config EIR data event */
|
||||
ESP_BT_GAP_SET_AFH_CHANNELS_EVT, /*!< set AFH channels event */
|
||||
ESP_BT_GAP_READ_REMOTE_NAME_EVT, /*!< read Remote Name event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
@ -324,6 +325,15 @@ typedef union {
|
||||
struct set_afh_channels_param {
|
||||
esp_bt_status_t stat; /*!< set AFH channel status */
|
||||
} set_afh_channels; /*!< set AFH channel parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_READ_REMOTE_NAME_EVT
|
||||
*/
|
||||
struct read_rmt_name_param {
|
||||
esp_bt_status_t stat; /*!< read Remote Name status */
|
||||
uint8_t rmt_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< Remote device name */
|
||||
} read_rmt_name; /*!< read Remote Name parameter struct */
|
||||
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -665,6 +675,18 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels);
|
||||
|
||||
/**
|
||||
* @brief Read the remote device name
|
||||
*
|
||||
* @param[in] remote_bda: The remote device's address
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_read_remote_name(esp_bd_addr_t remote_bda);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -680,6 +680,77 @@ void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data)
|
||||
#endif /// CLASSIC_BT_INCLUDED
|
||||
}
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_read_remote_device_name
|
||||
**
|
||||
** Description Initiate to get remote device name
|
||||
**
|
||||
** Returns TRUE if started to get remote name
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
{
|
||||
tBTM_STATUS btm_status;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name");
|
||||
|
||||
bdcpy(bta_dm_search_cb.peer_bdaddr, bd_addr);
|
||||
bta_dm_search_cb.peer_name[0] = 0;
|
||||
|
||||
btm_status = BTM_ReadRemoteDeviceName (bta_dm_search_cb.peer_bdaddr,
|
||||
(tBTM_CMPL_CB *) bta_dm_remname_cback,
|
||||
transport);
|
||||
|
||||
if ( btm_status == BTM_CMD_STARTED ) {
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName is started");
|
||||
|
||||
return (TRUE);
|
||||
} else if ( btm_status == BTM_BUSY ) {
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName is busy");
|
||||
|
||||
/* Remote name discovery is on going now so BTM cannot notify through "bta_dm_remname_cback" */
|
||||
/* adding callback to get notified that current reading remore name done */
|
||||
BTM_SecAddRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
|
||||
|
||||
return (TRUE);
|
||||
} else {
|
||||
APPL_TRACE_WARNING("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName returns 0x%02X", btm_status);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_read_rmt_name
|
||||
**
|
||||
** Description Initiate to get remote device name
|
||||
**
|
||||
** Returns TRUE if started to get remote name
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s",__func__);
|
||||
bdcpy(bta_dm_search_cb.peer_bdaddr, p_data->get_rmt_name.rmt_addr);
|
||||
bta_dm_search_cb.peer_name[0] = 0;
|
||||
|
||||
tBTM_STATUS btm_status = BTM_ReadRemoteDeviceName(bta_dm_search_cb.peer_bdaddr,
|
||||
(tBTM_CMPL_CB *) p_data->get_rmt_name.rmt_name_cb,
|
||||
bta_dm_search_cb.transport);
|
||||
|
||||
if (btm_status == BTM_CMD_STARTED) {
|
||||
BTM_TRACE_DEBUG("%s: BTM_ReadRemoteDeviceName is started",__func__);
|
||||
} else if (btm_status == BTM_BUSY) {
|
||||
BTM_TRACE_DEBUG("%s: BTM_ReadRemoteDeviceName is busy",__func__);
|
||||
} else {
|
||||
BTM_TRACE_WARNING("%s: BTM_ReadRemoteDeviceName returns 0x%02X",__func__, btm_status);
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
void bta_dm_config_eir (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTA_DM_API_CONFIG_EIR *config_eir = &p_data->config_eir;
|
||||
@ -724,7 +795,7 @@ void bta_dm_config_eir (tBTA_DM_MSG *p_data)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_set_afh_channels
|
||||
** Function bta_dm_ble_set_channels
|
||||
**
|
||||
** Description Sets AFH channels
|
||||
**
|
||||
@ -1662,49 +1733,6 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_read_remote_device_name
|
||||
**
|
||||
** Description Initiate to get remote device name
|
||||
**
|
||||
** Returns TRUE if started to get remote name
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
{
|
||||
tBTM_STATUS btm_status;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name");
|
||||
|
||||
bdcpy(bta_dm_search_cb.peer_bdaddr, bd_addr);
|
||||
bta_dm_search_cb.peer_name[0] = 0;
|
||||
|
||||
btm_status = BTM_ReadRemoteDeviceName (bta_dm_search_cb.peer_bdaddr,
|
||||
(tBTM_CMPL_CB *) bta_dm_remname_cback,
|
||||
transport);
|
||||
|
||||
if ( btm_status == BTM_CMD_STARTED ) {
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName is started");
|
||||
|
||||
return (TRUE);
|
||||
} else if ( btm_status == BTM_BUSY ) {
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName is busy");
|
||||
|
||||
/* Remote name discovery is on going now so BTM cannot notify through "bta_dm_remname_cback" */
|
||||
/* adding callback to get notified that current reading remore name done */
|
||||
BTM_SecAddRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
|
||||
|
||||
return (TRUE);
|
||||
} else {
|
||||
APPL_TRACE_WARNING("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName returns 0x%02X", btm_status);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_inq_cmpl
|
||||
@ -2775,7 +2803,6 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
|
||||
|
||||
APPL_TRACE_DEBUG("bta_dm_remname_cback len = %d name=<%s>", p_remote_name->length,
|
||||
p_remote_name->remote_bd_name);
|
||||
|
||||
/* remote name discovery is done but it could be failed */
|
||||
bta_dm_search_cb.name_discover_done = TRUE;
|
||||
BCM_STRNCPY_S((char *)bta_dm_search_cb.peer_name, sizeof(BD_NAME), (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN));
|
||||
@ -2798,7 +2825,6 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
|
||||
|
||||
p_msg->hdr.event = BTA_DM_REMT_NAME_EVT;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,6 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
|
||||
@ -238,7 +236,6 @@ void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb)
|
||||
{
|
||||
|
||||
tBTA_DM_API_SET_AFH_CHANNELS *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_AFH_CHANNELS *) osi_malloc(sizeof(tBTA_DM_API_SET_AFH_CHANNELS))) != NULL) {
|
||||
@ -249,11 +246,33 @@ void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb)
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif /// CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmGetRemoteName
|
||||
**
|
||||
** Description This function gets the peer device's Bluetooth name.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmGetRemoteName(BD_ADDR remote_addr, tBTA_CMPL_CB *rmt_name_cb)
|
||||
{
|
||||
tBTA_DM_API_GET_REMOTE_NAME *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_GET_REMOTE_NAME *) osi_malloc(sizeof(tBTA_DM_API_GET_REMOTE_NAME))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_GET_REMOTE_NAME_EVT;
|
||||
p_msg->rmt_name_cb = rmt_name_cb;
|
||||
bdcpy(p_msg->rmt_addr, remote_addr);
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -401,6 +420,7 @@ void BTA_DmSearchCancel(void)
|
||||
|
||||
}
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmDiscover
|
||||
@ -412,7 +432,6 @@ void BTA_DmSearchCancel(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
|
||||
{
|
||||
|
@ -58,6 +58,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
|
||||
bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_read_rmt_name, /* BTA_DM_API_GET_REMOTE_NAME_EVT*/
|
||||
#endif
|
||||
bta_dm_set_visibility, /* BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */
|
||||
|
@ -54,6 +54,9 @@ enum {
|
||||
BTA_DM_API_SET_NAME_EVT,
|
||||
BTA_DM_API_CONFIG_EIR_EVT,
|
||||
BTA_DM_API_SET_AFH_CHANNELS_EVT,
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_API_GET_REMOTE_NAME_EVT,
|
||||
#endif
|
||||
BTA_DM_API_SET_VISIBILITY_EVT,
|
||||
|
||||
BTA_DM_ACL_CHANGE_EVT,
|
||||
@ -214,6 +217,15 @@ typedef struct {
|
||||
tBTA_CMPL_CB *set_afh_cb;
|
||||
}tBTA_DM_API_SET_AFH_CHANNELS;
|
||||
|
||||
/* data type for BTA_DM_API_GET_REMOTE_NAME_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR rmt_addr;
|
||||
BD_NAME rmt_name;
|
||||
tBTA_TRANSPORT transport;
|
||||
tBTA_CMPL_CB *rmt_name_cb;
|
||||
} tBTA_DM_API_GET_REMOTE_NAME;
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/* data type for BTA_DM_API_BLE_SET_CHANNELS_EVT */
|
||||
typedef struct {
|
||||
@ -822,6 +834,9 @@ typedef union {
|
||||
tBTA_DM_API_CONFIG_EIR config_eir;
|
||||
|
||||
tBTA_DM_API_SET_AFH_CHANNELS set_afh_channels;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tBTA_DM_API_GET_REMOTE_NAME get_rmt_name;
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBTA_DM_API_BLE_SET_CHANNELS ble_set_channels;
|
||||
@ -1282,6 +1297,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
|
||||
|
@ -418,7 +418,6 @@ typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK;
|
||||
|
||||
|
||||
typedef tBTM_ADD_WHITELIST_CBACK tBTA_ADD_WHITELIST_CBACK;
|
||||
|
||||
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
|
||||
@ -435,6 +434,9 @@ typedef tBTM_RSSI_RESULTS tBTA_RSSI_RESULTS;
|
||||
|
||||
typedef tBTM_SET_AFH_CHANNELS_RESULTS tBTA_SET_AFH_CHANNELS_RESULTS;
|
||||
typedef tBTM_BLE_SET_CHANNELS_RESULTS tBTA_BLE_SET_CHANNELS_RESULTS;
|
||||
|
||||
typedef tBTM_REMOTE_DEV_NAME tBTA_REMOTE_DEV_NAME;
|
||||
|
||||
/* advertising channel map */
|
||||
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
||||
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
||||
@ -1103,15 +1105,22 @@ typedef struct {
|
||||
tBT_UUID service; /* GATT based Services UUID found on peer device. */
|
||||
} tBTA_DM_DISC_BLE_RES;
|
||||
|
||||
/* Structure associated with tBTA_DM_RMTNAME_CMPL */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr;
|
||||
BD_NAME bd_name;
|
||||
tBTA_CMPL_CB *read_rmtname_cb;
|
||||
} tBTA_DM_RMTNAME_CMPL;
|
||||
|
||||
/* Union of all search callback structures */
|
||||
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_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_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
|
||||
tBTA_DM_INQ_DISCARD inq_dis; /* the discarded packets information of inquiry */
|
||||
tBTA_DM_INQ_DISCARD inq_dis; /* the discarded packets information of inquiry */
|
||||
tBTA_DM_RMTNAME_CMPL rmt_name; /* the remote name information */
|
||||
} tBTA_DM_SEARCH;
|
||||
|
||||
/* Structure of search callback event and structures */
|
||||
@ -1463,6 +1472,18 @@ extern void BTA_DisableTestMode(void);
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmGetRemoteName
|
||||
**
|
||||
** Description This function gets the peer device's Bluetooth name.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmGetRemoteName(BD_ADDR remote_addr, tBTA_CMPL_CB *read_remote_name_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmConfigEir
|
||||
|
@ -200,7 +200,7 @@ void bta_sys_free(void)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sm_execute
|
||||
** Function bta_sys_sm_execute
|
||||
**
|
||||
** Description State machine event handling function for DM
|
||||
**
|
||||
|
@ -733,6 +733,30 @@ static void btc_gap_bt_set_afh_channels(btc_gap_bt_args_t *arg)
|
||||
BTA_DmSetAfhChannels(arg->set_afh_channels.channels, btc_gap_bt_set_afh_channels_cmpl_callback);
|
||||
}
|
||||
|
||||
static void btc_gap_bt_read_remote_name_cmpl_callback(void *p_data)
|
||||
{
|
||||
tBTA_REMOTE_DEV_NAME *result = (tBTA_REMOTE_DEV_NAME *)p_data;
|
||||
esp_bt_gap_cb_param_t param;
|
||||
btc_msg_t msg;
|
||||
bt_status_t ret;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_READ_REMOTE_NAME_EVT;
|
||||
|
||||
param.read_rmt_name.stat = btc_btm_status_to_esp_status(result->status);
|
||||
memcpy(param.read_rmt_name.rmt_name,result->remote_bd_name,ESP_BT_GAP_MAX_BDNAME_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gap_bt_read_remote_name(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmGetRemoteName(arg->rmt_name_bda.address, btc_gap_bt_read_remote_name_cmpl_callback);
|
||||
}
|
||||
|
||||
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
switch (msg->act) {
|
||||
@ -746,6 +770,8 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE:
|
||||
case BTC_GAP_BT_ACT_PIN_REPLY:
|
||||
case BTC_GAP_BT_ACT_SET_PIN_TYPE:
|
||||
case BTC_GAP_BT_ACT_SET_AFH_CHANNELS:
|
||||
case BTC_GAP_BT_ACT_READ_REMOTE_NAME:
|
||||
break;
|
||||
#if (BT_SSP_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
@ -809,6 +835,8 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE:
|
||||
case BTC_GAP_BT_ACT_PIN_REPLY:
|
||||
case BTC_GAP_BT_ACT_SET_PIN_TYPE:
|
||||
case BTC_GAP_BT_ACT_SET_AFH_CHANNELS:
|
||||
case BTC_GAP_BT_ACT_READ_REMOTE_NAME:
|
||||
break;
|
||||
#if (BT_SSP_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
@ -903,7 +931,10 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_set_afh_channels(arg);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTC_GAP_BT_ACT_READ_REMOTE_NAME: {
|
||||
btc_gap_bt_read_remote_name(arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -940,6 +971,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:
|
||||
case BTC_GAP_BT_SET_AFH_CHANNELS_EVT:
|
||||
case BTC_GAP_BT_READ_REMOTE_NAME_EVT:
|
||||
#if (BT_SSP_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_CFM_REQ_EVT:
|
||||
case BTC_GAP_BT_KEY_NOTIF_EVT:
|
||||
@ -1001,6 +1033,12 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_SET_AFH_CHANNELS_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_READ_REMOTE_NAME_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_READ_REMOTE_NAME_EVT,(esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
@ -35,6 +35,7 @@ typedef enum {
|
||||
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
|
||||
BTC_GAP_BT_CONFIG_EIR_DATA_EVT,
|
||||
BTC_GAP_BT_SET_AFH_CHANNELS_EVT,
|
||||
BTC_GAP_BT_READ_REMOTE_NAME_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
@ -53,6 +54,7 @@ typedef enum {
|
||||
BTC_GAP_BT_ACT_CONFIRM_REPLY,
|
||||
BTC_GAP_BT_ACT_CONFIG_EIR,
|
||||
BTC_GAP_BT_ACT_SET_AFH_CHANNELS,
|
||||
BTC_GAP_BT_ACT_READ_REMOTE_NAME,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
@ -139,6 +141,10 @@ typedef union {
|
||||
struct set_afh_channels_args {
|
||||
esp_bt_gap_afh_channels channels;
|
||||
} set_afh_channels;
|
||||
|
||||
// BTC_GAP_BT_ACT_READ_REMOTE_NAME
|
||||
bt_bdaddr_t rmt_name_bda;
|
||||
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
@ -1111,7 +1111,7 @@ tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_chann
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_set_afh_channels_complete
|
||||
** Function btm_ble_set_channels_complete
|
||||
**
|
||||
** Description This function is called when setting AFH channels complete.
|
||||
** message is received from the HCI.
|
||||
|
@ -1030,7 +1030,7 @@ tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb
|
||||
BTM_TRACE_API ("BTM_ReadRemoteDeviceName: bd addr [%02x%02x%02x%02x%02x%02x]\n",
|
||||
remote_bda[0], remote_bda[1], remote_bda[2],
|
||||
remote_bda[3], remote_bda[4], remote_bda[5]);
|
||||
|
||||
|
||||
/* Use the remote device's clock offset if it is in the local inquiry database */
|
||||
if ((p_i = btm_inq_db_find (remote_bda)) != NULL) {
|
||||
p_cur = &p_i->inq_info;
|
||||
@ -2178,19 +2178,17 @@ void btm_process_cancel_complete(UINT8 status, UINT8 mode)
|
||||
** BTM_WRONG_MODE if the device is not up.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS btm_initiate_rem_name (BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur,
|
||||
tBTM_STATUS btm_initiate_rem_name (BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur,
|
||||
UINT8 origin, UINT32 timeout, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
|
||||
BOOLEAN cmd_ok;
|
||||
|
||||
|
||||
/*** Make sure the device is ready ***/
|
||||
if (!BTM_IsDeviceUp()) {
|
||||
return (BTM_WRONG_MODE);
|
||||
}
|
||||
|
||||
|
||||
if (origin == BTM_RMT_NAME_SEC) {
|
||||
cmd_ok = btsnd_hcic_rmt_name_req (remote_bda, HCI_PAGE_SCAN_REP_MODE_R1,
|
||||
HCI_MANDATARY_PAGE_SCAN_MODE, 0);
|
||||
@ -2302,8 +2300,6 @@ void btm_process_remote_name (BD_ADDR bda, BD_NAME bdn, UINT16 evt_len, UINT8 hc
|
||||
}
|
||||
rem_name.remote_bd_name[rem_name.length] = 0;
|
||||
}
|
||||
|
||||
|
||||
/* If processing a stand alone remote name then report the error in the callback */
|
||||
else {
|
||||
rem_name.status = BTM_BAD_VALUE_RET;
|
||||
|
@ -295,7 +295,6 @@ BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback)
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_SecDeleteRmtNameNotifyCallback
|
||||
|
Loading…
x
Reference in New Issue
Block a user