enhance logging

Signed-off-by: DL3EL <dl3el@darc.de>
pull/11/head
DL3EL 2022-09-16 16:58:56 +02:00
rodzic 2c2ebfb051
commit d892cf5206
1 zmienionych plików z 28 dodań i 0 usunięć

Wyświetl plik

@ -117,6 +117,11 @@ WiFiServer gpsServer(NETWORK_GPS_PORT);
Syslog syslog(udpClient, SYSLOG_PROTO_IETF);
#endif
// APRS-IS Reboot msg
String aprsis_time_last_successful_connect = "";
int aprsis_connect_tries = 0;
extern char gps_time_s[];
#ifdef T_BEAM_V1_0
#include <axp20x.h>
extern AXP20X_Class axp;
@ -1188,10 +1193,27 @@ void restart_AP_or_STA(void) {
if (WiFi.getMode() == WIFI_MODE_STA) {
if (WiFi.status() != WL_CONNECTED) { aprsis_status = "Error: no internet"; goto on_err; } else { if (aprsis_status == "Error: no internet") aprsis_status = "Internet available"; }
if (!aprs_is_client.connected() && t_connect_apprsis_again < millis()) {
#if defined(ENABLE_SYSLOG) && defined(ENABLE_WIFI) // unfortunately, on this plattform we only have IP if we have WIFI
syslog_log(LOG_INFO, String("Connecting to '") + aprsis_host.c_str() + "'");
Serial.printf("Host: %s Tries: %d\n", aprsis_host.c_str(), aprsis_connect_tries);
#endif
aprsis_status = "Connecting";
aprsis_connect_tries++;
aprs_is_client.connect(aprsis_host.c_str(), aprsis_port);
if (!aprs_is_client.connected()) { aprsis_status = "Error: connect failed"; goto on_err; }
aprsis_status = "Connected. Waiting for greeting.";
// send mesg to APRS-IS: rebooted (first connect to aprs-is
String outString = aprsis_callsign + ">" + MY_APRS_DEST_IDENTIFYER + ":>aprs-is-connect: " + String(gps_time_s);
if (aprsis_time_last_successful_connect.length() > 0) outString = outString + ", last " + aprsis_time_last_successful_connect;
outString = outString + ", tries " + String(aprsis_connect_tries);
aprsis_time_last_successful_connect = gps_time_s;
#if defined(ENABLE_SYSLOG) && defined(ENABLE_WIFI) // unfortunately, on this plattform we only have IP if we have WIFI
syslog_log(LOG_INFO, String("Reboot? '") + outString + String("'"));
Serial.printf("Tries: %d\n", aprsis_connect_tries);
#endif
aprsis_connect_tries = 0;
aprs_is_client.print(outString);
//
uint32_t t_start = millis();
while (!aprs_is_client.available() && (millis()-t_start) < 25000L) delay(100);
if (aprs_is_client.available()) {
@ -1212,6 +1234,9 @@ void restart_AP_or_STA(void) {
if (s.isEmpty() || !s.startsWith("#")) { aprsis_status = "Error: unexpected reponse on login"; goto on_err; }
if (s.indexOf(" logresp") == -1) { aprsis_status = "Error: Login denied: " + s; aprsis_status.trim(); goto on_err; }
if (s.indexOf(" verified") == -1) { aprsis_status = "Notice: server responsed not verified: " + s; aprsis_status.trim(); }
#if defined(ENABLE_SYSLOG) && defined(ENABLE_WIFI) // unfortunately, on this plattform we only have IP if we have WIFI
syslog_log(LOG_INFO, String("APRS-IS, connected to: '") + aprsis_host.c_str() + String("'"));
#endif
} else { aprsis_status = "Error: No response"; goto on_err; }
}
if (!aprs_is_client.connected())
@ -1315,6 +1340,9 @@ do_not_send:
if (err) {
on_err:
#if defined(ENABLE_SYSLOG) && defined(ENABLE_WIFI) // unfortunately, on this plattform we only have IP if we have WIFI
syslog_log(LOG_INFO, String("APRS-IS on_Err: '") + aprsis_status + String("'"));
#endif
aprs_is_client.stop();
if (!aprsis_status.startsWith("Error: "))
aprsis_status = "Disconnected";