]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: add BLE adv report flow control
authorzhiweijian <zhiweijian@espressif.com>
Fri, 1 Mar 2019 13:59:55 +0000 (21:59 +0800)
committerzhiweijian <zhiweijian@espressif.com>
Tue, 12 Mar 2019 03:10:26 +0000 (11:10 +0800)
20 files changed:
components/bt/Kconfig
components/bt/bluedroid/api/include/api/esp_gap_ble_api.h
components/bt/bluedroid/bta/dm/bta_dm_act.c
components/bt/bluedroid/bta/include/bta/bta_api.h
components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c
components/bt/bluedroid/common/include/common/bt_target.h
components/bt/bluedroid/device/controller.c
components/bt/bluedroid/hci/hci_hal_h4.c
components/bt/bluedroid/hci/hci_layer.c
components/bt/bluedroid/hci/hci_packet_factory.c
components/bt/bluedroid/hci/include/hci/hci_packet_factory.h
components/bt/bluedroid/stack/btm/btm_ble_gap.c
components/bt/bluedroid/stack/btm/include/btm_ble_int.h
components/bt/bluedroid/stack/btu/btu_hcif.c
components/bt/bluedroid/stack/hcic/hciblecmds.c
components/bt/bluedroid/stack/include/stack/btm_api.h
components/bt/bluedroid/stack/include/stack/btm_ble_api.h
components/bt/bluedroid/stack/include/stack/hcidefs.h
components/bt/bluedroid/stack/include/stack/hcimsgs.h
components/bt/lib

index d0152d6ff802e500e15f77584d0fd3c489e7b86c..2215c3e22315bfc8f09e802ceec7d860bf8d1bc2 100644 (file)
@@ -258,6 +258,40 @@ menu Bluetooth
                 The full scan function is mainly used to provide BLE scan performance.
                 This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
 
+        config BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
+            bool "BLE adv report flow control supported"
+            depends on (BTDM_CONTROLLER_MODE_BTDM || BTDM_CONTROLLER_MODE_BLE_ONLY)
+            default y
+            help
+                The function is mainly used to enable flow control for advertising reports. When it is enabled,
+                advertising reports will be discarded by the controller if the number of unprocessed advertising
+                reports exceeds the size of BLE adv report flow control.
+
+        config BLE_ADV_REPORT_FLOW_CONTROL_NUM
+            int "BLE adv report flow control number"
+            depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
+            range 50 1000
+            default 100
+            help
+                The number of unprocessed advertising report that Bluedroid can save.If you set
+                `BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a small value, this may cause adv packets lost.
+                If you set `BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a large value, Bluedroid may cache a
+                lot of adv packets and this may cause system memory run out. For example, if you set
+                it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
+                `BLE_ADV_REPORT_FLOW_CONTROL_NUM` according to your system free memory and handle adv
+                packets as fast as possible, otherwise it will cause adv packets lost.
+
+        config BLE_ADV_REPORT_DISCARD_THRSHOLD
+            int "BLE adv lost event threshold value"
+            depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
+            range 1 1000
+            default 20
+            help
+                When adv report flow control is enabled, The ADV lost event will be generated when the number
+                of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
+                If you set `BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
+                may cause adv packets lost more.
+
     endmenu
 
     menuconfig BLUEDROID_ENABLED
index d067f42108451ebbfd7bf5642d336505ff626cdb..b34c2ae11d9b4a16f94c74f4151c83d8da634596 100644 (file)
@@ -558,6 +558,7 @@ typedef enum {
     ESP_GAP_SEARCH_DISC_CMPL_EVT           = 4,      /*!< Discovery complete. */
     ESP_GAP_SEARCH_DI_DISC_CMPL_EVT        = 5,      /*!< Discovery complete. */
     ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT  = 6,      /*!< Search cancelled */
+    ESP_GAP_SEARCH_INQ_DISCARD_NUM_EVT     = 7,      /*!< The number of pkt discarded by flow control */
 } esp_gap_search_evt_t;
 
 /**
@@ -635,6 +636,7 @@ typedef union {
         int num_resps;                              /*!< Scan result number */
         uint8_t adv_data_len;                       /*!< Adv data length */
         uint8_t scan_rsp_len;                       /*!< Scan response length */
+        uint32_t num_dis;                          /*!< The number of discard packets */
     } scan_rst;                                     /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
     /**
      * @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
index 7139356dd497d28d54d9f8859c50e8e7cf1d1e39..f1061a390fe0b5c06ec54b94e4769ca68aaa54ac 100644 (file)
@@ -127,6 +127,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
 #endif  ///SMP_INCLUDED == TRUE
 static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
 static void bta_dm_observe_cmpl_cb(void *p_result);
+static void bta_dm_observe_discard_cb (uint32_t num_dis);
 static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
 extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128);
 static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle);
@@ -4273,6 +4274,28 @@ static void bta_dm_observe_cmpl_cb (void *p_result)
     }
 }
 
+/*******************************************************************************
+**
+** Function         bta_dm_observe_discard_cb
+**
+** Description      Callback for BLE Observe lost
+**
+**
+** Returns          void
+**
+*******************************************************************************/
+static void bta_dm_observe_discard_cb (uint32_t num_dis)
+{
+    tBTA_DM_SEARCH  data;
+
+    APPL_TRACE_DEBUG("bta_dm_observe_discard_cb");
+
+    data.inq_dis.num_dis = num_dis;
+    if (bta_dm_search_cb.p_scan_cback) {
+        bta_dm_search_cb.p_scan_cback(BTA_DM_INQ_DISCARD_NUM_EVT, &data);
+    }
+}
+
 #if (SMP_INCLUDED == TRUE)
 /*******************************************************************************
 **
@@ -4815,7 +4838,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
         bta_dm_search_cb.p_scan_cback = p_data->ble_scan.p_cback;
 
         if ((status = BTM_BleScan(TRUE, p_data->ble_scan.duration,
-                                     bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) {
+                                     bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb, bta_dm_observe_discard_cb)) != BTM_CMD_STARTED) {
             APPL_TRACE_WARNING(" %s start scan failed. status=0x%x\n", __FUNCTION__, status);
         }
 
@@ -4825,7 +4848,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
         }
     } else {
         bta_dm_search_cb.p_scan_cback = NULL;
-        status = BTM_BleScan(FALSE, 0, NULL, NULL);
+        status = BTM_BleScan(FALSE, 0, NULL, NULL, NULL);
 
         if (status != BTM_CMD_STARTED){
             APPL_TRACE_WARNING(" %s stop scan failed, status=0x%x\n", __FUNCTION__, status);
index 4081ee15f853f2da76aee1e5a62e8b38499e92c3..f384edeb456da9018c0fb2a2c5a5320ea75e6123 100644 (file)
@@ -1024,6 +1024,7 @@ typedef struct {
 #define BTA_DM_DISC_CMPL_EVT            4       /* Discovery complete. */
 #define BTA_DM_DI_DISC_CMPL_EVT         5       /* Discovery complete. */
 #define BTA_DM_SEARCH_CANCEL_CMPL_EVT   6       /* Search cancelled */
+#define BTA_DM_INQ_DISCARD_NUM_EVT      7       /* The number of inquiry discarded packets */
 
 typedef UINT8 tBTA_DM_SEARCH_EVT;
 
@@ -1055,6 +1056,11 @@ typedef struct {
     UINT8           num_resps;          /* Number of inquiry responses. */
 } tBTA_DM_INQ_CMPL;
 
+/* Structure associated with BTA_DM_INQ_DISCARD_NUM_EVT */
+typedef struct {
+    UINT32           num_dis;          /* The number of inquiry discarded packets. */
+} tBTA_DM_INQ_DISCARD;
+
 /* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
 typedef struct {
     BD_ADDR             bd_addr;        /* BD address peer device. */
@@ -1092,6 +1098,7 @@ typedef union {
     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_SEARCH;
 
 /* Structure of search callback event and structures */
index 7cc669d861a5c955e5d788c93fd1d6c69b4c309e..ef13106dde6035144ae6ea663ca89641e63bfb62 100644 (file)
@@ -604,6 +604,9 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
     case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
         BTC_TRACE_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n");
         break;
+    case BTA_DM_INQ_DISCARD_NUM_EVT:
+        param.scan_rst.num_dis = p_data->inq_dis.num_dis;
+        break;
     default:
         BTC_TRACE_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event);
         return;
index 997295bb419377b251230dbf9933ca68bbcd8420..200c6a118c309a90aa81ad321278e45a6cae7044 100644 (file)
 #define SMP_SLAVE_CON_PARAMS_UPD_ENABLE  FALSE
 #endif
 
+#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
+#define BLE_ADV_REPORT_FLOW_CONTROL  FALSE
+#else
+#define BLE_ADV_REPORT_FLOW_CONTROL  CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
+#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED */
+
+#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
+#define BLE_ADV_REPORT_FLOW_CONTROL_NUM   100
+#else 
+#define BLE_ADV_REPORT_FLOW_CONTROL_NUM     CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
+#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM */
+
+#ifndef CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
+#define BLE_ADV_REPORT_DISCARD_THRSHOLD  20
+#else 
+#define BLE_ADV_REPORT_DISCARD_THRSHOLD  CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
+#endif /* CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD */
+
 #if (CONFIG_BT_ACL_CONNECTIONS)
 #define MAX_ACL_CONNECTIONS  CONFIG_BT_ACL_CONNECTIONS
 #define GATT_MAX_PHY_CHANNEL CONFIG_BT_ACL_CONNECTIONS
index b4fec286c3a7c99fabcd036bf21b57cb5551bab4..45ef4ea504e7adf3ced9dd53c3c07de7fd026e07 100644 (file)
@@ -100,7 +100,11 @@ static void start_up(void)
     response = AWAIT_COMMAND(packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
     packet_parser->parse_generic_command_complete(response);
 #endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
-
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+    // Enable adv flow control
+    response = AWAIT_COMMAND(packet_factory->make_set_adv_report_flow_control(HCI_HOST_FLOW_CTRL_ADV_REPORT_ON, (uint16_t)BLE_ADV_REPORT_FLOW_CONTROL_NUM, (uint16_t)BLE_ADV_REPORT_DISCARD_THRSHOLD));
+    packet_parser->parse_generic_command_complete(response);
+#endif
     // Tell the controller about our buffer sizes and buffer counts next
     // TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
     response = AWAIT_COMMAND(
index 84aec2e9cac6090c0df5bc0ee34bac2dc7df974b..e742b6240fd32df4c8e38187f50fad2cc42d3305 100644 (file)
@@ -55,6 +55,7 @@ static const uint16_t outbound_event_types[] = {
 typedef struct {
     size_t buffer_size;
     fixed_queue_t *rx_q;
+    uint16_t adv_free_num;
 } hci_hal_env_t;
 
 
@@ -81,6 +82,7 @@ static void hci_hal_env_init(
     assert(max_buffer_count > 0);
 
     hci_hal_env.buffer_size = buffer_size;
+    hci_hal_env.adv_free_num = 0;
 
     hci_hal_env.rx_q = fixed_queue_new(max_buffer_count);
     if (hci_hal_env.rx_q) {
@@ -102,8 +104,11 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
 {
     assert(upper_callbacks != NULL);
     callbacks = upper_callbacks;
-
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+    hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, BLE_ADV_REPORT_FLOW_CONTROL_NUM + L2CAP_HOST_FC_ACL_BUFS + QUEUE_SIZE_MAX); // adv flow control num + ACL flow control num + hci cmd numeber
+#else
     hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
+#endif
 
     xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
     xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
@@ -223,12 +228,37 @@ static void hci_packet_complete(BT_HDR *packet){
 bool host_recv_adv_packet(BT_HDR *packet)
 {
     assert(packet);
-    if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] ==  HCI_BLE_ADV_PKT_RPT_EVT) {
-        return true;
+    if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT) {
+        if(packet->data[3] ==  HCI_BLE_ADV_PKT_RPT_EVT 
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+        || packet->data[3] ==  HCI_BLE_ADV_DISCARD_REPORT_EVT
+#endif
+        ) {
+            return true;
+        }
     }
     return false;
 }
 
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+static void hci_update_adv_report_flow_control(BT_HDR *packet)
+{
+    // this is adv packet
+    if(host_recv_adv_packet(packet)) {
+        // update adv free number
+        hci_hal_env.adv_free_num ++;
+        if (esp_vhci_host_check_send_available()){
+            // send hci cmd
+            btsnd_hcic_ble_update_adv_report_flow_control(hci_hal_env.adv_free_num);
+            hci_hal_env.adv_free_num = 0;
+        } else {
+            //do nothing
+        }
+    }
+
+}
+#endif
+
 static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
 {
     uint8_t type, hdr_size;
@@ -282,6 +312,11 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
         osi_free(packet);
         return;
     }
+
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+    hci_update_adv_report_flow_control(packet);
+#endif
+
 #if SCAN_QUEUE_CONGEST_CHECK
     if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
         HCI_TRACE_ERROR("BtuQueue is congested");
@@ -289,7 +324,6 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
         return;
     }
 #endif
-
     packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
     callbacks->packet_ready(packet);
 }
index 87d187c8d187357e04c3110be9368c5b43aa022f..c2b6223ce7c5eee068dd8864a94f75e9ea5d0894 100644 (file)
@@ -317,7 +317,11 @@ static void event_command_ready(fixed_queue_t *queue)
 
     wait_entry = fixed_queue_dequeue(queue);
 
-    if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE){
+    if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE 
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+    || wait_entry->opcode == HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL
+#endif
+    ){
         packet_fragmenter->fragment_and_dispatch(wait_entry->command);
         osi_free(wait_entry->command);
         osi_free(wait_entry);
index ecf7e75fabc34d6801b0c03df46cee98a0b0236f..19641d1046d2fe8b24473743e9f59173396808f6 100644 (file)
@@ -53,6 +53,18 @@ static BT_HDR *make_set_c2h_flow_control(uint8_t enable)
     return packet;
 }
 
+static BT_HDR *make_set_adv_report_flow_control(uint8_t enable, uint16_t num, uint16_t lost_threshold)
+{
+    uint8_t *stream;
+    const uint8_t parameter_size = 1 + 2 + 2;
+    BT_HDR *packet = make_command(HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL, parameter_size, &stream);
+
+    UINT8_TO_STREAM(stream, enable);
+    UINT16_TO_STREAM(stream, num);
+    UINT16_TO_STREAM(stream, lost_threshold);
+    return packet;
+}
+
 static BT_HDR *make_host_buffer_size(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count)
 {
     uint8_t *stream;
@@ -239,6 +251,7 @@ static const hci_packet_factory_t interface = {
     make_reset,
     make_read_buffer_size,
     make_set_c2h_flow_control,
+    make_set_adv_report_flow_control,
     make_host_buffer_size,
     make_read_local_version_info,
     make_read_bd_addr,
index 21bd2c9a62f3b3645856c3760830b38a2b738efe..fd8731fbc20038ae9ebb77cd7ca0431295151ef7 100644 (file)
@@ -26,6 +26,7 @@ typedef struct {
     BT_HDR *(*make_reset)(void);
     BT_HDR *(*make_read_buffer_size)(void);
     BT_HDR *(*make_set_c2h_flow_control)(uint8_t enable);
+    BT_HDR *(*make_set_adv_report_flow_control)(uint8_t enable, uint16_t num, uint16_t lost_threshold);
     BT_HDR *(*make_host_buffer_size)(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count);
     BT_HDR *(*make_read_local_version_info)(void);
     BT_HDR *(*make_read_bd_addr)(void);
index 892a5124d76e3da4c3ae9eee3bf621ac56aafa99..a015a3cbb205be713a8ffbbba3c2c54c817720bf 100644 (file)
@@ -493,7 +493,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
 **
 *******************************************************************************/
 tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
-                           tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb)
+                           tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb)
 {
     tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
     tBTM_STATUS status = BTM_WRONG_MODE;
@@ -511,6 +511,7 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
 
         btm_cb.ble_ctr_cb.p_scan_results_cb = p_results_cb;
         btm_cb.ble_ctr_cb.p_scan_cmpl_cb = p_cmpl_cb;
+        btm_cb.ble_ctr_cb.p_obs_discard_cb = p_discard_cb;
         status = BTM_CMD_STARTED;
 
         /* scan is not started */
@@ -3602,6 +3603,17 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
     }
 }
 
+void btm_ble_process_adv_discard_evt(UINT8 *p)
+{
+#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
+    uint32_t num_dis = 0;
+    STREAM_TO_UINT32 (num_dis, p);
+    tBTM_INQ_DIS_CB *p_obs_discard_cb = btm_cb.ble_ctr_cb.p_obs_discard_cb;
+    if(p_obs_discard_cb) {
+        (p_obs_discard_cb)(num_dis);
+    }
+#endif
+}
 /*******************************************************************************
 **
 ** Function         btm_ble_start_scan
index feedae2c39919fd9548709a100a753c8784a8f5a..848bff3740509460154c24e47c48dccd63c6ed10 100644 (file)
@@ -319,6 +319,7 @@ typedef struct {
     /* observer callback and timer */
     tBTM_INQ_RESULTS_CB *p_obs_results_cb;
     tBTM_CMPL_CB *p_obs_cmpl_cb;
+    tBTM_INQ_DIS_CB *p_obs_discard_cb;
     TIMER_LIST_ENT obs_timer_ent;
 
     /* scan callback and timer */
@@ -368,6 +369,7 @@ extern "C" {
 
 void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
 void btm_ble_process_adv_pkt (UINT8 *p);
+void btm_ble_process_adv_discard_evt(UINT8 *p);
 void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
 tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
 BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
index a3bcc61b99de6b95b909f40864dcbda24e0d4e84..7f0395a5b3c1401f0b956a4fe01e859a1fbffc09 100644 (file)
@@ -122,6 +122,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len);
 #if BLE_INCLUDED == TRUE
 static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len);
 static void btu_ble_process_adv_pkt (UINT8 *p);
+static void btu_ble_process_adv_dis(UINT8 *p);
 static void btu_ble_read_remote_feat_evt (UINT8 *p);
 static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len);
 static void btu_ble_ll_get_conn_param_format_err_from_contoller (UINT8 status, UINT16 handle);
@@ -342,6 +343,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
         case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */
             btu_ble_process_adv_pkt(p);
             break;
+        case HCI_BLE_ADV_DISCARD_REPORT_EVT:
+            btu_ble_process_adv_dis(p);
+            break;
         case HCI_BLE_CONN_COMPLETE_EVT:
             btu_ble_ll_conn_complete_evt(p, hci_evt_len);
             break;
@@ -1809,6 +1813,11 @@ static void btu_ble_process_adv_pkt (UINT8 *p)
     btm_ble_process_adv_pkt(p);
 }
 
+static void btu_ble_process_adv_dis(UINT8 *p)
+{
+    btm_ble_process_adv_discard_evt(p);
+}
+
 static void btu_ble_ll_conn_complete_evt ( UINT8 *p, UINT16 evt_len)
 {
     btm_ble_conn_complete(p, evt_len, FALSE);
index 89d4fd94c8352b45c6978b2e612f1483769fd34c..a34806fdb81069d5f636f4b040b64d60c566feb2 100644 (file)
@@ -999,5 +999,27 @@ BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets, UIN
     return TRUE;
 }
 
+BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num)
+{
+    BT_HDR *p;
+    UINT8 *pp;
+
+    if ((p = HCI_GET_CMD_BUF (1)) == NULL) {
+        return (FALSE);
+    }
+
+    pp = (UINT8 *)(p + 1);
+
+    p->len = HCIC_PREAMBLE_SIZE + 2;
+    p->offset = 0;
+
+    UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL);
+    UINT8_TO_STREAM (pp, 2);
+    UINT16_TO_STREAM (pp, num);
+
+    btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
+    return TRUE;
+}
+
 #endif
 
index f686a12175240677f30c951a4ad56f9e104c4c2e..6aa833c036ebddc8786de9a5ecc97e76c6d87e5b 100644 (file)
@@ -169,6 +169,8 @@ typedef void (tBTM_VS_EVT_CB) (UINT8 len, UINT8 *p);
 */
 typedef void (tBTM_CMPL_CB) (void *p1);
 
+typedef void (tBTM_INQ_DIS_CB) (uint32_t num_dis);
+
 /* VSC callback function for notifying an application that a synchronous
 ** BTM function is complete. The pointer contains the address of any returned data.
 */
@@ -677,7 +679,6 @@ typedef struct {
     UINT8       num_resp;       /* Number of results from the current inquiry */
 } tBTM_INQUIRY_CMPL;
 
-
 /* Structure returned with remote name  request */
 typedef struct {
     UINT16      status;
index 96a6445dc56c7364c96860d0b801158ef6145a27..7e6feb39bd77dc6d7f10407f2d870f481c77dc5b 100644 (file)
@@ -1272,7 +1272,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
 *******************************************************************************/
 //extern
 tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
-                           tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
+                           tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb);
 
 
 /*******************************************************************************
index e307f19c708347ee92953639e589c53afbc876fd..6249f2c39565510ab83ff5dd12b6cb5cde9bed08 100644 (file)
 #define HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS       0x06
 #define HCI_SUBCODE_BLE_LONG_ADV                   0x07
 #define HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST 0x08
+#define HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL       0x09
+#define HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL    0x0A
 #define HCI_SUBCODE_BLE_MAX                        0x7F
 
 //ESP BT subcode define
 #define HCI_VENDOR_BLE_LONG_ADV_DATA      HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_LONG_ADV)
 /* BLE update duplicate scan exceptional list */
 #define HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST  HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST)
+#define HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL        HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL)
+#define HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL     HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL)
 //ESP BT HCI CMD
 
 /* subcode for multi adv feature */
 #define HCI_BLE_DATA_LENGTH_CHANGE_EVT      0x07
 #define HCI_BLE_ENHANCED_CONN_COMPLETE_EVT  0x0a
 #define HCI_BLE_DIRECT_ADV_EVT              0x0b
+/* ESP vendor BLE Event sub code */
+#define HCI_BLE_ADV_DISCARD_REPORT_EVT      0XF0
 
 /* Definitions for LE Channel Map */
 #define HCI_BLE_CHNL_MAP_SIZE               5
index 37b64c7d151eb46766b89460da0c8a9ccbd7cf50..cc5dc1d6132cb26c0cb4f328634cd75da824bd48 100644 (file)
@@ -555,6 +555,10 @@ BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags);            /* Write Voice
 #define HCI_HOST_FLOW_CTRL_SCO_ON       2
 #define HCI_HOST_FLOW_CTRL_BOTH_ON      3
 
+#define  HCI_HOST_FLOW_CTRL_ADV_REPORT_OFF     0
+#define  HCI_HOST_FLOW_CTRL_ADV_REPORT_ON      1
+
+
 BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle,
         UINT16 timeout);    /* Write Retransmit Timout */
 
@@ -806,6 +810,8 @@ BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle);
 BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle,
         UINT16 timeout);
 
+BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num);
+
 #define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT  4
 
 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF  0
index 48ecf82c99f9e5d729e07c39a9d4c350a0f2f8e9..a8aed8085d65e92f054d324137d03528409e4a41 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 48ecf82c99f9e5d729e07c39a9d4c350a0f2f8e9
+Subproject commit a8aed8085d65e92f054d324137d03528409e4a41