Esempio n. 1
0
        public static KNXmessage CreateResponse(FaHDevice atHomeDevice, KNXAddress AddressToSendTo)
        {
            KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong);

            //kNXmessage.HopCount = 6;
            kNXmessage.SourceAddress = atHomeDevice.KnxAddress;

            uint payloadSize = __FAHChannelStart + (atHomeDevice.ChannelCount * 2);

            kNXmessage.TargetAddress = AddressToSendTo;
            kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.DeviceDescriptorResponse, payloadSize);
            kNXmessage.Payload.ReadablePayloadPacket = new FAHDeviceDescriptorResponse(kNXmessage.Payload);
            FAHDeviceDescriptorResponse newPkg = (FAHDeviceDescriptorResponse)kNXmessage.Payload.ReadablePayloadPacket;

            newPkg.UpdatePacketSettings();
            newPkg.DescriptorType   = 3;
            newPkg.__UnknownValue0  = new KNXu16SimpleStruct(0x0E, 0x00); //14 00
            newPkg.FahDeviceAddress = atHomeDevice.FaHAddress;
            newPkg.fahSystemID      = atHomeDevice.SystemID;
            newPkg.faHDeviceType    = atHomeDevice.DeviceType;
            newPkg.ConsistencyValue = atHomeDevice.ConsistancyValue;
            //kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Group;

            for (int i = 1; i <= atHomeDevice.ChannelCount; i++)
            {
                KNXu16SimpleStruct addr;
                if (atHomeDevice.ReadChannelIndentifier(i, out addr))
                {
                    newPkg.SetDeviceChannel((uint)i, addr);
                }
                //else NULL
            }
            return(kNXmessage);
        }