using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciVsDebugPinTestEvtInfo : PacketInfoBase
{
	public override string Name => "Hci Vs Debug Pin Test Evt";

	public override string DisplayGroup => "Vendor Specific";

	public HciVsDebugPinTestEvtInfo(HciVsDebugPinTestEvt packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciVsDebugPinTestEvt hciVsDebugPinTestEvt = (HciVsDebugPinTestEvt)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("OpCode", "Debug", 8, FormatValue(hciVsDebugPinTestEvt.UserFields.Opcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SubOpCode", "HCI_VS_DEBUG_PIN_TEST_CMD", 8, FormatValue(hciVsDebugPinTestEvt.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("InterfaceID", PinConnectivityInterfaceIdInfo.PinConnectivityInterfaceIdToDescription(), 8, FormatValue(hciVsDebugPinTestEvt.UserFields.Interfaceid, 8), PinConnectivityInterfaceIdInfo.PinConnectivityInterfaceIdToString(PinConnectivityInterfaceIdInfo.ValueToPinConnectivityInterfaceId(hciVsDebugPinTestEvt.UserFields.Interfaceid)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(hciVsDebugPinTestEvt.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(hciVsDebugPinTestEvt.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciVsDebugPinTestEvt hciVsDebugPinTestEvt = (HciVsDebugPinTestEvt)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Opcode");
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Subopcode");
		}
		if (index == ++num)
		{
			hciVsDebugPinTestEvt.UserFields.Interfaceid = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciVsDebugPinTestEvt.UserFields.Status = Convert.ToUInt32(value, 16);
		}
	}
}
