--- add SOS/Fall timestamp ----
This commit is contained in:
parent
47ca6726e7
commit
75c207ed73
|
@ -190,23 +190,31 @@ typedef struct STS_OO_SensorStatusDataTypeDef
|
||||||
uint32_t event_sensor1_start_time;
|
uint32_t event_sensor1_start_time;
|
||||||
uint32_t event_sensor1_stop_time;
|
uint32_t event_sensor1_stop_time;
|
||||||
uint32_t event_sensor1_duration;
|
uint32_t event_sensor1_duration;
|
||||||
|
|
||||||
uint32_t event_sensor2_start_time;
|
uint32_t event_sensor2_start_time;
|
||||||
|
uint32_t event_sensor2_start_timestamp;
|
||||||
uint32_t event_sensor2_stop_time;
|
uint32_t event_sensor2_stop_time;
|
||||||
|
uint32_t event_sensor2_stop_timestamp;
|
||||||
uint32_t event_sensor2_duration;
|
uint32_t event_sensor2_duration;
|
||||||
|
|
||||||
uint32_t event_sensor3_motion_start_time;
|
uint32_t event_sensor3_motion_start_time;
|
||||||
uint32_t event_sensor3_motion_stop_time;
|
uint32_t event_sensor3_motion_stop_time;
|
||||||
uint32_t event_sensor3_motion_duration;
|
uint32_t event_sensor3_motion_duration;
|
||||||
|
|
||||||
uint32_t event_sensor3_fall_start_time;
|
uint32_t event_sensor3_fall_start_time;
|
||||||
uint32_t event_sensor3_fall_start_time_stamp;
|
uint32_t event_sensor3_fall_start_time_stamp;
|
||||||
uint32_t event_sensor3_fall_stop_time_stamp;
|
uint32_t event_sensor3_fall_stop_time_stamp;
|
||||||
uint32_t event_sensor3_fall_stop_time;
|
uint32_t event_sensor3_fall_stop_time;
|
||||||
uint32_t event_sensor3_fall_duration;
|
uint32_t event_sensor3_fall_duration;
|
||||||
|
|
||||||
uint32_t event_sensor3_no_movement_start_time;
|
uint32_t event_sensor3_no_movement_start_time;
|
||||||
uint32_t event_sensor3_no_movement_stop_time;
|
uint32_t event_sensor3_no_movement_stop_time;
|
||||||
uint32_t event_sensor3_no_movement_duration;
|
uint32_t event_sensor3_no_movement_duration;
|
||||||
|
|
||||||
uint32_t event_sensor3_unconcious_start_time;
|
uint32_t event_sensor3_unconcious_start_time;
|
||||||
uint32_t event_sensor3_unconcious_stop_time;
|
uint32_t event_sensor3_unconcious_stop_time;
|
||||||
uint32_t event_sensor3_unconcious_duration;
|
uint32_t event_sensor3_unconcious_duration;
|
||||||
|
|
||||||
uint32_t event_sensor4_start_time;
|
uint32_t event_sensor4_start_time;
|
||||||
uint32_t event_sensor4_stop_time;
|
uint32_t event_sensor4_stop_time;
|
||||||
uint32_t event_sensor4_duration;
|
uint32_t event_sensor4_duration;
|
||||||
|
@ -674,7 +682,7 @@ void OnSensor3AStateChanged(void);
|
||||||
void OnSensor3BStateChanged(void);
|
void OnSensor3BStateChanged(void);
|
||||||
void OnSensor3CStateChanged(void);
|
void OnSensor3CStateChanged(void);
|
||||||
void OnSensor4StateChanged(void);
|
void OnSensor4StateChanged(void);
|
||||||
void STS_Get_Date_Time_Stamp(uint32_t *time_stamp, uint8_t *datetimestamp);
|
uint32_t STS_Get_Date_Time_Stamp(void);//uint32_t *time_stamp, uint8_t *datetimestamp);
|
||||||
void STS_SENSOR_Power_ON(uint8_t cnt);
|
void STS_SENSOR_Power_ON(uint8_t cnt);
|
||||||
void STS_SENSOR_Power_OFF(uint8_t cnt);
|
void STS_SENSOR_Power_OFF(uint8_t cnt);
|
||||||
void STS_SENSOR_MEMS_Reset(uint8_t cnt);
|
void STS_SENSOR_MEMS_Reset(uint8_t cnt);
|
||||||
|
|
|
@ -696,8 +696,12 @@ void STS_PRESENCE_SENSOR_Init_Send_Data(void)
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor1_start_time = 0x0;
|
sts_o7_sensorData.event_sensor1_start_time = 0x0;
|
||||||
sts_o7_sensorData.event_sensor1_duration = 0x0;
|
sts_o7_sensorData.event_sensor1_duration = 0x0;
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor2_start_time = 0x0;
|
sts_o7_sensorData.event_sensor2_start_time = 0x0;
|
||||||
sts_o7_sensorData.event_sensor2_duration = 0x0;
|
sts_o7_sensorData.event_sensor2_duration = 0x0;
|
||||||
|
sts_o7_sensorData.event_sensor2_start_timestamp = 0x0;
|
||||||
|
sts_o7_sensorData.event_sensor2_stop_timestamp = 0x0;
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor3_motion_start_time = 0x0;
|
sts_o7_sensorData.event_sensor3_motion_start_time = 0x0;
|
||||||
sts_o7_sensorData.event_sensor3_motion_duration = 0x0;
|
sts_o7_sensorData.event_sensor3_motion_duration = 0x0;
|
||||||
sts_o7_sensorData.event_sensor3_fall_start_time = 0x0;
|
sts_o7_sensorData.event_sensor3_fall_start_time = 0x0;
|
||||||
|
@ -721,6 +725,9 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
|
||||||
sensor_data->state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read
|
sensor_data->state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read
|
||||||
sensor_data->state_sensor4_on_off = sts_rss_2nd_result;
|
sensor_data->state_sensor4_on_off = sts_rss_2nd_result;
|
||||||
|
|
||||||
|
sensor_data->event_sensor2_start_timestamp = sts_o7_sensorData.event_sensor2_start_timestamp;
|
||||||
|
sensor_data->event_sensor2_stop_timestamp = sts_o7_sensorData.event_sensor2_stop_timestamp;
|
||||||
|
|
||||||
if (sts_rss_result == STS_RESULT_MOTION)
|
if (sts_rss_result == STS_RESULT_MOTION)
|
||||||
{
|
{
|
||||||
sensor_data->rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF;
|
sensor_data->rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF;
|
||||||
|
@ -810,17 +817,23 @@ void STS_PRESENCE_SENSOR_Init(void)
|
||||||
sts_o7_sensorData.event_sensor1_start_time = 0;
|
sts_o7_sensorData.event_sensor1_start_time = 0;
|
||||||
sts_o7_sensorData.event_sensor1_stop_time = 0;
|
sts_o7_sensorData.event_sensor1_stop_time = 0;
|
||||||
sts_o7_sensorData.event_sensor1_duration = 0;
|
sts_o7_sensorData.event_sensor1_duration = 0;
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor2_start_time = 0;
|
sts_o7_sensorData.event_sensor2_start_time = 0;
|
||||||
sts_o7_sensorData.event_sensor2_stop_time = 0;
|
sts_o7_sensorData.event_sensor2_stop_time = 0;
|
||||||
sts_o7_sensorData.event_sensor2_duration = 0;
|
sts_o7_sensorData.event_sensor2_duration = 0;
|
||||||
|
sts_o7_sensorData.event_sensor2_start_timestamp = 0;
|
||||||
|
sts_o7_sensorData.event_sensor2_stop_timestamp = 0;
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor3_motion_start_time = 0;
|
sts_o7_sensorData.event_sensor3_motion_start_time = 0;
|
||||||
sts_o7_sensorData.event_sensor3_motion_stop_time = 0;
|
sts_o7_sensorData.event_sensor3_motion_stop_time = 0;
|
||||||
sts_o7_sensorData.event_sensor3_motion_duration = 0;
|
sts_o7_sensorData.event_sensor3_motion_duration = 0;
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor3_fall_start_time = 0;
|
sts_o7_sensorData.event_sensor3_fall_start_time = 0;
|
||||||
sts_o7_sensorData.event_sensor3_fall_start_time_stamp = 0;
|
sts_o7_sensorData.event_sensor3_fall_start_time_stamp = 0;
|
||||||
sts_o7_sensorData.event_sensor3_fall_stop_time = 0;
|
sts_o7_sensorData.event_sensor3_fall_stop_time = 0;
|
||||||
sts_o7_sensorData.event_sensor3_fall_stop_time_stamp = 0;
|
sts_o7_sensorData.event_sensor3_fall_stop_time_stamp = 0;
|
||||||
sts_o7_sensorData.event_sensor3_fall_duration = 0;
|
sts_o7_sensorData.event_sensor3_fall_duration = 0;
|
||||||
|
|
||||||
sts_o7_sensorData.event_sensor4_start_time = 0;
|
sts_o7_sensorData.event_sensor4_start_time = 0;
|
||||||
sts_o7_sensorData.event_sensor4_stop_time = 0;
|
sts_o7_sensorData.event_sensor4_stop_time = 0;
|
||||||
sts_o7_sensorData.event_sensor4_duration = 0;
|
sts_o7_sensorData.event_sensor4_duration = 0;
|
||||||
|
@ -1101,15 +1114,19 @@ void OnSensor1StateChanged(void)
|
||||||
void OnSensor2StateChanged(void)
|
void OnSensor2StateChanged(void)
|
||||||
{
|
{
|
||||||
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
||||||
|
uint32_t time_stamp=STS_Get_Date_Time_Stamp();
|
||||||
|
|
||||||
if (sts_hall2_read==STS_Status_SOS_Pushdown)
|
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_time = sensor_event_time.Seconds;
|
||||||
|
sts_o7_sensorData.event_sensor2_start_timestamp = time_stamp;
|
||||||
sts_o7_sensorData.event_sensor2_duration = 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 );
|
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)
|
}else if (sts_hall2_read==STS_Status_SOS_Release)
|
||||||
{
|
{
|
||||||
sts_o7_sensorData.event_sensor2_start_time =0;
|
sts_o7_sensorData.event_sensor2_start_time =0;
|
||||||
sts_o7_sensorData.event_sensor2_stop_time = sensor_event_time.Seconds;
|
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.over_stay_state = 0;
|
||||||
//sts_o7_sensorData.event_sensor2_duration = 0;
|
//sts_o7_sensorData.event_sensor2_duration = 0;
|
||||||
}
|
}
|
||||||
|
@ -1170,6 +1187,8 @@ void OnSensor3AStateChanged(void)
|
||||||
void OnSensor3BStateChanged(void)
|
void OnSensor3BStateChanged(void)
|
||||||
{
|
{
|
||||||
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
||||||
|
uint32_t time_stamp=STS_Get_Date_Time_Stamp();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter
|
if ((sensor_event_time.Seconds - last_sts_rss_time_stamp) < 3 ) //less than 3 seconds ... return for flipping filter
|
||||||
{
|
{
|
||||||
|
@ -1184,6 +1203,7 @@ void OnSensor3BStateChanged(void)
|
||||||
|
|
||||||
case STS_PRESENCE_FALL:
|
case STS_PRESENCE_FALL:
|
||||||
if (motion_in_hs_zone[0][motion_detected_count]) {
|
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_start_time = sensor_event_time.Seconds;
|
||||||
sts_o7_sensorData.event_sensor3_fall_duration = 0;
|
sts_o7_sensorData.event_sensor3_fall_duration = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -987,15 +987,26 @@ static void SendTxData(void)
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_speed)&0xff; //18 fall detected speed
|
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_speed)&0xff; //18 fall detected speed
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_gravity)&0xff; //19 fall detected gravity
|
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_gravity)&0xff; //19 fall detected gravity
|
||||||
|
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp>>24)&0xff; //20 fall start time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_start_timestamp>>24)&0xff; //20 fall start time stamp
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp>>16)&0xff; //21 fall start time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_start_timestamp>>16)&0xff; //21 fall start time stamp
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp>>8)&0xff; //22 fall start time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_start_timestamp>>8)&0xff; //22 fall start time stamp
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp)&0xff; //23 fall start time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_start_timestamp)&0xff; //23 fall start time stamp
|
||||||
|
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp>>24)&0xff; //20 fall stop time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_stop_timestamp>>24)&0xff; //24 fall start time stamp
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp>>16)&0xff; //21 fall stop time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_stop_timestamp>>16)&0xff; //25 fall start time stamp
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp>>8)&0xff; //22 fall stop time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_stop_timestamp>>8)&0xff; //26 fall start time stamp
|
||||||
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp)&0xff; //23 fall stop time stamp
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor2_stop_timestamp)&0xff; //27 fall start time stamp
|
||||||
|
|
||||||
|
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp>>24)&0xff; //28 fall start time stamp
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp>>16)&0xff; //29 fall start time stamp
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp>>8)&0xff; //30 fall start time stamp
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_start_time_stamp)&0xff; //31 fall start time stamp
|
||||||
|
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp>>24)&0xff; //32 fall stop time stamp
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp>>16)&0xff; //33 fall stop time stamp
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp>>8)&0xff; //34 fall stop time stamp
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sensorData.event_sensor3_fall_stop_time_stamp)&0xff; //35 fall stop time stamp
|
||||||
|
|
||||||
}
|
}
|
||||||
uint8_t ich= (sts_lamp_bar_color>>4 & 0x0f);
|
uint8_t ich= (sts_lamp_bar_color>>4 & 0x0f);
|
||||||
|
@ -1264,8 +1275,8 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||||
STS_PRESENCE_UNCONSCIOUS,
|
STS_PRESENCE_UNCONSCIOUS,
|
||||||
STS_PRESENCE_STAYSTILL
|
STS_PRESENCE_STAYSTILL
|
||||||
*/
|
*/
|
||||||
uint32_t time_stamp=0; uint8_t datetimestamp[8]={0};
|
uint32_t time_stamp=STS_Get_Date_Time_Stamp(); //uint8_t datetimestamp[8]={0};
|
||||||
STS_Get_Date_Time_Stamp(&time_stamp, datetimestamp);
|
//(&time_stamp, datetimestamp);
|
||||||
|
|
||||||
switch (sts_fall_rising_detected_result){
|
switch (sts_fall_rising_detected_result){
|
||||||
case STS_PRESENCE_NORMAL:
|
case STS_PRESENCE_NORMAL:
|
||||||
|
@ -1281,7 +1292,7 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||||
if (sts_o7_sensorData.event_sensor3_fall_duration > 10*sts_cfg_nvm.fall_confirm_threshold_in_10sec)
|
if (sts_o7_sensorData.event_sensor3_fall_duration > 10*sts_cfg_nvm.fall_confirm_threshold_in_10sec)
|
||||||
{
|
{
|
||||||
//sts_o7_sensorData.occupancy_over_stay_state = 1;
|
//sts_o7_sensorData.occupancy_over_stay_state = 1;
|
||||||
sts_o7_sensorData.event_sensor3_fall_start_time_stamp = time_stamp;
|
//sts_o7_sensorData.event_sensor3_fall_start_time_stamp = time_stamp;
|
||||||
sts_o7_sensorData.fall_state = sts_fall_rising_detected_result;
|
sts_o7_sensorData.fall_state = sts_fall_rising_detected_result;
|
||||||
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
|
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
|
||||||
over_threshold = TRUE;
|
over_threshold = TRUE;
|
||||||
|
@ -2913,7 +2924,7 @@ void STS_SENSOR_Function_Test_Process(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STS_Get_Date_Time_Stamp(uint32_t *time_stamp, uint8_t *datetimestamp)
|
uint32_t STS_Get_Date_Time_Stamp(void) //uint32_t *time_stamp, uint8_t *datetimestamp)
|
||||||
{
|
{
|
||||||
struct tm localtime;
|
struct tm localtime;
|
||||||
|
|
||||||
|
@ -2921,11 +2932,15 @@ void STS_Get_Date_Time_Stamp(uint32_t *time_stamp, uint8_t *datetimestamp)
|
||||||
UnixEpoch.Seconds -= 18; /*removing leap seconds*/
|
UnixEpoch.Seconds -= 18; /*removing leap seconds*/
|
||||||
SysTimeLocalTime(UnixEpoch.Seconds, &localtime);
|
SysTimeLocalTime(UnixEpoch.Seconds, &localtime);
|
||||||
|
|
||||||
*time_stamp = UnixEpoch.Seconds;
|
//*time_stamp = (uint32_t)UnixEpoch.Seconds;
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "LTIME:%02dh%02dm%02ds on %02d/%02d/%04d\r\n",
|
APP_LOG(TS_OFF, VLEVEL_L, "LTIME:%02dh%02dm%02ds on %02d/%02d/%04d\r\n",
|
||||||
localtime.tm_hour, localtime.tm_min, localtime.tm_sec,
|
localtime.tm_hour, localtime.tm_min, localtime.tm_sec,
|
||||||
localtime.tm_mday, localtime.tm_mon + 1, localtime.tm_year + 1900);
|
localtime.tm_mday, localtime.tm_mon + 1, localtime.tm_year + 1900);
|
||||||
|
|
||||||
|
return (uint32_t)UnixEpoch.Seconds;
|
||||||
|
|
||||||
|
#if 0
|
||||||
datetimestamp[0] = localtime.tm_hour;
|
datetimestamp[0] = localtime.tm_hour;
|
||||||
datetimestamp[1] = localtime.tm_min;
|
datetimestamp[1] = localtime.tm_min;
|
||||||
datetimestamp[2] = localtime.tm_sec;
|
datetimestamp[2] = localtime.tm_sec;
|
||||||
|
@ -2934,4 +2949,6 @@ void STS_Get_Date_Time_Stamp(uint32_t *time_stamp, uint8_t *datetimestamp)
|
||||||
datetimestamp[4] = localtime.tm_mon+1;
|
datetimestamp[4] = localtime.tm_mon+1;
|
||||||
datetimestamp[5] = ((localtime.tm_year+1900)>>8)&0xff;
|
datetimestamp[5] = ((localtime.tm_year+1900)>>8)&0xff;
|
||||||
datetimestamp[6] = ((localtime.tm_year+1900))&0xff;
|
datetimestamp[6] = ((localtime.tm_year+1900))&0xff;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue