diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index d5d519581d568a..91a92c4dafd758 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -270,6 +270,11 @@ void CommissioningWindowManager::CloseCommissioningWindow() CHIP_ERROR CommissioningWindowManager::StartAdvertisement() { +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + // notify device layer that advertisement is beginning (to do work such as increment rotating id) + DeviceLayer::ConfigurationMgr().NotifyOfAdvertisementStart(); +#endif + if (mIsBLE) { ReturnErrorOnFailure(chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true)); diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index 28b044ee896e9b..a8977307b14aee 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -136,6 +136,13 @@ class ConfigurationManager virtual bool IsFullyProvisioned() = 0; virtual void InitiateFactoryReset() = 0; + // Gets called when starting BLE/DNS-SD advertisement +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + virtual void NotifyOfAdvertisementStart() {} +#else + void NotifyOfAdvertisementStart() {} +#endif + virtual void LogDeviceConfig() = 0; virtual bool IsCommissionableDeviceTypeEnabled() = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 72d5875abbe21e..e327da4cfd38d3 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -248,11 +248,16 @@ CHIP_ERROR GenericConfigurationManagerImpl::StoreManufacturingDate( template void GenericConfigurationManagerImpl::InitiateFactoryReset() +{} + +template +void GenericConfigurationManagerImpl::NotifyOfAdvertisementStart() { #if CHIP_ENABLE_ROTATING_DEVICE_ID + // Increment life time counter to protect against long-term tracking of rotating device ID. IncrementLifetimeCounter(); -#endif // Inheriting classes should call this method so the lifetime counter is updated if necessary. +#endif } template diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 7fb9554ae0737c..e498eb0e60854e 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -113,6 +113,11 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR RunUnitTests(void) override; bool IsFullyProvisioned() override; void InitiateFactoryReset() override; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + void NotifyOfAdvertisementStart() override; +#else + void NotifyOfAdvertisementStart(); +#endif void LogDeviceConfig() override; virtual ~GenericConfigurationManagerImpl() = default; diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index f6f392ee1ceca7..c21134e33e5b83 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -359,11 +359,6 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - // Increment life time counter to protect against long-term tracking of rotating device ID. - ReturnErrorOnFailure(ConfigurationMgr().IncrementLifetimeCounter()); -#endif - // Post a CHIPoBLEAdvertisingChange(Stopped) event. { ChipDeviceEvent advChange;