using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class WriteAuthenticatedPayloadTimeoutInfo : PacketInfoBase
{
	public override string Name => "Write Authenticated Payload Timeout";

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

	public WriteAuthenticatedPayloadTimeoutInfo(WriteAuthenticatedPayloadTimeout packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		WriteAuthenticatedPayloadTimeout writeAuthenticatedPayloadTimeout = (WriteAuthenticatedPayloadTimeout)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle used to identify a connection. Range: 0x0000-0x0EFF.  Reserved for future use (0x0F00 - 0x0FFF)", 16, FormatValue(writeAuthenticatedPayloadTimeout.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Authenticated_Payload_Timeout", "Maximum amount of time specified between packets authenticated by a valid MIC. Range: 0x0001 to 0xFFFF, Time = N * 10 msec, Time Range: 10 msec to 655,350 msec", 16, FormatValue(writeAuthenticatedPayloadTimeout.UserFields.AuthenticatedPayloadTimeout, 16), "", "0001", "FFFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		WriteAuthenticatedPayloadTimeout writeAuthenticatedPayloadTimeout = (WriteAuthenticatedPayloadTimeout)packet;
		int num = -1;
		if (index == ++num)
		{
			writeAuthenticatedPayloadTimeout.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			writeAuthenticatedPayloadTimeout.UserFields.AuthenticatedPayloadTimeout = Convert.ToUInt32(value, 16);
		}
	}
}
