using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeRpaOffloadRemoveIrkFromListInfo : PacketInfoBase
{
	public override string Name => "Le Rpa Offload Remove Irk From List";

	public override string DisplayGroup => "Vendor Specific";

	public LeRpaOffloadRemoveIrkFromListInfo(LeRpaOffloadRemoveIrkFromList packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeRpaOffloadRemoveIrkFromList leRpaOffloadRemoveIrkFromList = (LeRpaOffloadRemoveIrkFromList)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("RPA_offload_opcode", "Remove IRK from the list", 8, FormatValue(leRpaOffloadRemoveIrkFromList.UserFields.RpaOffloadOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Address_Type", DeviceAddressTypeInfo.DeviceAddressTypeToDescription(), 8, FormatValue(leRpaOffloadRemoveIrkFromList.UserFields.AddressType, 8), DeviceAddressTypeInfo.DeviceAddressTypeToString(DeviceAddressTypeInfo.ValueToDeviceAddressType(leRpaOffloadRemoveIrkFromList.UserFields.AddressType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LE_Device_Address", "Public or Random address associated to IRK (1st byte LSB)", 48, FormatValue(leRpaOffloadRemoveIrkFromList.UserFields.LeDeviceAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeRpaOffloadRemoveIrkFromList leRpaOffloadRemoveIrkFromList = (LeRpaOffloadRemoveIrkFromList)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field RpaOffloadOpcode");
		}
		if (index == ++num)
		{
			leRpaOffloadRemoveIrkFromList.UserFields.AddressType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leRpaOffloadRemoveIrkFromList.UserFields.LeDeviceAddress = Convert.ToUInt64(value, 16);
		}
	}
}
