using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class DebugSimulateCxmMciRxInfo : PacketInfoBase
{
	public override string Name => "Debug Simulate Cxm Mci Rx";

	public override string DisplayGroup => "Vendor Specific";

	public DebugSimulateCxmMciRxInfo(DebugSimulateCxmMciRx packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		DebugSimulateCxmMciRx debugSimulateCxmMciRx = (DebugSimulateCxmMciRx)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "HCI_VS_DEBUG_CXM_MCI_RX_CMD", 8, FormatValue(debugSimulateCxmMciRx.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("MCI_Header", "MCI header defined in Table 2 MCI Messages from WLAN-BT MCI Messaging Specification.\r\n\r\n" + DebugSimulateCxmMciRx.UserFieldsWrapper.MciHeaderInfo.MciHeaderToDescription(), 8, FormatValue(debugSimulateCxmMciRx.UserFields.MciHeader, 8), DebugSimulateCxmMciRx.UserFieldsWrapper.MciHeaderInfo.MciHeaderToString(DebugSimulateCxmMciRx.UserFieldsWrapper.MciHeaderInfo.ValueToMciHeader(debugSimulateCxmMciRx.UserFields.MciHeader)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("MCI_Body", "An optional body of up to 16 bytes. 0xFFFFFFFFXX…XX : If T1 (first 4 bytes) is filled with 0xFFFFFFFF and MciHeader is MCI_GPM_TYPE, i.e., 0x80, then T1 will be replaced with the current system clock automatically by controller. This is useful if T1 matters on certain GPM messages, e.g., Antenna Auto Isolation Detection – Power Measurement Request.", debugSimulateCxmMciRx.UserFields.MciBodyList.Count * 8, FormatValue(debugSimulateCxmMciRx.UserFields.MciBodyList, debugSimulateCxmMciRx.UserFields.MciBodyList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		DebugSimulateCxmMciRx debugSimulateCxmMciRx = (DebugSimulateCxmMciRx)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			debugSimulateCxmMciRx.UserFields.MciHeader = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, debugSimulateCxmMciRx.UserFields.MciBodyList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				debugSimulateCxmMciRx.UserFields.MciBodyList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
	}
}
