From 3ef6cf39749c00366b12aef9f023aac3bda16f2d Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 17 Nov 2025 23:39:25 +0800
Subject: [PATCH] update modules for tsl2561 and ds18b20

---
 project/lightd/config.h |   79 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/project/lightd/config.h b/project/lightd/config.h
new file mode 100644
index 0000000..85f47ff
--- /dev/null
+++ b/project/lightd/config.h
@@ -0,0 +1,79 @@
+/*********************************************************************************
+ *      Copyright:  (C) 2019 LingYun IoT System Studio
+ *                  All rights reserved.
+ *
+ *       Filename:  config.h
+ *    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秒"
+ *
+ ********************************************************************************/
+#ifndef  __CONF_H_
+#define  __CONF_H_
+
+#include "gpio.h"
+
+enum
+{
+    Qos0, /* 发送者只发送一次消息,不进行重试,Broker不会返回确认消息。在Qos0情况下,Broker可能没有接受到消息 */
+    Qos1, /* 发送者最少发送一次消息,确保消息到达Broker,Broker需要返回确认消息PUBACK。在Qos1情况下,Broker可能接受到重复消息 */
+    Qos2, /* Qos2使用两阶段确认来保证消息的不丢失和不重复。在Qos2情况下,Broker肯定会收到消息,且只收到一次  */
+};
+
+#define DEF_KEEPALIVE       30
+#define DEF_PUBINTERVAL     120
+#define DEF_QOS             Qos2
+
+typedef struct mqtt_ctx_s
+{
+    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            token[64];  /* token */
+    char            uid[64];    /* username */
+    char            pwd[64];    /* password */
+    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 */
+
+    /* Subscriber settings */
+    char            subTopic[256]; /* Subscriber topic */
+    int             subQos;        /* Subscriber Qos  */
+} mqtt_ctx_t;
+
+typedef struct logger_s
+{
+    /* logger settings */
+    char            logfile[128]; /* logger record file */
+    int             loglevel;     /* logger level  */
+    int             logsize;      /* logger file maxsize, oversize will rollback */
+} logger_t;
+
+typedef struct hwinfo_s
+{
+    gpio_t          gpio;         /* gpio information */
+    int             light_intval; /* light on interval */
+    float           lux_threshold;/* lux threshold value  */
+    int             ds18b20;      /* ds18b20 enable or not */
+    int             tsl2561;      /* tsl2561 enable or not */
+} hwinfo_t;
+
+typedef struct iotd_ctx_s
+{
+    logger_t        logger;
+    hwinfo_t        hwinfo;
+    mqtt_ctx_t      mqtt;
+} iotd_ctx_t;
+
+extern int parser_conf(const char *conf_file, iotd_ctx_t *ctx, int debug);
+
+#endif   /* ----- #ifndef _CONF_H_  ----- */
+

--
Gitblit v1.9.1