Porównaj commity

...

2 Commity

5 zmienionych plików z 31 dodań i 15 usunięć

Wyświetl plik

@ -296,6 +296,12 @@ Many thanks to David Brooke for coding this feature and the AFC.
Change History
==============
## 08/10/2023 - V1.10.6
Use callsign for MQTT client ID
## 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.6"
bool run = TRUE;
// RFM98
@ -2142,7 +2142,6 @@ void LoadConfigFile(void)
RegisterConfigString(MainSection, -1, "MQTTPort", Config.MQTTPort, sizeof(Config.MQTTPort), NULL);
RegisterConfigString(MainSection, -1, "MQTTUser", Config.MQTTUser, sizeof(Config.MQTTUser), NULL);
RegisterConfigString(MainSection, -1, "MQTTPass", Config.MQTTPass, sizeof(Config.MQTTPass), NULL);
RegisterConfigString(MainSection, -1, "MQTTClient", Config.MQTTClient, sizeof(Config.MQTTClient), NULL);
RegisterConfigString(MainSection, -1, "MQTTTopic", Config.MQTTTopic, sizeof(Config.MQTTTopic), NULL);
@ -2753,7 +2752,7 @@ int main( int argc, char **argv )
strcpy(mqttConnection->user, Config.MQTTUser);
strcpy(mqttConnection->pass, Config.MQTTPass);
strcpy(mqttConnection->topic, Config.MQTTTopic);
strcpy(mqttConnection->clientId, Config.MQTTClient);
strcpy(mqttConnection->clientId, Config.Tracker);
if ( pthread_create (&MQTTThread, NULL, MQTTLoop, mqttConnection))
{

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;
@ -153,7 +151,6 @@ struct TConfig
char MQTTPort[8];
char MQTTUser[16];
char MQTTPass[32];
char MQTTClient[16];
char MQTTTopic[128];
};

11
mqtt.c
Wyświetl plik

@ -110,17 +110,16 @@ bool UploadMQTTPacket(mqtt_connect_t * mqttConnection, received_t * t )
BuildMQTTPath(topic, mqttConnection, t);
MQTTClient_create(&client, address, mqttConnection->clientId,
MQTTCLIENT_PERSISTENCE_NONE, NULL);
MQTTClient_create(&client, address, mqttConnection->clientId, MQTTCLIENT_PERSISTENCE_NONE, NULL);
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.username = mqttConnection->user;
conn_opts.password = mqttConnection->pass;
MQTTClient_setCallbacks(client, NULL, connlost, msgarrvd, delivered);
// LogMessage("Attempting publication on host: %s\n",
// address);
//"on topic %s for client with ClientID: %s\n",
//t->Message, address, topic, mqttConnection->clientId);
LogMessage("Attempting publication on host: %s\n", address);
LogMessage("on topic %s for client with ClientID: %s\n", topic, mqttConnection->clientId);
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
LogMessage("MQTT: Failed to connect, return code %d\n", rc);

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