-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java-matter-controller] Convert from java to kotlin phase II (#25491)
* [java-matter-controller] Convert from java to kotlin phase II * Address review comments
- Loading branch information
1 parent
42a552b
commit 9110132
Showing
47 changed files
with
1,158 additions
and
920 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
...atter-controller/java/src/com/matter/controller/commands/pairing/CloseSessionCommand.java
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
...-matter-controller/java/src/com/matter/controller/commands/pairing/CloseSessionCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package com.matter.controller.commands.pairing | ||
|
||
import chip.devicecontroller.ChipDeviceController | ||
import com.matter.controller.commands.common.CredentialsIssuer | ||
import com.matter.controller.commands.common.MatterCommand | ||
import java.util.concurrent.atomic.AtomicInteger | ||
import java.util.concurrent.atomic.AtomicLong | ||
|
||
class CloseSessionCommand(controller: ChipDeviceController, credsIssuer: CredentialsIssuer?) : | ||
MatterCommand(controller, "close-session", credsIssuer) { | ||
private val destinationId: AtomicLong = AtomicLong() | ||
private val timeoutSecs: AtomicInteger = AtomicInteger() | ||
|
||
init { | ||
addArgument("destination-id", 0, Long.MAX_VALUE, destinationId, null, false) | ||
addArgument( | ||
"timeout", 0.toShort(), Short.MAX_VALUE, | ||
timeoutSecs, | ||
"Time, in seconds, before this command is considered to have timed out.", | ||
false | ||
) | ||
} | ||
|
||
override fun runCommand() {} | ||
} |
61 changes: 30 additions & 31 deletions
61
...commands/pairing/DiscoveryFilterType.java → ...r/commands/pairing/DiscoveryFilterType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
/* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.matter.controller.commands.pairing; | ||
|
||
public enum DiscoveryFilterType { | ||
NONE, | ||
SHORT_DISCRIMINATOR, | ||
LONG_DISCRIMINATOR, | ||
VENDOR_ID, | ||
DEVICE_TYPE, | ||
COMMISSIONING_MODE, | ||
INSTANCE_NAME, | ||
COMMISSIONER, | ||
COMPRESSED_FABRIC_ID, | ||
} | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
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 | ||
} |
39 changes: 0 additions & 39 deletions
39
...er-controller/java/src/com/matter/controller/commands/pairing/PairAddressPaseCommand.java
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
...tter-controller/java/src/com/matter/controller/commands/pairing/PairAddressPaseCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package com.matter.controller.commands.pairing | ||
|
||
import chip.devicecontroller.ChipDeviceController | ||
import com.matter.controller.commands.common.CredentialsIssuer | ||
import java.util.logging.Level | ||
import java.util.logging.Logger | ||
|
||
class PairAddressPaseCommand(controller: ChipDeviceController, credsIssue: CredentialsIssuer?) : PairingCommand( | ||
controller, | ||
"address-paseonly", | ||
credsIssue, | ||
PairingModeType.ADDRESS_PASE_ONLY, | ||
PairingNetworkType.NONE | ||
) { | ||
override fun onPairingComplete(errorCode: Int) { | ||
logger.log(Level.INFO, "onPairingComplete with error code: $errorCode") | ||
if (errorCode == 0) { | ||
setSuccess() | ||
} else { | ||
setFailure("onPairingComplete failure") | ||
} | ||
} | ||
|
||
override fun runCommand() { | ||
currentCommissioner() | ||
.establishPaseConnection( | ||
getNodeId(), | ||
getRemoteAddr().getHostAddress(), | ||
getRemotePort(), | ||
getSetupPINCode() | ||
) | ||
currentCommissioner().setCompletionListener(this) | ||
waitCompleteMs(getTimeoutMillis()) | ||
} | ||
|
||
companion object { | ||
private val logger = Logger.getLogger(PairAddressPaseCommand::class.java.name) | ||
} | ||
} |
Oops, something went wrong.