using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CommandCompleteForReadLocalAmpInfoInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Read Local Amp Info";

	public override string DisplayGroup => "Status Parameters";

	public CommandCompleteForReadLocalAmpInfoInfo(CommandCompleteForReadLocalAmpInfo packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForReadLocalAmpInfo commandCompleteForReadLocalAmpInfo = (CommandCompleteForReadLocalAmpInfo)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForReadLocalAmpInfo.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForReadLocalAmpInfo.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("AMP_Status", "", 8, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.AmpStatus, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total_Bandwidth", "An upper bound on the total data rate that can be achieved by the AMP over HCI. It accounts for the total bandwidth provided by the HCI transport. No sustained combination of transmit and receive operations shall exceed this value. This can be used to help in AMP selection and admission control. Expressed in kbps.", 32, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.TotalBandwidth, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_Guaranteed_Bandwidth", "An upper bound on the maximum data the AMP can guarantee for a single logical link over HCI. Any request made by an application above this threshold would be rejected. It accounts for any bandwidth limitations of the HCI transport. No sustained combination of transmit and receive operations shall exceed this value. This can be used to help in AMP selection and admission control. Expressed in kbps.", 32, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.MaxGuaranteedBandwidth, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Min_Latency", "A lower bound on the latency in microseconds that the AMP can guarantee for a logical channel. It accounts for the minimum latency of the HCI transport. This can be used to help in AMP selection and admission control.", 32, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.MinLatency, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_PDU_Size", "An upper bound on the size of L2CAP PDU which may be provided for transmission or reception on this AMP. The Host shall not require the AMP to transport L2CAP PDUs larger than this value. Expressed in octets. The Maximum PDU Size parameter described in (BT Specification, RETRANSMISSION AND FLOW CONTROL OPTION Section) for any connection over this AMP should not exceed this value.", 16, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.MaxPduSize, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Controller_Type", "See Bluetooth Assigned Numbers.", 8, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.ControllerType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PAL_Capabilities", "Bit 0: (Service Type = Guaranteed) is supported by PAL = 1. Bits 15-1: Reserved (shall be set to 0). See BT Specification, EXTENDED FLOW SPECIFICATION OPTION Section.", 16, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.PalCapabilities, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_AMP_ASSOC_Length", "AMP_ASSOC maximum length for this local AMP Controller. For use with Read and Write AMP_ASSOC commands. This value is sent to the remote AMP Manager in the AMP Get Info Response (See BT Specifiction, AMP GET INFO RESPONSE (CODE 0X07) Section).", 16, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.MaxAmpAssocLength, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_Flush_Timeout", "Maximum time period, in microseconds, which the AMP device uses to attempt to transmit a frame on a Guaranteed Logical Link. If the Controller is configured to retry frames for an unbounded time (i.e. there is no flushing at all), then it shall set this value to 0xFFFFFFFF.", 32, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.MaxFlushTimeout, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Best_Effort_Flush_Timeout", "The typical time period, in microseconds, which the AMP device may use to attempt to transmit a frame on a Best Effort Logical Link. The value shall not exceed the value given in Max_Flush_Timeout. If the Controller is configured to retry frames for an unbounded time (i.e. there is no flushing at all), then it shall set this value to 0xFFFFFFFF.", 32, FormatValue(commandCompleteForReadLocalAmpInfo.UserFields.BestEffortFlushTimeout, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForReadLocalAmpInfo commandCompleteForReadLocalAmpInfo = (CommandCompleteForReadLocalAmpInfo)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.AmpStatus = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.TotalBandwidth = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.MaxGuaranteedBandwidth = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.MinLatency = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.MaxPduSize = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.ControllerType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.PalCapabilities = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.MaxAmpAssocLength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.MaxFlushTimeout = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalAmpInfo.UserFields.BestEffortFlushTimeout = Convert.ToUInt32(value, 16);
		}
	}
}
