sts_presence_fall_detection setting

This commit is contained in:
Yunhorn 2024-05-12 18:03:36 +08:00
parent a947485d64
commit 9482e98bed
1 changed files with 13 additions and 6 deletions

View File

@ -122,7 +122,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
extern volatile uint8_t sensor_data_ready; extern volatile uint8_t sensor_data_ready;
extern volatile STS_OO_SensorStatusDataTypeDef sts_o7_sensorData; extern volatile STS_OO_SensorStatusDataTypeDef sts_o7_sensorData;
extern volatile float sts_distance_rss_distance; extern volatile float sts_distance_rss_distance;
//volatile uint8_t sts_presence_fall_detection;
char sts_lamp_color_code[10][10]={ char sts_lamp_color_code[10][10]={
"Dark", "Dark",
"Green", "Green",
@ -1577,6 +1577,7 @@ static void OnYunhornSTSSamplingCheckTimerEvent(void *context)
void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
{ {
uint8_t i=0, mems_ver, invalid_flag=1; uint8_t i=0, mems_ver, invalid_flag=1;
UTIL_MEM_set_8(outbuf,0x0, sizeof(outbuf));
if (((char)tlv_buf[CFG_CMD1] == 'Y') && (tlv_buf_size <=5)) // BEGIN OF *** BOARD LEVEL CONTROL OR REPORT if (((char)tlv_buf[CFG_CMD1] == 'Y') && (tlv_buf_size <=5)) // BEGIN OF *** BOARD LEVEL CONTROL OR REPORT
{ {
@ -1601,7 +1602,6 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
//STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf); //STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
i=0; i=0;
memset(outbuf,0x0, sizeof(outbuf));
STS_SENSOR_Function_Test_Process(); STS_SENSOR_Function_Test_Process();
@ -1706,7 +1706,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
uint8_t cfg_in_nvm[YUNHORN_STS_MAX_NVM_CFG_SIZE]=""; uint8_t cfg_in_nvm[YUNHORN_STS_MAX_NVM_CFG_SIZE]="";
OnRestoreSTSCFGContextRequest((uint8_t *)cfg_in_nvm); OnRestoreSTSCFGContextRequest((uint8_t *)cfg_in_nvm);
i=0; i=0;
memset(outbuf,0x0, sizeof(outbuf));
outbuf[i++] = (uint8_t) 'C'; outbuf[i++] = (uint8_t) 'C';
outbuf[i++] = (uint8_t) cfg_in_nvm[NVM_MTM1]; //MTM Code outbuf[i++] = (uint8_t) cfg_in_nvm[NVM_MTM1]; //MTM Code
@ -2100,6 +2100,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
} else if (((char)tlv_buf[CFG_CMD1] == 'A') && ((char)tlv_buf[CFG_CMD2] == 'C') && (tlv_buf_size == (YUNHORN_STS_AC_CODE_SIZE+2))) // BEGIN OF *** BOARD LEVEL AUTHORIZATION CODE } else if (((char)tlv_buf[CFG_CMD1] == 'A') && ((char)tlv_buf[CFG_CMD2] == 'C') && (tlv_buf_size == (YUNHORN_STS_AC_CODE_SIZE+2))) // BEGIN OF *** BOARD LEVEL AUTHORIZATION CODE
{ {
// 'AC'+ AC_CODE(20bytes) // 'AC'+ AC_CODE(20bytes)
//UTIL_MEM_cpy_8(sts_ac_code, tlv_buf+2,YUNHORN_STS_AC_CODE_SIZE);
for (uint8_t j=0; j< YUNHORN_STS_AC_CODE_SIZE; j++) for (uint8_t j=0; j< YUNHORN_STS_AC_CODE_SIZE; j++)
{ {
@ -2110,6 +2111,8 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
if ((hmac_result.ac_pass == 1U)) if ((hmac_result.ac_pass == 1U))
{ {
//UTIL_MEM_cpy_8(sts_cfg_nvm.ac, sts_ac_code,YUNHORN_STS_AC_CODE_SIZE);
for (uint8_t j=0; j < YUNHORN_STS_AC_CODE_SIZE; j++) for (uint8_t j=0; j < YUNHORN_STS_AC_CODE_SIZE; j++)
{ {
sts_cfg_nvm.ac[j] = sts_ac_code[j]; sts_cfg_nvm.ac[j] = sts_ac_code[j];
@ -2202,7 +2205,7 @@ void OnStoreSTSCFGContextRequest(void)
/* USER CODE BEGIN OnStoreContextRequest_1 */ /* USER CODE BEGIN OnStoreContextRequest_1 */
uint8_t i=0,j=0,nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0}; uint8_t i=0,j=0,nvm_store_value[YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
#if (defined(STS_O7)||defined(STS_O5) || defined(STS_O6) || defined(STS_R0) || defined(STS_R5)|| defined(STS_R4)|| defined(STS_R1D)) //#if (defined(STS_O7)||defined(STS_O5) || defined(STS_O6) || defined(STS_R0) || defined(STS_R5)|| defined(STS_R4)|| defined(STS_R1D))
sts_cfg_nvm.length = STS_O7_NVM_CFG_SIZE; sts_cfg_nvm.length = STS_O7_NVM_CFG_SIZE;
nvm_store_value[i++] = sts_cfg_nvm.mtmcode1; nvm_store_value[i++] = sts_cfg_nvm.mtmcode1;
nvm_store_value[i++] = sts_cfg_nvm.mtmcode2; nvm_store_value[i++] = sts_cfg_nvm.mtmcode2;
@ -2225,13 +2228,17 @@ void OnStoreSTSCFGContextRequest(void)
nvm_store_value[i++] = sts_cfg_nvm.fall_detection_depth_threshold; nvm_store_value[i++] = sts_cfg_nvm.fall_detection_depth_threshold;
nvm_store_value[i++] = sts_cfg_nvm.fall_unconcious_threshold; nvm_store_value[i++] = sts_cfg_nvm.fall_unconcious_threshold;
nvm_store_value[i++] = sts_cfg_nvm.occupancy_overtime_threshold; nvm_store_value[i++] = sts_cfg_nvm.occupancy_overtime_threshold;
if ((sts_cfg_nvm.fall_detection_acc_threshold ==0)&&(sts_cfg_nvm.fall_detection_depth_threshold==0)) {
sts_presence_fall_detection =0;
} else {
sts_presence_fall_detection =1;
}
if ((sts_cfg_nvm.ac[0]!=0x0) && (sts_cfg_nvm.ac[19]!=0x0)) { if ((sts_cfg_nvm.ac[0]!=0x0) && (sts_cfg_nvm.ac[19]!=0x0)) {
for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) { for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) {
nvm_store_value[i++] = (sts_cfg_nvm.ac[j]); nvm_store_value[i++] = (sts_cfg_nvm.ac[j]);
} }
} }
#endif //#endif
/* USER CODE END OnStoreContextRequest_1 */ /* USER CODE END OnStoreContextRequest_1 */
/* store nvm in flash */ /* store nvm in flash */