Skip to content

Commit

Permalink
add kotlin IM read test and enable im test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Mar 10, 2023
1 parent 3c6bed3 commit b015c6b
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,54 @@ jobs:
--tool-args "onnetwork-long --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
--factoryreset \
'
- name: Run IM Invoke Test
timeout-minutes: 10
run: |
scripts/run_in_build_env.sh \
'./scripts/tests/run_java_test.py \
--app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
--app-args "--discriminator 3840 --interface-id -1" \
--tool-path out/linux-x64-java-matter-controller \
--tool-cluster "pairing" \
--tool-args "onnetwork-long-im-invoke --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
--factoryreset \
'
- name: Run IM Read Test
timeout-minutes: 10
run: |
scripts/run_in_build_env.sh \
'./scripts/tests/run_java_test.py \
--app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
--app-args "--discriminator 3840 --interface-id -1" \
--tool-path out/linux-x64-java-matter-controller \
--tool-cluster "pairing" \
--tool-args "onnetwork-long-im-read --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
--factoryreset \
'
- name: Run IM Write Test
timeout-minutes: 10
run: |
scripts/run_in_build_env.sh \
'./scripts/tests/run_java_test.py \
--app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
--app-args "--discriminator 3840 --interface-id -1" \
--tool-path out/linux-x64-java-matter-controller \
--tool-cluster "pairing" \
--tool-args "onnetwork-long-im-write --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
--factoryreset \
'
- name: Run IM Subscribe Test
timeout-minutes: 10
run: |
scripts/run_in_build_env.sh \
'./scripts/tests/run_java_test.py \
--app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
--app-args "--discriminator 3840 --interface-id -1" \
--tool-path out/linux-x64-java-matter-controller \
--tool-cluster "pairing" \
--tool-args "onnetwork-long-im-subscribe --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
--factoryreset \
'
- name: Run Pairing AlreadyDiscovered Test
timeout-minutes: 10
run: |
Expand Down
1 change: 1 addition & 0 deletions examples/java-matter-controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ kotlin_binary("java-matter-controller") {
"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/PairOnNetworkLongImReadCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImSubscribeCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImWriteCommand.kt",
"java/src/com/matter/controller/commands/pairing/PairOnNetworkShortCommand.kt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private fun getImCommands(
credentialsIssuer: CredentialsIssuer
): List<Command> {
return listOf(
PairOnNetworkLongImReadCommand(controller, credentialsIssuer),
PairOnNetworkLongImSubscribeCommand(controller, credentialsIssuer),
PairOnNetworkLongImWriteCommand(controller, credentialsIssuer),
PairOnNetworkLongImInvokeCommand(controller, credentialsIssuer),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.matter.controller.commands.pairing

import chip.devicecontroller.ChipDeviceController
import chip.devicecontroller.GetConnectedDeviceCallbackJni.GetConnectedDeviceCallback
import chip.devicecontroller.ReportCallback
import chip.devicecontroller.model.NodeState
import chip.devicecontroller.model.ChipAttributePath
import chip.devicecontroller.model.ChipEventPath
import com.matter.controller.commands.common.CredentialsIssuer
import java.util.Collections
import java.util.logging.Level
import java.util.logging.Logger

class PairOnNetworkLongImReadCommand(
controller: ChipDeviceController, credsIssue: CredentialsIssuer?
) : PairingCommand(
controller,
"onnetwork-long-im-read",
credsIssue,
PairingModeType.ON_NETWORK,
PairingNetworkType.NONE,
DiscoveryFilterType.LONG_DISCRIMINATOR
) {
private var devicePointer: Long = 0

private inner class InternalReportCallback : ReportCallback {
override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, e: Exception) {
logger.log(Level.INFO, "Read receive onError")
setFailure("read failure")
}

override fun onReport(nodeState: NodeState) {
logger.log(Level.INFO, "Read receve onReport")
setSuccess()
}

}

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

override fun onConnectionFailure(nodeId: Long, error: Exception?) {
logger.log(Level.INFO, "onConnectionFailure")
}
}

override fun runCommand() {
val attributePathList = listOf(ChipAttributePath.newInstance(
/* endpointId= */ 0, CLUSTER_ID_BASIC, ATTR_ID_LOCAL_CONFIG_DISABLED))

currentCommissioner()
.pairDeviceWithAddress(
getNodeId(),
getRemoteAddr().getHostAddress(),
MATTER_PORT,
getDiscriminator(),
getSetupPINCode(),
null
)
currentCommissioner().setCompletionListener(this)
waitCompleteMs(getTimeoutMillis())
currentCommissioner()
.getConnectedDevicePointer(getNodeId(), InternalGetConnectedDeviceCallback())
clear()
currentCommissioner()
.readPath(InternalReportCallback(), devicePointer, attributePathList, Collections.emptyList(), false)
waitCompleteMs(getTimeoutMillis())
}

companion object {
private val logger = Logger.getLogger(
PairOnNetworkLongImReadCommand::class.java.name
)

private const val MATTER_PORT = 5540
private const val CLUSTER_ID_BASIC = 0x0028L
private const val ATTR_ID_LOCAL_CONFIG_DISABLED = 16L
}
}

0 comments on commit b015c6b

Please sign in to comment.