/// <summary> /// Generate user information. /// </summary> /// <param name="settings">DLMS settings.</param> /// <param name="cipher"></param> /// <param name="data">Generated user information.</param> static internal void GenerateUserInformation(GXDLMSSettings settings, GXICipher cipher, GXByteBuffer data) { data.SetUInt8((byte)BerType.Context | (byte)BerType.Constructed | (byte)PduType.UserInformation); if (cipher == null || !cipher.IsCiphered()) { //Length for AARQ user field data.SetUInt8(0x10); //Coding the choice for user-information (Octet STRING, universal) data.SetUInt8(BerType.OctetString); //Length data.SetUInt8(0x0E); GetInitiateRequest(settings, cipher, data); } else { GXByteBuffer tmp = new GXByteBuffer(); GetInitiateRequest(settings, cipher, tmp); byte[] crypted = cipher.Encrypt(0x21, cipher.SystemTitle, tmp.Array()); //Length for AARQ user field data.SetUInt8((byte)(2 + crypted.Length)); //Coding the choice for user-information (Octet STRING, universal) data.SetUInt8(BerType.OctetString); data.SetUInt8((byte)crypted.Length); data.Set(crypted); } }
private static byte[] GetUserInformation(GXDLMSSettings settings, GXICipher cipher) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8(GXCommon.InitialResponce); // Tag for xDLMS-Initiate response // NegotiatedQualityOfService (not used) data.SetUInt8(0x1); data.SetUInt8(0x00); // DLMS Version Number data.SetUInt8(06); data.SetUInt8(0x5F); data.SetUInt8(0x1F); data.SetUInt8(0x04); // length of the conformance block data.SetUInt8(0x00); // encoding the number of unused bits in the bit string if (settings.UseLogicalNameReferencing) { data.Set(settings.LnSettings.ConformanceBlock); } else { data.Set(settings.SnSettings.ConformanceBlock); } data.SetUInt16(settings.MaxReceivePDUSize); //VAA Name VAA name (0x0007 for LN referencing and 0xFA00 for SN) if (settings.UseLogicalNameReferencing) { data.SetUInt16(0x0007); } else { data.SetUInt16(0xFA00); } if (cipher != null && cipher.IsCiphered()) { return(cipher.Encrypt(0x28, cipher.SystemTitle, data.Array())); } return(data.Array()); }
private static byte[] GetUserInformation(GXDLMSSettings settings, GXICipher cipher) { GXByteBuffer data = new GXByteBuffer(); data.SetUInt8(Command.InitiateResponse); // Tag for xDLMS-Initiate response // NegotiatedQualityOfService (not used) data.SetUInt8(0x1); data.SetUInt8(0x00); // DLMS Version Number data.SetUInt8(06); data.SetUInt8(0x5F); data.SetUInt8(0x1F); data.SetUInt8(0x04);// length of the conformance block data.SetUInt8(0x00);// encoding the number of unused bits in the bit string if (settings.UseLogicalNameReferencing) { data.Set(settings.LnSettings.ConformanceBlock); } else { data.Set(settings.SnSettings.ConformanceBlock); } data.SetUInt16(settings.MaxPduSize); //VAA Name VAA name (0x0007 for LN referencing and 0xFA00 for SN) if (settings.UseLogicalNameReferencing) { data.SetUInt16(0x0007); } else { data.SetUInt16(0xFA00); } if (cipher != null && cipher.IsCiphered()) { return cipher.Encrypt((byte)Command.GloInitiateResponse, cipher.SystemTitle, data.Array()); } return data.Array(); }
/// <summary> /// Generate user information. /// </summary> /// <param name="settings">DLMS settings.</param> /// <param name="cipher"></param> /// <param name="data">Generated user information.</param> static internal void GenerateUserInformation(GXDLMSSettings settings, GXICipher cipher, GXByteBuffer encryptedData, GXByteBuffer data) { data.SetUInt8((byte)BerType.Context | (byte)BerType.Constructed | (byte)PduType.UserInformation); if (cipher == null || !cipher.IsCiphered()) { //Length for AARQ user field data.SetUInt8(0x10); //Coding the choice for user-information (Octet STRING, universal) data.SetUInt8(BerType.OctetString); //Length data.SetUInt8(0x0E); GetInitiateRequest(settings, cipher, data); } else { if (encryptedData != null && encryptedData.Size != 0) { //Length for AARQ user field data.SetUInt8((byte)(4 + encryptedData.Size)); //Tag data.SetUInt8(BerType.OctetString); data.SetUInt8((byte)(2 + encryptedData.Size)); //Coding the choice for user-information (Octet STRING, universal) data.SetUInt8((byte)Command.GloInitiateRequest); data.SetUInt8((byte)encryptedData.Size); data.Set(encryptedData); } else { GXByteBuffer tmp = new GXByteBuffer(); GetInitiateRequest(settings, cipher, tmp); byte[] crypted = cipher.Encrypt((byte)Command.GloInitiateRequest, cipher.SystemTitle, tmp.Array()); //Length for AARQ user field data.SetUInt8((byte)(2 + crypted.Length)); //Coding the choice for user-information (Octet STRING, universal) data.SetUInt8(BerType.OctetString); data.SetUInt8((byte)crypted.Length); data.Set(crypted); } } }