using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetConnectionlessSlaveBroadcastInfo : PacketInfoBase
{
	public override string Name => "Set Connectionless Slave Broadcast";

	public override string DisplayGroup => "Link Control";

	public SetConnectionlessSlaveBroadcastInfo(SetConnectionlessSlaveBroadcast packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetConnectionlessSlaveBroadcast setConnectionlessSlaveBroadcast = (SetConnectionlessSlaveBroadcast)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Enable", SetConnectionlessSlaveBroadcast.UserFieldsWrapper.EnableInfo.EnableToDescription(), 8, FormatValue(setConnectionlessSlaveBroadcast.UserFields.Enable, 8), SetConnectionlessSlaveBroadcast.UserFieldsWrapper.EnableInfo.EnableToString(SetConnectionlessSlaveBroadcast.UserFieldsWrapper.EnableInfo.ValueToEnable(setConnectionlessSlaveBroadcast.UserFields.Enable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LT_ADDR", SetConnectionlessSlaveBroadcast.UserFieldsWrapper.LtAddrInfo.LtAddrToDescription(), 8, FormatValue(setConnectionlessSlaveBroadcast.UserFields.LtAddr, 8), SetConnectionlessSlaveBroadcast.UserFieldsWrapper.LtAddrInfo.LtAddrToString(SetConnectionlessSlaveBroadcast.UserFieldsWrapper.LtAddrInfo.ValueToLtAddr(setConnectionlessSlaveBroadcast.UserFields.LtAddr)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LPO_Allowed", "", 8, FormatValue(setConnectionlessSlaveBroadcast.UserFields.LpoAllowed, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet_Type", AclPacketTypeInfo.AclPacketTypeToDescription(), 16, FormatValue(setConnectionlessSlaveBroadcast.UserFields.PacketType, 16), AclPacketTypeInfo.AclPacketTypeToString(AclPacketTypeInfo.ValueToAclPacketType(setConnectionlessSlaveBroadcast.UserFields.PacketType)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Interval_Min", "Minimum interval between Connectionless Slave Broadcast packets in slots, Only even values are valid.", 16, FormatValue(setConnectionlessSlaveBroadcast.UserFields.IntervalMin, 16), "", "0002", "FFFE", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Interval_Max", "Maximum interval between Connectionless Slave Broadcast packets in slots, Only even values are valid.", 16, FormatValue(setConnectionlessSlaveBroadcast.UserFields.IntervalMax, 16), "", "0002", "FFFE", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CSB_supervisionTO", "Duration in slots after which the BR/EDR Controller reports a Connectionless Slave Broadcast Timeout event if it is unable to transmit a Connectionless Slave Broadcast packet.", 16, FormatValue(setConnectionlessSlaveBroadcast.UserFields.CsbSupervisionto, 16), "", "0002", "FFFE", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetConnectionlessSlaveBroadcast setConnectionlessSlaveBroadcast = (SetConnectionlessSlaveBroadcast)packet;
		int num = -1;
		if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.Enable = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.LtAddr = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.LpoAllowed = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.PacketType = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.IntervalMin = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.IntervalMax = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setConnectionlessSlaveBroadcast.UserFields.CsbSupervisionto = Convert.ToUInt32(value, 16);
		}
	}
}
