Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Mar 7, 2023
1 parent 5496cab commit f34fce7
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ public final void addArgument(
addArgumentToList(arg, optional);
}

/**
* @brief Add a long Integer command argument
* @param name The name that will be displayed in the command help
* @param min The minimum value of the argv value
* @param max The minimum value of the argv value
* @param out A pointer to a MutableInteger where the argv value will be stored
* @param desc The description of the argument that will be displayed in the command help
* @param optional Indicate if an optional argument
* @return The number of arguments currently added to the command
*/
public final void addArgument(
String name, short min, short max, AtomicLong out, @Nullable String desc, boolean optional) {
Argument arg = new Argument(name, min, max, out, desc, optional);
addArgumentToList(arg, optional);
}

/**
* @brief Add a long Integer command argument
* @param name The name that will be displayed in the command help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@
package com.matter.controller.commands.pairing

enum class DiscoveryFilterType {
NONE, SHORT_DISCRIMINATOR, LONG_DISCRIMINATOR, VENDOR_ID, DEVICE_TYPE, COMMISSIONING_MODE, INSTANCE_NAME, COMMISSIONER, COMPRESSED_FABRIC_ID
NONE,
SHORT_DISCRIMINATOR,
LONG_DISCRIMINATOR,
VENDOR_ID,
DEVICE_TYPE,
COMMISSIONING_MODE,
INSTANCE_NAME,
COMMISSIONER,
COMPRESSED_FABRIC_ID
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ import java.util.logging.Logger
class PairAddressPaseCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand(
controller,
"address-paseonly",
credsIssue,
PairingModeType.ADDRESS_PASE_ONLY,
PairingNetworkType.NONE,
credsIssue
PairingNetworkType.NONE
) {
private val logger = Logger.getLogger(PairAddressPaseCommand::class.java.name)

override fun onPairingComplete(errorCode: Int) {
logger.log(Level.INFO, "onPairingComplete with error code: $errorCode")
if (errorCode == 0) {
Expand All @@ -51,4 +49,8 @@ class PairAddressPaseCommand(controller: ChipDeviceController, credsIssue: Crede
currentCommissioner().setCompletionListener(this)
waitCompleteMs(getTimeoutMillis())
}

companion object {
private val logger = Logger.getLogger(PairAddressPaseCommand::class.java.name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class PairAlreadyDiscoveredCommand(
) : PairingCommand(
controller,
"already-discovered",
credsIssue,
PairingModeType.ALREADY_DISCOVERED,
PairingNetworkType.NONE,
credsIssue
PairingNetworkType.NONE
) {
override fun runCommand() {
currentCommissioner()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import chip.devicecontroller.ChipDeviceController
import com.matter.controller.commands.common.CredentialsIssuer

class PairCodeCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) :
PairingCommand(controller, "code", PairingModeType.CODE, PairingNetworkType.NONE, credsIssue) {
PairingCommand(controller, "code", credsIssue, PairingModeType.CODE, PairingNetworkType.NONE) {
override fun runCommand() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import com.matter.controller.commands.common.CredentialsIssuer
class PairCodePaseCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand(
controller,
"code-paseonly",
credsIssue,
PairingModeType.CODE_PASE_ONLY,
PairingNetworkType.NONE,
credsIssue
PairingNetworkType.NONE
) {
override fun runCommand() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import chip.devicecontroller.ChipDeviceController
import com.matter.controller.commands.common.CredentialsIssuer

class PairCodeThreadCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) :
PairingCommand(controller, "code-thread", PairingModeType.CODE, PairingNetworkType.THREAD, credsIssue) {
PairingCommand(controller, "code-thread", credsIssue, PairingModeType.CODE, PairingNetworkType.THREAD) {
override fun runCommand() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import chip.devicecontroller.ChipDeviceController
import com.matter.controller.commands.common.CredentialsIssuer

class PairCodeWifiCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) :
PairingCommand(controller, "code-wifi", PairingModeType.CODE, PairingNetworkType.WIFI, credsIssue) {
PairingCommand(controller, "code-wifi", credsIssue, PairingModeType.CODE, PairingNetworkType.WIFI) {
override fun runCommand() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import chip.devicecontroller.ChipDeviceController
import com.matter.controller.commands.common.CredentialsIssuer

class PairOnNetworkCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) :
PairingCommand(controller, "onnetwork", PairingModeType.ON_NETWORK, PairingNetworkType.NONE, credsIssue) {
PairingCommand(controller, "onnetwork", credsIssue, PairingModeType.ON_NETWORK, PairingNetworkType.NONE) {
override fun runCommand() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class PairOnNetworkCommissionerCommand(
) : PairingCommand(
controller,
"onnetwork-commissioner",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.COMMISSIONER
) {
override fun runCommand() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class PairOnNetworkCommissioningModeCommand(
) : PairingCommand(
controller,
"onnetwork-commissioning-mode",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.COMMISSIONING_MODE
) {
override fun runCommand() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class PairOnNetworkDeviceTypeCommand(
) : PairingCommand(
controller,
"onnetwork-device-type",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.DEVICE_TYPE
) {
override fun runCommand() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import com.matter.controller.commands.common.CredentialsIssuer
class PairOnNetworkFabricCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand(
controller,
"onnetwork-fabric",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.COMPRESSED_FABRIC_ID
) {
override fun runCommand() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class PairOnNetworkInstanceNameCommand(
) : PairingCommand(
controller,
"onnetwork-instance-name",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.INSTANCE_NAME
) {
override fun runCommand() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ package com.matter.controller.commands.pairing
import chip.devicecontroller.ChipDeviceController
import com.matter.controller.commands.common.CredentialsIssuer

private const val MATTER_PORT = 5540

class PairOnNetworkLongCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand(
controller,
"onnetwork-long",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.LONG_DISCRIMINATOR
) {
private val MATTER_PORT = 5540

override fun runCommand() {
currentCommissioner()
.pairDeviceWithAddress(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import chip.devicecontroller.WriteAttributesCallback
import chip.devicecontroller.model.AttributeWriteRequest
import chip.devicecontroller.model.ChipAttributePath
import com.matter.controller.commands.common.CredentialsIssuer
import java.util.ArrayList
import java.util.logging.Level
import java.util.logging.Logger
import javax.annotation.Nullable
Expand All @@ -37,18 +36,15 @@ class PairOnNetworkLongImWriteCommand(
) : PairingCommand(
controller,
"onnetwork-long-im-write",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.LONG_DISCRIMINATOR
) {
private var devicePointer: Long = 0
private fun setDevicePointer(devicePointer: Long) {
this.devicePointer = devicePointer
}

private inner class InternalWriteAttributesCallback : WriteAttributesCallback {
override fun onError(@Nullable attributePath: ChipAttributePath?, e: Exception?) {
override fun onError(attributePath: ChipAttributePath?, e: Exception) {
logger.log(Level.INFO, "Write receive onError on ")
if (attributePath != null) {
logger.log(Level.INFO, attributePath.toString())
Expand All @@ -67,7 +63,7 @@ class PairOnNetworkLongImWriteCommand(

private inner class InternalGetConnectedDeviceCallback : GetConnectedDeviceCallback {
override fun onDeviceConnected(devicePointer: Long) {
setDevicePointer(devicePointer)
this@PairOnNetworkLongImWriteCommand.devicePointer = devicePointer
logger.log(Level.INFO, "onDeviceConnected")
}

Expand All @@ -79,11 +75,15 @@ class PairOnNetworkLongImWriteCommand(
override fun runCommand() {
// boolean true for tlv
val booleanTLV = byteArrayOf(0x09)
val attribute: AttributeWriteRequest = AttributeWriteRequest.newInstance( /* endpointId= */
0, CLUSTER_ID_BASIC, ATTR_ID_LOCAL_CONFIG_DISABLED, booleanTLV
val attributeList = listOf(
AttributeWriteRequest.newInstance(
/* endpointId= */ 0,
CLUSTER_ID_BASIC,
ATTR_ID_LOCAL_CONFIG_DISABLED,
booleanTLV,
)
)
val attributeList: ArrayList<AttributeWriteRequest> = ArrayList<AttributeWriteRequest>()
attributeList.add(attribute)

currentCommissioner()
.pairDeviceWithAddress(
getNodeId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import com.matter.controller.commands.common.CredentialsIssuer
class PairOnNetworkShortCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand(
controller,
"onnetwork-short",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.SHORT_DISCRIMINATOR
) {
override fun runCommand() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import com.matter.controller.commands.common.CredentialsIssuer
class PairOnNetworkVendorCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand(
controller,
"onnetwork-vendor",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
credsIssue,
DiscoveryFilterType.VENDOR_ID
) {
override fun runCommand() {}
Expand Down
Loading

0 comments on commit f34fce7

Please sign in to comment.