using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

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

	public override string DisplayGroup => "Link Control";

	public IoCapabilityRequestNegativeReplyInfo(IoCapabilityRequestNegativeReply packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		IoCapabilityRequestNegativeReply ioCapabilityRequestNegativeReply = (IoCapabilityRequestNegativeReply)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD_ADDR", "BD_ADDR of remote device involved in the Simple Pairing process.", 48, FormatValue(ioCapabilityRequestNegativeReply.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Reason", "Reason that Simple Pairing rejected. See BT Specification document for Error Codes and descriptions.", 8, FormatValue(ioCapabilityRequestNegativeReply.UserFields.Reason, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		IoCapabilityRequestNegativeReply ioCapabilityRequestNegativeReply = (IoCapabilityRequestNegativeReply)packet;
		int num = -1;
		if (index == ++num)
		{
			ioCapabilityRequestNegativeReply.UserFields.BdAddr = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			ioCapabilityRequestNegativeReply.UserFields.Reason = Convert.ToUInt32(value, 16);
		}
	}
}
