Skip to content

Commit

Permalink
Remove pair step before calling any cluster API (#30968)
Browse files Browse the repository at this point in the history
* Remove pair step before calling any cluster API

* Address review comments
  • Loading branch information
yufengwangca authored and pull[bot] committed Jun 27, 2024
1 parent 9123697 commit 1471086
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,13 @@ class PairOnNetworkLongImInvokeCommand(
DiscoveryFilterType.LONG_DISCRIMINATOR
) {
override fun runCommand() {
currentCommissioner()
.pairDevice(
getNodeId(),
getRemoteAddr().address.hostAddress,
MATTER_PORT,
getDiscriminator(),
getSetupPINCode(),
)
currentCommissioner().setCompletionListener(this)
waitCompleteMs(getTimeoutMillis())

runBlocking {
try {
val identifyTime: UShort = 1u
val identifyCluster = IdentifyCluster(controller = currentCommissioner(), endpointId = 0u)

// By running command identify, we are implicitly requesting CASE to be established if it's
// not already present.
identifyCluster.identify(identifyTime)
logger.log(Level.INFO, "Invoke command succeeded")
} catch (ex: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@ class PairOnNetworkLongImReadCommand(controller: MatterController, credsIssue: C
DiscoveryFilterType.LONG_DISCRIMINATOR
) {
override fun runCommand() {
currentCommissioner()
.pairDevice(
getNodeId(),
getRemoteAddr().address.hostAddress,
MATTER_PORT,
getDiscriminator(),
getSetupPINCode(),
)
currentCommissioner().setCompletionListener(this)
waitCompleteMs(getTimeoutMillis())

runBlocking {
try {
val basicInformationCluster =
BasicInformationCluster(controller = currentCommissioner(), endpointId = DEFAULT_ENDPOINT)
val vendorName = basicInformationCluster.readVendorNameAttribute()

// By running command readVendorIDAttribute, we are implicitly requesting CASE to be
// established if it's not already present.
val vendorId = basicInformationCluster.readVendorIDAttribute()
logger.log(Level.INFO, "Read command succeeded, Verdor Name:${vendorName} (ID:${vendorId})")
} catch (ex: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,13 @@ class PairOnNetworkLongImWriteCommand(
DiscoveryFilterType.LONG_DISCRIMINATOR
) {
override fun runCommand() {
currentCommissioner()
.pairDevice(
getNodeId(),
getRemoteAddr().address.hostAddress,
MATTER_PORT,
getDiscriminator(),
getSetupPINCode(),
)
currentCommissioner().setCompletionListener(this)
waitCompleteMs(getTimeoutMillis())

runBlocking {
try {
val basicInformationCluster =
BasicInformationCluster(controller = currentCommissioner(), endpointId = DEFAULT_ENDPOINT)

// By running command writeNodeLabelAttribute, we are implicitly requesting CASE to be
// established if it's not already present.
basicInformationCluster.writeNodeLabelAttribute("Test Node Label")
logger.log(Level.INFO, "Write command succeeded")

Expand Down

0 comments on commit 1471086

Please sign in to comment.