Skip to content

Commit

Permalink
fix PH, allow for longer extended discovery timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo committed Mar 24, 2022
1 parent 1f3467e commit 4038dc0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ bool DnssdServer::HaveOperationalCredentials()

#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY

void DnssdServer::SetExtendedDiscoveryTimeoutSecs(int16_t secs)
void DnssdServer::SetExtendedDiscoveryTimeoutSecs(int32_t secs)
{
ChipLogDetail(Discovery, "Setting extended discovery timeout to %" PRId16 "s", secs);
chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Put(DefaultStorageKeyAllocator::DNSExtendedDiscoveryTimeout(), secs);
}

int16_t DnssdServer::GetExtendedDiscoveryTimeoutSecs()
int32_t DnssdServer::GetExtendedDiscoveryTimeoutSecs()
{
int16_t secs;
int32_t secs;
CHIP_ERROR err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Get(
DefaultStorageKeyAllocator::DNSExtendedDiscoveryTimeout(), &secs);

Expand Down Expand Up @@ -199,7 +199,7 @@ void DnssdServer::OnDiscoveryExpiration(System::Layer * aSystemLayer, void * aAp
ChipLogDetail(Discovery, "OnDiscoveryExpiration callback for valid session");

#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
int16_t extTimeout = GetExtendedDiscoveryTimeoutSecs();
int32_t extTimeout = GetExtendedDiscoveryTimeoutSecs();
if (extTimeout != CHIP_DEVICE_CONFIG_DISCOVERY_DISABLED)
{
CHIP_ERROR err = AdvertiseCommissionableNode(chip::Dnssd::CommissioningMode::kDisabled);
Expand Down Expand Up @@ -232,16 +232,16 @@ CHIP_ERROR DnssdServer::ScheduleDiscoveryExpiration()
#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
CHIP_ERROR DnssdServer::ScheduleExtendedDiscoveryExpiration()
{
int16_t extendedDiscoveryTimeoutSecs = GetExtendedDiscoveryTimeoutSecs();
int32_t extendedDiscoveryTimeoutSecs = GetExtendedDiscoveryTimeoutSecs();
if (extendedDiscoveryTimeoutSecs == CHIP_DEVICE_CONFIG_DISCOVERY_NO_TIMEOUT)
{
return CHIP_NO_ERROR;
}
ChipLogDetail(Discovery, "Scheduling extended discovery timeout in %" PRId16 "s", extendedDiscoveryTimeoutSecs);

mExtendedDiscoveryExpiration = mTimeSource.GetMonotonicTimestamp() + System::Clock::Seconds16(extendedDiscoveryTimeoutSecs);
mExtendedDiscoveryExpiration = mTimeSource.GetMonotonicTimestamp() + System::Clock::Seconds32(extendedDiscoveryTimeoutSecs);

return DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(extendedDiscoveryTimeoutSecs),
return DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(extendedDiscoveryTimeoutSecs),
HandleExtendedDiscoveryExpiration, nullptr);
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
Expand Down Expand Up @@ -378,7 +378,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi

advertiseParameters.SetMRPConfig(GetLocalMRPConfig()).SetTcpSupported(Optional<bool>(INET_CONFIG_ENABLE_TCP_ENDPOINT));

if (mode != chip::Dnssd::CommissioningMode::kEnabledEnhanced)
if (!HaveOperationalCredentials())
{
if (DeviceLayer::ConfigurationMgr().GetInitialPairingHint(value) != CHIP_NO_ERROR)
{
Expand Down
10 changes: 5 additions & 5 deletions src/app/server/Dnssd.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class DLL_EXPORT DnssdServer
Inet::InterfaceId GetInterfaceId() { return mInterfaceId; }

/// Sets the factory-new state commissionable node discovery timeout
void SetDiscoveryTimeoutSecs(int16_t secs) { mDiscoveryTimeoutSecs = secs; }
void SetDiscoveryTimeoutSecs(int32_t secs) { mDiscoveryTimeoutSecs = secs; }

/// Gets the factory-new state commissionable node discovery timeout
int16_t GetDiscoveryTimeoutSecs() const { return mDiscoveryTimeoutSecs; }
int32_t GetDiscoveryTimeoutSecs() const { return mDiscoveryTimeoutSecs; }

//
// Override the referenced fabric table from the default that is present
Expand All @@ -88,7 +88,7 @@ class DLL_EXPORT DnssdServer

#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
/// Sets the extended discovery timeout. Value will be persisted across reboots
void SetExtendedDiscoveryTimeoutSecs(int16_t secs);
void SetExtendedDiscoveryTimeoutSecs(int32_t secs);

/// Callback from Extended Discovery Expiration timer
/// Checks if extended discovery has expired and if so,
Expand Down Expand Up @@ -165,15 +165,15 @@ class DLL_EXPORT DnssdServer

/// schedule next discovery expiration
CHIP_ERROR ScheduleDiscoveryExpiration();
int16_t mDiscoveryTimeoutSecs = CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS;
int32_t mDiscoveryTimeoutSecs = CHIP_DEVICE_CONFIG_DISCOVERY_TIMEOUT_SECS;
System::Clock::Timestamp mDiscoveryExpiration = kTimeoutCleared;

/// return true if expirationMs is valid (not cleared and not in the future)
bool OnExpiration(System::Clock::Timestamp expiration);

#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
/// get the current extended discovery timeout (from persistent storage)
int16_t GetExtendedDiscoveryTimeoutSecs();
int32_t GetExtendedDiscoveryTimeoutSecs();

/// schedule next extended discovery expiration
CHIP_ERROR ScheduleExtendedDiscoveryExpiration();
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@
*/
#define CHIP_DEVICE_CONFIG_DISCOVERY_DISABLED 0
#define CHIP_DEVICE_CONFIG_DISCOVERY_NO_TIMEOUT -1
#define CHIP_DEVICE_CONFIG_EXTENDED_DISCOVERY_TIMEOUT_SECS (15 * 60)
#define CHIP_DEVICE_CONFIG_EXTENDED_DISCOVERY_TIMEOUT_SECS (24 * 60 * 60)

/**
* CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE
Expand Down

0 comments on commit 4038dc0

Please sign in to comment.