using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CommandCompleteForEdlPatchAttachRequestInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Edl Patch Attach Request";

	public override string DisplayGroup => "Vendor Specific";

	public CommandCompleteForEdlPatchAttachRequestInfo(CommandCompleteForEdlPatchAttachRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForEdlPatchAttachRequest commandCompleteForEdlPatchAttachRequest = (CommandCompleteForEdlPatchAttachRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForEdlPatchAttachRequest.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForEdlPatchAttachRequest.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForEdlPatchAttachRequest.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", "EDL Status Info\r\n\r\n" + EdlErrorCodeInfo.EdlErrorCodeToDescription(), 8, FormatValue(commandCompleteForEdlPatchAttachRequest.UserFields.Status, 8), EdlErrorCodeInfo.EdlErrorCodeToString(EdlErrorCodeInfo.ValueToEdlErrorCode(commandCompleteForEdlPatchAttachRequest.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", CommandCompleteForEdlPatchAttachRequest.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(commandCompleteForEdlPatchAttachRequest.UserFields.SubOpcode, 8), CommandCompleteForEdlPatchAttachRequest.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(CommandCompleteForEdlPatchAttachRequest.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(commandCompleteForEdlPatchAttachRequest.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Product ID", ProductIdInfo.ProductIdToDescription(), 8, FormatValue(commandCompleteForEdlPatchAttachRequest.UserFields.ProductId, 8), ProductIdInfo.ProductIdToString(ProductIdInfo.ValueToProductId(commandCompleteForEdlPatchAttachRequest.UserFields.ProductId)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("EDL App Type", CommandCompleteForEdlPatchAttachRequest.UserFieldsWrapper.EdlAppTypeInfo.EdlAppTypeToDescription(), 8, FormatValue(commandCompleteForEdlPatchAttachRequest.UserFields.EdlAppType, 8), CommandCompleteForEdlPatchAttachRequest.UserFieldsWrapper.EdlAppTypeInfo.EdlAppTypeToString(CommandCompleteForEdlPatchAttachRequest.UserFieldsWrapper.EdlAppTypeInfo.ValueToEdlAppType(commandCompleteForEdlPatchAttachRequest.UserFields.EdlAppType)), "", "03", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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