bug fixes, features, much work on telemetry

- bugfixes
   - on reset and read from preferences.cfg file, configured lat/lon
    have been ignored.
   - fix for compressed position with ambiguity > 0

- right after boot, do not wait for a precise position.
  this avoids a jump to the configured fixed position,
  which may be very far away.
  The code will become even nicer in a next release (I'm
  currently testing with hdop.hdop(), which will have changes
  of the decision-making of storing a current location); so
  the use of no_gps_position_since_boot will become nice.

- display:
  - show P= instead of Batt= if powered from USB
  - "Up " instead of " Up " for uptime if no system time is available
  - display " LoRa-TX: dis" instead of " never TX"
  - display " GPS: no fix " instead of " no GPS fix"
      Why?: "WiFi-Cli no GPS fix" is irritating (no WiFi-Client but GPS fix?
      No, it was WiFo mode Client, and GPS without fix).
  - show P: instead tof Batt: on boot
  - show axp temperature on TTGO

- InpVolts vs BattVolts:
  Hardware without AXP chip (all except T-BEAM TTGO) have no idea of
  battery voltage. -> Changed Display and Telemetry vor this:
  InpVolts instead of VattVolts.

- system time from GPS:
  - Added check if function calls are successful
  - changed nasty code with type errors and misleading variable names
  - etc..

- manual beacon (button pressed): added next_fixed_beacon = ...

- Telemetry
  - removed dependency of define KISS_PROTOCOL
  - the AXP chip of the T-BEAM could measure temperature! Cewl..
    But we already have all 5 telemetry-positions in use.
    -> If we have no battery on boot, we have 3 fields free (Batt V,
    Current in ant out). If we have no usb on battery-boot connected,
    we have one field free for the temperature. Temperature is measured
    in steps of 0.25 degrees C.
  - The new temperature field as well as the "InputVolts vs BatteryVolts
    values" for the different devices needet a re-mix of the positions
    in the telemetry frame.
    I also decided "AC V" and "AC C" to "P V" and "P C". Trackers are
    powered on DC, not AC ;)
    For various reasons, we add temperature to the 5'th field.
    "B Out" was irritating: what, Volt, Current, Light? It's now BCout.
  - Changed equations for Volt. The problem with the old method was,
    that if you have 0 V (i.E. no battery attached), it was interpreted
    by the += 3000 level -> 3V.
    Unfortunately, the APRS spec does not define an encoding if i.E.
    a sensor is not available. ",," would be nice. But the field is
    defined exactly as ",nmo," with n, m and o as digit.
  - We had two cases for
      // DO NOT ENABLE THIS UNTIL YOU READ AND UNDERSTOOD THE IMPACT DESCRIBED ABOVE
    and people have overseen the second case. Changed the concept (one
    boolean variable).
  - Searched more than week why often EQNS are sent (while PARM, etc..
    was expected). Our local state variable (type static) sometimes,
    but not always, was set to 0 on re-entering the function block.
    -> either a compiler problem, or might be a buffer overflow corrupts
    the stack?
    After I fixed this, the same happeneed with the new local static
    variable static const boolan may_add_temperature = ...,
    which changed it's assigned value  during runtime.

- taskWebserver: made status messages more consistent.

- watchdog patches from hb9xar

Signed-off-by: Thomas Osterried <dl9sau@darc.de>
pull/10/head
Thomas Osterried 2023-03-27 18:28:25 +02:00
rodzic c8d7a6c71f
commit 883c9f84cb
5 zmienionych plików z 42 dodań i 21 usunięć

Wyświetl plik

@ -618,7 +618,7 @@ See also the option beneath about showing maidenhead grid locator.">
<option value="1">B1: Lat/Lon in classic notation</option>
<option value="2">B2: Lat/Lon in nautical notation</option>
<option value="3">C1: Lat/Lon in classic notation, left side</option>
<option value="4">C1: Lat/Lon in nautical notation, left side</option>
<option value="4">C2: Lat/Lon in nautical notation, left side</option>
</select>
</div>
<div>

Wyświetl plik

@ -1038,7 +1038,7 @@ void writedisplaytext(String HeaderTxt, String Line1, String Line2, String Line3
if (InpVolts < 1.0) {
if (BattVolts < 3.5 && BattVolts > 3.3){
#ifdef T_BEAM_V1_0
# ifdef ENABLE_LED_SIGNALING
#ifdef ENABLE_LED_SIGNALING
axp.setChgLEDMode(AXP20X_LED_BLINK_4HZ);
#endif
#endif
@ -1392,8 +1392,17 @@ void fillDisplayLines3to5(int force) {
if (oled_line3and4_format == 0) {
if (show_locator) {
OledLine3 = aprsLatLonAsMaidenheadGridLocator + " " + aprsPresetShown /* + " " + foobar */;
// ^ free for future use, i.e. temp, pressure, humidity
OledLine3 = aprsLatLonAsMaidenheadGridLocator + " " + aprsPresetShown;
#ifdef T_BEAM_V1_0
// field for extended use, i.e. temp, pressure, humidity
if (aprsLatLonAsMaidenheadGridLocator.length() + 1 + 1 + + 12 <= 21) {
char sensor_data[13] = { 0 } ; // room for 12 + \0 == 13
float t_AXP = axp.getTemp();
if (t_AXP < -9.9) t_AXP = -9.9; else if (t_AXP > 99.9) t_AXP = 99.9;
sprintf(sensor_data, " tAXP:%.1f%cC", t_AXP, '\xF7');
OledLine3 = OledLine3 + String(sensor_data);
}
#endif
} else {
OledLine3 = aprsLatPreset + " " + aprsLonPreset + " " + aprsPresetShown;
}
@ -1454,18 +1463,23 @@ void fillDisplayLines3to5(int force) {
// end of hack
if (show_locator) {
// field for extended use, i.e. temp, pressure, humidity
char sensor_data[12] = { 0 } ; // room for 11 + \0 == 12
#ifdef T_BEAM_V1_0
float t_AXP = axp.getTemp();
if (t_AXP < -9.9) t_AXP = -9.9; else if (t_AXP > 99.9) t_AXP = 99.9;
sprintf(sensor_data, "tAXP:%.1f%cC", t_AXP, '\xF7');
#endif
// show maidenhead grid locator
if (oled_line3and4_format < 3) {
sprintf(buf, "%4.4s%6.6s %-10.10s", str_course(0), str_altitude(), aprsLatLonAsMaidenheadGridLocator.c_str());
OledLine3 = String(buf);
sprintf(buf, "%7.7s %.1s %-11.11s", spd, aprsPresetShown.c_str(), "");
// ^ free for future use, i.e. temp, pressure, humidity
sprintf(buf, "%7.7s %.1s %-11.11s", spd, aprsPresetShown.c_str(), sensor_data);
OledLine4 = String(buf);
} else {
sprintf(buf, "%11.11s %.1s %7.7s", aprsLatLonAsMaidenheadGridLocator.c_str(), aprsPresetShown.c_str(), spd);
OledLine3 = String(buf);
sprintf(buf, "%11.11s %4.4s%5.5s", "", str_course(0), str_altitude());
// ^ free for future use, i.e. temp, pressure, humidity
sprintf(buf, "%11.11s %4.4s%5.5s", sensor_data, str_course(0), str_altitude());
OledLine4 = String(buf);
}
} else {
@ -3270,6 +3284,9 @@ void setup()
// for diagnostics
uint32_t t_setup_entered = millis();
// initialize ESP32 Process WDT, 120s T/O
esp_task_wdt_init(120, true);
// Our BUILD_NUMBER. The define is not available in the WEBSERVR -> we need to assign a global variable
buildnr = BUILD_NUMBER;
@ -3554,11 +3571,11 @@ void setup()
#endif /* ENABLE_WIFI */
esp_task_wdt_init(120, true); //enable panic so ESP32 restarts
esp_task_wdt_add(NULL); //add current thread to WDT watch
setup_oled_timer_values();
esp_task_wdt_add(NULL); //add current thread to WDT watch
esp_task_wdt_reset();
writedisplaytext("LoRa-APRS","","Init:","FINISHED OK!"," =:-) ","");
fillDisplayLine1();
fillDisplayLine2();

Wyświetl plik

@ -45,7 +45,7 @@ bool gpsInitialized = false;
}
esp_task_wdt_init(120, true); //enable panic so ESP32 restarts
// esp_task_wdt_init() has already been done in main task during setup()
esp_task_wdt_add(NULL); //add current thread to WDT watch
String gpsDataBuffer = " ";

Wyświetl plik

@ -79,7 +79,7 @@ void handleKISSData(char character, int bufferIndex) {
tncReceivedQueue = xQueueCreate(4,sizeof(String *));
String *loraReceivedFrameString = nullptr;
esp_task_wdt_init(120, true); //enable panic so ESP32 restarts
// esp_task_wdt_init() has already been done in main task during setup()
esp_task_wdt_add(NULL); //add current thread to WDT watch
while (true) {

Wyświetl plik

@ -495,7 +495,7 @@ void refill_preferences_as_jsonData()
} else {
s_tmp = aprsLatPresetNiceNotation + " " + aprsLonPresetNiceNotation + " [" + (aprsPresetShown == "" ? "GPS" : aprsPresetShown) + "]";
}
s = s + jsonLineFromString("curPos", s_tmp.c_str());
s = s + "\n " + jsonLineFromString("curPos", s_tmp.c_str());
s = s + "\n " + jsonLineFromInt("UptimeMinutes", millis()/1000/60);
s = s + "\n " + jsonLineFromString("OledLine1", OledLine1.c_str());
s = s + "\n " + jsonLineFromString("OledLine2", OledLine2.c_str());
@ -1467,12 +1467,14 @@ void do_send_status_message_about_connect_to_aprsis(void) {
outString.replace(":>", ",RFONLY:>");
if (lora_tx_enabled && tx_own_beacon_from_this_device_or_fromKiss__to_frequencies) {
esp_task_wdt_reset();
if (tx_own_beacon_from_this_device_or_fromKiss__to_frequencies % 2)
if (tx_own_beacon_from_this_device_or_fromKiss__to_frequencies % 2) {
esp_task_wdt_reset();
loraSend(txPower, lora_freq, lora_speed, 0, outString); //send the packet, data is in TXbuff from lora_TXStart to lora_TXEnd
esp_task_wdt_reset();
if (tx_own_beacon_from_this_device_or_fromKiss__to_frequencies > 1 && lora_digipeating_mode > 1 && lora_freq_cross_digi > 1.0 && lora_freq_cross_digi != lora_freq)
}
if (tx_own_beacon_from_this_device_or_fromKiss__to_frequencies > 1 && lora_digipeating_mode > 1 && lora_freq_cross_digi > 1.0 && lora_freq_cross_digi != lora_freq) {
esp_task_wdt_reset();
loraSend(txPower_cross_digi, lora_freq_cross_digi, lora_speed_cross_digi, 0, outString); //send the packet, data is in TXbuff from lora_TXStart to lora_TXEnd
}
}
esp_task_wdt_reset();
@ -1503,7 +1505,7 @@ int connect_to_aprsis(void) {
aprsis_status = "Connected. Waiting for greeting.";
uint32_t t_start = millis();
while (!aprsis_client.available() && (millis()-t_start) < 25000L) { delay(100); esp_task_wdt_reset(); }
while (!aprsis_client.available() && (millis()-t_start) < 25000L) { vTaskDelay(100 / portTICK_PERIOD_MS); esp_task_wdt_reset(); }
if (aprsis_client.available()) {
// check
String s = aprsis_client.readStringUntil('\n');
@ -1525,7 +1527,7 @@ int connect_to_aprsis(void) {
aprsis_client.print(String(buffer) + "\r\n");
t_start = millis();
while (!aprsis_client.available() && (millis()-t_start) < 25000L) { delay(100); esp_task_wdt_reset(); }
while (!aprsis_client.available() && (millis()-t_start) < 25000L) { vTaskDelay(100 / portTICK_PERIOD_MS); esp_task_wdt_reset(); }
if (aprsis_client.available()) {
// check
String s = aprsis_client.readStringUntil('\n');
@ -1801,6 +1803,7 @@ void read_from_aprsis(void) {
loraSend(txPower, lora_freq, lora_speed, 0, third_party_packet);
}
if (aprsis_data_allow_inet_to_rf > 1 && lora_freq_cross_digi > 1.0 && lora_freq_cross_digi != lora_freq) {
esp_task_wdt_reset();
loraSend(txPower_cross_digi, lora_freq_cross_digi, lora_speed_cross_digi, 0, third_party_packet);
esp_task_wdt_reset();
}
@ -1925,7 +1928,7 @@ void send_to_aprsis()
server.onNotFound(handle_NotFound);
esp_task_wdt_init(120, true); //enable panic so ESP32 restarts
// esp_task_wdt_init() has already been done in main task during setup()
esp_task_wdt_add(NULL); //add current thread to WDT watch
// 8 characters is requirements for WPA2
@ -2005,6 +2008,7 @@ void send_to_aprsis()
uint32_t webserver_started = millis();
// main loop
while (true) {
esp_task_wdt_reset();