Skip to content

Commit c3b07ea

Browse files
CopilotMrAlders0n
andcommitted
Fix repeater ID validation and correct SNR range documentation
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
1 parent bb7ae50 commit c3b07ea

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

content/wardrive.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,18 @@ function startRepeaterTracking(sessionLi) {
492492
// Check if this is a group text message (our ping echo)
493493
// Verify path exists and has at least one byte (repeater ID)
494494
if (packet.getPayloadType() === Packet.PAYLOAD_TYPE_GRP_TXT &&
495-
packet.path && packet.path.length > 0 && packet.path[0] !== undefined) {
495+
packet.path && packet.path.length > 0) {
496496
// Extract repeater ID (first byte of path)
497+
// Note: repeaterId can be 0 (valid byte value), so we check path.length instead
497498
const repeaterId = packet.path[0];
499+
500+
// Validate repeater ID is a valid byte value (0-255)
501+
if (typeof repeaterId !== 'number' || repeaterId < 0 || repeaterId > 255) {
502+
console.warn(`Invalid repeater ID: ${repeaterId}`);
503+
return;
504+
}
505+
506+
// SNR ranges from -12 to +12 dB (Int8 / 4)
498507
const snr = Math.round(logData.lastSnr);
499508

500509
// Store or update repeater data (keep best/strongest SNR if duplicate)
@@ -539,7 +548,7 @@ function stopRepeaterTracking() {
539548
const repeaters = state.repeaterData.repeaters;
540549
if (repeaters.size > 0) {
541550
// Format repeater data as [ID1(SNR1),ID2(SNR2),...]
542-
// SNR values are typically negative, e.g., [25(-112),21(-109)]
551+
// SNR values range from -12 to +12 dB, e.g., [25(-8),21(-5),14(3)]
543552
const repeaterList = Array.from(repeaters.entries())
544553
.sort((a, b) => a[0] - b[0]) // Sort by repeater ID
545554
.map(([id, snr]) => `${id}(${snr})`)

0 commit comments

Comments
 (0)