From 45e62dbd9e964c74b24f7fcadad9b418f117e008 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Thu, 27 Jun 2019 15:11:42 +0800
Subject: [PATCH] update mqttd, add hardware configured in configure files

---
 mqttd/etc/conf.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/mqttd/etc/conf.c b/mqttd/etc/conf.c
index a32683d..f998ce4 100644
--- a/mqttd/etc/conf.c
+++ b/mqttd/etc/conf.c
@@ -101,6 +101,53 @@
 
 
     /*+------------------------------------------------------+
+     *|      parser hardware module configuration ID         |
+     *+------------------------------------------------------+*/
+
+    /* hardware module enable or not */
+    ctx->hwconf.enable=iniparser_getint(ini, "hardware:enable", 0);
+    log_nrml("Parser hardware modules [%s]\n", ctx->hwconf.enable ? "enable" : "disable");
+
+    /* relay control light  */
+    ctx->hwconf.relay=iniparser_getint(ini, "hardware:relay_pin", 0);
+    if( !ctx->hwconf.relay )
+        log_nrml("Parser relay module disabled\n");
+    else
+        log_nrml("Parser relay connected wPI #pin nubmer [%d]\n", ctx->hwconf.relay); 
+
+    /* buzzer */
+    ctx->hwconf.beep=iniparser_getint(ini, "hardware:beep_pin", 0);
+
+    /* RGB 3-colors LED  */
+    ctx->hwconf.redled=iniparser_getint(ini, "hardware:red_pin", 0);
+    ctx->hwconf.greenled=iniparser_getint(ini, "hardware:green_pin", 0);
+    ctx->hwconf.blueled=iniparser_getint(ini, "hardware:blue_pin", 0);
+    if( !ctx->hwconf.redled && !ctx->hwconf.greenled && !ctx->hwconf.blueled )
+    {
+        ctx->hwconf.leds = 0;
+        log_nrml("Parser RGB leds module disabled\n");
+    }
+    else
+    {
+        ctx->hwconf.leds = 1;
+        log_nrml("Parser RGB led connected wPI #pin nubmer [%d,%d,%d]\n", 
+            ctx->hwconf.redled, ctx->hwconf.greenled, ctx->hwconf.blueled);
+    }
+
+    /* temperature sensor ds18b20  */
+    ctx->hwconf.ds18b20=iniparser_getint(ini, "hardware:ds18b20", 0);
+    log_nrml("Parser temperature sensor DS18B20 modules [%s]\n", ctx->hwconf.ds18b20 ? "enable" : "disable");
+
+    /* temperature and hummidity sensor sht2x  */
+    ctx->hwconf.sht2x=iniparser_getint(ini, "hardware:sht2x", 0);
+    log_nrml("Parser temperature and hummidity sensor sht2x modules [%s]\n", ctx->hwconf.sht2x ? "enable" : "disable");
+
+    /* light intensity sensor TSL2561 */
+    ctx->hwconf.lux=iniparser_getint(ini, "hardware:lux", 0);
+    log_nrml("Parser light intensity sensor TSL2561 modules [%s]\n", ctx->hwconf.ds18b20 ? "enable" : "disable");
+
+
+    /*+------------------------------------------------------+
      *|               parser production ID                   |
      *+------------------------------------------------------+*/
 

--
Gitblit v1.9.1