using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciSniffModeInfo : PacketInfoBase
{
	public override string Name => "Hci Sniff Mode";

	public override string DisplayGroup => "Link Policy";

	public HciSniffModeInfo(HciSniffMode packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciSniffMode hciSniffMode = (HciSniffMode)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to identify a connection.Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(hciSniffMode.UserFields.ConnectionHandle, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sniff_Max_Interval", HciSniffMode.UserFieldsWrapper.SniffMaxIntervalInfo.SniffMaxIntervalToDescription(), 16, FormatValue(hciSniffMode.UserFields.SniffMaxInterval, 16), ValueTimes0p625MsecExpression.ValueTimes0p625MsecToString(hciSniffMode.UserFields.SniffMaxInterval), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sniff_Min_Interval", HciSniffMode.UserFieldsWrapper.SniffMinIntervalInfo.SniffMinIntervalToDescription(), 16, FormatValue(hciSniffMode.UserFields.SniffMinInterval, 16), ValueTimes0p625MsecExpression.ValueTimes0p625MsecToString(hciSniffMode.UserFields.SniffMinInterval), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sniff_Attempt", HciSniffMode.UserFieldsWrapper.SniffAttemptInfo.SniffAttemptToDescription(), 16, FormatValue(hciSniffMode.UserFields.SniffAttempt, 16), ValueTimes0p625MsecExpression.ValueTimes0p625MsecToString(hciSniffMode.UserFields.SniffAttempt), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sniff_Timeout", HciSniffMode.UserFieldsWrapper.SniffTimeoutInfo.SniffTimeoutToDescription(), 16, FormatValue(hciSniffMode.UserFields.SniffTimeout, 16), ValueTimes0p625MsecExpression.ValueTimes0p625MsecToString(hciSniffMode.UserFields.SniffTimeout), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciSniffMode hciSniffMode = (HciSniffMode)packet;
		int num = -1;
		if (index == ++num)
		{
			hciSniffMode.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSniffMode.UserFields.SniffMaxInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSniffMode.UserFields.SniffMinInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSniffMode.UserFields.SniffAttempt = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSniffMode.UserFields.SniffTimeout = Convert.ToUInt32(value, 16);
		}
	}
}
