kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
Merge branch 'LukePrior-devel' into devel
commit
56df804a6a
|
@ -60,7 +60,7 @@ WiFiClient client;
|
||||||
WiFiClient shclient; // Sondehub v2
|
WiFiClient shclient; // Sondehub v2
|
||||||
unsigned long time_last_update = 0;
|
unsigned long time_last_update = 0;
|
||||||
/* SH_LOC_OFF: never send position information to SondeHub
|
/* SH_LOC_OFF: never send position information to SondeHub
|
||||||
SH_LOC_FIXED: send fixed position (if specified in config) or GPS position (if there is a GPS fix) as fixed station position (no chase mode) to sondehub
|
SH_LOC_FIXED: send fixed position (if specified in config) to sondehub
|
||||||
SH_LOC_CHASE: always activate chase mode and send GPS position (if available)
|
SH_LOC_CHASE: always activate chase mode and send GPS position (if available)
|
||||||
SH_LOC_AUTO: if there is no valid GPS position, or GPS position < MIN_LOC_AUTO_DIST away from known fixed position: use FIXED mode
|
SH_LOC_AUTO: if there is no valid GPS position, or GPS position < MIN_LOC_AUTO_DIST away from known fixed position: use FIXED mode
|
||||||
otherwise, i.e. if there is a valid GPS position and (either no fixed position in config, or GPS position is far away from fixed position), use CHASE mode.
|
otherwise, i.e. if there is a valid GPS position and (either no fixed position in config, or GPS position is far away from fixed position), use CHASE mode.
|
||||||
|
@ -3115,40 +3115,52 @@ void sondehub_station_update(WiFiClient *client, struct st_sondehub *conf) {
|
||||||
"{"
|
"{"
|
||||||
"\"software_name\": \"%s\","
|
"\"software_name\": \"%s\","
|
||||||
"\"software_version\": \"%s\","
|
"\"software_version\": \"%s\","
|
||||||
"\"uploader_callsign\": \"%s\","
|
"\"uploader_callsign\": \"%s\",",
|
||||||
"\"uploader_contact_email\": \"%s\",",
|
version_name, version_id, conf->callsign);
|
||||||
version_name, version_id, conf->callsign, conf->email);
|
|
||||||
w += strlen(w);
|
w += strlen(w);
|
||||||
|
|
||||||
// We send GPS position: (a) in CHASE mode, (b) in FIXED mode if no fixed location has been specified in config
|
// Only send email if provided
|
||||||
if (chase == SH_LOC_CHASE || (chase == SH_LOC_FIXED && (isnan(conf->lat) || isnan(conf->lon)) ) ) {
|
if (conf->email != '\0') {
|
||||||
|
sprintf(w,
|
||||||
|
"\"uploader_contact_email\": \"%s\",",
|
||||||
|
conf->email);
|
||||||
|
w += strlen(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only send antenna if provided
|
||||||
|
if (conf->antenna != '\0') {
|
||||||
|
sprintf(w,
|
||||||
|
"\"uploader_antenna\": \"%s\",",
|
||||||
|
conf->antenna);
|
||||||
|
w += strlen(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We send GPS position: (a) in CHASE mode, (b) in AUTO mode if no fixed location has been specified in config
|
||||||
|
if (chase == SH_LOC_CHASE) {
|
||||||
if (gpsPos.valid && gpsPos.lat != 0 && gpsPos.lon != 0) {
|
if (gpsPos.valid && gpsPos.lat != 0 && gpsPos.lon != 0) {
|
||||||
sprintf(w,
|
sprintf(w,
|
||||||
"\"uploader_position\": [%.6f,%.6f,%d],"
|
"\"uploader_position\": [%.6f,%.6f,%d],"
|
||||||
"\"uploader_antenna\": \"%s\","
|
"\"mobile\": true",
|
||||||
"\"mobile\": true"
|
gpsPos.lat, gpsPos.lon, gpsPos.alt);
|
||||||
"}",
|
} else {
|
||||||
gpsPos.lat, gpsPos.lon, gpsPos.alt, conf->antenna);
|
sprintf(w, "\"uploader_position\": [null,null,null]");
|
||||||
}
|
}
|
||||||
|
w += strlen(w);
|
||||||
}
|
}
|
||||||
// Otherweise, in FIXED mode we send the fixed position from config (if specified)
|
// Otherweise, in FIXED mode we send the fixed position from config (if specified)
|
||||||
else if (chase == SH_LOC_FIXED) {
|
else if (chase == SH_LOC_FIXED) {
|
||||||
if ((!isnan(conf->lat)) && (!isnan(conf->lon))) {
|
if ((!isnan(conf->lat)) && (!isnan(conf->lon))) {
|
||||||
sprintf(w,
|
sprintf(w,
|
||||||
"\"uploader_position\": [%.6f,%.6f,%s],"
|
"\"uploader_position\": [%.6f,%.6f,%s]",
|
||||||
"\"uploader_antenna\": \"%s\""
|
conf->lat, conf->lon, conf->alt[0] ? conf->alt : "null");
|
||||||
"}",
|
} else {
|
||||||
conf->lat, conf->lon, conf->alt[0] ? conf->alt : "null", conf->antenna);
|
sprintf(w, "\"uploader_position\": [null,null,null]");
|
||||||
}
|
}
|
||||||
|
w += strlen(w);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// otherwise (in SH_LOC_NONE mode) we dont include any position info
|
// otherwise (in SH_LOC_NONE mode) we dont include any position info
|
||||||
sprintf(w,
|
sprintf(w, "}");
|
||||||
"\"uploader_position\": [null,null,null],"
|
|
||||||
"\"uploader_antenna\": \"%s\""
|
|
||||||
"}",
|
|
||||||
conf->antenna);
|
|
||||||
}
|
|
||||||
|
|
||||||
client->println("PUT /listeners HTTP/1.1");
|
client->println("PUT /listeners HTTP/1.1");
|
||||||
client->print("Host: ");
|
client->print("Host: ");
|
||||||
|
@ -3210,6 +3222,12 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
||||||
// For all others, sec should always be 0 and time the exact time in seconds
|
// For all others, sec should always be 0 and time the exact time in seconds
|
||||||
time_t t = s->time;
|
time_t t = s->time;
|
||||||
|
|
||||||
|
int chase = conf->chase;
|
||||||
|
// automatically decided if CHASE or FIXED mode is used (for config AUTO)
|
||||||
|
if (chase == SH_LOC_AUTO) {
|
||||||
|
if (SH_LOC_AUTO_IS_CHASE) chase = SH_LOC_CHASE; else chase = SH_LOC_FIXED;
|
||||||
|
}
|
||||||
|
|
||||||
while (client->available() > 0) {
|
while (client->available() > 0) {
|
||||||
// data is available from remote server, process it...
|
// data is available from remote server, process it...
|
||||||
int cnt = client->readBytesUntil('\n', rs_msg, MSG_SIZE-1);
|
int cnt = client->readBytesUntil('\n', rs_msg, MSG_SIZE-1);
|
||||||
|
@ -3280,34 +3298,31 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
||||||
"\"manufacturer\": \"%s\","
|
"\"manufacturer\": \"%s\","
|
||||||
"\"serial\": \"%s\","
|
"\"serial\": \"%s\","
|
||||||
"\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
|
"\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
|
||||||
"\"lat\": %.6f,"
|
"\"lat\": %.5f,"
|
||||||
"\"lon\": %.6f,"
|
"\"lon\": %.5f,"
|
||||||
"\"alt\": %.3f,"
|
"\"alt\": %.5f,"
|
||||||
"\"frequency\": %.3f,"
|
"\"frequency\": %.3f,"
|
||||||
"\"vel_h\": %.3f,"
|
"\"vel_h\": %.5f,"
|
||||||
"\"vel_v\": %.3f,"
|
"\"vel_v\": %.5f,"
|
||||||
"\"heading\": %.3f,"
|
"\"heading\": %.5f,"
|
||||||
"\"rssi\": %.1f,",
|
"\"rssi\": %.1f,"
|
||||||
|
"\"frame\": %d,"
|
||||||
|
"\"type\": \"%s\",",
|
||||||
version_name, version_id, conf->callsign,
|
version_name, version_id, conf->callsign,
|
||||||
timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec,
|
timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec,
|
||||||
manufacturer_string[realtype], s->ser,
|
manufacturer_string[realtype], s->ser,
|
||||||
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec,
|
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec,
|
||||||
(float)s->lat, (float)s->lon, (float)s->alt, (float)s->freq, (float)s->hs, (float)s->vs,
|
(float)s->lat, (float)s->lon, (float)s->alt, (float)s->freq, (float)s->hs, (float)s->vs,
|
||||||
(float)s->dir, -((float)s->rssi / 2)
|
(float)s->dir, -((float)s->rssi / 2), s->vframe, sondeTypeStrSH[realtype]
|
||||||
);
|
);
|
||||||
w += strlen(w);
|
w += strlen(w);
|
||||||
|
|
||||||
|
// Only send sats if not M20
|
||||||
if (realtype != STYPE_M20) {
|
if (realtype != STYPE_M20) {
|
||||||
sprintf(w, "\"sats\": %d,", (int)s->sats);
|
sprintf(w, "\"sats\": %d,", (int)s->sats);
|
||||||
w += strlen(w);
|
w += strlen(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(w, "\"frame\": %d,", s->vframe);
|
|
||||||
w += strlen(w);
|
|
||||||
|
|
||||||
sprintf(w, "\"type\": \"%s\",", sondeTypeStrSH[realtype]);
|
|
||||||
w += strlen(w);
|
|
||||||
|
|
||||||
/* if there is a subtype (DFM only) */
|
/* if there is a subtype (DFM only) */
|
||||||
if ( TYPE_IS_DFM(s->type) && s->subtype > 0 && s->subtype < 16 ) {
|
if ( TYPE_IS_DFM(s->type) && s->subtype > 0 && s->subtype < 16 ) {
|
||||||
const char *t = dfmSubtypeStrSH[s->subtype];
|
const char *t = dfmSubtypeStrSH[s->subtype];
|
||||||
|
@ -3317,6 +3332,7 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
||||||
w += strlen(w);
|
w += strlen(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only send temp & humidity if provided
|
||||||
if (((int)s->temperature != 0) && ((int)s->relativeHumidity != 0)) {
|
if (((int)s->temperature != 0) && ((int)s->relativeHumidity != 0)) {
|
||||||
sprintf(w,
|
sprintf(w,
|
||||||
"\"temp\": %.1f,"
|
"\"temp\": %.1f,"
|
||||||
|
@ -3326,38 +3342,41 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
||||||
w += strlen(w);
|
w += strlen(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((conf->chase == 0) && (!isnan(conf->lat)) && (!isnan(conf->lon))) {
|
// Only send antenna if provided
|
||||||
if (conf->alt[0] != '\0') {
|
if (conf->antenna != '\0') {
|
||||||
sprintf(w,
|
sprintf(w,
|
||||||
"\"uploader_position\": [%.6f,%.6f,%s],"
|
"\"uploader_antenna\": \"%s\",",
|
||||||
"\"uploader_antenna\": \"%s\""
|
conf->antenna);
|
||||||
"}",
|
w += strlen(w);
|
||||||
conf->lat, conf->lon, conf->alt, conf->antenna
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
sprintf(w,
|
|
||||||
"\"uploader_position\": [%.6f,%.6f,null],"
|
|
||||||
"\"uploader_antenna\": \"%s\""
|
|
||||||
"}",
|
|
||||||
conf->lat, conf->lon, conf->antenna
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (gpsPos.valid && gpsPos.lat != 0 && gpsPos.lon != 0) {
|
// We send GPS position: (a) in CHASE mode, (b) in AUTO mode if no fixed location has been specified in config
|
||||||
|
if (chase == SH_LOC_CHASE) {
|
||||||
|
if (gpsPos.valid && gpsPos.lat != 0 && gpsPos.lon != 0) {
|
||||||
sprintf(w,
|
sprintf(w,
|
||||||
"\"uploader_position\": [%.6f,%.6f,%d],"
|
"\"uploader_position\": [%.6f,%.6f,%d],"
|
||||||
"\"uploader_antenna\": \"%s\""
|
"\"mobile\": true",
|
||||||
"}",
|
gpsPos.lat, gpsPos.lon, gpsPos.alt);
|
||||||
gpsPos.lat, gpsPos.lon, gpsPos.alt, conf->antenna
|
} else {
|
||||||
);
|
sprintf(w, "\"uploader_position\": [null,null,null]");
|
||||||
}
|
}
|
||||||
else {
|
w += strlen(w);
|
||||||
|
}
|
||||||
|
// Otherweise, in FIXED mode we send the fixed position from config (if specified)
|
||||||
|
else if (chase == SH_LOC_FIXED) {
|
||||||
|
if ((!isnan(conf->lat)) && (!isnan(conf->lon))) {
|
||||||
sprintf(w,
|
sprintf(w,
|
||||||
"\"uploader_antenna\": \"%s\""
|
"\"uploader_position\": [%.6f,%.6f,%s]",
|
||||||
"}",
|
conf->lat, conf->lon, conf->alt[0] ? conf->alt : "null");
|
||||||
conf->antenna
|
} else {
|
||||||
);
|
sprintf(w, "\"uploader_position\": [null,null,null]");
|
||||||
}
|
}
|
||||||
|
w += strlen(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise (in SH_LOC_NONE mode) we dont include any position info
|
||||||
|
sprintf(w, "}");
|
||||||
|
|
||||||
if (shState != SH_CONN_APPENDING) {
|
if (shState != SH_CONN_APPENDING) {
|
||||||
sondehub_send_header(client, s, conf);
|
sondehub_send_header(client, s, conf);
|
||||||
sondehub_send_next(client, s, conf, rs_msg, strlen(rs_msg), 1);
|
sondehub_send_next(client, s, conf, rs_msg, strlen(rs_msg), 1);
|
||||||
|
|
|
@ -121,7 +121,7 @@ mqtt.prefix=rdz_sonde_server/
|
||||||
#-------------------------------#
|
#-------------------------------#
|
||||||
# Sondehub v2 DB settings
|
# Sondehub v2 DB settings
|
||||||
sondehub.active=0
|
sondehub.active=0
|
||||||
sondehub.chase=0
|
sondehub.chase=2
|
||||||
sondehub.host=api.v2.sondehub.org
|
sondehub.host=api.v2.sondehub.org
|
||||||
sondehub.callsign=CHANGEME_RDZTTGO
|
sondehub.callsign=CHANGEME_RDZTTGO
|
||||||
sondehub.lat=
|
sondehub.lat=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const char *version_name = "rdzTTGOsonde";
|
const char *version_name = "rdzTTGOsonde";
|
||||||
const char *version_id = "devel20210912";
|
const char *version_id = "devel20210913";
|
||||||
const int SPIFFS_MAJOR=2;
|
const int SPIFFS_MAJOR=2;
|
||||||
const int SPIFFS_MINOR=14;
|
const int SPIFFS_MINOR=14;
|
||||||
|
|
Ładowanie…
Reference in New Issue