using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CommandStatusForExitPeriodicInquiryModeInfo : PacketInfoBase
{
	public override string Name => "Command Status For Exit Periodic Inquiry Mode";

	public override string DisplayGroup => "Link Control";

	public CommandStatusForExitPeriodicInquiryModeInfo(CommandStatusForExitPeriodicInquiryMode packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandStatusForExitPeriodicInquiryMode commandStatusForExitPeriodicInquiryMode = (CommandStatusForExitPeriodicInquiryMode)packet;
		fieldInfoList.Clear();
		if (commandStatusForExitPeriodicInquiryMode.UserFields.Status == 0)
		{
			fieldInfoList.Add(new PacketFieldInfo("Status", CommandStatusInfo.CommandStatusToDescription(), 8, FormatValue(commandStatusForExitPeriodicInquiryMode.UserFields.Status, 8), CommandStatusInfo.CommandStatusToString(CommandStatusInfo.ValueToCommandStatus(commandStatusForExitPeriodicInquiryMode.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		else if (commandStatusForExitPeriodicInquiryMode.UserFields.Status >= 1 && commandStatusForExitPeriodicInquiryMode.UserFields.Status <= 255)
		{
			fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandStatusForExitPeriodicInquiryMode.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandStatusForExitPeriodicInquiryMode.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		else
		{
			fieldInfoList.Add(new PacketFieldInfo("Status", "", 8, FormatValue(commandStatusForExitPeriodicInquiryMode.UserFields.Status, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandStatusForExitPeriodicInquiryMode.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandStatusForExitPeriodicInquiryMode.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandStatusForExitPeriodicInquiryMode.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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