OMNI latest:
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
this.BatteryVoltage.ADCCount = BitConverter.ToUInt32(this.bytes, 54);
|
||||
|
||||
this.FactorySealed = this.bytes[58] == 1;
|
||||
|
||||
this.ValidateParameters();
|
||||
}
|
||||
|
||||
public BuildInfo BuildInfo { get; set; }
|
||||
@@ -56,5 +58,73 @@
|
||||
public BatteryVoltage BatteryVoltage { get; set; }
|
||||
|
||||
public bool FactorySealed { get; set; }
|
||||
|
||||
public bool IsValid { get; set; }
|
||||
|
||||
private void ValidateParameters()
|
||||
{
|
||||
this.IsValid = !this.FactorySealed;
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var firmwareTokens = this.VersionAndType
|
||||
?.Value
|
||||
?.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
?? new string[2];
|
||||
|
||||
var versionString = string.Empty;
|
||||
|
||||
if (firmwareTokens?.Length > 0 && firmwareTokens[0]?.Length > 0)
|
||||
{
|
||||
versionString = firmwareTokens[0].Substring(1);
|
||||
}
|
||||
|
||||
this.IsValid = double.TryParse(versionString, out var version) && version >= 1.23;
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var typeString = string.Empty;
|
||||
|
||||
if (firmwareTokens?.Length > 1 && firmwareTokens[1]?.Length > 0)
|
||||
{
|
||||
typeString = firmwareTokens[1].ToUpper();
|
||||
}
|
||||
|
||||
this.IsValid = typeString == "OMNI-01" || typeString == "OMNI-02";
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.IsValid = 3.19 <= this.BatteryVoltage.Volts && this.BatteryVoltage.Volts <= 3.75;
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.IsValid = this.RebootsCount != 0xFF;
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.IsValid = Math.Abs((DateTime.UtcNow - this.SystemTime.DateTime).Seconds) <= 700;
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.IsValid = Math.Abs((DateTime.UtcNow - this.ManifacturingTime.DateTime).Seconds) <= 365;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using OmniPlus.Features;
|
||||
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
@@ -93,7 +94,7 @@ namespace OmniPlus
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Parameters.Clear();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user