using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetConnectionEncryptionInfo : PacketInfoBase
{
	public override string Name => "Set Connection Encryption";

	public override string DisplayGroup => "Link Control";

	public SetConnectionEncryptionInfo(SetConnectionEncryption packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetConnectionEncryption setConnectionEncryption = (SetConnectionEncryption)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to enable/disable the link layer encryption for all Connection_Handles with the same BR/EDR Controller end-point as the specified Connection_Handle.", 16, FormatValue(setConnectionEncryption.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Encryption_Enable", SetConnectionEncryption.UserFieldsWrapper.EncryptionEnableInfo.EncryptionEnableToDescription(), 8, FormatValue(setConnectionEncryption.UserFields.EncryptionEnable, 8), SetConnectionEncryption.UserFieldsWrapper.EncryptionEnableInfo.EncryptionEnableToString(SetConnectionEncryption.UserFieldsWrapper.EncryptionEnableInfo.ValueToEncryptionEnable(setConnectionEncryption.UserFields.EncryptionEnable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetConnectionEncryption setConnectionEncryption = (SetConnectionEncryption)packet;
		int num = -1;
		if (index == ++num)
		{
			setConnectionEncryption.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionEncryption.UserFields.EncryptionEnable = Convert.ToUInt32(value, 16);
		}
	}
}
