From 7a0488541f68d1a9eb712a4eb5c6c36da150bc4a Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Fri, 23 Apr 2021 22:43:13 +0800
Subject: [PATCH] update iotd and test infared ok

---
 iotd/main.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/iotd/main.c b/iotd/main.c
index ed29b06..53cdf9c 100644
--- a/iotd/main.c
+++ b/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);
     }
 }
 

--
Gitblit v1.9.1