using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class BurstBroadcastAudioInfo : PacketInfoBase
{
	public override string Name => "Burst Broadcast Audio";

	public override string DisplayGroup => "Vendor Specific";

	public BurstBroadcastAudioInfo(BurstBroadcastAudio packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		BurstBroadcastAudio burstBroadcastAudio = (BurstBroadcastAudio)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Enable", "0x00 – Disable 0x01- Enable\r\n\r\n" + BurstBroadcastAudio.UserFieldsWrapper.EnableInfo.EnableToDescription(), 8, FormatValue(burstBroadcastAudio.UserFields.Enable, 8), BurstBroadcastAudio.UserFieldsWrapper.EnableInfo.EnableToString(BurstBroadcastAudio.UserFieldsWrapper.EnableInfo.ValueToEnable(burstBroadcastAudio.UserFields.Enable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total number of packets", "Total number of packets in a CSB burst event. Similar to ‘M’ in N:M\r\n\r\n" + BurstBroadcastAudio.UserFieldsWrapper.TotalNumberOfPacketsInfo.TotalNumberOfPacketsToDescription(), 8, FormatValue(burstBroadcastAudio.UserFields.TotalNumberOfPackets, 8), BurstBroadcastAudio.UserFieldsWrapper.TotalNumberOfPacketsInfo.TotalNumberOfPacketsToString(BurstBroadcastAudio.UserFieldsWrapper.TotalNumberOfPacketsInfo.ValueToTotalNumberOfPackets(burstBroadcastAudio.UserFields.TotalNumberOfPackets)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Minimum packets", "Number of min packets to be received in CSB event. Similar to ‘N’ in N:M\r\n\r\n" + BurstBroadcastAudio.UserFieldsWrapper.MinimumPacketsInfo.MinimumPacketsToDescription(), 8, FormatValue(burstBroadcastAudio.UserFields.MinimumPackets, 8), BurstBroadcastAudio.UserFieldsWrapper.MinimumPacketsInfo.MinimumPacketsToString(BurstBroadcastAudio.UserFieldsWrapper.MinimumPacketsInfo.ValueToMinimumPackets(burstBroadcastAudio.UserFields.MinimumPackets)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CSB packet type", "CSB_Packet_Type parameter specifies whether BR/EDR packets or QHS packets are being used on the CSB logical transport\r\n\r\n" + BurstBroadcastAudio.UserFieldsWrapper.CsbPacketTypeInfo.CsbPacketTypeToDescription(), 8, FormatValue(burstBroadcastAudio.UserFields.CsbPacketType, 8), BurstBroadcastAudio.UserFieldsWrapper.CsbPacketTypeInfo.CsbPacketTypeToString(BurstBroadcastAudio.UserFieldsWrapper.CsbPacketTypeInfo.ValueToCsbPacketType(burstBroadcastAudio.UserFields.CsbPacketType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet interval", "Gap between two consecutive CSB packets in a CSB event. (only even values supported)", 8, FormatValue(burstBroadcastAudio.UserFields.PacketInterval, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		BurstBroadcastAudio burstBroadcastAudio = (BurstBroadcastAudio)packet;
		int num = -1;
		if (index == ++num)
		{
			burstBroadcastAudio.UserFields.Enable = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			burstBroadcastAudio.UserFields.TotalNumberOfPackets = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			burstBroadcastAudio.UserFields.MinimumPackets = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			burstBroadcastAudio.UserFields.CsbPacketType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			burstBroadcastAudio.UserFields.PacketInterval = Convert.ToUInt32(value, 16);
		}
	}
}
