using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HogpSetLeScanParametersInfo : PacketInfoBase
{
	public override string Name => "Hogp Set Le Scan Parameters";

	public override string DisplayGroup => "Vendor Specific";

	public HogpSetLeScanParametersInfo(HogpSetLeScanParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HogpSetLeScanParameters hogpSetLeScanParameters = (HogpSetLeScanParameters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "HCI_VSC_HOGP_SET_SCAN_PARA", 8, FormatValue(hogpSetLeScanParameters.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Scan Type", "LE Scan Type", 8, FormatValue(hogpSetLeScanParameters.UserFields.ScanType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Scan Interval", "LE Scan Interval", 16, FormatValue(hogpSetLeScanParameters.UserFields.ScanInterval, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Scan Window", "LE Scan Window", 16, FormatValue(hogpSetLeScanParameters.UserFields.ScanWindow, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Addr Type", "Addr Type", 8, FormatValue(hogpSetLeScanParameters.UserFields.AddrType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Filter Policy", "Filter Policy", 8, FormatValue(hogpSetLeScanParameters.UserFields.FilterPolicy, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HogpSetLeScanParameters hogpSetLeScanParameters = (HogpSetLeScanParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			hogpSetLeScanParameters.UserFields.ScanType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hogpSetLeScanParameters.UserFields.ScanInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hogpSetLeScanParameters.UserFields.ScanWindow = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hogpSetLeScanParameters.UserFields.AddrType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hogpSetLeScanParameters.UserFields.FilterPolicy = Convert.ToUInt32(value, 16);
		}
	}
}
