From c395bea78de70eb968c697e55c486d1d249f4b58 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Thu, 27 Nov 2025 21:44:58 +0800
Subject: [PATCH] Update lightd code for incoming detect

---
 project/lightd/hal/gpio.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/project/lightd/hal/gpio.c b/project/lightd/hal/gpio.c
index d0e781c..db49bd2 100644
--- a/project/lightd/hal/gpio.c
+++ b/project/lightd/hal/gpio.c
@@ -17,14 +17,7 @@
 #include <errno.h>
 
 #include "logger.h"
-#include "util_proc.h"
-#include "gpio.h"
-
-#define RPI_GPIONAME        "gpiochip0"
-#include <errno.h>
-
-#include "logger.h"
-#include "util_proc.h"
+#include "utils.h"
 #include "gpio.h"
 
 #define RPI_GPIONAME        "gpiochip0"
@@ -93,7 +86,7 @@
             goto failed;
         }
 
-        if( gpio->output[i].active_level )
+        if( gpio->input[i].active_level )
             rv = gpiod_line_request_rising_edge_events(gpio->input[i].line, gpio->input[i].name) ;
         else
             rv = gpiod_line_request_falling_edge_events(gpio->input[i].line, gpio->input[i].name) ;
@@ -101,14 +94,14 @@
         if( rv < 0 )
         {
             log_error("gpiod request '%s' pin[#%d] event edge [%s] failure: %s\n",
-                    gpio->input[i].name, gpio->input[i].pin, gpio->output[i].active_level?"rising":"falling", strerror(errno));
+                    gpio->input[i].name, gpio->input[i].pin, gpio->input[i].active_level?"rising":"falling", strerror(errno));
             rv = -4;
             goto failed;
         }
         else
         {
             log_info("gpiod request '%s' pin[#%d] event edge [%s] ok\n",
-                    gpio->input[i].name, gpio->input[i].pin, gpio->output[i].active_level?"rising":"falling");
+                    gpio->input[i].name, gpio->input[i].pin, gpio->input[i].active_level?"rising":"falling");
         }
     }
 
@@ -202,7 +195,7 @@
         return 0;
     }
 
-    log_debug("infrared start detect event(blocked) now...\n");
+    log_info("infrared start detect event(blocked) now...\n");
     rv = gpiod_line_event_wait_bulk(&bulk, NULL, &event_bulk);
     if( rv <= 0 )
     {

--
Gitblit v1.9.1