V1.10.1: Sondehub upload: For errors, log return code, return text and uploaded JSON to errors.txt

master
Dave Akerman 2023-08-22 14:10:03 +01:00
rodzic 76638b8c2b
commit 9fc3719bbb
4 zmienionych plików z 21 dodań i 7 usunięć

Wyświetl plik

@ -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 **
**<u>ALL HABHUB SUPPORT HAS BEEN REMOVED since that server has been decommissioned</u>**
<u>**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.**</u>
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

Wyświetl plik

@ -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 );
}

Wyświetl plik

@ -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,
... );

Wyświetl plik

@ -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;
}