@@ -116,9 +116,11 @@ uint8_t NimBLEDevice::m_ownAddrType{BLE_OWN_ADDR_PUBLIC};
116
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
+ uint16_t NimBLEDevice::m_scanDuplicateResetTime{0 };
119
120
# 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};
121
+ uint16_t NimBLEDevice::m_scanDuplicateSize{CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT};
122
+ uint8_t NimBLEDevice::m_scanFilterMode{CONFIG_BT_LE_SCAN_DUPL_TYPE};
123
+ uint16_t NimBLEDevice::m_scanDuplicateResetTime{0 };
122
124
extern " C" int ble_vhci_disc_duplicate_set_max_cache_size (int max_cache_size);
123
125
extern " C" int ble_vhci_disc_duplicate_set_period_refresh_time (int refresh_period_time);
124
126
extern " C" int ble_vhci_disc_duplicate_mode_disable (int mode);
@@ -312,7 +314,26 @@ void NimBLEDevice::setScanFilterMode(uint8_t mode) {
312
314
313
315
m_scanFilterMode = mode;
314
316
}
315
- # endif // CONFIG_BTDM_BLE_SCAN_DUPL
317
+
318
+ /* *
319
+ * @brief Set the time in seconds to reset the duplicate cache.
320
+ * @param [in] time The time in seconds to reset the cache.
321
+ * @details When the cache is reset all scanned devices will be reported again
322
+ * even if already seen in the current scan. If set to 0 the cache will never be reset.
323
+ */
324
+ void NimBLEDevice::setScanDuplicateCacheResetTime (uint16_t time) {
325
+ if (m_initialized) {
326
+ NIMBLE_LOGE (LOG_TAG, " Cannot change scan cache reset time while initialized" );
327
+ return ;
328
+ } else if (time > 1000 ) {
329
+ NIMBLE_LOGE (LOG_TAG, " Invalid scan cache reset time" );
330
+ return ;
331
+ }
332
+
333
+ NIMBLE_LOGD (LOG_TAG, " Set duplicate cache reset time to: %u" , time );
334
+ m_scanDuplicateResetTime = time ;
335
+ }
336
+ # endif // CONFIG_BTDM_BLE_SCAN_DUPL || CONFIG_BT_LE_SCAN_DUPL
316
337
# endif // ESP_PLATFORM
317
338
# endif // #if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
318
339
@@ -908,8 +929,9 @@ bool NimBLEDevice::init(const std::string& deviceName) {
908
929
# endif
909
930
910
931
# if CONFIG_BTDM_BLE_SCAN_DUPL
911
- bt_cfg.normal_adv_size = m_scanDuplicateSize;
912
- bt_cfg.scan_duplicate_type = m_scanFilterMode;
932
+ bt_cfg.normal_adv_size = m_scanDuplicateSize;
933
+ bt_cfg.scan_duplicate_type = m_scanFilterMode;
934
+ bt_cfg.dup_list_refresh_period = m_scanDuplicateResetTime;
913
935
# elif CONFIG_BT_LE_SCAN_DUPL
914
936
bt_cfg.ble_ll_rsp_dup_list_count = m_scanDuplicateSize;
915
937
bt_cfg.ble_ll_adv_dup_list_count = m_scanDuplicateSize;
@@ -936,6 +958,7 @@ bool NimBLEDevice::init(const std::string& deviceName) {
936
958
ble_vhci_disc_duplicate_mode_disable (0xFFFFFFFF );
937
959
ble_vhci_disc_duplicate_mode_enable (mode);
938
960
ble_vhci_disc_duplicate_set_max_cache_size (m_scanDuplicateSize);
961
+ ble_vhci_disc_duplicate_set_period_refresh_time (m_scanDuplicateResetTime);
939
962
# endif
940
963
941
964
err = esp_bt_controller_enable (ESP_BT_MODE_BLE);
0 commit comments