using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

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

	public override string DisplayGroup => "Vendor Specific";

	public LeExtendedSetScanParametersInfo(LeExtendedSetScanParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeExtendedSetScanParameters leExtendedSetScanParameters = (LeExtendedSetScanParameters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("LE_Ex_Scan_Type", LeExtendedSetScanParameters.UserFieldsWrapper.LeExScanTypeInfo.LeExScanTypeToDescription(), 8, FormatValue(leExtendedSetScanParameters.UserFields.LeExScanType, 8), LeExtendedSetScanParameters.UserFieldsWrapper.LeExScanTypeInfo.LeExScanTypeToString(LeExtendedSetScanParameters.UserFieldsWrapper.LeExScanTypeInfo.ValueToLeExScanType(leExtendedSetScanParameters.UserFields.LeExScanType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LE_Ex_Scan_Interval", "This is defined as the time interval from when the Controller started its last LE scan until it begins the subsequent LE scan,Range: 0x0004 to 0x00FFFFFF, Default: 0x0010 (10 ms), Time = N * 0.625 msec, Time Range: 2.5 msec to 10442.25 seconds ", 32, FormatValue(leExtendedSetScanParameters.UserFields.LeExScanInterval, 32), "", "00000004", "00FFFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LE_Ex_Scan_Window", "The duration of the LE scan. LE_Scan_Window shall be less than or equal to LE_Scan_Interval, Range: 0x0004 to 0xFFFF, Default: 0x0010 (10 ms), Time = N * 0.625 msec, Time Range: 2.5 msec to 40.95 seconds", 32, FormatValue(leExtendedSetScanParameters.UserFields.LeExScanWindow, 32), "", "00000004", "0000FFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Own_Address_Type", DeviceAddressTypeInfo.DeviceAddressTypeToDescription(), 8, FormatValue(leExtendedSetScanParameters.UserFields.OwnAddressType, 8), DeviceAddressTypeInfo.DeviceAddressTypeToString(DeviceAddressTypeInfo.ValueToDeviceAddressType(leExtendedSetScanParameters.UserFields.OwnAddressType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LE_Ex_Scan_Filter_Policy", LeExtendedSetScanParameters.UserFieldsWrapper.LeExScanFilterPolicyInfo.LeExScanFilterPolicyToDescription(), 8, FormatValue(leExtendedSetScanParameters.UserFields.LeExScanFilterPolicy, 8), LeExtendedSetScanParameters.UserFieldsWrapper.LeExScanFilterPolicyInfo.LeExScanFilterPolicyToString(LeExtendedSetScanParameters.UserFieldsWrapper.LeExScanFilterPolicyInfo.ValueToLeExScanFilterPolicy(leExtendedSetScanParameters.UserFields.LeExScanFilterPolicy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeExtendedSetScanParameters leExtendedSetScanParameters = (LeExtendedSetScanParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			leExtendedSetScanParameters.UserFields.LeExScanType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leExtendedSetScanParameters.UserFields.LeExScanInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leExtendedSetScanParameters.UserFields.LeExScanWindow = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leExtendedSetScanParameters.UserFields.OwnAddressType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leExtendedSetScanParameters.UserFields.LeExScanFilterPolicy = Convert.ToUInt32(value, 16);
		}
	}
}
