From 4deb51ffc4dd4588183aed82bd7877909ba2130e Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 31 Jul 2019 11:19:22 +0800 Subject: [PATCH] update mqtt configure file, support breakin detect support --- mqttd/hal/hal.c | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mqttd/hal/hal.c b/mqttd/hal/hal.c index 94dd8dc..4840944 100644 --- a/mqttd/hal/hal.c +++ b/mqttd/hal/hal.c @@ -16,9 +16,12 @@ /* LED_R LED_G LED_B */ static int led_pin[LED_MAX] = { 0,0,0 }; static int relay_pin = 0; +static int beep_pin = 0; +static int infrared_pin = 0; void init_relay(int pin); void init_led(int redpin, int greenpin, int bluepin); +void init_beep(int pin); int hal_init(hwconf_t *hwconf) { @@ -31,10 +34,16 @@ wiringPiSetup(); if( hwconf->leds ) - init_led(hwconf->redled, hwconf->greenled, hwconf->blueled); + init_led(hwconf->red_pin, hwconf->green_pin, hwconf->blue_pin); - if(hwconf->relay) - init_relay(hwconf->relay); + if( hwconf->relay_pin ) + init_relay(hwconf->relay_pin); + + if( hwconf->beep_pin ) + init_beep(hwconf->beep_pin); + + if( hwconf->infrared_pin && hwconf->ifrd_handler ) + init_infrared(hwconf->infrared_pin, INT_EDGE_RISING, hwconf->ifrd_handler); if( hwconf->sht2x && sht2x_init() < 0 ) { @@ -86,6 +95,20 @@ pinMode(relay_pin, OUTPUT); } +void init_beep(int pin) +{ + beep_pin = pin; + //pinMode(relay_pin, OUTPUT); +} + +void init_infrared(int pin, int irq_type, void (*handler)(void)) +{ + pinMode(pin, INPUT); + + delay(100); + + wiringPiISR(pin, irq_type, handler); +} void turn_relay(int cmd) { -- Gitblit v1.9.1