Skip to content

Commit

Permalink
Revert "[nrf fromtree] Fix max timeout for open commissioning window (p…
Browse files Browse the repository at this point in the history
…roject-chip#35507)"

This reverts commit 7c2da28.

Signed-off-by: Adrian Gielniewski <[email protected]>
  • Loading branch information
adigie committed Nov 28, 2024
1 parent 9e942fa commit 573e763
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 918 deletions.
14 changes: 0 additions & 14 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,6 @@ 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)
{
Expand Down
11 changes: 10 additions & 1 deletion src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ class CommissioningWindowManager : public Messaging::UnsolicitedMessageHandler,
return CHIP_NO_ERROR;
}

System::Clock::Seconds32 MaxCommissioningTimeout() const;
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 MinCommissioningTimeout() const
{
Expand Down
14 changes: 7 additions & 7 deletions src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,18 +631,18 @@
#endif

/**
* CHIP_DEVICE_CONFIG_EXT_ADVERTISING
* CHIP_DEVICE_CONFIG_BLE_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_EXT_ADVERTISING
#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING 0
#ifndef CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING 0
#endif

#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING

/**
* CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS
Expand Down Expand Up @@ -726,18 +726,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_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_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_EXT_ADVERTISING is enabled bump the default Discovery timeout
* Therefore, when CHIP_DEVICE_CONFIG_BLE_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_EXT_ADVERTISING
#endif // CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
#endif // CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS

/**
Expand Down
7 changes: 1 addition & 6 deletions src/platform/ESP32/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@
#define CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS CONFIG_CHIP_DISCOVERY_TIMEOUT_SECS
#define CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE CONFIG_ENABLE_ESP32_BLE_CONTROLLER
#define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART

#ifdef CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT
#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT
#else
#define CHIP_DEVICE_CONFIG_EXT_ADVERTISING 0
#endif
#define CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING CONFIG_ENABLE_BLE_EXT_ANNOUNCEMENT

// Options for background chip task
#define CHIP_DEVICE_CONFIG_ENABLE_BG_EVENT_PROCESSING CONFIG_ENABLE_BG_EVENT_PROCESSING
Expand Down
8 changes: 4 additions & 4 deletions src/platform/ESP32/nimble/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer)
BLEMgrImpl().mFlags.Set(Flags::kFastAdvertisingEnabled, 0);
BLEMgrImpl().mFlags.Set(Flags::kAdvertisingRefreshNeeded, 1);

#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
BLEMgrImpl().mFlags.Clear(Flags::kExtAdvertisingEnabled);
BLEMgrImpl().StartBleAdvTimeoutTimer(CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING_INTERVAL_CHANGE_TIME_MS);
#endif
PlatformMgr().ScheduleWork(DriveBLEState, 0);
}
#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
else
{
ChipLogProgress(DeviceLayer, "bleAdv Timeout : Start extended advertisement");
Expand Down Expand Up @@ -1094,7 +1094,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)
ExitNow();
}

#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
// Check for extended advertisement interval and redact VID/PID if past the initial period.
if (mFlags.Has(Flags::kExtAdvertisingEnabled))
{
Expand Down Expand Up @@ -1699,7 +1699,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
}
else
{
#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
if (!mFlags.Has(Flags::kExtAdvertisingEnabled))
{
adv_params.itvl_min = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN;
Expand Down
8 changes: 4 additions & 4 deletions src/platform/Linux/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_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.
Expand Down Expand Up @@ -629,7 +629,7 @@ void BLEManagerImpl::DriveBLEState()

// Setup service data for advertising.
auto serviceDataFlags = BluezAdvertisement::kServiceDataNone;
#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
if (mFlags.Has(Flags::kExtAdvertisingEnabled))
serviceDataFlags |= BluezAdvertisement::kServiceDataExtendedAnnouncement;
#endif
Expand Down Expand Up @@ -698,7 +698,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_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_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
Expand All @@ -713,7 +713,7 @@ void BLEManagerImpl::HandleAdvertisingTimer(chip::System::Layer *, void * appSta
{
ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisement");
self->_SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising);
#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
self->mFlags.Clear(Flags::kExtAdvertisingEnabled);
DeviceLayer::SystemLayer().StartTimer(kSlowAdvertiseTimeout, HandleAdvertisingTimer, self);
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezAdvertisement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ CHIP_ERROR BluezAdvertisement::SetupServiceData(ServiceDataFlags aFlags)
deviceInfo.SetAdditionalDataFlag(true);
#endif

#if CHIP_DEVICE_CONFIG_EXT_ADVERTISING
#if CHIP_DEVICE_CONFIG_BLE_EXT_ADVERTISING
if (aFlags & kServiceDataExtendedAnnouncement)
{
deviceInfo.SetExtendedAnnouncementFlag(true);
Expand Down
Loading

0 comments on commit 573e763

Please sign in to comment.