Another time based telemetry algo.

Only numeric; no need to store seq.
Because alphanumeric telemetry is complained by aprs.fi.

Signed-off-by: Thomas Osterried <dl9sau@darc.de>
pull/7/head
Thomas Osterried 2022-12-18 11:22:56 +01:00
rodzic ec81084a46
commit 6a40329280
3 zmienionych plików z 82 dodań i 25 usunięć

Wyświetl plik

@ -247,15 +247,16 @@
</div>
<div>
<label for="tnc_tel_mic">Self Telemetry Sequence</label>
<select id="tnc_tel_mic" name="tnc_tel_mic" title="self telemetry sequence type (numeric supported by aprs.fi and aprsdirect.de). "Type numeric": Cave: sequence number is stored to flash; flash has a limited number of writes before it becomes defect-.">
<option value="-1">Time based, encoding 0-9A-Za-z</option>
<select id="tnc_tel_mic" name="tnc_tel_mic" title="self telemetry sequence type (only 'numeric' sequences and 'time based numeric sequences' are supported by aprs.fi and aprsdirect.de). Sequence overflow: Type 'time based, alphanumeric' uses digits and letters 0-9,A-Z,a-z and has a resolution of 23s in two months; 'numeric timebased' has only digits and has resolotuin of 10min in one week. Type 'Numeric' (except for numeric time based): Caution: sequence number is stored to flash; flash has a limited number of writes before it becomes defect.">
<option value="-2">Time based, numeric encoding</option>
<option value="-1">Time based, alphanumeric encoding</option>
<option value="0">Numeric</option>
<option value="1">MIC</option>
</select>
</div>
<div>
<label for="tnc_tel_path">Self Telemetry Relay Path</label>
<input class="u-full-width" type="text" minlength="0" name="tnc_tel_path" id="tnc_tel_path" title="APRS path for self telemetry, use the shortest as possible (émpty path is recommended; for aprs-is connection, no path is necessary). Or use WIDE2-1. ">
<input class="u-full-width" type="text" minlength="0" name="tnc_tel_path" id="tnc_tel_path" title="APRS path for self telemetry, use the shortest as possible (émpty path is recommended; for aprs-is connection, no path is necessary). Or use WIDE2-1.">
</div>
</div>
<div class="grid-container full">
@ -770,23 +771,23 @@
data/wifi.cfg<br>
<ul>
<li>wifi.cfg can to be created manually, following the json structure in the example. The names of the variables (aka keys) must not be altered</li>
<li>The preferred way is to upgrade the firmware to the newest version, make sure, that the wifi credentials are set correctly and then press the SAVEWIFI2FS Button</li>
<li>The preferred way is to upgrade the firmware to the newest version, make sure, that the wifi credentials are set correctly and then kilck the SAVEWIFI2FS Button.</li>
<li>The content, what will be saved, can be viewed above.</li>
<li>wifi.cfg in the directory data contains SSID and password of up to 10 AP and a password for the local accesspoint</li>
<li>The password must not be shorter that 8 byte. The json structure must not be changed</li>
<li>if something is wrong or the file is missing, the complete file will be ignored. If credentials are available in flash memory, they will be used.</li>
<li>if something is wrong or the file is missing, the complete file will be ignored. If credentials are available in flash, they will be used.</li>
<li>An alternative to upload wifi.cfg to your board is via Upload File System image in PlatformIO!</li>
<li>To find the 'Upload File System image' click the PlatformIO symbol (the little alien) on the left side, choose your configuration, click on 'Platform' and search for 'Upload File System image'. If you use platformio-cli, upload the filesystem as described below.</li>
</ul>
which WiFi is selected?<br/>
<ul>
<li>An AP entry containing the keyword "prio":1 defines the entry which is taken as first to connect before following the configured order</li>
<li>if there is nothing prioritized, then the configured order is followed. If credentials are available in flash memory, they will be used first.</li>
<li>if there is nothing prioritized, then the configured order is followed. If credentials are available in flash, they will be used first.</li>
<li>if no connection to a configured AP could be established, a local accesspoint with the SSID "call AP" will be created. After connected to, this Webserver will be reachable with the IP Address 192.168.4.1. The password for the selfAP can be preconfigured with the key "ap_password" in this file</li>
</ul>
data/preferences.cfg<br>
<ul>
<li>preferences.cfg can be created by the system, if you press "SAVE2FS" in the Update section of the site.
<li>preferences.cfg can be created by the system, if you kilck to "SAVE2FS" in the Update section of the site.
<li>if you want to changes items of the preferences, you have to start with the data shown in the configuration view of this WebSite. Be sure to deleted everything before the "{". Again the keys must not be altered. The file then has to be placed into the data directory on your system using the name preferences.cfg.
</ul>
which config is selected?<br/>

Wyświetl plik

@ -203,8 +203,9 @@ boolean always_send_cseSpd_AND_altitude = false;
#ifdef TNC_SELF_TELEMETRY_MIC
int tel_mic = 1; // telemetry as "T#MIC"
#else
//int tel_mic = 0; // telemetry as "T#001"
int tel_mic = -1; // telemetry as "T#AbC"
//int tel_mic = 0; // telemetry as "T#001" // numeric 0-9. Needs to remember sequence
//int tel_mic = -1; // telemetry as "T#AbC" // time based alphanumeric 0-9,A-Z,a-z. cool, but aprs.fi complains. Resolution 23s in two months.
int tel_mic = -2; // telemetry as "T#001" // time based numeric 0-9. Resolution 10min in one week.
#endif
#if defined(ENABLE_BLUETOOTH) && defined(KISS_PROTOCOL)
boolean enable_bluetooth = true;
@ -1240,9 +1241,9 @@ void send_telemetry_to_TNC_usb_serial_and_aprsis(const String &telemetryPacket)
Serial.println(telemetryPacket);
#if defined(ENABLE_WIFI)
send_to_aprsis(telemetryPacket);
// another hack: send_to_aprsis has no queue. Webserver-code needs enough time to send. Are 1500ms enough?
// another hack: send_to_aprsis has no queue. Webserver-code needs enough time to send. Are 500ms enough?
esp_task_wdt_reset();
delay(1500);
delay(500);
esp_task_wdt_reset();
#endif
}
@ -1288,6 +1289,15 @@ void sendTelemetryFrame() {
switch (n) {
case 0:
// Equations are defined only for the 5 analog channels. May be less then 5.
// Most important for correct interpretation -> position 0.
s = String("EQNS.");
s = s + "0,5.1,3000";
#ifdef T_BEAM_V1_0
s = s + ",0,10,0" + ",0,10,0" + ",0,28,3000" + ",0,10,0";
#endif
break;
case 1:
// up to 5 analog and 8 digital channels. If not needed, could break at any item.
// if you use 4 analog and 2 digital channel, set names to "A,B,C,D,,X,Y"
s = String("PARM.");
@ -1298,7 +1308,7 @@ void sendTelemetryFrame() {
//if (m == 4) s = s + ",,,," + "yourDigitalParamNames1,2,3,4,5,6,7,8";
#endif
break;
case 1:
case 2:
// up to 5 analog and 8 digital channels. If not needed, could break at any item.
// if you use 4 analog and 2 digital channel, set names to "A,B,C,D,,X,Y"
s = String("UNIT.");
@ -1309,14 +1319,6 @@ void sendTelemetryFrame() {
//if (m == 4) s = s + ",,,," + "yourDigitalUnitsNames1,2,3,4,5,6,7,8";
#endif
break;
case 2:
// Equations are defined only for the 5 analog channels. May be less then 5
s = String("EQNS.");
s = s + "0,5.1,3000";
#ifdef T_BEAM_V1_0
s = s + ",0,10,0" + ",0,10,0" + ",0,28,3000" + ",0,10,0";
#endif
break;
case 3:
//Example for the up to 8 digital BITS channel (currently not used)
//Make sure that when using this, it starts after the 5 analog measurement fields;
@ -1340,13 +1342,15 @@ void sendTelemetryFrame() {
// sequence number for measurement packet
#ifndef ENABLE_PREFERENCES
// no preferences enabled -> use variant -1.
if (tel_mic == 0) tel_mic = -1;
if (tel_mic == 0) tel_mic = -2;
#endif
// Determine if MIC, digit sequence number or alphanumeric sequence number
if (tel_mic == 1) {
tel_sequence_str = "MIC";
} else if (tel_mic == -1) {
// Unfortunately, aprs.fi comments this with "[Invalid telemetry packet]".
// -> See also the less efficient approach tel_mic == -2
// a much better approach, without storing sequence number back to flash.
// On most trackers, the system time is set correct, either due to GPS time, or by NTP.
// Telemetry sequence can be any number or letter. It has a size of 3 characters.
@ -1370,6 +1374,30 @@ void sendTelemetryFrame() {
// fall back to MIC format
tel_sequence_str = String("MIC");
}
} else if (tel_mic == -2) {
// This variant has a resolution of 10min and overflows in a week; in contrast to
// tel_mic -1 variant (digit+charachter based), which has a resolution of 23 seconds
// and overflows in two months.
// assumption: we send telemetry at min every 10min (enforced by web interface)
// We could encode week day in pos 0 (-> 0-6). Pos 1+2 are time dependend
// values. 6*24*6+22*6+3 = 999 packets, last sent at saturday 22:30. We need room
// for 8 packets. Let's send them as 000 up to 006, and the last (from sat, 23:50) to 999, and see what happens ;)
// Because amateur radio projects like balloons often use the weekend, it's better
// to have the overflow in mid of the week instead of saturday evening. We start our
// week at thursday instead of sunday -> (tm_wday += 4).
struct tm timeinfo{};
if (getLocalTime(&timeinfo)) {
char buf[4];
// resolution 6 packets in an hour.
int t = (24*60+((timeinfo.tm_wday + 4) % 7) + timeinfo.tm_hour *60 + timeinfo.tm_min) / 10.0;
if (t >= 1007)
t = 999;
sprintf_P(buf, "%03u", t % 1000);
tel_sequence_str = String(buf);
} else {
// fall back to MIC format
tel_sequence_str = String("MIC");
}
} else {
// Get the current saved telemetry sequence
#ifdef ENABLE_PREFERENCES
@ -3547,8 +3575,8 @@ void handle_usb_serial_input(void) {
// some commands need an non-binary agument
#ifdef ENABLE_PREFERENCES
if (cmd == "save_preferences_cfg") {
refill_preferences_as_jsonData();
Serial.println("*** save_preferences_cfg:");
refill_preferences_as_jsonData();
if (!preferences_as_jsonData.isEmpty()) {
int ret = save_to_file("TNC", "/preferences.cfg", preferences_as_jsonData);
if (ret >= 0)
@ -3592,8 +3620,8 @@ void handle_usb_serial_input(void) {
inputBuf = "";
return;
} else if (cmd == "save_wifi_cfg") {
fill_wifi_config_as_jsonData();
Serial.println("*** save_preferences_cfg:");
fill_wifi_config_as_jsonData();
if (!wifi_config_as_jsonData.isEmpty()) {
int ret = save_to_file("TNC", "/wifi.cfg", wifi_config_as_jsonData);
if (ret >= 0)
@ -3653,9 +3681,9 @@ void handle_usb_serial_input(void) {
Serial.println(" logging <on|off>");
#ifdef ENABLE_PREFERENCES
Serial.println(" preferences (needs to bei implemented)");
Serial.println(" show_preferences (shows preferences from flash)");
Serial.println(" show_preferences (shows preferences as json from flash)");
Serial.println(" save_preferences_cfg (saves running config to /preferences.cfg in filesystem)");
Serial.println(" show_wifi (shows wifi from flash)");
Serial.println(" show_wifi (shows wifi settings as json from ram)");
Serial.println(" save_wifi_cfg (saves running wifi config to /wifi.cfg in filesystem)");
Serial.println(" dir (lists SPIFFS directory)");
#endif

Wyświetl plik

@ -1937,6 +1937,34 @@ void send_to_aprsis()
// connect to aprsis
if (!connect_to_aprsis()) {
log_msg = String("APRS-IS: on_Err: '") + aprsis_status + String("' [") + aprsis_client.remoteIP().toString() + String("], tries ") + String(aprsis_connect_tries);
// sometimes after boot, connection does not work:
// APRS-IS: connecting to 'aprs.hc.r1.ampr.org', tries 1
// [ 10068][E][WiFiClient.cpp:268] connect(): socket error on fd 50, errno: 104, "Connection reset by peer"
// APRS-IS: on_Err: 'Error: connect failed' [0.0.255.0], tries 1
// connection retry intervall is every 10s. -> In 5min, tries == 30.
// -> Q&D fix: Restart WIFI.
if (aprsis_connect_tries % 30) {
//log_msg = log_msg + ". Restarted WIFI!";
//restart_AP_or_STA();
// ^does not help
// first thing we now try: trigger watchdog for taskWebserver thread.
// we had configured watchdog timeout to 120s.
String m = log_msg + ". connect bug? - Restarting webserver the soft way, by watchdog timer expiry";
#if defined(ENABLE_SYSLOG)
syslog_log(LOG_CRIT, m);
#endif
do_serial_println(m);
delay(3*60*1000);
// wdt reseted? Then we'll not have survied to be not here. -> next try: reboot
m = "Did not help. Now the hard way: reboot";
#if defined(ENABLE_SYSLOG)
syslog_log(LOG_CRIT, m);
#endif
do_serial_println(m);
delay(2000);
ESP.restart();
}
#if defined(ENABLE_SYSLOG)
syslog_log(LOG_INFO, log_msg);
#endif