using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LePeriodicAdvertisingSyncTransferReceivedInfo : PacketInfoBase
{
	public override string Name => "Le Periodic Advertising Sync Transfer Received";

	public override string DisplayGroup => "LE Controller";

	public LePeriodicAdvertisingSyncTransferReceivedInfo(LePeriodicAdvertisingSyncTransferReceived packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LePeriodicAdvertisingSyncTransferReceived lePeriodicAdvertisingSyncTransferReceived = (LePeriodicAdvertisingSyncTransferReceived)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Subevent_Code", "Subevent code for LE Periodic Advertising Sync Transfer Received", 8, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.SubeventCode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(lePeriodicAdvertisingSyncTransferReceived.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "Handle of LE connection receiving PAST", 16, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Service_Data", "Host Specific Data.", 16, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.ServiceData, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sync_Handle", "Handle of sync connection established", 16, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.SyncHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Sid", "Sid of the periodic advertiser.", 8, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingSid, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_AddressType", LePeriodicAdvertisingSyncTransferReceived.UserFieldsWrapper.AdvertisingAddresstypeInfo.AdvertisingAddresstypeToDescription(), 8, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingAddresstype, 8), LePeriodicAdvertisingSyncTransferReceived.UserFieldsWrapper.AdvertisingAddresstypeInfo.AdvertisingAddresstypeToString(LePeriodicAdvertisingSyncTransferReceived.UserFieldsWrapper.AdvertisingAddresstypeInfo.ValueToAdvertisingAddresstype(lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingAddresstype)), "0", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_Address", "Address of the periodic advertiser.", 48, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertising_PHY", "PHY mask of the periodic advertiser.", 8, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingPhy, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Periodic_Advertising_Interval ", "Interval of the periodic advertiser.", 16, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.PeriodicAdvertisingInterval, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Advertiser_ClockAccuracy", "Clock accuracy of the periodic advertiser.", 8, FormatValue(lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertiserClockaccuracy, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LePeriodicAdvertisingSyncTransferReceived lePeriodicAdvertisingSyncTransferReceived = (LePeriodicAdvertisingSyncTransferReceived)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubeventCode");
		}
		if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.ServiceData = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.SyncHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingSid = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingAddresstype = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingAddress = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertisingPhy = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.PeriodicAdvertisingInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			lePeriodicAdvertisingSyncTransferReceived.UserFields.AdvertiserClockaccuracy = Convert.ToUInt32(value, 16);
		}
	}
}
