|
66 | 66 | # if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
67 | 67 | # include "NimBLEServer.h"
|
68 | 68 | # if CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM > 0
|
69 |
| -# include "NimBLEL2CAPServer.h" |
| 69 | +# include "NimBLEL2CAPServer.h" |
70 | 70 | # endif
|
71 | 71 | # endif
|
72 | 72 |
|
@@ -113,9 +113,16 @@ std::vector<NimBLEAddress> NimBLEDevice::m_whiteList{};
|
113 | 113 | uint8_t NimBLEDevice::m_ownAddrType{BLE_OWN_ADDR_PUBLIC};
|
114 | 114 |
|
115 | 115 | # ifdef ESP_PLATFORM
|
116 |
| -# ifdef CONFIG_BTDM_BLE_SCAN_DUPL |
| 116 | +# if CONFIG_BTDM_BLE_SCAN_DUPL |
117 | 117 | uint16_t NimBLEDevice::m_scanDuplicateSize{CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE};
|
118 | 118 | uint8_t NimBLEDevice::m_scanFilterMode{CONFIG_BTDM_SCAN_DUPL_TYPE};
|
| 119 | +# elif CONFIG_BT_LE_SCAN_DUPL |
| 120 | +uint16_t NimBLEDevice::m_scanDuplicateSize{CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT}; |
| 121 | +uint8_t NimBLEDevice::m_scanFilterMode{CONFIG_BT_LE_SCAN_DUPL_TYPE}; |
| 122 | +extern "C" int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size); |
| 123 | +extern "C" int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time); |
| 124 | +extern "C" int ble_vhci_disc_duplicate_mode_disable(int mode); |
| 125 | +extern "C" int ble_vhci_disc_duplicate_mode_enable(int mode); |
119 | 126 | # endif
|
120 | 127 | # endif
|
121 | 128 |
|
@@ -258,7 +265,7 @@ NimBLEScan* NimBLEDevice::getScan() {
|
258 | 265 | } // getScan
|
259 | 266 |
|
260 | 267 | # ifdef ESP_PLATFORM
|
261 |
| -# ifdef CONFIG_BTDM_BLE_SCAN_DUPL |
| 268 | +# if CONFIG_BTDM_BLE_SCAN_DUPL || CONFIG_BT_LE_SCAN_DUPL |
262 | 269 | /**
|
263 | 270 | * @brief Set the duplicate filter cache size for filtering scanned devices.
|
264 | 271 | * @param [in] size The number of advertisements filtered before the cache is reset.\n
|
@@ -900,16 +907,37 @@ bool NimBLEDevice::init(const std::string& deviceName) {
|
900 | 907 | bt_cfg.nimble_max_connections = CONFIG_BT_NIMBLE_MAX_CONNECTIONS;
|
901 | 908 | # endif
|
902 | 909 |
|
903 |
| -# ifdef CONFIG_BTDM_BLE_SCAN_DUPL |
| 910 | +# if CONFIG_BTDM_BLE_SCAN_DUPL |
904 | 911 | bt_cfg.normal_adv_size = m_scanDuplicateSize;
|
905 | 912 | bt_cfg.scan_duplicate_type = m_scanFilterMode;
|
| 913 | +# elif CONFIG_BT_LE_SCAN_DUPL |
| 914 | + bt_cfg.ble_ll_rsp_dup_list_count = m_scanDuplicateSize; |
| 915 | + bt_cfg.ble_ll_adv_dup_list_count = m_scanDuplicateSize; |
906 | 916 | # endif
|
907 | 917 | err = esp_bt_controller_init(&bt_cfg);
|
908 | 918 | if (err != ESP_OK) {
|
909 | 919 | NIMBLE_LOGE(LOG_TAG, "esp_bt_controller_init() failed; err=%d", err);
|
910 | 920 | return false;
|
911 | 921 | }
|
912 | 922 |
|
| 923 | +# if CONFIG_BT_LE_SCAN_DUPL |
| 924 | + int mode = (1UL << 4); // FILTER_DUPLICATE_EXCEPTION_FOR_MESH |
| 925 | + switch (m_scanFilterMode) { |
| 926 | + case 1: |
| 927 | + mode |= (1UL << 3); // FILTER_DUPLICATE_ADVDATA |
| 928 | + break; |
| 929 | + case 2: |
| 930 | + mode |= ((1UL << 2) | (1UL << 3)); // FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_ADVDATA |
| 931 | + break; |
| 932 | + default: |
| 933 | + mode |= (1UL << 0) | (1UL << 2); // FILTER_DUPLICATE_PDUTYPE | FILTER_DUPLICATE_ADDRESS |
| 934 | + } |
| 935 | + |
| 936 | + ble_vhci_disc_duplicate_mode_disable(0xFFFFFFFF); |
| 937 | + ble_vhci_disc_duplicate_mode_enable(mode); |
| 938 | + ble_vhci_disc_duplicate_set_max_cache_size(m_scanDuplicateSize); |
| 939 | +# endif |
| 940 | + |
913 | 941 | err = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
914 | 942 | if (err != ESP_OK) {
|
915 | 943 | NIMBLE_LOGE(LOG_TAG, "esp_bt_controller_enable() failed; err=%d", err);
|
|
0 commit comments