using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class WriteLinkSupervisionTimeoutInfo : PacketInfoBase
{
	public override string Name => "Write Link Supervision Timeout";

	public override string DisplayGroup => "Host Control and Baseband";

	public WriteLinkSupervisionTimeoutInfo(WriteLinkSupervisionTimeout packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		WriteLinkSupervisionTimeout writeLinkSupervisionTimeout = (WriteLinkSupervisionTimeout)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Handle", "Specifies which Handle's Link Supervision Timeout value is to be written. The Handle is a Connection Handle for a BR/EDR Controller. On an AMP a Physical Link Handle is used as the lower 8 bits of the Handle. The upper 4 bits are reserved and shall be set to 0. Range: 0x0000-0x0EFF. Reserved for future use (0x0F00 - 0x0FFF)", 16, FormatValue(writeLinkSupervisionTimeout.UserFields.Handle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Link_Supervision_Timeout", "0x0000: No Link_Supervision_Timeout. Measured in Number of BR/EDR Baseband slots, Link_Supervision_Timeout = N*0.625 msec (1 Baseband slot), Range for N: 0x0001 â€“ 0xFFFF, Time Range: 0.625ms - 40.9 sec, Default: N = 0x7D00, Link_Supervision_Timeout = 20 sec, Mandatory Range for Controller: 0x0190 to 0xFFFF; plus 0 for infinite timeout.", 16, FormatValue(writeLinkSupervisionTimeout.UserFields.LinkSupervisionTimeout, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		WriteLinkSupervisionTimeout writeLinkSupervisionTimeout = (WriteLinkSupervisionTimeout)packet;
		int num = -1;
		if (index == ++num)
		{
			writeLinkSupervisionTimeout.UserFields.Handle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			writeLinkSupervisionTimeout.UserFields.LinkSupervisionTimeout = Convert.ToUInt32(value, 16);
		}
	}
}
