Skip to content

Commit

Permalink
[sleepy] Rename sleepy params per spec. (#17927)
Browse files Browse the repository at this point in the history
* [sleepy] Initial rename of CRA/CRI to SAI/SII.

* [sleepy] More CRA/CRI -> SAI/SII rename.

* [sleepy] Update comments per review.

* [sleepy] Test mainline case: SAI < SII.

* [sleepy] Fix test after SAI < SII.
  • Loading branch information
turon authored and pull[bot] committed Oct 26, 2023
1 parent 35aae65 commit 63576e3
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/app/tests/suites/certification/Test_TC_SC_4_5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tests:
verification:
"1. On the raspi controller, publish matter service, using below
command $avahi-publish-service 87E1B004E235A130-8FC7772401CD0696
_matter._tcp 22222 CRI=3000 CRA=4000 T=0"
_matter._tcp 22222 SII=3000 SAI=2000 T=0"
disabled: true

- label:
Expand All @@ -51,7 +51,7 @@ tests:
verification:
"1. On the raspi controller, publish matter service chanding the T
value 1, using below command $avahi-publish-service
87E1B004E235A130-8FC7772401CD0696 _matter._tcp 22222 CRI=3000 CRA=4000
87E1B004E235A130-8FC7772401CD0696 _matter._tcp 22222 SII=3000 SAI=2000
T=1"
disabled: true

Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
}
}
#endif
// TODO: In some cases like PASE over IP, CRA and CRI values from commissionable node service should be used
// TODO: In some cases like PASE over IP, SAI and SII values from commissionable node service should be used
session = mSystemState->SessionMgr()->CreateUnauthenticatedSession(params.GetPeerAddress(), device->GetRemoteMRPConfig());
VerifyOrExit(session.HasValue(), err = CHIP_ERROR_NO_MEMORY);

Expand Down
22 changes: 10 additions & 12 deletions src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ class AdvertiserMinMdns : public ServiceAdvertiser,
struct CommonTxtEntryStorage
{
// +2 for all to account for '=' and terminating nullchar
char mrpRetryIntervalIdleBuf[KeySize(TxtFieldKey::kMrpRetryIntervalIdle) + ValSize(TxtFieldKey::kMrpRetryIntervalIdle) + 2];
char mrpRetryIntervalActiveBuf[KeySize(TxtFieldKey::kMrpRetryIntervalActive) +
ValSize(TxtFieldKey::kMrpRetryIntervalActive) + 2];
char sleepyIdleIntervalBuf[KeySize(TxtFieldKey::kSleepyIdleInterval) + ValSize(TxtFieldKey::kSleepyIdleInterval) + 2];
char sleepyActiveIntervalBuf[KeySize(TxtFieldKey::kSleepyActiveInterval) + ValSize(TxtFieldKey::kSleepyActiveInterval) + 2];
char tcpSupportedBuf[KeySize(TxtFieldKey::kTcpSupported) + ValSize(TxtFieldKey::kTcpSupported) + 2];
};
template <class Derived>
Expand All @@ -227,13 +226,13 @@ class AdvertiserMinMdns : public ServiceAdvertiser,
"MRP retry interval idle value exceeds allowed range of 1 hour, using maximum available");
mrp.mIdleRetransTimeout = kMaxRetryInterval;
}
size_t writtenCharactersNumber = snprintf(storage.mrpRetryIntervalIdleBuf, sizeof(storage.mrpRetryIntervalIdleBuf),
"CRI=%" PRIu32, mrp.mIdleRetransTimeout.count());
size_t writtenCharactersNumber = snprintf(storage.sleepyIdleIntervalBuf, sizeof(storage.sleepyIdleIntervalBuf),
"SII=%" PRIu32, mrp.mIdleRetransTimeout.count());
VerifyOrReturnError((writtenCharactersNumber > 0) &&
(writtenCharactersNumber < sizeof(storage.mrpRetryIntervalIdleBuf)),
(writtenCharactersNumber < sizeof(storage.sleepyIdleIntervalBuf)),
CHIP_ERROR_INVALID_STRING_LENGTH);

txtFields[numTxtFields++] = storage.mrpRetryIntervalIdleBuf;
txtFields[numTxtFields++] = storage.sleepyIdleIntervalBuf;
}

{
Expand All @@ -243,13 +242,12 @@ class AdvertiserMinMdns : public ServiceAdvertiser,
"MRP retry interval active value exceeds allowed range of 1 hour, using maximum available");
mrp.mActiveRetransTimeout = kMaxRetryInterval;
}
size_t writtenCharactersNumber =
snprintf(storage.mrpRetryIntervalActiveBuf, sizeof(storage.mrpRetryIntervalActiveBuf), "CRA=%" PRIu32,
mrp.mActiveRetransTimeout.count());
size_t writtenCharactersNumber = snprintf(storage.sleepyActiveIntervalBuf, sizeof(storage.sleepyActiveIntervalBuf),
"SAI=%" PRIu32, mrp.mActiveRetransTimeout.count());
VerifyOrReturnError((writtenCharactersNumber > 0) &&
(writtenCharactersNumber < sizeof(storage.mrpRetryIntervalActiveBuf)),
(writtenCharactersNumber < sizeof(storage.sleepyActiveIntervalBuf)),
CHIP_ERROR_INVALID_STRING_LENGTH);
txtFields[numTxtFields++] = storage.mrpRetryIntervalActiveBuf;
txtFields[numTxtFields++] = storage.sleepyActiveIntervalBuf;
}
}
if (params.GetTcpSupported().HasValue())
Expand Down
14 changes: 7 additions & 7 deletions src/lib/dnssd/Discovery_ImplPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ CHIP_ERROR CopyTxtRecord(TxtFieldKey key, char * buffer, size_t bufferLen, const
{
case TxtFieldKey::kTcpSupported:
return CopyTextRecordValue(buffer, bufferLen, params.GetTcpSupported());
case TxtFieldKey::kMrpRetryIntervalIdle:
case TxtFieldKey::kMrpRetryIntervalActive:
return CopyTextRecordValue(buffer, bufferLen, params.GetMRPConfig(), key == TxtFieldKey::kMrpRetryIntervalIdle);
case TxtFieldKey::kSleepyIdleInterval:
case TxtFieldKey::kSleepyActiveInterval:
return CopyTextRecordValue(buffer, bufferLen, params.GetMRPConfig(), key == TxtFieldKey::kSleepyIdleInterval);
default:
return CHIP_ERROR_INVALID_ARGUMENT;
}
Expand Down Expand Up @@ -537,8 +537,8 @@ CHIP_ERROR DiscoveryImplPlatform::Advertise(const OperationalAdvertisingParamete
{
PREPARE_RECORDS(Operational);

ADD_TXT_RECORD(MrpRetryIntervalIdle);
ADD_TXT_RECORD(MrpRetryIntervalActive);
ADD_TXT_RECORD(SleepyIdleInterval);
ADD_TXT_RECORD(SleepyActiveInterval);
ADD_TXT_RECORD(TcpSupported);

ADD_PTR_RECORD(CompressedFabricId);
Expand All @@ -555,8 +555,8 @@ CHIP_ERROR DiscoveryImplPlatform::Advertise(const CommissionAdvertisingParameter
ADD_TXT_RECORD(VendorProduct);
ADD_TXT_RECORD(DeviceType);
ADD_TXT_RECORD(DeviceName);
ADD_TXT_RECORD(MrpRetryIntervalIdle);
ADD_TXT_RECORD(MrpRetryIntervalActive);
ADD_TXT_RECORD(SleepyIdleInterval);
ADD_TXT_RECORD(SleepyActiveInterval);
ADD_TXT_RECORD(TcpSupported);

ADD_PTR_RECORD(VendorId);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dnssd/Resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct ResolvedNodeData

bool IsDeviceTreatedAsSleepy(const ReliableMessageProtocolConfig * defaultMRPConfig) const
{
// If either retry interval (Idle - CRI, Active - CRA) has a value and that value is greater
// If either sleepy 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 (mMrpRetryIntervalIdle.HasValue() && (mMrpRetryIntervalIdle.Value() > defaultMRPConfig->mIdleRetransTimeout)) ||
Expand Down
8 changes: 4 additions & 4 deletions src/lib/dnssd/TxtFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & val, DiscoveredN
case TxtFieldKey::kPairingHint:
nodeData.pairingHint = Internal::GetPairingHint(val);
break;
case TxtFieldKey::kMrpRetryIntervalIdle:
case TxtFieldKey::kSleepyIdleInterval:
nodeData.mrpRetryIntervalIdle = Internal::GetRetryInterval(val);
break;
case TxtFieldKey::kMrpRetryIntervalActive:
case TxtFieldKey::kSleepyActiveInterval:
nodeData.mrpRetryIntervalActive = Internal::GetRetryInterval(val);
break;
case TxtFieldKey::kTcpSupported:
Expand All @@ -243,10 +243,10 @@ void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & value, ResolvedN
{
switch (Internal::GetTxtFieldKey(key))
{
case TxtFieldKey::kMrpRetryIntervalIdle:
case TxtFieldKey::kSleepyIdleInterval:
nodeData.mMrpRetryIntervalIdle = Internal::GetRetryInterval(value);
break;
case TxtFieldKey::kMrpRetryIntervalActive:
case TxtFieldKey::kSleepyActiveInterval:
nodeData.mMrpRetryIntervalActive = Internal::GetRetryInterval(value);
break;
case TxtFieldKey::kTcpSupported:
Expand Down
12 changes: 6 additions & 6 deletions src/lib/dnssd/TxtFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace Dnssd {
using namespace System::Clock::Literals;

// Operational node TXT entries
static constexpr size_t kKeyMrpRetryIntervalIdleMaxLength = 7; // [CRI] 0-3600000
static constexpr size_t kKeyMrpRetryIntervalActiveMaxLength = 7; // [CRA] 0-3600000
static constexpr size_t kKeySleepyIdleIntervalMaxLength = 7; // [SII] 0-3600000
static constexpr size_t kKeySleepyActiveIntervalMaxLength = 7; // [SAI] 0-3600000
static constexpr System::Clock::Milliseconds32 kMaxRetryInterval = 3600000_ms32;
static constexpr size_t kKeyTcpSupportedMaxLength = 1;

Expand Down Expand Up @@ -66,8 +66,8 @@ enum class TxtFieldKey : uint8_t
kRotatingDeviceId,
kPairingInstruction,
kPairingHint,
kMrpRetryIntervalIdle,
kMrpRetryIntervalActive,
kSleepyIdleInterval,
kSleepyActiveInterval,
kTcpSupported,
kCount,
};
Expand All @@ -92,8 +92,8 @@ constexpr const TxtFieldInfo txtFieldInfo[static_cast<size_t>(TxtFieldKey::kCoun
{ TxtFieldKey::kRotatingDeviceId, kKeyRotatingDeviceIdMaxLength, "RI", TxtKeyUse::kCommission },
{ TxtFieldKey::kPairingInstruction, kKeyPairingInstructionMaxLength, "PI", TxtKeyUse::kCommission },
{ TxtFieldKey::kPairingHint, kKeyPairingHintMaxLength, "PH", TxtKeyUse::kCommission },
{ TxtFieldKey::kMrpRetryIntervalIdle, kKeyMrpRetryIntervalIdleMaxLength, "CRI", TxtKeyUse::kCommon },
{ TxtFieldKey::kMrpRetryIntervalActive, kKeyMrpRetryIntervalActiveMaxLength, "CRA", TxtKeyUse::kCommon },
{ TxtFieldKey::kSleepyIdleInterval, kKeySleepyIdleIntervalMaxLength, "SII", TxtKeyUse::kCommon },
{ TxtFieldKey::kSleepyActiveInterval, kKeySleepyActiveIntervalMaxLength, "SAI", TxtKeyUse::kCommon },
{ TxtFieldKey::kTcpSupported, kKeyTcpSupportedMaxLength, "T", TxtKeyUse::kCommon },
};
#ifdef CHIP_CONFIG_TEST
Expand Down
19 changes: 10 additions & 9 deletions src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ FullQName kCompressedIdSubName2 = FullQName(kCompressedIdSubPart
PtrResourceRecord ptrServiceSubCompressedId1 = PtrResourceRecord(kDnsSdQueryName, kCompressedIdSubName1);
PtrResourceRecord ptrServiceSubCompressedId2 = PtrResourceRecord(kDnsSdQueryName, kCompressedIdSubName2);

OperationalAdvertisingParameters operationalParams1 = OperationalAdvertisingParameters()
.SetPeerId(kPeerId1)
.SetMac(ByteSpan(kMac))
.SetPort(CHIP_PORT)
.EnableIpV4(true)
.SetTcpSupported(chip::Optional<bool>(false))
.SetMRPConfig(ReliableMessageProtocolConfig(32_ms32, 33_ms32));
OperationalAdvertisingParameters operationalParams1 =
OperationalAdvertisingParameters()
.SetPeerId(kPeerId1)
.SetMac(ByteSpan(kMac))
.SetPort(CHIP_PORT)
.EnableIpV4(true)
.SetTcpSupported(chip::Optional<bool>(false))
.SetMRPConfig(ReliableMessageProtocolConfig(32_ms32, 30_ms32)); // Match SII, SAI below
OperationalAdvertisingParameters operationalParams2 =
OperationalAdvertisingParameters().SetPeerId(kPeerId2).SetMac(ByteSpan(kMac)).SetPort(CHIP_PORT).EnableIpV4(true);
OperationalAdvertisingParameters operationalParams3 =
Expand All @@ -89,7 +90,7 @@ OperationalAdvertisingParameters operationalParams5 =
OperationalAdvertisingParameters().SetPeerId(kPeerId5).SetMac(ByteSpan(kMac)).SetPort(CHIP_PORT).EnableIpV4(true);
OperationalAdvertisingParameters operationalParams6 =
OperationalAdvertisingParameters().SetPeerId(kPeerId6).SetMac(ByteSpan(kMac)).SetPort(CHIP_PORT).EnableIpV4(true);
const QNamePart txtOperational1Parts[] = { "CRI=32", "CRA=33", "T=0" };
const QNamePart txtOperational1Parts[] = { "SII=32", "SAI=30", "T=0" };
PtrResourceRecord ptrOperationalService = PtrResourceRecord(kDnsSdQueryName, kMatterOperationalQueryName);
PtrResourceRecord ptrOperational1 = PtrResourceRecord(kMatterOperationalQueryName, kInstanceName1);
SrvResourceRecord srvOperational1 = SrvResourceRecord(kInstanceName1, kHostnameName, CHIP_PORT);
Expand Down Expand Up @@ -182,7 +183,7 @@ CommissionAdvertisingParameters commissionableNodeParamsLargeEnhanced =
.SetMRPConfig(ReliableMessageProtocolConfig(3600000_ms32, 3600005_ms32));
QNamePart txtCommissionableNodeParamsLargeEnhancedParts[] = { "D=22", "VP=555+897", "CM=2", "DT=70000",
"DN=testy-test", "RI=id_that_spins", "PI=Pair me", "PH=3",
"CRA=3600000", "CRI=3600000", "T=1" };
"SAI=3600000", "SII=3600000", "T=1" };
FullQName txtCommissionableNodeParamsLargeEnhancedName = FullQName(txtCommissionableNodeParamsLargeEnhancedParts);
TxtResourceRecord txtCommissionableNodeParamsLargeEnhanced =
TxtResourceRecord(instanceName, txtCommissionableNodeParamsLargeEnhancedName);
Expand Down
10 changes: 5 additions & 5 deletions src/lib/dnssd/platform/tests/TestPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ OperationalAdvertisingParameters operationalParams2 = OperationalAdvertisingPara
.SetMac(ByteSpan(kMac))
.SetPort(CHIP_PORT)
.EnableIpV4(true)
.SetMRPConfig({ 32_ms32, 33_ms32 })
.SetMRPConfig({ 32_ms32, 30_ms32 }) // SII and SAI to match below
.SetTcpSupported(Optional<bool>(true));
test::ExpectedCall operationalCall2 = test::ExpectedCall()
.SetProtocol(DnssdServiceProtocol::kDnssdProtocolTcp)
.SetServiceName("_matter")
.SetInstanceName("5555666677778888-1212343456567878")
.SetHostName(host)
.AddSubtype("_I5555666677778888")
.AddTxt("CRI", "32")
.AddTxt("CRA", "33")
.AddTxt("SII", "32")
.AddTxt("SAI", "30")
.AddTxt("T", "1");

CommissionAdvertisingParameters commissionableNodeParamsSmall =
Expand Down Expand Up @@ -110,8 +110,8 @@ test::ExpectedCall commissionableLargeBasic = test::ExpectedCall()
.AddTxt("PI", "Pair me")
.AddTxt("PH", "3")
.AddTxt("T", "1")
.AddTxt("CRI", "3600000")
.AddTxt("CRA", "3600000")
.AddTxt("SII", "3600000")
.AddTxt("SAI", "3600000")
.AddSubtype("_S2")
.AddSubtype("_L22")
.AddSubtype("_V555")
Expand Down
Loading

0 comments on commit 63576e3

Please sign in to comment.