Skip to content

Commit

Permalink
Fix max timeout for open commissioning window
Browse files Browse the repository at this point in the history
Commissioning window can be opened using timeout exceeding
the maximum value of 900 s defined by the spec. This can happen
if selected transport is IP, but the device uses BLE extended
announcement feature.

Added checking if device is commissioned to be able to determine
what max timeout should be used for the particular scenario.

Fixes: project-chip#35505
  • Loading branch information
kkasperczyk-no committed Sep 11, 2024
1 parent 83d345e commit 51cd0a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,20 @@ CHIP_ERROR CommissioningWindowManager::AdvertiseAndListenForPASE()
return CHIP_NO_ERROR;
}

System::Clock::Seconds32 CommissioningWindowManager::MaxCommissioningTimeout() const
{
#if CHIP_DEVICE_CONFIG_BLE_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: 1 addition & 10 deletions src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 51cd0a2

Please sign in to comment.