using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMptaGrantModeContInfoInfo : PacketInfoBase
{
	public override string Name => "Set Mpta Grant Mode Cont Info";

	public override string DisplayGroup => "Vendor Specific";

	public SetMptaGrantModeContInfoInfo(SetMptaGrantModeContInfo packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetMptaGrantModeContInfo setMptaGrantModeContInfo = (SetMptaGrantModeContInfo)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", SetMptaGrantModeContInfo.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(setMptaGrantModeContInfo.UserFields.SubOpcode, 8), SetMptaGrantModeContInfo.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(SetMptaGrantModeContInfo.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(setMptaGrantModeContInfo.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Link_ID", " Link ID", 8, FormatValue(setMptaGrantModeContInfo.UserFields.LinkId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RSSI", "Rx RSSI in dBm (signed)", 8, FormatValue(setMptaGrantModeContInfo.UserFields.Rssi, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel", "Channel", 8, FormatValue(setMptaGrantModeContInfo.UserFields.Channel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TX_Power", "TX Power", 8, FormatValue(setMptaGrantModeContInfo.UserFields.TxPower, 8), "", "00", "09", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetMptaGrantModeContInfo setMptaGrantModeContInfo = (SetMptaGrantModeContInfo)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			setMptaGrantModeContInfo.UserFields.LinkId = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMptaGrantModeContInfo.UserFields.Rssi = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMptaGrantModeContInfo.UserFields.Channel = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMptaGrantModeContInfo.UserFields.TxPower = Convert.ToUInt32(value, 16);
		}
	}
}
