| | |
| | | if( !conf_file ) |
| | | debug = 1; |
| | | |
| | | //printf("conf_file: %s debug:%d\n", conf_file, debug); |
| | | |
| | | if( parser_conf(conf_file, &ctx, debug)<0 ) |
| | | { |
| | | fprintf(stderr, "Parser mqtted configure file failure\n"); |
| | | return -2; |
| | | } |
| | | |
| | | return 0; |
| | | |
| | | if( hal_init(hal_ctx) < 0 ) |
| | | { |
| | | log_err("Initialise hardware failure\n"); |
| | | return -3; |
| | | } |
| | | else |
| | | { |
| | | log_nrml("HAL initialise ok\n"); |
| | | } |
| | | log_nrml("Initialise hardware okay.\n"); |
| | | |
| | | return 0; /* todo: debug and removed */ |
| | | |
| | | install_default_signal(); |
| | | |
| | | if( check_set_program_running(daemon, DAEMON_PIDFILE) < 0 ) |
| | | goto OUT; |
| | | |
| | | mosquitto_lib_init(); |
| | | |
| | | mosquitto_lib_init(); |
| | | |
| | | /*+--------------------------------------------+ |
| | | *| Start MQTT subsciber thread if enable | |
| | |
| | | } |
| | | } |
| | | |
| | | /*+--------------------------------------------+ |
| | | *| Control thread start dead loop | |
| | | *+--------------------------------------------+*/ |
| | | control_thread_loop(&ctx); |
| | | |
| | | log_nrml("Start infrared monitor thread working...\n"); |
| | | OUT: |
| | | mosquitto_lib_cleanup(); |
| | | hal_term(hal_ctx); |
| | | logger_term(); |
| | | |
| | | return 0; |
| | | } /* ----- End of main() ----- */ |
| | | |
| | | |
| | | void control_thread_loop(void *ctx) |
| | | { |
| | | iotd_ctx_t *ctx = (iotd_ctx_t *)ctx; |
| | | hal_ctx_t *hal_ctx; |
| | | |
| | | |
| | | hal_ctx = &ctx->hal_ctx; |
| | | |
| | | log_nrml("Start control thread working...\n"); |
| | | |
| | | while( ! g_signal.stop ) |
| | | { |
| | | lux = tsl2561_get_lux(); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | OUT: |
| | | mosquitto_lib_cleanup(); |
| | | hal_term(hal_ctx); |
| | | logger_term(); |
| | | |
| | | return 0; |
| | | } /* ----- End of main() ----- */ |
| | | } |
| | | |
| | | |