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 488bd29 commit d456ce5
Show file tree
Hide file tree
Showing 26 changed files with 216 additions and 186 deletions.
2 changes: 1 addition & 1 deletion examples/java-matter-controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ java_library("java") {
"java/src/com/matter/controller/commands/common/IPAddress.java",
"java/src/com/matter/controller/commands/common/MatterCommand.java",
"java/src/com/matter/controller/commands/common/RealResult.java",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImInvokeCommand.java",
]

javac_flags = [ "-Xlint:deprecation" ]
Expand Down Expand Up @@ -69,6 +68,7 @@ kotlin_binary("java-matter-controller") {
"java/src/com/matter/controller/commands/pairing/PairOnNetworkFabricCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkInstanceNameCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkLongCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImInvokeCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkShortCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkVendorCommand.kt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ fun main(args: Array<String>) {
commandManager.register("discover", getDiscoveryCommands(controller, credentialsIssuer))
commandManager.register("pairing", getPairingCommands(controller, credentialsIssuer))
commandManager.register("im", getImCommands(controller, credentialsIssuer))

try {
commandManager.run(args)
} catch (e: Exception) {
println("Run command failed with exception: " + e.message)
System.exit(1)
}

controller.shutdownCommissioning()
}
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 @@ -23,13 +23,9 @@ import com.matter.controller.commands.common.CredentialsIssuer
import com.matter.controller.commands.common.MatterCommand
import java.util.concurrent.TimeUnit

private const val MAX_DISCOVERED_DEVICES = 10
private const val TIME_TO_WAIT_FOR_RESULTS_SECONDS = 7L

class DiscoverCommissionablesCommand(
controller: ChipDeviceController, credsIssuer: CredentialsIssuer?
) : MatterCommand(controller, "commissionables", credsIssuer) {

override fun runCommand() {
currentCommissioner().discoverCommissionableNodes()

Expand All @@ -55,4 +51,9 @@ class DiscoverCommissionablesCommand(
System.out.format("\tDiscriminator: %d", device.discriminator)
System.out.format("\tIP Address : %s%n", device.ipAddress)
}

companion object {
private const val MAX_DISCOVERED_DEVICES = 10
private const val TIME_TO_WAIT_FOR_RESULTS_SECONDS = 7L
}
}
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

This file was deleted.

Loading

0 comments on commit d456ce5

Please sign in to comment.