using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciAcceptConnectionRequestInfo : PacketInfoBase
{
	public override string Name => "Hci Accept Connection Request";

	public override string DisplayGroup => "Link Control";

	public HciAcceptConnectionRequestInfo(HciAcceptConnectionRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciAcceptConnectionRequest hciAcceptConnectionRequest = (HciAcceptConnectionRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD_ADDR", "BD_ADDR of the Device to be connected", 48, FormatValue(hciAcceptConnectionRequest.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Role", HciAcceptConnectionRequest.UserFieldsWrapper.RoleInfo.RoleToDescription(), 8, FormatValue(hciAcceptConnectionRequest.UserFields.Role, 8), HciAcceptConnectionRequest.UserFieldsWrapper.RoleInfo.RoleToString(HciAcceptConnectionRequest.UserFieldsWrapper.RoleInfo.ValueToRole(hciAcceptConnectionRequest.UserFields.Role)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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