Skip to content

Commit b34d0e0

Browse files
committed
use new API for receivers
1 parent 0813228 commit b34d0e0

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

js/tracker.js

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var mission_id = 0;
22
var position_id = 0;
33
var data_url = "https://api.v2.sondehub.org/datanew";
4-
var receivers_url = "https://api.v2.sondehub.org/listeners";
4+
var receivers_url = "https://api.v2.sondehub.org/listeners/telemetry";
55
var predictions_url = "https://api.v2.sondehub.org/predictions?vehicles=";
66
var recovered_sondes_url = "https://api.v2.sondehub.org/recovered";
77

@@ -2844,29 +2844,28 @@ function refreshSingleOld(serial) {
28442844
}
28452845

28462846
function refreshReceivers() {
2847-
// if options to hide receivers is selected do nothing
28482847
if(offline.get('opt_hide_receivers')) return;
28492848

2849+
var mode = wvar.mode.toLowerCase();
2850+
mode = (mode == "position") ? "latest" : mode.replace(/ /g,"");
2851+
2852+
data_str = "duration=3h";
2853+
28502854
$.ajax({
28512855
type: "GET",
28522856
url: receivers_url,
2853-
data: "",
2857+
data: data_str,
28542858
dataType: "json",
28552859
success: function(response, textStatus) {
2856-
offline.set('receivers', response);
28572860
updateReceivers(response);
28582861
},
2859-
error: function() {
2860-
if(!ls_receivers && offline.get('opt_offline')) updateReceivers(offline.get('receivers'));
2861-
},
28622862
complete: function(request, textStatus) {
28632863
periodical_listeners = setTimeout(refreshReceivers, 60 * 1000);
28642864
}
28652865
});
28662866
}
28672867

28682868
function refreshRecoveries() {
2869-
// TODO: Option to hide recoveries
28702869
if(offline.get('opt_hide_recoveries')) return;
28712870

28722871
$.ajax({
@@ -2875,8 +2874,6 @@ function refreshRecoveries() {
28752874
data: "",
28762875
dataType: "json",
28772876
success: function(response, textStatus) {
2878-
// TODO: Offline stuff. (Or don't bother?)
2879-
//offline.set('recoveries', response);
28802877
updateRecoveries(response);
28812878
},
28822879
error: function() {
@@ -3007,7 +3004,11 @@ function updateReceiverMarker(receiver) {
30073004
// init a marker if the receiver doesn't already have one
30083005
if(!receiver.marker) {
30093006

3010-
if (!receiver.description.includes("radiosonde_auto_rx")) {
3007+
if (receiver.software == "radiosonde_auto_rx") {
3008+
//future option to show different icon per software
3009+
} else if (receiver.software == "rdzTTGO") {
3010+
//future option to show different icon per software
3011+
} else {
30113012
//future option to show different icon per software
30123013
}
30133014

@@ -3038,36 +3039,40 @@ function updateReceivers(r) {
30383039
if(!r) return;
30393040
ls_receivers = true;
30403041

3041-
var i = 0, ii = r.length;
3042-
for(; i < ii; i++) {
3043-
var lat = parseFloat(r[i].lat);
3044-
var lon = parseFloat(r[i].lon);
3042+
for (var i in r) {
3043+
if (r.hasOwnProperty(i)) {
3044+
var last = r[i][Object.keys(r[i])[Object.keys(r[i]).length - 1]];
3045+
if(last.mobile != false) continue;
3046+
var lat = parseFloat(last.uploader_position[0]);
3047+
var lon = parseFloat(last.uploader_position[1]);
3048+
var alt = parseFloat(last.uploader_position[2]);
30453049

3046-
if(lat < -90 || lat > 90 || lon < -180 || lon > 180) continue;
3050+
if(lat < -90 || lat > 90 || lon < -180 || lon > 180) continue;
30473051

3048-
// Filter out any receivers that are from the TTN Bridge code, and that are older than 1 hour.
3049-
// This helps de-clutter the map during launches utilising TTN, and that result in *many* new
3050-
// receivers showing up on the map.
3051-
var age = parseFloat(r[i].tdiff_hours); // Grab age of the receiver.
3052-
if(r[i].description.includes('TTN_LORAWAN_GW') && age > 1.0) continue;
3052+
var age = new Date(last.ts);
30533053

3054-
var r_index = $.inArray(r[i].name, receiver_names);
3054+
var r_index = $.inArray(last.uploader_callsign, receiver_names);
30553055

3056-
if(r_index == -1) {
3057-
receiver_names.push(r[i].name);
3058-
r_index = receiver_names.length - 1;
3059-
receivers[r_index] = {marker: null, infobox: null};
3060-
}
3056+
if(r_index == -1) {
3057+
receiver_names.push(r[i].name);
3058+
r_index = receiver_names.length - 1;
3059+
receivers[r_index] = {marker: null, infobox: null};
3060+
}
30613061

3062-
var receiver = receivers[r_index];
3063-
receiver.name = r[i].name;
3064-
receiver.lat = lat;
3065-
receiver.lon = lon;
3066-
receiver.alt = parseFloat(r[i].alt);
3067-
receiver.description = "<font style='font-size: 13px'>"+r[i].name+"</font><br/>" + r[i].description.replace("><BR>\n<","><").replace("ago<BR>\n<","ago<");
3068-
receiver.fresh = true;
3062+
var receiver = receivers[r_index];
3063+
receiver.name = last.uploader_callsign;
3064+
receiver.software = last.software_name;
3065+
receiver.version = last.software_version;
3066+
receiver.lat = lat;
3067+
receiver.lon = lon;
3068+
receiver.alt = alt;
3069+
receiver.age = age.toISOString();
3070+
receiver.description = "<font style='font-size: 13px'>"+receiver.name+"</font><br/><font size='-2'><BR><B>Radio: </B>" + last.software_name + "-" + last.software_version
3071+
+ "<BR><B>Antenna: </B>" + last.uploader_antenna + "<BR><B>Last Contact: </B>" + age.toISOString() + "<BR></font>";
3072+
receiver.fresh = true;
30693073

3070-
updateReceiverMarker(receiver);
3074+
updateReceiverMarker(receiver);
3075+
}
30713076
}
30723077

30733078
// clear old receivers

0 commit comments

Comments
 (0)