using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMwsTransportLayerInfo : PacketInfoBase
{
	public override string Name => "Set Mws Transport Layer";

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

	public SetMwsTransportLayerInfo(SetMwsTransportLayer packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetMwsTransportLayer setMwsTransportLayer = (SetMwsTransportLayer)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Transport_Layer", "See Bluetooth Assigned numbers", 8, FormatValue(setMwsTransportLayer.UserFields.TransportLayer, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("To_MWS_Baud_Rate", "Baud rate in the Bluetooth to MWS direction in Baud", 32, FormatValue(setMwsTransportLayer.UserFields.ToMwsBaudRate, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("From_MWS_Baud_Rate", "Baud rate in the MWS to Bluetooth direction in Baud", 32, FormatValue(setMwsTransportLayer.UserFields.FromMwsBaudRate, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetMwsTransportLayer setMwsTransportLayer = (SetMwsTransportLayer)packet;
		int num = -1;
		if (index == ++num)
		{
			setMwsTransportLayer.UserFields.TransportLayer = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMwsTransportLayer.UserFields.ToMwsBaudRate = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMwsTransportLayer.UserFields.FromMwsBaudRate = Convert.ToUInt32(value, 16);
		}
	}
}
