using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ReadRemoteVersionInformationCompleteInfo : PacketInfoBase
{
	public override string Name => "Read Remote Version Information Complete";

	public override string DisplayGroup => "Link Control";

	public ReadRemoteVersionInformationCompleteInfo(ReadRemoteVersionInformationComplete packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ReadRemoteVersionInformationComplete readRemoteVersionInformationComplete = (ReadRemoteVersionInformationComplete)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(readRemoteVersionInformationComplete.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(readRemoteVersionInformationComplete.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection Handle which is used for the Read_Remote_Version_Information command.", 16, FormatValue(readRemoteVersionInformationComplete.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Version", "Version of the Current LMP in the remote Controller. See LMP VersNr and Link LayerVersNr in the Bluetooth Assigned Numbers.", 8, FormatValue(readRemoteVersionInformationComplete.UserFields.Version, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Manufacturer_Name", "Manufacturer Name of the remote Controller. See CompId in the Bluetooth Assigned Numbers.", 16, FormatValue(readRemoteVersionInformationComplete.UserFields.ManufacturerName, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Subversion", "Subversion of the LMP in the remote Controller.", 16, FormatValue(readRemoteVersionInformationComplete.UserFields.Subversion, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ReadRemoteVersionInformationComplete readRemoteVersionInformationComplete = (ReadRemoteVersionInformationComplete)packet;
		int num = -1;
		if (index == ++num)
		{
			readRemoteVersionInformationComplete.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			readRemoteVersionInformationComplete.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			readRemoteVersionInformationComplete.UserFields.Version = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			readRemoteVersionInformationComplete.UserFields.ManufacturerName = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			readRemoteVersionInformationComplete.UserFields.Subversion = Convert.ToUInt32(value, 16);
		}
	}
}
