using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LePeriodicAdvertisingSyncLostInfo : PacketInfoBase
{
	public override string Name => "Le Periodic Advertising Sync Lost";

	public override string DisplayGroup => "LE Controller";

	public LePeriodicAdvertisingSyncLostInfo(LePeriodicAdvertisingSyncLost packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LePeriodicAdvertisingSyncLost lePeriodicAdvertisingSyncLost = (LePeriodicAdvertisingSyncLost)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Subevent_Code", "Subevent code for LE Periodic Advertising Sync Lost event", 8, FormatValue(lePeriodicAdvertisingSyncLost.UserFields.SubeventCode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sync_Handle", "Sync_Handle to be used to identify the periodic advertiser. Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(lePeriodicAdvertisingSyncLost.UserFields.SyncHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LePeriodicAdvertisingSyncLost lePeriodicAdvertisingSyncLost = (LePeriodicAdvertisingSyncLost)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubeventCode");
		}
		if (index == ++num)
		{
			lePeriodicAdvertisingSyncLost.UserFields.SyncHandle = Convert.ToUInt32(value, 16);
		}
	}
}
