using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HeadlessDeleteDeviceInfo : PacketInfoBase
{
	public override string Name => "Headless Delete Device";

	public override string DisplayGroup => "Vendor Specific";

	public HeadlessDeleteDeviceInfo(HeadlessDeleteDevice packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HeadlessDeleteDevice headlessDeleteDevice = (HeadlessDeleteDevice)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "HCI_VSC_HEADLESS_DEV_DEL", 8, FormatValue(headlessDeleteDevice.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Bd_Addr", "Bluetooth Address of remote device. If the Bd_Addr is 0x0, then this means delete all of the BR/EDR devices.", 48, FormatValue(headlessDeleteDevice.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HeadlessDeleteDevice headlessDeleteDevice = (HeadlessDeleteDevice)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			headlessDeleteDevice.UserFields.BdAddr = Convert.ToUInt64(value, 16);
		}
	}
}
