using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ShortRangeModeChangeCompleteInfo : PacketInfoBase
{
	public override string Name => "Short Range Mode Change Complete";

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

	public ShortRangeModeChangeCompleteInfo(ShortRangeModeChangeComplete packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ShortRangeModeChangeComplete shortRangeModeChangeComplete = (ShortRangeModeChangeComplete)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(shortRangeModeChangeComplete.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(shortRangeModeChangeComplete.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Physical_Link_Handle", "Physical_Link_Handle to which the configuration applies", 8, FormatValue(shortRangeModeChangeComplete.UserFields.PhysicalLinkHandle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Short_Range_Mode_State", "State of Short Range Mode in controller: 0x00 - Short Range Mode disabled, 0x01 - Short Range Mode enabled, Reserved (0x02 - 0xFF)", 8, FormatValue(shortRangeModeChangeComplete.UserFields.ShortRangeModeState, 8), "", "00", "01", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ShortRangeModeChangeComplete shortRangeModeChangeComplete = (ShortRangeModeChangeComplete)packet;
		int num = -1;
		if (index == ++num)
		{
			shortRangeModeChangeComplete.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			shortRangeModeChangeComplete.UserFields.PhysicalLinkHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			shortRangeModeChangeComplete.UserFields.ShortRangeModeState = Convert.ToUInt32(value, 16);
		}
	}
}
