kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
RS41 subtype for sondehub
rodzic
a30f51e5a0
commit
eb769e6d12
|
@ -23,6 +23,7 @@
|
|||
#include "src/rs92gps.h"
|
||||
#include "src/aprs.h"
|
||||
#include "src/ShFreqImport.h"
|
||||
#include "src/RS41.h"
|
||||
|
||||
#if FEATURE_MQTT
|
||||
#include "src/mqtt.h"
|
||||
|
@ -536,11 +537,9 @@ const char *createLiveJson() {
|
|||
strcpy(ptr, "{");
|
||||
|
||||
SondeInfo *s = &sonde.sondeList[sonde.currentSonde];
|
||||
if (s->validID) {
|
||||
sprintf(ptr + strlen(ptr), "\"sonde\": {\"id\": \"%s\", \"freq\": %3.3f, \"type\": \"%s\", \"lat\": %.6f, \"lon\": %.6f, \"alt\": %.0f, \"speed\": %.1f, \"dir\": %.0f, \"climb\": %.1f }", s->id, s->freq, sondeTypeStr[s->type], s->lat, s->lon, s->alt, s->hs, s->dir, s->vs);
|
||||
} else {
|
||||
sprintf(ptr + strlen(ptr), "\"sonde\": {\"launchsite\": \"%s\",\"freq\": %3.3f, \"type\": \"%s\" }", s->launchsite, s->freq, sondeTypeStr[s->type]);
|
||||
}
|
||||
sprintf(ptr + strlen(ptr), "\"res\": %d, \"rssi\": %d, \"sonde\": {\"vframe\": %d, \"time\": %d,\"id\": \"%s\", \"freq\": %3.3f, \"type\": \"%s\","
|
||||
"\"lat\": %.6f, \"lon\": %.6f, \"alt\": %.0f, \"speed\": %.1f, \"dir\": %.0f, \"climb\": %.1f, \"launchsite\": \"%s\" }",
|
||||
s->rxStat[0], s->rssi, s->vframe, s->time, s->id, s->freq, sondeTypeStr[s->type], s->lat, s->lon, s->alt, s->hs, s->dir, s->vs, s->launchsite);
|
||||
|
||||
if (sonde.config.gps_rxd < 0) {
|
||||
// gps disabled
|
||||
|
@ -3689,6 +3688,12 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
|||
if (t) sprintf(w, "\"subtype\": \"%s\",", t);
|
||||
else sprintf(w, "\"subtype\": \"DFMx%X\",", s->subtype); // Unknown subtype
|
||||
w += strlen(w);
|
||||
} else if ( s->type == STYPE_RS41 ) {
|
||||
char buf[11];
|
||||
if(RS41::getSubtype(buf, 11, s)==0) {
|
||||
sprintf(w, "\"subtype\": \"%s\",", buf);
|
||||
w += strlen(w);
|
||||
}
|
||||
}
|
||||
|
||||
// Only send temp if provided
|
||||
|
|
|
@ -70,11 +70,12 @@ $('.leaflet-footer').append(footer);
|
|||
|
||||
var statbar = '';
|
||||
headtxt = function(data,stat) {
|
||||
console.log(data);
|
||||
var staticon = (stat == '1')?greendot:yellowdot;
|
||||
statbar = staticon + statbar;
|
||||
if ((statbar.length) > 10*greendot.length) { statbar = statbar.substring(0,10*greendot.length); }
|
||||
if (data.lat == '0.000000') { return false; }
|
||||
if (data.id) {
|
||||
if (data.res == 0) {
|
||||
$('#sonde_id').html(data.id);
|
||||
$('#sonde_alt').html(data.alt);
|
||||
$('#sonde_climb').html(data.climb);
|
||||
|
@ -155,9 +156,10 @@ headtxt = function(data,stat) {
|
|||
|
||||
draw = function(data) {
|
||||
var stat;
|
||||
console.log(data);
|
||||
if (data.id) {
|
||||
|
||||
if ((data.lat != '0.000000' && data.lon != '0.000000') && (JSON.stringify(data) != JSON.stringify(last_data)) ) {
|
||||
// data.res: 0: ok 1: no rx (timeout), 2: crc err, >2 some other error
|
||||
if ((data.lat != '0.000000' && data.lon != '0.000000') && (data.res==0)) { //JSON.stringify(data) != JSON.stringify(last_data)) ) {
|
||||
var location = [data.lat,data.lon,data.alt];
|
||||
if (!marker) {
|
||||
map.setView(location, 14);
|
||||
|
@ -231,8 +233,10 @@ headtxt = function(data,stat) {
|
|||
|
||||
get_data = function() {
|
||||
$('#status').html(reddot);
|
||||
console.log("get_data called");
|
||||
$.ajax({url: 'live.json', success: (function( data ) {
|
||||
if (typeof data != "object") { data = $.parseJSON(data); }
|
||||
console.log(data);
|
||||
if (data.sonde) {
|
||||
draw(data.sonde);
|
||||
} else {
|
||||
|
|
|
@ -829,11 +829,24 @@ static uint8_t scramble[64] = {150U,131U,62U,81U,177U,73U,8U,152U,50U,5U,89U,
|
|||
int RS41::receive() {
|
||||
sx1278.setPayloadLength(RS41MAXLEN-8);
|
||||
int e = sx1278.receivePacketTimeout(1000, data+8);
|
||||
#if 1
|
||||
if(e) { /*Serial.println("TIMEOUT");*/ return RX_TIMEOUT; }
|
||||
|
||||
for(int i=0; i<RS41MAXLEN; i++) { data[i] = reverse(data[i]); }
|
||||
for(int i=0; i<RS41MAXLEN; i++) { data[i] = data[i] ^ scramble[i&0x3F]; }
|
||||
return decode41(data, RS41MAXLEN);
|
||||
#else
|
||||
// FAKE testing data
|
||||
SondeInfo *si = sonde.si();
|
||||
si->lat = 48;
|
||||
si->lon = -100;
|
||||
si->alt = 30000;
|
||||
si->vs = 3.4;
|
||||
si->validPos = 0x7f;
|
||||
si->validID = 1;
|
||||
strcpy(si->id, "A1234");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int RS41::waitRXcomplete() {
|
||||
|
@ -842,4 +855,17 @@ int RS41::waitRXcomplete() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// copy variant string to buf (max buflen chars; buflen should be 11
|
||||
// return 0 if subtype is available, -1 if not
|
||||
int RS41::getSubtype(char *buf, int buflen, SondeInfo *si) {
|
||||
struct subframeBuffer *sf = (struct subframeBuffer *)si->extra;
|
||||
if(!sf) return -1;
|
||||
if( (sf->valid & (3<<21)) != (3<<21) ) return -1; // or 1 instead of 3 for the first 8 chars only, as in autorx?
|
||||
if(buflen>11) buflen=11; // then buflen should be capped at 9 (8+trailing \0)
|
||||
strncpy(buf, sf->value.names.variant, buflen);
|
||||
buf[buflen-1]=0;
|
||||
if(*buf==0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
RS41 rs41 = RS41();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef inttypes_h
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#include "Sonde.h"
|
||||
|
||||
/* Main class */
|
||||
class RS41
|
||||
|
@ -61,6 +62,8 @@ public:
|
|||
int waitRXcomplete();
|
||||
//int receiveFrame();
|
||||
|
||||
static int getSubtype(char *buf, int buflen, SondeInfo *si);
|
||||
|
||||
int use_ecc = 1;
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue