From a574ce7edf7f31847be882f9f08dcd1ab8e5ebe0 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Tue, 18 Nov 2025 16:00:47 +0800
Subject: [PATCH] update lightd and thingsboard

---
 project/thingsboard/config.h |   73 +++++++++++++++++++++---------------
 1 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/project/thingsboard/config.h b/project/thingsboard/config.h
index 8cf4e2e..7f9a43c 100644
--- a/project/thingsboard/config.h
+++ b/project/thingsboard/config.h
@@ -3,7 +3,7 @@
  *                  All rights reserved.
  *
  *       Filename:  config.h
- *    Description:  This file is mqttd configure file parser function
+ *    Description:  This file is thingsboard configure file parser function
  *
  *        Version:  1.0.0(2019年06月25日)
  *         Author:  Guo Wenxue <guowenxue@gmail.com>
@@ -12,6 +12,8 @@
  ********************************************************************************/
 #ifndef  __CONF_H_
 #define  __CONF_H_
+
+#include "utils.h"
 
 enum
 {
@@ -24,49 +26,58 @@
 #define DEF_PUBINTERVAL     120
 #define DEF_QOS             Qos2
 
-typedef struct hwconf_s
+typedef struct hwinfo_s
 {
-    int            relay;   /* relay aviable or not.   0:Disable  1: Enable */
-    int            led;     /* RGB led aviable or not. 0:Disable  1: Enable */
-    int            beeper;  /* beeper aviable or not.  0:Disable  1: Enable */
-    int            ds18b20; /* DS1B820 aviable or not. 0:Disable  1: Enable */
-    int            sht2x;   /* SHT20  aviable or not.  0:Disable  1: Enable */
-    int            tsl2561; /* TSL2561 aviable or not.  0:Disable  1: Enable */
-} hwconf_t;
+    int             relay;   /* relay aviable or not.   0:Disable  1: Enable */
+    int             led;     /* RGB led aviable or not. 0:Disable  1: Enable */
+    int             beeper;  /* beeper aviable or not.  0:Disable  1: Enable */
+    int             ds18b20; /* DS1B820 aviable or not. 0:Disable  1: Enable */
+    int             sht2x;   /* SHT20  aviable or not.  0:Disable  1: Enable */
+    int             tsl2561; /* TSL2561 aviable or not. 0:Disable  1: Enable */
+} hwinfo_t;
 
+/* logger settings */
+typedef struct logger_s
+{
+    char            logfile[128]; /* logger record file */
+    int             loglevel;     /* logger level  */
+    int             logsize;      /* logger file maxsize, oversize will rollback */
+} logger_t;
 
 typedef struct mqtt_ctx_s
 {
-    char          devid[32];    /*  device ID */
-
-    /* hardware configuration */
-    hwconf_t      hwconf;
-
-    /* logger settings */
-    char          logfile[128]; /* logger record file */
-    int           loglevel;     /* logger level  */
-    int           logsize;      /* logger file maxsize, oversize will rollback */
+    char			devid[32];    /*  device ID */
+    void           *userdata;      /* user data pointer */
 
     /* Broker settings  */
-    char          host[128];  /* MQTT broker server name  */
-    int           port;       /* MQTT broker listen port  */
-    char          uid[64];    /* username */
-    char          pwd[64];    /* password */
-    char          token[64];  /* token */
-    int           keepalive;  /* MQTT broker send PING message to subsciber/publisher keepalive timeout<seconds> */
+    char            host[128];  /* MQTT broker server name  */
+    int             port;       /* MQTT broker listen port  */
+    char            uid[64];    /* username */
+    char            pwd[64];    /* password */
+    char            token[64];  /* token */
+    int             keepalive;  /* MQTT broker send PING message to subsciber/publisher keepalive timeout<seconds> */
 
     /* Publisher settings */
-    char          pubTopic[256]; /* Publisher topic  */
-    int           pubQos;        /* Publisher Qos */
-    int           interval ;     /* Publish sensor data interval time, unit seconds */
+    char            pubTopic[256]; /* Publisher topic  */
+    int             pubQos;        /* Publisher Qos */
+    int             interval ;     /* Publish sensor data interval time, unit seconds */
 
     /* Subscriber settings */
-    char          subTopic[256]; /* Subscriber topic */
-    int           subQos;        /* Subscriber Qos  */
+    char            subTopic[256]; /* Subscriber topic */
+    int             subQos;        /* Subscriber Qos  */
 } mqtt_ctx_t;
 
+typedef struct iotd_ctx_s
+{
+    logger_t        logger;
+    hwinfo_t        hwinfo;
+    mqtt_ctx_t      mqtt;
+} iotd_ctx_t;
 
-extern int mqttd_parser_conf(const char *conf_file, mqtt_ctx_t *ctx, int debug);
+/* get iotd_ctx address by mqtt_ctx address */
+#define to_iotd(ctx)	container_of(ctx, iotd_ctx_t, mqtt);
 
-#endif   /* ----- #ifndef _CONF_H_  ----- */
+extern int parser_conf(const char *conf_file, iotd_ctx_t *ctx, int debug);
+
+#endif
 

--
Gitblit v1.9.1