41 lines
979 B
C#
41 lines
979 B
C#
namespace Common.Hardware.SIRT.Parameters
|
|
{
|
|
public class RSSI
|
|
{
|
|
public RSSI(byte value, int mhz)
|
|
{
|
|
this.Value = value;
|
|
|
|
if (mhz == 433)
|
|
{
|
|
this.Dbm = value * 0.5 - 140;
|
|
this.Percent = value * 0.7333 - 57.6667;
|
|
}
|
|
else if (mhz == 868)
|
|
{
|
|
this.Dbm = value * 0.5 - 131.3;
|
|
this.Percent = value * 0.66 - 40.316;
|
|
}
|
|
|
|
if (this.Percent > 100)
|
|
{
|
|
this.Percent = 100;
|
|
}
|
|
else if (this.Percent < 0)
|
|
{
|
|
this.Percent = 0;
|
|
}
|
|
}
|
|
|
|
public byte Value { get; }
|
|
|
|
public double Dbm { get; }
|
|
|
|
public double Percent { get; }
|
|
|
|
public override string ToString() => $"{this.Dbm}dBm ({this.Percent:0.0}%)";
|
|
|
|
public static implicit operator string(RSSI rssi) => rssi?.ToString();
|
|
}
|
|
}
|