using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeEnhancedReadTransmitPowerLevelInfo : PacketInfoBase
{
	public override string Name => "Le Enhanced Read Transmit Power Level";

	public override string DisplayGroup => "LE Controller";

	public LeEnhancedReadTransmitPowerLevelInfo(LeEnhancedReadTransmitPowerLevel packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeEnhancedReadTransmitPowerLevel leEnhancedReadTransmitPowerLevel = (LeEnhancedReadTransmitPowerLevel)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "Connection handle for the LE connection.", 16, FormatValue(leEnhancedReadTransmitPowerLevel.UserFields.ConnectionHandle, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("phy", "Phy parameter for the connection.\r\n\r\n" + LeEnhancedReadTransmitPowerLevel.UserFieldsWrapper.PhyInfo.PhyToDescription(), 8, FormatValue(leEnhancedReadTransmitPowerLevel.UserFields.Phy, 8), LeEnhancedReadTransmitPowerLevel.UserFieldsWrapper.PhyInfo.PhyToString(LeEnhancedReadTransmitPowerLevel.UserFieldsWrapper.PhyInfo.ValueToPhy(leEnhancedReadTransmitPowerLevel.UserFields.Phy)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeEnhancedReadTransmitPowerLevel leEnhancedReadTransmitPowerLevel = (LeEnhancedReadTransmitPowerLevel)packet;
		int num = -1;
		if (index == ++num)
		{
			leEnhancedReadTransmitPowerLevel.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leEnhancedReadTransmitPowerLevel.UserFields.Phy = Convert.ToUInt32(value, 16);
		}
	}
}
