@@ -116,9 +116,11 @@ uint8_t NimBLEDevice::m_ownAddrType{BLE_OWN_ADDR_PUBLIC};
116116# if CONFIG_BTDM_BLE_SCAN_DUPL
117117uint16_t NimBLEDevice::m_scanDuplicateSize{CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE};
118118uint8_t NimBLEDevice::m_scanFilterMode{CONFIG_BTDM_SCAN_DUPL_TYPE};
119+ uint16_t NimBLEDevice::m_scanDuplicateResetTime{0 };
119120# 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 };
122124extern " C" int ble_vhci_disc_duplicate_set_max_cache_size (int max_cache_size);
123125extern " C" int ble_vhci_disc_duplicate_set_period_refresh_time (int refresh_period_time);
124126extern " C" int ble_vhci_disc_duplicate_mode_disable (int mode);
@@ -312,7 +314,26 @@ void NimBLEDevice::setScanFilterMode(uint8_t mode) {
312314
313315 m_scanFilterMode = mode;
314316}
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
316337# endif // ESP_PLATFORM
317338# endif // #if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
318339
@@ -908,8 +929,9 @@ bool NimBLEDevice::init(const std::string& deviceName) {
908929# endif
909930
910931# 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;
913935# elif CONFIG_BT_LE_SCAN_DUPL
914936 bt_cfg.ble_ll_rsp_dup_list_count = m_scanDuplicateSize;
915937 bt_cfg.ble_ll_adv_dup_list_count = m_scanDuplicateSize;
@@ -936,6 +958,7 @@ bool NimBLEDevice::init(const std::string& deviceName) {
936958 ble_vhci_disc_duplicate_mode_disable (0xFFFFFFFF );
937959 ble_vhci_disc_duplicate_mode_enable (mode);
938960 ble_vhci_disc_duplicate_set_max_cache_size (m_scanDuplicateSize);
961+ ble_vhci_disc_duplicate_set_period_refresh_time (m_scanDuplicateResetTime);
939962# endif
940963
941964 err = esp_bt_controller_enable (ESP_BT_MODE_BLE);
0 commit comments