From 4bb23da006f050c6014156c9aab675f37dda906a Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Sat, 15 Nov 2025 01:48:22 +0800
Subject: [PATCH] update thingsboard and test okay

---
 project/thingsboard/config.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/project/mosquitto/conf.c b/project/thingsboard/config.c
similarity index 93%
rename from project/mosquitto/conf.c
rename to project/thingsboard/config.c
index 4c0ee20..8471e81 100644
--- a/project/mosquitto/conf.c
+++ b/project/thingsboard/config.c
@@ -2,28 +2,27 @@
  *      Copyright:  (C) 2019 LingYun IoT System Studio
  *                  All rights reserved.
  *
- *       Filename:  conf.c
+ *       Filename:  config.c
  *    Description:  This file is mqttd configure file parser function
- *                 
+ *
  *        Version:  1.0.0(2019年06月25日)
  *         Author:  Guo Wenxue <guowenxue@gmail.com>
  *      ChangeLog:  1, Release initial version on "2019年06月25日 22时23分55秒"
- *                 
+ *
  ********************************************************************************/
-#include "conf.h"
+#include "config.h"
 #include "logger.h"
 #include "iniparser.h"
-
 
 int mqttd_parser_conf(const char *conf_file, mqtt_ctx_t *ctx, int debug)
 {
     dictionary          *ini;
     const char          *str;
-    int                  val; 
-    int                  rv = 0; 
+    int                  val;
+    int                  rv = 0;
 
     if( !conf_file || !ctx )
-    { 
+    {
         fprintf(stderr, "%s() Invalid input arguments\n", __func__);
         return -1;
     }
@@ -40,9 +39,9 @@
     /*+------------------------------------------------------+
      *|    parser logger settings and start logger system    |
      *+------------------------------------------------------+*/
-    if( !debug ) 
+    if( !debug )
     {
-        str = iniparser_getstring(ini, "logger:file", "/tmp/mqttd.log");
+        str = iniparser_getstring(ini, "logger:file", "/tmp/thingsboard.log");
         strncpy(ctx->logfile, str, sizeof(ctx->logfile));
         ctx->logsize = iniparser_getint(ini, "logger:size", 1024);
         ctx->loglevel = iniparser_getint(ini, "logger:level", LOG_LEVEL_INFO);
@@ -54,7 +53,7 @@
         ctx->logsize = 0;
     }
 
-    if( log_open(ctx->logfile, ctx->loglevel, ctx->logsize, LOG_LOCK_DISABLE) < 0 ) 
+    if( log_open(ctx->logfile, ctx->loglevel, ctx->logsize, LOG_LOCK_DISABLE) < 0 )
     {
         fprintf(stderr, "Logger system initialise failure\n");
         return -2;
@@ -136,7 +135,7 @@
     }
     strncpy(ctx->host, str, sizeof(ctx->host) );
 
-    if( (val=iniparser_getint(ini, "broker:port", -1)) < 0 ) 
+    if( (val=iniparser_getint(ini, "broker:port", -1)) < 0 )
     {
         log_error("ERROR: Parser MQTT broker server port failure\n");
         rv = -5;
@@ -145,6 +144,9 @@
     ctx->port = val;
     log_info("Parser MQTT broker server [%s:%d]\n", ctx->host, ctx->port);
 
+    str=iniparser_getstring(ini, "broker:token", NULL);
+    strncpy(ctx->token, str, sizeof(ctx->uid) );
+
     str=iniparser_getstring(ini, "broker:username", NULL);
     strncpy(ctx->uid, str, sizeof(ctx->uid) );
 

--
Gitblit v1.9.1