diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 01bff4bf07db46..110a729d8f1b87 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -302,6 +302,20 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE() return CHIP_NO_ERROR; } +System::Clock::Seconds32 CommissioningWindowManager::MaxCommissioningTimeout() const +{ +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING + /* Allow for extended announcement only if the device is uncomissioned. */ + if (mServer->GetFabricTable().FabricCount() == 0) + { + // Specification section 2.3.1 - Extended Announcement Duration up to 48h + return System::Clock::Seconds32(60 * 60 * 48); + } +#endif + // Specification section 5.4.2.3. Announcement Duration says 15 minutes. + return System::Clock::Seconds32(15 * 60); +} + CHIP_ERROR CommissioningWindowManager::OpenBasicCommissioningWindow(Seconds32 commissioningTimeout, CommissioningWindowAdvertisement advertisementMode) { diff --git a/src/app/server/CommissioningWindowManager.h b/src/app/server/CommissioningWindowManager.h index 51efb44b19376e..3bc50ed3e33685 100644 --- a/src/app/server/CommissioningWindowManager.h +++ b/src/app/server/CommissioningWindowManager.h @@ -58,16 +58,7 @@ class CommissioningWindowManager : public Messaging::UnsolicitedMessageHandler, return CHIP_NO_ERROR; } - static constexpr System::Clock::Seconds32 MaxCommissioningTimeout() - { -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING - // Specification section 2.3.1 - Extended Announcement Duration up to 48h - return System::Clock::Seconds32(60 * 60 * 48); -#else - // Specification section 5.4.2.3. Announcement Duration says 15 minutes. - return System::Clock::Seconds32(15 * 60); -#endif - } + System::Clock::Seconds32 MaxCommissioningTimeout() const; System::Clock::Seconds32 MinCommissioningTimeout() const { diff --git a/src/include/platform/CHIPDeviceConfig.h b/src/include/platform/CHIPDeviceConfig.h index f4b5fbdc41789c..87fdfad76a531c 100644 --- a/src/include/platform/CHIPDeviceConfig.h +++ b/src/include/platform/CHIPDeviceConfig.h @@ -640,18 +640,18 @@ #endif /** - * CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING + * CHIP_DEVICE_CONFIG_EXT_ADVERTISING * * Optional configuration to enable Extended Announcement Duration up to 48h. * Should be used together with extending CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS past 15 minutes. * Disabled by default. */ -#ifndef CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING -#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 0 +#ifndef CHIP_DEVICE_CONFIG_EXT_ADVERTISING +#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING 0 #endif -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING /** * CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS @@ -735,18 +735,18 @@ static_assert(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN <= CHIP_DEVICE * Time in seconds that a factory new device will advertise commissionable node discovery. */ #ifndef CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING /** * By default, the extended announcement, when enabled, starts its extended advertising 15 mins * after the standard slow advertisement. Time at which the default discovery time would close the * commissioning window and stop the BLE. - * Therefore, when CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING is enabled bump the default Discovery timeout + * Therefore, when CHIP_DEVICE_CONFIG_EXT_ADVERTISING is enabled bump the default Discovery timeout * to the maximum allowed by the spec. 48h. */ #define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS (60 * 60 * 48) #else #define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS (15 * 60) -#endif // CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#endif // CHIP_DEVICE_CONFIG_EXT_ADVERTISING #endif // CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS /** diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index dc4f380c262fb5..81ee804035d4ab 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -152,9 +152,9 @@ #define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART #ifdef CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT -#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT +#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT #else -#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 0 +#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING 0 #endif // Options for background chip task diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index d4d90f45362dbe..db3ade84d0234b 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -281,12 +281,12 @@ void BLEManagerImpl::BleAdvTimeoutHandler(System::Layer *, void *) BLEMgrImpl().mFlags.Set(Flags::kFastAdvertisingEnabled, 0); BLEMgrImpl().mFlags.Set(Flags::kAdvertisingRefreshNeeded, 1); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING BLEMgrImpl().mFlags.Clear(Flags::kExtAdvertisingEnabled); BLEMgrImpl().StartBleAdvTimeoutTimer(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS); #endif } -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING else { ChipLogProgress(DeviceLayer, "bleAdv Timeout : Start extended advertisement"); @@ -1066,7 +1066,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) ExitNow(); } -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING // Check for extended advertisement interval and redact VID/PID if past the initial period. if (mFlags.Has(Flags::kExtAdvertisingEnabled)) { @@ -1671,7 +1671,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) } else { -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (!mFlags.Has(Flags::kExtAdvertisingEnabled)) { adv_params.itvl_min = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN; diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index e2070c6978ea70..4ef45f88ea60fa 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -61,7 +61,7 @@ static constexpr System::Clock::Timeout kNewConnectionScanTimeout = System::Cloc static constexpr System::Clock::Timeout kConnectTimeout = System::Clock::Seconds16(20); static constexpr System::Clock::Timeout kFastAdvertiseTimeout = System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING // The CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS specifies the transition time // starting from advertisement commencement. Since the extended advertisement timer is started after // the fast-to-slow transition, we have to subtract the time spent in fast advertising. @@ -584,7 +584,7 @@ void BLEManagerImpl::DriveBLEState() // Setup service data for advertising. auto serviceDataFlags = BluezAdvertisement::kServiceDataNone; -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (mFlags.Has(Flags::kExtAdvertisingEnabled)) serviceDataFlags |= BluezAdvertisement::kServiceDataExtendedAnnouncement; #endif @@ -667,7 +667,7 @@ BluezAdvertisement::AdvertisingIntervals BLEManagerImpl::GetAdvertisingIntervals { if (mFlags.Has(Flags::kFastAdvertisingEnabled)) return { CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX }; -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (mFlags.Has(Flags::kExtAdvertisingEnabled)) return { CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX }; #endif @@ -682,7 +682,7 @@ void BLEManagerImpl::HandleAdvertisingTimer(chip::System::Layer *, void * appSta { ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); self->_SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING self->mFlags.Clear(Flags::kExtAdvertisingEnabled); DeviceLayer::SystemLayer().StartTimer(kSlowAdvertiseTimeout, HandleAdvertisingTimer, self); } diff --git a/src/platform/Linux/bluez/BluezAdvertisement.cpp b/src/platform/Linux/bluez/BluezAdvertisement.cpp index c68d601d241cd0..859c1bf64fa07b 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.cpp +++ b/src/platform/Linux/bluez/BluezAdvertisement.cpp @@ -161,7 +161,7 @@ CHIP_ERROR BluezAdvertisement::SetupServiceData(ServiceDataFlags aFlags) deviceInfo.SetAdditionalDataFlag(true); #endif -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (aFlags & kServiceDataExtendedAnnouncement) { deviceInfo.SetExtendedAnnouncementFlag(true); diff --git a/src/platform/NuttX/BLEManagerImpl.cpp b/src/platform/NuttX/BLEManagerImpl.cpp index f28308dd86fc6a..6672b5d4bdd295 100644 --- a/src/platform/NuttX/BLEManagerImpl.cpp +++ b/src/platform/NuttX/BLEManagerImpl.cpp @@ -60,7 +60,7 @@ static constexpr System::Clock::Timeout kNewConnectionScanTimeout = System::Cloc static constexpr System::Clock::Timeout kConnectTimeout = System::Clock::Seconds16(20); static constexpr System::Clock::Timeout kFastAdvertiseTimeout = System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING // The CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS specifies the transition time // starting from advertisement commencement. Since the extended advertisement timer is started after // the fast-to-slow transition, we have to subtract the time spent in fast advertising. @@ -593,7 +593,7 @@ void BLEManagerImpl::DriveBLEState() // Setup service data for advertising. auto serviceDataFlags = BluezAdvertisement::kServiceDataNone; -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (mFlags.Has(Flags::kExtAdvertisingEnabled)) serviceDataFlags |= BluezAdvertisement::kServiceDataExtendedAnnouncement; #endif @@ -662,7 +662,7 @@ BluezAdvertisement::AdvertisingIntervals BLEManagerImpl::GetAdvertisingIntervals { if (mFlags.Has(Flags::kFastAdvertisingEnabled)) return { CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX }; -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (mFlags.Has(Flags::kExtAdvertisingEnabled)) return { CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN, CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MAX }; #endif @@ -677,7 +677,7 @@ void BLEManagerImpl::HandleAdvertisingTimer(chip::System::Layer *, void * appSta { ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); self->_SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING self->mFlags.Clear(Flags::kExtAdvertisingEnabled); DeviceLayer::SystemLayer().StartTimer(kSlowAdvertiseTimeout, HandleAdvertisingTimer, self); } diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index 7af097195c6e27..49751da62479e3 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -295,7 +295,7 @@ inline CHIP_ERROR BLEManagerImpl::PrepareAdvertisingRequest() Encoding::LittleEndian::Put16(serviceData.uuid, UUID16_CHIPoBLEService.val); ReturnErrorOnFailure(ConfigurationMgr().GetBLEDeviceIdentificationInfo(serviceData.deviceIdInfo)); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (mFlags.Has(Flags::kExtendedAdvertisingEnabled)) { serviceData.deviceIdInfo.SetVendorId(DEVICE_HANDLE_NULL); @@ -316,7 +316,7 @@ inline CHIP_ERROR BLEManagerImpl::PrepareAdvertisingRequest() mAdvertisingRequest.minInterval = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN; mAdvertisingRequest.maxInterval = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX; } -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING else if (mFlags.Has(Flags::kExtendedAdvertisingEnabled)) { mAdvertisingRequest.minInterval = CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_MIN; @@ -421,7 +421,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising() System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME), HandleSlowBLEAdvertisementInterval, this); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING // Start timer to schedule start of the extended advertising DeviceLayer::SystemLayer().StartTimer( System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS), @@ -443,7 +443,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising() mFlags.Clear(Flags::kAdvertising); mFlags.Set(Flags::kFastAdvertisingEnabled, true); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING mFlags.Clear(Flags::kExtendedAdvertisingEnabled); #endif diff --git a/src/platform/Zephyr/CHIPDevicePlatformConfig.h b/src/platform/Zephyr/CHIPDevicePlatformConfig.h index 687e743444b9d9..3c855a74374668 100644 --- a/src/platform/Zephyr/CHIPDevicePlatformConfig.h +++ b/src/platform/Zephyr/CHIPDevicePlatformConfig.h @@ -166,7 +166,7 @@ #endif // CONFIG_CHIP_EXTENDED_DISCOVERY #ifdef CONFIG_CHIP_BLE_EXT_ADVERTISING -#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 1 +#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING 1 #endif // CONFIG_CHIP_BLE_EXT_ADVERTISING #define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS (CONFIG_CHIP_BLE_ADVERTISING_DURATION * 60) diff --git a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h index c05dfb11845605..486a48cc074af2 100644 --- a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h +++ b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h @@ -242,7 +242,7 @@ #endif // CONFIG_CHIP_EXTENDED_DISCOVERY #ifdef CONFIG_CHIP_BLE_EXT_ADVERTISING -#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 1 +#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING 1 #endif // CONFIG_CHIP_BLE_EXT_ADVERTISING #define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS (CONFIG_CHIP_BLE_ADVERTISING_DURATION * 60) diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 010d72ebb887eb..d8c58a93685c21 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -155,7 +155,7 @@ #define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE 25 -#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING SL_MATTER_BLE_EXTENDED_ADV +#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING SL_MATTER_BLE_EXTENDED_ADV /* ICD Configuration Defines diff --git a/src/platform/silabs/efr32/BLEManagerImpl.cpp b/src/platform/silabs/efr32/BLEManagerImpl.cpp index e29e34e31af16e..ef553bffa152a1 100644 --- a/src/platform/silabs/efr32/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/BLEManagerImpl.cpp @@ -449,7 +449,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) advData[index++] = ShortUUID_CHIPoBLEService[0]; // AD value advData[index++] = ShortUUID_CHIPoBLEService[1]; -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING // Check for extended advertisement interval and redact VID/PID if past the initial period. if (mFlags.Has(Flags::kExtAdvertisingEnabled)) { @@ -553,7 +553,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) } else { -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING if (!mFlags.Has(Flags::kExtAdvertisingEnabled)) { interval_min = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN; @@ -993,12 +993,12 @@ void BLEManagerImpl::BleAdvTimeoutHandler(void * arg) ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement"); BLEMgrImpl().mFlags.Set(Flags::kAdvertising); BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING BLEMgrImpl().mFlags.Clear(Flags::kExtAdvertisingEnabled); BLEMgrImpl().StartBleAdvTimeoutTimer(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS); #endif } -#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING +#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING else { ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start extended advertisement");