Skip to content

Commit a62b7fe

Browse files
v1.3 Commissioner Passcode field for Linux and Android tv-casting-apps
1 parent 90732b2 commit a62b7fe

File tree

8 files changed

+41
-14
lines changed

8 files changed

+41
-14
lines changed

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java

+4
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ private String getCastingPlayerButtonText(CastingPlayer player) {
351351
? (aux.isEmpty() ? "" : ", ") + "Device Type: " + player.getDeviceType()
352352
: "";
353353
aux += (aux.isEmpty() ? "" : ", ") + "Resolved IP?: " + (player.getIpAddresses().size() > 0);
354+
aux +=
355+
(aux.isEmpty() ? "" : ", ")
356+
+ "Commissioner Passcode Supported?: "
357+
+ (player.isCommissionerPasscodeSupported());
354358

355359
aux = aux.isEmpty() ? aux : "\n" + aux;
356360
return main + aux;

examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/CastingPlayer.java

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public interface CastingPlayer {
4949

5050
long getDeviceType();
5151

52+
boolean isCommissionerPasscodeSupported();
53+
5254
List<Endpoint> getEndpoints();
5355

5456
@Override

examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/core/MatterCastingPlayer.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class MatterCastingPlayer implements CastingPlayer {
4747
private int productId;
4848
private int vendorId;
4949
private long deviceType;
50+
private boolean commissionerPasscodeSupported;
5051
protected long _cppCastingPlayer;
5152

5253
public MatterCastingPlayer(
@@ -59,7 +60,8 @@ public MatterCastingPlayer(
5960
int port,
6061
int productId,
6162
int vendorId,
62-
long deviceType) {
63+
long deviceType,
64+
boolean commissionerPasscodeSupported) {
6365
this.connected = connected;
6466
this.deviceId = deviceId;
6567
this.hostName = hostName;
@@ -70,6 +72,7 @@ public MatterCastingPlayer(
7072
this.productId = productId;
7173
this.vendorId = vendorId;
7274
this.deviceType = deviceType;
75+
this.commissionerPasscodeSupported = commissionerPasscodeSupported;
7376
}
7477

7578
/**
@@ -131,6 +134,11 @@ public long getDeviceType() {
131134
return this.deviceType;
132135
}
133136

137+
@Override
138+
public boolean isCommissionerPasscodeSupported() {
139+
return this.commissionerPasscodeSupported;
140+
}
141+
134142
@Override
135143
public native List<Endpoint> getEndpoints();
136144

examples/tv-casting-app/android/App/app/src/main/jni/cpp/support/Converters-JNI.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
127127
// Get the constructor for the com/matter/casting/core/MatterCastingPlayer Java class
128128
jmethodID constructor =
129129
env->GetMethodID(matterCastingPlayerJavaClass, "<init>",
130-
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJ)V");
130+
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJZ)V");
131131
if (constructor == nullptr)
132132
{
133133
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava() could not locate MatterCastingPlayer Java class constructor");
@@ -158,11 +158,12 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
158158

159159
// Create a new instance of the MatterCastingPlayer Java class
160160
jobject jMatterCastingPlayer = nullptr;
161-
jMatterCastingPlayer = env->NewObject(matterCastingPlayerJavaClass, constructor, static_cast<jboolean>(player->IsConnected()),
162-
env->NewStringUTF(player->GetId()), env->NewStringUTF(player->GetHostName()),
163-
env->NewStringUTF(player->GetDeviceName()), env->NewStringUTF(player->GetInstanceName()),
164-
jIpAddressList, (jint) (player->GetPort()), (jint) (player->GetProductId()),
165-
(jint) (player->GetVendorId()), (jlong) (player->GetDeviceType()));
161+
jMatterCastingPlayer =
162+
env->NewObject(matterCastingPlayerJavaClass, constructor, static_cast<jboolean>(player->IsConnected()),
163+
env->NewStringUTF(player->GetId()), env->NewStringUTF(player->GetHostName()),
164+
env->NewStringUTF(player->GetDeviceName()), env->NewStringUTF(player->GetInstanceName()), jIpAddressList,
165+
(jint) (player->GetPort()), (jint) (player->GetProductId()), (jint) (player->GetVendorId()),
166+
(jlong) (player->GetDeviceType()), static_cast<jboolean>(player->IsCommissionerPasscodeSupported()));
166167
if (jMatterCastingPlayer == nullptr)
167168
{
168169
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava(): Could not create MatterCastingPlayer Java object");

examples/tv-casting-app/linux/simple-app-helper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ DiscoveryDelegateImpl * DiscoveryDelegateImpl::GetInstance()
4545

4646
void DiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong<matter::casting::core::CastingPlayer> player)
4747
{
48+
ChipLogProgress(AppServer, "DiscoveryDelegateImpl::HandleOnAdded() called");
4849
if (commissionersCount == 0)
4950
{
5051
ChipLogProgress(AppServer, "Select discovered Casting Player (start index = 0) to request commissioning");
@@ -58,7 +59,7 @@ void DiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong<matter
5859

5960
void DiscoveryDelegateImpl::HandleOnUpdated(matter::casting::memory::Strong<matter::casting::core::CastingPlayer> player)
6061
{
61-
ChipLogProgress(AppServer, "Updated CastingPlayer with ID: %s", player->GetId());
62+
ChipLogProgress(AppServer, "DiscoveryDelegateImpl::HandleOnUpdated() Updated CastingPlayer with ID: %s", player->GetId());
6263
}
6364

6465
void InvokeContentLauncherLaunchURL(matter::casting::memory::Strong<matter::casting::core::Endpoint> endpoint)

examples/tv-casting-app/tv-casting-common/core/CastingPlayer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ bool CastingPlayer::ContainsDesiredEndpoint(core::CastingPlayer * cachedCastingP
236236

237237
void CastingPlayer::LogDetail() const
238238
{
239+
ChipLogProgress(AppServer, "CastingPlayer::LogDetail() called");
239240
if (strlen(mAttributes.id) != 0)
240241
{
241242
ChipLogDetail(AppServer, "\tID: %s", mAttributes.id);
@@ -281,6 +282,7 @@ void CastingPlayer::LogDetail() const
281282
{
282283
ChipLogDetail(AppServer, "\tDevice Type: %" PRIu32, mAttributes.deviceType);
283284
}
285+
ChipLogDetail(AppServer, "\tCommissioner Passcode feature supported: %u", mAttributes.commissionerPasscode);
284286
if (mAttributes.nodeId > 0)
285287
{
286288
ChipLogDetail(AppServer, "\tNode ID: 0x" ChipLogFormatX64, ChipLogValueX64(mAttributes.nodeId));

examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ class CastingPlayerAttributes
5656
char deviceName[chip::Dnssd::kMaxDeviceNameLen + 1] = {};
5757
char hostName[chip::Dnssd::kHostNameMaxLength + 1] = {};
5858
char instanceName[chip::Dnssd::Commission::kInstanceNameMaxLength + 1] = {};
59-
unsigned int numIPs; // number of valid IP addresses
59+
unsigned int numIPs; // Number of valid IP addresses
6060
chip::Inet::IPAddress ipAddresses[chip::Dnssd::CommonResolutionData::kMaxIPAddresses];
6161
chip::Inet::InterfaceId interfaceId;
6262
uint16_t port;
6363
uint16_t productId;
6464
uint16_t vendorId;
6565
uint32_t deviceType;
66+
uint8_t commissionerPasscode = 0; // Indicates whether a CastingPlayer supports the Commissioner-Generated Passcode feature.
6667

6768
chip::NodeId nodeId = 0;
6869
chip::FabricIndex fabricIndex = 0;
@@ -113,6 +114,11 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
113114
*/
114115
bool IsConnected() const { return mConnectionState == CASTING_PLAYER_CONNECTED; }
115116

117+
/**
118+
* @return true if this CastingPlayer supports the Commissioner-Generated Passcode feature.
119+
*/
120+
bool IsCommissionerPasscodeSupported() const { return mAttributes.commissionerPasscode != 0; }
121+
116122
/**
117123
* @brief Verifies that a connection exists with this CastingPlayer, or triggers a new session
118124
* 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<CastingPlayer>
182188

183189
uint32_t GetDeviceType() const { return mAttributes.deviceType; }
184190

191+
uint8_t GetCommissionerPasscode() const { return mAttributes.commissionerPasscode; }
192+
185193
chip::NodeId GetNodeId() const { return mAttributes.nodeId; }
186194

187195
chip::FabricIndex GetFabricIndex() const { return mAttributes.fabricIndex; }

examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ void DeviceDiscoveryDelegateImpl::OnDiscoveredDevice(const chip::Dnssd::Discover
9393
{
9494
attributes.ipAddresses[j] = nodeData.resolutionData.ipAddress[j];
9595
}
96-
attributes.interfaceId = nodeData.resolutionData.interfaceId;
97-
attributes.port = nodeData.resolutionData.port;
98-
attributes.productId = nodeData.nodeData.productId;
99-
attributes.vendorId = nodeData.nodeData.vendorId;
100-
attributes.deviceType = nodeData.nodeData.deviceType;
96+
attributes.interfaceId = nodeData.resolutionData.interfaceId;
97+
attributes.port = nodeData.resolutionData.port;
98+
attributes.productId = nodeData.nodeData.productId;
99+
attributes.vendorId = nodeData.nodeData.vendorId;
100+
attributes.deviceType = nodeData.nodeData.deviceType;
101+
attributes.commissionerPasscode = nodeData.nodeData.commissionerPasscode;
101102

102103
memory::Strong<CastingPlayer> player = std::make_shared<CastingPlayer>(attributes);
103104

0 commit comments

Comments
 (0)