guowenxue
2021-08-17 ed4285674b9648e85e45e9aeadcc79bd8898790e
iotd/main.c
@@ -194,26 +194,31 @@
                if( lux > hal_ctx->lux_threshold )
                {
                    log_nrml("Lux[%.3f] > Treshold[%.3f], don't need light on.\n", lux, hal_ctx->lux_threshold);
                    sleep(30);
                    log_nrml("Lux[%.3f] > Treshold[%.3f], don't need light on and sleep now.\n", lux, hal_ctx->lux_threshold);
                    if( hal_ctx->gpio.light_intval > 0)
                        sleep( hal_ctx->gpio.light_intval );
                    else
                        sleep(30);
                    continue;
                }
            }
            rv = infrared_detect(250);
            rv = infrared_detect();
            if( rv & FLAG_INFRARED_INDOOR ) 
            {
                log_nrml("Someone incoming detected by indoor infrared\n");
                thread_start(NULL, light_on_worker, "indoor" );
            }
            if( rv & FLAG_INFRARED_HALLWAY ) 
            {
                log_nrml("Someone incoming detected by hallway infrared\n");
                thread_start(NULL, light_on_worker, "hallway" );
            }
        }
        msleep(500);
        msleep(100);
    }
}