using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetDataLengthInfo : PacketInfoBase
{
	public override string Name => "Le Set Data Length";

	public override string DisplayGroup => "LE Controller";

	public LeSetDataLengthInfo(LeSetDataLength packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetDataLength leSetDataLength = (LeSetDataLength)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to identify a connection. Range: 0x0000-0x0EFF. Reserved for future use (0x0F00 - 0x0FFF)", 16, FormatValue(leSetDataLength.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TxOctets", "Preferred maximum number of payload octets that the local Controller should include in a single Link Layer Data Channel PDU. Range: 0x001B-0x00FB. Reserved for future use (0x0000 - 0x001A and 0x00FC - 0xFFFF)", 16, FormatValue(leSetDataLength.UserFields.Txoctets, 16), "", "001B", "00FB", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TxTime", "Preferred maximum number of microseconds that the local Controller should use to transmit a single Link Layer Data Channel PDU. Range: 0x0148-0x4290 (all other values reserved for future use)", 16, FormatValue(leSetDataLength.UserFields.Txtime, 16), "", "0148", "4290", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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