Added timestamp checker and skip adv data deliver for a short time interval.

PiperOrigin-RevId: 759782377
This commit is contained in:
hai007
2025-05-16 15:45:08 -07:00
committed by Copybara-Service
parent 959322177f
commit 4b20e8a541
2 changed files with 63 additions and 1 deletions
@@ -189,6 +189,17 @@ class BleMedium : public api::ble_v2::BleMedium {
GNCBLEMedium *medium_;
PeripheralsMap peripherals_;
struct BlockAdvertisementPacket {
bool block;
NSDate *last_timestamp;
nearby::ByteArray last_service_data;
};
// A map for maintaining the set of advertisement packets that should be blocked or not.
absl::flat_hash_map<api::ble_v2::BlePeripheral::UniqueId, BlockAdvertisementPacket>
block_advertisement_packets_;
// The timestamp of the last time to start blocking advertisement packet process. We reset ths
// procedure every 10 minutes to avoid stale peripherals that are not advertising any more.
NSDate *last_block_advertisement_packet_timestamp_{nil};
GNSPeripheralServiceManager *socketPeripheralServiceManager_;
GNSPeripheralManager *socketPeripheralManager_;