Skip to content

Commit

Permalink
Addressed comments by andy31415, part 2 member variable name change
Browse files Browse the repository at this point in the history
  • Loading branch information
pgregorr-amazon committed Apr 22, 2024
1 parent 1e6c5d0 commit 8863452
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface CastingPlayer {

long getDeviceType();

boolean isCommissionerPasscodeSupported();
boolean getSupportsCommissionerGeneratedPasscode();

List<Endpoint> getEndpoints();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -77,7 +73,7 @@ public MatterCastingPlayer(
this.productId = productId;
this.vendorId = vendorId;
this.deviceType = deviceType;
this.commissionerPasscode = commissionerPasscode;
this.supportsCommissionerGeneratedPasscode = supportsCommissionerGeneratedPasscode;
}

/**
Expand Down Expand Up @@ -140,8 +136,8 @@ public long getDeviceType() {
}

@Override
public boolean isCommissionerPasscodeSupported() {
return this.commissionerPasscode;
public boolean getSupportsCommissionerGeneratedPasscode() {
return this.supportsCommissionerGeneratedPasscode;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ jobject convertCastingPlayerFromCppToJava(matter::casting::memory::Strong<core::

// Create a new instance of the MatterCastingPlayer Java class
jobject jMatterCastingPlayer = nullptr;
jMatterCastingPlayer =
env->NewObject(matterCastingPlayerJavaClass, constructor, static_cast<jboolean>(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<jboolean>(player->isCommissionerPasscodeSupported()));
jMatterCastingPlayer = env->NewObject(matterCastingPlayerJavaClass, constructor, static_cast<jboolean>(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<jboolean>(player->GetSupportsCommissionerGeneratedPasscode()));
if (jMatterCastingPlayer == nullptr)
{
ChipLogError(AppServer, "convertCastingPlayerFromCppToJava(): Could not create MatterCastingPlayer Java object");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,7 +183,7 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>

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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CastingPlayer> player = std::make_shared<CastingPlayer>(attributes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ std::vector<core::CastingPlayer> 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<core::CastingPlayer>(),
ChipLogError(AppServer, "TLVReader.Get failed %" CHIP_ERROR_FORMAT, err.Format()));
continue;
Expand Down Expand Up @@ -480,8 +480,8 @@ CHIP_ERROR CastingStore::WriteAll(std::vector<core::CastingPlayer> 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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class CastingStore : public chip::FabricTable::Delegate
kCastingPlayerEndpointServerListContainerTag,
kCastingPlayerEndpointServerClusterIdTag,

kCastingPlayerCommissionerPasscodeTag,
kCastingPlayerSupportsCommissionerGeneratedPasscodeTag,

kContextTagMaxNum = UINT8_MAX
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dnssd/TxtFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/lib/dnssd/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {};
Expand Down Expand Up @@ -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");
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/lib/dnssd/tests/TestTxtFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8863452

Please sign in to comment.