using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CommandCompleteForReadLocalExtendedFeaturesInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Read Local Extended Features";

	public override string DisplayGroup => "Information Parameters";

	public CommandCompleteForReadLocalExtendedFeaturesInfo(CommandCompleteForReadLocalExtendedFeatures packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForReadLocalExtendedFeatures commandCompleteForReadLocalExtendedFeatures = (CommandCompleteForReadLocalExtendedFeatures)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForReadLocalExtendedFeatures.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForReadLocalExtendedFeatures.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Page Number", CommandCompleteForReadLocalExtendedFeatures.UserFieldsWrapper.PageNumberInfo.PageNumberToDescription(), 8, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.PageNumber, 8), CommandCompleteForReadLocalExtendedFeatures.UserFieldsWrapper.PageNumberInfo.PageNumberToString(CommandCompleteForReadLocalExtendedFeatures.UserFieldsWrapper.PageNumberInfo.ValueToPageNumber(commandCompleteForReadLocalExtendedFeatures.UserFields.PageNumber)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Maximum Page Number", "The highest features page number which contains non-zero bits for the local device.", 8, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.MaximumPageNumber, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		if (commandCompleteForReadLocalExtendedFeatures.UserFields.PageNumber == 0)
		{
			fieldInfoList.Add(new PacketFieldInfo("Extended LMP Features", "Bit map of requested page of LMP features. See LMP specification for details.\r\n\r\n" + SupportedFeaturesInfo.SupportedFeaturesToDescription(), 64, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures, 64), SupportedFeaturesInfo.SupportedFeaturesToString(SupportedFeaturesInfo.ValueToSupportedFeatures(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		else if (commandCompleteForReadLocalExtendedFeatures.UserFields.PageNumber == 1)
		{
			fieldInfoList.Add(new PacketFieldInfo("Extended LMP Features", "Bit map of requested page of LMP features. See LMP specification for details.\r\n\r\n" + ExtendedFeaturesPage1Info.ExtendedFeaturesPage1ToDescription(), 64, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures, 64), ExtendedFeaturesPage1Info.ExtendedFeaturesPage1ToString(ExtendedFeaturesPage1Info.ValueToExtendedFeaturesPage1(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		else if (commandCompleteForReadLocalExtendedFeatures.UserFields.PageNumber == 2)
		{
			fieldInfoList.Add(new PacketFieldInfo("Extended LMP Features", "Bit map of requested page of LMP features. See LMP specification for details.\r\n\r\n" + ExtendedFeaturesPage2Info.ExtendedFeaturesPage2ToDescription(), 64, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures, 64), ExtendedFeaturesPage2Info.ExtendedFeaturesPage2ToString(ExtendedFeaturesPage2Info.ValueToExtendedFeaturesPage2(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		else
		{
			fieldInfoList.Add(new PacketFieldInfo("Extended LMP Features", "Bit map of requested page of LMP features. See LMP specification for details.", 64, FormatValue(commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures, 64), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForReadLocalExtendedFeatures commandCompleteForReadLocalExtendedFeatures = (CommandCompleteForReadLocalExtendedFeatures)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForReadLocalExtendedFeatures.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForReadLocalExtendedFeatures.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalExtendedFeatures.UserFields.PageNumber = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalExtendedFeatures.UserFields.MaximumPageNumber = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			commandCompleteForReadLocalExtendedFeatures.UserFields.ExtendedLmpFeatures = Convert.ToUInt64(value, 16);
		}
	}
}
