From b0ddf93ed803c2f23dcd3b9a56e7bf554a9100e6 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Thu, 25 Jul 2024 13:57:14 +0800 Subject: [PATCH] --- revise presence normal vs presence staystill threshold --- Core/Inc/yunhorn_sts_sensors.h | 1 + Core/Src/yunhorn_sts_presence_rss.c | 11 +++++++---- Core/Src/yunhorn_sts_process.c | 15 ++++++++++++--- LoRaWAN/App/lora_app.c | 13 +++++++++++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 8e6e786..8a56233 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -181,6 +181,7 @@ typedef struct STS_OO_SensorStatusDataTypeDef uint32_t over_stay_duration; // sensor 1, door lock or door contact, time lenght of overstay in seconds uint16_t occupancy_duration; // sensor 3, motion detection duration uint32_t fall_laydown_duration; // sensor 3, fall down not rise up duration + uint8_t no_movement_state; uint32_t no_movement_duration; uint8_t occupancy_over_stay_state; // uint8_t battery_Pct; /* % of battery two digits, 88% (00-99)% */ diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index a03f111..884e182 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -722,9 +722,12 @@ void STS_YunhornCheckStandardDeviation(void) // ******************************************* // *********** detection situation suggestion - if (standard_variance_presence_score <= MIN(DEFAULT_UNCONSCIOUS_THRESHOLD, sts_unconscious_threshold)) { - //sts_fall_rising_detected_result = STS_PRESENCE_STAYSTILL; - sts_fall_rising_detected_result = STS_PRESENCE_NO_MOVEMENT; + if ((standard_variance_presence_score > DEFAULT_UNCONSCIOUS_THRESHOLD) && (standard_variance_presence_score <= sts_unconscious_threshold)) + { + sts_fall_rising_detected_result = STS_PRESENCE_STAYSTILL; + //sts_fall_rising_detected_result = STS_PRESENCE_NO_MOVEMENT; + } else { + sts_fall_rising_detected_result = STS_PRESENCE_NORMAL; } if ( sts_fall_rising_pattern_factor1 > (uint16_t)sts_fall_detection_acc_threshold) @@ -755,7 +758,7 @@ void STS_YunhornCheckStandardDeviation(void) if ( sts_fall_rising_detected_result == STS_PRESENCE_FALL ) { - APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n >>>>>>>>>>>>>>>>> Suspecious Object FALL DOWN detected \r\n"); + APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n >>>>>>>>>>>>>>>>> Suspicious Object FALL DOWN detected \r\n"); } //if (average_presence_distance > DEFAULT_START_M) { diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 1d32d4f..0a9b678 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -120,7 +120,8 @@ char sts_presence_fall_detection_message[10][20]={ "State_Rising_Up", "State_Laydown", "State_Unconscious", - "State_StayStill" + "State_StayStill", + "State_No_Movement" }; #endif @@ -698,6 +699,7 @@ void STS_PRESENCE_SENSOR_Init_Send_Data(void) sts_o7_sensorData.over_stay_state = 0x0; sts_o7_sensorData.over_stay_duration = 0x0; sts_o7_sensorData.unconscious_state = 0x0; + sts_o7_sensorData.no_movement_state = 0x0; sts_o7_sensorData.unconscious_duration = 0x0; sts_o7_sensorData.no_movement_duration = 0x0; @@ -739,8 +741,12 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso } // no_movement or unconcious duration - sensor_data->unconscious_state = (sts_fall_rising_detected_result == STS_PRESENCE_UNCONSCIOUS)? 1:0; + sensor_data->unconscious_state = ((sts_fall_rising_detected_result == STS_PRESENCE_UNCONSCIOUS) || + (sts_fall_rising_detected_result==STS_PRESENCE_STAYSTILL) || + (sts_fall_rising_detected_result==STS_PRESENCE_NO_MOVEMENT))? 1:0; sensor_data->unconscious_duration = sts_o7_sensorData.event_sensor3_unconcious_duration; + + sensor_data->no_movement_state = sensor_data->unconscious_state; sensor_data->no_movement_duration = sts_o7_sensorData.event_sensor3_no_movement_duration; if (sensor_data->unconscious_state !=0) { @@ -823,9 +829,12 @@ void STS_PRESENCE_SENSOR_Init(void) sts_o7_sensorData.over_stay_state = 0; sts_o7_sensorData.over_stay_duration = 0; - sts_o7_sensorData.unconscious_duration = 0; + + sts_o7_sensorData.no_movement_state = 0; sts_o7_sensorData.no_movement_duration = 0; + sts_o7_sensorData.unconscious_state = 0; + sts_o7_sensorData.unconscious_duration = 0; STS_SENSOR_Power_ON(0); STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init(); diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index d6321b7..983cc8a 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -188,6 +188,15 @@ char sts_work_mode_code[15][25] ={ "OTHER_MODE1", "OTHER_MODE2", }; +char sts_fall_mode_code[8][25] = { + "State_Normal", + "State_Fall_Down", + "State_Rising_Up", + "State_Laydown", + "State_Unconscious", + "State_StayStill", + "State_No_Movement" +}; #endif /* USER CODE END EV */ @@ -990,10 +999,10 @@ static void SendTxData(void) { APP_LOG(TS_OFF, VLEVEL_L, "\r\n######| S1-Door | S2-Motion | S3-SOS | S4 |Distance(mm) | MotionScore| Unconscious | Over_Stay_(min) | Fall Detected|" - "\r\n######| %s | %1d | %s | %1d | %04d | %04d | %1d | %4d | %1d |\r\n", + "\r\n######| %s | %1d | %s | %1d | %04d | %04d | %1d | %4d | %s |\r\n", sts_door_status_code[sensorData.state_sensor1_on_off], sensorData.state_sensor2_on_off,sts_sos_status_code[sensorData.state_sensor3_on_off], sensorData.state_sensor4_on_off, (uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score, - sensorData.unconscious_state, sensorData.over_stay_duration, sensorData.fall_state ); + sensorData.unconscious_state, sensorData.over_stay_duration, sts_fall_mode_code[sensorData.fall_state]); } else if (sts_work_mode == STS_DUAL_MODE) { APP_LOG(TS_OFF, VLEVEL_L,