using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeBiginfoAdvertisingReportInfo : PacketInfoBase
{
	public override string Name => "Le Biginfo Advertising Report";

	public override string DisplayGroup => "LE Controller";

	public LeBiginfoAdvertisingReportInfo(LeBiginfoAdvertisingReport packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeBiginfoAdvertisingReport leBiginfoAdvertisingReport = (LeBiginfoAdvertisingReport)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Subevent_Code", "Subevent Code for HCI_LE_BIGInfo_Advertising_Report event.", 8, FormatValue(leBiginfoAdvertisingReport.UserFields.SubeventCode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sync_Handle", "Used to identify the periodic advertising.", 16, FormatValue(leBiginfoAdvertisingReport.UserFields.SyncHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Num_BIS", "Total number of Broadcast Isochronous Streams to synchronize to.", 8, FormatValue(leBiginfoAdvertisingReport.UserFields.NumBis, 8), "", "1", "1F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("NSE", "", 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Nse, 8), "", "1", "1E", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ISO_Interval", "", 16, FormatValue(leBiginfoAdvertisingReport.UserFields.IsoInterval, 16), "", "4", "0C80", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("BN", "", 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Bn, 8), "", "0", "7", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PTO", "", 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Pto, 8), "", "0", "0F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("IRC", "", 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Irc, 8), "", "1", "0F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_PDU", "", 16, FormatValue(leBiginfoAdvertisingReport.UserFields.MaxPdu, 16), "", "0", "FB", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SDU_Interval", "", 24, FormatValue(leBiginfoAdvertisingReport.UserFields.SduInterval, 24), "", "FF", "FFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_SDU", "", 16, FormatValue(leBiginfoAdvertisingReport.UserFields.MaxSdu, 16), "", "0", "FFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY", LePhyInfo.LePhyToDescription(), 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Phy, 8), LePhyInfo.LePhyToString(LePhyInfo.ValueToLePhy(leBiginfoAdvertisingReport.UserFields.Phy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Framing", IsoFramingInfo.IsoFramingToDescription(), 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Framing, 8), IsoFramingInfo.IsoFramingToString(IsoFramingInfo.ValueToIsoFraming(leBiginfoAdvertisingReport.UserFields.Framing)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Encryption", IsoEncryptionInfo.IsoEncryptionToDescription(), 8, FormatValue(leBiginfoAdvertisingReport.UserFields.Encryption, 8), IsoEncryptionInfo.IsoEncryptionToString(IsoEncryptionInfo.ValueToIsoEncryption(leBiginfoAdvertisingReport.UserFields.Encryption)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeBiginfoAdvertisingReport leBiginfoAdvertisingReport = (LeBiginfoAdvertisingReport)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubeventCode");
		}
		if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.SyncHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.NumBis = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Nse = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.IsoInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Bn = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Pto = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Irc = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.MaxPdu = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.SduInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.MaxSdu = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Phy = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Framing = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBiginfoAdvertisingReport.UserFields.Encryption = Convert.ToUInt32(value, 16);
		}
	}
}
