using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeReadPeerResolvableAddressInfo : PacketInfoBase
{
	public override string Name => "Le Read Peer Resolvable Address";

	public override string DisplayGroup => "LE Controller";

	public LeReadPeerResolvableAddressInfo(LeReadPeerResolvableAddress packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeReadPeerResolvableAddress leReadPeerResolvableAddress = (LeReadPeerResolvableAddress)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Peer_Identity_Address_Type", PeerIdentityAddressTypeInfo.PeerIdentityAddressTypeToDescription(), 8, FormatValue(leReadPeerResolvableAddress.UserFields.PeerIdentityAddressType, 8), PeerIdentityAddressTypeInfo.PeerIdentityAddressTypeToString(PeerIdentityAddressTypeInfo.ValueToPeerIdentityAddressType(leReadPeerResolvableAddress.UserFields.PeerIdentityAddressType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Peer_Identity_Address", "Public or Random (static) Identity address of the peer device", 48, FormatValue(leReadPeerResolvableAddress.UserFields.PeerIdentityAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeReadPeerResolvableAddress leReadPeerResolvableAddress = (LeReadPeerResolvableAddress)packet;
		int num = -1;
		if (index == ++num)
		{
			leReadPeerResolvableAddress.UserFields.PeerIdentityAddressType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leReadPeerResolvableAddress.UserFields.PeerIdentityAddress = Convert.ToUInt64(value, 16);
		}
	}
}
