예제 #1
0
        private void _LightCtrl(byte data)
        {
            // 生成数据包
            byte[] temp = new byte[GestureControl.PackageHeadLen + 2];
            temp[0] = GestureControl.PackageHead;
            temp[1] = 2;
            temp[2] = (byte)ZIGBEE_CLUST_ID.CTRL_LED_ID;
            temp[3] = 0xFF;
            temp[4] = 0xFF;
            temp[5] = (byte)ZigBeeCMD.CMD_CTRL;
            temp[6] = data;
            GestureControl gc = new GestureControl(temp);

            // 发送数据
            GestureControl gcRcv = SendToSensorNet(gc);
            WriteLine("send message to[" + SENSOR_NET_ADDRESS.ToString() + "]");

            if (null != gcRcv)
                WriteLine("recive [" + gcRcv.Data[2].ToString() + "]");
        }
예제 #2
0
        private GestureControl SendToSensorNet(GestureControl gc)
        {
            byte[] byData = gc.ToArray();
            byte[] byRcv = null;
            IPEndPoint ipRcv = null;

            try
            {
                m_UdpSensorNet.Send(byData, byData.Length, SENSOR_NET_ADDRESS);
                //byRcv = m_UdpSensorNet.Receive(ref ipRcv);
            }
            catch (Exception ex)
            {
                WriteLine(ex.Message);
            }

            if (null != ipRcv &&
                null != byRcv &&
                ipRcv.Equals(SENSOR_NET_ADDRESS) &&
                byRcv.Length >= byData.Length)
                return new GestureControl(byRcv);
            else
                return null;
        }