using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeWriteSuggestedDefaultDataLengthInfo : PacketInfoBase
{
	public override string Name => "Le Write Suggested Default Data Length";

	public override string DisplayGroup => "LE Controller";

	public LeWriteSuggestedDefaultDataLengthInfo(LeWriteSuggestedDefaultDataLength packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeWriteSuggestedDefaultDataLength leWriteSuggestedDefaultDataLength = (LeWriteSuggestedDefaultDataLength)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Suggested_Max_Tx_Octets", "The Host's suggested value for the Controller's maximum transmitted packet size to be used for new connections - connInitialMaxTxOctets. Range 0x001B-0x00FB (0x0000 - 0x001A and 0x00FC - 0xFFFF Reserved for future use)", 16, FormatValue(leWriteSuggestedDefaultDataLength.UserFields.SuggestedMaxTxOctets, 16), "", "001B", "00FB", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Suggested_Max_Tx_Time", "The Host's suggested value for the Controller's maximum packet transmission time to be used for new connections - connInitialMaxTxTime. Range: 0x0148-0x4290 (all other values reserved for future use)", 16, FormatValue(leWriteSuggestedDefaultDataLength.UserFields.SuggestedMaxTxTime, 16), "", "0148", "4290", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeWriteSuggestedDefaultDataLength leWriteSuggestedDefaultDataLength = (LeWriteSuggestedDefaultDataLength)packet;
		int num = -1;
		if (index == ++num)
		{
			leWriteSuggestedDefaultDataLength.UserFields.SuggestedMaxTxOctets = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leWriteSuggestedDefaultDataLength.UserFields.SuggestedMaxTxTime = Convert.ToUInt32(value, 16);
		}
	}
}
