Skip to content

Commit 1a0d543

Browse files
Mark JessopMark Jessop
authored andcommitted
Merge branch 'testing'
2 parents 5fc5836 + 55da2b7 commit 1a0d543

File tree

2 files changed

+67
-33
lines changed

2 files changed

+67
-33
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ <h4>Support Us!</h4>
9999
If you use SondeHub regularly, please consider <a href="https://www.patreon.com/sondehub" target="_blank" rel="noopener">supporting us on Patreon</a>, or with a <a href="https://sondehub.org/go/donate" target="_blank" rel="noopener">donation on Paypal</a>.
100100

101101
<h4>Amateur HAB Launches?</h4>
102-
You can find Amateur High-Altitude Balloon launches on the <a href="https://tracker.habhub.org/" target="_blank" rel="noopener">HabHub Tracker</a>.
102+
You can find Amateur High-Altitude Balloon launches on the <a href="https://amateur.sondehub.org/" target="_blank" rel="noopener">Sondehub-Amateur Tracker</a>.
103103

104104
<h4>SondeHub Status Pages</h4>
105105
You can find the status of the SondeHub Database on the <a href="https://sondehub.org/go/status" target="_blank" rel="noopener">SondeHub Dashboard</a>.<br/>

js/tracker.js

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,6 +3530,11 @@ function liveData() {
35303530
client.subscribe("batch");
35313531
clientTopic = "batch";
35323532
}
3533+
// Also subscribe to listener data, for listener and chase-car telemetry.
3534+
// To revert listener-via-websockets change, comment out this line,
3535+
// and un-comment the 'Disable periodical listener refresh' lines further below.
3536+
client.subscribe("listener/#");
3537+
35333538
clientConnected = true;
35343539
$("#stText").text("websocket |");
35353540
};
@@ -3570,25 +3575,51 @@ function liveData() {
35703575
var dateNow = new Date().getTime();
35713576
try {
35723577
if (clientActive) {
3573-
var frame = JSON.parse(message.payloadString.toString());
3574-
if (wvar.query == "" || sondePrefix.indexOf(wvar.query) > -1 || wvar.query == frame.serial) {
3575-
if (frame.length == null) {
3576-
var tempDate = new Date(frame.time_received).getTime();
3578+
if(message.topic.startsWith("listener")){
3579+
// Message is Listener / Chase-Car information
3580+
var frame = JSON.parse(message.payloadString.toString());
3581+
// We need to convert this into the right format for feeding into the receiver / chase car update functions.
3582+
// Probably a cleaner way of doing this.
3583+
// Format needs to be {callsign : {timestamp: frame}}
3584+
var formatted_frame = {};
3585+
formatted_frame[frame.uploader_callsign] = {};
3586+
formatted_frame[frame.uploader_callsign][frame.ts] = frame;
3587+
3588+
// Send frames with mobile present and true onto the chase-car updater,
3589+
// otherwise, send them to the receiver updater.
3590+
// Do this on a per-update bases, since listener / chase car updates shouldn't
3591+
// be as frequent.
3592+
if(frame.hasOwnProperty('mobile')) {
3593+
if(frame.mobile == true) {
3594+
updateChase(formatted_frame);
3595+
} else {
3596+
updateReceivers(formatted_frame, single=true);
3597+
}
35773598
} else {
3578-
var tempDate = new Date(frame[frame.length - 1].time_received).getTime()
3599+
updateReceivers(formatted_frame, single=true);
35793600
}
3580-
if ((dateNow - tempDate) < 30000) {
3581-
var test = formatData(frame, true);
3582-
if (clientActive) {
3583-
live_data_buffer.positions.position.push.apply(live_data_buffer.positions.position,test.positions.position)
3601+
3602+
} else {
3603+
var frame = JSON.parse(message.payloadString.toString());
3604+
if (wvar.query == "" || sondePrefix.indexOf(wvar.query) > -1 || wvar.query == frame.serial) {
3605+
if (frame.length == null) {
3606+
var tempDate = new Date(frame.time_received).getTime();
3607+
} else {
3608+
var tempDate = new Date(frame[frame.length - 1].time_received).getTime()
3609+
}
3610+
if ((dateNow - tempDate) < 30000) {
3611+
var test = formatData(frame, true);
3612+
if (clientActive) {
3613+
live_data_buffer.positions.position.push.apply(live_data_buffer.positions.position,test.positions.position)
3614+
}
3615+
$("#stTimer").attr("data-timestamp", dateNow);
3616+
$("#stText").text("websocket |");
3617+
} else if ((dateNow - new Date(frame.time_received).getTime()) > 150000) {
3618+
$("#stText").text("error |");
3619+
refresh();
3620+
} else {
3621+
$("#stText").text("error |");
35843622
}
3585-
$("#stTimer").attr("data-timestamp", dateNow);
3586-
$("#stText").text("websocket |");
3587-
} else if ((dateNow - new Date(frame.time_received).getTime()) > 150000) {
3588-
$("#stText").text("error |");
3589-
refresh();
3590-
} else {
3591-
$("#stText").text("error |");
35923623
}
35933624
}
35943625
}
@@ -3710,7 +3741,7 @@ function refreshReceivers() {
37103741
data: data_str,
37113742
dataType: "json",
37123743
success: function(response, textStatus) {
3713-
updateReceivers(response);
3744+
updateReceivers(response, single=false);
37143745
},
37153746
complete: function(request, textStatus) {
37163747
if (!offline.get("opt_hide_chase")) {
@@ -3746,7 +3777,8 @@ function refreshNewReceivers(initial, serial) {
37463777
},
37473778
complete: function(request, textStatus) {
37483779
if (typeof serial === 'undefined') {
3749-
periodical_listeners = setTimeout(function() {refreshNewReceivers(false)}, 30 * 1000);
3780+
// Disable periodical listener refresh - this data now comes via websockets.
3781+
//periodical_listeners = setTimeout(function() {refreshNewReceivers(false)}, 30 * 1000);
37503782
}
37513783
}
37523784
});
@@ -4023,7 +4055,7 @@ function showRecoveredMap(serial) {
40234055
clean_refresh(wvar.mode, true, true);
40244056
};
40254057

4026-
function updateReceivers(r) {
4058+
function updateReceivers(r, single) {
40274059
if(!r) return;
40284060
ls_receivers = true;
40294061

@@ -4065,20 +4097,22 @@ function updateReceivers(r) {
40654097
}
40664098

40674099
// clear old receivers
4068-
i = 0;
4069-
for(; i < receivers.length;) {
4070-
var e = receivers[i];
4071-
if(e.fresh) {
4072-
e.fresh = false;
4073-
i++;
4074-
}
4075-
else {
4076-
map.removeLayer(e.infobox);
4077-
receiverCanvas.removeLayer(e.marker);
4100+
if(single == false){
4101+
i = 0;
4102+
for(; i < receivers.length;) {
4103+
var e = receivers[i];
4104+
if(e.fresh) {
4105+
e.fresh = false;
4106+
i++;
4107+
}
4108+
else {
4109+
map.removeLayer(e.infobox);
4110+
receiverCanvas.removeLayer(e.marker);
40784111

4079-
// remove from arrays
4080-
receivers.splice(i,1);
4081-
receiver_names.splice(i,1);
4112+
// remove from arrays
4113+
receivers.splice(i,1);
4114+
receiver_names.splice(i,1);
4115+
}
40824116
}
40834117
}
40844118

0 commit comments

Comments
 (0)