diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 08b6736..72a60e7 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -34,6 +34,7 @@ #include "CayenneLpp.h" #include "sys_sensors.h" #include "flash_if.h" +#include "stdio.h" #ifdef CLOCK_SYNC #include "LmhpClockSync.h" @@ -44,9 +45,11 @@ #include "app_tof_peoplecount.h" #include "yunhorn_sts_prd_conf.h" #include "yunhorn_sts_sensors.h" -#if defined(STS_O6)||defined(STS_T6)||defined(O1L) + +#if (defined(STS_O6)||defined(STS_T6)||defined(O1L)) #include "sts_lamp_bar.h" #endif + /* USER CODE END Includes */ /* External variables ---------------------------------------------------------*/ @@ -68,6 +71,10 @@ extern volatile sts_fhmos_sensor_data_t sts_fhmos_data; extern volatile sts_fhmos_sensor_config_t sts_fhmos_cfg; extern volatile sts_fhmos_sensor_ambient_height_t sts_fhmos_bg; // volatile LmHandlerAppData_t sts_app_data={ 0, 0, sts_data_buf }; +extern volatile uint8_t sts_hall1_read, sts_hall2_read; // Above hall1_read == reed_hall_result, hall2_read == emergency_button +extern volatile uint8_t sts_hall3_read, sts_hall4_read; +extern volatile uint8_t sts_pir_state; + /* USER CODE END EV */ @@ -595,16 +602,37 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { case BUT1_Pin: /* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */ - if (EventType == TX_ON_EVENT) + HAL_Delay(100); + __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); + + sts_hall1_read = HALL1_STATE; + printf("\r\n HALL 1 state =%d \r\n", sts_hall1_read); + if (sts_hall1_read == 0) sts_lamp_bar_color = STS_RED_DARK; + printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color); + + + //if (EventType == TX_ON_EVENT) { UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); } break; #ifndef STS_R4 -#if 0 +#if 1 case BUT2_Pin: - UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0); + HAL_Delay(100); + __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); + + sts_hall2_read = HALL2_STATE; + printf("\r\n HALL 2 state =%d \r\n", sts_hall2_read); + if (sts_hall2_read == 0) sts_lamp_bar_color = STS_RED_BLUE; + printf("\r\n lamp bar color =0x%02x \r\n", sts_lamp_bar_color); + + { + UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); + } + + //UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0); break; #endif #endif @@ -614,6 +642,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) break; #endif case PIR_Pin: + HAL_Delay(100); + __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin); + sts_pir_state = PIR_STATE; printf("\r\n PIR state =%d \r\n", sts_pir_state); if (sts_pir_state == 1) fhmos_human_movement = 1; diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf index 54b079b..807d597 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ