Commit pirate JS files
This commit is contained in:
87
js/CandidateFilterByBadTelemetry.js
Normal file
87
js/CandidateFilterByBadTelemetry.js
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright (c) 2023-forever Douglas Malnati. All rights reserved.
|
||||
|
||||
See the /faq/tos page for details.
|
||||
|
||||
(If this generated header is stamped on a file which is a 3rd party file or under a different license or copyright, then ignore this copyright statement and use that file's terms.)
|
||||
*/
|
||||
|
||||
import { CandidateFilterBase } from './CandidateFilterBase.js';
|
||||
import { NonRejectedOnlyFilter } from './WsprMessageCandidate.js';
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Candidate Filter - Bad Telemetry
|
||||
//
|
||||
// Reject any msg which is detected as invalid
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
export class CandidateFilterByBadTelemetry
|
||||
extends CandidateFilterBase
|
||||
{
|
||||
constructor(t)
|
||||
{
|
||||
super("ByBadTelemetry", t);
|
||||
}
|
||||
|
||||
OnFilterStart()
|
||||
{
|
||||
this.t.Event(`CandidateFilterByBadTelemetry Start`);
|
||||
}
|
||||
|
||||
OnFilterEnd()
|
||||
{
|
||||
this.t.Event(`CandidateFilterByBadTelemetry End`);
|
||||
}
|
||||
|
||||
FilterWindowAlgorithm(msgListList)
|
||||
{
|
||||
// eliminate any extended telemetry marked as the wrong slot
|
||||
for (let slot = 0; slot < 5; ++slot)
|
||||
{
|
||||
for (let msg of NonRejectedOnlyFilter(msgListList[slot]))
|
||||
{
|
||||
if (msg.IsTelemetryExtended())
|
||||
{
|
||||
let codec = msg.GetCodec();
|
||||
|
||||
|
||||
// actually check if decode was bad
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let hdrTypeSupportedList = [
|
||||
0, // user-defined
|
||||
1, // heartbeat
|
||||
2, // ExpandedBasicTelemetry
|
||||
3, // highResLocation
|
||||
15, // vendor-defined
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let hdrRESERVED = codec.GetHdrRESERVEDEnum();
|
||||
let hdrSlot = codec.GetHdrSlotEnum();
|
||||
let hdrType = codec.GetHdrTypeEnum();
|
||||
|
||||
if (hdrRESERVED != 0)
|
||||
{
|
||||
msg.Reject(this.type, `Bad Telemetry - HdrRESERVED is non-zero (${hdrRESERVED})`);
|
||||
}
|
||||
else if (hdrSlot != slot)
|
||||
{
|
||||
msg.Reject(this.type, `Bad Telemetry - HdrSlot (${hdrSlot}) set incorrectly, found in slot ${slot}`);
|
||||
}
|
||||
else if (hdrTypeSupportedList.indexOf(hdrType) == -1)
|
||||
{
|
||||
msg.Reject(this.type, `Bad Telemetry - HdrType (${hdrType}) set to unsupported value`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user