예제 #1
0
		/// <summary>
		/// Send Bind Request to a Node Hosting a Binding Table
		/// </summary>
		/// <param name="shortSrcAddress">Short address of destination node of request (client device to bind to). This
		/// may or may not be the node holding the binding table.</param>
		/// <param name="srcAddress">IEEE address of the source node for the binding (client device to bind to)</param>
		/// <param name="srcEndPoint">Binding source endpoint</param>
		/// <param name="clustID">Cluster ID to match</param>
		/// <param name="dstAdd">Destination Address</param>
		/// <param name="dstEndPoint">Destination endpoint</param>
		/// <returns>Bind Request packet</returns>
		public static CidPacket BindRequest(UInt16 shortSrcAddress, UInt64 srcAddress,
			byte srcEndPoint, ZigbeeNet.Clusters.ClusterID clustID, UInt64 dstAdd, byte dstEndPoint)
		{
			byte[] u8AddMode = new byte[] { 0x01 }; //16bit IEEE
			byte[] uAddress = BitHelpers.GetBytes(shortSrcAddress).ToArray();
			byte[] u64SrcAddr = BitHelpers.GetBytes(srcAddress).ToArray();
			byte[] u8SrcEPt = new byte[] { srcEndPoint };
			byte[] u16ClstrID = BitHelpers.GetBytes((ushort)clustID).ToArray();
			byte[] u8DstMode = new byte[] { 0x03 }; //64bit IEEE
			byte[] u64DstAddr = BitHelpers.GetBytes(dstAdd).ToArray();
			byte[] u8DstEPt = new byte[] { dstEndPoint };
			var data = Merge(new byte[][] { u8AddMode, uAddress, u64SrcAddr, 
				u8SrcEPt, u16ClstrID, u8DstMode, u64DstAddr, u8DstEPt });
			return new CidPacket(new byte[] { 0x00, 0x20 }, data.ToArray() );
		}
예제 #2
0
		public static CidPacket DiscoverAttributes(ushort deviceAddress, byte destEndpoint, ZigbeeNet.Clusters.ClusterID clusterID)
		{
			return SendCommand(false, false, true, false, 0,
				deviceAddress, destEndpoint, clusterID, 0x0C, new byte[] { 0x00,0x00,0xFF }
				);
		}
예제 #3
0
		public static CidPacket SendCommand(bool forceApsSecurity, bool disableDefaultResponse, bool directionIsServerToClient, bool isCrossProfile,
			ushort manufacturerCode, ushort deviceAddrs, byte destEndpoint, ZigbeeNet.Clusters.ClusterID clusterID, byte commandID, byte[] payload)
		{
			byte u8Mode = 0x01; //dst is short
			if (forceApsSecurity)
				u8Mode = (byte)(u8Mode | 8);
			if (disableDefaultResponse)
				u8Mode = (byte)(u8Mode | 16);
			if (directionIsServerToClient)
				u8Mode = (byte)(u8Mode | 32);
			if (manufacturerCode > 0)
				u8Mode = (byte)(u8Mode | 64);
			if (isCrossProfile)
				u8Mode = (byte)(u8Mode | 128);
			u8Mode = 0x92;
			byte[] pid = BitConverter.GetBytes(deviceAddrs);
			byte[] mcode = BitConverter.GetBytes(manufacturerCode);
			byte[] cid = BitConverter.GetBytes((ushort)clusterID);

			byte[] header1;
			if (manufacturerCode > 0)
				header1 = new byte[] { 
				u8Mode, //
				mcode[1], mcode[0] //Manufacturer Code (if bit 6 is set in u8Mode) 
				};
			else
				header1 = new byte[] { u8Mode };
			byte[] header2 = new byte[] { 
				 pid[1], pid[0], //Network address of the device being addressed 
				 destEndpoint, //Destination endpoint 
				 cid[1], cid[0], //Cluster ID being addressed 
				 commandID // Command identifier
			};
			byte[] data = Merge(new byte[][] { header1, header2, payload }).ToArray();
			//string debug = string.Join(",", data.Select(b => b.ToString("X2")));
			return new CidPacket(new byte[] { 0x00, 0x30 }, data);
		}
예제 #4
0
		public static CidPacket ReadAttributes(ushort deviceAddress, byte destEndpoint, ZigbeeNet.Clusters.ClusterID clusterID, ushort[] attrList)
		{
			byte[] payload = new byte[1 + attrList.Length * 2 ];
			payload[0] = (byte)attrList.Length;
			for (int i = 0; i < attrList.Length; i++)
			{
				byte[] pid = BitConverter.GetBytes(attrList[i]);
				payload[1 + i * 2] = pid[1];
				payload[1 + i * 2 + 1] = pid[0];
			}
			return SendCommand(false, true, true, true, 0,
				deviceAddress, destEndpoint, clusterID, 0x00, payload
				);
		}