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); }
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()); } }
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 CreateResponse(FAHFunctionPropertyCommand MessageToRespondTo, FaHDevice atHomeDevice) { if (MessageToRespondTo.PropertyControl != FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc) { throw new InvalidCastException(); } KNXmessage kNXmessage; string Description; atHomeDevice.ReadChannelDescription(MessageToRespondTo.ObjectID, MessageToRespondTo.PropertyID, out Description); if (Description.Length > 10) { kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketLong); } else { kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); } kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; uint payloadSize = (uint)(FPSRHEADERSIZE + DescriptionByteLenght(Description)); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_ChannelDescription(kNXmessage.Payload); FPSR_ChannelDescription newPkg = (FPSR_ChannelDescription)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; newPkg.Description = Description; return(kNXmessage); }
/* * 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 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.ReadIconId) { throw new InvalidCastException(); } //int objId = MessageToRespondTo.ObjectID; UInt16 Icon = atHomeDevice.ReadIconInfo(MessageToRespondTo.ObjectID, MessageToRespondTo.PropertyID);// KNXHelpers.GetCheckNullUint16Value(atHomeDevice.Channels[objId].Properties[MessageToRespondTo.PropertyID].IconId, 0xFFFF); /* * if (Room == 0 && X== 0 && Y == 0) * { * atHomeDevice.ChannelProperties[MessageToRespondTo.ObjectID].Properties[MessageToRespondTo.PropertyID].RoomID = 0xFFFF; * Room = 0xFFFF; * atHomeDevice.ChannelProperties[MessageToRespondTo.ObjectID].Properties[MessageToRespondTo.PropertyID].X = 0xFFFF; * X = 0xFFFF; * atHomeDevice.ChannelProperties[MessageToRespondTo.ObjectID].Properties[MessageToRespondTo.PropertyID].X = 0xFFFF; * Y = 0xFFFF; * atHomeDevice.Serialize("input.json"); * }*/ //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.json"); * }*/ KNXmessage kNXmessage = new KNXmessage(knxControlField.KnxPacketType.KNX_PacketShort); kNXmessage.DestinationAddressType = KNXmessage.DestinationAddressFieldType.Individual; uint payloadSize = (uint)(FPSRHEADERSIZE + VALUESIZE); kNXmessage.Payload.NewPayload(KNXAdpu.ApduType.FunctionPropertyStateResponse, payloadSize); kNXmessage.Payload.ReadablePayloadPacket = new FPSR_IconInfo(kNXmessage.Payload); FPSR_IconInfo newPkg = (FPSR_IconInfo)kNXmessage.Payload.ReadablePayloadPacket; newPkg.UpdatePacketSettings(); newPkg.PropertyID = MessageToRespondTo.PropertyID; newPkg.ObjectID = MessageToRespondTo.ObjectID; newPkg.resultCode = KNXHelpers.knxPropertyReturnValues.Success; newPkg.Icon = Icon; 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); } }
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 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); }
static void LearnDevice(ref KNXUartConnection kNXUart) { byte counter = 0; bool moreIndices; for (byte i = 1; i <= 10; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 7, 2, new byte[] { i, 1 }); ConsoleWriteOnEmptyLine(string.Format("Sending {0} ", ReadCons.HeaderAsString)); ReadCons.Payload.ReadablePayloadPacket.PrintUnaccountedBytes(); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 1; i <= 10; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 8, 3, new byte[] { i, 1 }); ConsoleWriteOnEmptyLine(string.Format("Sending {0} ", ReadCons.HeaderAsString)); ReadCons.Payload.ReadablePayloadPacket.PrintUnaccountedBytes(); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 1; i <= 10; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 8, 2, new byte[] { i, 1 }); ConsoleWriteOnEmptyLine(string.Format("Sending {0} ", ReadCons.HeaderAsString)); ReadCons.Payload.ReadablePayloadPacket.PrintUnaccountedBytes(); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 1; i <= deviceToLearn.ChannelCount; i++) { for (byte propID = 2; propID <= 3; propID++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons ch:" + i + ":" + propID + " id:" + counter); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, i, propID, new byte[] { counter++, 0x01 }); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } } for (byte i = 1; i <= 10; i++) { moreIndices = true; byte ix = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo"); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, i, 5, new byte[] { ix++ }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } for (byte i = 1; i <= deviceToLearn.ChannelCount; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, i, 1, null); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 1; i <= 10; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 7, i, null); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 0; i <= 10; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 8, i, null); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDevHealth"); KNXmessage ReadDevHealth = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDevHealth, 0, 1, null); ((FAHFunctionPropertyCommand)ReadDevHealth.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDevHealth, true)) { return; } else if (!ProcessResponse(out moreIndices)) { return; } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc"); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 1, 5, null); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 0; i <= deviceToLearn.ChannelCount + 5; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo Chn: " + i); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, i, 1, null); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { Console.WriteLine("Failed"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc"); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 0, 4, new byte[] { 0x01 }); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { return; } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons-ShouldFail"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 0, 4, new byte[] { 0x01 }); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (ProcessResponse(out moreIndices)) { return; } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo-ShouldFail"); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, 0, 7, new byte[] { 0x01 }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (ProcessResponse(out moreIndices)) { return; } } for (byte i = 1; i <= deviceToLearn.ChannelCount; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo " + i); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, i, 1, null); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc"); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 7, 5, null); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } //return; } for (byte i = 0; i < 10; i++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadFunctList"); KNXmessage ReadFunctList = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadFuncList, i, 1, new byte[] { counter++ }); ((FAHFunctionPropertyCommand)ReadFunctList.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadFunctList, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc Ndice:" + counter); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 7, 4, new byte[] { (byte)counter++ }); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons-ShouldFail"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, 7, 4, new byte[] { 0x01 }); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (ProcessResponse(out moreIndices)) { return; } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo-ShouldFail"); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, 7, 7, new byte[] { 0x01 }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (ProcessResponse(out moreIndices)) { return; } } moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc OID:" + counter); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 7, 3, new byte[] { (byte)counter++ }); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc OID:" + counter); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 7, 2, new byte[] { (byte)counter++ }); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo"); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, 0, 4, new byte[] { 0x01 }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { return; } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc"); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 0, 1, null); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 0; i <= deviceToLearn.ChannelCount + 2; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadFlr_RmNr"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadFlr_RmNr, i, 1, null); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } for (byte i = 1; i <= deviceToLearn.ChannelCount + 2; i++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadIconId"); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadIconId, i, 1, null); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo"); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, 0, 16, new byte[] { 0x00, 0x00 }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc"); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, 1, 1, null); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } if (true) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("__UnsupportedCommand__0x07"); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.__UnsupportedCommand__0x07, 1, 1, new byte[] { 0x07 }); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (ProcessResponse(out moreIndices)) { return; } } for (byte i = 1; i <= deviceToLearn.ChannelCount; i++) { for (byte propID = 2; propID <= 3; propID++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons ch:" + i + ":" + propID + " id:" + counter); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, i, propID, new byte[] { counter++, 0x01 }); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } } if (true) { byte i = 7; for (byte propID = 2; propID <= 3; propID++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadCons ch:" + i + ":" + propID + " id:" + counter); KNXmessage ReadCons = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadConns, i, propID, new byte[] { counter++, 0x01 }); ((FAHFunctionPropertyCommand)ReadCons.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadCons, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } } for (byte channelID = 1; channelID <= deviceToLearn.ChannelCount; channelID++) { ConsoleWriteHeader("ReadBasicInfo channel:" + channelID); for (byte propID = 3; propID <= 5; propID++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo ch:" + channelID + ":" + propID + " id:" + counter); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, channelID, propID, new byte[] { counter++ }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } } if (true) { byte channelID = 7; ConsoleWriteHeader("ReadBasicInfo channel:" + channelID); for (byte propID = 3; propID <= 5; propID++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo ch:" + channelID + ":" + propID + " id:" + counter); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, channelID, propID, new byte[] { counter++ }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } } if (true) { byte channelID = 8; ConsoleWriteHeader("ReadBasicInfo channel:" + channelID); for (byte propID = 3; propID <= 5; propID++) { moreIndices = true; counter = 1; while (moreIndices) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadBasicInfo ch:" + channelID + ":" + propID + " id:" + counter); KNXmessage ReadBasicInfo = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadBasicInfo, channelID, propID, new byte[] { counter++ }); ((FAHFunctionPropertyCommand)ReadBasicInfo.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); if (!kNXUart.WriteDirect(ReadBasicInfo, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } } } for (byte channelID = 1; channelID <= deviceToLearn.ChannelCount + 2; channelID++) { //*---------------------------------------------------------------------------- ConsoleWriteHeader("ReadDesc:" + channelID); KNXmessage ReadDesc = FAHFunctionPropertyCommand.CreateFAHFunctionPropertyCommand(deviceToLearn, FAHFunctionPropertyCommand.PropertyControlTypes.ReadDesc, channelID, 1, null); ((FAHFunctionPropertyCommand)ReadDesc.Payload.ReadablePayloadPacket).GetPropertyControlForReply(ref ByteDataParm, ref lastRequestedPropertyControl); Console.WriteLine(ReadDesc.ToHexString()); if (!kNXUart.WriteDirect(ReadDesc, true)) { return; } else if (!ProcessResponse(out moreIndices)) { ConsoleWriteLine("Invalid data"); } } Console.WriteLine("Setting Interface types we know"); if (deviceToLearn.DeviceType == FaHDeviceType.SensorSwitchactuator22gang) { Console.WriteLine("Switch 2\\2"); //Dit kunnen we sturen //deviceToLearn.WriteChannelPropertyType(1, 2, FaHDeviceProperties.ChannelType.NotDefined, FaHDeviceProperties.SensorActorInterfaceType.NotDefined); //deviceToLearn.WriteChannelPropertyType(4, 2, FaHDeviceProperties.ChannelType.NotDefined, FaHDeviceProperties.SensorActorInterfaceType.NotDefined); deviceToLearn.WriteChannelPropertyType(1, 3, FaHDeviceProperties.ChannelType.chanOutputOnClickChannelType, FaHDeviceProperties.SensorActorInterfaceType.ButtonLeft); deviceToLearn.WriteChannelPropertyType(4, 3, FaHDeviceProperties.ChannelType.chanOutputOnClickChannelType, FaHDeviceProperties.SensorActorInterfaceType.ButtonRight); //Deze moeten we monitoren deviceToLearn.WriteChannelPropertyType(7, 2, FaHDeviceProperties.ChannelType.chanInputActorGroupMessage, FaHDeviceProperties.SensorActorInterfaceType.Actor1); deviceToLearn.WriteChannelPropertyType(8, 2, FaHDeviceProperties.ChannelType.chanInputActorGroupMessage, FaHDeviceProperties.SensorActorInterfaceType.Actor2); //Dit moeten we sturen als waarde veranderd deviceToLearn.WriteChannelPropertyType(7, 3, FaHDeviceProperties.ChannelType.chanOutputActorChangedValue, FaHDeviceProperties.SensorActorInterfaceType.Actor1); deviceToLearn.WriteChannelPropertyType(8, 3, FaHDeviceProperties.ChannelType.chanOutputActorChangedValue, FaHDeviceProperties.SensorActorInterfaceType.Actor2); deviceToLearn.DeviceHealthStatus.DeviceReboots = 0; deviceToLearn.DeviceHealthStatus.Uptime = 0; } else { Console.WriteLine("Unkown"); } ConsoleWriteHeader("Read Completed:" + deviceToLearn.FaHAddress); deviceToLearn.Serialize(deviceToLearn.FaHAddress + "-learn.json"); }
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); }