using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciVsRdbConnStatsInfo : PacketInfoBase
{
	public override string Name => "Hci Vs Rdb Conn Stats";

	public override string DisplayGroup => "Vendor Specific";

	public HciVsRdbConnStatsInfo(HciVsRdbConnStats packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciVsRdbConnStats hciVsRdbConnStats = (HciVsRdbConnStats)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub_OpCode", "Read conneciton state database.", 8, FormatValue(hciVsRdbConnStats.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "", 16, FormatValue(hciVsRdbConnStats.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciVsRdbConnStats hciVsRdbConnStats = (HciVsRdbConnStats)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			hciVsRdbConnStats.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
	}
}
