]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: add set gap icon API
authorzhiweijian <zhiweijian@espressif.com>
Mon, 26 Mar 2018 09:02:24 +0000 (17:02 +0800)
committerbot <bot@espressif.com>
Fri, 30 Mar 2018 09:21:53 +0000 (09:21 +0000)
components/bt/bluedroid/api/esp_gap_ble_api.c
components/bt/bluedroid/api/include/esp_gap_ble_api.h
components/bt/bluedroid/bta/dm/bta_dm_act.c
components/bt/bluedroid/bta/dm/bta_dm_api.c
components/bt/bluedroid/bta/dm/bta_dm_main.c
components/bt/bluedroid/bta/include/bta_api.h
components/bt/bluedroid/bta/include/bta_dm_int.h
components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c
components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h
components/bt/bluedroid/stack/btm/btm_ble_gap.c
components/bt/bluedroid/stack/include/btm_ble_api.h

index 84df9d6131ee519e2f837df920c9e957cef9478f..ecfccca5bfb5d57359c5d07f95b23255522c4707 100644 (file)
@@ -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;
index 3e0c16e349f24372583b14641abb2e7340fbd060..baba893f1c8bbd5811aff598ff37053a54b26b43 100644 (file)
@@ -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
 *
index fb21560bfb8e53ee6594a944ebbee79d60f25130..7fb3ddac66a6d3e156367d81d701f53ef7e52abd 100644 (file)
@@ -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
index 060692fcd72c69e5fff4ee5498f953865bb78dd8..7558788beb163ce32d61a21e63c1f8a8906f39e6 100644 (file)
@@ -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
index ed118adfb8c8ef1dff5f034f296574dbfefc8079..9d3b42d637f4c22c0f99f0062478b1c53932010f 100644 (file)
@@ -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 */
index a13c082273989218cfe5baca51d350da32958074..8df5952d6222c25fb06eccddc4b155ba4224cd7a 100644 (file)
@@ -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
index a95bb676ecedffad9b44ef841c3f4ffc641d6b33..a27c94979f007456c72f4ffc76d1d45046589d57 100644 (file)
@@ -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);
index 19c47b607c809add1154f486ad9ae42b9ef3b3d3..93df5ba0d2191c786e41a3a5efbc5231cb057b81 100644 (file)
@@ -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;
index ba744702b295edec58b905e02af4c88e63ce7f79..9ee03d4117168daecdd2514669b0341bc8eab2e1 100644 (file)
@@ -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;
index b5faafe166eda9ff27a53782e0f4664ca0f9c11d..4d1bf10f9917c886035ae131fd254881c65781b0 100644 (file)
@@ -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
index 6d6837a3d7d07e1478219325f01fde30cce96151..707be455af5dc6609d3236a44c33b6b346be971b 100644 (file)
@@ -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