From 872482893f87385677ade6db69bbe11ca9ff1eb8 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 14 Aug 2024 19:37:49 +0800 Subject: [PATCH] --minor changes for fall state --- Core/Src/yunhorn_sts_presence_rss.c | 3 ++- Core/Src/yunhorn_sts_process.c | 4 ++++ LoRaWAN/App/lora_app.c | 14 ++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 0d0b184..eeed422 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -529,6 +529,7 @@ int sts_presence_rss_fall_rise_detection(void) motion_count = motion_count%DEFAULT_MOTION_DATASET_LEN; // get all required number of motion data + sts_fall_rising_detected_result = STS_PRESENCE_NORMAL; if ((sts_presence_fall_detection == TRUE)&& (motion_count>10)) STS_YunhornCheckStandardDeviation(); @@ -808,7 +809,7 @@ void STS_YunhornCheckStandardDeviation(void) } } - if ((last_sts_fall_rising_detected_result == STS_PRESENCE_FALL)) + if ((last_sts_fall_rising_detected_result == STS_PRESENCE_FALL)&&( sts_fall_rising_detected_result != STS_PRESENCE_FALL )) { if ((average_presence_distance < (sts_motion_feature[motion_feature_count].p_dist_avg + sts_motion_feature[motion_feature_count].p_dist_standard))) { diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 9da26fe..e0449a3 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -1195,7 +1195,11 @@ void OnSensorRSS3BStateChanged(void) { sts_o7_sensorData.event_sensor3_fall_start_time_stamp = time_stamp; sts_o7_sensorData.event_sensor3_fall_start_time = sensor_event_time.Seconds; + + //start counter of fall after rising up or other release actions/states sts_o7_sensorData.event_sensor3_fall_duration = 0; + sts_o7_sensorData.event_sensor3_fall_stop_time_stamp = 0; + sts_o7_sensorData.event_sensor3_fall_stop_time = 0; } break; diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index d6d0328..28af51c 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -70,7 +70,7 @@ volatile uint8_t sts_unconscious_or_motionless_level_threshold=6; //6*128 volatile uint8_t sts_motionless_duration_threshold_in_min=1; // test mode, 1 min, normal 10 min. long occupation 30 min volatile uint16_t sts_unconscious_level_threshold=600; volatile uint8_t sts_alarm_mute_reset_timer_in_10sec=6; -extern volatile uint8_t sts_fall_rising_detected_result, sts_fall_rising_detected_result_changed_flag; +extern volatile uint8_t sts_fall_rising_detected_result, sts_fall_rising_detected_result_changed_flag, last_sts_fall_rising_detected_result; extern volatile uint32_t event_start_time, event_stop_time; extern volatile uint16_t sts_unconscious_threshold; volatile uint8_t sts_occupancy_overtime_state = 0; @@ -1042,12 +1042,12 @@ static void SendTxData(void) strcpy(colorshow, (ich==0)?"":sts_lamp_color_code[ich]); APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color = %s%s | Mode = %5s |\r\n",(char *)colorshow, sts_lamp_color_code[icl], (char*)sts_work_mode_code[sensorData.workmode]); + "\r\n######| Color = %s%s | Mode = %5s |\r\n",(char *)colorshow, sts_lamp_color_code[icl], (char*)sts_work_mode_code[sts_work_mode]); if (sts_work_mode == STS_UNI_MODE) { APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| S1-Door | S2-SOS | S3-Motion | S4 |Distance(mm) | MotionScore| Unconscious | Over_Stay_(min) | Fall Detected|" - "\r\n######| %s | %s | %d | %1d | %04d | %04d | %1d | %4d | %s |\r\n", + "\r\n######| S1-Door | S2-SOS | S3-Motion| S4 |Distance(mm) | MotionScore| Unconscious | Over_Stay_(min) | Fall Detected|" + "\r\n######| %s | %s | %d | %1d | %04d | %04d | %1d | %4d | %s |\r\n", sts_door_status_code[sensorData.state_sensor1_on_off], sts_sos_status_code[sensorData.state_sensor2_on_off], sensorData.state_sensor3_on_off, @@ -1274,6 +1274,12 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context) case STS_PRESENCE_NORMAL: sts_o7_sensorData.fall_state = STS_PRESENCE_NORMAL; sts_o7_sensorData.fall_laydown_duration=0; + if (last_sts_fall_rising_detected_result == STS_PRESENCE_FALL) + { + sts_o7_sensorData.event_sensor3_fall_stop_time_stamp = time_stamp; + sts_o7_sensorData.fall_laydown_duration = sts_o7_sensorData.event_sensor3_fall_duration; + } + sts_o7_sensorData.unconscious_state =STS_PRESENCE_NORMAL; sts_o7_sensorData.unconscious_duration =0; sts_o7_sensorData.no_movement_duration =0;