zigbee-herdsman-zigate
Version:
An open source ZigBee gateway solution with node.js.
354 lines • 15.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZiGateCommand = void 0;
const constants_1 = require("./constants");
function equal(expected, received) {
return expected === received;
}
function notEqual(expected, received) {
return expected !== received;
}
exports.ZiGateCommand = {
[constants_1.ZiGateCommandCode.SetDeviceType]: {
request: [
{ name: 'deviceType', parameterType: 'UINT8' } //<device type: uint8_t>
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.SetDeviceType }
]
]
},
[constants_1.ZiGateCommandCode.StartNetwork]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.StartNetwork },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.NetworkJoined }
],
]
},
[constants_1.ZiGateCommandCode.StartNetworkScan]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.StartNetworkScan },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.NetworkJoined }
]
]
},
[constants_1.ZiGateCommandCode.GetNetworkState]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.GetNetworkState },
]
]
},
[constants_1.ZiGateCommandCode.GetTimeServer]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.GetTimeServer },
]
]
},
[constants_1.ZiGateCommandCode.ErasePersistentData]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.ErasePersistentData },
]
]
},
[constants_1.ZiGateCommandCode.Reset]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.Reset },
]
]
},
[constants_1.ZiGateCommandCode.SetTXpower]: {
request: [
{ name: 'value', parameterType: 'UINT8' }
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.SetTXpower },
]
]
},
[constants_1.ZiGateCommandCode.ManagementLQI]: {
request: [
{ name: 'targetAddress', parameterType: 'UINT16' },
{ name: 'startIndex', parameterType: 'UINT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.ManagementLQI },
]
]
},
[constants_1.ZiGateCommandCode.SetSecurityStateKey]: {
request: [
{ name: 'keyType', parameterType: 'UINT8' },
{ name: 'key', parameterType: 'DATA' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.SetSecurityStateKey },
]
]
},
[constants_1.ZiGateCommandCode.GetVersion]: {
request: [],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.GetVersion },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.VersionList }
],
]
},
[constants_1.ZiGateCommandCode.RawMode]: {
request: [
{ name: 'enabled', parameterType: 'INT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.RawMode },
]
]
},
[constants_1.ZiGateCommandCode.SetExpendedPANID]: {
request: [
{ name: 'panId', parameterType: 'IEEEADDR' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.SetExpendedPANID },
]
]
},
[constants_1.ZiGateCommandCode.SetChannelMask]: {
request: [
{ name: 'channelMask', parameterType: 'UINT32BE' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.SetChannelMask },
]
]
},
[constants_1.ZiGateCommandCode.RemoveDevice]: {
request: [
{ name: 'targetShortAddress', parameterType: 'IEEEADDR' },
{ name: 'extendedAddress:', parameterType: 'IEEEADDR' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.RemoveDevice },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.LeaveIndication }
],
]
},
[constants_1.ZiGateCommandCode.PermitJoin]: {
request: [
{ name: 'targetShortAddress', parameterType: 'UINT16' },
// broadcast 0xfffc
{ name: 'interval', parameterType: 'UINT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.PermitJoin },
]
]
},
[constants_1.ZiGateCommandCode.PermitJoinStatus]: {
request: [
{ name: 'targetShortAddress', parameterType: 'UINT16' },
// broadcast 0xfffc
{ name: 'interval', parameterType: 'UINT8' },
// 0 = Disable Joining
// 1 – 254 = Time in seconds to allow joins
// 255 = Allow all joins
{ name: 'TCsignificance', parameterType: 'UINT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.PermitJoinStatus },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.PermitJoinStatus }
],
]
},
[constants_1.ZiGateCommandCode.RawAPSDataRequest]: {
request: [
{ name: 'addressMode', parameterType: 'UINT8' },
{ name: 'targetShortAddress', parameterType: 'UINT16BE' },
{ name: 'sourceEndpoint', parameterType: 'UINT8' },
{ name: 'destinationEndpoint', parameterType: 'UINT8' },
{ name: 'clusterID', parameterType: 'UINT16BE' },
{ name: 'profileID', parameterType: 'UINT16BE' },
{ name: 'securityMode', parameterType: 'UINT8' },
{ name: 'radius', parameterType: 'UINT8' },
{ name: 'dataLength', parameterType: 'UINT8' },
{ name: 'data', parameterType: 'BUFFER' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.RawAPSDataRequest },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.DataIndication },
{
receivedProperty: 'payload.sourceAddress', matcher: equal,
expectedProperty: 'payload.targetShortAddress'
},
{
receivedProperty: 'payload.clusterID',
matcher: equal,
expectedProperty: 'payload.clusterID'
},
{
receivedProperty: 'payload.sourceEndpoint', matcher: equal,
expectedProperty: 'payload.destinationEndpoint'
},
{ receivedProperty: 'payload.profileID', matcher: equal, expectedProperty: 'payload.profileID' },
],
]
},
[constants_1.ZiGateCommandCode.SimpleDescriptor]: {
request: [
{ name: 'targetShortAddress', parameterType: 'UINT16BE' },
{ name: 'endpoint', parameterType: 'UINT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.SimpleDescriptor },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.DataIndication },
{
receivedProperty: 'payload.sourceAddress',
matcher: equal,
expectedProperty: 'payload.targetShortAddress'
},
{
receivedProperty: 'payload.clusterID',
matcher: equal, value: constants_1.ZiGateMessageCode.SimpleDescriptorResponse
}
],
]
},
[constants_1.ZiGateCommandCode.ActiveEndpoint]: {
request: [
{ name: 'targetShortAddress', parameterType: 'UINT16BE' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.ActiveEndpoint },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.DataIndication },
{
receivedProperty: 'payload.sourceAddress',
matcher: equal,
expectedProperty: 'payload.targetShortAddress'
},
{ receivedProperty: 'payload.clusterID', matcher: equal, value: constants_1.ZiGateMessageCode.ActiveEndpointResponse }
],
]
},
[constants_1.ZiGateCommandCode.NodeDescriptor]: {
request: [
{ name: 'targetShortAddress', parameterType: 'UINT16BE' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.NodeDescriptor },
],
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.DataIndication },
{
receivedProperty: 'payload.sourceAddress',
matcher: equal,
expectedProperty: 'payload.targetShortAddress'
},
{ receivedProperty: 'payload.clusterID', matcher: equal, value: 0x8002 },
],
]
},
[constants_1.ZiGateCommandCode.Bind]: {
request: [
{ name: 'targetExtendedAddress', parameterType: 'IEEEADR' },
{ name: 'targetEndpoint', parameterType: 'UINT8' },
{ name: 'clusterID', parameterType: 'UINT16BE' },
{ name: 'destinationAddressMode', parameterType: 'UINT8' },
{ name: 'destinationAddress', parameterType: 'ADDRESS_WITH_TYPE_DEPENDENCY' },
{ name: 'destinationEndpoint', parameterType: 'UINT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.Bind },
],
]
},
[constants_1.ZiGateCommandCode.UnBind]: {
request: [
{ name: 'targetExtendedAddress', parameterType: 'IEEEADR' },
{ name: 'targetEndpoint', parameterType: 'UINT8' },
{ name: 'clusterID', parameterType: 'UINT16BE' },
{ name: 'destinationAddressMode', parameterType: 'UINT8' },
{ name: 'destinationAddress', parameterType: 'ADDRESS_WITH_TYPE_DEPENDENCY' },
{ name: 'destinationEndpoint', parameterType: 'UINT8' },
],
response: [
[
{ receivedProperty: 'code', matcher: equal, value: constants_1.ZiGateMessageCode.Status },
{ receivedProperty: 'payload.status', matcher: notEqual, value: 0 },
{ receivedProperty: 'payload.packetType', matcher: equal, value: constants_1.ZiGateCommandCode.UnBind },
],
]
},
};
//# sourceMappingURL=commandType.js.map