From ea435789dc2fab30ec16fa765a0b6577fe08166a Mon Sep 17 00:00:00 2001
From: GuoWenxue <“guowenxue@gmail.com”>
Date: Tue, 19 Apr 2022 10:06:03 +0800
Subject: [PATCH] update client and socket.c, add DNS support

---
 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