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); }
public static KNXmessage CreateFAHFunctionPropertyCommand(FaHDevice faHDevice, PropertyControlTypes propertyControlType, byte ObjectID, byte PropertyID, byte[] payload = null) { if (payload == null) { payload = new byte[0]; } KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Group; kNXmessage.SourceAddress = new KNXAddress(1); kNXmessage.TargetAddress = faHDevice.KnxAddress; kNXmessage.HopCount = 6; kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyCommand, (uint)(5 + payload.Length)); kNXmessage.Payload.ReadablePayloadPacket = new FAHFunctionPropertyCommand(kNXmessage.Payload); FAHFunctionPropertyCommand newPkg = (FAHFunctionPropertyCommand)kNXmessage.Payload.ReadablePayloadPacket; newPkg.PropertyControl = propertyControlType; if (payload.Length != 0) { kNXmessage.Payload.UpdateBytes(payload, 5, payload.Length); } newPkg.ObjectID = ObjectID; newPkg.PropertyID = PropertyID; return(kNXmessage); }
static void Main(string[] args) { Console.SetWindowSize(Console.WindowWidth * 2, Console.WindowHeight); KNXUartConnection kNXUart = new KNXUartConnection(AppSettings.Default.ComPort) { AllowWrite = true }; kNXUart.OnKNXMessage += KNXUart_OnKNXMessage; kNXUart.ResetAndInit(); kNXUart.AddKNXAddressToAck(new KNXAddress(0x00, 0x02)); SysApEmulator = new FreeAtHomeDevices.FaHDevice { FaHAddress = FaHDeviceAddress.FromByteArray(new byte[] { 0xAB, 0xB7, 0x00, 0xD2, 0x32, 0x48 }, 0), }; SysApEmulator.SetAddressInformation(new KNXAddress(0x00, 0x02), SystemID); if (!DiscoverDevice(ref kNXUart)) { Console.WriteLine("Cannot find a device"); return; } LearnDevice(ref kNXUart); Console.ReadLine(); }
public static KNXmessage CreateFAHGroupValueResponse(FaHDevice faHDevice, KNXAddress GroupValueAddress, byte[] Payload) { if (Payload == null) { throw new InvalidDataException(); } uint plLen; if (Payload.Length == 1) //Encoded in second byte { plLen = 0; } else { //Not encoded plLen = (uint)Payload.Length; } KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Group; kNXmessage.SourceAddress = faHDevice.KnxAddress; kNXmessage.TargetAddress = GroupValueAddress; kNXmessage.HopCount = 6; kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.GroupValueResponse, 2 + plLen); kNXmessage.Payload.ReadablePayloadPacket = new FAHGroupValueResponse(kNXmessage.Payload); FAHGroupValueResponse newPkg = (FAHGroupValueResponse)kNXmessage.Payload.ReadablePayloadPacket; newPkg.MessageData = Payload; return(kNXmessage); }
public KNXmessage Process(FaHDevice atHomeDevice) { if (payloadReference.PayloadByteData.Length == 7) { Console.WriteLine("Odd Size"); return(CreateEmptySuccessMessage(false)); } if (PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.DeleteConn) { throw new InvalidCastException(); } int ChannelIndex = ObjectID; int propIndex = PropertyID; bool hasMoreIndices; if (atHomeDevice.RemoveChannelConnection(ChannelIndex, propIndex, ConnectionID, GroupValueAddress, out hasMoreIndices)) { return(CreateEmptySuccessMessage(hasMoreIndices)); } else { //For now we simply accept all delete commands, succesfull or not. return(CreateEmptySuccessMessage(hasMoreIndices)); } //return CreateCommandNotSupportedMessage(); }
public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { if (this.resultCode == KNXHelpers.knxPropertyReturnValues.MoreIndices) { faHDevice.WritePropertyMoreIncides(ObjectID, PropertyID, (ushort)(this.FieldID + 1)); } moreIndices = faHDevice.WritePropertyValue(this.ObjectID, this.PropertyID, this.FieldID, this.FPSRpayload); return(true); }
public KNXmessage Process(FaHDevice atHomeDevice) { if (PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.WriteIconId) { throw new InvalidCastException(); } int ChannelIndex = ObjectID; int propIndex = PropertyID; bool hasMoreIndices = false; atHomeDevice.WriteIconInfo(ChannelIndex, PropertyID, Icon); return(CreateEmptySuccessMessage(hasMoreIndices)); }
//private byte[] requestDataParms = null; public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { /*if (requestDataParms == null) * Console.WriteLine("NULL"); * else * Console.WriteLine("DATA"); */ int FieldIndex = FPSRpayload[0]; if (FPSRpayload.Length < 5) { FieldIndex = 0; } moreIndices = faHDevice.WriteOIDData(ObjectID, PropertyID, FieldIndex, FPSRpayload); return(true); }
public static KNXmessage CreateFAHIndividualAddressSerialNumberWrite(FaHDevice faHDevice) { KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Group; kNXmessage.SourceAddress = new KNXAddress(1); kNXmessage.HopCount = 6; kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.IndividualAddressSerialNumberWrite, 12); kNXmessage.Payload.ReadablePayloadPacket = new FAHIndividualAddressSerialNumberWrite(kNXmessage.Payload); FAHIndividualAddressSerialNumberWrite newPkg = (FAHIndividualAddressSerialNumberWrite)kNXmessage.Payload.ReadablePayloadPacket; newPkg.FaHDeviceAddress = faHDevice.FaHAddress; newPkg.FahSystemID = faHDevice.SystemID; newPkg.kNXAddress = faHDevice.KnxAddress; return(kNXmessage); }
public KNXmessage Process(FaHDevice atHomeDevice) { if (PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.WriteValue) { throw new InvalidCastException(); } int ChannelIndex = ObjectID; int propIndex = PropertyID; int lFieldID = (int)FieldID; //TODO check to keep fieldID in value to store??/ bool hasMoreIndices = atHomeDevice.WritePropertyValue(ChannelIndex, propIndex, lFieldID, RemainderBytesAsPayload(5)); KNXmessage k = CreateEmptySuccessMessage(hasMoreIndices); k.Payload.AppendPayload(new byte[] { (byte)FieldID }); return(k); }
public KNXmessage Process(FaHDevice atHomeDevice) { if (PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.AssignConn) { throw new InvalidCastException(); } int ChannelIndex = ObjectID; int propIndex = PropertyID; if (propIndex == 1) //Description { atHomeDevice.WriteChannelDescription(ChannelIndex, propIndex, Description); } else { throw new Exception(); } return(CreateEmptySuccessMessage(false)); }
//private const UInt16 PACKET_PAYLOAD_ASSIGNCONN = 3; public KNXmessage Process(FaHDevice atHomeDevice) { if (PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.AssignConn) { throw new InvalidCastException(); } int ChannelIndex = ObjectID; int propIndex = PropertyID; bool hasMoreIndices; if (propIndex == 1) //Description { throw new Exception(); } else { atHomeDevice.WriteConnectionValue(ChannelIndex, PropertyID, ConnectionID, 1, new KNXAddress[] { GroupValueAddress }, out hasMoreIndices); } return(CreateEmptySuccessMessage(hasMoreIndices)); }
/* * FunctionPropertyStateResponse KNX_PRIORITY_NORMAL H:6, Single, FF:0x00 [0x6F-0x01] [0x00-0x01] Ch007:1->Success * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 * 0x02 0xC9 0x07 0x01 0x00 0x01 0x00 0x12 0x00 0xEC 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x01 * * * * * FlID */ public static KNXmessage CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadFuncList) { throw new InvalidCastException(); } //TODO, add as actual param to device! //FahDeviceParametersNew p = new FahDeviceParametersNew(); //p.dataType = FahDeviceParametersNew.ParameterType.deviceInfo; //p.Response = KNXHelpers.knxPropertyReturnValues.Success; /* * if (atHomeDevice.FunctionList == null) * { * atHomeDevice.FunctionList = new byte[] { 0x01, 0x00, 0x12, 0x00, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01 }; * atHomeDevice.Serialize("input. * "); * }*/ KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; const int HEADERSIZE = 5; bool moreIndices; byte[] bData; // atHomeDevice.Channels[MessageToRespondTo.ObjectID].Properties[MessageToRespondTo.PropertyID].FunctionList[(byte)MessageToRespondTo.FieldID].data; if (!atHomeDevice.ReadFunctionList(MessageToRespondTo.ObjectID, MessageToRespondTo.PropertyID, (int)MessageToRespondTo.FieldID, out bData, out moreIndices)) { return(MessageToRespondTo.CreateCommandNotSupportedMessage()); } //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + bData.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_FunctionList(kNXmessage.Payload); FPSR_FunctionList newPkg = (FPSR_FunctionList)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = bData; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; if (moreIndices) { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.MoreIndices; } else { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; } return(kNXmessage); }
public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { moreIndices = faHDevice.WriteFunctionList(this.ObjectID, this.PropertyID, this.FieldID, this.FPSRpayload); return(true); }
public static KNXmessage CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc) { throw new InvalidCastException(); } KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong) { DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual }; const int HEADERSIZE = 5; //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + atHomeDevice.DeviceParameterInfo.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_DeviceParameterInfo(kNXmessage.Payload); FPSR_DeviceParameterInfo newPkg = (FPSR_DeviceParameterInfo)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = atHomeDevice.DeviceParameterInfo; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; //Part of the FPSRpayload at this moment! newPkg.FieldID = (byte)MessageToRespondTo.FieldID; return(kNXmessage); }
/* * 2020-06-06 15:32:06.093; Data-FunctionPropertyCommand KNX_PRIORITY_NORMAL [NoExtdFrame] [0x00-0x01] [0x6F-0x01] Ch000:4->ReadDesc [01] * 2020-06-06 15:32:06.172; Data-FunctionPropertyStateResponse KNX_PRIORITY_NORMAL H:6, Single, FF:0x00 [0x6F-0x01] [0x00-0x01] Ch000:4->Success [01 00 3B FF FF FF FF 07 14 C8 00 0C 01 00 49 00 00 00 05 00 4A 00 00 00 09 00 4B 00 00 00 06 00 4C 00 00 00 0A] */ // ID 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 // HEX 0xC9 0x00 0x04 0x00 0x01 0x00 0x3B 0xFF 0xFF 0xFF 0xFF 0x07 0x14 0xC8 0x00 0x0C 0x01 0x00 0x49 0x00 0x00 0x00 0x05 0x00 0x4A 0x00 0x00 0x00 0x09 0x00 0x4B 0x00 0x00 0x00 0x06 0x00 0x4C 0x00 0x00 0x00 0x0A // DEC * * * * 0 0 59 255 255 255 255 7 20 200 0 12 1 0 73 0 0 0 5 0 74 0 0 0 9 0 75 0 0 0 6 0 76 0 0 0 10 // Index SWVER? PARAMID MATCHCODE-------MATCHCODE BIT? DPT-----DPT PARMID--PARMID Value optionNameID MASK--------------------MASK optionNameID MASK--------------------MASK optionNameID MASK--------------------MASK optionNameID MASK--------------------MASK // // BIT? --> wizardOnly="false" deviceChannelSelector="false" channelSelector="true" writable="true" visible="true" // /* * <parameters> * <parameter nameId="003B" i="pm0000" optional="false" dependencyId="FFFF" wizardOnly="false" deviceChannelSelector="false" channelSelector="true" writable="true" visible="true" accessLevel="Enduser" parameterId="000C" matchCode="FFFFFFFF" dpt="14C8"> * <valueEnum> * <option nameId="0049" mask="00000005" isDefault="true" key="1"/> * <option nameId="004A" mask="00000009" isDefault="false" key="2"/> * <option nameId="004B" mask="00000006" isDefault="false" key="3"/> * <option nameId="004C" mask="0000000A" isDefault="false" key="4"/> * </valueEnum> * <value>1</value> * </parameter> */ public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { moreIndices = false; faHDevice.DeviceParameterInfo = FPSRpayload; return(true); }
public KNXmessage ProcessRebootPackage(FaHDevice atHomeDevice, KNXAddress AddressToSendTo) { return(null); }
public static KNXmessage CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo && MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc) { throw new InvalidCastException(); } int ChannelIndex = MessageToRespondTo.ObjectID; //TODO, add as actual param to device and index! //FahDeviceParametersNew p = new FahDeviceParametersNew(); //p.dataType = FahDeviceParametersNew.ParameterType.deviceInfo; //p.Response = KNXHelpers.knxPropertyReturnValues.Success; /* * if (atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo == null) * { * if(ChannelIndex==0) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00, 0x80, 0x00, 0x43, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x55 }; * else if (ChannelIndex == 1) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00, 0x40, 0x00, 0x45, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x2A }; * else if (ChannelIndex == 2) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00, 0x60, 0x00, 0x46, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x2A }; * else if (ChannelIndex == 3) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00, 0x80, 0x00, 0x44, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x55 }; * else if (ChannelIndex == 4) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00, 0x40, 0x00, 0x47, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x2A }; * else if (ChannelIndex == 5) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00, 0x60, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x2A }; * else if (ChannelIndex == 6) * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x02, 0x60, 0x00, 0x4F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xAA }; * else * atHomeDevice.Channels[ChannelIndex].DeviceChannelInfo = new byte[] { 0x00}; * atHomeDevice.Serialize("input.json"); * }*/ KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong) { DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual }; const int HEADERSIZE = 5; byte[] bData; if (!atHomeDevice.ReadChannelInfo(ChannelIndex, out bData)) { return(MessageToRespondTo.CreateCommandNotSupportedMessage()); } //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + bData.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_DeviceChannelInfo(kNXmessage.Payload); FPSR_DeviceChannelInfo newPkg = (FPSR_DeviceChannelInfo)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = bData; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; return(kNXmessage); }
public static KNXmessage CreateReadResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { try { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadDevHealth) { throw new InvalidCastException(); } byte[] bData = atHomeDevice.DeviceHealthStatus.ByteData; KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong) { DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual }; const int HEADERSIZE = 5; //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + bData.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_ReadDeviceHealth(kNXmessage.Payload); FPSR_ReadDeviceHealth newPkg = (FPSR_ReadDeviceHealth)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = bData; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; return(kNXmessage); } catch { return(MessageToRespondTo.CreateCommandNotSupportedMessage()); } }
/* * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 * HEX: 0x02 0xC9 0x01 0x01 0x00 0x00 0x80 0x00 0x43 0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x01 0x55 //Moredata * HEX: 0x02 0xC9 0x02 0x01 0x00 0x00 0x40 0x00 0x45 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x01 0x2A //Done * HEX: 0x02 0xC9 0x03 0x01 0x00 0x00 0x60 0x00 0x46 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x01 0x2A * HEX: 0x02 0xC9 0x04 0x01 0x00 0x00 0x80 0x00 0x44 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x01 0x55 * HEX: 0x02 0xC9 0x05 0x01 0x00 0x00 0x40 0x00 0x47 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x01 0x2A * HEX: 0x02 0xC9 0x06 0x01 0x00 0x00 0x60 0x00 0x48 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x01 0x2A * HEX: 0x02 0xC9 0x07 0x01 0x00 0x02 0x60 0x00 0x4F 0xFF 0xFF 0xFF 0xFF 0x00 0x00 0x00 0x00 0xAA //FunctionID 12 ?? * DESC: * * * * fprop CHANID--CHANID ChanNID-ChanNID MASK--------------------MASK COMBIND MoreDataFlag? * retval * * //55 01010101 * //2A 00101010 * //AA 10101010 * * <channels> +<channel nameId="0043" cid="ABB70080" i="ch0000" combined="true" mask="00000001"> * <channel nameId="0045" cid="ABB70040" i="ch0001" combined="true" mask="00000002"/> * <channel nameId="0046" cid="ABB70060" i="ch0002" combined="true" mask="00000002"/> +<channel nameId="0044" cid="ABB70080" i="ch0003" combined="true" mask="00000004"> * <channel nameId="0047" cid="ABB70040" i="ch0004" combined="true" mask="00000008"/> * <channel nameId="0048" cid="ABB70060" i="ch0005" combined="true" mask="00000008"/> +<channel nameId="004F" cid="ABB70260" i="ch0006" mask="FFFFFFFF"> * </channels> */ public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { faHDevice.WriteChannelInfo(this.ObjectID, this.FPSRpayload); moreIndices = false; return(true); }
public KNXmessage ProcessAndCreateResponse(FaHDevice device) { KNXmessage k = null; switch (PropertyControl) { case PropertyControlTypes.__UnsupportedCommand__0x07: k = CreateCommandNotSupportedMessage(); break; case PropertyControlTypes.ReadConns: //ConctionID if (payloadReference.PayloadByteData.Length == 7) { k = FPSR_ConnectionInfo.CreateResponse(this, device); //Should not exist? } else if (payloadReference.PayloadByteData.Length == 5) { k = FPSR_ConnectionInfo.CreateResponse(this, device); } else { k = CreateCommandNotSupportedMessage(); } break; case PropertyControlTypes.ReadBasicInfo: if (this.ObjectID == 0 && PropertyID == 1) { k = FPSR_BasicDeviceInfo.CreateResponse(this, device); break; } else if (ObjectID > 0 && PropertyID == 1) { k = FPSR_DeviceChannelInfo.CreateResponse(this, device); break; } else { k = FPSR_PropertyValueRead.CreateReadResponse(this, device); break; } case PropertyControlTypes.ReadDevHealth: k = FPSR_ReadDeviceHealth.CreateReadResponse(this, device); break; case PropertyControlTypes.ReadDesc: if (this.ObjectID == 0 && PropertyID == 4) { k = FPSR_DeviceParameterInfo.CreateResponse(this, device); } else if (PropertyID == 1) { k = FPSR_ChannelDescription.CreateResponse(this, device); } else if (PropertyID >= 2 && ObjectID == 7) { k = FPSR_DeviceOIDData.CreateResponse(this, device); } else if (PropertyID >= 2) { k = FPSR_DescriptorValueRead.CreateReadResponse(this, device); } break; case PropertyControlTypes.WriteValue: payloadReference.ReadablePayloadPacket = new FPC_PropertyValueWrite(payloadReference); FPC_PropertyValueWrite fPSR_PropertyValue = this.payloadReference.ReadablePayloadPacket as FPC_PropertyValueWrite; k = fPSR_PropertyValue.Process(device); break; case PropertyControlTypes.ReadFlr_RmNr: k = FPSR_RoomInfo.CreateResponse(this, device); break; case PropertyControlTypes.ReadIconId: k = FPSR_IconInfo.CreateResponse(this, device); break; case PropertyControlTypes.DeleteConn: payloadReference.ReadablePayloadPacket = new FPC_DeleteConnection(payloadReference); FPC_DeleteConnection fPC_Delete = this.payloadReference.ReadablePayloadPacket as FPC_DeleteConnection; k = fPC_Delete.Process(device); break; case PropertyControlTypes.AssignConn: if (PropertyID == 1) //Property ID 1 == name of channel { payloadReference.ReadablePayloadPacket = new FPC_WriteDescription(payloadReference); FPC_WriteDescription fPC_WriteDescription = this.payloadReference.ReadablePayloadPacket as FPC_WriteDescription; k = fPC_WriteDescription.Process(device); } else { payloadReference.ReadablePayloadPacket = new FPC_AssignConnection(payloadReference); FPC_AssignConnection fPC_Assign = this.payloadReference.ReadablePayloadPacket as FPC_AssignConnection; k = fPC_Assign.Process(device); } break; case PropertyControlTypes.WriteIconId: payloadReference.ReadablePayloadPacket = new FPC_WriteIcon(payloadReference); FPC_WriteIcon fPC_WriteIcon = this.payloadReference.ReadablePayloadPacket as FPC_WriteIcon; k = fPC_WriteIcon.Process(device); break; case PropertyControlTypes.WriteFlr_RmNr: payloadReference.ReadablePayloadPacket = new FPC_WriteRoomInfo(payloadReference); FPC_WriteRoomInfo fPC_WriteRoomInfo = this.payloadReference.ReadablePayloadPacket as FPC_WriteRoomInfo; k = fPC_WriteRoomInfo.Process(device); break; case PropertyControlTypes.UpdConsistencyTag: k = FPSR_ConsistancyTag.UpdateConsistancyTag(this, device); break; case FAHFunctionPropertyCommand.PropertyControlTypes.ReadFuncList: k = FPSR_FunctionList.CreateResponse(this, device); break; } if (k != null) { k.SourceAddress = device.KnxAddress; k.TargetAddress = this.payloadReference.OwnerOfPayload.SourceAddress; } return(k); }
public static KNXmessage CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns) { throw new InvalidCastException(); } int ChannelIndex = MessageToRespondTo.ObjectID; int propIndex = MessageToRespondTo.PropertyID; byte requestedIndice; byte propertyInfo; bool moreIndices; KNXAddress[] GroupValueAddress; //byte[] additionalData = null; uint payloadSize = (uint)(FPSRHEADERSIZE + 2); if (MessageToRespondTo.FPCpayload == null) { requestedIndice = 0; //There is no field requested; default to 0 } else { requestedIndice = MessageToRespondTo.FPCpayload[0]; } if (!atHomeDevice.ReadConnectionValue(ChannelIndex, propIndex, requestedIndice, out propertyInfo, out GroupValueAddress, out moreIndices)) { return(MessageToRespondTo.CreateCommandNotSupportedMessage()); } KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort) { DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual }; if (GroupValueAddress != null) { payloadSize += (uint)GroupValueAddress.Length * 2; //Address is not empty, add space to store it. /*if (additionalData != null) * { * payloadSize += (uint)additionalData.Length; * }*/ } kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_ConnectionInfo(kNXmessage.Payload); FPSR_ConnectionInfo newPkg = (FPSR_ConnectionInfo)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.ConnectionID = requestedIndice; newPkg.ConnectionSubIndexID = propertyInfo; if (GroupValueAddress != null) { newPkg.GroupValueAddress = GroupValueAddress; /*if(additionalData!=null) * { * * }*/ } newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; if (moreIndices && requestedIndice != 0) //for 0 (no params) there are no more indices to report { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.MoreIndices; } else { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; } return(kNXmessage); }
public static KNXmessage CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { try { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo) { throw new InvalidCastException(); } //TODO, add as actual param to device! //FahDeviceParametersNew p = new FahDeviceParametersNew(); //p.dataType = FahDeviceParametersNew.ParameterType.deviceInfo; //p.Response = KNXHelpers.knxPropertyReturnValues.Success; /* * if (atHomeDevice.BasicDeviceInformation == null) * { * atHomeDevice.BasicDeviceInformation = new byte[] { 0xFF, 0xEB, 0xFE, 0xFF, 0x08, 0x00, 0x37, 0x00, 0x6A, 0xF6, 0xD1, 0x00, 0x00, 0x02, 0x7E }; * }*/ KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; const int HEADERSIZE = 5; //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + atHomeDevice.BasicDeviceInformation.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_BasicDeviceInfo(kNXmessage.Payload); FPSR_BasicDeviceInfo newPkg = (FPSR_BasicDeviceInfo)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = atHomeDevice.BasicDeviceInformation; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; return(kNXmessage); } catch { return(null); } }
/* * 2020-06-06 15:32:05.250; Data-FunctionPropertyCommand KNX_PRIORITY_NORMAL [NoExtdFrame] [0x00-0x01] [0x6F-0x01] Ch000:1->ReadBasicInfo * 2020-06-06 15:32:05.297; Data-FunctionPropertyStateResponse KNX_PRIORITY_NORMAL H:6, Single, FF:0x00 [0x6F-0x01] [0x00-0x01] Ch000:1->Success [FF EB FE FF 08 00 37 00 6A F6 D1 00 00 02 7E] 0xFF 0xEB 0xFE 0xFF 0x08 0x00 0x37 0x00 0x6A 0xF6 0xD1 0x00 0x00 0x02 0x7E */ // // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 // HEX 0x02 0xC9 0x00 0x01 0x00 0xFF 0xFD 0xFE 0xFF 0x15 0x56 0x37 0x00 0x7A 0x3C 0xF9 0x00 0x00 0x05 0x56 0x02 0x00 0x01 0x00 // DEC 2 201 0 1 0 255 253 254 255 21 86 55 0 122 60 249 0 0 5 86 2 0 1 0 //<device isTp = "true" nameId="FFEB" profile="0E00" maxAPDULength="37" compilerVersion="007A3CF9" buildNumber="00000556" iconId="FFFE" protocolVersion="0002" minConfigVersion="0001" deviceFlavor="00" interface="TP" functionId="FEFF" shortSerialNumber="CYY" softwareId="1556" softwareVersion="2.1366" deviceId="1019" serialNumber="ABB700C77FC1" commissioningState="ready" copyId="c"> // HEX 0x02 0xC9 0x00 0x01 0x00 0xFF 0xEB 0xFE 0xFF 0x08 0x00 0x37 0x00 0x6A 0xF6 0xD1 0x00 0x00 0x02 0x7E // DEC 2 201 0 1 0 255 235 254 255 8 0 55 0 106 246 209 0 0 2 126 // NAME * * * * NAMEID NAMEID FUNCTID FUNCTID COMPILER------------COMPILER BUILD------------------BUILD public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { faHDevice.BasicDeviceInformation = this.FPSRpayload; moreIndices = false; return(true); }
public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { faHDevice.SetAddressInformation(kNXAddress, FahSystemID); moreIndices = false; return(true); }
public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { moreIndices = false; faHDevice.DeviceHealthStatus = new FahDeviceHealth(this.FPSRpayload); return(true); }
public static KNXmessage CreateReadResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { try { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo) { throw new InvalidCastException(); } int ChannelIndex = MessageToRespondTo.ObjectID; int propIndex = MessageToRespondTo.PropertyID; int fieldID = (int)MessageToRespondTo.FieldID; byte[] bData;//= atHomeDevice.Channels[ChannelIndex].Properties[propIndex].FieldData[fieldID].data; bool moreIndices; if (!atHomeDevice.ReadPropertyValue(ChannelIndex, propIndex, fieldID, out bData, out moreIndices)) { return(MessageToRespondTo.CreateCommandNotSupportedMessage()); } KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort) { DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual }; const int HEADERSIZE = 5; //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + bData.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_PropertyValueRead(kNXmessage.Payload); FPSR_PropertyValueRead newPkg = (FPSR_PropertyValueRead)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = bData; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.FieldID = (byte)MessageToRespondTo.FieldID; if (moreIndices) { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.MoreIndices; } else { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; } return(kNXmessage); } catch { return(MessageToRespondTo.CreateCommandNotSupportedMessage()); } }
public static KNXmessage CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc) { throw new InvalidCastException(); } bool moreIndices = false; int OIDindex = MessageToRespondTo.PropertyID; byte[] bData; byte indice = 0; if (MessageToRespondTo.FieldID != null) { indice = (byte)(MessageToRespondTo.FieldID); } if (!atHomeDevice.ReadOIDData(MessageToRespondTo.ObjectID, MessageToRespondTo.PropertyID, indice, out bData, out moreIndices)) { return(MessageToRespondTo.CreateInvalidIndexMessage()); } //OidChannel 5 needs ShortPkg! (currently based on packet payload lenght) KNXmessage kNXmessage; if (bData.Length < 5) { kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); } else { kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong); } kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; const int HEADERSIZE = 5; //Todo, check lenght? uint payloadSize = (uint)(HEADERSIZE + bData.Length); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_DeviceOIDData(kNXmessage.Payload); FPSR_DeviceOIDData newPkg = (FPSR_DeviceOIDData)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.FPSRpayload = bData; newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; if (moreIndices) { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.MoreIndices; } else { newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; } return(kNXmessage); }
public static KNXmessage UpdateConsistancyTag(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.UpdConsistencyTag) { throw new InvalidCastException(); } KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; uint payloadSize = (uint)(FPSRHEADERSIZE + 2); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_ConsistancyTag(kNXmessage.Payload); FPSR_ConsistancyTag newPkg = (FPSR_ConsistancyTag)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; newPkg.ConsistancyValue = atHomeDevice.GenerateNewConsistancyTag(); return(kNXmessage); }
public override bool SaveToDevice(ref FaHDevice faHDevice, out bool moreIndices) { if (this.resultCode == KNXHelpers.knxPropertyReturnValues.MoreIndices) { faHDevice.WriteConnectionMoreIncides(ObjectID, PropertyID, (ushort)(this.FPSRpayload[0] + 1)); } if (this.requestDataParms == null) { if (FPSRpayload.Length == 4) { //There is a knxaddress in response; save faHDevice.WriteConnectionValue(ObjectID, PropertyID, this.FPSRpayload[0], this.FPSRpayload[1], new KNXAddress[] { new KNXAddress(FPSRpayload, 2) }, out moreIndices); } else if (FPSRpayload.Length == 2) { //There is knxaddress in response; save as null faHDevice.WriteConnectionValue(ObjectID, PropertyID, this.FPSRpayload[0], this.FPSRpayload[1], null, out moreIndices); } else { throw new NotImplementedException(); } return(true); } else { if (this.requestDataParms.Length == 2) { //Contains groupvalue if (FPSRpayload.Length >= 4) { if (this.requestDataParms[0] == this.ConnectionID && this.requestDataParms[1] == this.ConnectionSubIndexID) { faHDevice.WriteConnectionValue(ObjectID, PropertyID, (ushort)this.ConnectionID, (byte)this.ConnectionSubIndexID, this.GroupValueAddress, out moreIndices); return(true); } else { throw new InvalidDataException(); } } //Empty groupvalue else if (FPSRpayload.Length == 2) { if (this.requestDataParms[0] == this.ConnectionID && this.requestDataParms[1] == this.ConnectionSubIndexID) { faHDevice.WriteConnectionValue(ObjectID, PropertyID, (ushort)this.ConnectionID, (byte)this.ConnectionSubIndexID, null, out moreIndices); return(true); } else { throw new InvalidDataException(); } } /*else * { * if (this.requestDataParms[0] == this.ConnectionID && this.requestDataParms[1] == this.ConnectionSubIndexID) * { * faHDevice.WriteConnectionValue(ObjectID, PropertyID, (ushort)this.ConnectionID, (byte)this.ConnectionSubIndexID, GroupValueAddress, AdditionalData, out moreIndices); * return true; * } * else * { * throw new InvalidDataException(); * } * }*/ } moreIndices = false; return(false); } }