[Chore] Convert chip::Optional to std::optional for dnssd/types.h (#33179)
* Replace some chip Optional with std::optional
* Restyle
* a few more updates
* Also fix RemoteDataLogger.cpp
* Code review feedback: added some bracketing
* Re-do the bracketing
* Fix some of the unchecked optional access warnings
* Also fix TestIncrementalResolve
* Fix Commissionable script binding
* Fix more files
* Restyle
---------
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp
index 9a99605..9e4f29c 100644
--- a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp
+++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp
@@ -245,24 +245,24 @@
value["port"] = resolutionData.port;
value["numIPs"] = static_cast<uint8_t>(resolutionData.numIPs);
- if (resolutionData.mrpRetryIntervalIdle.HasValue())
+ if (resolutionData.mrpRetryIntervalIdle.has_value())
{
- value["mrpRetryIntervalIdle"] = resolutionData.mrpRetryIntervalIdle.Value().count();
+ value["mrpRetryIntervalIdle"] = resolutionData.mrpRetryIntervalIdle->count();
}
- if (resolutionData.mrpRetryIntervalActive.HasValue())
+ if (resolutionData.mrpRetryIntervalActive.has_value())
{
- value["mrpRetryIntervalActive"] = resolutionData.mrpRetryIntervalActive.Value().count();
+ value["mrpRetryIntervalActive"] = resolutionData.mrpRetryIntervalActive->count();
}
- if (resolutionData.mrpRetryActiveThreshold.HasValue())
+ if (resolutionData.mrpRetryActiveThreshold.has_value())
{
- value["mrpRetryActiveThreshold"] = resolutionData.mrpRetryActiveThreshold.Value().count();
+ value["mrpRetryActiveThreshold"] = resolutionData.mrpRetryActiveThreshold->count();
}
- if (resolutionData.isICDOperatingAsLIT.HasValue())
+ if (resolutionData.isICDOperatingAsLIT.has_value())
{
- value["isICDOperatingAsLIT"] = resolutionData.isICDOperatingAsLIT.Value();
+ value["isICDOperatingAsLIT"] = *(resolutionData.isICDOperatingAsLIT);
}
Json::Value rootValue;
diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp
index c3aecbf..cf7ba2a 100644
--- a/src/controller/SetUpCodePairer.cpp
+++ b/src/controller/SetUpCodePairer.cpp
@@ -620,14 +620,14 @@
auto & ip = data.ipAddress[index];
SetPeerAddress(Transport::PeerAddress::UDP(ip, data.port, ip.IsIPv6LinkLocal() ? data.interfaceId : Inet::InterfaceId::Null()));
- if (data.mrpRetryIntervalIdle.HasValue())
+ if (data.mrpRetryIntervalIdle.has_value())
{
- SetIdleInterval(data.mrpRetryIntervalIdle.Value());
+ SetIdleInterval(*data.mrpRetryIntervalIdle);
}
- if (data.mrpRetryIntervalActive.HasValue())
+ if (data.mrpRetryIntervalActive.has_value())
{
- SetActiveInterval(data.mrpRetryIntervalActive.Value());
+ SetActiveInterval(*data.mrpRetryIntervalActive);
}
}
diff --git a/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp b/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp
index 6df32c6..157789f 100644
--- a/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp
+++ b/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp
@@ -97,17 +97,21 @@
ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId);
ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->pairingInstruction);
ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->pairingHint);
- if (dnsSdInfo->GetMrpRetryIntervalIdle().HasValue())
+
+ auto idleInterval = dnsSdInfo->GetMrpRetryIntervalIdle();
+ if (idleInterval.has_value())
{
- ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", dnsSdInfo->GetMrpRetryIntervalIdle().Value().count());
+ ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", idleInterval->count());
}
else
{
ChipLogProgress(Discovery, "\tMrp Interval idle\tNot present");
}
- if (dnsSdInfo->GetMrpRetryIntervalActive().HasValue())
+
+ auto activeInterval = dnsSdInfo->GetMrpRetryIntervalIdle();
+ if (activeInterval.has_value())
{
- ChipLogProgress(Discovery, "\tMrp Interval active\t%u", dnsSdInfo->GetMrpRetryIntervalActive().Value().count());
+ ChipLogProgress(Discovery, "\tMrp Interval active\t%u", activeInterval->count());
}
else
{
@@ -115,9 +119,9 @@
}
ChipLogProgress(Discovery, "\tSupports TCP\t\t%d", dnsSdInfo->supportsTcp);
- if (dnsSdInfo->isICDOperatingAsLIT.HasValue())
+ if (dnsSdInfo->isICDOperatingAsLIT.has_value())
{
- ChipLogProgress(Discovery, "\tICD is operating as a\t%s", dnsSdInfo->isICDOperatingAsLIT.Value() ? "LIT" : "SIT");
+ ChipLogProgress(Discovery, "\tICD is operating as a\t%s", *(dnsSdInfo->isICDOperatingAsLIT) ? "LIT" : "SIT");
}
for (unsigned j = 0; j < dnsSdInfo->numIPs; ++j)
diff --git a/src/controller/python/ChipDeviceController-Discovery.cpp b/src/controller/python/ChipDeviceController-Discovery.cpp
index b758979..4ad6db5 100644
--- a/src/controller/python/ChipDeviceController-Discovery.cpp
+++ b/src/controller/python/ChipDeviceController-Discovery.cpp
@@ -124,17 +124,23 @@
jsonVal["deviceName"] = dnsSdInfo->deviceName;
jsonVal["pairingInstruction"] = dnsSdInfo->pairingInstruction;
jsonVal["pairingHint"] = dnsSdInfo->pairingHint;
- if (dnsSdInfo->GetMrpRetryIntervalIdle().HasValue())
+
+ auto idleInterval = dnsSdInfo->GetMrpRetryIntervalIdle();
+ if (idleInterval.has_value())
{
- jsonVal["mrpRetryIntervalIdle"] = dnsSdInfo->GetMrpRetryIntervalIdle().Value().count();
+ jsonVal["mrpRetryIntervalIdle"] = idleInterval->count();
}
- if (dnsSdInfo->GetMrpRetryIntervalActive().HasValue())
+
+ auto activeInterval = dnsSdInfo->GetMrpRetryIntervalActive();
+ if (activeInterval.has_value())
{
- jsonVal["mrpRetryIntervalActive"] = dnsSdInfo->GetMrpRetryIntervalActive().Value().count();
+ jsonVal["mrpRetryIntervalActive"] = activeInterval->count();
}
- if (dnsSdInfo->GetMrpRetryActiveThreshold().HasValue())
+
+ auto activeThreshold = dnsSdInfo->GetMrpRetryActiveThreshold();
+ if (activeThreshold.has_value())
{
- jsonVal["mrpRetryActiveThreshold"] = dnsSdInfo->GetMrpRetryActiveThreshold().Value().count();
+ jsonVal["mrpRetryActiveThreshold"] = activeThreshold->count();
}
jsonVal["supportsTcp"] = dnsSdInfo->supportsTcp;
{
@@ -147,9 +153,9 @@
}
jsonVal["addresses"] = addresses;
}
- if (dnsSdInfo->isICDOperatingAsLIT.HasValue())
+ if (dnsSdInfo->isICDOperatingAsLIT.has_value())
{
- jsonVal["isICDOperatingAsLIT"] = dnsSdInfo->isICDOperatingAsLIT.Value();
+ jsonVal["isICDOperatingAsLIT"] = *(dnsSdInfo->isICDOperatingAsLIT);
}
if (dnsSdInfo->rotatingIdLen > 0)
{
@@ -188,26 +194,31 @@
ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId);
ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->pairingInstruction);
ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->pairingHint);
- if (dnsSdInfo->GetMrpRetryIntervalIdle().HasValue())
+
+ auto idleInterval = dnsSdInfo->GetMrpRetryIntervalIdle();
+ if (idleInterval.has_value())
{
- ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", dnsSdInfo->GetMrpRetryIntervalIdle().Value().count());
+ ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", idleInterval->count());
}
else
{
ChipLogProgress(Discovery, "\tMrp Interval idle\tNot present");
}
- if (dnsSdInfo->GetMrpRetryIntervalActive().HasValue())
+
+ auto activeInterval = dnsSdInfo->GetMrpRetryIntervalActive();
+ if (activeInterval.has_value())
{
- ChipLogProgress(Discovery, "\tMrp Interval active\t%u", dnsSdInfo->GetMrpRetryIntervalActive().Value().count());
+ ChipLogProgress(Discovery, "\tMrp Interval active\t%u", activeInterval->count());
}
else
{
ChipLogProgress(Discovery, "\tMrp Interval active\tNot present");
}
+
ChipLogProgress(Discovery, "\tSupports TCP\t\t%d", dnsSdInfo->supportsTcp);
- if (dnsSdInfo->isICDOperatingAsLIT.HasValue())
+ if (dnsSdInfo->isICDOperatingAsLIT.has_value())
{
- ChipLogProgress(Discovery, "\tICD is operating as a\t%s", dnsSdInfo->isICDOperatingAsLIT.Value() ? "LIT" : "SIT");
+ ChipLogProgress(Discovery, "\tICD is operating as a\t%s", *(dnsSdInfo->isICDOperatingAsLIT) ? "LIT" : "SIT");
}
for (unsigned j = 0; j < dnsSdInfo->numIPs; ++j)
{
diff --git a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp
index 6e461a4..5a9651f 100644
--- a/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp
+++ b/src/lib/address_resolve/AddressResolve_DefaultImpl.cpp
@@ -290,9 +290,9 @@
result.mrpRemoteConfig = nodeData.resolutionData.GetRemoteMRPConfig();
result.supportsTcp = nodeData.resolutionData.supportsTcp;
- if (nodeData.resolutionData.isICDOperatingAsLIT.HasValue())
+ if (nodeData.resolutionData.isICDOperatingAsLIT.has_value())
{
- result.isICDOperatingAsLIT = nodeData.resolutionData.isICDOperatingAsLIT.Value();
+ result.isICDOperatingAsLIT = *(nodeData.resolutionData.isICDOperatingAsLIT);
}
for (size_t i = 0; i < nodeData.resolutionData.numIPs; i++)
diff --git a/src/lib/dnssd/TxtFields.cpp b/src/lib/dnssd/TxtFields.cpp
index 88a1168..6ac2cfa 100644
--- a/src/lib/dnssd/TxtFields.cpp
+++ b/src/lib/dnssd/TxtFields.cpp
@@ -105,14 +105,14 @@
return val.size() == 1 && static_cast<char>(*val.data()) == '1';
}
-Optional<bool> MakeOptionalBoolFromAsciiDecimal(const ByteSpan & val)
+std::optional<bool> MakeOptionalBoolFromAsciiDecimal(const ByteSpan & val)
{
char character = static_cast<char>(*val.data());
if (val.size() == 1 && ((character == '1') || (character == '0')))
{
- return MakeOptional(character == '1');
+ return std::make_optional(character == '1');
}
- return NullOptional;
+ return std::nullopt;
}
size_t GetPlusSignIdx(const ByteSpan & value)
@@ -188,27 +188,27 @@
return MakeBoolFromAsciiDecimal(value);
}
-Optional<System::Clock::Milliseconds32> GetRetryInterval(const ByteSpan & value)
+std::optional<System::Clock::Milliseconds32> GetRetryInterval(const ByteSpan & value)
{
const auto undefined = std::numeric_limits<uint32_t>::max();
const auto retryInterval = MakeU32FromAsciiDecimal(value, undefined);
if (retryInterval != undefined && retryInterval <= kMaxRetryInterval.count())
- return MakeOptional(System::Clock::Milliseconds32(retryInterval));
+ return std::make_optional(System::Clock::Milliseconds32(retryInterval));
- return NullOptional;
+ return std::nullopt;
}
-Optional<System::Clock::Milliseconds16> GetRetryActiveThreshold(const ByteSpan & value)
+std::optional<System::Clock::Milliseconds16> GetRetryActiveThreshold(const ByteSpan & value)
{
const auto retryInterval = MakeU16FromAsciiDecimal(value);
if (retryInterval == 0)
{
- return NullOptional;
+ return std::nullopt;
}
- return MakeOptional(System::Clock::Milliseconds16(retryInterval));
+ return std::make_optional(System::Clock::Milliseconds16(retryInterval));
}
TxtFieldKey GetTxtFieldKey(const ByteSpan & key)
diff --git a/src/lib/dnssd/Types.h b/src/lib/dnssd/Types.h
index e62c9a5..c88dd0a 100644
--- a/src/lib/dnssd/Types.h
+++ b/src/lib/dnssd/Types.h
@@ -19,10 +19,10 @@
#include <cstdint>
#include <cstring>
+#include <optional>
#include <inet/InetInterface.h>
#include <lib/core/CHIPError.h>
-#include <lib/core/Optional.h>
#include <lib/core/PeerId.h>
#include <lib/dnssd/Constants.h>
#include <lib/support/BytesToHex.h>
@@ -91,10 +91,10 @@
uint16_t port = 0;
char hostName[kHostNameMaxLength + 1] = {};
bool supportsTcp = false;
- Optional<bool> isICDOperatingAsLIT;
- Optional<System::Clock::Milliseconds32> mrpRetryIntervalIdle;
- Optional<System::Clock::Milliseconds32> mrpRetryIntervalActive;
- Optional<System::Clock::Milliseconds16> mrpRetryActiveThreshold;
+ std::optional<bool> isICDOperatingAsLIT;
+ std::optional<System::Clock::Milliseconds32> mrpRetryIntervalIdle;
+ std::optional<System::Clock::Milliseconds32> mrpRetryIntervalActive;
+ std::optional<System::Clock::Milliseconds16> mrpRetryActiveThreshold;
CommonResolutionData() { Reset(); }
@@ -103,21 +103,21 @@
ReliableMessageProtocolConfig GetRemoteMRPConfig() const
{
const ReliableMessageProtocolConfig defaultConfig = GetDefaultMRPConfig();
- return ReliableMessageProtocolConfig(GetMrpRetryIntervalIdle().ValueOr(defaultConfig.mIdleRetransTimeout),
- GetMrpRetryIntervalActive().ValueOr(defaultConfig.mActiveRetransTimeout),
- GetMrpRetryActiveThreshold().ValueOr(defaultConfig.mActiveThresholdTime));
+ return ReliableMessageProtocolConfig(GetMrpRetryIntervalIdle().value_or(defaultConfig.mIdleRetransTimeout),
+ GetMrpRetryIntervalActive().value_or(defaultConfig.mActiveRetransTimeout),
+ GetMrpRetryActiveThreshold().value_or(defaultConfig.mActiveThresholdTime));
}
- Optional<System::Clock::Milliseconds32> GetMrpRetryIntervalIdle() const { return mrpRetryIntervalIdle; }
- Optional<System::Clock::Milliseconds32> GetMrpRetryIntervalActive() const { return mrpRetryIntervalActive; }
- Optional<System::Clock::Milliseconds16> GetMrpRetryActiveThreshold() const { return mrpRetryActiveThreshold; }
+ std::optional<System::Clock::Milliseconds32> GetMrpRetryIntervalIdle() const { return mrpRetryIntervalIdle; }
+ std::optional<System::Clock::Milliseconds32> GetMrpRetryIntervalActive() const { return mrpRetryIntervalActive; }
+ std::optional<System::Clock::Milliseconds16> GetMrpRetryActiveThreshold() const { return mrpRetryActiveThreshold; }
bool IsDeviceTreatedAsSleepy(const ReliableMessageProtocolConfig * defaultMRPConfig) const
{
// If either session interval (Idle - SII, Active - SAI) has a value and that value is greater
// than the value passed to this function, then the peer device will be treated as if it is
// a Sleepy End Device (SED)
- return (mrpRetryIntervalIdle.HasValue() && (mrpRetryIntervalIdle.Value() > defaultMRPConfig->mIdleRetransTimeout)) ||
- (mrpRetryIntervalActive.HasValue() && (mrpRetryIntervalActive.Value() > defaultMRPConfig->mActiveRetransTimeout));
+ return (mrpRetryIntervalIdle.has_value() && (*mrpRetryIntervalIdle > defaultMRPConfig->mIdleRetransTimeout)) ||
+ (mrpRetryIntervalActive.has_value() && (*mrpRetryIntervalActive > defaultMRPConfig->mActiveRetransTimeout));
}
bool IsHost(const char * host) const { return strcmp(host, hostName) == 0; }
@@ -125,10 +125,10 @@
void Reset()
{
memset(hostName, 0, sizeof(hostName));
- mrpRetryIntervalIdle = NullOptional;
- mrpRetryIntervalActive = NullOptional;
- mrpRetryActiveThreshold = NullOptional;
- isICDOperatingAsLIT = NullOptional;
+ mrpRetryIntervalIdle = std::nullopt;
+ mrpRetryIntervalActive = std::nullopt;
+ mrpRetryActiveThreshold = std::nullopt;
+ isICDOperatingAsLIT = std::nullopt;
numIPs = 0;
port = 0;
supportsTcp = false;
@@ -157,34 +157,34 @@
{
ChipLogDetail(Discovery, "\tPort: %u", port);
}
- if (mrpRetryIntervalIdle.HasValue())
+ if (mrpRetryIntervalIdle.has_value())
{
- ChipLogDetail(Discovery, "\tMrp Interval idle: %" PRIu32 " ms", mrpRetryIntervalIdle.Value().count());
+ ChipLogDetail(Discovery, "\tMrp Interval idle: %" PRIu32 " ms", mrpRetryIntervalIdle->count());
}
else
{
ChipLogDetail(Discovery, "\tMrp Interval idle: not present");
}
- if (mrpRetryIntervalActive.HasValue())
+ if (mrpRetryIntervalActive.has_value())
{
- ChipLogDetail(Discovery, "\tMrp Interval active: %" PRIu32 " ms", mrpRetryIntervalActive.Value().count());
+ ChipLogDetail(Discovery, "\tMrp Interval active: %" PRIu32 " ms", mrpRetryIntervalActive->count());
}
else
{
ChipLogDetail(Discovery, "\tMrp Interval active: not present");
}
- if (mrpRetryActiveThreshold.HasValue())
+ if (mrpRetryActiveThreshold.has_value())
{
- ChipLogDetail(Discovery, "\tMrp Active Threshold: %u ms", mrpRetryActiveThreshold.Value().count());
+ ChipLogDetail(Discovery, "\tMrp Active Threshold: %u ms", mrpRetryActiveThreshold->count());
}
else
{
ChipLogDetail(Discovery, "\tMrp Active Threshold: not present");
}
ChipLogDetail(Discovery, "\tTCP Supported: %d", supportsTcp);
- if (isICDOperatingAsLIT.HasValue())
+ if (isICDOperatingAsLIT.has_value())
{
- ChipLogDetail(Discovery, "\tThe ICD operates in %s", isICDOperatingAsLIT.Value() ? "LIT" : "SIT");
+ ChipLogDetail(Discovery, "\tThe ICD operates in %s", *isICDOperatingAsLIT ? "LIT" : "SIT");
}
else
{
diff --git a/src/lib/dnssd/tests/TestIncrementalResolve.cpp b/src/lib/dnssd/tests/TestIncrementalResolve.cpp
index 5ed4191..0b5f26a 100644
--- a/src/lib/dnssd/tests/TestIncrementalResolve.cpp
+++ b/src/lib/dnssd/tests/TestIncrementalResolve.cpp
@@ -307,9 +307,8 @@
EXPECT_EQ(nodeData.resolutionData.numIPs, 1u);
EXPECT_EQ(nodeData.resolutionData.port, 0x1234);
EXPECT_FALSE(nodeData.resolutionData.supportsTcp);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalIdle().Value(), chip::System::Clock::Milliseconds32(23));
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalIdle(), std::make_optional(chip::System::Clock::Milliseconds32(23)));
Inet::IPAddress addr;
EXPECT_TRUE(Inet::IPAddress::FromString("fe80::abcd:ef11:2233:4455", addr));
@@ -396,9 +395,8 @@
EXPECT_EQ(nodeData.numIPs, 2u);
EXPECT_EQ(nodeData.port, 0x1234);
EXPECT_FALSE(nodeData.supportsTcp);
- EXPECT_TRUE(nodeData.GetMrpRetryIntervalActive().HasValue());
- EXPECT_EQ(nodeData.GetMrpRetryIntervalActive().Value(), chip::System::Clock::Milliseconds32(321));
- EXPECT_FALSE(nodeData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_EQ(nodeData.GetMrpRetryIntervalActive(), std::make_optional(chip::System::Clock::Milliseconds32(321)));
+ EXPECT_FALSE(nodeData.GetMrpRetryIntervalIdle().has_value());
Inet::IPAddress addr;
EXPECT_TRUE(Inet::IPAddress::FromString("fe80::abcd:ef11:2233:4455", addr));
diff --git a/src/lib/dnssd/tests/TestTxtFields.cpp b/src/lib/dnssd/tests/TestTxtFields.cpp
index ce206e3..b80f1c0 100644
--- a/src/lib/dnssd/tests/TestTxtFields.cpp
+++ b/src/lib/dnssd/tests/TestTxtFields.cpp
@@ -304,9 +304,9 @@
{
if (node.longDiscriminator != 0 || node.vendorId != 0 || node.productId != 0 || node.commissioningMode != 0 ||
- node.deviceType != 0 || node.rotatingIdLen != 0 || node.pairingHint != 0 || node.mrpRetryIntervalIdle.HasValue() ||
- node.mrpRetryIntervalActive.HasValue() || node.mrpRetryActiveThreshold.HasValue() || node.isICDOperatingAsLIT.HasValue() ||
- node.supportsTcp || node.supportsCommissionerGeneratedPasscode != 0)
+ node.deviceType != 0 || node.rotatingIdLen != 0 || node.pairingHint != 0 || node.mrpRetryIntervalIdle.has_value() ||
+ node.mrpRetryIntervalActive.has_value() || node.mrpRetryActiveThreshold.has_value() ||
+ node.isICDOperatingAsLIT.has_value() || node.supportsTcp || node.supportsCommissionerGeneratedPasscode != 0)
{
return false;
}
@@ -411,39 +411,39 @@
bool NodeDataIsEmpty(const ResolvedNodeData & nodeData)
{
return nodeData.operationalData.peerId == PeerId{} && nodeData.resolutionData.numIPs == 0 &&
- nodeData.resolutionData.port == 0 && !nodeData.resolutionData.mrpRetryIntervalIdle.HasValue() &&
- !nodeData.resolutionData.mrpRetryIntervalActive.HasValue() && !nodeData.resolutionData.supportsTcp &&
- !nodeData.resolutionData.isICDOperatingAsLIT.HasValue();
+ nodeData.resolutionData.port == 0 && !nodeData.resolutionData.mrpRetryIntervalIdle.has_value() &&
+ !nodeData.resolutionData.mrpRetryIntervalActive.has_value() && !nodeData.resolutionData.supportsTcp &&
+ !nodeData.resolutionData.isICDOperatingAsLIT.has_value();
}
void ResetRetryIntervalIdle(DiscoveredNodeData & nodeData)
{
- nodeData.Get<CommissionNodeData>().mrpRetryIntervalIdle.ClearValue();
+ nodeData.Get<CommissionNodeData>().mrpRetryIntervalIdle.reset();
}
void ResetRetryIntervalIdle(ResolvedNodeData & nodeData)
{
- nodeData.resolutionData.mrpRetryIntervalIdle.ClearValue();
+ nodeData.resolutionData.mrpRetryIntervalIdle.reset();
}
void ResetRetryIntervalActive(DiscoveredNodeData & nodeData)
{
- nodeData.Get<CommissionNodeData>().mrpRetryIntervalActive.ClearValue();
+ nodeData.Get<CommissionNodeData>().mrpRetryIntervalActive.reset();
}
void ResetRetryIntervalActive(ResolvedNodeData & nodeData)
{
- nodeData.resolutionData.mrpRetryIntervalActive.ClearValue();
+ nodeData.resolutionData.mrpRetryIntervalActive.reset();
}
void ResetRetryActiveThreshold(DiscoveredNodeData & nodeData)
{
- nodeData.Get<CommissionNodeData>().mrpRetryActiveThreshold.ClearValue();
+ nodeData.Get<CommissionNodeData>().mrpRetryActiveThreshold.reset();
}
void ResetRetryActiveThreshold(ResolvedNodeData & nodeData)
{
- nodeData.resolutionData.mrpRetryActiveThreshold.ClearValue();
+ nodeData.resolutionData.mrpRetryActiveThreshold.reset();
}
template <class NodeData>
@@ -459,15 +459,13 @@
strcpy(key, "SII");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().Value() == 1_ms32);
+ EXPECT_EQ(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle(), std::make_optional(1_ms32));
// Maximum
strcpy(key, "SII");
strcpy(val, "3600000");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().Value() == 3600000_ms32);
+ EXPECT_EQ(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle(), std::make_optional(3600000_ms32));
// Test no other fields were populated
ResetRetryIntervalIdle(nodeData);
@@ -477,37 +475,37 @@
strcpy(key, "SII");
strcpy(val, "-1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().has_value());
// Invalid SII - greater than maximum
strcpy(key, "SII");
strcpy(val, "3600001");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().has_value());
// Invalid SII - much greater than maximum
strcpy(key, "SII");
strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32)
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().has_value());
// Invalid SII - hexadecimal value
strcpy(key, "SII");
strcpy(val, "0x20");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().has_value());
// Invalid SII - leading zeros
strcpy(key, "SII");
strcpy(val, "0700");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().has_value());
// Invalid SII - text at the end
strcpy(key, "SII");
strcpy(val, "123abc");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalIdle().has_value());
}
// Test SAI (formerly CRA)
@@ -524,15 +522,13 @@
strcpy(key, "SAI");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().Value() == 1_ms32);
+ EXPECT_EQ(nodeData.Get<NodeData>().GetMrpRetryIntervalActive(), std::make_optional(1_ms32));
// Maximum
strcpy(key, "SAI");
strcpy(val, "3600000");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().Value() == 3600000_ms32);
+ EXPECT_EQ(nodeData.Get<NodeData>().GetMrpRetryIntervalActive(), std::make_optional(3600000_ms32));
// Test no other fields were populated
ResetRetryIntervalActive(nodeData);
@@ -542,37 +538,37 @@
strcpy(key, "SAI");
strcpy(val, "-1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().has_value());
// Invalid SAI - greater than maximum
strcpy(key, "SAI");
strcpy(val, "3600001");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().has_value());
// Invalid SAI - much greater than maximum
strcpy(key, "SAI");
strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32)
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().has_value());
// Invalid SAI - hexadecimal value
strcpy(key, "SAI");
strcpy(val, "0x20");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().has_value());
// Invalid SAI - leading zeros
strcpy(key, "SAI");
strcpy(val, "0700");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().has_value());
// Invalid SAI - text at the end
strcpy(key, "SAI");
strcpy(val, "123abc");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryIntervalActive().has_value());
}
// Test SAT (Session Active Threshold)
@@ -589,15 +585,13 @@
strcpy(key, "SAT");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().Value() == 1_ms16);
+ EXPECT_EQ(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold(), std::make_optional(1_ms16));
// Maximum
strcpy(key, "SAT");
strcpy(val, "65535");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().Value() == 65535_ms16);
+ EXPECT_EQ(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold(), std::make_optional(65535_ms16));
// Test no other fields were populated
ResetRetryActiveThreshold(nodeData);
@@ -607,37 +601,37 @@
strcpy(key, "SAT");
strcpy(val, "-1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().has_value());
// Invalid SAI - greater than maximum
strcpy(key, "SAT");
strcpy(val, "65536");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - much greater than maximum
strcpy(key, "SAT");
strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32)
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - hexadecimal value
strcpy(key, "SAT");
strcpy(val, "0x20");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - leading zeros
strcpy(key, "SAT");
strcpy(val, "0700");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - text at the end
strcpy(key, "SAT");
strcpy(val, "123abc");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.Get<NodeData>().GetMrpRetryActiveThreshold().has_value());
}
// Test T (TCP support)
@@ -687,27 +681,25 @@
strcpy(key, "ICD");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().isICDOperatingAsLIT.HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().isICDOperatingAsLIT.Value());
+ EXPECT_EQ(nodeData.Get<NodeData>().isICDOperatingAsLIT, std::make_optional(true));
// Test no other fields were populated
- nodeData.Get<NodeData>().isICDOperatingAsLIT.ClearValue();
+ nodeData.Get<NodeData>().isICDOperatingAsLIT.reset();
EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get<NodeData>()));
// ICD is operating as a SIT device
strcpy(key, "ICD");
strcpy(val, "0");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().isICDOperatingAsLIT.HasValue());
- EXPECT_TRUE(nodeData.Get<NodeData>().isICDOperatingAsLIT.Value() == false);
+ EXPECT_EQ(nodeData.Get<NodeData>().isICDOperatingAsLIT, std::make_optional(false));
- nodeData.Get<NodeData>().isICDOperatingAsLIT.ClearValue();
+ nodeData.Get<NodeData>().isICDOperatingAsLIT.reset();
EXPECT_TRUE(NodeDataIsEmpty(nodeData.Get<NodeData>()));
// Invalid value, No key set
strcpy(key, "ICD");
strcpy(val, "asdf");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(nodeData.Get<NodeData>().isICDOperatingAsLIT.HasValue() == false);
+ EXPECT_FALSE(nodeData.Get<NodeData>().isICDOperatingAsLIT.has_value());
}
// Test IsDeviceTreatedAsSleepy() with CRI
@@ -723,13 +715,13 @@
CommonResolutionData & resolutionData = nodeData.Get<NodeData>();
// No key/val set, so the device can't be sleepy
- EXPECT_TRUE(!nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
+ EXPECT_FALSE(nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
// If the interval is the default value, the device is not sleepy
strcpy(key, "SII");
sprintf(val, "%d", static_cast<int>(CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL.count()));
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
+ EXPECT_FALSE(nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
// If the interval is greater than the default value, the device is sleepy
sprintf(key, "SII");
@@ -751,13 +743,13 @@
CommonResolutionData & resolutionData = nodeData.Get<NodeData>();
// No key/val set, so the device can't be sleepy
- EXPECT_TRUE(!nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
+ EXPECT_FALSE(nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
// If the interval is the default value, the device is not sleepy
sprintf(key, "SAI");
sprintf(val, "%d", static_cast<int>(CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL.count()));
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), resolutionData);
- EXPECT_TRUE(!nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
+ EXPECT_FALSE(nodeData.Get<NodeData>().IsDeviceTreatedAsSleepy(&defaultMRPConfig));
// If the interval is greater than the default value, the device is sleepy
strcpy(key, "SAI");
@@ -778,15 +770,13 @@
strcpy(key, "SII");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalIdle().Value(), 1_ms32);
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalIdle(), std::make_optional(1_ms32));
// Maximum
strcpy(key, "SII");
strcpy(val, "3600000");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalIdle().Value(), 3600000_ms32);
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalIdle(), std::make_optional(3600000_ms32));
// Test no other fields were populated
ResetRetryIntervalIdle(nodeData);
@@ -796,37 +786,37 @@
strcpy(key, "SII");
strcpy(val, "-1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().has_value());
// Invalid SII - greater than maximum
strcpy(key, "SII");
strcpy(val, "3600001");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().has_value());
// Invalid SII - much greater than maximum
strcpy(key, "SII");
strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32)
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().has_value());
// Invalid SII - hexadecimal value
strcpy(key, "SII");
strcpy(val, "0x20");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().has_value());
// Invalid SII - leading zeros
strcpy(key, "SII");
strcpy(val, "0700");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().has_value());
// Invalid SII - text at the end
strcpy(key, "SII");
strcpy(val, "123abc");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalIdle().has_value());
}
TEST(TestTxtFields, TxtDiscoveredFieldMrpRetryIntervalIdle)
@@ -851,15 +841,13 @@
strcpy(key, "SAI");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalActive().Value(), 1_ms32);
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalActive(), std::make_optional(1_ms32));
// Maximum
strcpy(key, "SAI");
strcpy(val, "3600000");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalActive().Value(), 3600000_ms32);
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryIntervalActive(), std::make_optional(3600000_ms32));
// Test no other fields were populated
ResetRetryIntervalActive(nodeData);
@@ -869,37 +857,37 @@
strcpy(key, "SAI");
strcpy(val, "-1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
// Invalid SAI - greater than maximum
strcpy(key, "SAI");
strcpy(val, "3600001");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
// Invalid SAI - much greater than maximum
strcpy(key, "SAI");
strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32)
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
// Invalid SAI - hexadecimal value
strcpy(key, "SAI");
strcpy(val, "0x20");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
// Invalid SAI - leading zeros
strcpy(key, "SAI");
strcpy(val, "0700");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
// Invalid SAI - text at the end
strcpy(key, "SAI");
strcpy(val, "123abc");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryIntervalActive().has_value());
}
TEST(TestTxtFields, TxtDiscoveredFieldMrpRetryIntervalActive)
@@ -924,15 +912,13 @@
strcpy(key, "SAT");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryActiveThreshold().Value(), 1_ms16);
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryActiveThreshold(), std::make_optional(1_ms16));
// Maximum
strcpy(key, "SAT");
strcpy(val, "65535");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
- EXPECT_EQ(nodeData.resolutionData.GetMrpRetryActiveThreshold().Value(), 65535_ms16);
+ EXPECT_EQ(nodeData.resolutionData.GetMrpRetryActiveThreshold(), std::make_optional(65535_ms16));
// Test no other fields were populated
ResetRetryActiveThreshold(nodeData);
@@ -942,37 +928,37 @@
strcpy(key, "SAT");
strcpy(val, "-1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().has_value());
// Invalid SAI - greater than maximum
strcpy(key, "SAT");
strcpy(val, "65536");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - much greater than maximum
strcpy(key, "SAT");
strcpy(val, "1095216660481"); // 0xFF00000001 == 1 (mod 2^32)
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - hexadecimal value
strcpy(key, "SAT");
strcpy(val, "0x20");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - leading zeros
strcpy(key, "SAT");
strcpy(val, "0700");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().has_value());
// Invalid SAT - text at the end
strcpy(key, "SAT");
strcpy(val, "123abc");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().HasValue());
+ EXPECT_FALSE(nodeData.resolutionData.GetMrpRetryActiveThreshold().has_value());
}
TEST(TestTxtFields, TxtDiscoveredFieldMrpRetryActiveThreshold)
@@ -1038,27 +1024,27 @@
strcpy(key, "ICD");
strcpy(val, "1");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.isICDOperatingAsLIT.HasValue());
- EXPECT_TRUE(nodeData.resolutionData.isICDOperatingAsLIT.Value());
+ EXPECT_TRUE(nodeData.resolutionData.isICDOperatingAsLIT.has_value());
+ EXPECT_TRUE(nodeData.resolutionData.isICDOperatingAsLIT.value_or(false));
// Test no other fields were populated
- nodeData.resolutionData.isICDOperatingAsLIT.ClearValue();
+ nodeData.resolutionData.isICDOperatingAsLIT.reset();
EXPECT_TRUE(NodeDataIsEmpty(nodeData));
// ICD is operating as a SIT device
strcpy(key, "ICD");
strcpy(val, "0");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_TRUE(nodeData.resolutionData.isICDOperatingAsLIT.HasValue());
- EXPECT_EQ(nodeData.resolutionData.isICDOperatingAsLIT.Value(), false);
+ EXPECT_TRUE(nodeData.resolutionData.isICDOperatingAsLIT.has_value());
+ EXPECT_EQ(nodeData.resolutionData.isICDOperatingAsLIT.value_or(true), false);
- nodeData.resolutionData.isICDOperatingAsLIT.ClearValue();
+ nodeData.resolutionData.isICDOperatingAsLIT.reset();
EXPECT_TRUE(NodeDataIsEmpty(nodeData));
// Invalid value, No key set
strcpy(key, "ICD");
strcpy(val, "asdf");
FillNodeDataFromTxt(GetSpan(key), GetSpan(val), nodeData.resolutionData);
- EXPECT_EQ(nodeData.resolutionData.isICDOperatingAsLIT.HasValue(), false);
+ EXPECT_EQ(nodeData.resolutionData.isICDOperatingAsLIT.has_value(), false);
}
TEST(TestTxtFields, TxtDiscoveredIsICDoperatingAsLIT)
diff --git a/src/lib/shell/commands/Dns.cpp b/src/lib/shell/commands/Dns.cpp
index 04d8231..7fac018 100644
--- a/src/lib/shell/commands/Dns.cpp
+++ b/src/lib/shell/commands/Dns.cpp
@@ -115,25 +115,25 @@
auto retryInterval = nodeData.GetMrpRetryIntervalIdle();
- if (retryInterval.HasValue())
- streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\r\n", retryInterval.Value());
+ if (retryInterval.has_value())
+ streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\r\n", *retryInterval);
retryInterval = nodeData.GetMrpRetryIntervalActive();
- if (retryInterval.HasValue())
- streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\r\n", retryInterval.Value());
+ if (retryInterval.has_value())
+ streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\r\n", *retryInterval);
- if (nodeData.GetMrpRetryActiveThreshold().HasValue())
+ auto activeThreshold = nodeData.GetMrpRetryActiveThreshold();
+
+ if (activeThreshold.has_value())
{
- streamer_printf(streamer_get(), " MRP retry active threshold time: %" PRIu32 "ms\r\n",
- nodeData.GetMrpRetryActiveThreshold().Value());
+ streamer_printf(streamer_get(), " MRP retry active threshold time: %" PRIu32 "ms\r\n", *activeThreshold);
}
streamer_printf(streamer_get(), " Supports TCP: %s\r\n", nodeData.supportsTcp ? "yes" : "no");
- if (nodeData.isICDOperatingAsLIT.HasValue())
+ if (nodeData.isICDOperatingAsLIT.has_value())
{
- streamer_printf(streamer_get(), " ICD is operating as a: %s\r\n",
- nodeData.isICDOperatingAsLIT.Value() ? "LIT" : "SIT");
+ streamer_printf(streamer_get(), " ICD is operating as a: %s\r\n", *(nodeData.isICDOperatingAsLIT) ? "LIT" : "SIT");
}
streamer_printf(streamer_get(), " IP addresses:\r\n");
for (size_t i = 0; i < nodeData.numIPs; i++)