public static byte[] ZigBee_WriteKeyMsg(uint OnlyAddr, byte[] Data, uint L) { byte[] Buf = new byte[1500]; int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, OnlyAddr, (byte)ACFF.SCFF_GetSendKeyMsg, Data, (byte)L); ZigBeeBus.ZigBee_CheckCrc(Buf); byte[] Temp = new byte[Length]; for (int i = 0; i < Length; i++) { Temp[i] = Buf[i]; } return(Buf); }
private void SendKey() { byte[] Data = new byte[2]; while (Value.App_Run) { if (Value.KeyValue > 0) { Data[0] = (byte)Value.KeyValue; Value.KeyMsg.Key_Value = Value.KeyValue; Value.KeyValue = 0; byte[] Buf = ZigBeeBus.ZigBee_WriteKeyMsg(0x00, Data, 2); try { serialPort1.Write(Buf, 0, Buf.Length); serialPort1.Write(Data, 0, Data.Length); } catch { ComError = true; } } Thread.Sleep(6); } }