Skip to content

Commit ce3c60f

Browse files
authored
Merge pull request #18 from HB9HIL/more_data
Add more CAT data
2 parents f701a04 + dc4e03e commit ce3c60f

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

renderer.js

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ async function get_trx() {
135135
let currentCat={};
136136
currentCat.vfo=await getInfo('rig.get_vfo');
137137
currentCat.mode=await getInfo('rig.get_mode');
138+
currentCat.ptt=await getInfo('rig.get_ptt');
139+
currentCat.power=await getInfo('rig.get_power') ?? 0;
140+
currentCat.split=await getInfo('rig.get_split');
141+
currentCat.vfoB=await getInfo('rig.get_vfoB');
142+
currentCat.modeB=await getInfo('rig.get_modeB');
143+
138144
$("#current_trx").html((currentCat.vfo/(1000*1000))+" MHz / "+currentCat.mode);
139145
if (!(isDeepEqual(oldCat,currentCat))) {
140146
// console.log(currentCat);
@@ -146,21 +152,21 @@ async function get_trx() {
146152

147153
async function getInfo(which) {
148154
const response = await fetch(
149-
"http://"+$("#flrig_host").val()+':'+$("#flrig_port").val(),
150-
{
155+
"http://"+$("#flrig_host").val()+':'+$("#flrig_port").val(), {
151156
method: 'POST',
152157
// mode: 'no-cors',
153-
headers: {
154-
'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
155-
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
156-
},
157-
body: '<?xml version="1.0"?><methodCall><methodName>'+which+'</methodName></methodCall>'
158-
});
159-
const data = await response.text();
158+
headers: {
159+
'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
160+
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
161+
},
162+
body: '<?xml version="1.0"?><methodCall><methodName>'+which+'</methodName></methodCall>'
163+
}
164+
);
165+
const data = await response.text();
160166
var parser = new DOMParser();
161-
var xmlDoc = parser.parseFromString(data, "text/xml");
162-
var qrgplain = xmlDoc.getElementsByTagName("value")[0].textContent;
163-
return qrgplain;
167+
var xmlDoc = parser.parseFromString(data, "text/xml");
168+
var qrgplain = xmlDoc.getElementsByTagName("value")[0].textContent;
169+
return qrgplain;
164170
}
165171

166172
async function getsettrx() {
@@ -199,7 +205,28 @@ const isObject = (object) => {
199205
};
200206

201207
async function informWavelog(CAT) {
202-
let data={ radio: "WLGate", key: cfg.wavelog_key, radio: cfg.wavelog_radioname, frequency: (CAT.vfo), mode: CAT.mode };
208+
let data = {
209+
radio: "WLGate",
210+
key: cfg.wavelog_key,
211+
radio: cfg.wavelog_radioname
212+
};
213+
if (CAT.power !== undefined && CAT.power !== 0) {
214+
data.power = CAT.power;
215+
}
216+
// if (CAT.ptt !== undefined) { // not impleented yet in Wavelog, so maybe later
217+
// data.ptt = CAT.ptt;
218+
// }
219+
if (CAT.split == '1') {
220+
// data.split=true; // not implemented yet in Wavelog
221+
data.frequency=CAT.vfoB;
222+
data.mode=CAT.modeB;
223+
data.frequency_rx=CAT.vfo;
224+
data.mode_rx=CAT.mode;
225+
} else {
226+
data.frequency=CAT.vfo;
227+
data.mode=CAT.mode;
228+
}
229+
203230
let x=await fetch(cfg.wavelog_url + '/api/radio', {
204231
method: 'POST',
205232
rejectUnauthorized: false,

0 commit comments

Comments
 (0)