diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index f10502a..37cdd34 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -47,7 +47,7 @@ extern "C" { /** * @brief Verbose level for all trace logs */ -#define VERBOSE_LEVEL VLEVEL_M +#define VERBOSE_LEVEL VLEVEL_H /** * @brief Enable trace logs diff --git a/Core/Inc/utilities_def.h b/Core/Inc/utilities_def.h index 68b7566..7952ef3 100644 --- a/Core/Inc/utilities_def.h +++ b/Core/Inc/utilities_def.h @@ -82,7 +82,7 @@ typedef enum /* USER CODE BEGIN CFG_SEQ_Task_Id_t */ CFG_SEQ_Task_YunhornSTSEventRFAC, /* RFAC */ -#if defined(STS_M1)||defined(STS_O6) +#if defined(STS_M1)||defined(STS_O6)||defined(STS_O7)||defined(STS_O6T)||defined(L8)||defined(STS_T6) CFG_SEQ_Task_YunhornSTSEventP1, /* REEDSWITCH, IO */ #endif #if defined(STS_O6)||defined(O1L) diff --git a/Core/Src/main.c b/Core/Src/main.c index a0a1ca6..b991287 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -136,7 +136,7 @@ int main(void) /* USER CODE END WHILE */ MX_LoRaWAN_Process(); - +printf("."); /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 6d8e0db..68f6272 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -62,6 +62,8 @@ volatile static bool r_b=true; extern volatile uint8_t sts_pir_state; extern volatile uint32_t rfac_timer; extern volatile uint32_t STS_TOFScanPeriod_msec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec; +extern volatile uint32_t STS_RSSWakeUpScanPeriod_msec; +volatile uint8_t sts_presence_fall_detection=TRUE; volatile uint8_t sts_data_buf[LORAWAN_APP_DATA_BUFFER_MAX_SIZE]={0x0}; extern volatile uint8_t fhmos_fall, fhmos_human_movement, fhmos_occupancy, fhmos_sos_alarm; @@ -74,8 +76,8 @@ extern volatile sts_fhmos_sensor_ambient_height_t sts_fhmos_bg; 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; - - +extern volatile uint8_t sts_rss_result_changed_flag; +extern volatile uint8_t sts_fall_rising_detected_result_changed_flag; /* USER CODE END EV */ /* Private typedef -----------------------------------------------------------*/ @@ -107,6 +109,8 @@ typedef enum TxEventType_e */ #define LED_PERIOD_TIME 800 +#define YUNHORN_STS_RSS_WAKEUP_CHECK_TIME STS_RSSWakeUpScanPeriod_msec + /** * Join switch period value of the timer in ms */ @@ -396,6 +400,11 @@ static UTIL_TIMER_Object_t STSLampBarColorTimer; */ static UTIL_TIMER_Object_t STSDurationCheckTimer; +/** + * @brief Timer to handle the YunHorn STS RSS WakeUP Checking + */ +static UTIL_TIMER_Object_t YunhornSTSRSSWakeUpTimer; + /** * @brief Tx Timer period */ @@ -555,12 +564,15 @@ void LoRaWAN_Init(void) UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), UTIL_SEQ_RFU, STS_YunhornSTSEventRFAC_Process); -#ifdef STS_M1 +#if defined(STS_M1)||defined(STS_O7)||defined(STS_O6)||defined(L8) UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), UTIL_SEQ_RFU, STS_YunhornSTSEventP1_Process); #endif +#if defined(STS_O7)||defined(STS_O6)||defined(L8) + UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), UTIL_SEQ_RFU, STS_YunhornSTSEventP2_Process); +#endif #if defined(STS_P2)||defined(STS_T6)||defined(L8) @@ -585,6 +597,9 @@ void LoRaWAN_Init(void) UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer); #endif +UTIL_TIMER_Create(&YunhornSTSRSSWakeUpTimer, YUNHORN_STS_RSS_WAKEUP_CHECK_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSOORSSWakeUpTimerEvent, NULL); +UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer); + UTIL_TIMER_Start(&STSLampBarColorTimer); //UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL); @@ -1549,6 +1564,27 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context) static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context) { + if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_UNI_MODE)) + { + UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), CFG_SEQ_Prio_0); + + if ((sts_rss_result_changed_flag == 1) || (sts_fall_rising_detected_result_changed_flag == 1)) + { + //SendTxData(); + sts_rss_result_changed_flag = 0; + sts_fall_rising_detected_result_changed_flag = 0; + + UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); + //if ((last_sts_rss_result ==STS_RESULT_NO_MOTION)&& (sts_rss_result==STS_RESULT_MOTION)) + { + //OnSensor3StateChanged(); + } + } + + } + + UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer); + #ifdef STS_O6 #endif diff --git a/STM32CubeIDE/.project b/STM32CubeIDE/.project index 9d94277..306ac4e 100644 --- a/STM32CubeIDE/.project +++ b/STM32CubeIDE/.project @@ -412,6 +412,16 @@ 1 copy_PARENT1/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_fw.c + + Application/User/Core/acc_hal_integration_a111.c + 1 + PARENT-1-PROJECT_LOC/Core/Src/acc_hal_integration_a111.c + + + Application/User/Core/acc_integration_log.c + 1 + PARENT-1-PROJECT_LOC/Core/Src/acc_integration_log.c + Application/User/Core/acc_integration_stm32.c 1 diff --git a/STM32CubeIDE/Release/Application/User/Core/subdir.mk b/STM32CubeIDE/Release/Application/User/Core/subdir.mk index 8af9d56..3ff25d5 100644 --- a/STM32CubeIDE/Release/Application/User/Core/subdir.mk +++ b/STM32CubeIDE/Release/Application/User/Core/subdir.mk @@ -5,6 +5,8 @@ # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ +D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/acc_hal_integration_a111.c \ +D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/acc_integration_log.c \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/acc_integration_stm32.c \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/adc.c \ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/adc_if.c \ @@ -32,6 +34,8 @@ D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_S D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/usart_if.c OBJS += \ +./Application/User/Core/acc_hal_integration_a111.o \ +./Application/User/Core/acc_integration_log.o \ ./Application/User/Core/acc_integration_stm32.o \ ./Application/User/Core/adc.o \ ./Application/User/Core/adc_if.o \ @@ -59,6 +63,8 @@ OBJS += \ ./Application/User/Core/usart_if.o C_DEPS += \ +./Application/User/Core/acc_hal_integration_a111.d \ +./Application/User/Core/acc_integration_log.d \ ./Application/User/Core/acc_integration_stm32.d \ ./Application/User/Core/adc.d \ ./Application/User/Core/adc_if.d \ @@ -87,6 +93,10 @@ C_DEPS += \ # Each subdirectory must supply rules for building sources it contributes +Application/User/Core/acc_hal_integration_a111.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/acc_hal_integration_a111.c Application/User/Core/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DL8 -DPIR -DCLOCK_SYNC -DO1L -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../STS/RSS/include -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/RSS/include -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" +Application/User/Core/acc_integration_log.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/acc_integration_log.c Application/User/Core/subdir.mk + arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DL8 -DPIR -DCLOCK_SYNC -DO1L -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../STS/RSS/include -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/RSS/include -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" Application/User/Core/acc_integration_stm32.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/acc_integration_stm32.c Application/User/Core/subdir.mk arm-none-eabi-gcc "$<" -mcpu=cortex-m4 -std=gnu11 -DL8 -DPIR -DCLOCK_SYNC -DO1L -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32WLE5xx -c -I../../Core/Inc -I../../STS/Core/Inc -I../../STS/TOF/App -I../../STS/TOF/Target -I../../STS/TOF/vl53l1x_uld -I../../STS/TOF/vl53l0x -I../../STS/RSS/include -I../../LoRaWAN/App -I../../LoRaWAN/Target -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc -I../../../../../../../Drivers/STM32WLxx_HAL_Driver/Inc/Legacy -I../../../../../../../Utilities/trace/adv_trace -I../../../../../../../Utilities/misc -I../../../../../../../Utilities/sequencer -I../../../../../../../Utilities/timer -I../../../../../../../Utilities/lpm/tiny_lpm -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler/Packages -I../../../../../../../Drivers/CMSIS/Device/ST/STM32WLxx/Include -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Crypto -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac/Region -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Mac -I../../../../../../../Middlewares/Third_Party/LoRaWAN/LmHandler -I../../../../../../../Middlewares/Third_Party/LoRaWAN/Utilities -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy -I../../../../../../../Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver -I../../../../../../../Middlewares/ST/STM32_Cryptographic/include -I../../../../../../../Drivers/CMSIS/Include -I../../../../../../../Drivers/BSP/STM32WLxx_Nucleo -I../../../../../../../Drivers/BSP/Components/vl53l8cx/porting -I../../../../../../../Drivers/BSP/Components/Common -I../../../../../../../Drivers/BSP/53L8A1 -I../../../../../../../Drivers/RSS/include -I../../../../../../../Drivers/BSP/Components/vl53l8cx/modules -I../../../../../../../Drivers/BSP/Components/vl53l8cx -Os -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" Application/User/Core/adc.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/WLE5CC_NODE_STS/Core/Src/adc.c Application/User/Core/subdir.mk @@ -139,7 +149,7 @@ Application/User/Core/usart_if.o: D:/ONEDRIVE/STM32WLV13/Projects/NUCLEO-WL55JC/ clean: clean-Application-2f-User-2f-Core clean-Application-2f-User-2f-Core: - -$(RM) ./Application/User/Core/acc_integration_stm32.cyclo ./Application/User/Core/acc_integration_stm32.d ./Application/User/Core/acc_integration_stm32.o ./Application/User/Core/acc_integration_stm32.su ./Application/User/Core/adc.cyclo ./Application/User/Core/adc.d ./Application/User/Core/adc.o ./Application/User/Core/adc.su ./Application/User/Core/adc_if.cyclo ./Application/User/Core/adc_if.d ./Application/User/Core/adc_if.o ./Application/User/Core/adc_if.su ./Application/User/Core/dma.cyclo ./Application/User/Core/dma.d ./Application/User/Core/dma.o ./Application/User/Core/dma.su ./Application/User/Core/flash_if.cyclo ./Application/User/Core/flash_if.d ./Application/User/Core/flash_if.o ./Application/User/Core/flash_if.su ./Application/User/Core/gpio.cyclo ./Application/User/Core/gpio.d ./Application/User/Core/gpio.o ./Application/User/Core/gpio.su ./Application/User/Core/i2c.cyclo ./Application/User/Core/i2c.d ./Application/User/Core/i2c.o ./Application/User/Core/i2c.su ./Application/User/Core/main.cyclo ./Application/User/Core/main.d ./Application/User/Core/main.o ./Application/User/Core/main.su ./Application/User/Core/rtc.cyclo ./Application/User/Core/rtc.d ./Application/User/Core/rtc.o ./Application/User/Core/rtc.su ./Application/User/Core/spi.cyclo ./Application/User/Core/spi.d ./Application/User/Core/spi.o ./Application/User/Core/spi.su ./Application/User/Core/stm32_lpm_if.cyclo ./Application/User/Core/stm32_lpm_if.d ./Application/User/Core/stm32_lpm_if.o ./Application/User/Core/stm32_lpm_if.su ./Application/User/Core/stm32wlxx_hal_msp.cyclo ./Application/User/Core/stm32wlxx_hal_msp.d ./Application/User/Core/stm32wlxx_hal_msp.o ./Application/User/Core/stm32wlxx_hal_msp.su ./Application/User/Core/stm32wlxx_it.cyclo ./Application/User/Core/stm32wlxx_it.d ./Application/User/Core/stm32wlxx_it.o ./Application/User/Core/stm32wlxx_it.su ./Application/User/Core/stm32wlxx_nucleo_bus.cyclo ./Application/User/Core/stm32wlxx_nucleo_bus.d ./Application/User/Core/stm32wlxx_nucleo_bus.o ./Application/User/Core/stm32wlxx_nucleo_bus.su ./Application/User/Core/sts_lamp_bar.cyclo ./Application/User/Core/sts_lamp_bar.d ./Application/User/Core/sts_lamp_bar.o ./Application/User/Core/sts_lamp_bar.su ./Application/User/Core/subghz.cyclo ./Application/User/Core/subghz.d ./Application/User/Core/subghz.o ./Application/User/Core/subghz.su ./Application/User/Core/sys_app.cyclo ./Application/User/Core/sys_app.d ./Application/User/Core/sys_app.o ./Application/User/Core/sys_app.su ./Application/User/Core/sys_debug.cyclo ./Application/User/Core/sys_debug.d ./Application/User/Core/sys_debug.o ./Application/User/Core/sys_debug.su ./Application/User/Core/sys_sensors.cyclo ./Application/User/Core/sys_sensors.d ./Application/User/Core/sys_sensors.o ./Application/User/Core/sys_sensors.su ./Application/User/Core/syscalls.cyclo ./Application/User/Core/syscalls.d ./Application/User/Core/syscalls.o ./Application/User/Core/syscalls.su ./Application/User/Core/sysmem.cyclo ./Application/User/Core/sysmem.d ./Application/User/Core/sysmem.o ./Application/User/Core/sysmem.su ./Application/User/Core/tim.cyclo ./Application/User/Core/tim.d ./Application/User/Core/tim.o ./Application/User/Core/tim.su ./Application/User/Core/timer_if.cyclo ./Application/User/Core/timer_if.d ./Application/User/Core/timer_if.o ./Application/User/Core/timer_if.su ./Application/User/Core/usart.cyclo ./Application/User/Core/usart.d ./Application/User/Core/usart.o ./Application/User/Core/usart.su ./Application/User/Core/usart_if.cyclo ./Application/User/Core/usart_if.d ./Application/User/Core/usart_if.o ./Application/User/Core/usart_if.su + -$(RM) ./Application/User/Core/acc_hal_integration_a111.cyclo ./Application/User/Core/acc_hal_integration_a111.d ./Application/User/Core/acc_hal_integration_a111.o ./Application/User/Core/acc_hal_integration_a111.su ./Application/User/Core/acc_integration_log.cyclo ./Application/User/Core/acc_integration_log.d ./Application/User/Core/acc_integration_log.o ./Application/User/Core/acc_integration_log.su ./Application/User/Core/acc_integration_stm32.cyclo ./Application/User/Core/acc_integration_stm32.d ./Application/User/Core/acc_integration_stm32.o ./Application/User/Core/acc_integration_stm32.su ./Application/User/Core/adc.cyclo ./Application/User/Core/adc.d ./Application/User/Core/adc.o ./Application/User/Core/adc.su ./Application/User/Core/adc_if.cyclo ./Application/User/Core/adc_if.d ./Application/User/Core/adc_if.o ./Application/User/Core/adc_if.su ./Application/User/Core/dma.cyclo ./Application/User/Core/dma.d ./Application/User/Core/dma.o ./Application/User/Core/dma.su ./Application/User/Core/flash_if.cyclo ./Application/User/Core/flash_if.d ./Application/User/Core/flash_if.o ./Application/User/Core/flash_if.su ./Application/User/Core/gpio.cyclo ./Application/User/Core/gpio.d ./Application/User/Core/gpio.o ./Application/User/Core/gpio.su ./Application/User/Core/i2c.cyclo ./Application/User/Core/i2c.d ./Application/User/Core/i2c.o ./Application/User/Core/i2c.su ./Application/User/Core/main.cyclo ./Application/User/Core/main.d ./Application/User/Core/main.o ./Application/User/Core/main.su ./Application/User/Core/rtc.cyclo ./Application/User/Core/rtc.d ./Application/User/Core/rtc.o ./Application/User/Core/rtc.su ./Application/User/Core/spi.cyclo ./Application/User/Core/spi.d ./Application/User/Core/spi.o ./Application/User/Core/spi.su ./Application/User/Core/stm32_lpm_if.cyclo ./Application/User/Core/stm32_lpm_if.d ./Application/User/Core/stm32_lpm_if.o ./Application/User/Core/stm32_lpm_if.su ./Application/User/Core/stm32wlxx_hal_msp.cyclo ./Application/User/Core/stm32wlxx_hal_msp.d ./Application/User/Core/stm32wlxx_hal_msp.o ./Application/User/Core/stm32wlxx_hal_msp.su ./Application/User/Core/stm32wlxx_it.cyclo ./Application/User/Core/stm32wlxx_it.d ./Application/User/Core/stm32wlxx_it.o ./Application/User/Core/stm32wlxx_it.su ./Application/User/Core/stm32wlxx_nucleo_bus.cyclo ./Application/User/Core/stm32wlxx_nucleo_bus.d ./Application/User/Core/stm32wlxx_nucleo_bus.o ./Application/User/Core/stm32wlxx_nucleo_bus.su ./Application/User/Core/sts_lamp_bar.cyclo ./Application/User/Core/sts_lamp_bar.d ./Application/User/Core/sts_lamp_bar.o ./Application/User/Core/sts_lamp_bar.su ./Application/User/Core/subghz.cyclo ./Application/User/Core/subghz.d ./Application/User/Core/subghz.o ./Application/User/Core/subghz.su ./Application/User/Core/sys_app.cyclo ./Application/User/Core/sys_app.d ./Application/User/Core/sys_app.o ./Application/User/Core/sys_app.su ./Application/User/Core/sys_debug.cyclo ./Application/User/Core/sys_debug.d ./Application/User/Core/sys_debug.o ./Application/User/Core/sys_debug.su ./Application/User/Core/sys_sensors.cyclo ./Application/User/Core/sys_sensors.d ./Application/User/Core/sys_sensors.o ./Application/User/Core/sys_sensors.su ./Application/User/Core/syscalls.cyclo ./Application/User/Core/syscalls.d ./Application/User/Core/syscalls.o ./Application/User/Core/syscalls.su ./Application/User/Core/sysmem.cyclo ./Application/User/Core/sysmem.d ./Application/User/Core/sysmem.o ./Application/User/Core/sysmem.su ./Application/User/Core/tim.cyclo ./Application/User/Core/tim.d ./Application/User/Core/tim.o ./Application/User/Core/tim.su ./Application/User/Core/timer_if.cyclo ./Application/User/Core/timer_if.d ./Application/User/Core/timer_if.o ./Application/User/Core/timer_if.su ./Application/User/Core/usart.cyclo ./Application/User/Core/usart.d ./Application/User/Core/usart.o ./Application/User/Core/usart.su ./Application/User/Core/usart_if.cyclo ./Application/User/Core/usart_if.d ./Application/User/Core/usart_if.o ./Application/User/Core/usart_if.su .PHONY: clean-Application-2f-User-2f-Core diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf index f12502f..79adce1 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ diff --git a/STS/Core/Inc/yunhorn_sts_prd_conf.h b/STS/Core/Inc/yunhorn_sts_prd_conf.h index f54b5d3..9cab974 100644 --- a/STS/Core/Inc/yunhorn_sts_prd_conf.h +++ b/STS/Core/Inc/yunhorn_sts_prd_conf.h @@ -60,6 +60,8 @@ #define YUNHORN_STS_R4_ENABLED 1U #elif defined(L8) #define STS_L8 +//#define USE_ACCONEER_A111 1U + #endif diff --git a/STS/Core/Inc/yunhorn_sts_sensors.h b/STS/Core/Inc/yunhorn_sts_sensors.h index 49b1d30..52f7017 100644 --- a/STS/Core/Inc/yunhorn_sts_sensors.h +++ b/STS/Core/Inc/yunhorn_sts_sensors.h @@ -471,6 +471,19 @@ void STS_YunhornSTSEventP7_Process(void); void STS_YunhornSTSEventRFAC_Process(void); void STS_YunhornAuthenticationCode_Process(void); + +int sts_presence_rss_presence_detection(void); +int sts_presence_rss_fall_rise_detection(void); +int sts_distance_rss_detector_distance(void); +void OnSensor1StateChanged(void); +void OnSensor2StateChanged(void); +void OnSensor3StateChanged(void); +void OnSensor4StateChanged(void); + +void OnSensorRSS3AStateChanged(void); +void OnSensorRSS3BStateChanged(void); +void OnSensorRSS3CStateChanged(void); + void STS_Reed_Hall_Presence_Detection(void); void STS_SENSOR_Upload_Config_Invalid_Message(void); @@ -497,7 +510,7 @@ void STS_FHMOS_sensor_config_init(void); void STS_FHMOS_sensor_config_update(void); void STSWakeupScanTimerStop(void); void STSWakeupScanTimerStart(void); - +uint32_t STS_Get_Date_Time_Stamp(void);//uint32_t *time_stamp, uint8_t *datetimestamp); /* USER CODE BEGIN Private defines */ /* In this example TIM2 input clock (TIM2CLK) is set to APB1 clock (PCLK1), diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index 0b85d66..7f5bb48 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -54,8 +54,13 @@ extern volatile uint8_t sts_tof_presence_state_changed; #include "sts_lamp_bar.h" volatile uint8_t sts_hall1_read=STS_Status_Door_Open,sts_hall2_read=STS_Status_SOS_Release; // Above hall1_read == reed_hall_result, hall2_read == emergency_button volatile uint8_t sts_hall3_read=STS_Status_Alarm_Mute_Release,sts_hall4_read=STS_Status_Alarm_Reset_Release; +volatile uint8_t sts_reed_hall_1_result=STS_Status_Door_Open,sts_reed_hall_2_result=STS_Status_SOS_Release, last_sts_reed_hall_1_result=STS_Status_Door_Open, last_sts_reed_hall_2_result=STS_Status_SOS_Release; +volatile uint8_t sts_reed_hall_3_result=STS_Status_Door_Open, last_sts_reed_hall_3_result=STS_Status_Door_Open, sts_reed_hall_4_result=STS_Status_Door_Open, last_sts_reed_hall_4_result=STS_Status_Door_Open; + volatile uint8_t sts_pir_state=0; +volatile uint8_t sts_reed_hall_changed_flag = 0; volatile STS_OO_SensorStatusDataTypeDef sts_o7_sensorData; + volatile uint8_t sts_fall_detection_acc_threshold = 30, //0.3g sts_fall_detection_depth_threshold=20, sts_fall_confirm_threshold_in_10sec=1, @@ -66,10 +71,10 @@ extern volatile uint8_t sts_lamp_bar_color; //puColor extern volatile uint8_t sts_lamp_bar_flashing_color; //0x23; RED_BLUE; volatile uint8_t sts_cloud_netcolor = STS_BLUE; //netColor extern volatile uint8_t sts_occupancy_status; - +extern volatile uint8_t sts_presence_fall_detection; extern volatile uint8_t sts_status_color, sts_lamp_bar_color;//puColor extern uint8_t luminance_level; - +extern volatile uint8_t sts_rss_config_updated_flag; extern volatile sts_fhmos_sensor_config_t sts_fhmos_cfg; extern volatile uint8_t sts_mask_bitmap[8]; #endif @@ -143,6 +148,7 @@ volatile uint8_t sensor_data_ready=0; volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=30, STS_HeartBeatTimerPeriod_sec=3600; #elif defined(STS_L8)||defined(STS_P2)||defined(STS_O6T)||defined(STS_T6)||defined(O1L) volatile uint32_t STS_TOFScanPeriod_msec=500, STS_TxPeriod_sec=300, STS_HeartBeatTimerPeriod_sec=3600; +volatile uint32_t STS_RSSWakeUpScanPeriod_msec = 1000; #endif volatile uint8_t sts_rss_result_changed_flag = 0; @@ -150,7 +156,15 @@ volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION; volatile uint8_t sts_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION; volatile uint8_t last_sts_rss_result=STS_RESULT_NO_MOTION; +extern volatile uint8_t last_lamp_bar_color; +extern volatile uint8_t sts_fall_rising_detected_result; +extern volatile uint8_t sts_fall_rising_detected_result_changed_flag; +extern volatile uint8_t last_sts_fall_rising_detected_result; +extern volatile uint8_t sts_reed_hall_changed_flag; +extern volatile uint8_t sts_fall_rising_detected_result_changed_flag; +volatile uint8_t sts_reed_hall_result; +volatile uint32_t last_sts_rss_time_stamp=0; static uint8_t outbuf[128]={0x0}; extern volatile hmac_result_t hmac_result; extern uint16_t sensor_id; @@ -350,33 +364,32 @@ void STS_YunhornSTSEventP1_Process(void) */ void STS_YunhornSTSEventP2_Process(void) { -#if (defined(YUNHORN_STS_O6_ENABLED) && defined(USE_ACCONEER_A111)) - if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE)) - { - STS_RSS_Smart_Presence_Detection(); - STS_Reed_Hall_Presence_Detection(); - - if (sts_rss_result == last_sts_rss_result) { - sts_rss_result_changed_flag =0; - } else { - sts_rss_result_changed_flag =1; - } - - if (sts_reed_hall_result == last_sts_reed_hall_result) + //STS_Lamp_Bar_Refresh(); //TODO XXX eliminate refresh every second.... try + if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE)) { - sts_reed_hall_changed_flag = 0; + if (sts_presence_fall_detection == TRUE) { + sts_rss_config_updated_flag = STS_RSS_CONFIG_FALL_DETECTION; + } + sts_presence_rss_fall_rise_detection(); - } else - { - sts_reed_hall_changed_flag = 1; + sts_rss_result_changed_flag = (sts_rss_result == last_sts_rss_result)? 0:1; + + last_sts_rss_result = sts_rss_result; + + //sts_fall_rising_detected_result_changed_flag = (sts_fall_rising_detected_result == last_sts_fall_rising_detected_result)?0:1; + sts_fall_rising_detected_result_changed_flag = (sts_fall_rising_detected_result != last_sts_fall_rising_detected_result)?1:0; + + + last_sts_fall_rising_detected_result = sts_fall_rising_detected_result; + + if (sts_service_mask > 0 ) { + sts_rss_result_changed_flag =0; + sts_reed_hall_changed_flag = 0; + sts_fall_rising_detected_result_changed_flag =0; + } + + STS_Combined_Status_Processing(); } - - STS_Combined_Status_Processing(); - - last_sts_rss_result = sts_rss_result; - last_sts_reed_hall_result = sts_reed_hall_result; - } -#endif } void STS_Reed_Hall_Presence_Detection(void) @@ -400,9 +413,9 @@ void STS_Reed_Hall_Presence_Detection(void) void STS_RSS_Smart_Presence_Detection(void) { -#if (defined(YUNHORN_STS_O6_ENABLED) && defined(USE_ACCONEER_A111)) - sts_presence_rss_pressence_detection(); -#endif +//#if (defined(YUNHORN_STS_O6_ENABLED) && defined(USE_ACCONEER_A111)) + //sts_presence_rss_pressence_detection(); +//#endif } /* @@ -1540,6 +1553,192 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s } // END OF USER_APP_AUTO_RESPONDER_P_CMD + + +void STS_Combined_Status_Processing(void) +{ + switch (sts_work_mode) + { + case STS_NETWORK_MODE: + sts_status_color = sts_cloud_netcolor; + sts_lamp_bar_color = sts_cloud_netcolor; + + break; + case STS_WIRED_MODE: // NO LAMP BAR FOR THOSE WATER LEAKAGE SENSOR OR SOAP CAPACITY SENSORS + sts_status_color = STS_DARK; +#ifdef STS_M1 + sts_water_leakage_result = (sts_reed_hall_result == STS_Status_Door_Open )?STS_RESULT_WATER_LEAKAGE_YES:STS_RESULT_WATER_LEAKAGE_NO; + sts_water_leakage_changed_flag = 1; +#endif + break; + case STS_REEDSWITCH_MODE: + + sts_status_color = (sts_reed_hall_1_result == STS_Status_Door_Open )? STS_GREEN: STS_RED; + if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) + { + sts_status_color = STS_RED_BLUE; + } + break; + case STS_RSS_MODE: + if (sts_rss_result == STS_RESULT_NO_MOTION){ + sts_status_color = STS_GREEN; + } else if ((sts_rss_result == STS_RESULT_MOTION)) + { + sts_status_color = STS_RED; + } + break; + case STS_DUAL_MODE: // FOR STS_O6 + if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release )) + { + sts_status_color = STS_GREEN; + + } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown )) + { + sts_status_color = STS_RED; + + if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) + { + sts_status_color = STS_RED_BLUE; + } + } + break; + + case STS_UNI_MODE: //FOR STS-O7 + if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release ) + && (sts_reed_hall_3_result == STS_Status_Alarm_Mute_Release )&& (sts_reed_hall_4_result == STS_Status_Alarm_Reset_Release )) + { + sts_status_color = STS_GREEN; + + } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) + || (sts_reed_hall_3_result == STS_Status_Alarm_Mute_Pushdown )|| (sts_reed_hall_4_result == STS_Status_Alarm_Reset_Pushdown )) + { + sts_status_color = STS_RED; + + if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) + { + sts_status_color = STS_RED_BLUE; + } + } + + switch(sts_fall_rising_detected_result) + { + case STS_PRESENCE_NORMAL: + //do nothing + break; + + case STS_PRESENCE_LAYDOWN: + sts_lamp_bar_color = STS_YELLOW; + sts_status_color = STS_YELLOW; + break; + + case STS_PRESENCE_FALL: //RED_BLUE FLASH + sts_lamp_bar_color = STS_RED_BLUE; + sts_status_color = STS_RED_BLUE; + break; + + case STS_PRESENCE_RISING: //NORMAL OCCUPANCY STATUS + sts_lamp_bar_color = STS_RED; + sts_status_color = STS_RED; + break; + + default: +// sts_lamp_bar_color = STS_RED; +// sts_status_color = STS_RED; + break; + } + + break; + + case STS_REMOTE_REED_RSS_MODE: + if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_result == STS_Status_Door_Open )) + { + sts_status_color = STS_GREEN; + + } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_result == STS_Status_Door_Close )) + { + sts_status_color = STS_RED; + } + break; + case STS_DUAL_RSS_MODE: + if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_rss_2nd_result == STS_RESULT_NO_MOTION)) + { + sts_status_color = STS_GREEN; + } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_rss_2nd_result == STS_RESULT_MOTION)) + { + sts_status_color = STS_RED; + } + + break; + case STS_TOF_RSS_MODE: + if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_tof_result == STS_RESULT_NO_PRESENCE)){ + sts_status_color = STS_GREEN; + + } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_tof_result == STS_RESULT_PRESENCE)) + { + sts_status_color = STS_RED; + } + + break; +// TO-DO LIST *********************************************************** + case STS_TOF_DISTANCE_MODE: + if ((sts_tof_result == STS_RESULT_NO_PRESENCE)) { + sts_status_color = STS_GREEN; + } else if ((sts_tof_result == STS_RESULT_PRESENCE)) { + sts_status_color = STS_RED; + } + break; + case STS_TOF_PRESENCE_MODE: + if ((sts_tof_result == STS_RESULT_NO_PRESENCE)) { + sts_status_color = STS_GREEN; + } else if ((sts_tof_result == STS_RESULT_PRESENCE)) { + sts_status_color = STS_RED; + } + break; + case STS_TOF_IN_OUT_MODE: + if ((sts_tof_result == STS_RESULT_NO_PRESENCE)) { + sts_status_color = STS_GREEN; + } else if ((sts_tof_result == STS_RESULT_PRESENCE)) { + sts_status_color = STS_RED; + } + break; +// TO-DO LIST *********************************************************** + default: + break; + } + + if ((sts_work_mode == STS_WIRED_MODE) || (sts_service_mask > STS_SERVICE_MASK_L0)) + { + sts_status_color = STS_DARK; + sts_lamp_bar_color = STS_DARK; + last_lamp_bar_color = STS_DARK; + STS_Lamp_Bar_Set_Dark(); + } + else + { + + if ((last_lamp_bar_color != sts_status_color)) + { + sts_lamp_bar_color = sts_status_color; + + //STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); + + last_lamp_bar_color = sts_lamp_bar_color; + } + } + + + if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag)||(sts_fall_rising_detected_result_changed_flag)) + { + //sts_rss_result_changed_flag =0; + //sts_reed_hall_changed_flag =0; + //sts_fall_rising_detected_result_changed_flag =0; + //sts_tof_result_changed_flag =0; + sensor_data_ready = 1; + //STS_PRESENCE_SENSOR_Prepare_Send_Data(); + } + +} + void STS_SENSOR_Upload_Config_Invalid_Message(void) { if (sts_service_mask == STS_SERVICE_MASK_L0) @@ -2249,6 +2448,251 @@ void YunhornSTSDurationCheckTimer(void) } } + + + +/* reedswitch 1 on off */ +void OnSensor1StateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + if (sts_hall1_read == STS_Status_Door_Close) + { + sts_o7_sensorData.event_sensor1_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor1_duration = 0; + APP_LOG(TS_OFF, VLEVEL_L, "Door Closed ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor1_start_time ); + } else if (sts_hall1_read==STS_Status_Door_Open) + { + sts_o7_sensorData.event_sensor1_start_time = 0; + sts_o7_sensorData.event_sensor1_stop_time = sensor_event_time.Seconds; + //sts_o7_sensorData.event_sensor1_duration = 0; + sts_o7_sensorData.over_stay_state = 0; + } + +} + +/* SOS emergency button on off */ +void OnSensor2StateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + uint32_t time_stamp=STS_Get_Date_Time_Stamp(); + + if (sts_hall2_read==STS_Status_SOS_Pushdown) + { + sts_o7_sensorData.event_sensor2_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor2_start_timestamp = time_stamp; + sts_o7_sensorData.event_sensor2_stop_time = 0; + sts_o7_sensorData.event_sensor2_duration = 0; + APP_LOG(TS_OFF, VLEVEL_L, "SOS PushDown ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor2_start_time ); + }else if (sts_hall2_read==STS_Status_SOS_Release) + { + sts_o7_sensorData.event_sensor2_start_time = 0; + sts_o7_sensorData.event_sensor2_start_timestamp = 0; + sts_o7_sensorData.event_sensor2_stop_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor2_stop_timestamp = time_stamp; + //sts_o7_sensorData.over_stay_state = 0; + //sts_o7_sensorData.event_sensor2_duration = 0; + } +} + +/* motion sensor RSS ON-OFF */ +void OnSensorRSS3StateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); +#if 0 + if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter + { + return ; + } +#endif + if (sts_rss_result == STS_RESULT_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_motion_duration = 0; + } else if (sts_rss_result == STS_RESULT_NO_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_start_timestamp = 0; + //sts_o7_sensorData.event_sensor3_motion_duration = 0; + + } + + + last_sts_rss_time_stamp = sensor_event_time.Seconds; + +} + +/* motion sensor A: Motion/No-Motion Detection, Unconscious Detection */ +void OnSensorRSS3AStateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); +#if 0 + if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter + { + return ; + } +#endif + if (sts_rss_result == STS_RESULT_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_motion_duration = 0; + } else if (sts_rss_result == STS_RESULT_NO_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_start_timestamp = 0; + //sts_o7_sensorData.event_sensor3_motion_duration = 0; + } + + + last_sts_rss_time_stamp = sensor_event_time.Seconds; + +} + +/* motion sensor B, Fall Detection suggestionF */ +void OnSensorRSS3BStateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + uint32_t time_stamp=STS_Get_Date_Time_Stamp(); + +#if 0 + if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter + { + return ; + } +#endif + switch (sts_fall_rising_detected_result) + { + case STS_PRESENCE_NORMAL: + sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; + break; + + case STS_PRESENCE_FALL: + //if (motion_in_hs_zone[0][motion_detected_count]) + { + sts_o7_sensorData.event_sensor3_fall_start_time_stamp = time_stamp; + sts_o7_sensorData.event_sensor3_fall_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_fall_duration = 0; + } + break; + + case STS_PRESENCE_RISING: + sts_o7_sensorData.event_sensor3_fall_stop_time_stamp = time_stamp; + sts_o7_sensorData.event_sensor3_fall_stop_time = sensor_event_time.Seconds; + break; + + case STS_PRESENCE_LAYDOWN: + break; + + case STS_PRESENCE_STAYSTILL: + case STS_PRESENCE_NO_MOVEMENT: + case STS_PRESENCE_UNCONSCIOUS: + sts_o7_sensorData.event_sensor3_no_movement_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_unconcious_start_time = sensor_event_time.Seconds; + //sts_o7_sensorData.event_sensor3_unconcious_duration = 0; + //sts_o7_sensorData.event_sensor3_no_movement_duration = 0; + //sts_o7_sensorData.fall_laydown_duration = 0; + break; + + default: + break; + + } + + last_sts_rss_time_stamp = sensor_event_time.Seconds; + + +} + +/* motion sensor C: Over stay detection */ +void OnSensorRSS3CStateChanged(void) +{ + SysTime_t sensor_event_time = SysTimeGetMcuTime(); +#if 0 + if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter + { + return ; + } +#endif + if (sts_rss_result == STS_RESULT_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor3_motion_duration = 0; + } else if (sts_rss_result == STS_RESULT_NO_MOTION) + { + sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; + //sts_o7_sensorData.event_sensor3_motion_duration = 0; + } + + + last_sts_rss_time_stamp = sensor_event_time.Seconds; + +} + + +void OnSensor3StateChanged(void) +{ +#if 0 + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + // reserved... to be finalized 2024-06-03 + + if (sts_xxx_result) + sts_o7_sensorData.event_sensor4_start_time = sensor_event_time.Seconds; + else + sts_o7_sensorData.event_sensor4_stop_time = sensor_event_time.Seconds; +#endif + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + uint32_t time_stamp=STS_Get_Date_Time_Stamp(); + + if (sts_hall3_read==STS_Status_Alarm_Mute_Pushdown) + { + sts_o7_sensorData.event_sensor4_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor4_start_timestamp = time_stamp; + sts_o7_sensorData.event_sensor4_stop_time = 0; + sts_o7_sensorData.event_sensor4_duration = 0; + APP_LOG(TS_OFF, VLEVEL_L, "Alarm Mute PushDown ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor4_start_time ); + }else if (sts_hall3_read==STS_Status_Alarm_Mute_Release) + { + sts_o7_sensorData.event_sensor4_start_time = 0; + sts_o7_sensorData.event_sensor4_start_timestamp = 0; + sts_o7_sensorData.event_sensor4_stop_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor4_stop_timestamp = time_stamp; + //sts_o7_sensorData.over_stay_state = 0; + //sts_o7_sensorData.event_sensor2_duration = 0; + } +} + +void OnSensor4StateChanged(void) +{ +#if 0 + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + // reserved... to be finalized 2024-06-03 + + if (sts_xxx_result) + sts_o7_sensorData.event_sensor4_start_time = sensor_event_time.Seconds; + else + sts_o7_sensorData.event_sensor4_stop_time = sensor_event_time.Seconds; +#endif + SysTime_t sensor_event_time = SysTimeGetMcuTime(); + uint32_t time_stamp=STS_Get_Date_Time_Stamp(); + + if (sts_hall4_read==STS_Status_Alarm_Mute_Pushdown) + { + sts_o7_sensorData.event_sensor5_start_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor5_start_timestamp = time_stamp; + sts_o7_sensorData.event_sensor5_stop_time = 0; + sts_o7_sensorData.event_sensor5_duration = 0; + APP_LOG(TS_OFF, VLEVEL_L, "Alarm RESET PushDown ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor5_start_time ); + }else if (sts_hall4_read==STS_Status_Alarm_Mute_Release) + { + sts_o7_sensorData.event_sensor5_start_time = 0; + sts_o7_sensorData.event_sensor5_start_timestamp = 0; + sts_o7_sensorData.event_sensor5_stop_time = sensor_event_time.Seconds; + sts_o7_sensorData.event_sensor5_stop_timestamp = time_stamp; + //sts_o7_sensorData.over_stay_state = 0; + //sts_o7_sensorData.event_sensor2_duration = 0; + } +} + + /* USER CODE BEGIN EF */ /* USER CODE END EF */ diff --git a/STS/RSS/yunhorn_sts_presence_rss.c b/STS/RSS/yunhorn_sts_presence_rss.c index 3c15ad3..85fe01d 100644 --- a/STS/RSS/yunhorn_sts_presence_rss.c +++ b/STS/RSS/yunhorn_sts_presence_rss.c @@ -126,7 +126,7 @@ typedef struct uint16_t presence_score; // 1000* uint16_t presence_distance; // 1000*, in mm } STS_presence_result_t; - +volatile uint8_t sts_rss_config_updated_flag = 0; static STS_presence_result_t sts_motion_dataset[DEFAULT_MOTION_DATASET_LEN]; static STS_PRESENCE_Motion_Featuer_t sts_motion_feature[DEFAULT_MOTION_FEATURE_LEN]; volatile uint8_t sts_fall_rising_detected_result = STS_PRESENCE_NORMAL;