Skip to content

Commit eef800c

Browse files
CopilotMrAlders0n
andcommitted
Add sample_count support to passive RX log entries
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
1 parent 1483881 commit eef800c

1 file changed

Lines changed: 37 additions & 21 deletions

File tree

content/wardrive.js

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,9 +2681,13 @@ function parseRxLogEntry(entry) {
26812681
rssi: entry.rssi,
26822682
pathLength: entry.pathLength,
26832683
header: entry.header,
2684-
lat: entry.lat.toFixed(5),
2685-
lon: entry.lon.toFixed(5),
2686-
timestamp: entry.timestamp
2684+
// Keep original numeric values for CSV export and short formatted strings for UI
2685+
lat: (typeof entry.lat === 'number') ? entry.lat.toFixed(5) : entry.lat,
2686+
lon: (typeof entry.lon === 'number') ? entry.lon.toFixed(5) : entry.lon,
2687+
timestamp: entry.timestamp,
2688+
// New: pass sample_count through (fall back to 1 if not present)
2689+
sampleCount: (typeof entry.sample_count !== 'undefined') ? entry.sample_count : (
2690+
typeof entry.sampleCount !== 'undefined' ? entry.sampleCount : 1)
26872691
};
26882692
}
26892693

@@ -2714,14 +2718,21 @@ function createRxLogEntryElement(entry) {
27142718
topRow.appendChild(time);
27152719
topRow.appendChild(coords);
27162720

2717-
// Chips row: repeater ID and SNR
2721+
// Chips row: repeater ID, SNR and sample count
27182722
const chipsRow = document.createElement('div');
27192723
chipsRow.className = 'heardChips';
27202724

2721-
// Create chip for repeater with SNR
2725+
// Create chip for repeater with SNR (existing helper)
27222726
const chip = createChipElement(parsed.repeaterId, parsed.snr);
27232727
chipsRow.appendChild(chip);
27242728

2729+
// New: sample count chip (small, subtle)
2730+
const sampleChip = document.createElement('span');
2731+
sampleChip.className = 'text-xs font-mono text-slate-400 ml-2 sample-count-chip';
2732+
sampleChip.setAttribute('title', `sample count: ${parsed.sampleCount}`);
2733+
sampleChip.textContent = ${parsed.sampleCount}`;
2734+
chipsRow.appendChild(sampleChip);
2735+
27252736
logEntry.appendChild(topRow);
27262737
logEntry.appendChild(chipsRow);
27272738

@@ -3154,28 +3165,33 @@ function sessionLogToCSV() {
31543165
}
31553166

31563167
/**
3157-
* Convert RX Log to CSV format
3158-
* Columns: Timestamp,RepeaterID,SNR,RSSI,PathLength
3159-
* @returns {string} CSV formatted string
3168+
* Export RX log entries to CSV (used by the copy button)
3169+
* Columns: Timestamp,RepeaterId,Lat,Lon,SNR,SampleCount,PathLength,Header
31603170
*/
31613171
function rxLogToCSV() {
3162-
debugLog('[PASSIVE RX UI] Converting RX log to CSV format');
3163-
3164-
if (rxLogState.entries.length === 0) {
3172+
if (!rxLogState || !Array.isArray(rxLogState.entries) || rxLogState.entries.length === 0) {
31653173
debugWarn('[PASSIVE RX UI] No RX log entries to export');
3166-
return 'Timestamp,RepeaterID,SNR,RSSI,PathLength\n';
3174+
return 'Timestamp,RepeaterId,Lat,Lon,SNR,SampleCount,PathLength,Header\n';
31673175
}
3168-
3169-
const header = 'Timestamp,RepeaterID,SNR,RSSI,PathLength\n';
3170-
3176+
3177+
const header = 'Timestamp,RepeaterId,Lat,Lon,SNR,SampleCount,PathLength,Header\n';
3178+
31713179
const rows = rxLogState.entries.map(entry => {
3172-
// Handle potentially missing fields from old entries
3173-
const snr = entry.snr !== undefined ? entry.snr.toFixed(2) : '';
3174-
const rssi = entry.rssi !== undefined ? entry.rssi : '';
3175-
const pathLength = entry.pathLength !== undefined ? entry.pathLength : '';
3176-
return `${entry.timestamp},${entry.repeaterId},${snr},${rssi},${pathLength}`;
3180+
// normalize fields
3181+
const ts = entry.timestamp || '';
3182+
const repeater = (entry.repeaterId || '').toString().replace(/"/g, '""');
3183+
const lat = (typeof entry.lat === 'number') ? entry.lat.toFixed(5) : (entry.lat || '');
3184+
const lon = (typeof entry.lon === 'number') ? entry.lon.toFixed(5) : (entry.lon || '');
3185+
const snr = (typeof entry.snr !== 'undefined') ? entry.snr : '';
3186+
const sampleCount = (typeof entry.sample_count !== 'undefined') ? entry.sample_count :
3187+
(typeof entry.sampleCount !== 'undefined' ? entry.sampleCount : 1);
3188+
const pathLength = (typeof entry.pathLength !== 'undefined') ? entry.pathLength : '';
3189+
const headerField = (entry.header || '').toString().replace(/"/g, '""');
3190+
3191+
// Quote repeater and header to be safe
3192+
return `${ts},"${repeater}",${lat},${lon},${snr},${sampleCount},${pathLength},"${headerField}"`;
31773193
});
3178-
3194+
31793195
const csv = header + rows.join('\n');
31803196
debugLog(`[PASSIVE RX UI] CSV export complete: ${rxLogState.entries.length} entries`);
31813197
return csv;

0 commit comments

Comments
 (0)