Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Downgrade zigBee library to last working version (1.2.2)" #3

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ buildscript {
tunjiAndroidxCore = 'com.tunjid.androidx:core:1.2.1'
tunjiAndroidxView = 'com.tunjid.androidx:view:1.1.0'

zigBeeCore = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee:1.2.2'
zigBeeConsole = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee.console:1.2.2'
zigBeeSerial = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee.serial:1.2.2'
zigBeeDongle = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee.dongle.cc2531:1.2.2'
zigBeeCore = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee:1.3.9'
zigBeeConsole = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee.console:1.3.9'
zigBeeSerial = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee.serial:1.3.9'
zigBeeDongle = 'com.zsmartsystems.zigbee:com.zsmartsystems.zigbee.dongle.cc2531:1.3.9'

junit = 'junit:junit:4.12'
androidJunit = 'androidx.test.ext:junit:1.1.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ class ColorCommand : AbsZigBeeCommand() {
val endpoint = getNode(destination.address).getEndpoint(destination.endpoint) ?: return null
val cluster = endpoint.getInputCluster(ZclColorControlCluster.CLUSTER_ID) as ZclColorControlCluster

return cluster.moveToColorCommand(x, y, (time * 10).toInt())
return cluster.sendCommand(MoveToColorCommand(x, y, (time * 10).toInt()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ class LevelCommand : AbsZigBeeCommand() {

val cluster = endpoint.getInputCluster(ZclLevelControlCluster.CLUSTER_ID) as ZclLevelControlCluster

return cluster.moveToLevelWithOnOffCommand(l, (time * 10).toInt())
return cluster.sendCommand(MoveToLevelWithOnOffCommand(l, (time * 10).toInt()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ class MembershipAddCommand : AbsZigBeeCommand() {
* @return the command result future
*/
private fun ZigBeeNetworkManager.addMembership(device: ZigBeeEndpoint, groupId: Int, groupName: String): Future<CommandResult> {
val command = AddGroupCommand()
command.groupId = groupId
command.groupName = groupName

val command = AddGroupCommand(groupId, groupName)
command.destinationAddress = device.endpointAddress

return sendTransaction(command, ZclTransactionMatcher())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ class MembershipListCommand : AbsZigBeeCommand() {
* @return the command result future
*/
private fun ZigBeeNetworkManager.getGroupMemberships(device: ZigBeeEndpoint): Future<CommandResult> {
val command = GetGroupMembershipCommand()

command.groupCount = 0
command.groupList = emptyList()
val command = GetGroupMembershipCommand(0, emptyList())
command.destinationAddress = device.endpointAddress

return sendTransaction(command, ZclTransactionMatcher())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class MembershipRemoveCommand : AbsZigBeeCommand() {
* @return the command result future
*/
private fun ZigBeeNetworkManager.removeMembership(device: ZigBeeEndpoint, groupId: Int): Future<CommandResult> {
val command = RemoveGroupCommand()
command.groupId = groupId
val command = RemoveGroupCommand(groupId)
command.destinationAddress = device.endpointAddress

return sendTransaction(command, ZclTransactionMatcher())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class MembershipViewCommand : AbsZigBeeCommand() {
* @return the command result future
*/
fun ZigBeeNetworkManager.viewMembership(device: ZigBeeEndpoint, groupId: Int): Future<CommandResult> {
val command = ViewGroupCommand()
command.groupId = groupId
val command = ViewGroupCommand(groupId)
command.destinationAddress = device.endpointAddress

return sendTransaction(command, ZclTransactionMatcher())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ class OffCommand : AbsZigBeeCommand() {

val cluster = endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID) as ZclOnOffCluster

return cluster.offCommand()
return cluster.sendCommand(OffCommand())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ class OnCommand : AbsZigBeeCommand() {

val cluster = endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID) as ZclOnOffCluster

return cluster.onCommand()
return cluster.sendCommand(OnCommand())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package com.rcswitchcontrol.zigbee.commands

import com.rcswitchcontrol.zigbee.R
import com.tunjid.rcswitchcontrol.common.ContextProvider
import com.zsmartsystems.zigbee.ExtendedPanId
import com.zsmartsystems.zigbee.ZigBeeNetworkManager
import com.zsmartsystems.zigbee.transport.DeviceType
import com.zsmartsystems.zigbee.transport.TransportConfig
Expand All @@ -47,22 +46,14 @@ class StartupCommand : AbsZigBeeCommand() {
@Throws(Exception::class)
override fun process(networkManager: ZigBeeNetworkManager, args: Array<out String>, out: PrintStream) {
args.expect(3)
//
// networkManager.zigBeeTransport.apply {
// updateTransportConfig(TransportConfig().apply {
// addOption(TransportConfigOption.DEVICE_TYPE, DeviceType.COORDINATOR)
// })
//// out.println("ZigBees status is: ${startup(true)}")
// out.println("Reinitialize: ${networkManager.reinitialize()}")
// out.println("start up: ${networkManager.startup(true)}")
// }

val transportOptions = TransportConfig()

networkManager.setZigBeePanId(args[1].toInt())
networkManager.setZigBeeExtendedPanId(ExtendedPanId(args[2]))
transportOptions.addOption(TransportConfigOption.DEVICE_TYPE, DeviceType.COORDINATOR)
networkManager.getZigBeeTransport().updateTransportConfig(transportOptions)
out.println("start up: ${networkManager.startup(true)}")
networkManager.zigBeeTransport.apply {
updateTransportConfig(TransportConfig().apply {
addOption(TransportConfigOption.DEVICE_TYPE, DeviceType.COORDINATOR)
})
// out.println("ZigBees status is: ${startup(true)}")
out.println("Reinitialize: ${networkManager.reinitialize()}")
out.println("start up: ${networkManager.startup(true)}")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class LazyDiscoveryExtension(

val backing = networkManager?.getExtension(ZigBeeDiscoveryExtension::class.java)
as? ZigBeeDiscoveryExtension
?: return ZigBeeStatus.INVALID_STATE
?: return ZigBeeStatus.NO_NETWORK

Log.i("TEST", "CONFIGURED LAZY DISCOVERY")

// backing.setUpdateOnChange(true)
backing.setUpdateOnChange(true)
backing.updatePeriod = ZigBeeProtocol.MESH_UPDATE_PERIOD
backing.refresh()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ import com.tunjid.rcswitchcontrol.common.ContextProvider
import com.tunjid.rcswitchcontrol.common.deserialize
import com.tunjid.rcswitchcontrol.common.serialize
import com.tunjid.rcswitchcontrol.common.serializeList
import com.zsmartsystems.zigbee.*
import com.zsmartsystems.zigbee.ExtendedPanId
import com.zsmartsystems.zigbee.ZigBeeChannel
import com.zsmartsystems.zigbee.ZigBeeNetworkManager
import com.zsmartsystems.zigbee.ZigBeeNetworkNodeListener
import com.zsmartsystems.zigbee.ZigBeeNode
import com.zsmartsystems.zigbee.ZigBeeProfileType
import com.zsmartsystems.zigbee.ZigBeeStatus
import com.zsmartsystems.zigbee.app.basic.ZigBeeBasicServerExtension
import com.zsmartsystems.zigbee.app.discovery.ZigBeeDiscoveryExtension
import com.zsmartsystems.zigbee.app.iasclient.ZigBeeIasCieExtension
Expand Down Expand Up @@ -186,7 +192,7 @@ class ZigBeeProtocol(driver: UsbSerialDriver, printWriter: PrintWriter) : CommsP

if (resetNetwork) reset()

// networkManager.setDefaultProfileId(ZigBeeProfileType.ZIGBEE_HOME_AUTOMATION.key)
networkManager.setDefaultProfileId(ZigBeeProfileType.ZIGBEE_HOME_AUTOMATION.key)

transportOptions.apply {
addOption(TransportConfigOption.RADIO_TX_POWER, 3)
Expand All @@ -197,37 +203,35 @@ class ZigBeeProtocol(driver: UsbSerialDriver, printWriter: PrintWriter) : CommsP

dongle.updateTransportConfig(transportOptions)

networkManager.addSupportedCluster(ZclIasZoneCluster.CLUSTER_ID)

// listOf(
// ZclIasZoneCluster.CLUSTER_ID,
// ZclBasicCluster.CLUSTER_ID,
// ZclIdentifyCluster.CLUSTER_ID,
// ZclGroupsCluster.CLUSTER_ID,
// ZclScenesCluster.CLUSTER_ID,
// ZclPollControlCluster.CLUSTER_ID,
// ZclOnOffCluster.CLUSTER_ID,
// ZclLevelControlCluster.CLUSTER_ID,
// ZclColorControlCluster.CLUSTER_ID,
// ZclPressureMeasurementCluster.CLUSTER_ID,
// ZclThermostatCluster.CLUSTER_ID,
// ZclWindowCoveringCluster.CLUSTER_ID,
// 1000
// ).sorted().forEach(networkManager::addSupportedClientCluster)
//
// listOf(
// ZclBasicCluster.CLUSTER_ID,
// ZclIdentifyCluster.CLUSTER_ID,
// ZclGroupsCluster.CLUSTER_ID,
// ZclScenesCluster.CLUSTER_ID,
// ZclPollControlCluster.CLUSTER_ID,
// ZclOnOffCluster.CLUSTER_ID,
// ZclLevelControlCluster.CLUSTER_ID,
// ZclColorControlCluster.CLUSTER_ID,
// ZclPressureMeasurementCluster.CLUSTER_ID,
// ZclWindowCoveringCluster.CLUSTER_ID,
// 1000
// ).sorted().forEach(networkManager::addSupportedServerCluster)
listOf(
ZclIasZoneCluster.CLUSTER_ID,
ZclBasicCluster.CLUSTER_ID,
ZclIdentifyCluster.CLUSTER_ID,
ZclGroupsCluster.CLUSTER_ID,
ZclScenesCluster.CLUSTER_ID,
ZclPollControlCluster.CLUSTER_ID,
ZclOnOffCluster.CLUSTER_ID,
ZclLevelControlCluster.CLUSTER_ID,
ZclColorControlCluster.CLUSTER_ID,
ZclPressureMeasurementCluster.CLUSTER_ID,
ZclThermostatCluster.CLUSTER_ID,
ZclWindowCoveringCluster.CLUSTER_ID,
1000
).sorted().forEach(networkManager::addSupportedClientCluster)

listOf(
ZclBasicCluster.CLUSTER_ID,
ZclIdentifyCluster.CLUSTER_ID,
ZclGroupsCluster.CLUSTER_ID,
ZclScenesCluster.CLUSTER_ID,
ZclPollControlCluster.CLUSTER_ID,
ZclOnOffCluster.CLUSTER_ID,
ZclLevelControlCluster.CLUSTER_ID,
ZclColorControlCluster.CLUSTER_ID,
ZclPressureMeasurementCluster.CLUSTER_ID,
ZclWindowCoveringCluster.CLUSTER_ID,
1000
).sorted().forEach(networkManager::addSupportedServerCluster)

post(
if (networkManager.startup(resetNetwork) !== ZigBeeStatus.SUCCESS) "ZigBee console starting up ... [FAIL]"
Expand Down