From ad915bcd3cdfdeea14b85320b41dc7eabed466ae Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Thu, 1 Jun 2023 11:50:23 -0400 Subject: [PATCH] Add a GenericThreadDriver constructor to set 2 private timeout variable, Add setter for those same variables so user cand modify them at runtime if they need to. --- .../GenericNetworkCommissioningThreadDriver.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h b/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h index 8a445e8d6c08e8..4a87d07e2fb084 100644 --- a/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h +++ b/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h @@ -81,6 +81,12 @@ class GenericThreadDriver final : public ThreadDriver bool exhausted = false; }; + GenericThreadDriver(uint8_t scanTimeoutSec = 10, uint8_t connectTimeoutSec = 20) + { + scanNetworkTimeoutSeconds = scanTimeoutSec; + connectNetworkTimeout = connectTimeoutSec; + } + // BaseDriver NetworkIterator * GetNetworks() override { return new ThreadNetworkIterator(this); } CHIP_ERROR Init(Internal::BaseDriver::NetworkStatusChangeCallback * statusChangeCallback) override; @@ -88,8 +94,11 @@ class GenericThreadDriver final : public ThreadDriver // WirelessDriver uint8_t GetMaxNetworks() override { return 1; } - uint8_t GetScanNetworkTimeoutSeconds() override { return 10; } - uint8_t GetConnectNetworkTimeoutSeconds() override { return 20; } + uint8_t GetScanNetworkTimeoutSeconds() override { return scanNetworkTimeoutSeconds; } + uint8_t GetConnectNetworkTimeoutSeconds() override { return connectNetworkTimeout; } + + void SetScanNetworkTimeoutSeconds(uint8_t scanTimeoutSec) { scanNetworkTimeoutSeconds = scanTimeoutSec; } + void SetConnectNetworkTimeoutSeconds(uint8_t connectTimeoutSec) { connectNetworkTimeout = connectTimeoutSec; } CHIP_ERROR CommitConfiguration() override; CHIP_ERROR RevertConfiguration() override; @@ -103,6 +112,8 @@ class GenericThreadDriver final : public ThreadDriver void ScanNetworks(ThreadDriver::ScanCallback * callback) override; private: + uint8_t scanNetworkTimeoutSeconds; + uint8_t connectNetworkTimeout; Status MatchesNetworkId(const Thread::OperationalDataset & dataset, const ByteSpan & networkId) const; CHIP_ERROR BackupConfiguration();