using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciSetupSynchronousConnectionInfo : PacketInfoBase
{
	public override string Name => "Hci Setup Synchronous Connection";

	public override string DisplayGroup => "Link Control";

	public HciSetupSynchronousConnectionInfo(HciSetupSynchronousConnection packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciSetupSynchronousConnection hciSetupSynchronousConnection = (HciSetupSynchronousConnection)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "Connection Handle for the ACL connection being used to create an SCO connection.Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(hciSetupSynchronousConnection.UserFields.ConnectionHandle, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit Bandwidth", "Transmit bandwidth in octets per second", 32, FormatValue(hciSetupSynchronousConnection.UserFields.TransmitBandwidth, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Receive Bandwidth", "Receive bandwidth in octets per second", 32, FormatValue(hciSetupSynchronousConnection.UserFields.ReceiveBandwidth, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max Latency", HciSetupSynchronousConnection.UserFieldsWrapper.MaxLatencyInfo.MaxLatencyToDescription(), 16, FormatValue(hciSetupSynchronousConnection.UserFields.MaxLatency, 16), HciSetupSynchronousConnection.UserFieldsWrapper.MaxLatencyInfo.MaxLatencyToString(HciSetupSynchronousConnection.UserFieldsWrapper.MaxLatencyInfo.ValueToMaxLatency(hciSetupSynchronousConnection.UserFields.MaxLatency)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Voice Setting", "", 16, FormatValue(hciSetupSynchronousConnection.UserFields.VoiceSetting, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Retransmission Effort", HciSetupSynchronousConnection.UserFieldsWrapper.RetransmissionEffortInfo.RetransmissionEffortToDescription(), 8, FormatValue(hciSetupSynchronousConnection.UserFields.RetransmissionEffort, 8), HciSetupSynchronousConnection.UserFieldsWrapper.RetransmissionEffortInfo.RetransmissionEffortToString(HciSetupSynchronousConnection.UserFieldsWrapper.RetransmissionEffortInfo.ValueToRetransmissionEffort(hciSetupSynchronousConnection.UserFields.RetransmissionEffort)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet Type", EnhancedSynchronousPacketTypeInfo.EnhancedSynchronousPacketTypeToDescription(), 16, FormatValue(hciSetupSynchronousConnection.UserFields.PacketType, 16), EnhancedSynchronousPacketTypeInfo.EnhancedSynchronousPacketTypeToString(EnhancedSynchronousPacketTypeInfo.ValueToEnhancedSynchronousPacketType(hciSetupSynchronousConnection.UserFields.PacketType)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciSetupSynchronousConnection hciSetupSynchronousConnection = (HciSetupSynchronousConnection)packet;
		int num = -1;
		if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.TransmitBandwidth = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.ReceiveBandwidth = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.MaxLatency = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.VoiceSetting = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.RetransmissionEffort = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hciSetupSynchronousConnection.UserFields.PacketType = Convert.ToUInt32(value, 16);
		}
	}
}
