--- add over threshold event trigger sendtxdata

This commit is contained in:
Yunhorn 2024-07-22 13:28:38 +08:00
parent 8a6851c32d
commit 01dc003367
3 changed files with 32 additions and 19 deletions

View File

@ -629,6 +629,12 @@ typedef struct sts_cfg_nvm {
uint8_t ac[YUNHORN_STS_AC_CODE_SIZE]; // authorization code, 20 bytes MCU UUID coded
} sts_cfg_nvm_t;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/**
* @brief Store/Write/Flash Configuration in RW RAM
*/

View File

@ -433,16 +433,14 @@ int sts_presence_rss_fall_rise_detection(void)
motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++;
}
if (sts_presence_fall_detection == 1)
{
sts_motion_dataset[motion_count].presence_distance = result.presence_distance;
sts_motion_dataset[motion_count].presence_score = result.presence_score;
if (sts_presence_fall_detection == TRUE)
{
if (motion_count ++ == DEFAULT_MOTION_DATASET_LEN)
{
STS_YunhornCheckStandardDeviation();
// STS_YunhornCheckStandardDeviation(); no Deviation in middle 2024 -7-22
motion_count = 0;
}
}
@ -457,7 +455,7 @@ int sts_presence_rss_fall_rise_detection(void)
#endif
// ******** Second Half detection of fall down and rise up
//if (sts_presence_fall_detection == 1)
//if (sts_presence_fall_detection == TRUE)
//{
set_default_fall_rise_configuration(presence_configuration);
@ -508,7 +506,7 @@ int sts_presence_rss_fall_rise_detection(void)
}
if (sts_presence_fall_detection == 1)
if (sts_presence_fall_detection == TRUE)
{
sts_motion_dataset[motion_count].presence_distance = result.presence_distance;
sts_motion_dataset[motion_count].presence_score = result.presence_score;

View File

@ -71,7 +71,7 @@ extern volatile uint8_t 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;
volatile uint8_t sts_presence_fall_detection=1;
volatile uint8_t sts_presence_fall_detection=TRUE;
volatile uint32_t SamplingPeriodicity = 3000; //unit ms
volatile uint32_t HeartBeatPeriodicity = 120000; //unit ms
volatile uint8_t STS_LoRa_WAN_Joined = 0;
@ -1150,6 +1150,7 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
static void OnYunhornSTSDurationCheckTimerEvent(void *context)
{
static bool over_threshold = FALSE;
SysTime_t current_time = SysTimeGetMcuTime();
@ -1162,7 +1163,7 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
{
sts_o7_sensorData.over_stay_state = 1;
sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor1_duration;
over_threshold = TRUE;
APP_LOG(TS_OFF, VLEVEL_L, "\r\nSensor 1 Over Stay State=%d, Duration= %d Sec, Threshold =%u \r\n", sts_o7_sensorData.over_stay_state,(sts_o7_sensorData.over_stay_duration),(sts_occupancy_overtime_threshold_in_10min*60) );
sts_lamp_bar_color = STS_RED_DARK;
//sts_lamp_bar_flashing_color = 0x20;
@ -1186,6 +1187,7 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
// 2024-07-15 update, no overwrite sensor1 duration value
//sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor2_duration;
//
over_threshold = TRUE;
}
// to be defiend later for SOS threshold TODO XXXX
@ -1203,6 +1205,7 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
{
sts_o7_sensorData.occupancy_over_stay_state = 1;
sts_o7_sensorData.occupancy_duration =sts_o7_sensorData.event_sensor3_motion_duration;
over_threshold = TRUE;
}
} else {
sts_o7_sensorData.event_sensor3_motion_duration =0;
@ -1232,6 +1235,7 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
//sts_o7_sensorData.occupancy_over_stay_state = 1;
sts_o7_sensorData.fall_state = sts_fall_rising_detected_result;
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
over_threshold = TRUE;
}
break;
@ -1255,6 +1259,11 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
sts_o7_sensorData.event_sensor3_event_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor4_start_time;
#endif
if (over_threshold == TRUE) {
sensor_data_ready = 1;
SendTxData();
}
}
@ -2217,7 +2226,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
{
if ((sts_fall_detection_acc_threshold ==0)&&(sts_fall_detection_depth_threshold==0))
{
sts_presence_fall_detection = 0;
sts_presence_fall_detection = FALSE;
}
}
@ -2291,9 +2300,9 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
//sts_lamp_bar_color = STS_GREEN;
sts_cfg_nvm.work_mode = (uint8_t)sts_work_mode;
if (sts_work_mode == STS_UNI_MODE) {
sts_presence_fall_detection=1;
sts_presence_fall_detection=TRUE;
} else {
sts_presence_fall_detection=0;
sts_presence_fall_detection=FALSE;
}
sts_cfg_nvm.sts_service_mask = (uint8_t)sts_service_mask;
OnStoreSTSCFGContextRequest();
@ -2723,9 +2732,9 @@ void OnRestoreSTSCFGContextProcess(void)
sts_service_mask = sts_cfg_nvm.sts_service_mask;
sts_lamp_bar_flashing_color = sts_cfg_nvm.alarm_lamp_bar_flashing_color;
if (sts_work_mode == STS_UNI_MODE){
sts_presence_fall_detection =1;
sts_presence_fall_detection =TRUE;
} else {
sts_presence_fall_detection =0;
sts_presence_fall_detection =FALSE;
}
sts_sensor_install_height = sts_cfg_nvm.sensor_install_height_in_10cm*100; //10cm translate to mm
sts_fall_detection_acc_threshold = (uint8_t)sts_cfg_nvm.fall_detection_acc_threshold*10;