Skip to content

Commit cad954c

Browse files
committedApr 19, 2024
Addressed comments by andy31415, CommissionerPasscode change from uint8_t to bool
1 parent 358046b commit cad954c

File tree

10 files changed

+31
-24
lines changed

10 files changed

+31
-24
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
@@ -352,8 +352,8 @@ private String getCastingPlayerButtonText(CastingPlayer player) {
352352
aux += (aux.isEmpty() ? "" : ", ") + "Resolved IP?: " + (player.getIpAddresses().size() > 0);
353353
aux +=
354354
(aux.isEmpty() ? "" : ", ")
355-
+ "Commissioner Passcode: "
356-
+ (player.getCommissionerPasscode());
355+
+ "CommissionerPasscode: "
356+
+ (player.isCommissionerPasscodeSupported());
357357

358358
aux = aux.isEmpty() ? aux : "\n" + aux;
359359
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-
short getCommissionerPasscode();
52+
boolean isCommissionerPasscodeSupported();
5353

5454
List<Endpoint> getEndpoints();
5555

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public class MatterCastingPlayer implements CastingPlayer {
4747
private int productId;
4848
private int vendorId;
4949
private long deviceType;
50-
private short commissionerPasscode;
50+
/**
51+
* The CommissionerPasscode field indicates whether a CastingPlayer supports the
52+
* Commissioner-Generated Passcode feature.
53+
*/
54+
private boolean commissionerPasscode;
55+
5156
protected long _cppCastingPlayer;
5257

5358
public MatterCastingPlayer(
@@ -61,7 +66,7 @@ public MatterCastingPlayer(
6166
int productId,
6267
int vendorId,
6368
long deviceType,
64-
short commissionerPasscode) {
69+
boolean commissionerPasscode) {
6570
this.connected = connected;
6671
this.deviceId = deviceId;
6772
this.hostName = hostName;
@@ -135,7 +140,7 @@ public long getDeviceType() {
135140
}
136141

137142
@Override
138-
public short getCommissionerPasscode() {
143+
public boolean isCommissionerPasscodeSupported() {
139144
return this.commissionerPasscode;
140145
}
141146

‎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
@@ -151,7 +151,7 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
151151
// Get the constructor for the com/matter/casting/core/MatterCastingPlayer Java class
152152
jmethodID constructor =
153153
env->GetMethodID(matterCastingPlayerJavaClass, "<init>",
154-
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJS)V");
154+
"(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IIIJZ)V");
155155
if (constructor == nullptr)
156156
{
157157
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava() could not locate MatterCastingPlayer Java class constructor");
@@ -182,11 +182,12 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::
182182

183183
// Create a new instance of the MatterCastingPlayer Java class
184184
jobject jMatterCastingPlayer = nullptr;
185-
jMatterCastingPlayer = env->NewObject(
186-
matterCastingPlayerJavaClass, constructor, static_cast<jboolean>(player->IsConnected()), env->NewStringUTF(player->GetId()),
187-
env->NewStringUTF(player->GetHostName()), env->NewStringUTF(player->GetDeviceName()),
188-
env->NewStringUTF(player->GetInstanceName()), jIpAddressList, (jint) (player->GetPort()), (jint) (player->GetProductId()),
189-
(jint) (player->GetVendorId()), (jlong) (player->GetDeviceType()), static_cast<jbyte>(player->GetCommissionerPasscode()));
185+
jMatterCastingPlayer =
186+
env->NewObject(matterCastingPlayerJavaClass, constructor, static_cast<jboolean>(player->IsConnected()),
187+
env->NewStringUTF(player->GetId()), env->NewStringUTF(player->GetHostName()),
188+
env->NewStringUTF(player->GetDeviceName()), env->NewStringUTF(player->GetInstanceName()), jIpAddressList,
189+
(jint) (player->GetPort()), (jint) (player->GetProductId()), (jint) (player->GetVendorId()),
190+
(jlong) (player->GetDeviceType()), static_cast<jboolean>(player->isCommissionerPasscodeSupported()));
190191
if (jMatterCastingPlayer == nullptr)
191192
{
192193
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: %u", mAttributes.commissionerPasscode);
285+
ChipLogDetail(AppServer, "\tCommissionerPasscode: %s", mAttributes.commissionerPasscode ? "true" : "false");
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-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ class CastingPlayerAttributes
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.
66+
/**
67+
* The CommissionerPasscode field indicates whether a CastingPlayer supports the Commissioner-Generated Passcode feature.
68+
*/
69+
bool commissionerPasscode;
6770

6871
chip::NodeId nodeId = 0;
6972
chip::FabricIndex fabricIndex = 0;
@@ -183,7 +186,7 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
183186

184187
uint32_t GetDeviceType() const { return mAttributes.deviceType; }
185188

186-
uint8_t GetCommissionerPasscode() const { return mAttributes.commissionerPasscode; }
189+
bool isCommissionerPasscodeSupported() const { return mAttributes.commissionerPasscode; }
187190

188191
chip::NodeId GetNodeId() const { return mAttributes.nodeId; }
189192

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ CHIP_ERROR CastingStore::WriteAll(std::vector<core::CastingPlayer> castingPlayer
480480
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerVendorIdTag), castingPlayer.GetVendorId()));
481481
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerProductIdTag), castingPlayer.GetProductId()));
482482
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerDeviceTypeIdTag), castingPlayer.GetDeviceType()));
483-
ReturnErrorOnFailure(
484-
tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerCommissionerPasscodeTag), castingPlayer.GetCommissionerPasscode()));
483+
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerCommissionerPasscodeTag),
484+
castingPlayer.isCommissionerPasscodeSupported()));
485485
ReturnErrorOnFailure(tlvWriter.Put(chip::TLV::ContextTag(kCastingPlayerPortTag), castingPlayer.GetPort()));
486486
ReturnErrorOnFailure(tlvWriter.PutBytes(chip::TLV::ContextTag(kCastingPlayerInstanceNameTag),
487487
(const uint8_t *) castingPlayer.GetInstanceName(),

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

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

8988
kCastingPlayerEndpointsContainerTag,
@@ -98,6 +97,8 @@ class CastingStore : public chip::FabricTable::Delegate
9897
kCastingPlayerEndpointServerListContainerTag,
9998
kCastingPlayerEndpointServerClusterIdTag,
10099

100+
kCastingPlayerCommissionerPasscodeTag,
101+
101102
kContextTagMaxNum = UINT8_MAX
102103
};
103104

‎src/lib/dnssd/TxtFields.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void GetPairingInstruction(const ByteSpan & value, char * pairingInstruction)
185185

186186
uint8_t GetCommissionerPasscode(const ByteSpan & value)
187187
{
188-
return MakeU8FromAsciiDecimal(value);
188+
return MakeBoolFromAsciiDecimal(value);
189189
}
190190

191191
Optional<System::Clock::Milliseconds32> GetRetryInterval(const ByteSpan & value)

‎src/lib/dnssd/Types.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ struct DnssdNodeData
214214
uint16_t productId = 0;
215215
uint16_t pairingHint = 0;
216216
uint8_t commissioningMode = 0;
217-
uint8_t commissionerPasscode = 0;
217+
bool commissionerPasscode = 0;
218218
uint8_t rotatingId[kMaxRotatingIdLen] = {};
219219
char instanceName[Commission::kInstanceNameMaxLength + 1] = {};
220220
char deviceName[kMaxDeviceNameLen + 1] = {};
@@ -272,10 +272,7 @@ struct DnssdNodeData
272272
ChipLogDetail(Discovery, "\tInstance Name: %s", instanceName);
273273
}
274274
ChipLogDetail(Discovery, "\tCommissioning Mode: %u", commissioningMode);
275-
if (commissionerPasscode > 0)
276-
{
277-
ChipLogDetail(Discovery, "\tCommissioner Passcode: %u", commissionerPasscode);
278-
}
275+
ChipLogDetail(Discovery, "\tCommissionerPasscode: %s", commissionerPasscode ? "true" : "false");
279276
}
280277
};
281278

0 commit comments

Comments
 (0)