using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class UserConfirmationRequestInfo : PacketInfoBase
{
	public override string Name => "User Confirmation Request";

	public override string DisplayGroup => "Link Control";

	public UserConfirmationRequestInfo(UserConfirmationRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		UserConfirmationRequest userConfirmationRequest = (UserConfirmationRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD_ADDR", "BD_ADDR of device involved in Simple Pairing process.", 48, FormatValue(userConfirmationRequest.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Numeric_Value", "Numeric value to be displayed. Valid values are decimal 000000 - 999999.", 32, FormatValue(userConfirmationRequest.UserFields.NumericValue, 32), "", "00000000", "000F423F", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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