using System;
using System.Runtime.InteropServices;

namespace QC.QMSLPhone;

public class LogMfloRssiValueDynamicParams : LogMessage
{
	[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 8)]
	public struct MfloRssiValueDynamicParamsType
	{
		public byte Interrupt_type;

		public ushort reserved1;

		public byte reserved2;

		public ushort rssi_int_part;

		public byte rssi_fract_part;

		public byte rssi_value_positive;
	}

	private const int logSize = 8;

	public MfloRssiValueDynamicParamsType ds;

	private GCHandle pinnedPacket;

	private IntPtr p;

	public LogMfloRssiValueDynamicParams(LogMessage msgVal)
		: base(msgVal.msgID, msgVal.message, displayRawVal: false)
	{
		pinnedPacket = GCHandle.Alloc(message, GCHandleType.Pinned);
		p = pinnedPacket.AddrOfPinnedObject();
		p = new IntPtr(p.ToInt64() + 16);
		ds = (MfloRssiValueDynamicParamsType)Marshal.PtrToStructure(p, typeof(MfloRssiValueDynamicParamsType));
	}

	public override string ToString()
	{
		return base.ToString() + string.Format(" RSSI: {0}{1}.{2}", (ds.rssi_value_positive != 0) ? "" : "-", ds.rssi_int_part, ds.rssi_fract_part);
	}
}
