using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class IoCapabilityRequestReplyInfo : PacketInfoBase
{
	public override string Name => "Io Capability Request Reply";

	public override string DisplayGroup => "Link Control";

	public IoCapabilityRequestReplyInfo(IoCapabilityRequestReply packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		IoCapabilityRequestReply ioCapabilityRequestReply = (IoCapabilityRequestReply)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD_ADDR", "BD_ADDR of remote device involved in simple pairing process.", 48, FormatValue(ioCapabilityRequestReply.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("IO_Capability", IoCapabilityInfo.IoCapabilityToDescription(), 8, FormatValue(ioCapabilityRequestReply.UserFields.IoCapability, 8), IoCapabilityInfo.IoCapabilityToString(IoCapabilityInfo.ValueToIoCapability(ioCapabilityRequestReply.UserFields.IoCapability)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("OOB_Data_Present", IoCapabilityRequestReply.UserFieldsWrapper.OobDataPresentInfo.OobDataPresentToDescription(), 8, FormatValue(ioCapabilityRequestReply.UserFields.OobDataPresent, 8), IoCapabilityRequestReply.UserFieldsWrapper.OobDataPresentInfo.OobDataPresentToString(IoCapabilityRequestReply.UserFieldsWrapper.OobDataPresentInfo.ValueToOobDataPresent(ioCapabilityRequestReply.UserFields.OobDataPresent)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Authentication_Requirements", AuthenticationRequirementsInfo.AuthenticationRequirementsToDescription(), 8, FormatValue(ioCapabilityRequestReply.UserFields.AuthenticationRequirements, 8), AuthenticationRequirementsInfo.AuthenticationRequirementsToString(AuthenticationRequirementsInfo.ValueToAuthenticationRequirements(ioCapabilityRequestReply.UserFields.AuthenticationRequirements)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		IoCapabilityRequestReply ioCapabilityRequestReply = (IoCapabilityRequestReply)packet;
		int num = -1;
		if (index == ++num)
		{
			ioCapabilityRequestReply.UserFields.BdAddr = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			ioCapabilityRequestReply.UserFields.IoCapability = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ioCapabilityRequestReply.UserFields.OobDataPresent = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ioCapabilityRequestReply.UserFields.AuthenticationRequirements = Convert.ToUInt32(value, 16);
		}
	}
}
