using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

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

	public override string DisplayGroup => "LE Controller";

	public LeSetExtendedAdvertisingParametersInfo(LeSetExtendedAdvertisingParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetExtendedAdvertisingParameters leSetExtendedAdvertisingParameters = (LeSetExtendedAdvertisingParameters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Handle", "Used to identify an advertising set.", 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.AdvertisingHandle, 8), "", "00", "EF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Event_Properties", LeSetExtendedAdvertisingParameters.UserFieldsWrapper.AdvertisingEventPropertiesInfo.AdvertisingEventPropertiesToDescription(), 16, FormatValue(leSetExtendedAdvertisingParameters.UserFields.AdvertisingEventProperties, 16), LeSetExtendedAdvertisingParameters.UserFieldsWrapper.AdvertisingEventPropertiesInfo.AdvertisingEventPropertiesToString(LeSetExtendedAdvertisingParameters.UserFieldsWrapper.AdvertisingEventPropertiesInfo.ValueToAdvertisingEventProperties(leSetExtendedAdvertisingParameters.UserFields.AdvertisingEventProperties)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Primary_Advertising_Interval_Min", "Minimum advertising interval for undirected and low duty cycle directed advertising. Range: 0x000020 to 0xFFFFFF. Time = N * 0.625 ms, Time Range: 20 ms to 10,486759 s\r\n\r\n" + ExtAdvIntervalInfo.ExtAdvIntervalToDescription(), 24, FormatValue(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingIntervalMin, 24), ExtAdvIntervalInfo.ExtAdvIntervalToString(ExtAdvIntervalInfo.ValueToExtAdvInterval(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingIntervalMin)), "000020", "FFFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Primary_Advertising_Interval_Max", "Maximum advertising interval for undirected and low duty cycle directed advertising. Range: 0x000020 to 0xFFFFFF. Time = N * 0.625 ms, Time Range: 20 ms to 10,486759 s\r\n\r\n" + ExtAdvIntervalInfo.ExtAdvIntervalToDescription(), 24, FormatValue(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingIntervalMax, 24), ExtAdvIntervalInfo.ExtAdvIntervalToString(ExtAdvIntervalInfo.ValueToExtAdvInterval(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingIntervalMax)), "000020", "FFFFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Primary_Advertising_Channel_Map", AdvertisingChannelMapInfo.AdvertisingChannelMapToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingChannelMap, 8), AdvertisingChannelMapInfo.AdvertisingChannelMapToString(AdvertisingChannelMapInfo.ValueToAdvertisingChannelMap(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingChannelMap)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Own_Address_Type", ExtendedAdvertisingOwnAddressTypeInfo.ExtendedAdvertisingOwnAddressTypeToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.OwnAddressType, 8), ExtendedAdvertisingOwnAddressTypeInfo.ExtendedAdvertisingOwnAddressTypeToString(ExtendedAdvertisingOwnAddressTypeInfo.ValueToExtendedAdvertisingOwnAddressType(leSetExtendedAdvertisingParameters.UserFields.OwnAddressType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Peer_Address_Type", PeerAddressTypeInfo.PeerAddressTypeToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.PeerAddressType, 8), PeerAddressTypeInfo.PeerAddressTypeToString(PeerAddressTypeInfo.ValueToPeerAddressType(leSetExtendedAdvertisingParameters.UserFields.PeerAddressType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Peer_Address", "Public Device Address, Random Device Address, Public Identity Address, or Random (static) Identity Address of the device to be connected.", 48, FormatValue(leSetExtendedAdvertisingParameters.UserFields.PeerAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Filter_Policy", AdvertisingFilterPolicyInfo.AdvertisingFilterPolicyToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.AdvertisingFilterPolicy, 8), AdvertisingFilterPolicyInfo.AdvertisingFilterPolicyToString(AdvertisingFilterPolicyInfo.ValueToAdvertisingFilterPolicy(leSetExtendedAdvertisingParameters.UserFields.AdvertisingFilterPolicy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Tx_Power", "Size: 1 Octet (signed integer), Range: -127 ≤ N ≤ +126, Units: dBm\r\n\r\n" + ExtendedAdvertisingTxPowerInfo.ExtendedAdvertisingTxPowerToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.AdvertisingTxPower, 8), ExtendedAdvertisingTxPowerInfo.ExtendedAdvertisingTxPowerToString(ExtendedAdvertisingTxPowerInfo.ValueToExtendedAdvertisingTxPower(leSetExtendedAdvertisingParameters.UserFields.AdvertisingTxPower)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Primary_Advertising_PHY", LeSetExtendedAdvertisingParameters.UserFieldsWrapper.PrimaryAdvertisingPhyInfo.PrimaryAdvertisingPhyToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingPhy, 8), LeSetExtendedAdvertisingParameters.UserFieldsWrapper.PrimaryAdvertisingPhyInfo.PrimaryAdvertisingPhyToString(LeSetExtendedAdvertisingParameters.UserFieldsWrapper.PrimaryAdvertisingPhyInfo.ValueToPrimaryAdvertisingPhy(leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingPhy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Secondary_Advertising_Max_Skip", LeSetExtendedAdvertisingParameters.UserFieldsWrapper.SecondaryAdvertisingMaxSkipInfo.SecondaryAdvertisingMaxSkipToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.SecondaryAdvertisingMaxSkip, 8), LeSetExtendedAdvertisingParameters.UserFieldsWrapper.SecondaryAdvertisingMaxSkipInfo.SecondaryAdvertisingMaxSkipToString(LeSetExtendedAdvertisingParameters.UserFieldsWrapper.SecondaryAdvertisingMaxSkipInfo.ValueToSecondaryAdvertisingMaxSkip(leSetExtendedAdvertisingParameters.UserFields.SecondaryAdvertisingMaxSkip)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Secondary_Advertising_PHY", LeSetExtendedAdvertisingParameters.UserFieldsWrapper.SecondaryAdvertisingPhyInfo.SecondaryAdvertisingPhyToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.SecondaryAdvertisingPhy, 8), LeSetExtendedAdvertisingParameters.UserFieldsWrapper.SecondaryAdvertisingPhyInfo.SecondaryAdvertisingPhyToString(LeSetExtendedAdvertisingParameters.UserFieldsWrapper.SecondaryAdvertisingPhyInfo.ValueToSecondaryAdvertisingPhy(leSetExtendedAdvertisingParameters.UserFields.SecondaryAdvertisingPhy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_SID", AdvertisingSidInfo.AdvertisingSidToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.AdvertisingSid, 8), AdvertisingSidInfo.AdvertisingSidToString(AdvertisingSidInfo.ValueToAdvertisingSid(leSetExtendedAdvertisingParameters.UserFields.AdvertisingSid)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Scan_Request_Notification_Enable", LeSetExtendedAdvertisingParameters.UserFieldsWrapper.ScanRequestNotificationEnableInfo.ScanRequestNotificationEnableToDescription(), 8, FormatValue(leSetExtendedAdvertisingParameters.UserFields.ScanRequestNotificationEnable, 8), LeSetExtendedAdvertisingParameters.UserFieldsWrapper.ScanRequestNotificationEnableInfo.ScanRequestNotificationEnableToString(LeSetExtendedAdvertisingParameters.UserFieldsWrapper.ScanRequestNotificationEnableInfo.ValueToScanRequestNotificationEnable(leSetExtendedAdvertisingParameters.UserFields.ScanRequestNotificationEnable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetExtendedAdvertisingParameters leSetExtendedAdvertisingParameters = (LeSetExtendedAdvertisingParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.AdvertisingHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.AdvertisingEventProperties = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingIntervalMin = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingIntervalMax = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingChannelMap = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.OwnAddressType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.PeerAddressType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.PeerAddress = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.AdvertisingFilterPolicy = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.AdvertisingTxPower = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.PrimaryAdvertisingPhy = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.SecondaryAdvertisingMaxSkip = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.SecondaryAdvertisingPhy = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.AdvertisingSid = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetExtendedAdvertisingParameters.UserFields.ScanRequestNotificationEnable = Convert.ToUInt32(value, 16);
		}
	}
}
