From c40159c25437a439e943c79f16b3e1932fa2e04d Mon Sep 17 00:00:00 2001 From: Dave Akerman Date: Wed, 11 Oct 2023 11:57:44 +0100 Subject: [PATCH] V1.10.6 - Use receiver callsign for MQTT client ID because that needs to be unique --- README.md | 3 +++ gateway.c | 5 ++--- global.h | 1 - mqtt.c | 11 +++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 55e6200..eb977e9 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,9 @@ 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 diff --git a/gateway.c b/gateway.c index 204fe3e..a0e6c6d 100644 --- a/gateway.c +++ b/gateway.c @@ -45,7 +45,7 @@ #include "udpclient.h" #include "lifo_buffer.h" -#define VERSION "V1.10.5" +#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)) { diff --git a/global.h b/global.h index 90a9a2d..3666fc3 100644 --- a/global.h +++ b/global.h @@ -151,7 +151,6 @@ struct TConfig char MQTTPort[8]; char MQTTUser[16]; char MQTTPass[32]; - char MQTTClient[16]; char MQTTTopic[128]; }; diff --git a/mqtt.c b/mqtt.c index a63d9a7..8e7aea9 100644 --- a/mqtt.c +++ b/mqtt.c @@ -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);