using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetAdvertisingSetRandomAddressInfo : PacketInfoBase
{
	public override string Name => "Le Set Advertising Set Random Address";

	public override string DisplayGroup => "LE Controller";

	public LeSetAdvertisingSetRandomAddressInfo(LeSetAdvertisingSetRandomAddress packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetAdvertisingSetRandomAddress leSetAdvertisingSetRandomAddress = (LeSetAdvertisingSetRandomAddress)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Handle", "Used to identify an advertising set", 8, FormatValue(leSetAdvertisingSetRandomAddress.UserFields.AdvertisingHandle, 8), "", "00", "EF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Random_Address", "Random Device Address as defined by [Vol 6] Part B, Section1.3.2.", 48, FormatValue(leSetAdvertisingSetRandomAddress.UserFields.AdvertisingRandomAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetAdvertisingSetRandomAddress leSetAdvertisingSetRandomAddress = (LeSetAdvertisingSetRandomAddress)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetAdvertisingSetRandomAddress.UserFields.AdvertisingHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetAdvertisingSetRandomAddress.UserFields.AdvertisingRandomAddress = Convert.ToUInt64(value, 16);
		}
	}
}
