Skip to content

Commit f4e3fe5

Browse files
authored
Merge pull request #60 from goodspeed34/band-undef-patch-1
Support determining band info from parsedXML frequency
2 parents 6c2cf4b + 3ba27c6 commit f4e3fe5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,18 @@ function writeADIF(adifObject) {
299299
return adiWriter;
300300
}
301301

302+
function freqToBand(freq_mz) {
303+
const f = parseFloat(freq_mz);
304+
if (isNaN(f)) return null;
305+
306+
const bandMap = require('tcadif/lib/enums/Band');
307+
for (const [band, { lowerFreq, upperFreq }] of Object.entries(bandMap))
308+
if (f >= parseFloat(lowerFreq) && f <= parseFloat(upperFreq))
309+
return band;
310+
311+
return null;
312+
}
313+
302314
function send2wavelog(o_cfg,adif, dryrun = false) {
303315
let clpayload={};
304316
clpayload.key=o_cfg.wavelog_key.trim();
@@ -413,6 +425,8 @@ ports.forEach(port => {
413425
GRIDSQUARE: parsedXML.contactinfo.gridsquare[0],
414426
STATION_CALLSIGN: parsedXML.contactinfo.mycall[0]
415427
} ]};
428+
let band = freqToBand(adobject.qsos[0].FREQ);
429+
if (band) adobject.qsos[0].BAND = band;
416430
} catch (e) {}
417431
} else {
418432
try {

renderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ window.TX_API.onUpdateMsg((value) => {
154154

155155
window.TX_API.onUpdateTX((value) => {
156156
if (value.created) {
157-
$("#log").html('<div class="alert alert-success" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+value.qsos[0].BAND+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - OK</div>');
157+
$("#log").html('<div class="alert alert-success" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+(value.qsos[0].BAND || 'No BAND')+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - OK</div>');
158158
} else {
159-
$("#log").html('<div class="alert alert-danger" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+value.qsos[0].BAND+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - Error<br/>Reason: '+value.fail.payload.reason+'</div>');
159+
$("#log").html('<div class="alert alert-danger" role="alert">'+value.qsos[0].TIME_ON+" "+value.qsos[0].CALL+" ("+(value.qsos[0].GRIDSQUARE || 'No Grid')+") on "+(value.qsos[0].BAND || 'NO BAND')+" (R:"+(value.qsos[0].RST_RCVD || 'No RST')+" / S:"+(value.qsos[0].RST_SENT || 'No RST')+') - Error<br/>Reason: '+value.fail.payload.reason+'</div>');
160160
}
161161
})
162162

0 commit comments

Comments
 (0)