Beispiel #1
0
        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     = ByteHelper.ShortFromBytes(framedata[8], framedata[7]);
                DeviceId      = ByteHelper.ShortFromBytes(framedata[10], framedata[9]);
                DeviceVersion = framedata[11];

                NumInClusters = framedata[12];
                InClusterList = new ushort[NumInClusters];

                for (int i = 0; i < NumInClusters; i++)
                {
                    InClusterList[i] = ByteHelper.ShortFromBytes(framedata[(i * 2) + 14], framedata[(i * 2) + 13]);
                }

                NumOutClusters = framedata[((NumInClusters) * 2) + 13];
                OutClusterList = new ushort[NumOutClusters];

                for (int i = 0; i < NumOutClusters; i++)
                {
                    OutClusterList[i] = ByteHelper.ShortFromBytes(framedata[(i * 2) + ((NumInClusters) * 2) + 15],
                                                                  framedata[(i * 2) + ((NumInClusters) * 2) + 14]);
                }

                BuildPacket((ushort)ZToolCMD.ZDO_SIMPLE_DESC_RSP, framedata);
            }
        }
        public ZDO_MGMT_PERMIT_JOIN_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket((ushort)ZToolCMD.ZDO_MGMT_PERMIT_JOIN_RSP, data);
        }
Beispiel #3
0
        public ZDO_BIND_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_BIND_RSP), data);
        }
Beispiel #4
0
        public ZB_ALLOW_BIND_CONFIRM(byte[] framedata)
        {
            Source = new ZToolAddress16(framedata[1], framedata[0]);


            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZB_ALLOW_BIND_CONFIRM), framedata);
        }
Beispiel #5
0
        public ZB_SEND_DATA_REQUEST(ZToolAddress16 destination, ushort 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.GetLSB();
            framedata[3] = CommandId.GetMSB();
            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((ushort)ZToolCMD.ZB_SEND_DATA_REQUEST, framedata);
        }
Beispiel #6
0
        public ZDO_USER_DESC_SET(ZToolAddress16 num1, ZToolAddress16 num2, byte num3, byte[] buffer1)
        {
            this.DstAddr    = num1;
            this.NwkAddr    = num2;
            this.DescLen    = num3;
            this.Descriptor = new byte[buffer1.Length];
            this.Descriptor = buffer1;

            /*
             * if (buffer1.Length > 15)
             * {
             * throw new Exception("Error creating object.");
             * }
             * this.Descriptor = new byte[15];
             * Array.Copy(buffer1, this.Descriptor, buffer1.Length);
             */

            byte[] framedata = new byte[5 + this.Descriptor.Length];
            framedata[0] = this.DstAddr.Lsb;
            framedata[1] = this.DstAddr.Msb;
            framedata[2] = this.NwkAddr.Lsb;
            framedata[3] = this.NwkAddr.Msb;
            framedata[4] = this.DescLen;
            for (int i = 0; i < this.Descriptor.Length; i++)
            {
                framedata[i + 5] = this.Descriptor[i];
            }
            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_USER_DESC_SET), framedata);
        }
Beispiel #7
0
        public ZDO_STATUS_ERROR_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket(new DoubleByte(ZToolCMD.ZDO_STATUS_ERROR_RSP), data);
        }
Beispiel #8
0
        public AF_INCOMING_MSG(byte[] framedata)
        {
            GroupId      = ByteHelper.ShortFromBytes(framedata[1], framedata[0]);
            ClusterId    = ByteHelper.ShortFromBytes(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((ushort)ZToolCMD.AF_INCOMING_MSG, framedata);
        }
        public ZDO_STATUS_ERROR_RSP(byte[] data)
        {
            SrcAddr = new ZToolAddress16(data[1], data[0]);
            Status  = (PacketStatus)data[2];

            BuildPacket((ushort)ZToolCMD.ZDO_STATUS_ERROR_RSP, data);
        }
Beispiel #10
0
        public ZDO_END_DEVICE_ANNCE_IND(byte[] framedata)
        {
            SrcAddr      = new ZToolAddress16(framedata[1], framedata[0]);
            NwkAddr      = new ZToolAddress16(framedata[3], framedata[2]);
            IEEEAddr     = new ZToolAddress64(BitConverter.ToInt64(framedata, 4));
            Capabilities = framedata[12];

            BuildPacket((ushort)ZToolCMD.ZDO_END_DEVICE_ANNCE_IND, framedata);
        }
Beispiel #11
0
        public ZDO_ACTIVE_EP_REQ(ZToolAddress16 dstAddr, ZToolAddress16 nwkAddrOfInterest)
        {
            byte[] framedata = new byte[4];
            framedata[0] = dstAddr.Lsb;
            framedata[1] = dstAddr.Msb;
            framedata[2] = nwkAddrOfInterest.Lsb;
            framedata[3] = nwkAddrOfInterest.Msb;

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_ACTIVE_EP_REQ), framedata);
        }
Beispiel #12
0
 public NeighborLqiListItemClass(long extendedPanID, ZToolAddress64 extendedAddress,
                                 ZToolAddress16 networkAddress, int flags, int joining, int depth, int rxLqi)
 {
     this.extendedPanID   = extendedPanID;
     this.extendedAddress = extendedAddress;
     this.networkAddress  = networkAddress;
     this.Reserved_Relationship_RxOnWhenIdle_DeviceType = flags;
     this.Reserved_PermitJoining = joining;
     this.depth = depth;
     this.rxLQI = rxLqi;
 }
Beispiel #13
0
        /// <name>TI.ZPI1.ZDO_MGMT_LQI_REQ</name>
        /// <summary>Constructor</summary>
        public ZDO_MGMT_LQI_REQ(ZToolAddress16 num1, byte num2)
        {
            this.DstAddr    = num1;
            this.StartIndex = num2;

            byte[] framedata = new byte[3];
            framedata[0] = this.DstAddr.Lsb;
            framedata[1] = this.DstAddr.Msb;
            framedata[2] = this.StartIndex;
            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_MGMT_LQI_REQ), framedata);
        }
        public ZDO_SIMPLE_DESC_REQ(ZToolAddress16 nwkAddr, byte endPoint)
        {
            byte[] framedata = new byte[5];

            framedata[0] = nwkAddr.Lsb;
            framedata[1] = nwkAddr.Msb;
            framedata[2] = nwkAddr.Lsb;
            framedata[3] = nwkAddr.Msb;
            framedata[4] = endPoint;

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_SIMPLE_DESC_REQ), framedata);
        }
Beispiel #15
0
        public ZDO_USER_DESC_REQ(ZToolAddress16 num1, ZToolAddress16 num2)
        {
            this.DstAddr = num1;
            this.NwkAddr = num2;

            byte[] framedata = new byte[4];
            framedata[0] = this.DstAddr.Lsb;
            framedata[1] = this.DstAddr.Msb;
            framedata[2] = this.NwkAddr.Lsb;
            framedata[3] = this.NwkAddr.Msb;

            BuildPacket((ushort)ZToolCMD.ZDO_USER_DESC_REQ, framedata);
        }
Beispiel #16
0
        public ZDO_NODE_DESC_REQ(ZToolAddress16 dstAddr, ZToolAddress16 nwkAddrOfinterest)
        {
            DstAddr           = dstAddr;
            NwkAddrOfInterest = nwkAddrOfinterest;

            byte[] framedata = new byte[4];
            framedata[0] = DstAddr.Lsb;
            framedata[1] = DstAddr.Msb;
            framedata[2] = NwkAddrOfInterest.Lsb;
            framedata[3] = NwkAddrOfInterest.Msb;

            BuildPacket((ushort)ZToolCMD.ZDO_NODE_DESC_REQ, framedata);
        }
Beispiel #17
0
        public ZDO_TC_DEVICE_IND(byte[] framedata)
        {
            SrcAddr = new ZToolAddress16(framedata[1], framedata[0]);
            byte[] bytes = new byte[8];
            for (int i = 0; i < 8; i++)
            {
                bytes[i] = framedata[9 - i];
            }
            IeeeAddr = new ZToolAddress64(bytes);
            NwkAddr  = new ZToolAddress16(framedata[11], framedata[10]);

            BuildPacket((ushort)ZToolCMD.ZDO_TC_DEVICE_IND, framedata);
        }
 public ZDO_USER_DESC_CONF(byte[] framedata)
 {
     this.SrcAddress = new ZToolAddress16(framedata[1], framedata[0]);
     this.Status     = framedata[2];
     if (framedata.Length == 5)
     {
         this.NwkAddr = new ZToolAddress16(framedata[4], framedata[3]);
     }
     else
     {
         this.NwkAddr = new ZToolAddress16();
     }
     BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_USER_DESC_CONF), 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 ZB_RECEIVE_DATA_INDICATION(byte[] framedata)
        {
            Source  = new ZToolAddress16(framedata[1], framedata[0]);
            Command = ByteHelper.ShortFromBytes(framedata[3], framedata[2]);
            Len     = ByteHelper.ShortFromBytes(framedata[5], framedata[4]);
            Data    = new byte[framedata.Length - 6];

            for (int i = 0; i < Data.Length; i++)
            {
                Data[i] = framedata[i + 6];
            }

            BuildPacket((ushort)ZToolCMD.ZB_RECEIVE_DATA_INDICATION, framedata);
        }
Beispiel #21
0
        public ZDO_IEEE_ADDR_REQ(ZToolAddress16 shortAddress, RequestType reqType, byte startIndex)
        {
            ShortAddress = shortAddress;
            ReqType      = reqType;
            StartIndex   = startIndex;

            List <byte> data = new List <byte>();

            data.AddRange(ShortAddress.Address);
            data.Add((byte)ReqType);
            data.Add(StartIndex);

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_IEEE_ADDR_REQ), data.ToArray());
        }
Beispiel #22
0
        public ZDO_ACTIVE_EP_RSP(byte[] framedata)
        {
            SrcAddr = new ZToolAddress16(framedata[1], framedata[0]);
            Status  = (PacketStatus)framedata[2];
            NwkAddr = new ZToolAddress16(framedata[4], framedata[3]);

            ActiveEPCount = framedata[5];
            ActiveEpList  = new byte[ActiveEPCount];
            for (int i = 0; i < ActiveEpList.Length; i++)
            {
                ActiveEpList[i] = framedata[i + 6];
            }

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_ACTIVE_EP_RSP), framedata);
        }
        public ZDO_END_DEVICE_ANNCE(ZToolAddress16 num1, ZToolAddress64 num2, int capability_info1)
        {
            this.nwkAddr      = num1;
            this.IEEEAddress  = num2;
            this.Capabilities = capability_info1;

            byte[] framedata = new byte[11];
            framedata[0] = this.nwkAddr.Lsb;
            framedata[1] = this.nwkAddr.Msb;
            byte[] bytes = this.IEEEAddress.Address;
            for (int i = 0; i < 8; i++)
            {
                framedata[i + 2] = bytes[7 - i];
            }
            BuildPacket((ushort)ZToolCMD.ZDO_END_DEVICE_ANNCE, framedata);
        }
Beispiel #24
0
        public ZDO_MGMT_LEAVE_REQ(ZToolAddress16 num1, ZToolAddress64 num2, byte flag1)
        {
            this.DstAddr               = num1;
            this.DeviceAddress         = num2;
            this.RemoveChildren_Rejoin = flag1;

            byte[] framedata = new byte[11];
            framedata[0] = this.DstAddr.Lsb;
            framedata[1] = this.DstAddr.Msb;
            for (int i = 0; i < 8; i++)
            {
                framedata[2 + i] = this.DeviceAddress.Address[7 - i];
            }
            framedata[10] = this.RemoveChildren_Rejoin;
            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_MGMT_LEAVE_REQ), framedata);
        }
Beispiel #25
0
        public ZDO_MGMT_PERMIT_JOIN_REQ(byte addrMode, ZToolAddress16 dstAddr, byte duration, bool tcsSignificant)
        {
            AddrMode       = addrMode;
            DstAddr        = dstAddr;
            Duration       = duration;
            TCSignificance = tcsSignificant ? (byte)0x01 : (byte)0x00;

            List <byte> data = new List <byte>();

            data.Add(AddrMode);
            data.AddRange(DstAddr.Address);
            data.Add(Duration);
            data.Add(TCSignificance);

            BuildPacket(new DoubleByte((ushort)ZToolCMD.ZDO_MGMT_PERMIT_JOIN_REQ), data.ToArray());
        }
Beispiel #26
0
        public ZDO_IEEE_ADDR_RSP(byte[] data)
        {
            Status      = (PacketStatus)data[0];
            IeeeAddr    = new ZToolAddress64(BitConverter.ToInt64(data, 1));
            NwkAddr     = new ZToolAddress16(data[10], data[9]);
            StartIndex  = data[11];
            NumAssocDev = data[12];

            AssocDevList = new List <ZToolAddress16>();
            for (int i = 0; i < AssocDevList.Count; i++)
            {
                this.AssocDevList[i] = new ZToolAddress16(data[14 + (i * 2)], data[13 + (i * 2)]);
            }

            BuildPacket((ushort)ZToolCMD.ZDO_IEEE_ADDR_RSP, data);
        }
        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);
        }
Beispiel #28
0
        public ZDO_BIND_REQ(ZToolAddress16 nwkDst, ZToolAddress64 ieeeSrc, byte epSrc, DoubleByte cluster,
                            Address_Mode addressingMode, ZToolAddress64 ieeeDst, byte epDst)
        {
            byte[] framedata;
            if (addressingMode == Address_Mode.ADDRESS_64_BIT)
            {
                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] = (byte)addressingMode;
            bytes         = ieeeDst.Address;
            if (addressingMode == Address_Mode.ADDRESS_64_BIT)
            {
                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_BIND_REQ), 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);
        }
Beispiel #30
0
        public ZDO_MGMT_LQI_RSP(byte[] framedata)
        {
            SrcAddress = new ZToolAddress16(framedata[1], framedata[0]);
            Status     = framedata[2];
            if (framedata.Length > 3)
            {
                NeighborLQIEntries = framedata[3];
                StartIndex         = framedata[4];
                NeighborLQICount   = framedata[5];
                NeighborLqiList    = new NeighborLqiListItemClass[framedata[5]];

                int NOpt1;
                int NOpt2;

                int    k     = 0;
                byte[] bytes = new byte[8];
                for (int z = 0; z < this.NeighborLqiList.Length; z++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        bytes[7 - j] = (byte)framedata[6 + k + j];/// MSB><LSB?
                    }
                    long panId = ByteUtils.ConvertMultiByteToLong(bytes);
                    for (int j = 0; j < 8; j++)
                    {
                        bytes[7 - j] = (byte)framedata[14 + k + j];/// MSB><LSB?
                    }
                    ZToolAddress64 ieeeAddr = new ZToolAddress64(bytes);
                    ZToolAddress16 nwkAddr  = new ZToolAddress16(framedata[23 + k], framedata[22 + k]);/// MSB><LSB?
                    NOpt1 = framedata[24 + k];
                    NOpt2 = framedata[25 + k];
                    byte lqi   = framedata[26 + k];
                    byte depth = framedata[27 + k];
                    NeighborLqiList[z] = new NeighborLqiListItemClass(panId, ieeeAddr, nwkAddr, NOpt1, NOpt2, lqi, depth);
                    k += 22;
                }
            }
            BuildPacket((ushort)ZToolCMD.ZDO_MGMT_LQI_RSP, framedata);
        }