V1.10.5 - fully handle all documented return codes from Sondehub uploads

master
Dave Akerman 2023-10-10 16:17:32 +01:00
rodzic 1175b8183d
commit 89581085ab
4 zmienionych plików z 22 dodań i 6 usunięć

Wyświetl plik

@ -296,6 +296,9 @@ Many thanks to David Brooke for coding this feature and the AFC.
Change History
==============
## 08/10/2023 - V1.10.5
Fully handle all documented Sondehub responses - see https://github.com/projecthorus/sondehub-infra/wiki/API-(Beta)#notes-on-api-response-codes
## 14/9/2023 - V1.10.4
Clear InUse flag in SH upload so new telemetry is only uploaded once

Wyświetl plik

@ -45,7 +45,7 @@
#include "udpclient.h"
#include "lifo_buffer.h"
#define VERSION "V1.10.4"
#define VERSION "V1.10.5"
bool run = TRUE;
// RFM98

Wyświetl plik

@ -116,9 +116,7 @@ struct TConfig
double latitude, longitude, altitude; // Receiver's location
int EnableSSDV;
int EnableHablink;
int EnableSondehub;
char HablinkAddress[32];
int EnableTelemetryLogging;
int EnablePacketLogging;
int CallingTimeout;

Wyświetl plik

@ -106,22 +106,37 @@ int UploadJSONToServer(char *url, char *json)
res = curl_easy_perform( curl );
// Check for errors
if ( res == CURLE_OK )
if (res == CURLE_OK)
{
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp);
if (http_resp == 200)
{
// Data submitted OK
result = true;
}
else if (http_resp == 400)
else if ((http_resp >= 201) && (http_resp <= 209))
{
LogMessage("400 response to %s\n", json);
//Data submitted, but with some issues. Refer to response for details.
LogMessage("20x response to %s\n", json);
LogError(http_resp, "JSON: ", json);
LogError(http_resp, "RESP: ", curl_error);
result = true; // Don't retry - this partially failed due to the uploaded JSON containing something that the server complained about
}
else if ((http_resp >= 400) && (http_resp <= 409))
{
LogMessage("%d response to %s\n", http_resp, json);
LogError(http_resp, "JSON: ", json);
LogError(http_resp, "RESP: ", curl_error);
result = true; // Don't retry - this failed due to the uploaded JSON containing something that the server rejected
}
else if ((http_resp >= 500) && (http_resp <= 509))
{
// Server busy, retry
result = false;
}
else
{
// Undocumented response; log but don't retry
LogMessage("Unexpected HTTP response %ld for URL '%s'\n", http_resp, url);
LogError(http_resp, "JSON: ", json);
LogError(http_resp, "RESP: ", curl_error);