add fhmos config command parse and reporting
This commit is contained in:
parent
d0e4841fd8
commit
cc22e87c26
Binary file not shown.
|
@ -47,7 +47,10 @@ enum cfg_cmd_order{
|
|||
CFG_CMD3, // # Z {H, S, C} M {0,1,2,3,4]
|
||||
CFG_CMD4, // #
|
||||
CFG_CMD5, // 'S','M','H'
|
||||
CFG_CMD6
|
||||
CFG_CMD6,
|
||||
CFG_CMD7,
|
||||
CFG_CMD8,
|
||||
CFG_CMD9
|
||||
};
|
||||
enum p_cmd_order{
|
||||
P_CMD=0, //'P' //P_MTM_CODE, // #1
|
||||
|
@ -169,6 +172,14 @@ typedef struct sts_cfg_nvm {
|
|||
uint8_t alarm_parameter05;
|
||||
uint8_t alarm_mute_reset_timer_in_10sec; //60(0x3C) sec alarm_mute_or_reset_expire_timer_in_sec
|
||||
uint8_t alarm_lamp_bar_flashing_color; //Lamp Bar Flashing color define, 0x20, 2==STS_RED, 0 = STS_DARK, 0x23, 2=STS_RED, 3=STS_BLUE
|
||||
#ifdef L8
|
||||
uint8_t fhmos_cfg_1;
|
||||
uint8_t fhmos_cfg_2;
|
||||
uint8_t fhmos_cfg_3;
|
||||
uint8_t fhmos_cfg_4;
|
||||
uint8_t fhmos_cfg_5;
|
||||
uint8_t fhmos_cfg_6;
|
||||
#else
|
||||
uint8_t occupancy_overtime_threshold_in_10min; // 0 - 9: 0:disable, 1-9 occupy over time threshold * 10 min
|
||||
|
||||
uint8_t motionless_duration_threshold_in_min; // 10(0x0A) min (2 min.) motionless_duration_threshold_in_min
|
||||
|
@ -177,8 +188,9 @@ typedef struct sts_cfg_nvm {
|
|||
uint8_t fall_detection_acc_threshold; // 0 - 9: 0:disable: 1-9 accelaration mg/s2
|
||||
uint8_t fall_detection_depth_threshold; // 0 - 9: 0:disable: 1-9 fall down depth * 10 cm
|
||||
uint8_t fall_confirm_threshold_in_10sec; // 0-60(0x3C) Sec, or 3*10(0x03) sec default falldown_confirm_threshold_in_10sec
|
||||
|
||||
#endif
|
||||
uint8_t ac[YUNHORN_STS_AC_CODE_SIZE]; // authorization code, 20 bytes MCU UUID coded
|
||||
|
||||
} sts_cfg_nvm_t;
|
||||
|
||||
#ifndef TRUE
|
||||
|
@ -223,12 +235,23 @@ typedef struct sts_fhmos_sensor_data
|
|||
uint8_t fall_state; /* 0/blue: no occupy, 1/green:occupy yet normal, 2/yellow: suspicious state, 3/red: fall confirmed */
|
||||
uint8_t human_movement_state; /* 0/blue: no occupy, 1/green:occupy yet normal, 2/yellow: suspicious state, 3/red: fall confirmed */
|
||||
uint8_t occupancy_state; /* 0/blue: no occupy, 1/green:occupy yet normal, 3/red: over stay */
|
||||
uint8_t sos_alarm_state; /* 1/green, sos on-duty, 2/yellow, sos button pressed 3/red, alarm */
|
||||
uint8_t sos_alarm_state; /* 1/green, sos on-duty, 2/yellow, sos button pressed 3/red, alarm */
|
||||
uint8_t on_off_event; /* 1: liquid sensed, 0: no liquid sensed */
|
||||
|
||||
|
||||
} sts_fhmos_sensor_data_t;
|
||||
|
||||
typedef struct sts_fhmos_sensor_config
|
||||
{
|
||||
uint8_t sts_head_level_height_threshold_cm;
|
||||
uint8_t sts_fall_duration_threshold_potential_15sec;
|
||||
uint8_t sts_fall_duration_threshold_confirm_15sec;
|
||||
uint8_t sts_motionless_threshold_short_15sec;
|
||||
uint8_t sts_motionless_threshold_long_15sec;
|
||||
uint8_t sts_occupancy_threshold_overstay_15sec;
|
||||
|
||||
} sts_fhmos_sensor_config_t;
|
||||
|
||||
/**
|
||||
* @brief Store/Write/Flash Configuration in RW RAM
|
||||
*/
|
||||
|
@ -280,7 +303,7 @@ void STS_SENSOR_MEMS_Get_ID(uint16_t *devID);
|
|||
void STS_RR_Sensor_read(sts_tof_range_data_t *sts_rr_sensor_data);
|
||||
void STS_R4_sensor_read(sts_r_sensor_data_t *sts_r_sensor_data);
|
||||
void STS_M1_sensor_read(sts_r_sensor_data_t *sts_m_sensor_data);
|
||||
void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_fhmos_data);
|
||||
|
||||
void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity);
|
||||
void OnYunhornSTSTxPeriodicityChanged(uint32_t periodicity);
|
||||
void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_size);
|
||||
|
@ -289,6 +312,12 @@ void STS_SENSOR_Distance_Test_Process(void);
|
|||
void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_t count);
|
||||
void STS_PRESENCE_SENSOR_Distance_Measure_Process(void);
|
||||
|
||||
void STS_TOF_L8_Process(void);
|
||||
void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_fhmos_data);
|
||||
void STS_FHMOS_sensor_config_init(void);
|
||||
void STS_FHMOS_sensor_config_update(void);
|
||||
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
/*
|
||||
In this example TIM2 input clock (TIM2CLK) is set to APB1 clock (PCLK1),
|
||||
|
|
|
@ -51,6 +51,7 @@ extern volatile uint8_t sts_door_jam_profile;
|
|||
extern volatile uint8_t sts_tof_presence_state_changed;
|
||||
#elif defined(L8)
|
||||
#include "app_tof.h"
|
||||
extern volatile sts_fhmos_sensor_config_t sts_fhmos_cfg;
|
||||
#endif
|
||||
volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
||||
sts_mtmcode1,
|
||||
|
@ -591,6 +592,7 @@ void STS_O5_SENSOR_Read(STS_OO_SensorDataTypeDef *oo_data)
|
|||
|
||||
void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size)
|
||||
{
|
||||
uint8_t i=0;
|
||||
|
||||
switch (parse_buffer_size) {
|
||||
|
||||
|
@ -631,6 +633,43 @@ void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size)
|
|||
break;
|
||||
case 5:
|
||||
break;
|
||||
|
||||
// P11T XYYY for fall down, human movement, occupancy, SOS
|
||||
case 8:
|
||||
if ((parse_buffer[CFG_CMD4]=='T') && (parse_buffer[CFG_CMD5]>='0')&& (parse_buffer[CFG_CMD5]<='9'))
|
||||
{
|
||||
uint8_t sts_fhmos_cfg_index = (uint8_t)(parse_buffer[CFG_CMD5]-0x30);
|
||||
uint8_t sts_fhmos_cfg_value = (parse_buffer[CFG_CMD6]-0x30)*100+(parse_buffer[CFG_CMD7]-0x30)*10+(parse_buffer[CFG_CMD8]-0x30);
|
||||
switch (sts_fhmos_cfg_index) {
|
||||
case 1: // head level height threshold
|
||||
sts_fhmos_cfg.sts_head_level_height_threshold_cm = sts_fhmos_cfg_value;
|
||||
break;
|
||||
case 2:
|
||||
sts_fhmos_cfg.sts_fall_duration_threshold_potential_15sec = sts_fhmos_cfg_value;
|
||||
break;
|
||||
case 3:
|
||||
sts_fhmos_cfg.sts_fall_duration_threshold_confirm_15sec = sts_fhmos_cfg_value;
|
||||
break;
|
||||
case 4:
|
||||
sts_fhmos_cfg.sts_motionless_threshold_short_15sec = sts_fhmos_cfg_value;
|
||||
break;
|
||||
case 5:
|
||||
sts_fhmos_cfg.sts_motionless_threshold_long_15sec = sts_fhmos_cfg_value;
|
||||
break;
|
||||
case 6:
|
||||
sts_fhmos_cfg.sts_occupancy_threshold_overstay_15sec = sts_fhmos_cfg_value;
|
||||
break;
|
||||
}
|
||||
|
||||
OnStoreSTSCFGContextRequest();
|
||||
// 2024-11-18
|
||||
UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
|
||||
UTIL_MEM_cpy_8((void*)outbuf,(void*)parse_buffer,parse_buffer_size);
|
||||
i = parse_buffer_size;
|
||||
STS_SENSOR_Upload_Message(YUNHORN_STS_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
}
|
||||
break;
|
||||
|
||||
case 12:
|
||||
break;
|
||||
default:
|
||||
|
@ -1498,6 +1537,14 @@ void OnStoreSTSCFGContextRequest(void)
|
|||
to_store__value[i++] = sts_cfg_nvm.alarm_parameter05;
|
||||
to_store__value[i++] = sts_cfg_nvm.alarm_mute_reset_timer_in_10sec;
|
||||
to_store__value[i++] = sts_cfg_nvm.alarm_lamp_bar_flashing_color;
|
||||
#ifdef L8
|
||||
to_store__value[i++] = sts_cfg_nvm.fhmos_cfg_1;
|
||||
to_store__value[i++] = sts_cfg_nvm.fhmos_cfg_2;
|
||||
to_store__value[i++] = sts_cfg_nvm.fhmos_cfg_3;
|
||||
to_store__value[i++] = sts_cfg_nvm.fhmos_cfg_4;
|
||||
to_store__value[i++] = sts_cfg_nvm.fhmos_cfg_5;
|
||||
to_store__value[i++] = sts_cfg_nvm.fhmos_cfg_6;
|
||||
#else
|
||||
to_store__value[i++] = sts_cfg_nvm.occupancy_overtime_threshold_in_10min;
|
||||
|
||||
to_store__value[i++] = sts_cfg_nvm.motionless_duration_threshold_in_min;
|
||||
|
@ -1505,7 +1552,7 @@ void OnStoreSTSCFGContextRequest(void)
|
|||
to_store__value[i++] = sts_cfg_nvm.fall_detection_acc_threshold;
|
||||
to_store__value[i++] = sts_cfg_nvm.fall_detection_depth_threshold;
|
||||
to_store__value[i++] = sts_cfg_nvm.fall_confirm_threshold_in_10sec;
|
||||
|
||||
#endif
|
||||
if ((nvm_store_value[NVM_AC_CODE_START]!= 0x0) && (nvm_store_value[NVM_AC_CODE_START+19]!=0x0))
|
||||
{
|
||||
//APP_LOG(TS_OFF, VLEVEL_M, "\n\r Transfer good NVM Stored ac_code to NVM_STORE_VALUE\r\n");
|
||||
|
@ -1585,13 +1632,21 @@ void STS_REBOOT_CONFIG_Init(void)
|
|||
sts_cfg_nvm.alarm_parameter05 =(uint8_t)nvm_store_value[NVM_ALARM_PARAMETER05];
|
||||
sts_cfg_nvm.alarm_mute_reset_timer_in_10sec = (uint8_t)nvm_store_value[NVM_ALARM_MUTE_RESET_TIMER];
|
||||
sts_cfg_nvm.alarm_lamp_bar_flashing_color = (uint8_t)nvm_store_value[NVM_ALARM_LAMP_BAR_FLASHING_COLOR];
|
||||
#ifdef L8
|
||||
sts_cfg_nvm.fhmos_cfg_1 =(uint8_t)nvm_store_value[NVM_OCCUPANCY_OVERTIME_THRESHOLD];
|
||||
sts_cfg_nvm.fhmos_cfg_2 =(uint8_t)nvm_store_value[NVM_MOTIONLESS_DURATION_THRESHOLD];
|
||||
sts_cfg_nvm.fhmos_cfg_3 =(uint8_t)nvm_store_value[NVM_UNCONSCIOUS_LEVEL_THRESHOLD];
|
||||
sts_cfg_nvm.fhmos_cfg_4 =(uint8_t)nvm_store_value[NVM_FALL_DETECTION_ACC_THRESHOLD];
|
||||
sts_cfg_nvm.fhmos_cfg_5 =(uint8_t)nvm_store_value[NVM_FALL_DETECTION_DEPTH_THRESHOLD];
|
||||
sts_cfg_nvm.fhmos_cfg_6 =(uint8_t)nvm_store_value[NVM_FALL_CONFIRM_THRESHOLD];
|
||||
#else
|
||||
sts_cfg_nvm.occupancy_overtime_threshold_in_10min = (uint8_t)nvm_store_value[NVM_OCCUPANCY_OVERTIME_THRESHOLD];
|
||||
sts_cfg_nvm.motionless_duration_threshold_in_min= (uint8_t)nvm_store_value[NVM_MOTIONLESS_DURATION_THRESHOLD];
|
||||
sts_cfg_nvm.unconscious_or_motionless_level_threshold = (uint8_t)nvm_store_value[NVM_UNCONSCIOUS_LEVEL_THRESHOLD];
|
||||
sts_cfg_nvm.fall_detection_acc_threshold = (uint8_t)nvm_store_value[NVM_FALL_DETECTION_ACC_THRESHOLD];
|
||||
sts_cfg_nvm.fall_detection_depth_threshold = (uint8_t)nvm_store_value[NVM_FALL_DETECTION_DEPTH_THRESHOLD];
|
||||
sts_cfg_nvm.fall_confirm_threshold_in_10sec = (uint8_t)nvm_store_value[NVM_FALL_CONFIRM_THRESHOLD];
|
||||
|
||||
#endif
|
||||
for (uint8_t j=0; j< YUNHORN_STS_AC_CODE_SIZE; j++) {
|
||||
sts_cfg_nvm.ac[j] = (uint8_t)nvm_store_value[NVM_AC_CODE_START +j];
|
||||
}
|
||||
|
@ -1688,8 +1743,42 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef L8
|
||||
STS_FHMOS_sensor_config_update();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef L8
|
||||
void STS_FHMOS_sensor_config_init(void)
|
||||
{
|
||||
//uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
sts_fhmos_cfg.sts_head_level_height_threshold_cm = 70; // default 700mm
|
||||
sts_fhmos_cfg.sts_fall_duration_threshold_potential_15sec = 4; // 4*15=60 sec, 1 min.
|
||||
sts_fhmos_cfg.sts_fall_duration_threshold_confirm_15sec = 8; // 8*15 = 120 sec, 2 min.
|
||||
sts_fhmos_cfg.sts_motionless_threshold_short_15sec = 4; // 4*15 = 60 sec , 1 min.
|
||||
sts_fhmos_cfg.sts_motionless_threshold_long_15sec = 16; // 20*15 = 300 sec, 5 min.
|
||||
sts_fhmos_cfg.sts_occupancy_threshold_overstay_15sec = 100; // 80*15 = 1200 sec, 20 min.
|
||||
|
||||
}
|
||||
|
||||
void STS_FHMOS_sensor_config_update()
|
||||
{
|
||||
|
||||
sts_fhmos_cfg.sts_head_level_height_threshold_cm = sts_cfg_nvm.fhmos_cfg_1; // default 700mm
|
||||
sts_fhmos_cfg.sts_fall_duration_threshold_potential_15sec = sts_cfg_nvm.fhmos_cfg_2; // 4*15=60 sec, 1 min.
|
||||
sts_fhmos_cfg.sts_fall_duration_threshold_confirm_15sec = sts_cfg_nvm.fhmos_cfg_3; // 8*15 = 120 sec, 2 min.
|
||||
sts_fhmos_cfg.sts_motionless_threshold_short_15sec = sts_cfg_nvm.fhmos_cfg_4; // 4*15 = 60 sec , 1 min.
|
||||
sts_fhmos_cfg.sts_motionless_threshold_long_15sec = sts_cfg_nvm.fhmos_cfg_5; // 20*15 = 300 sec, 5 min.
|
||||
sts_fhmos_cfg.sts_occupancy_threshold_overstay_15sec = sts_cfg_nvm.fhmos_cfg_6; // 80*15 = 1200 sec, 20 min.
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void STS_Show_STS_CFG_NVM(uint8_t * store_value)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n-----------------------------------------------\n");
|
||||
|
|
|
@ -37,6 +37,7 @@ extern "C" {
|
|||
#include "yunhorn_sts_sensors.h"
|
||||
volatile uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
volatile uint32_t fhmos_fall_counter=0;
|
||||
volatile sts_fhmos_sensor_config_t sts_fhmos_cfg;
|
||||
#endif
|
||||
#include "stm32wlxx_nucleo.h"
|
||||
|
||||
|
@ -471,6 +472,35 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
|||
#endif
|
||||
|
||||
#ifdef L8
|
||||
/* Represent Color Value Definition
|
||||
* Fall Blue 0 The Room is not occupied by Human
|
||||
* Green 1 Human in room in normal level (head above 700 mmH from floor level)
|
||||
* Yellow 2 Human in low level position for short time potential (Head below 700mmH from floor level
|
||||
* Red 3 Human in low level position with time longer than threshold, e.g. 4 mins.(Head below 700 mm from Floor level
|
||||
* Human
|
||||
* Movement Blue 0 The Room is not occupied by Human
|
||||
* Green 1 The room is occupied by human, with movement
|
||||
* Yellow 2 The room is occupied by human, with motionless for short period of time (???)
|
||||
* Red 3 The room is occupied by human, with motionless for a period of time longer than threshold period, e.g. 5min.
|
||||
*
|
||||
* Occupancy Blue 0 The room is not occupied by Human
|
||||
* Green 1 The room is occupied by human, with movement
|
||||
* Red 2 The room is occupied by human, for a short period of time (???)
|
||||
*
|
||||
* # height is configurable from 10cm to 90 cm, with interval of 1cm
|
||||
* # the period of time is configurable, from 1 min to 30 mins, with 15 sec as interval
|
||||
*
|
||||
* sts_height_threshold (10cm --90 cm, 1cm interval) (10cm=10, 90cm=90, "P11T1XXX"
|
||||
* sts_fall_duration_threshold_potential (1 min to 30 min. 15 sec interval, 1800 sec. 1800=15*120, 60=15*4) "P11T2XXX"
|
||||
* sts_fall_duration_threshold_confirm (1 min to 30 min. 15 sec interval, 1800 sec. 1800=15*120, 60=15*4) "P11T3XXX"
|
||||
*
|
||||
* sts_motionless_threshold_short (1 min to 30 min. 15 sec interval, 1800 sec. 1800=15*120, 60=15*4) "P11T4XXX"
|
||||
* sts_motionless_threshold_long (1 min to 30 min. 15 sec interval, 1800 sec. 1800=15*120, 60=15*4) "P11T5XXX"
|
||||
*
|
||||
* sts_occupancy_threshold_overstay (1 min to 30 min. 15 sec interval, 1800 sec. 1800=15*120, 60=15*4) "P11T6XXX"
|
||||
*
|
||||
*/
|
||||
|
||||
void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_fhmos_data)
|
||||
{
|
||||
//uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
|
||||
|
@ -479,6 +509,9 @@ void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_fhmos_data)
|
|||
sts_fhmos_data->occupancy_state =fhmos_occupancy;
|
||||
sts_fhmos_data->sos_alarm_state =fhmos_sos_alarm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue