using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSendAoaRequestInfo : PacketInfoBase
{
	public override string Name => "Le Send Aoa Request";

	public override string DisplayGroup => "LE Controller";

	public LeSendAoaRequestInfo(LeSendAoaRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSendAoaRequest leSendAoaRequest = (LeSendAoaRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to identify a connection. Range 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(leSendAoaRequest.UserFields.ConnectionHandle, 16), "", "0EFF", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("AoA_Request_Interval", "Maximum value for the interval of sending LL_AOA_REQ PDUs, Range: 0x0001 to 0x8000, Time = N * 1 msec, Time Range: 1 msec to 32,768 msec\r\n\r\n" + LeSendAoaRequest.UserFieldsWrapper.AoaRequestIntervalInfo.AoaRequestIntervalToDescription(), 16, FormatValue(leSendAoaRequest.UserFields.AoaRequestInterval, 16), ValueTimes1MsecExpression.ValueTimes1MsecToString(leSendAoaRequest.UserFields.AoaRequestInterval), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Requested_Supplemental_Length", LeSendAoaRequest.UserFieldsWrapper.RequestedSupplementalLengthInfo.RequestedSupplementalLengthToDescription(), 8, FormatValue(leSendAoaRequest.UserFields.RequestedSupplementalLength, 8), LeSendAoaRequest.UserFieldsWrapper.RequestedSupplementalLengthInfo.RequestedSupplementalLengthToString(LeSendAoaRequest.UserFieldsWrapper.RequestedSupplementalLengthInfo.ValueToRequestedSupplementalLength(leSendAoaRequest.UserFields.RequestedSupplementalLength)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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