public void BuildPacket(DoubleByte ApiId, byte[] frameData) { // packet size is start byte + len byte + 2 cmd bytes + data + checksum byte Packet = new byte[frameData.Length + 5]; Packet[0] = START_BYTE; // note: if checksum is not correct, XBee won't send out packet or return error. ask me how I know. // checksum is always computed on pre-escaped packet Checksum checksum = new Checksum(); // Packet length does not include escape bytes LEN = frameData.Length; Packet[1] = (byte)LEN; checksum.AddByte(Packet[1]); // msb Cmd0 -> Type & Subsystem Packet[2] = ApiId.Msb; checksum.AddByte(Packet[2]); // lsb Cmd1 -> PROFILE_ID_HOME_AUTOMATION Packet[3] = ApiId.Lsb; checksum.AddByte(Packet[3]); CMD = ApiId; // data for (int i = 0; i < frameData.Length; i++) { if (!ByteUtils.IsByteValue(frameData[i])) { throw new Exception("Value is greater than one byte: " + frameData[i] + " (" + string.Format("{0:X}", frameData[i]) + ")"); } Packet[PAYLOAD_START_INDEX + i] = frameData[i]; checksum.AddByte(Packet[PAYLOAD_START_INDEX + i]); } // set last byte as checksum FCS = checksum.Value; Packet[Packet.Length - 1] = FCS; }
public ZDO_SIMPLE_DESC_RSP(byte[] framedata) { SrcAddr = new ZToolAddress16(framedata[1], framedata[0]); Status = (PacketStatus)framedata[2]; NwkAddr = new ZToolAddress16(framedata[4], framedata[3]); Len = framedata[5]; if (Len >= MIN_DESC_LEN) { Endpoint = framedata[6]; ProfileId = new DoubleByte(framedata[8], framedata[7]); DeviceId = new DoubleByte(framedata[10], framedata[9]); DeviceVersion = framedata[11]; NumInClusters = framedata[12]; InClusterList = new DoubleByte[NumInClusters]; for (int i = 0; i < NumInClusters; i++) { InClusterList[i] = new DoubleByte(framedata[(i * 2) + 14], framedata[(i * 2) + 13]); } NumOutClusters = framedata[((NumInClusters) * 2) + 13]; OutClusterList = new DoubleByte[NumOutClusters]; for (int i = 0; i < NumOutClusters; i++) { OutClusterList[i] = new DoubleByte(framedata[(i * 2) + ((NumInClusters) * 2) + 15], framedata[(i * 2) + ((NumInClusters) * 2) + 14]); } BuildPacket(new DoubleByte(ZToolCMD.ZDO_SIMPLE_DESC_RSP), framedata); } }
public ZB_SEND_DATA_REQUEST(ZToolAddress16 destination, DoubleByte commandId, int handle, int ack, int radius, int payloadLength, byte[] payload) { // TODO: check buffer length Destination = destination; CommandId = commandId; Handle = handle; Ack = ack; Radius = radius; PayloadLength = payloadLength; PayloadValue = payload; byte[] framedata = new byte[PayloadValue.Length + 8]; framedata[0] = Destination.Lsb; framedata[1] = Destination.Msb; framedata[2] = CommandId.Lsb; framedata[3] = CommandId.Msb; framedata[4] = (byte)Handle; framedata[5] = (byte)Ack; framedata[6] = (byte)Radius; framedata[7] = (byte)PayloadLength; for (int i = 0; i < this.PayloadValue.Length; i++) { framedata[i + 8] = this.PayloadValue[i]; } BuildPacket(new DoubleByte((ushort)ZToolCMD.ZB_SEND_DATA_REQUEST), framedata); }
public static async Task <ZToolPacket> ReadAsync(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var buffer = new byte[1024]; await stream.ReadAsyncExact(buffer, 0, 1); if (buffer[0] == 0xFE) { await stream.ReadAsyncExact(buffer, 1, 1); var length = buffer[1]; await stream.ReadAsyncExact(buffer, 2, length + 3); var type = (ZToolPacket.CommandType)(buffer[2] >> 5 & 0x07); var subsystem = (ZToolPacket.CommandSubsystem)(buffer[2] & 0x1f); var cmd1 = buffer[3]; var payload = buffer.Skip(4).Take(length).ToArray(); if (buffer.Skip(1).Take(length + 3).Aggregate((byte)0x00, (total, next) => (byte)(total ^ next)) != buffer[length + 4]) { throw new InvalidDataException("checksum error"); } DoubleByte cmd = new DoubleByte(buffer[3], buffer[2]); return(ParsePayload(cmd, buffer.Skip(4).Take(length).ToArray())); } throw new InvalidDataException("unable to decode packet"); }
public AF_INCOMING_MSG(byte[] framedata) { GroupId = new DoubleByte(framedata[1], framedata[0]); ClusterId = new DoubleByte(framedata[3], framedata[2]); SrcAddr = new ZToolAddress16(framedata[5], framedata[4]); SrcEndpoint = framedata[6]; DstEndpoint = framedata[7]; WasBroadcast = framedata[8]; LinkQuality = framedata[9]; SecurityUse = framedata[10]; byte[] bytes = new byte[4]; bytes[3] = (byte)framedata[11]; bytes[2] = (byte)framedata[12]; bytes[1] = (byte)framedata[13]; bytes[0] = (byte)framedata[14]; TimeStamp = BitConverter.ToInt32(bytes, 0); TransSeqNumber = framedata[15]; Len = framedata[16]; Data = new byte[Len]; for (int i = 0; i < this.Data.Length; i++) { this.Data[i] = framedata[17 + i]; } BuildPacket(new DoubleByte((ushort)ZToolCMD.AF_INCOMING_MSG), framedata); }
public ZDO_MSG_CB_REGISTER(DoubleByte cluster) { byte[] framedata = new byte[2]; framedata[0] = cluster.Lsb; framedata[1] = cluster.Msb; BuildPacket(new DoubleByte(ZToolCMD.ZDO_MSG_CB_REGISTER), framedata); }
public SYS_PING_RESPONSE(DoubleByte capabilities1) { this.Capabilities = capabilities1.Value; byte[] framedata = new byte[2]; framedata[0] = capabilities1.Lsb; framedata[1] = capabilities1.Msb; BuildPacket(new DoubleByte(ZToolCMD.SYS_PING_RESPONSE), framedata); }
/// <name>TI.ZPI1.SYS_SET_PANID</name> /// <summary>Constructor</summary> public UTIL_SET_PANID(DoubleByte num1) { this.PanID = num1; byte[] framedata = new byte[1]; framedata[0] = this.PanID.Msb; framedata[1] = this.PanID.Lsb; BuildPacket(new DoubleByte(ZToolCMD.UTIL_SET_PANID), framedata); }
/// <name>TI.ZPI2.ZB_APP_REGISTER_REQUEST</name> /// <summary>Constructor</summary> public ZB_APP_REGISTER_REQUEST(byte num1, DoubleByte num2, DoubleByte num3, byte num4, byte num5, byte num6, DoubleByte[] numArray1, byte num7, DoubleByte[] numArray2) { this.AppEndPoint = num1; this.AppProfileID = num2; this.DeviceId = num3; this.DeviceVersion = num4; this.Unused = num5; this.InputCommandsNum = num6; this.InputCommandsList = new DoubleByte[numArray1.Length]; this.InputCommandsList = numArray1; /* * if (numArray1.Length > 0xff) * { * throw new Exception("Error creating object."); * } * this.InputCommandsList = new ushort[0xff]; * Array.Copy(numArray1, this.InputCommandsList, numArray1.Length); */ this.OutputCommandsNum = num7; this.OutputCommandsList = new DoubleByte[numArray2.Length]; this.OutputCommandsList = numArray2; /* * if (numArray2.Length > 0xff) * { * throw new Exception("Error creating object."); * } * this.OutputCommandsList = new ushort[0xff]; * Array.Copy(numArray2, this.OutputCommandsList, numArray2.Length); */ byte[] framedata = new byte[9 + this.InputCommandsList.Length * 2 + this.OutputCommandsList.Length * 2]; framedata[0] = this.AppEndPoint; framedata[1] = this.AppProfileID.Lsb; framedata[2] = this.AppProfileID.Msb; framedata[3] = this.DeviceId.Lsb; framedata[4] = this.DeviceId.Msb; framedata[5] = this.DeviceVersion; framedata[6] = this.Unused; framedata[7] = this.InputCommandsNum; for (int i = 0; i < this.InputCommandsList.Length; i++) { framedata[(i * 2) + 8] = this.InputCommandsList[i].Lsb; framedata[(i * 2) + 9] = this.InputCommandsList[i].Msb; } framedata[((this.InputCommandsList.Length) * 2) + 8] = this.OutputCommandsNum; for (int i = 0; i < this.OutputCommandsList.Length; i++) { framedata[(i * 2) + ((this.InputCommandsList.Length) * 2) + 9] = this.OutputCommandsList[i].Lsb; framedata[(i * 2) + ((this.InputCommandsList.Length) * 2) + 10] = this.OutputCommandsList[i].Msb; } BuildPacket(new DoubleByte((ushort)ZToolCMD.ZB_APP_REGISTER_REQUEST), framedata); }
public ZB_FIND_DEVICE_CONFIRM(byte[] framedata) { SearchType = framedata[0]; SearchKey = new DoubleByte(framedata[1], framedata[2]); Result = new byte[8]; for (int i = 0; i < 8; i++) { this.Result[i] = framedata[i + 3]; } BuildPacket(new DoubleByte((ushort)ZToolCMD.ZB_FIND_DEVICE_CONFIRM), framedata); }
public ZB_RECEIVE_DATA_INDICATION(byte[] framedata) { Source = new ZToolAddress16(framedata[1], framedata[0]); Command = new DoubleByte(framedata[3], framedata[2]); Len = new DoubleByte(framedata[5], framedata[4]); Data = new byte[framedata.Length - 6]; for (int i = 0; i < Data.Length; i++) { Data[i] = framedata[i + 6]; } BuildPacket(new DoubleByte(ZToolCMD.ZB_RECEIVE_DATA_INDICATION), framedata); }
public ZDO_MSG_CB_INCOMING(byte[] framedata) { SrcAddr = new ZToolAddress16(framedata[1], framedata[0]); WasBroadcast = framedata[2]; ClusterId = new DoubleByte(framedata[4], framedata[3]); SecurityUse = framedata[5]; SeqNum = framedata[6]; MacDstAddr = new ZToolAddress16(framedata[8], framedata[7]); //Data = new byte[framedata.Length - 10]; //Array.Copy(framedata, 9, Data, 0, framedata.Length - 10); Data = framedata.Skip(9).ToArray(); // Arrays.copyOfRange(framedata, 9, framedata.Length); BuildPacket(new DoubleByte(ZToolCMD.ZDO_MSG_CB_INCOMING), framedata); }
public ZB_BIND_DEVICE(bool create, DoubleByte commandId, ZToolAddress64 destination) { Create = create; CommandId = commandId; Destination = destination; byte[] framedata = new byte[11]; framedata[0] = create ? (byte)0x01 : (byte)0x00; framedata[1] = commandId.Lsb; framedata[2] = commandId.Msb; byte[] dst = destination.Address; for (int i = 3; i < 8; i++) { framedata[i] = dst[i - 3]; } BuildPacket(new DoubleByte(ZToolCMD.ZB_BIND_DEVICE), framedata); }
public ZDO_NODE_DESC_RSP(byte[] framedata) { SrcAddr = new ZToolAddress16(framedata[1], framedata[0]); Status = (PacketStatus)framedata[2]; NwkAddr = new ZToolAddress16(framedata[4], framedata[3]); LogicalType = (ZigBeeNodeType)(framedata[5] & (byte)0x07); ComplexDescriptorAvailable = ((framedata[5] & (0x08)) >> 3) == 1; UserDescriptorAvailable = ((framedata[5] & (16)) >> 4) == 1; if (UserDescriptorAvailable) { APSFlags = (byte)(framedata[6] & (byte)0x0F); FrequencyBand = (byte)(framedata[6] & (byte)0xF0 >> 4); MacCapabilitiesFlags = (CapabilitiesFlags)framedata[10]; ManufacturerCode = new DoubleByte(framedata[11], framedata[12]); MaxBufferSize = framedata[13]; MaxInTransferSize = new DoubleByte(framedata[14], framedata[15]); ServerMask = new DoubleByte(framedata[16], framedata[17]); } BuildPacket(new DoubleByte(ZToolCMD.ZDO_NODE_DESC_RSP), framedata); }
public UTIL_GET_DEVICE_INFO_RESPONSE(byte[] framedata) { this.Status = framedata[0]; byte[] bytes = new byte[8]; for (int i = 0; i < 8; i++) { bytes[7 - i] = (byte)framedata[i + 1]; } this.IEEEAddr = new ZToolAddress64(bytes); this.ShortAddress = new ZToolAddress16(framedata[9], framedata[10]); this.DeviceType = framedata[11]; this.DeviceState = framedata[12]; this.NumAssocDevices = framedata[13]; // AssocDevicesList=new DoubleByte[(framedata.length-14)/2];//Actually more than NumAssocDevices AssocDevicesList = new DoubleByte[this.NumAssocDevices]; for (int i = 0; i < this.AssocDevicesList.Length; i++) { AssocDevicesList[i] = new DoubleByte(framedata[14 + (i * 2)], framedata[15 + (i * 2)]); } BuildPacket(new DoubleByte(ZToolCMD.UTIL_GET_DEVICE_INFO_RESPONSE), framedata); }
/// <name>TI.ZPI2.ZB_APP_REGISTER_REQUEST</name> /// <summary>Constructor</summary> public ZB_APP_REGISTER_REQUEST(byte num1, DoubleByte num2, DoubleByte num3, byte num4, byte num5, byte num6, DoubleByte[] numArray1, byte num7, DoubleByte[] numArray2) { this.AppEndPoint = num1; this.AppProfileID = num2; this.DeviceId = num3; this.DeviceVersion = num4; this.Unused = num5; this.InputCommandsNum = num6; this.InputCommandsList = new DoubleByte[numArray1.Length]; this.InputCommandsList = numArray1; this.OutputCommandsNum = num7; this.OutputCommandsList = new DoubleByte[numArray2.Length]; this.OutputCommandsList = numArray2; byte[] framedata = new byte[9 + this.InputCommandsList.Length * 2 + this.OutputCommandsList.Length * 2]; framedata[0] = this.AppEndPoint; framedata[1] = this.AppProfileID.Lsb; framedata[2] = this.AppProfileID.Msb; framedata[3] = this.DeviceId.Lsb; framedata[4] = this.DeviceId.Msb; framedata[5] = this.DeviceVersion; framedata[6] = this.Unused; framedata[7] = this.InputCommandsNum; for (int i = 0; i < this.InputCommandsList.Length; i++) { framedata[(i * 2) + 8] = this.InputCommandsList[i].Lsb; framedata[(i * 2) + 9] = this.InputCommandsList[i].Msb; } framedata[((this.InputCommandsList.Length) * 2) + 8] = this.OutputCommandsNum; for (int i = 0; i < this.OutputCommandsList.Length; i++) { framedata[(i * 2) + ((this.InputCommandsList.Length) * 2) + 9] = this.OutputCommandsList[i].Lsb; framedata[(i * 2) + ((this.InputCommandsList.Length) * 2) + 10] = this.OutputCommandsList[i].Msb; } BuildPacket(new DoubleByte((ushort)ZToolCMD.ZB_APP_REGISTER_REQUEST), framedata); }
/// <summary> /// Handle parsed packet. /// /// <param name="packet">the packet</param> /// </summary> public void HandlePacket(ZToolPacket packet) { DoubleByte cmdId = packet.CMD; switch (cmdId.Msb & 0xE0) { // Received incoming message which can be either message from dongle or remote device. case 0x40: Log.Debug("<-- Async incomming {Type} ({Packet})", packet.GetType().Name, ByteUtils.ToBase16(packet.Packet)); NotifyAsynchronousCommand(packet); break; // Received synchronous command response. case 0x60: Log.Debug("<-- Sync incomming {Type} ({Packet})", packet.GetType().Name, ByteUtils.ToBase16(packet.Packet)); NotifySynchronousCommand(packet); break; default: Log.Error("Received unknown packet. {Type}", packet.GetType().Name); break; } }
/// <summary> /// Notifies listeners about synchronous command response. /// /// <param name="packet">the received packet</param> /// </summary> private void NotifySynchronousCommand(ZToolPacket packet) { DoubleByte cmdId = packet.CMD; lock (_synchronousCommandListeners) { ushort id = (ushort)(cmdId.Value & 0x1FFF); _synchronousCommandListeners.TryGetValue(id, out ISynchronousCommandListener listener); if (listener != null) { listener.ReceivedCommandResponse(packet); _synchronousCommandListeners.Remove(id); _commandListenerSync.Set(); } else { // Notify asynchronous command listeners of unclaimed asynchronous command responses. IAsynchronousCommandListener[] listeners; lock (_asynchrounsCommandListeners) { listeners = _asynchrounsCommandListeners.ToArray(); } foreach (IAsynchronousCommandListener asynchronousCommandListener in listeners) { try { asynchronousCommandListener.ReceivedUnclaimedSynchronousCommandResponse(packet); } catch (Exception e) { Log.Error("Error in incoming asynchronous message processing: {Error}", e); } } } } }
public ZToolPacket ParsePacket() { Exception exception; Done = false; BytesRead = 0; try { ZToolPacket response; // int byteLength = this.read("Length"); _length = Read("Length"); // log.debug("data length is " + ByteUtils.formatByte(length.getLength())); byte[] frameData; byte apiIdMSB = Read("API PROFILE_ID_HOME_AUTOMATION MSB"); byte apiIdLSB = Read("API PROFILE_ID_HOME_AUTOMATION LSB"); DoubleByte apiId = new DoubleByte(apiIdMSB, apiIdLSB); // TODO Remove generic never used // generic = true; if (generic) { // log.info("Parsing data as generic"); int i = 0; frameData = new byte[_length]; // Read all data bytes without parsing while (i < frameData.Length) { frameData[i] = Read("Data " + i + "-th"); i++; } response = new ZToolPacket(apiId, frameData); } else { frameData = ReadRemainingBytes(); response = ParsePayload(apiId, frameData); } // response.setFCS(this.read("Checksum")); int fcs = Read("Checksum"); // setDone(true); if (fcs != response.FCS) { // log.debug("Checksum of packet failed: received =" + fcs + " expected = " + response.getFCS()); throw new ZToolParseException("Packet checksum failed"); } if (!Done) { // TODO this is not the answer! throw new ZToolParseException("Packet stream is not finished yet we seem to think it is"); } return(response); } catch (Exception e) { _logger.Error("Packet parsing failed due to exception.", e); exception = e; } ZToolPacket exceptionResponse = new ErrorPacket(); if (exception != null) { exceptionResponse.Error = true; exceptionResponse.ErrorMsg = exception.Message; } return(exceptionResponse); }
// PROTECTED? public ZToolPacket(DoubleByte ApiId, byte[] frameData) { BuildPacket(ApiId, frameData); }
public ZDO_UNBIND_REQ(ZToolAddress16 nwkDst, ZToolAddress64 ieeeSrc, byte epSrc, DoubleByte cluster, byte addressingMode, ZToolAddress64 ieeeDst, byte epDst) { byte[] framedata; if (addressingMode == 3) { framedata = new byte[23]; } else { framedata = new byte[16]; } framedata[0] = nwkDst.Lsb; framedata[1] = nwkDst.Msb; byte[] bytes = ieeeSrc.Address; for (int i = 0; i < 8; i++) { framedata[i + 2] = (byte)(bytes[7 - i] & 0xFF); } framedata[10] = epSrc; framedata[11] = cluster.Lsb; framedata[12] = cluster.Msb; framedata[13] = addressingMode; bytes = ieeeDst.Address; if (addressingMode == 3) { for (int i = 0; i < 8; i++) { framedata[i + 14] = (byte)(bytes[7 - i] & 0xFF); } framedata[22] = epDst; } else { framedata[14] = bytes[7]; framedata[15] = bytes[6]; } BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_UNBIND_REQ), framedata); }
/// <summary> /// Sends synchronous command and adds listener. /// /// <param name="packet">the command packet</param> /// <param name="listener">the synchronous command response listener</param> /// <param name="timeoutMillis">the timeout</param> /// @throws IOException if IO exception occurs in packet sending /// </summary> public void SendSynchronousCommand(ZToolPacket packet, ISynchronousCommandListener listener, long timeoutMillis) { if (timeoutMillis == -1L) { _synchronousCommandListenerTimeouts[listener] = -1L; } else { long expirationTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + timeoutMillis; _synchronousCommandListenerTimeouts[listener] = expirationTime; } DoubleByte cmdId = packet.CMD; int value = (cmdId.Msb & 0xE0); if (value != 0x20) { throw new ArgumentException("You are trying to send a non SREQ packet as synchronous command. " + "Evaluated " + value + " instead of " + 0x20 + "\nPacket " + packet.GetType().Name + "\n" + packet); } CleanExpiredSynchronousCommandListeners(); if (_supportMultipleSynchrounsCommand) { lock (_synchronousCommandListeners) { ushort id = (ushort)(cmdId.Value & 0x1FFF); while (_synchronousCommandListeners.ContainsKey(cmdId.Value)) { try { Log.Verbose("Waiting for other request {Command} to complete", id); _commandListenerSync.Wait(500); CleanExpiredSynchronousCommandListeners(); } catch (Exception ignored) { } } _synchronousCommandListeners[id] = listener; } } else { lock (_synchronousCommandListeners) { ushort id = (ushort)(cmdId.Value & 0x1FFF); while (!(_synchronousCommandListeners.Count == 0)) { try { Log.Verbose("Waiting for other request to complete"); _commandListenerSync.Wait(500); CleanExpiredSynchronousCommandListeners(); } catch (Exception ignored) { } } Log.Verbose("Put synchronousCommandListeners listener for {Command} command", id); _synchronousCommandListeners[id] = listener; } } Log.Verbose("Sending SynchronousCommand {Packet} ", packet); SendPacket(packet); }
public UTIL_SET_PANID(byte[] framedata) { this.PanID = new DoubleByte(framedata[1], framedata[0]); BuildPacket(new DoubleByte(ZToolCMD.UTIL_SET_PANID), framedata); }
public static ZToolPacket ParsePayload(DoubleByte cmd, byte[] payload) { switch ((ZToolCMD)cmd.Value) { case ZToolCMD.SYS_RESET_RESPONSE: return(new SYS_RESET_RESPONSE(payload)); case ZToolCMD.SYS_VERSION_RESPONSE: return(new SYS_VERSION_RESPONSE(payload)); case ZToolCMD.SYS_PING_RESPONSE: return(new SYS_PING_RESPONSE(payload)); case ZToolCMD.SYS_RPC_ERROR: return(new SYS_RPC_ERROR(payload)); case ZToolCMD.SYS_TEST_LOOPBACK_SRSP: return(new SYS_TEST_LOOPBACK_SRSP(payload)); case ZToolCMD.AF_DATA_CONFIRM: return(new AF_DATA_CONFIRM(payload)); case ZToolCMD.AF_DATA_SRSP: return(new AF_DATA_REQUEST_SRSP(payload)); case ZToolCMD.AF_DATA_SRSP_EXT: return(new AF_DATA_SRSP_EXT(payload)); case ZToolCMD.AF_INCOMING_MSG: return(new AF_INCOMING_MSG(payload)); case ZToolCMD.AF_REGISTER_SRSP: return(new AF_REGISTER_SRSP(payload)); case ZToolCMD.ZB_ALLOW_BIND_CONFIRM: return(new ZB_ALLOW_BIND_CONFIRM(payload)); case ZToolCMD.ZB_ALLOW_BIND_RSP: return(new ZB_ALLOW_BIND_RSP(payload)); case ZToolCMD.ZB_APP_REGISTER_RSP: return(new ZB_APP_REGISTER_RSP(payload)); case ZToolCMD.ZB_BIND_CONFIRM: return(new ZB_BIND_CONFIRM(payload)); case ZToolCMD.ZB_BIND_DEVICE_RSP: return(new ZB_BIND_DEVICE_RSP(payload)); case ZToolCMD.ZB_FIND_DEVICE_CONFIRM: return(new ZB_FIND_DEVICE_CONFIRM(payload)); case ZToolCMD.ZB_FIND_DEVICE_REQUEST_RSP: return(new ZB_FIND_DEVICE_REQUEST_RSP()); case ZToolCMD.ZB_GET_DEVICE_INFO_RSP: return(new ZB_GET_DEVICE_INFO_RSP(payload)); case ZToolCMD.ZB_PERMIT_JOINING_REQUEST_RSP: return(new ZB_PERMIT_JOINING_REQUEST_RSP(payload)); case ZToolCMD.ZB_READ_CONFIGURATION_RSP: return(new ZB_READ_CONFIGURATION_RSP(payload)); case ZToolCMD.ZB_RECEIVE_DATA_INDICATION: return(new ZB_RECEIVE_DATA_INDICATION(payload)); case ZToolCMD.ZB_SEND_DATA_CONFIRM: return(new ZB_SEND_DATA_CONFIRM(payload)); case ZToolCMD.ZB_SEND_DATA_REQUEST_RSP: return(new ZB_SEND_DATA_REQUEST_RSP(payload)); case ZToolCMD.ZB_START_CONFIRM: return(new ZB_START_CONFIRM(payload)); case ZToolCMD.ZB_START_REQUEST_RSP: return(new ZB_START_REQUEST_RSP(payload)); case ZToolCMD.ZB_WRITE_CONFIGURATION_RSP: return(new ZB_WRITE_CONFIGURATION_RSP(payload)); //case ZToolCMD.ZDO_ACTIVE_EP_REQ_SRSP: // return new ZDO_ACTIVE_EP_REQ_SRSP(payload); //case ZToolCMD.ZDO_ACTIVE_EP_RSP: // return new ZDO_ACTIVE_EP_RSP(payload); //case ZToolCMD.ZDO_BIND_REQ_SRSP: // return new ZDO_BIND_REQ_SRSP(payload); //case ZToolCMD.ZDO_BIND_RSP: // return new ZDO_BIND_RSP(payload); //case ZToolCMD.ZDO_END_DEVICE_ANNCE_IND: // return new ZDO_END_DEVICE_ANNCE_IND(payload); //case ZToolCMD.ZDO_END_DEVICE_ANNCE_SRSP: // return new ZDO_END_DEVICE_ANNCE_SRSP(payload); //case ZToolCMD.ZDO_END_DEVICE_BIND_REQ_SRSP: // return new ZDO_END_DEVICE_BIND_REQ_SRSP(payload); //case ZToolCMD.ZDO_END_DEVICE_BIND_RSP: // return new ZDO_END_DEVICE_BIND_RSP(payload); //case ZToolCMD.ZDO_IEEE_ADDR_REQ_SRSP: // return new ZDO_IEEE_ADDR_REQ_SRSP(payload); //case ZToolCMD.ZDO_IEEE_ADDR_RSP: // return new ZDO_IEEE_ADDR_RSP(payload); //case ZToolCMD.ZDO_MATCH_DESC_REQ_SRSP: // return new ZDO_MATCH_DESC_REQ_SRSP(payload); //case ZToolCMD.ZDO_MATCH_DESC_RSP: // return new ZDO_MATCH_DESC_RSP(payload); //case ZToolCMD.ZDO_MGMT_LEAVE_REQ_SRSP: // return new ZDO_MGMT_LEAVE_REQ_SRSP(payload); //case ZToolCMD.ZDO_MGMT_LEAVE_RSP: // return new ZDO_MGMT_LEAVE_RSP(payload); //case ZToolCMD.ZDO_MGMT_LQI_REQ_SRSP: // return new ZDO_MGMT_LQI_REQ_SRSP(payload); //case ZToolCMD.ZDO_MGMT_LQI_RSP: // return new ZDO_MGMT_LQI_RSP(payload); //case ZToolCMD.ZDO_MGMT_NWK_UPDATE_REQ_SRSP: // return new ZDO_MGMT_NWK_UPDATE_REQ_SRSP(payload); //case ZToolCMD.ZDO_MGMT_PERMIT_JOIN_REQ_SRSP: // return new ZDO_MGMT_PERMIT_JOIN_REQ_SRSP(payload); //case ZToolCMD.ZDO_MGMT_PERMIT_JOIN_RSP: // return new ZDO_MGMT_PERMIT_JOIN_RSP(payload); //case ZToolCMD.ZDO_MGMT_RTG_RSP: // return new ZDO_MGMT_RTG_RSP(payload); //case ZToolCMD.ZDO_MSG_CB_INCOMING: // ZDO_MSG_CB_INCOMING incoming = new ZDO_MSG_CB_INCOMING(payload); // return incoming.Translate(); //case ZToolCMD.ZDO_NODE_DESC_REQ_SRSP: // return new ZDO_NODE_DESC_REQ_SRSP(payload); //case ZToolCMD.ZDO_NODE_DESC_RSP: // return new ZDO_NODE_DESC_RSP(payload); //case ZToolCMD.ZDO_POWER_DESC_REQ_SRSP: // return new ZDO_POWER_DESC_REQ_SRSP(payload); //case ZToolCMD.ZDO_POWER_DESC_RSP: // return new ZDO_POWER_DESC_RSP(payload); //case ZToolCMD.ZDO_NWK_ADDR_REQ_SRSP: // return new ZDO_NWK_ADDR_REQ_SRSP(payload); //case ZToolCMD.ZDO_NWK_ADDR_RSP: // return new ZDO_NWK_ADDR_RSP(payload); //case ZToolCMD.ZDO_SIMPLE_DESC_REQ_SRSP: // return new ZDO_SIMPLE_DESC_REQ_SRSP(payload); //case ZToolCMD.ZDO_SIMPLE_DESC_RSP: // return new ZDO_SIMPLE_DESC_RSP(payload); //case ZToolCMD.ZDO_TC_DEVICE_IND: // return new ZDO_TC_DEVICE_IND(payload); //case ZToolCMD.ZDO_UNBIND_REQ_SRSP: // return new ZDO_UNBIND_REQ_SRSP(payload); //case ZToolCMD.ZDO_UNBIND_RSP: // return new ZDO_UNBIND_RSP(payload); //case ZToolCMD.ZDO_USER_DESC_REQ_SRSP: // return new ZDO_USER_DESC_REQ_SRSP(payload); //case ZToolCMD.ZDO_USER_DESC_RSP: // return new ZDO_USER_DESC_RSP(payload); //case ZToolCMD.ZDO_USER_DESC_CONF: // return new ZDO_USER_DESC_CONF(payload); //case ZToolCMD.ZDO_USER_DESC_SET_SRSP: // return new ZDO_USER_DESC_SET_SRSP(payload); case ZToolCMD.ZDO_STATE_CHANGE_IND: return(new ZDO_STATE_CHANGE_IND(payload)); case ZToolCMD.ZDO_STATUS_ERROR_RSP: return(new ZDO_STATUS_ERROR_RSP(payload)); case ZToolCMD.ZDO_MSG_CB_REGISTER_SRSP: return(new ZDO_MSG_CB_REGISTER_SRSP(payload)); case ZToolCMD.ZDO_STARTUP_FROM_APP_SRSP: return(new ZDO_STARTUP_FROM_APP_SRSP(payload)); case ZToolCMD.UTIL_SET_PANID_RESPONSE: return(new UTIL_SET_PANID_RESPONSE(payload)); case ZToolCMD.UTIL_SET_CHANNELS_RESPONSE: return(new UTIL_SET_CHANNELS_RESPONSE(payload)); case ZToolCMD.UTIL_GET_DEVICE_INFO_RESPONSE: return(new UTIL_GET_DEVICE_INFO_RESPONSE(payload)); case ZToolCMD.UTIL_LED_CONTROL_RESPONSE: return(new UTIL_LED_CONTROL_RESPONSE(payload)); default: _logger.Warn("Unknown command ID: {Command}", cmd); return(new ZToolPacket(cmd, payload)); } }