using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetAoaRxParametersInfo : PacketInfoBase
{
	public override string Name => "Le Set Aoa Rx Parameters";

	public override string DisplayGroup => "LE Controller";

	public LeSetAoaRxParametersInfo(LeSetAoaRxParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetAoaRxParameters leSetAoaRxParameters = (LeSetAoaRxParameters)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(leSetAoaRxParameters.UserFields.ConnectionHandle, 16), "", "0EFF", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Antenna_IDs", "The number of antenna IDs defined in a sequence. The Host shall define the Antenna IDs from 0 to N, where N-1 is equal to the total number of antenna elements.", 8, FormatValue(leSetAoaRxParameters.UserFields.NumberOfAntennaIds, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < leSetAoaRxParameters.UserFields.AntennaIdsSetList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Antenna_IDs[" + i + "]", "", 8, FormatValue(leSetAoaRxParameters.UserFields.AntennaIdsSetList[i].AntennaIds, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		fieldInfoList.Add(new PacketFieldInfo("Slot_Durations", SlotDurationsInfo.SlotDurationsToDescription(), 8, FormatValue(leSetAoaRxParameters.UserFields.SlotDurations, 8), SlotDurationsInfo.SlotDurationsToString(SlotDurationsInfo.ValueToSlotDurations(leSetAoaRxParameters.UserFields.SlotDurations)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetAoaRxParameters leSetAoaRxParameters = (LeSetAoaRxParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetAoaRxParameters.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			leSetAoaRxParameters.UserFields.NumberOfAntennaIds = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < leSetAoaRxParameters.UserFields.AntennaIdsSetList.Count; i++)
		{
			if (index == ++num)
			{
				leSetAoaRxParameters.UserFields.AntennaIdsSetList[i].AntennaIds = Convert.ToUInt32(value, 16);
				return;
			}
		}
		if (index == ++num)
		{
			leSetAoaRxParameters.UserFields.SlotDurations = Convert.ToUInt32(value, 16);
		}
	}
}
