using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class DebugWriteRssiThresholdInfo : PacketInfoBase
{
	public override string Name => "Debug Write Rssi Threshold";

	public override string DisplayGroup => "Vendor Specific";

	public DebugWriteRssiThresholdInfo(DebugWriteRssiThreshold packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		DebugWriteRssiThreshold debugWriteRssiThreshold = (DebugWriteRssiThreshold)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("SubOpCode", "HCI_VS_BLUETOOTH_WRITE_RSSI_THRESHOLD", 8, FormatValue(debugWriteRssiThreshold.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("HCI_Handle", "HCI Handle of BT link", 16, FormatValue(debugWriteRssiThreshold.UserFields.HciHandle, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RSSI_Threshold_Lower_Limit", "The lower limit of RSSI threshold", 16, FormatValue(debugWriteRssiThreshold.UserFields.RssiThresholdLowerLimit, 16), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RSSI_Threshold_Upper_Limit", "The upper limit of RSSI threshold", 16, FormatValue(debugWriteRssiThreshold.UserFields.RssiThresholdUpperLimit, 16), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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