using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeRejectCisRequestInfo : PacketInfoBase
{
	public override string Name => "Le Reject Cis Request";

	public override string DisplayGroup => "LE Controller";

	public LeRejectCisRequestInfo(LeRejectCisRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeRejectCisRequest leRejectCisRequest = (LeRejectCisRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection handle of the Connected Isochronous Stream.", 16, FormatValue(leRejectCisRequest.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Reason", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(leRejectCisRequest.UserFields.Reason, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(leRejectCisRequest.UserFields.Reason)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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