using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class GigawakeAddDeviceInfo : PacketInfoBase
{
	public override string Name => "Gigawake Add Device";

	public override string DisplayGroup => "Vendor Specific";

	public GigawakeAddDeviceInfo(GigawakeAddDevice packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		GigawakeAddDevice gigawakeAddDevice = (GigawakeAddDevice)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Bd_Address", "Bluetooth Address of Device", 48, FormatValue(gigawakeAddDevice.UserFields.BdAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Start_Interval", "After DUT enter S3, the time (in seconds) DUT starts to page remote device.", 16, FormatValue(gigawakeAddDevice.UserFields.StartInterval, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Retry_Interval", "The duration (in seconds) between DUT page scan failed and re-page.", 16, FormatValue(gigawakeAddDevice.UserFields.RetryInterval, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Confirm_Interval", "The interval (in seconds) between first and second page. If DUT can page device successfully for two times, DUT will wake up host.", 16, FormatValue(gigawakeAddDevice.UserFields.ConfirmInterval, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Signal_Strength_Limitation", "When remote device signal achieves this value (in dB), DUT can be waked up.", 8, FormatValue(gigawakeAddDevice.UserFields.SignalStrengthLimitation, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		GigawakeAddDevice gigawakeAddDevice = (GigawakeAddDevice)packet;
		int num = -1;
		if (index == ++num)
		{
			gigawakeAddDevice.UserFields.BdAddress = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			gigawakeAddDevice.UserFields.StartInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			gigawakeAddDevice.UserFields.RetryInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			gigawakeAddDevice.UserFields.ConfirmInterval = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			gigawakeAddDevice.UserFields.SignalStrengthLimitation = Convert.ToUInt32(value, 16);
		}
	}
}
