using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CommandCompleteForReadEnhancedTransmitPowerLevelInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Read Enhanced Transmit Power Level";

	public override string DisplayGroup => "Host Control and Baseband";

	public CommandCompleteForReadEnhancedTransmitPowerLevelInfo(CommandCompleteForReadEnhancedTransmitPowerLevel packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForReadEnhancedTransmitPowerLevel commandCompleteForReadEnhancedTransmitPowerLevel = (CommandCompleteForReadEnhancedTransmitPowerLevel)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Connection_Handle to be used to identify a connection. Range: 0x0000-0x0EFF. Reserved for future use (0x0F00 - 0x0FFF)", 16, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit_Power_Level_GFSK", "Size: 1 Octet (signed integer), Range: -100 ≤ N ≤ 20, Units: dBm\r\n\r\n" + CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevelGfskInfo.TransmitPowerLevelGfskToDescription(), 8, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevelGfsk, 8), CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevelGfskInfo.TransmitPowerLevelGfskToString(CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevelGfskInfo.ValueToTransmitPowerLevelGfsk(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevelGfsk)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit_Power_Level_DQPSK", "Size: 1 Octet (signed integer), Range: -100 ≤ N ≤ 20, Units: dBm\r\n\r\n" + CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevelDqpskInfo.TransmitPowerLevelDqpskToDescription(), 8, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevelDqpsk, 8), CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevelDqpskInfo.TransmitPowerLevelDqpskToString(CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevelDqpskInfo.ValueToTransmitPowerLevelDqpsk(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevelDqpsk)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit_Power_Level_8DPSK", "Size: 1 Octet (signed integer), Range: -100 ≤ N ≤ 20, Units: dBm\r\n\r\n" + CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevel8dpskInfo.TransmitPowerLevel8dpskToDescription(), 8, FormatValue(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevel8dpsk, 8), CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevel8dpskInfo.TransmitPowerLevel8dpskToString(CommandCompleteForReadEnhancedTransmitPowerLevel.UserFieldsWrapper.TransmitPowerLevel8dpskInfo.ValueToTransmitPowerLevel8dpsk(commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevel8dpsk)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForReadEnhancedTransmitPowerLevel commandCompleteForReadEnhancedTransmitPowerLevel = (CommandCompleteForReadEnhancedTransmitPowerLevel)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevelGfsk = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevelDqpsk = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadEnhancedTransmitPowerLevel.UserFields.TransmitPowerLevel8dpsk = Convert.ToUInt32(value, 16);
		}
	}
}
