From 67f8a597480e9951ea40e84997011660d09eeb84 Mon Sep 17 00:00:00 2001 From: Guo Wenxue <guowenxue@gmail.com> Date: Tue, 20 Nov 2018 14:22:19 +0800 Subject: [PATCH] update iotd program makefile remove install and update configure log file to iotd.log --- src/nbiotd/iotd.c | 45 ++++++++++++++++++++++----------------------- 1 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/nbiotd/iotd.c b/src/nbiotd/iotd.c index d901ab4..1656ae1 100644 --- a/src/nbiotd/iotd.c +++ b/src/nbiotd/iotd.c @@ -23,21 +23,11 @@ #include <sys/stat.h> #include <fcntl.h> -#include "cp_logger.h" #include "cp_proc.h" +#include "iotd_conf.h" -#define DEF_LOG_FILE "/var/log/iotd.log" -#define DEF_LOG_LEVEL LOG_LEVEL_NRML void *watchdog_worker(void *arg); - - - -typedef struct iotd_conf_s -{ - cp_logger logger; - -} iotd_conf_t; typedef struct iotd_ctx_s @@ -78,14 +68,14 @@ const char *progname=NULL; char pid_file[64] = { 0 }; /* The file used to record the PID */ - char *conf_file = "iotd.conf"; + char *conf_file = "etc/iotd.conf"; char *log_file = DEF_LOG_FILE; int log_level = DEF_LOG_LEVEL; iotd_ctx_t iotd_ctx; - pthread_t tid; +// pthread_t tid; iotd_conf_t *conf; - cp_logger *logger; + logger_t *logger; memset(&iotd_ctx, 0, sizeof(iotd_ctx)); conf = &iotd_ctx.conf; @@ -149,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); @@ -169,7 +160,6 @@ printf("Logger reopen failure with file: %s\n", logger->file); return -1; } - printf("Open logger ok\n"); } if( !debug ) @@ -184,19 +174,28 @@ cp_install_proc_signal(); /* start watchdog thread worker */ - thread_start(&tid, watchdog_worker, NULL); + //thread_start(&tid, watchdog_worker, NULL); /* Start MQTT thread worker */ - log_nrml("start MQTT socket process thread\n"); - //thread_start(&tid, mqtt_worker, (void *)&iotd_ctx ); + if( conf->mqtt_conf.enable ) + { + log_nrml("start MQTT publish process thread\n"); + //thread_start(&tid, mqtt_worker, (void *)&iotd_ctx ); + } /* Start NB-IoT thread worker */ - log_nrml("start NB-IoT process thread\n"); - //thread_start(&tid, nbiot_worker, (void *)&iotd_ctx ); + if( conf->nbiot_conf.enable ) + { + log_nrml("start NB-IoT process thread\n"); + //thread_start(&tid, nbiot_worker, (void *)&iotd_ctx ); + } /* Start LoRa thread worker */ - log_nrml("start LoRa AP process thread\n"); - //thread_start(&tid, nbiot_worker, (void *)&iotd_ctx ); + if( conf->nbiot_conf.enable ) + { + log_nrml("start LoRa AP process thread\n"); + //thread_start(&tid, nbiot_worker, (void *)&iotd_ctx ); + } while( !g_cp_signal.stop ) { @@ -243,7 +242,7 @@ } close(wtd_fd); - printf("watchdog thread worker exit\n"); + log_warn("watchdog thread worker exit\n"); return NULL; } -- Gitblit v1.9.1