change to event type = event type instead of previos timer mode
This commit is contained in:
parent
e0bf60b742
commit
0b4c98ec16
|
@ -285,7 +285,8 @@ void STS_Combined_Status_Processing(void)
|
||||||
sts_status_color = STS_RED_BLUE;
|
sts_status_color = STS_RED_BLUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STS_UNI_MODE: //FOR STS-O7
|
case STS_UNI_MODE: //FOR STS-O7
|
||||||
if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release ))
|
if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release ))
|
||||||
{
|
{
|
||||||
|
@ -294,7 +295,10 @@ void STS_Combined_Status_Processing(void)
|
||||||
} else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown ))
|
} else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown ))
|
||||||
{
|
{
|
||||||
sts_status_color = STS_RED;
|
sts_status_color = STS_RED;
|
||||||
switch(sts_fall_rising_detected_result) {
|
}
|
||||||
|
|
||||||
|
switch(sts_fall_rising_detected_result)
|
||||||
|
{
|
||||||
case STS_PRESENCE_LAYDOWN:
|
case STS_PRESENCE_LAYDOWN:
|
||||||
sts_lamp_bar_color = STS_YELLOW;
|
sts_lamp_bar_color = STS_YELLOW;
|
||||||
sts_status_color = STS_YELLOW;
|
sts_status_color = STS_YELLOW;
|
||||||
|
@ -302,18 +306,23 @@ void STS_Combined_Status_Processing(void)
|
||||||
case STS_PRESENCE_FALL: //RED_BLUE FLASH
|
case STS_PRESENCE_FALL: //RED_BLUE FLASH
|
||||||
sts_lamp_bar_color = STS_RED_BLUE;
|
sts_lamp_bar_color = STS_RED_BLUE;
|
||||||
sts_status_color = STS_RED_BLUE;
|
sts_status_color = STS_RED_BLUE;
|
||||||
break;
|
break;
|
||||||
case STS_PRESENCE_RISING: //NORMAL OCCUPANCY STATUS
|
case STS_PRESENCE_RISING: //NORMAL OCCUPANCY STATUS
|
||||||
sts_lamp_bar_color = STS_RED;
|
sts_lamp_bar_color = STS_RED;
|
||||||
sts_status_color = STS_RED;
|
sts_status_color = STS_RED;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown )
|
sts_lamp_bar_color = STS_RED;
|
||||||
{
|
sts_status_color = STS_RED;
|
||||||
sts_status_color = STS_RED_BLUE;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown )
|
||||||
|
{
|
||||||
|
sts_status_color = STS_RED_BLUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case STS_REMOTE_REED_RSS_MODE:
|
case STS_REMOTE_REED_RSS_MODE:
|
||||||
if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_result == STS_Status_Door_Open ))
|
if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_result == STS_Status_Door_Open ))
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold;
|
extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold;
|
||||||
volatile uint8_t sts_unconcious_state=0;
|
volatile uint8_t sts_unconcious_state=0;
|
||||||
volatile uint16_t sts_unconcious_threshold=1280, sts_unconcious_duration=0;
|
volatile uint16_t sts_unconcious_threshold=1280, sts_unconcious_duration=0;
|
||||||
extern volatile uint8_t sts_rss_result, sts_rss_config_updated_flag;
|
extern volatile uint8_t sts_rss_result, sts_rss_config_updated_flag, last_sts_rss_result;
|
||||||
extern volatile float sts_distance_rss_distance;
|
extern volatile float sts_distance_rss_distance;
|
||||||
volatile float sts_presence_rss_distance, sts_presence_rss_score;
|
volatile float sts_presence_rss_distance, sts_presence_rss_score;
|
||||||
volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
|
volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config;
|
||||||
|
@ -413,7 +413,8 @@ int sts_presence_rss_fall_rise_detection(void)
|
||||||
APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
|
APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||||
#endif
|
#endif
|
||||||
// ******** Second Half detection of fall down and rise up
|
// ******** Second Half detection of fall down and rise up
|
||||||
|
if (sts_presence_fall_detection == 1)
|
||||||
|
{
|
||||||
set_default_fall_rise_configuration(presence_configuration);
|
set_default_fall_rise_configuration(presence_configuration);
|
||||||
|
|
||||||
if (!acc_detector_presence_reconfigure(&handle, presence_configuration))
|
if (!acc_detector_presence_reconfigure(&handle, presence_configuration))
|
||||||
|
@ -472,10 +473,19 @@ int sts_presence_rss_fall_rise_detection(void)
|
||||||
|
|
||||||
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||||
APP_LOG(TS_OFF, VLEVEL_H,"Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
APP_LOG(TS_OFF, VLEVEL_H,"Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||||
|
}
|
||||||
sts_rss_result = (average_result > 1)? 1: 0;
|
sts_rss_result = (average_result > 1)? 1: 0;
|
||||||
|
if ((last_sts_rss_result ==STS_RESULT_NO_MOTION)&& (sts_rss_result==STS_RESULT_MOTION))
|
||||||
|
{
|
||||||
|
OnSensor3StateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
OnSensor3StateChanged();
|
/* TODO XXXX 2024-06-06
|
||||||
|
*
|
||||||
|
* if (sts_rss_fall_rising_detected_result)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_H,"Average Motion Result = %u OUTPUT RSS RESULT=%u \r\n", (int)average_result, sts_rss_result);
|
APP_LOG(TS_OFF, VLEVEL_H,"Average Motion Result = %u OUTPUT RSS RESULT=%u \r\n", (int)average_result, sts_rss_result);
|
||||||
for (k=0; k<10; k++) {
|
for (k=0; k<10; k++) {
|
||||||
|
@ -620,6 +630,7 @@ void STS_YunhornCheckStandardDeviation(void)
|
||||||
(int)(sts_fall_detection_depth_threshold), (int)(sts_fall_rising_pattern_factor2));
|
(int)(sts_fall_detection_depth_threshold), (int)(sts_fall_rising_pattern_factor2));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// *********** detection suggestion
|
||||||
if (standard_variance_presence_score <= MIN(DEFAULT_UNCONCIOUS_THRESHOLD, sts_unconcious_threshold)) {
|
if (standard_variance_presence_score <= MIN(DEFAULT_UNCONCIOUS_THRESHOLD, sts_unconcious_threshold)) {
|
||||||
sts_fall_rising_detected_result = STS_PRESENCE_STAYSTILL;
|
sts_fall_rising_detected_result = STS_PRESENCE_STAYSTILL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ volatile uint8_t sts_rss_result_changed_flag = 0;
|
||||||
volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION;
|
volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION;
|
||||||
volatile uint8_t sts_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status
|
volatile uint8_t sts_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status
|
||||||
volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION;
|
volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION;
|
||||||
volatile uint8_t last_sts_rss_result=0;
|
volatile uint8_t last_sts_rss_result=STS_RESULT_NO_MOTION;
|
||||||
|
|
||||||
//extern volatile uint8_t last_sts_reed_hall_result;
|
//extern volatile uint8_t last_sts_reed_hall_result;
|
||||||
extern volatile uint8_t last_lamp_bar_color;
|
extern volatile uint8_t last_lamp_bar_color;
|
||||||
|
@ -847,7 +847,7 @@ void OnSensor1StateChanged(void)
|
||||||
if (sts_hall1_read==STS_Status_Door_Close)
|
if (sts_hall1_read==STS_Status_Door_Close)
|
||||||
{
|
{
|
||||||
sts_o7_sensorData.event_sensor1_start_time = sensor_event_time.Seconds;
|
sts_o7_sensorData.event_sensor1_start_time = sensor_event_time.Seconds;
|
||||||
sts_o7_sensorData.event_sensor1_duration = sensor_event_time.Seconds- sts_o7_sensorData.event_sensor1_start_time;
|
sts_o7_sensorData.event_sensor1_duration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,7 +857,7 @@ void OnSensor2StateChanged(void)
|
||||||
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_duration = sensor_event_time.Seconds- sts_o7_sensorData.event_sensor2_start_time;
|
sts_o7_sensorData.event_sensor2_duration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -867,7 +867,7 @@ void OnSensor3StateChanged(void)
|
||||||
if (sts_rss_result == STS_RESULT_MOTION)
|
if (sts_rss_result == STS_RESULT_MOTION)
|
||||||
{
|
{
|
||||||
sts_o7_sensorData.event_sensor3_start_time = sensor_event_time.Seconds;
|
sts_o7_sensorData.event_sensor3_start_time = sensor_event_time.Seconds;
|
||||||
sts_o7_sensorData.event_sensor3_duration = sensor_event_time.Seconds- sts_o7_sensorData.event_sensor3_start_time;
|
sts_o7_sensorData.event_sensor3_duration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -449,7 +449,7 @@ static LmHandlerParams_t LmHandlerParams =
|
||||||
/**
|
/**
|
||||||
* @brief Type of Event to generate application Tx
|
* @brief Type of Event to generate application Tx
|
||||||
*/
|
*/
|
||||||
static TxEventType_t EventType = TX_ON_TIMER;
|
static TxEventType_t EventType = TX_ON_EVENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Timer to handle the application Tx
|
* @brief Timer to handle the application Tx
|
||||||
|
@ -1077,22 +1077,30 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
||||||
|
|
||||||
static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||||
{
|
{
|
||||||
SysTime_t sensor_event_time = SysTimeGetMcuTime();
|
SysTime_t current_time = SysTimeGetMcuTime();
|
||||||
|
|
||||||
|
|
||||||
if (sts_hall1_read==STS_Status_Door_Close)
|
if (sts_hall1_read==STS_Status_Door_Close)
|
||||||
sts_o7_sensorData.event_sensor1_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor1_start_time;
|
sts_o7_sensorData.event_sensor1_duration = current_time.Seconds - sts_o7_sensorData.event_sensor1_start_time;
|
||||||
if (sts_o7_sensorData.event_sensor1_duration > sts_occupancy_overtime_threshold)
|
if (sts_o7_sensorData.event_sensor1_duration > sts_occupancy_overtime_threshold)
|
||||||
{
|
{
|
||||||
sts_o7_sensorData.over_stay_state = 1;
|
sts_o7_sensorData.over_stay_state = 1;
|
||||||
sts_o7_sensorData.over_stay_duration =sts_o7_sensorData.event_sensor1_duration;
|
sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor1_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to be defiend later for SOS threshold TODO XXXX
|
||||||
if (sts_hall2_read==STS_Status_SOS_Pushdown)
|
if (sts_hall2_read==STS_Status_SOS_Pushdown)
|
||||||
sts_o7_sensorData.event_sensor2_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor2_start_time;
|
sts_o7_sensorData.event_sensor2_duration = current_time.Seconds - sts_o7_sensorData.event_sensor2_start_time;
|
||||||
|
if (sts_o7_sensorData.event_sensor2_duration > sts_occupancy_overtime_threshold)
|
||||||
|
{
|
||||||
|
sts_o7_sensorData.over_stay_state = 1;
|
||||||
|
sts_o7_sensorData.over_stay_duration = sts_o7_sensorData.event_sensor2_duration;
|
||||||
|
}
|
||||||
|
// to be defiend later for SOS threshold TODO XXXX
|
||||||
|
|
||||||
|
|
||||||
if (sts_rss_result==STS_RESULT_MOTION)
|
if (sts_rss_result==STS_RESULT_MOTION)
|
||||||
sts_o7_sensorData.event_sensor3_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor3_start_time;
|
sts_o7_sensorData.event_sensor3_duration = current_time.Seconds - sts_o7_sensorData.event_sensor3_start_time;
|
||||||
if (sts_o7_sensorData.event_sensor3_duration > sts_occupancy_overtime_threshold)
|
if (sts_o7_sensorData.event_sensor3_duration > sts_occupancy_overtime_threshold)
|
||||||
{
|
{
|
||||||
sts_o7_sensorData.occupancy_over_stay_state = 1;
|
sts_o7_sensorData.occupancy_over_stay_state = 1;
|
||||||
|
@ -1286,7 +1294,7 @@ static void OnTxPeriodicityChanged(uint32_t periodicity)
|
||||||
UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
|
UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
|
||||||
UTIL_TIMER_Start(&TxTimer);
|
UTIL_TIMER_Start(&TxTimer);
|
||||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||||
APP_LOG(TS_OFF, VLEVEL_L,"**************** TxPeriodicity = %u (sec)\r\n", (TxPeriodicity/1000) );
|
APP_LOG(TS_OFF, VLEVEL_M,"**************** TxPeriodicity = %u (sec)\r\n", (TxPeriodicity/1000) );
|
||||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1510,7 +1518,7 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
|
||||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||||
|
|
||||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||||
APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity Changed to: %u (ms)\r\n", HeartBeatPeriodicity );
|
APP_LOG(TS_OFF, VLEVEL_M,"**************** HeartBeatPeriodicity Changed to: %u (ms)\r\n", HeartBeatPeriodicity );
|
||||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2484,7 +2492,7 @@ void OnRestoreSTSCFGContextProcess(void)
|
||||||
periodicity *= 1;
|
periodicity *= 1;
|
||||||
}
|
}
|
||||||
periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit
|
periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit
|
||||||
TxPeriodicity= periodicity*1000; // to ms
|
//TxPeriodicity= periodicity*1000; // to ms
|
||||||
//OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
//OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
||||||
|
|
||||||
uint32_t sampling = (sts_cfg_nvm.sampling);
|
uint32_t sampling = (sts_cfg_nvm.sampling);
|
||||||
|
@ -2503,13 +2511,14 @@ void OnRestoreSTSCFGContextProcess(void)
|
||||||
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
//OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
||||||
//Heart-beat or Sampling interval
|
//Heart-beat or Sampling interval
|
||||||
#ifdef STS_E0
|
#ifdef STS_E0
|
||||||
samplingperiodicity = (samplingperiodicity > 0)? samplingperiodicity : 1; // in seconds unit
|
samplingperiodicity = (samplingperiodicity > 0)? samplingperiodicity : 1; // in seconds unit
|
||||||
HeartBeatPeriodicity = samplingperiodicity*1000;
|
HeartBeatPeriodicity = samplingperiodicity*1000;
|
||||||
#endif
|
#endif
|
||||||
#if defined(STS_O7)|| defined(STS_O6) ||defined(STS_O5)
|
#if defined(STS_O7)|| defined(STS_O6) ||defined(STS_O5)
|
||||||
|
OnYunhornSTSHeartBeatPeriodicityChanged(periodicity*1000);
|
||||||
OnYunhornSTSSamplingPeriodicityChanged(sampling); // in m-sec unit
|
OnYunhornSTSSamplingPeriodicityChanged(sampling); // in m-sec unit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue