using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class AcceptSynchronousConnectionRequestInfo : PacketInfoBase
{
	public override string Name => "Accept Synchronous Connection Request";

	public override string DisplayGroup => "Link Control";

	public AcceptSynchronousConnectionRequestInfo(AcceptSynchronousConnectionRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		AcceptSynchronousConnectionRequest acceptSynchronousConnectionRequest = (AcceptSynchronousConnectionRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("BD_ADDR", "BD_ADDR of the device requesting the connection.", 48, FormatValue(acceptSynchronousConnectionRequest.UserFields.BdAddr, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Transmit_Bandwidth", AcceptSynchronousConnectionRequest.UserFieldsWrapper.TransmitBandwidthInfo.TransmitBandwidthToDescription(), 32, FormatValue(acceptSynchronousConnectionRequest.UserFields.TransmitBandwidth, 32), AcceptSynchronousConnectionRequest.UserFieldsWrapper.TransmitBandwidthInfo.TransmitBandwidthToString(AcceptSynchronousConnectionRequest.UserFieldsWrapper.TransmitBandwidthInfo.ValueToTransmitBandwidth(acceptSynchronousConnectionRequest.UserFields.TransmitBandwidth)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Receive_Bandwidth", AcceptSynchronousConnectionRequest.UserFieldsWrapper.ReceiveBandwidthInfo.ReceiveBandwidthToDescription(), 32, FormatValue(acceptSynchronousConnectionRequest.UserFields.ReceiveBandwidth, 32), AcceptSynchronousConnectionRequest.UserFieldsWrapper.ReceiveBandwidthInfo.ReceiveBandwidthToString(AcceptSynchronousConnectionRequest.UserFieldsWrapper.ReceiveBandwidthInfo.ValueToReceiveBandwidth(acceptSynchronousConnectionRequest.UserFields.ReceiveBandwidth)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Max_Latency", "", 16, FormatValue(acceptSynchronousConnectionRequest.UserFields.MaxLatency, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Voice_Setting", "See VOICE SETTING parameter in BT specification document.", 16, FormatValue(acceptSynchronousConnectionRequest.UserFields.VoiceSetting, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Retransmission_Effort", AcceptSynchronousConnectionRequest.UserFieldsWrapper.RetransmissionEffortInfo.RetransmissionEffortToDescription(), 8, FormatValue(acceptSynchronousConnectionRequest.UserFields.RetransmissionEffort, 8), AcceptSynchronousConnectionRequest.UserFieldsWrapper.RetransmissionEffortInfo.RetransmissionEffortToString(AcceptSynchronousConnectionRequest.UserFieldsWrapper.RetransmissionEffortInfo.ValueToRetransmissionEffort(acceptSynchronousConnectionRequest.UserFields.RetransmissionEffort)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet_Type", EnhancedSynchronousPacketTypeInfo.EnhancedSynchronousPacketTypeToDescription(), 16, FormatValue(acceptSynchronousConnectionRequest.UserFields.PacketType, 16), EnhancedSynchronousPacketTypeInfo.EnhancedSynchronousPacketTypeToString(EnhancedSynchronousPacketTypeInfo.ValueToEnhancedSynchronousPacketType(acceptSynchronousConnectionRequest.UserFields.PacketType)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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