guowenxue
2021-04-22 4ff5fe054d3e9db5edf1eb8e9114729b5f7918a3
iotd/main.c
@@ -176,15 +176,21 @@
    iotd_ctx_t            *ctx = (iotd_ctx_t *)args;
    hal_ctx_t             *hal_ctx;
    float                  lux = 0.0;
    int                    rv;
    hal_ctx = &ctx->hal_ctx;
    log_dbg("infrared configured [%d], lux configured [%d]\n", hal_ctx->gpio.infrared_enable, hal_ctx->lux_enable);
    while( ! g_signal.stop )
    {
        if( hal_ctx->gpio.infrared_enable )
    { 
        if( hal_ctx->lux_enable )
        {
            lux = tsl2561_get_lux(); 
            log_dbg("TSL2561 get Lux[%.3f].\n", lux);
                log_dbg("TSL2561 get Lux[%.3f] Treshold[%.3f].\n", lux, hal_ctx->lux_threshold);
            if( lux > hal_ctx->lux_threshold )
            {
@@ -194,13 +200,20 @@
            }
        }
        log_nrml("start infrared monitor detect...\n");
        if( infrared_detect() )
            rv = infrared_detect(250);
            if( rv & FLAG_INFRARED_INDOOR )
        {
            log_nrml("Someone incoming detected by infrared\n");
                log_nrml("Someone incoming detected by indoor infrared\n");
        }
        sleep(1);
            if( rv & FLAG_INFRARED_HALLWAY )
            {
                log_nrml("Someone incoming detected by hallway infrared\n");
            }
        }
        msleep(500);
    }
}