using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetConnectionlessIAndQSamplingEnableInfo : PacketInfoBase
{
	public override string Name => "Le Set Connectionless I And Q Sampling Enable";

	public override string DisplayGroup => "LE Controller";

	public LeSetConnectionlessIAndQSamplingEnableInfo(LeSetConnectionlessIAndQSamplingEnable packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetConnectionlessIAndQSamplingEnable leSetConnectionlessIAndQSamplingEnable = (LeSetConnectionlessIAndQSamplingEnable)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sync_Handle", "Sync_Handle identifying the periodic advertising. Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(leSetConnectionlessIAndQSamplingEnable.UserFields.SyncHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sampling_Enable", LeSetConnectionlessIAndQSamplingEnable.UserFieldsWrapper.SamplingEnableInfo.SamplingEnableToDescription(), 8, FormatValue(leSetConnectionlessIAndQSamplingEnable.UserFields.SamplingEnable, 8), LeSetConnectionlessIAndQSamplingEnable.UserFieldsWrapper.SamplingEnableInfo.SamplingEnableToString(LeSetConnectionlessIAndQSamplingEnable.UserFieldsWrapper.SamplingEnableInfo.ValueToSamplingEnable(leSetConnectionlessIAndQSamplingEnable.UserFields.SamplingEnable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Slot_Durations", SlotDurationsInfo.SlotDurationsToDescription(), 8, FormatValue(leSetConnectionlessIAndQSamplingEnable.UserFields.SlotDurations, 8), SlotDurationsInfo.SlotDurationsToString(SlotDurationsInfo.ValueToSlotDurations(leSetConnectionlessIAndQSamplingEnable.UserFields.SlotDurations)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max sampled CTEs", LeSetConnectionlessIAndQSamplingEnable.UserFieldsWrapper.MaxSampledCtesInfo.MaxSampledCtesToDescription(), 8, FormatValue(leSetConnectionlessIAndQSamplingEnable.UserFields.MaxSampledCtes, 8), LeSetConnectionlessIAndQSamplingEnable.UserFieldsWrapper.MaxSampledCtesInfo.MaxSampledCtesToString(LeSetConnectionlessIAndQSamplingEnable.UserFieldsWrapper.MaxSampledCtesInfo.ValueToMaxSampledCtes(leSetConnectionlessIAndQSamplingEnable.UserFields.MaxSampledCtes)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_Of_Antenna_IDs", "The number of antenna IDs defined in the pattern. 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(leSetConnectionlessIAndQSamplingEnable.UserFields.NumberOfAntennaIds, 8), "", "01", "4B", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < leSetConnectionlessIAndQSamplingEnable.UserFields.AntennaIdsSetList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Antenna_IDs[" + i + "]", "", 8, FormatValue(leSetConnectionlessIAndQSamplingEnable.UserFields.AntennaIdsSetList[i].AntennaIds, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

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