public void ReqSendCommand(byte cmd0, byte cmd1, byte seq, byte stry, byte[] data) { Send_t snd = new Send_t(); snd.cmd0 = cmd0; snd.cmd1 = cmd1; snd.seq = seq; snd.runtime = ZigbeeApi.myZtool.GetSendTimeout(); snd.stry = stry; snd.data = new byte[data.Length]; Array.Copy(data, snd.data, data.Length); if (SendList != null) { if (snd.cmd0 == 0x29) { UInt16 addr = ZigbeeCommon.BtoU16(data, 0); byte point = data[2]; UInt16 cID = ZigbeeCommon.BtoU16(data, 5); byte dlen = data[7]; byte[] buf = new byte[dlen]; Array.Copy(data, 8, buf, 0, dlen); ZigbeeApi.myZtool.UpdateTestCommandInfo(ZigbeeApi.Device.GetDeviceCount(), addr, point, cID, buf); ZigbeeApi.Device.SendCount(addr); } SendList.Add(snd); } }
public void Poll() { try { if (SendList.Count > 0) { Send_t pkg = (Send_t)SendList[0]; if (pkg.runtime >= ZigbeeCommon.Tick) { pkg.runtime = pkg.runtime - ZigbeeCommon.Tick; } else { pkg.runtime = 0; } if (pkg.runtime == 0) { pkg.runtime = ZigbeeApi.myZtool.GetSendTimeout(); if (pkg.stry > 0) { Send(pkg.cmd0, pkg.cmd1, pkg.data); pkg.stry--; return; } else { if (pkg.cmd0 == 0x29) { UInt16 addr = ZigbeeCommon.BtoU16(pkg.data, 0); ZigbeeApi.Device.LossCount(addr); } SendList.Remove(pkg); } } } } catch (System.InvalidOperationException ex) { return; } }