using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class RejectSynchronousConnectionRequestInfo : PacketInfoBase
{
	public override string Name => "Reject Synchronous Connection Request";

	public override string DisplayGroup => "Link Control";

	public RejectSynchronousConnectionRequestInfo(RejectSynchronousConnectionRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		RejectSynchronousConnectionRequest rejectSynchronousConnectionRequest = (RejectSynchronousConnectionRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD_ADDR", "BD_ADDR of the device requesting the connection.", 48, FormatValue(rejectSynchronousConnectionRequest.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Reason", RejectSynchronousConnectionRequest.UserFieldsWrapper.ReasonInfo.ReasonToDescription(), 32, FormatValue(rejectSynchronousConnectionRequest.UserFields.Reason, 32), RejectSynchronousConnectionRequest.UserFieldsWrapper.ReasonInfo.ReasonToString(RejectSynchronousConnectionRequest.UserFieldsWrapper.ReasonInfo.ValueToReason(rejectSynchronousConnectionRequest.UserFields.Reason)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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