From 8863452046f5bb0e0c498b74a7e9aa13d0f56a10 Mon Sep 17 00:00:00 2001 From: Philip Gregor Date: Mon, 22 Apr 2024 11:37:22 -0700 Subject: [PATCH] Addressed comments by andy31415, part 2 member variable name change --- .../matter/casting/DiscoveryExampleFragment.java | 4 ++-- .../jni/com/matter/casting/core/CastingPlayer.java | 2 +- .../matter/casting/core/MatterCastingPlayer.java | 14 +++++--------- .../src/main/jni/cpp/support/Converters-JNI.cpp | 12 ++++++------ .../tv-casting-common/core/CastingPlayer.cpp | 3 ++- .../tv-casting-common/core/CastingPlayer.h | 7 ++----- .../core/CastingPlayerDiscovery.cpp | 12 ++++++------ .../tv-casting-common/support/CastingStore.cpp | 8 ++++---- .../tv-casting-common/support/CastingStore.h | 2 +- src/lib/dnssd/TxtFields.cpp | 2 +- src/lib/dnssd/Types.h | 5 +++-- src/lib/dnssd/tests/TestTxtFields.cpp | 8 ++++---- 12 files changed, 37 insertions(+), 42 deletions(-) diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java index 6fe5c997b35aca..a706780c5be3b4 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java @@ -352,8 +352,8 @@ private String getCastingPlayerButtonText(CastingPlayer player) { aux += (aux.isEmpty() ? "" : ", ") + "Resolved IP?: " + (player.getIpAddresses().size() > 0); aux += (aux.isEmpty() ? "" : ", ") - + "CommissionerPasscode: " - + (player.isCommissionerPasscodeSupported()); + + "Supports Commissioner Generated Passcode: " + + (player.getSupportsCommissionerGeneratedPasscode()); aux = aux.isEmpty() ? aux : "\n" + aux; return main + aux; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/CastingPlayer.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/CastingPlayer.java index 1681a5bfaee3f5..3c3a74032bd313 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/CastingPlayer.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/CastingPlayer.java @@ -49,7 +49,7 @@ public interface CastingPlayer { long getDeviceType(); - boolean isCommissionerPasscodeSupported(); + boolean getSupportsCommissionerGeneratedPasscode(); List getEndpoints(); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/MatterCastingPlayer.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/MatterCastingPlayer.java index efbf971d1c7964..a4f03a00e4f5a2 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/MatterCastingPlayer.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/MatterCastingPlayer.java @@ -47,11 +47,7 @@ public class MatterCastingPlayer implements CastingPlayer { private int productId; private int vendorId; private long deviceType; - /** - * The CommissionerPasscode field indicates whether a CastingPlayer supports the - * Commissioner-Generated Passcode feature. - */ - private boolean commissionerPasscode; + private boolean supportsCommissionerGeneratedPasscode; protected long _cppCastingPlayer; @@ -66,7 +62,7 @@ public MatterCastingPlayer( int productId, int vendorId, long deviceType, - boolean commissionerPasscode) { + boolean supportsCommissionerGeneratedPasscode) { this.connected = connected; this.deviceId = deviceId; this.hostName = hostName; @@ -77,7 +73,7 @@ public MatterCastingPlayer( this.productId = productId; this.vendorId = vendorId; this.deviceType = deviceType; - this.commissionerPasscode = commissionerPasscode; + this.supportsCommissionerGeneratedPasscode = supportsCommissionerGeneratedPasscode; } /** @@ -140,8 +136,8 @@ public long getDeviceType() { } @Override - public boolean isCommissionerPasscodeSupported() { - return this.commissionerPasscode; + public boolean getSupportsCommissionerGeneratedPasscode() { + return this.supportsCommissionerGeneratedPasscode; } @Override diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/Converters-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/Converters-JNI.cpp index e3e747879d059b..00ca47216ae804 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/Converters-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/Converters-JNI.cpp @@ -182,12 +182,12 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::StrongNewObject(matterCastingPlayerJavaClass, constructor, static_cast(player->IsConnected()), - env->NewStringUTF(player->GetId()), env->NewStringUTF(player->GetHostName()), - env->NewStringUTF(player->GetDeviceName()), env->NewStringUTF(player->GetInstanceName()), jIpAddressList, - (jint) (player->GetPort()), (jint) (player->GetProductId()), (jint) (player->GetVendorId()), - (jlong) (player->GetDeviceType()), static_cast(player->isCommissionerPasscodeSupported())); + jMatterCastingPlayer = env->NewObject(matterCastingPlayerJavaClass, constructor, static_cast(player->IsConnected()), + env->NewStringUTF(player->GetId()), env->NewStringUTF(player->GetHostName()), + env->NewStringUTF(player->GetDeviceName()), env->NewStringUTF(player->GetInstanceName()), + jIpAddressList, (jint) (player->GetPort()), (jint) (player->GetProductId()), + (jint) (player->GetVendorId()), (jlong) (player->GetDeviceType()), + static_cast(player->GetSupportsCommissionerGeneratedPasscode())); if (jMatterCastingPlayer == nullptr) { ChipLogError(AppServer, "convertCastingPlayerFromCppToJava(): Could not create MatterCastingPlayer Java object"); diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp index 2a5f261817f1f3..c9f938dbc695c7 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp @@ -282,7 +282,8 @@ void CastingPlayer::LogDetail() const { ChipLogDetail(AppServer, "\tDevice Type: %" PRIu32, mAttributes.deviceType); } - ChipLogDetail(AppServer, "\tCommissionerPasscode: %s", mAttributes.commissionerPasscode ? "true" : "false"); + ChipLogDetail(AppServer, "\tSupports Commissioner Generated Passcode: %s", + mAttributes.supportsCommissionerGeneratedPasscode ? "true" : "false"); if (mAttributes.nodeId > 0) { ChipLogDetail(AppServer, "\tNode ID: 0x" ChipLogFormatX64, ChipLogValueX64(mAttributes.nodeId)); diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h index 9d101c1a94f6d7..783d50f60af390 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h @@ -63,10 +63,7 @@ class CastingPlayerAttributes uint16_t productId; uint16_t vendorId; uint32_t deviceType; - /** - * The CommissionerPasscode field indicates whether a CastingPlayer supports the Commissioner-Generated Passcode feature. - */ - bool commissionerPasscode; + bool supportsCommissionerGeneratedPasscode; chip::NodeId nodeId = 0; chip::FabricIndex fabricIndex = 0; @@ -186,7 +183,7 @@ class CastingPlayer : public std::enable_shared_from_this uint32_t GetDeviceType() const { return mAttributes.deviceType; } - bool isCommissionerPasscodeSupported() const { return mAttributes.commissionerPasscode; } + bool GetSupportsCommissionerGeneratedPasscode() const { return mAttributes.supportsCommissionerGeneratedPasscode; } chip::NodeId GetNodeId() const { return mAttributes.nodeId; } diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp index f92fc1ac3e5062..9dd365d8db559f 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp @@ -93,12 +93,12 @@ void DeviceDiscoveryDelegateImpl::OnDiscoveredDevice(const chip::Dnssd::Discover { attributes.ipAddresses[j] = nodeData.resolutionData.ipAddress[j]; } - attributes.interfaceId = nodeData.resolutionData.interfaceId; - attributes.port = nodeData.resolutionData.port; - attributes.productId = nodeData.nodeData.productId; - attributes.vendorId = nodeData.nodeData.vendorId; - attributes.deviceType = nodeData.nodeData.deviceType; - attributes.commissionerPasscode = nodeData.nodeData.commissionerPasscode; + attributes.interfaceId = nodeData.resolutionData.interfaceId; + attributes.port = nodeData.resolutionData.port; + attributes.productId = nodeData.nodeData.productId; + attributes.vendorId = nodeData.nodeData.vendorId; + attributes.deviceType = nodeData.nodeData.deviceType; + attributes.supportsCommissionerGeneratedPasscode = nodeData.nodeData.supportsCommissionerGeneratedPasscode; memory::Strong player = std::make_shared(attributes); diff --git a/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp b/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp index 641c8d0b70b899..819c0299945ed4 100644 --- a/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp +++ b/examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp @@ -182,9 +182,9 @@ std::vector CastingStore::ReadAll() continue; } - if (castingPlayerContainerTagNum == kCastingPlayerCommissionerPasscodeTag) + if (castingPlayerContainerTagNum == kCastingPlayerSupportsCommissionerGeneratedPasscodeTag) { - err = reader.Get(attributes.commissionerPasscode); + err = reader.Get(attributes.supportsCommissionerGeneratedPasscode); VerifyOrReturnValue(err == CHIP_NO_ERROR, std::vector(), ChipLogError(AppServer, "TLVReader.Get failed %" CHIP_ERROR_FORMAT, err.Format())); continue; @@ -480,8 +480,8 @@ CHIP_ERROR CastingStore::WriteAll(std::vector castingPlayer ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerVendorIdTag), castingPlayer.GetVendorId())); ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerProductIdTag), castingPlayer.GetProductId())); ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerDeviceTypeIdTag), castingPlayer.GetDeviceType())); - ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerCommissionerPasscodeTag), - castingPlayer.isCommissionerPasscodeSupported())); + ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerSupportsCommissionerGeneratedPasscodeTag), + castingPlayer.GetSupportsCommissionerGeneratedPasscode())); ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerPortTag), castingPlayer.GetPort())); ReturnErrorOnFailure(tlvWriter.PutBytes(chip::TLV::ContextTag(kCastingPlayerInstanceNameTag), (const uint8_t *) castingPlayer.GetInstanceName(), diff --git a/examples/tv-casting-app/tv-casting-common/support/CastingStore.h b/examples/tv-casting-app/tv-casting-common/support/CastingStore.h index ae9ebf59e41368..c60fa128079122 100644 --- a/examples/tv-casting-app/tv-casting-common/support/CastingStore.h +++ b/examples/tv-casting-app/tv-casting-common/support/CastingStore.h @@ -97,7 +97,7 @@ class CastingStore : public chip::FabricTable::Delegate kCastingPlayerEndpointServerListContainerTag, kCastingPlayerEndpointServerClusterIdTag, - kCastingPlayerCommissionerPasscodeTag, + kCastingPlayerSupportsCommissionerGeneratedPasscodeTag, kContextTagMaxNum = UINT8_MAX }; diff --git a/src/lib/dnssd/TxtFields.cpp b/src/lib/dnssd/TxtFields.cpp index 28a39b9e31b0ed..c4ec70e342d41a 100644 --- a/src/lib/dnssd/TxtFields.cpp +++ b/src/lib/dnssd/TxtFields.cpp @@ -256,7 +256,7 @@ void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & val, DnssdNodeDa nodeData.pairingHint = Internal::GetPairingHint(val); break; case TxtFieldKey::kCommissionerPasscode: - nodeData.commissionerPasscode = Internal::GetCommissionerPasscode(val); + nodeData.supportsCommissionerGeneratedPasscode = Internal::GetCommissionerPasscode(val); break; default: break; diff --git a/src/lib/dnssd/Types.h b/src/lib/dnssd/Types.h index 0f38683f39c53f..43e55bfbc65e0e 100644 --- a/src/lib/dnssd/Types.h +++ b/src/lib/dnssd/Types.h @@ -214,7 +214,7 @@ struct DnssdNodeData uint16_t productId = 0; uint16_t pairingHint = 0; uint8_t commissioningMode = 0; - bool commissionerPasscode = false; + bool supportsCommissionerGeneratedPasscode = false; uint8_t rotatingId[kMaxRotatingIdLen] = {}; char instanceName[Commission::kInstanceNameMaxLength + 1] = {}; char deviceName[kMaxDeviceNameLen + 1] = {}; @@ -272,7 +272,8 @@ struct DnssdNodeData ChipLogDetail(Discovery, "\tInstance Name: %s", instanceName); } ChipLogDetail(Discovery, "\tCommissioning Mode: %u", commissioningMode); - ChipLogDetail(Discovery, "\tCommissionerPasscode: %s", commissionerPasscode ? "true" : "false"); + ChipLogDetail(Discovery, "\tSupports Commissioner Generated Passcode: %s", + supportsCommissionerGeneratedPasscode ? "true" : "false"); } }; diff --git a/src/lib/dnssd/tests/TestTxtFields.cpp b/src/lib/dnssd/tests/TestTxtFields.cpp index d8b91db28e967e..d6e7e6ea240670 100644 --- a/src/lib/dnssd/tests/TestTxtFields.cpp +++ b/src/lib/dnssd/tests/TestTxtFields.cpp @@ -309,7 +309,7 @@ bool NodeDataIsEmpty(const DiscoveredNodeData & node) node.nodeData.pairingHint != 0 || node.resolutionData.mrpRetryIntervalIdle.HasValue() || node.resolutionData.mrpRetryIntervalActive.HasValue() || node.resolutionData.mrpRetryActiveThreshold.HasValue() || node.resolutionData.isICDOperatingAsLIT.HasValue() || node.resolutionData.supportsTcp || - node.nodeData.commissionerPasscode != 0) + node.nodeData.supportsCommissionerGeneratedPasscode != 0) { return false; } @@ -360,12 +360,12 @@ void TestFillDiscoveredNodeDataFromTxt(nlTestSuite * inSuite, void * inContext) filled.nodeData.commissioningMode = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); - // CommissionerPasscode + // Supports Commissioner Generated Passcode strcpy(key, "CP"); strcpy(val, "1"); FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); - NL_TEST_ASSERT(inSuite, filled.nodeData.commissionerPasscode == true); - filled.nodeData.commissionerPasscode = false; + NL_TEST_ASSERT(inSuite, filled.nodeData.supportsCommissionerGeneratedPasscode == true); + filled.nodeData.supportsCommissionerGeneratedPasscode = false; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Device type