using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetPathLossReportingParametersInfo : PacketInfoBase
{
	public override string Name => "Le Set Path Loss Reporting Parameters";

	public override string DisplayGroup => "LE Controller";

	public LeSetPathLossReportingParametersInfo(LeSetPathLossReportingParameters packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetPathLossReportingParameters leSetPathLossReportingParameters = (LeSetPathLossReportingParameters)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "Connection handle for the LE connection.", 16, FormatValue(leSetPathLossReportingParameters.UserFields.ConnectionHandle, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("High Threshold", "High threshold for the path loss. Units: dB", 8, FormatValue(leSetPathLossReportingParameters.UserFields.HighThreshold, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("High Hysteresis", "Hysteresis value for the high threshold. Units: dB", 8, FormatValue(leSetPathLossReportingParameters.UserFields.HighHysteresis, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Low Threshold", "Low threshold for the path loss. Units: dB", 8, FormatValue(leSetPathLossReportingParameters.UserFields.LowThreshold, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Low Hysteresis", "Hysteresis value for the low threshold. Units: dB", 8, FormatValue(leSetPathLossReportingParameters.UserFields.LowHysteresis, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Minimum Time Spent", "Minimum time to be observed once the path crosses the threshold before an event is generated. Units: 0.1 seconds", 16, FormatValue(leSetPathLossReportingParameters.UserFields.MinimumTimeSpent, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetPathLossReportingParameters leSetPathLossReportingParameters = (LeSetPathLossReportingParameters)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetPathLossReportingParameters.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetPathLossReportingParameters.UserFields.HighThreshold = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetPathLossReportingParameters.UserFields.HighHysteresis = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetPathLossReportingParameters.UserFields.LowThreshold = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetPathLossReportingParameters.UserFields.LowHysteresis = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetPathLossReportingParameters.UserFields.MinimumTimeSpent = Convert.ToUInt32(value, 16);
		}
	}
}
