using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class VsReadRssiInfo : PacketInfoBase
{
	public override string Name => "Vs Read Rssi";

	public override string DisplayGroup => "Vendor Specific";

	public VsReadRssiInfo(VsReadRssi packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		VsReadRssi vsReadRssi = (VsReadRssi)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("SubOpCode", "HCI_VS_DEBUG_RM_READ_RSSI_CMD", 8, FormatValue(vsReadRssi.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel_Offset", "Offset to the channel to open from 2.4GHz, i.e. 0x02 is 2.402GHz, 0x04 is 2.404GHz", 8, FormatValue(vsReadRssi.UserFields.ChannelOffset, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_of_Samples", "Used to average the returned value", 8, FormatValue(vsReadRssi.UserFields.NumberOfSamples, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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