guowenxue
2021-04-21 f3122844296bad2700d06d4c74985b080e584e20
iotd/main.c
@@ -31,6 +31,7 @@
#define PROG_VERSION               "v1.0.0"
#define DAEMON_PIDFILE             "/tmp/.iotd.pid"
void control_thread_loop(void *ctx);
static void program_usage(char *progname)
{
@@ -59,7 +60,6 @@
    int                debug = 0;
    int                opt;
    char              *progname=NULL;
    float              lux = 0.0;
    struct option long_options[] = {
        {"conf", required_argument, NULL, 'c'},
@@ -174,11 +174,11 @@
} /* ----- End of main() ----- */
void control_thread_loop(void *ctx)
void control_thread_loop(void *args)
{
    iotd_ctx_t            *ctx = (iotd_ctx_t *)ctx;
    hal_ctx_t             *hal_ctx;
    float                  lux = 0.0;
    hal_ctx = &ctx->hal_ctx;
@@ -186,25 +186,25 @@
    while( ! g_signal.stop )
    { 
        if( hal_ctx->lux_enable )
        {
        lux = tsl2561_get_lux(); 
        if( lux > hal_ctx->lux_threshold )
        {
            log_nrml("Lux[%.3f] > Treshold[%.3f], don't need auto light.\n", lux, hal_ctx->lux_threshold);
                log_nrml("Lux[%.3f] > Treshold[%.3f], don't need light on.\n", lux, hal_ctx->lux_threshold);
            sleep(30);
            continue;
        }
        }
#if 0
        log_nrml("start infrared monitor detect...\n");
        if( infrared_detect() ) 
        {
            log_nrml("Someone incoming detected by infrared\n");
            if( lux < hal_ctx->lux_threshold )
            {
                log_nrml("Lux[%.3f] < Treshold[%.3f], auto light on now..\n", lux, hal_ctx->lux_threshold);
                //turn_light(LIGHT_HALLWAY, ON);
                alarm(hal_ctx->gpio.light_intval);
            }
        }
#endif
    }
}