From 9fc3719bbb6383b527002c1aa98a3794483ff6a9 Mon Sep 17 00:00:00 2001 From: Dave Akerman Date: Tue, 22 Aug 2023 14:10:03 +0100 Subject: [PATCH] V1.10.1: Sondehub upload: For errors, log return code, return text and uploaded JSON to errors.txt --- README.md | 12 +++++++++++- gateway.c | 6 +++--- gateway.h | 2 +- sondehub.c | 8 ++++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c66617b..50f485d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ Habitat LoRa Gateway Part of the LoRa Balloon Tracking System. Receives balloon telemetry and uploads to Sondehub and/or MQTT. -** ALL HABHUB SUPPORT HAS BEEN REMOVED since the server has been decommissioned ** +**ALL HABHUB SUPPORT HAS BEEN REMOVED since that server has been decommissioned** + +**If you are updating from an old version, please see the MQTT section below to install a library that you will need to build the latest version.** Runs on a Raspberry Pi with 1 or 2 RFM98HW modules attached to the SPI port. Also works with other compatible HopeRF and Semtec LoRa devices. @@ -294,6 +296,14 @@ Many thanks to David Brooke for coding this feature and the AFC. Change History ============== +## 13/8/2023 - V1.10.1 + + Sondehub upload: For errors, log return code, return text and uploaded JSON to errors.txt + +## 1/2023 - V1.10.0 + + Removed all HABHUB Support + ## 13/10/2022 - V1.9.6 Sondehub upload: Interpret battery voltage as V/mV automatiically diff --git a/gateway.c b/gateway.c index a582a54..a1b2824 100644 --- a/gateway.c +++ b/gateway.c @@ -45,7 +45,7 @@ #include "udpclient.h" #include "lifo_buffer.h" -#define VERSION "V1.10.0" +#define VERSION "V1.10.1" bool run = TRUE; // RFM98 @@ -355,7 +355,7 @@ void LogTelemetryPacket(int Channel, char *Telemetry) } } -void LogError(char *Message1, char *Message2) +void LogError(int ErrorCode, char *Message1, char *Message2) { // if (Config.EnableTelemetryLogging) { @@ -369,7 +369,7 @@ void LogError(char *Message1, char *Message2) now = time( 0 ); tm = localtime( &now ); - fprintf( fp, "%02d:%02d:%02d: %s %s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, Message1, Message2); + fprintf( fp, "%02d:%02d:%02d: Error %d: %s%s\n", tm->tm_hour, tm->tm_min, tm->tm_sec, ErrorCode, Message1, Message2); fclose( fp ); } diff --git a/gateway.h b/gateway.h index d1e8cf0..aea5c03 100644 --- a/gateway.h +++ b/gateway.h @@ -8,7 +8,7 @@ void hexdump_buffer( const char *title, const char *buffer, const int len_buffer ); void LogPacket( rx_metadata_t *Metadata, int Bytes, unsigned char MessageType ); void LogTelemetryPacket(int Channel, char *Telemetry); -void LogError(char *Message1, char *Message2); +void LogError(int ErrorCode, char *Message1, char *Message2); void LogMessage( const char *format, ... ); void ChannelPrintf( int Channel, int row, int column, const char *format, ... ); diff --git a/sondehub.c b/sondehub.c index 533dfe3..bf180f1 100755 --- a/sondehub.c +++ b/sondehub.c @@ -108,13 +108,13 @@ int UploadJSONToServer(char *url, char *json) else if (http_resp == 400) { LogMessage("400 response to %s\n", json); - LogError("400 response to:", json); result = true; } else { LogMessage("Unexpected HTTP response %ld for URL '%s'\n", http_resp, url); - LogError("400 response to:", json); + LogError(http_resp, "JSON: ", json); + LogError(http_resp, "RESP: ", curl_error); result = false; } } @@ -124,6 +124,10 @@ int UploadJSONToServer(char *url, char *json) LogMessage("Failed for URL '%s'\n", url); LogMessage("curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); LogMessage("error: %s\n", curl_error); + + LogError(res, "JSON: ", json); + LogError(res, "RESP: ", curl_error); + // Likely a network error, so return false to requeue result = false; }