Skip to content

Commit 33ffe7a

Browse files
Addressed comments by sharadb-amazon, added CP field to CastingStore
1 parent a62b7fe commit 33ffe7a

File tree

8 files changed

+26
-21
lines changed

8 files changed

+26
-21
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ private String getCastingPlayerButtonText(CastingPlayer player) {
353353
aux += (aux.isEmpty() ? "" : ", ") + "Resolved IP?: " + (player.getIpAddresses().size() > 0);
354354
aux +=
355355
(aux.isEmpty() ? "" : ", ")
356-
+ "Commissioner Passcode Supported?: "
357-
+ (player.isCommissionerPasscodeSupported());
356+
+ "Commissioner Passcode: "
357+
+ (player.getCommissionerPasscode());
358358

359359
aux = aux.isEmpty() ? aux : "\n" + aux;
360360
return main + aux;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface CastingPlayer {
4949

5050
long getDeviceType();
5151

52-
boolean isCommissionerPasscodeSupported();
52+
short getCommissionerPasscode();
5353

5454
List<Endpoint> getEndpoints();
5555

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class MatterCastingPlayer implements CastingPlayer {
4747
private int productId;
4848
private int vendorId;
4949
private long deviceType;
50-
private boolean commissionerPasscodeSupported;
50+
private short commissionerPasscode;
5151
protected long _cppCastingPlayer;
5252

5353
public MatterCastingPlayer(
@@ -61,7 +61,7 @@ public MatterCastingPlayer(
6161
int productId,
6262
int vendorId,
6363
long deviceType,
64-
boolean commissionerPasscodeSupported) {
64+
short commissionerPasscode) {
6565
this.connected = connected;
6666
this.deviceId = deviceId;
6767
this.hostName = hostName;
@@ -72,7 +72,7 @@ public MatterCastingPlayer(
7272
this.productId = productId;
7373
this.vendorId = vendorId;
7474
this.deviceType = deviceType;
75-
this.commissionerPasscodeSupported = commissionerPasscodeSupported;
75+
this.commissionerPasscode = commissionerPasscode;
7676
}
7777

7878
/**
@@ -135,8 +135,8 @@ public long getDeviceType() {
135135
}
136136

137137
@Override
138-
public boolean isCommissionerPasscodeSupported() {
139-
return this.commissionerPasscodeSupported;
138+
public short getCommissionerPasscode() {
139+
return this.commissionerPasscode;
140140
}
141141

142142
@Override

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

+6-7
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;IIIJZ)V");
130+
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJS)V");
131131
if (constructor == nullptr)
132132
{
133133
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava() could not locate MatterCastingPlayer Java class constructor");
@@ -158,12 +158,11 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
158158

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void CastingPlayer::LogDetail() const
282282
{
283283
ChipLogDetail(AppServer, "\tDevice Type: %" PRIu32, mAttributes.deviceType);
284284
}
285-
ChipLogDetail(AppServer, "\tCommissioner Passcode feature supported: %u", mAttributes.commissionerPasscode);
285+
ChipLogDetail(AppServer, "\tCommissioner Passcode: %u", mAttributes.commissionerPasscode);
286286
if (mAttributes.nodeId > 0)
287287
{
288288
ChipLogDetail(AppServer, "\tNode ID: 0x" ChipLogFormatX64, ChipLogValueX64(mAttributes.nodeId));

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

-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
114114
*/
115115
bool IsConnected() const { return mConnectionState == CASTING_PLAYER_CONNECTED; }
116116

117-
/**
118-
* @return true if this CastingPlayer supports the Commissioner-Generated Passcode feature.
119-
*/
120-
bool IsCommissionerPasscodeSupported() const { return mAttributes.commissionerPasscode != 0; }
121-
122117
/**
123118
* @brief Verifies that a connection exists with this CastingPlayer, or triggers a new session
124119
* request. If the CastingApp does not have the nodeId and fabricIndex of this CastingPlayer cached on disk,

examples/tv-casting-app/tv-casting-common/support/CastingStore.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ std::vector<core::CastingPlayer> CastingStore::ReadAll()
182182
continue;
183183
}
184184

185+
if (castingPlayerContainerTagNum == kCastingCommissionerPasscodeTag)
186+
{
187+
err = reader.Get(attributes.commissionerPasscode);
188+
VerifyOrReturnValue(err == CHIP_NO_ERROR, std::vector<core::CastingPlayer>(),
189+
ChipLogError(AppServer, "TLVReader.Get failed %" CHIP_ERROR_FORMAT, err.Format()));
190+
continue;
191+
}
192+
185193
if (castingPlayerContainerTagNum == kCastingPlayerPortTag)
186194
{
187195
err = reader.Get(attributes.port);
@@ -472,6 +480,8 @@ CHIP_ERROR CastingStore::WriteAll(std::vector<core::CastingPlayer> castingPlayer
472480
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerVendorIdTag), castingPlayer.GetVendorId()));
473481
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerProductIdTag), castingPlayer.GetProductId()));
474482
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerDeviceTypeIdTag), castingPlayer.GetDeviceType()));
483+
ReturnErrorOnFailure(
484+
tlvWriter.Put(chip::TLV::ContextTag(kCastingCommissionerPasscodeTag), castingPlayer.GetCommissionerPasscode()));
475485
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerPortTag), castingPlayer.GetPort()));
476486
ReturnErrorOnFailure(tlvWriter.PutBytes(chip::TLV::ContextTag(kCastingPlayerInstanceNameTag),
477487
(const uint8_t *) castingPlayer.GetInstanceName(),

examples/tv-casting-app/tv-casting-common/support/CastingStore.h

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class CastingStore : public chip::FabricTable::Delegate
8383
kCastingPlayerPortTag,
8484
kCastingPlayerInstanceNameTag,
8585
kCastingPlayerDeviceNameTag,
86+
kCastingCommissionerPasscodeTag,
8687
kCastingPlayerHostNameTag,
8788

8889
kCastingPlayerEndpointsContainerTag,

0 commit comments

Comments
 (0)