using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class QbceQleSetPhyInfo : PacketInfoBase
{
	public override string Name => "Qbce Qle Set Phy";

	public override string DisplayGroup => "Vendor Specific";

	public QbceQleSetPhyInfo(QbceQleSetPhy packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		QbceQleSetPhy qbceQleSetPhy = (QbceQleSetPhy)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Subopcode", "HCI_VS_QBCE_QLE_SET_PHY", 8, FormatValue(qbceQleSetPhy.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to identify a connection. Range:0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(qbceQleSetPhy.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("ALL_PHYS", PhyPreferenceUseInfo.PhyPreferenceUseToDescription(), 8, FormatValue(qbceQleSetPhy.UserFields.AllPhys, 8), PhyPreferenceUseInfo.PhyPreferenceUseToString(PhyPreferenceUseInfo.ValueToPhyPreferenceUse(qbceQleSetPhy.UserFields.AllPhys)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TX_PHYS", QbceTransmitterPhyPreferenceInfo.QbceTransmitterPhyPreferenceToDescription(), 8, FormatValue(qbceQleSetPhy.UserFields.TxPhys, 8), QbceTransmitterPhyPreferenceInfo.QbceTransmitterPhyPreferenceToString(QbceTransmitterPhyPreferenceInfo.ValueToQbceTransmitterPhyPreference(qbceQleSetPhy.UserFields.TxPhys)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RX_PHYS", QbceReceiverPhyPreferenceInfo.QbceReceiverPhyPreferenceToDescription(), 8, FormatValue(qbceQleSetPhy.UserFields.RxPhys, 8), QbceReceiverPhyPreferenceInfo.QbceReceiverPhyPreferenceToString(QbceReceiverPhyPreferenceInfo.ValueToQbceReceiverPhyPreference(qbceQleSetPhy.UserFields.RxPhys)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PHY_options", QbceQleSetPhy.UserFieldsWrapper.PhyOptionsInfo.PhyOptionsToDescription(), 16, FormatValue(qbceQleSetPhy.UserFields.PhyOptions, 16), QbceQleSetPhy.UserFieldsWrapper.PhyOptionsInfo.PhyOptionsToString(QbceQleSetPhy.UserFieldsWrapper.PhyOptionsInfo.ValueToPhyOptions(qbceQleSetPhy.UserFields.PhyOptions)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		QbceQleSetPhy qbceQleSetPhy = (QbceQleSetPhy)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Subopcode");
		}
		if (index == ++num)
		{
			qbceQleSetPhy.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			qbceQleSetPhy.UserFields.AllPhys = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			qbceQleSetPhy.UserFields.TxPhys = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			qbceQleSetPhy.UserFields.RxPhys = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			qbceQleSetPhy.UserFields.PhyOptions = Convert.ToUInt32(value, 16);
		}
	}
}
