Skip to content

Commit 9a49b48

Browse files
committed
useClearTextTraffic:true
1 parent 32ccd02 commit 9a49b48

File tree

5 files changed

+81
-23
lines changed

5 files changed

+81
-23
lines changed

config.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="de.dl9rdz" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget id="de.dl9rdz" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
3+
xmlns:android="schemas.android.com/apk/res/android">
34
<name>rdzSondyGO</name>
45
<description>
56
A sample Apache Cordova application that uses rdzwx-plugin.
@@ -22,6 +23,10 @@
2223

2324
<platform name="android">
2425
<allow-intent href="market:*" />
26+
<splash src="res/icon.png"/>
27+
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
28+
<application android:usesCleartextTraffic="true" />
29+
</edit-config>
2530
</platform>
2631
<icon src="res/icon.png"/>
2732

@@ -31,4 +36,7 @@
3136

3237
<preference name="android-minSdkVersion" value="23" />
3338
<preference name="android-targetSdkVersion" value="29" />
39+
40+
<preference name="SplashScreen" value="none" />
41+
3442
</widget>

www/css/index.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ html, body {
9898
color: #008cba;
9999
}
100100

101+
.infocontent .lifenessinfo {
102+
color: #ff0000;
103+
}
104+
.infocontent-status0 .lifenessinfo {
105+
color: #00ff00;
106+
}
107+
.infocontent-status2 .lifenessinfo {
108+
color: #ffff00;
109+
}
110+
101111
@media (orientation: portrait) {
102112
.infotable {
103113
width: 75vw;

www/img/ballon.png

734 Bytes
Loading

www/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
-->
4646
<script src="js/easy-button.js"></script>
4747

48-
<title>Hello World</title>
48+
<title>rdzSondyGO V1.0.1</title>
4949
</head>
5050
<body>
5151
<div id="all">

www/js/index.js

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var myposMarker = null;
3333
var ballonIcon, landIcon;
3434
var infobox = null;
3535

36-
var checkMark = "&#9989;";
36+
//var checkMark = "&#9989;";
37+
var checkMark = "&#x2714;";
3738
var crossMark = "&#x274C;";
3839

3940
// add "bottom center" to leaflet
@@ -63,6 +64,7 @@ function onDeviceReady() {
6364
tfatlas = L.tileLayer('https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png?apikey=' + tfapikey, {attribution: '&copy; <a href="http://www.thunderforest.com/">Thunderforest</a>, &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'}),
6465
opentopo = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>-Mitwirkende, <a href="http://viewfinderpanoramas.org">SRTM</a> | Kartendarstellung: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'}),
6566
sat = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'}),
67+
offline = L.tileLayer('file:///android_asset/www/tiles/{z}/{x}/{y}.png', {attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>', maxNativeZoom: 14} );
6668
Stamen_TonerHybrid = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-hybrid/{z}/{x}/{y}{r}.{ext}', {
6769
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
6870
subdomains: 'abcd',
@@ -87,7 +89,8 @@ function onDeviceReady() {
8789
"OpenCycleMap": tfcycle,
8890
"OpenTopoMap" : opentopo,
8991
"Sat": sat,
90-
"Hybdir": hybrid,
92+
"Hybdir": hybrid
93+
<!-- 'Offline': offline -->
9194
};
9295

9396
var baseMapControl = new L.control.layers(baseMaps, {}, { collapsed: true, position: 'topright' } ).addTo(map);
@@ -147,21 +150,29 @@ function onDeviceReady() {
147150
if(this._contentShown == false) { this._showContent(); } else { this._hideContent(); }
148151
},
149152
setContent: function(obj) {
153+
//alert(JSON.stringify(obj));
150154
if(!this._infoContentContainer) return;
151155
if(obj.type == null) obj.type = "RS41"; // TODO fix in plugin
152-
distance = L.latLng(obj).distanceTo(L.latLng(mypos))
153-
if(distance>9999) { distance = distance.toFixed(0); }
154-
else { distance = distance.toFixed(1); }
155-
distance = "d=" + distance + "m";
156-
l1 = "<table class=\"infotable\"><tr><td class=\"infotd\">" + obj.type + "</td><td class=\"infotdr\">" + obj.ser + "</td></tr></table>";
157-
l2 = "<table class=\"infotable\"><tr><td class=\"infotd\">" + obj.freq.toFixed(3) + " MHz </td><td class=\"infotdr\" style=\”font-size:0.9em;\">" + (0.001*obj.afc).toFixed(2) + " kHz</td></tr></table>";
156+
distance = "";
157+
if(obj.validPos) {
158+
distance = L.latLng(obj).distanceTo(L.latLng(mypos))
159+
if(distance>9999) { distance = distance.toFixed(0); }
160+
else { distance = distance.toFixed(1); }
161+
distance = "d=" + distance + "m";
162+
}
163+
sym = "<span class=\"lifenessinfo\">&#x2B24; </span>";
164+
l1 = "<table class=\"infotable\"><tr><td class=\"infotd\">" + sym + obj.type + "</td><td class=\"infotdr\">" + obj.ser + "</td></tr></table>";
165+
l2 = "<table class=\"infotable\"><tr><td class=\"infotd\">" + (1*obj.freq).toFixed(3) + " MHz </td><td class=\"infotdr\" style=\”font-size:0.9em;\">" + (0.001*obj.afc).toFixed(2) + " kHz</td></tr></table>";
158166
l3 = "<table class=\"infotable\"><tr><td class=\"infotd\">" + obj.alt.toFixed(0) + "m</td><td class=\"infotd\">" + obj.vs + "m/s </td><td class=\"infotdr\">" + (obj.hs*3.6).toFixed(1) + "km/h </td></tr></table>";
159167
l4 = "<table class=\"infotable\"><tr><td class=\"infotd\">RSSI: " + -0.5*obj.rssi + " </td><td class=\"infotdr\">" + distance + " </td></tr></table>";
160168
this._infoContentL1.innerHTML = l1;
161169
this._infoContentL2.innerHTML = l2;
162170
this._infoContentL3.innerHTML = l3;
163171
this._infoContentL4.innerHTML = l4;
164172
},
173+
setStatus: function(status) { // 0: rx, 1=to, 2=err, ...
174+
L.DomUtil.setClass(this._infoContentL1, "infocontent infocontentl1 infocontent-status"+status);
175+
},
165176
_hideContent: function(ev) {
166177
this._infoBody.style.display = 'none';
167178
this._infoCloseButton.style.display = 'none';
@@ -197,10 +208,10 @@ function onDeviceReady() {
197208
ttgourl: "http://192.168.42.1",
198209
states: [{ stateName: 'offline',
199210
icon: '<span class="ttgostatus">' + crossMark + '</span>'
200-
//, onClick: function(btn, map) { btn.state('online'); }
211+
, onClick: function(btn, map) { btn.state('online'); }
201212
},
202213
{ stateName: 'online',
203-
icon: '<span class="ttgostatus">' + checkMark + '</span>',
214+
icon: '<span style="color: transparent; text-shadow: 0 0 0 #009900; font-size:15pt" class="ttgostatus">' + checkMark + '</span>',
204215
onClick: function(btn, map) { cordova.InAppBrowser.open(btn.ttgourl, '_blank', "location=yes"); }
205216
}
206217
],
@@ -213,9 +224,9 @@ function onDeviceReady() {
213224

214225
ballonIcon = L.icon({
215226
iconUrl: "img/ballon.png",
216-
iconSize: [17,22],
217-
iconAnchor: [9,22],
218-
popupAnchor: [0,-28]
227+
iconSize: [32,32],
228+
iconAnchor: [16,32],
229+
popupAnchor: [0,-32]
219230
});
220231
landingIcon = L.icon({
221232
iconUrl: "img/landing.png",
@@ -225,9 +236,10 @@ function onDeviceReady() {
225236
});
226237
ready = 1;
227238
RdzWx.start("testarg", callBack);
239+
setInterval(periodicStatusCheck, 1000);
228240

229241
// just for testing
230-
update( {id: "A1234567", lat: 48, lon: 13, alt: 10000, vs: 10, hs: 30, rssi: -90, rxStat: "||||||||||||....", type: "RS41", freq: "400.000", afc: "+1.2", ser: "A1234567"} );
242+
update( {res: 0, validId: 1, validPos: 1, id: "A1234567", lat: 48, lon: 13, alt: 10000, vs: 10, hs: 30, rssi: -90, rxStat: "||||||||||||....", type: "RS41", freq: "400.000", afc: "+1.2", ser: "A1234567"} );
231243
updateMypos(mypos);
232244
}
233245

@@ -297,7 +309,10 @@ function getPrediction() {
297309
const url = TAWHIRI + formatParams(tParams);
298310
xhr.onreadystatechange = function() {
299311
if(xhr.readyState === 4) {
300-
console.log(xhr.response);
312+
if( (xhr.status/100)!=2 ) {
313+
alert("Request failed: "+xhr.statusText);
314+
return;
315+
}
301316
var pred = JSON.parse(xhr.response);
302317
var traj0 = pred.prediction[0].trajectory; // 0 is ascent, 1 is descent...
303318
var traj1 = pred.prediction[1].trajectory; // 0 is ascent, 1 is descent...
@@ -338,9 +353,9 @@ function callBack(arg) {
338353
return;
339354
}
340355
console.log("callback: "+JSON.stringify(arg));
341-
if(obj.id || obj.msgtype) {
342-
update(obj);
343-
}
356+
//if(obj.res || obj.msgtype) {
357+
update(obj);
358+
//}
344359
}
345360

346361
function updateMypos(obj) {
@@ -356,12 +371,25 @@ function updateMypos(obj) {
356371
}
357372
}
358373

374+
var lastMsgTS = 0;
375+
376+
function periodicStatusCheck() {
377+
now = new Date();
378+
if( lastMsgTS && (now-lastMsgTS) > 5000 ) {
379+
// handle connection broken (if still connnected)
380+
//alert("Closing conn: "+now+" vs "+lastMsgTS);
381+
console.log("no data for 5 seconds, closing connection to rdzTTGOsonde");
382+
RdzWx.closeconn("", function(){});
383+
}
384+
}
385+
359386
function update(obj) {
360-
console.log("update called");
361387
if(!ready || !map) {
362388
console.log("not ready");
363389
return;
364390
}
391+
lastMsgTS = new Date();
392+
console.log("update: "+lastMsgTS);
365393
if(obj.msgtype) {
366394
if(obj.msgtype == "ttgostatus") {
367395
ttgoStatus.ttgourl = 'http://' + obj.ip;
@@ -370,10 +398,23 @@ function update(obj) {
370398
if(obj.msgtype == "gps") {
371399
updateMypos(obj);
372400
}
401+
console.log("update: type="+obj.msgtype);
373402
return;
374403
}
375404

405+
// position update
406+
console.log("Pos update: "+JSON.stringify(obj));
407+
infobox.setContent(obj);
408+
infobox.setStatus(obj.res);
409+
if( (!obj.validId) || (!obj.validPos) || (obj.res!=0) ) {
410+
// no valid pos...
411+
// res: 1=Timeout, 2=CRC error, 3=unknown, 4=no position
412+
console.log("valid: "+(!obj.validId)+" validPos: "+(!obj.validPos)+" res: "+(obj.res!=0));
413+
console.log("update with no valid pos");
414+
return;
415+
}
376416
lastObj.obj = obj;
417+
console.log("Good update!");
377418
var pos = new L.LatLng(obj.lat, obj.lon);
378419
var marker;
379420
var tooltip;
@@ -392,14 +433,13 @@ function update(obj) {
392433
markers[obj.id] = marker;
393434
marker.addTo(map);
394435
poly.addTo(map);
395-
tooltip = L.tooltip({ direction: 'right', permanent: true, className: 'sondeTooltip', offset: [10,0], interactive: false, opacity: 0.6 });
436+
tooltip = L.tooltip({ direction: 'right', permanent: true, className: 'sondeTooltip', offset: [10,-16], interactive: false, opacity: 0.6 });
396437
marker.bindTooltip(tooltip);
397438
marker.tt = tooltip;
398439
marker.vsavg = obj.vs;
399440
}
400441
var tt = '<div class="tooltip-container">' + obj.id + '<div class="text-speed tooltip-container">' + obj.alt + 'm '+ obj.vs +'m/s ' + (obj.hs*3.6).toFixed(1) + 'km/h </div></div>';
401442
tooltip.setContent(tt);
402-
infobox.setContent(obj);
403443

404444
marker.setLatLng(pos);
405445
marker.update(); // necessary?

0 commit comments

Comments
 (0)