Skip to content

Configurable maxage for SondeHub #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RX_FSK/RX_FSK.ino
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ struct st_configitems config_list[] = {
{"sondehub.callsign", 63, &sonde.config.sondehub.callsign},
{"sondehub.antenna", 63, &sonde.config.sondehub.antenna},
{"sondehub.email", 63, &sonde.config.sondehub.email},
{"sondehub.maxage", 0, &sonde.config.sondehub.maxage},
{"sondehub.fiactive", 0, &sonde.config.sondehub.fiactive},
{"sondehub.fiinterval", 0, &sonde.config.sondehub.fiinterval},
{"sondehub.fimaxdist", 0, &sonde.config.sondehub.fimaxdist},
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/data/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var cfgs = [
[ "sondehub.callsign", "Callsign"],
[ "sondehub.antenna", "Antenna (optional, visisble on SondeHub tracker)"],
[ "sondehub.email", "SondeHub email (optional, only used to contact in case of upload errors)"],
[ "sondehub.maxage", "SondeHub max age of packets before submitting (seconds, ≥ 15)"],
[ "", "SondeHub frequency import", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/SondeHub-import" ],
[ "sondehub.fiactive", "SondeHub frequency import active (0=disabled, 1=active)" ],
[ "sondehub.fiinterval", "Import frequency (minutes, ≥ 5)" ],
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/data/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ sondehub.host=api.v2.sondehub.org
sondehub.callsign=CHANGEME_RDZTTGO
sondehub.antenna=
sondehub.email=
sondehub.maxage=15
#-------------------------------#
# Sondehub freq import settings
#-------------------------------#
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/src/Sonde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ extern const int N_CONFIG;

void Sonde::checkConfig() {
if(config.maxsonde > MAXSONDE) config.maxsonde = MAXSONDE;
if(config.sondehub.maxage<15) config.sondehub.maxage = 15;
if(config.sondehub.fiinterval<5) config.sondehub.fiinterval = 5;
if(config.sondehub.fimaxdist>700) config.sondehub.fimaxdist = 700;
if(config.sondehub.fimaxage>48) config.sondehub.fimaxage = 48;
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/src/Sonde.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct st_sondehub {
char callsign[64];
char antenna[64];
char email[64];
int maxage;
int fiactive;
int fiinterval;
int fimaxdist;
Expand Down
7 changes: 2 additions & 5 deletions RX_FSK/src/conn-sondehub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,6 @@ void ConnSondehub::sondehub_send_data(SondeInfo * s) {
return;
}

// max age of data in JSON request (in seconds)
#define SONDEHUB_MAXAGE 15

char rs_msg[MSG_SIZE];
char *w;
struct tm ts;
Expand Down Expand Up @@ -692,7 +689,7 @@ void ConnSondehub::sondehub_send_data(SondeInfo * s) {
} else {
sondehub_send_next(s, rs_msg, strlen(rs_msg), 0);
}
if (now - shStart > SONDEHUB_MAXAGE) { // after MAXAGE seconds
if (now - shStart > sonde.config.sondehub.maxage) { // after MAXAGE seconds
sondehub_send_last();
shclient_state = SH_CONN_WAITACK;
rs_msg_len = 0; // wait for new msg:
Expand All @@ -705,7 +702,7 @@ void ConnSondehub::sondehub_finish_data() {
if (shclient_state == SH_CONN_APPENDING) {
time_t now;
time(&now);
if (now - shStart > SONDEHUB_MAXAGE + 3) { // after MAXAGE seconds
if (now - shStart > sonde.config.sondehub.maxage + 3) { // after MAXAGE seconds
sondehub_send_last();
shclient_state = SH_CONN_WAITACK;
rs_msg_len = 0; // wait for new msg:
Expand Down