From e361b1654fefd1a563a82d335795f94b794b4873 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Tue, 20 Nov 2018 14:06:54 +0800
Subject: [PATCH] move configure parser source code to etc folder, and set default log file to /tmp

---
 src/nbiotd/iotd.c          |    1 +
 src/nbiotd/etc/iotd_conf.h |    2 +-
 src/nbiotd/makefile        |    2 +-
 src/nbiotd/etc/makefile    |    0 
 src/nbiotd/etc/iotd.conf   |    2 +-
 src/nbiotd/etc/iotd_conf.c |    7 ++++---
 6 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/nbiotd/etc/iotd.conf b/src/nbiotd/etc/iotd.conf
index 43376f0..c79be71 100644
--- a/src/nbiotd/etc/iotd.conf
+++ b/src/nbiotd/etc/iotd.conf
@@ -1,6 +1,6 @@
 # uited program configure file
 [log]
-file=/var/log/nbiotd.log
+file=/tmp/nbiotd.log
 
 #Loglevel: 0:Disable 1:Fatal 2:ERROR 3:warnning 4:Normal 5:Debug 6:Infor 7:Trace
 level=5
diff --git a/src/nbiotd/core/iotd_conf.c b/src/nbiotd/etc/iotd_conf.c
similarity index 96%
rename from src/nbiotd/core/iotd_conf.c
rename to src/nbiotd/etc/iotd_conf.c
index 6d52ec3..7935d17 100644
--- a/src/nbiotd/core/iotd_conf.c
+++ b/src/nbiotd/etc/iotd_conf.c
@@ -37,7 +37,8 @@
         return -2 ;
     }   
 
-    memset(iotd_conf, 0, sizeof(*iotd_conf));
+    log_nrml("Start parser iotd configure file \"%s\"\n", conf_file);
+
     logger = &iotd_conf->logger;
     nbiot = &iotd_conf->nbiot_conf;
     lora = &iotd_conf->lora_conf;
@@ -82,7 +83,7 @@
         log_err("Configure without NB-IoT comport device, thread will not start\n");
         nbiot->enable = DISABLE;
     }
-    log_nrml("Configure NB-IoT comport device as '%s'\n", lora->comport);
+    log_nrml("Configure NB-IoT comport device as '%s'\n", nbiot->comport);
 
     nbiot->baudrate = iniparser_getint(ini, "nbiot:baudrate", 9600);
     log_nrml("Configure NB-IoT comport baudrate as '%d'\n", nbiot->baudrate);
@@ -142,7 +143,7 @@
 
     data = iniparser_getint(ini, "mqtt:enable", 0);
     mqtt->enable = data? ENABLE : DISABLE;
-    log_nrml("Confiugre MQTT thread [%s]\n", lora->enable ? "enable" : "disable");
+    log_nrml("Confiugre MQTT thread [%s]\n", mqtt->enable ? "enable" : "disable");
 
     str = iniparser_getstring(ini, "mqtt:hostname", NULL);
     if( !str || strlen(str) <= 0 )
diff --git a/src/nbiotd/core/iotd_conf.h b/src/nbiotd/etc/iotd_conf.h
similarity index 97%
rename from src/nbiotd/core/iotd_conf.h
rename to src/nbiotd/etc/iotd_conf.h
index 7445b7e..888f568 100644
--- a/src/nbiotd/core/iotd_conf.h
+++ b/src/nbiotd/etc/iotd_conf.h
@@ -24,7 +24,7 @@
 #define FILEN_LEN              64
 #endif
 
-#define DEF_LOG_FILE         "/var/log/iotd.log"
+#define DEF_LOG_FILE         "/tmp/iotd.log"
 #define DEF_LOG_LEVEL        LOG_LEVEL_NRML
 
 typedef struct lora_conf_s 
diff --git a/src/nbiotd/core/makefile b/src/nbiotd/etc/makefile
similarity index 100%
rename from src/nbiotd/core/makefile
rename to src/nbiotd/etc/makefile
diff --git a/src/nbiotd/iotd.c b/src/nbiotd/iotd.c
index 061618d..977b0e0 100644
--- a/src/nbiotd/iotd.c
+++ b/src/nbiotd/iotd.c
@@ -139,6 +139,7 @@
         printf("Logger initialize failure with file: %s\n", logger->file);
         return -1;
     }
+    log_nrml("Init default logger file \"%s\" ok\n", log_file);
 
     /*  Parser configure file and start the initialize log */
     rv = parser_iotd_conf(conf_file, conf);
diff --git a/src/nbiotd/makefile b/src/nbiotd/makefile
index 5510125..e6ded50 100644
--- a/src/nbiotd/makefile
+++ b/src/nbiotd/makefile
@@ -49,7 +49,7 @@
 # archive to a static library, named lib${subdir_name}.a
 OBJFILES = $(patsubst %.c,%,$(wildcard *.c))
 SUBSRCS = $(shell find . -follow  -maxdepth 1 -type d|sed -n 's/.\///p'|grep -v 'libs' \
-		  |grep -v 'etc' | grep -v '.svn'|grep -v '.git'|grep -v 'include'|grep -v 'bin')
+		  | grep -v '.svn'|grep -v '.git'|grep -v 'include'|grep -v 'bin')
 
 # Add the subdir compiled static library into LDFLAGS
 #LDFLAGS+=$(patsubst %,-L%,$(SUBSRCS)) 

--
Gitblit v1.9.1