using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

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

	public override string DisplayGroup => "LE Controller";

	public LeReadLocalResolvableAddressInfo(LeReadLocalResolvableAddress packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

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

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