From d159ebee17bab001a92a1f551c17e3d962d19656 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 30 Jul 2025 19:09:36 +0800 Subject: [PATCH] minor improve --- Core/Src/yunhorn_sts_process.c | 19 ++++++++++++++----- LoRaWAN/App/lora_app.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 184f371..7819b41 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -140,7 +140,9 @@ char sts_presence_fall_detection_message[10][20]={ #define STS_COLOR_DEFAULT_VACANT (sts_color_occupy_vacant&0x0f) #define STS_COLOR_DEFAULT_OCCUPY ((sts_color_occupy_vacant>>4)&0x0f) - +#ifndef LED_PERIOD_TIME +#define LED_PERIOD_TIME 500 +#endif /* // UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0); // P1 --- REEDSWITCH, HALL ELEMENT, WATER LEAKAGE @@ -1089,7 +1091,7 @@ void STS_PRESENCE_SENSOR_Distance_Measure_Process(uint16_t *rss_distance) (unsigned int)(distance_cfg.acc_profile),(unsigned int)(distance_cfg.hwaas)); do { - LED1_TOGGLE; + //LED1_TOGGLE; // exit_status = sts_distance_rss_detector_distance(); exit_status = sts_distance_rss_detector_distance(&tmp_distance); @@ -1099,7 +1101,7 @@ void STS_PRESENCE_SENSOR_Distance_Measure_Process(uint16_t *rss_distance) } while ((exit_status == EXIT_FAILURE) && (i < 3) && (tmp_distance !=0)); *rss_distance = tmp_distance; - LED1_ON; + //LED1_ON; } @@ -1111,6 +1113,7 @@ void STS_PRESENCE_SENSOR_Background_Measure_Process(uint16_t *bg_distance, uint1 sts_work_mode = STS_RSS_BACKGROUND_MODE; sts_lamp_bar_color = STS_BLUE; + HAL_Delay(LED_PERIOD_TIME); APP_LOG(TS_OFF, VLEVEL_M, "\r\n SCAN Background Noise ... \r\n"); @@ -1124,6 +1127,7 @@ void STS_PRESENCE_SENSOR_Background_Measure_Process(uint16_t *bg_distance, uint1 sts_work_mode = previous_sts_work_mode; sts_lamp_bar_color = previous_sts_lamp_bar_color; + HAL_Delay(LED_PERIOD_TIME); sts_rss_config_updated_flag = previous_sts_rss_config_updated_flag|0x80; } @@ -1145,6 +1149,7 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(void) //STS_Lamp_Bar_Refresh(); HAL_Delay(200); sts_lamp_bar_color = STS_PINK; + HAL_Delay(LED_PERIOD_TIME); sts_presence_rss_detection_deinit(); test_res = sts_presence_rss_bring_up_test(); if (test_res != EXIT_SUCCESS) { @@ -1154,8 +1159,10 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(void) } //sts_presence_rss_detection_deinit(); - HAL_Delay(50); sts_lamp_bar_color = STS_CYAN; + HAL_Delay(LED_PERIOD_TIME); + HAL_Delay(50); + uint16_t tmp_dist=0; APP_LOG(TS_OFF, VLEVEL_M, "\r\n Distance Measure process \r\n"); STS_PRESENCE_SENSOR_Distance_Measure_Process(&tmp_dist); @@ -1163,8 +1170,9 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(void) self_test_result[12] = sts_sensor_install_height>>8&0xff; self_test_result[13] = sts_sensor_install_height&0xff; - HAL_Delay(50); sts_lamp_bar_color = STS_BLUE; + HAL_Delay(LED_PERIOD_TIME); + HAL_Delay(50); STS_PRESENCE_SENSOR_Background_Measure_Process(&bg_range, &bg_noise); self_test_result[14] = bg_range>>8&0xff; self_test_result[15] = bg_range&0xff; @@ -1174,6 +1182,7 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(void) } HAL_Delay(50); sts_lamp_bar_color = previous_lamp_bar_color; + HAL_Delay(LED_PERIOD_TIME); // *count = sizeof(bring_up_result); // UTIL_MEM_cpy_8((void*)self_test_result, (void*)bring_up_result, sizeof(bring_up_result)); diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 0fd6ed8..3c3e433 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -2070,8 +2070,12 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) i=0; UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer); + + STS_SENSOR_Function_Test_Process(); + UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer); + #if 0 HAL_Delay(5000); i=21; @@ -2097,7 +2101,15 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) uint16_t rss_distance=0; uint8_t previous_lamp_bar_color = sts_lamp_bar_color; sts_lamp_bar_color = STS_CYAN; + + UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer); + + STS_PRESENCE_SENSOR_Distance_Measure_Process(&rss_distance); + + UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer); + + sts_lamp_bar_color = previous_lamp_bar_color; APP_LOG(TS_OFF, VLEVEL_M, "\r\nRSS Measured Distance=[%u] mm \r\n", (uint16_t)sts_distance_rss_distance); @@ -2149,7 +2161,15 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) { // Background Noise Measure "YZB" #if defined(STS_O7)||defined(STS_O6) uint16_t bg_distance=0, bg_motion_noise=0; + + UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer); + + STS_PRESENCE_SENSOR_Background_Measure_Process(&bg_distance, &bg_motion_noise); + + UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer); + + APP_LOG(TS_OFF, VLEVEL_M, "\r\nRSS Measured Background Center Distance=[%u] mm Motion Noise Level = [%d] \r\n", (uint16_t)bg_distance, (uint16_t)bg_motion_noise); sts_cfg_nvm.p[RSS_CFG_BG_MOTION_NOISE] = (uint8_t)(bg_motion_noise/10)&0xff;