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 46401af8909cd2..3903dcecfac7c3 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 @@ -351,6 +351,10 @@ private String getCastingPlayerButtonText(CastingPlayer player) { ? (aux.isEmpty() ? "" : ", ") + "Device Type: " + player.getDeviceType() : ""; aux += (aux.isEmpty() ? "" : ", ") + "Resolved IP?: " + (player.getIpAddresses().size() > 0); + aux += + (aux.isEmpty() ? "" : ", ") + + "Commissioner Passcode Supported?: " + + (player.isCommissionerPasscodeSupported()); 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 39db6488fa8ed8..1681a5bfaee3f5 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,6 +49,8 @@ public interface CastingPlayer { long getDeviceType(); + boolean isCommissionerPasscodeSupported(); + List getEndpoints(); @Override 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 dd4bd0ba6531c6..899da687c788ec 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,6 +47,7 @@ public class MatterCastingPlayer implements CastingPlayer { private int productId; private int vendorId; private long deviceType; + private boolean commissionerPasscodeSupported; protected long _cppCastingPlayer; public MatterCastingPlayer( @@ -59,7 +60,8 @@ public MatterCastingPlayer( int port, int productId, int vendorId, - long deviceType) { + long deviceType, + boolean commissionerPasscodeSupported) { this.connected = connected; this.deviceId = deviceId; this.hostName = hostName; @@ -70,6 +72,7 @@ public MatterCastingPlayer( this.productId = productId; this.vendorId = vendorId; this.deviceType = deviceType; + this.commissionerPasscodeSupported = commissionerPasscodeSupported; } /** @@ -131,6 +134,11 @@ public long getDeviceType() { return this.deviceType; } + @Override + public boolean isCommissionerPasscodeSupported() { + return this.commissionerPasscodeSupported; + } + @Override public native List getEndpoints(); 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 9798f2b48b9359..22876a5f578111 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 @@ -127,7 +127,7 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::StrongGetMethodID(matterCastingPlayerJavaClass, "", - "(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJ)V"); + "(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJZ)V"); if (constructor == nullptr) { ChipLogError(AppServer, "convertCastingPlayerFromCppToJava() could not locate MatterCastingPlayer Java class constructor"); @@ -158,11 +158,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())); + 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->IsCommissionerPasscodeSupported())); if (jMatterCastingPlayer == nullptr) { ChipLogError(AppServer, "convertCastingPlayerFromCppToJava(): Could not create MatterCastingPlayer Java object"); diff --git a/examples/tv-casting-app/linux/simple-app-helper.cpp b/examples/tv-casting-app/linux/simple-app-helper.cpp index f0e7c2068883ea..1571fbe8ef5d2c 100644 --- a/examples/tv-casting-app/linux/simple-app-helper.cpp +++ b/examples/tv-casting-app/linux/simple-app-helper.cpp @@ -45,6 +45,7 @@ DiscoveryDelegateImpl * DiscoveryDelegateImpl::GetInstance() void DiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong player) { + ChipLogProgress(AppServer, "DiscoveryDelegateImpl::HandleOnAdded() called"); if (commissionersCount == 0) { ChipLogProgress(AppServer, "Select discovered Casting Player (start index = 0) to request commissioning"); @@ -58,7 +59,7 @@ void DiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong player) { - ChipLogProgress(AppServer, "Updated CastingPlayer with ID: %s", player->GetId()); + ChipLogProgress(AppServer, "DiscoveryDelegateImpl::HandleOnUpdated() Updated CastingPlayer with ID: %s", player->GetId()); } void InvokeContentLauncherLaunchURL(matter::casting::memory::Strong endpoint) 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 fe966722ccf902..c42662314b4d14 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp @@ -236,6 +236,7 @@ bool CastingPlayer::ContainsDesiredEndpoint(core::CastingPlayer * cachedCastingP void CastingPlayer::LogDetail() const { + ChipLogProgress(AppServer, "CastingPlayer::LogDetail() called"); if (strlen(mAttributes.id) != 0) { ChipLogDetail(AppServer, "\tID: %s", mAttributes.id); @@ -281,6 +282,7 @@ void CastingPlayer::LogDetail() const { ChipLogDetail(AppServer, "\tDevice Type: %" PRIu32, mAttributes.deviceType); } + ChipLogDetail(AppServer, "\tCommissioner Passcode feature supported: %u", mAttributes.commissionerPasscode); 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 7d383bb6669225..776d7ffee7174d 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h @@ -56,13 +56,14 @@ class CastingPlayerAttributes char deviceName[chip::Dnssd::kMaxDeviceNameLen + 1] = {}; char hostName[chip::Dnssd::kHostNameMaxLength + 1] = {}; char instanceName[chip::Dnssd::Commission::kInstanceNameMaxLength + 1] = {}; - unsigned int numIPs; // number of valid IP addresses + unsigned int numIPs; // Number of valid IP addresses chip::Inet::IPAddress ipAddresses[chip::Dnssd::CommonResolutionData::kMaxIPAddresses]; chip::Inet::InterfaceId interfaceId; uint16_t port; uint16_t productId; uint16_t vendorId; uint32_t deviceType; + uint8_t commissionerPasscode = 0; // Indicates whether a CastingPlayer supports the Commissioner-Generated Passcode feature. chip::NodeId nodeId = 0; chip::FabricIndex fabricIndex = 0; @@ -113,6 +114,11 @@ class CastingPlayer : public std::enable_shared_from_this */ bool IsConnected() const { return mConnectionState == CASTING_PLAYER_CONNECTED; } + /** + * @return true if this CastingPlayer supports the Commissioner-Generated Passcode feature. + */ + bool IsCommissionerPasscodeSupported() const { return mAttributes.commissionerPasscode != 0; } + /** * @brief Verifies that a connection exists with this CastingPlayer, or triggers a new session * request. If the CastingApp does not have the nodeId and fabricIndex of this CastingPlayer cached on disk, @@ -182,6 +188,8 @@ class CastingPlayer : public std::enable_shared_from_this uint32_t GetDeviceType() const { return mAttributes.deviceType; } + uint8_t GetCommissionerPasscode() const { return mAttributes.commissionerPasscode; } + chip::NodeId GetNodeId() const { return mAttributes.nodeId; } chip::FabricIndex GetFabricIndex() const { return mAttributes.fabricIndex; } 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 9b26a868efd8c1..f92fc1ac3e5062 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp @@ -93,11 +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.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; memory::Strong player = std::make_shared(attributes);