mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-11-23 12:57:58 +00:00
Adds fullRfLog (default off) so a sysop can opt in to queuing receptions the capture path cannot attribute to a node — DIRECT routes, 1-byte path hashes, etc — as a diagnostic RF observation stream. The decision lives in a new pure src/capture.js so it stays testable without a DOM; an unattributable reception moves no coverage state (counters, SNR meter, recently-heard, beeper, map hexes untouched). MQTT payload shape and Publisher.buildPayload are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert';
|
|
import { buildRfLogRecord } from '../src/capture.js';
|
|
|
|
const FIX = { lat: 51.05, lon: 3.72, acc_m: 10 };
|
|
const BASE = {
|
|
hk: null, fullRfLog: true, rawHex: 'aabbcc', snr: -7, rssi: -92,
|
|
fix: FIX, captureAllowed: true, nowISO: '2026-08-17T12:00:00.000Z',
|
|
};
|
|
|
|
test('unattributable reception is queued when fullRfLog is on', () => {
|
|
const rec = buildRfLogRecord(BASE);
|
|
assert.ok(rec);
|
|
// Shape is the MQTT contract — it must match the coverage record exactly.
|
|
assert.deepStrictEqual(Object.keys(rec).sort(),
|
|
['acc_m', 'lat', 'lon', 'raw', 'rssi', 'rx_at', 'snr'].sort());
|
|
assert.strictEqual(rec.raw, 'aabbcc');
|
|
assert.strictEqual(rec.rx_at, '2026-08-17T12:00:00.000Z');
|
|
assert.strictEqual(rec.lat, 51.05);
|
|
});
|
|
|
|
test('returns null when fullRfLog is off', () => {
|
|
assert.strictEqual(buildRfLogRecord({ ...BASE, fullRfLog: false }), null);
|
|
});
|
|
|
|
test('returns null for an attributable reception — coverage owns it', () => {
|
|
const hk = { heardKey: '152c', heardKeyLen: 2, src: 'rxlog' };
|
|
assert.strictEqual(buildRfLogRecord({ ...BASE, hk }), null);
|
|
});
|
|
|
|
test('returns null without a GPS fix', () => {
|
|
assert.strictEqual(buildRfLogRecord({ ...BASE, fix: null }), null);
|
|
});
|
|
|
|
test('returns null while stationary', () => {
|
|
assert.strictEqual(buildRfLogRecord({ ...BASE, captureAllowed: false }), null);
|
|
});
|