kopia lustrzana https://github.com/PiInTheSky/lora-gateway
V1.10.5 - fully handle all documented return codes from Sondehub uploads
rodzic
1175b8183d
commit
89581085ab
|
@ -296,6 +296,9 @@ Many thanks to David Brooke for coding this feature and the AFC.
|
||||||
Change History
|
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
|
## 14/9/2023 - V1.10.4
|
||||||
Clear InUse flag in SH upload so new telemetry is only uploaded once
|
Clear InUse flag in SH upload so new telemetry is only uploaded once
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "udpclient.h"
|
#include "udpclient.h"
|
||||||
#include "lifo_buffer.h"
|
#include "lifo_buffer.h"
|
||||||
|
|
||||||
#define VERSION "V1.10.4"
|
#define VERSION "V1.10.5"
|
||||||
bool run = TRUE;
|
bool run = TRUE;
|
||||||
|
|
||||||
// RFM98
|
// RFM98
|
||||||
|
|
2
global.h
2
global.h
|
@ -116,9 +116,7 @@ struct TConfig
|
||||||
double latitude, longitude, altitude; // Receiver's location
|
double latitude, longitude, altitude; // Receiver's location
|
||||||
|
|
||||||
int EnableSSDV;
|
int EnableSSDV;
|
||||||
int EnableHablink;
|
|
||||||
int EnableSondehub;
|
int EnableSondehub;
|
||||||
char HablinkAddress[32];
|
|
||||||
int EnableTelemetryLogging;
|
int EnableTelemetryLogging;
|
||||||
int EnablePacketLogging;
|
int EnablePacketLogging;
|
||||||
int CallingTimeout;
|
int CallingTimeout;
|
||||||
|
|
21
sondehub.c
21
sondehub.c
|
@ -106,22 +106,37 @@ int UploadJSONToServer(char *url, char *json)
|
||||||
res = curl_easy_perform( curl );
|
res = curl_easy_perform( curl );
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if ( res == CURLE_OK )
|
if (res == CURLE_OK)
|
||||||
{
|
{
|
||||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp);
|
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_resp);
|
||||||
if (http_resp == 200)
|
if (http_resp == 200)
|
||||||
{
|
{
|
||||||
|
// Data submitted OK
|
||||||
result = true;
|
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, "JSON: ", json);
|
||||||
LogError(http_resp, "RESP: ", curl_error);
|
LogError(http_resp, "RESP: ", curl_error);
|
||||||
result = true; // Don't retry - this failed due to the uploaded JSON containing something that the server rejected
|
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
|
else
|
||||||
{
|
{
|
||||||
|
// Undocumented response; log but don't retry
|
||||||
LogMessage("Unexpected HTTP response %ld for URL '%s'\n", http_resp, url);
|
LogMessage("Unexpected HTTP response %ld for URL '%s'\n", http_resp, url);
|
||||||
LogError(http_resp, "JSON: ", json);
|
LogError(http_resp, "JSON: ", json);
|
||||||
LogError(http_resp, "RESP: ", curl_error);
|
LogError(http_resp, "RESP: ", curl_error);
|
||||||
|
|
Ładowanie…
Reference in New Issue