mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Component/bt: add set gap icon API
This commit is contained in:
parent
e6d6deebc7
commit
99872beb6a
@ -195,6 +195,21 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
|
||||
arg.cfg_local_icon.icon = icon;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
@ -775,6 +775,20 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
/**
|
||||
* @brief set local gap appearance icon
|
||||
*
|
||||
*
|
||||
* @param[in] icon - Appearance value, these vlues are Defined by the Bluetooth organization, please refer to
|
||||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.gap.appearance.xml
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_local_icon (uint16_t icon);
|
||||
|
||||
/**
|
||||
* @brief Add or remove device from white list
|
||||
*
|
||||
|
@ -4677,6 +4677,19 @@ void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_config_local_privacy
|
||||
**
|
||||
** Description This function set the local device LE privacy settings.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_BleConfigLocalIcon (p_data->ble_local_icon.icon);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_observe
|
||||
|
@ -1629,6 +1629,30 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleConfigLocalIcon
|
||||
**
|
||||
** Description set gap local icon
|
||||
**
|
||||
** Parameters: icon - appearance value.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleConfigLocalIcon(uint16_t icon)
|
||||
{
|
||||
tBTA_DM_API_LOCAL_ICON *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_LOCAL_ICON *) osi_malloc(sizeof(tBTA_DM_API_LOCAL_ICON))) != NULL) {
|
||||
memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_ICON));
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_LOCAL_ICON_EVT;
|
||||
p_msg->icon = icon;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_BleEnableAdvInstance
|
||||
|
@ -111,6 +111,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||
#endif
|
||||
bta_dm_ble_config_local_icon, /* BTA_DM_API_LOCAL_ICON_EVT */
|
||||
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
||||
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
|
||||
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
||||
|
@ -2081,6 +2081,19 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleConfigLocalIcon
|
||||
**
|
||||
** Description set gap local icon
|
||||
**
|
||||
** Parameters: icon - appearance value.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleConfigLocalIcon(uint16_t icon);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleEnableRemotePrivacy
|
||||
|
@ -108,6 +108,7 @@ enum {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
BTA_DM_API_LOCAL_PRIVACY_EVT,
|
||||
#endif
|
||||
BTA_DM_API_LOCAL_ICON_EVT,
|
||||
BTA_DM_API_BLE_ADV_PARAM_EVT,
|
||||
|
||||
/*******This event added by Yulong at 2016/10/20 to
|
||||
@ -468,6 +469,11 @@ typedef struct {
|
||||
tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||
} tBTA_DM_API_LOCAL_PRIVACY;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
uint16_t icon;
|
||||
} tBTA_DM_API_LOCAL_ICON;
|
||||
|
||||
/* set scan parameter for BLE connections */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@ -775,6 +781,7 @@ typedef union {
|
||||
tBTA_DM_API_BLE_SCAN ble_scan;
|
||||
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
|
||||
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
|
||||
tBTA_DM_API_LOCAL_ICON ble_local_icon;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
|
||||
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
|
||||
@ -1180,6 +1187,7 @@ extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params_all(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
|
||||
|
@ -848,6 +848,11 @@ static void btc_ble_set_pkt_data_len(BD_ADDR remote_device, uint16_t tx_data_len
|
||||
BTA_DmBleSetDataLength(remote_device, tx_data_length, p_set_pkt_data_cback);
|
||||
}
|
||||
|
||||
static void btc_ble_config_local_icon(uint16_t icon)
|
||||
{
|
||||
BTA_DmBleConfigLocalIcon(icon);
|
||||
}
|
||||
|
||||
static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback)
|
||||
{
|
||||
if (rand_addr != NULL) {
|
||||
@ -1075,6 +1080,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
case BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY:
|
||||
btc_ble_config_local_privacy(arg->cfg_local_privacy.privacy_enable, btc_set_local_privacy_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON:
|
||||
btc_ble_config_local_icon(arg->cfg_local_icon.icon);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST:
|
||||
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
|
||||
break;
|
||||
|
@ -31,6 +31,7 @@ typedef enum {
|
||||
BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN,
|
||||
BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
|
||||
BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON,
|
||||
BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST,
|
||||
BTC_GAP_BLE_ACT_SET_CONN_PARAMS,
|
||||
BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
@ -83,6 +84,10 @@ typedef union {
|
||||
struct cfg_local_privacy_args {
|
||||
bool privacy_enable;
|
||||
} cfg_local_privacy;
|
||||
//BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON,
|
||||
struct cfg_local_icon_args {
|
||||
uint16_t icon;
|
||||
} cfg_local_icon;
|
||||
//BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST
|
||||
struct update_white_list_args {
|
||||
bool add_remove;
|
||||
|
@ -812,6 +812,26 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleConfigLocalIcon
|
||||
**
|
||||
** Description This function is called to set local icon
|
||||
**
|
||||
** Parameters icon: appearance value.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_BleConfigLocalIcon(uint16_t icon)
|
||||
{
|
||||
#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE)
|
||||
tGAP_BLE_ATTR_VALUE p_value;
|
||||
p_value.icon = icon;
|
||||
GAP_BleAttrDBUpdate(GATT_UUID_GAP_ICON, &p_value);
|
||||
#else
|
||||
BTM_TRACE_ERROR("%s\n", __func__);
|
||||
#endif
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleMaxMultiAdvInstanceCount
|
||||
|
@ -1632,6 +1632,18 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_st
|
||||
//extern
|
||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleConfigLocalIcon
|
||||
**
|
||||
** Description This function is called to set local icon
|
||||
**
|
||||
** Parameters icon: appearance value.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_BleConfigLocalIcon(uint16_t icon);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleLocalPrivacyEnabled
|
||||
|
Loading…
x
Reference in New Issue
Block a user