add sliding window size and threshold parse cmd YWABB
This commit is contained in:
parent
1786bb502e
commit
e8088ba50d
|
@ -813,7 +813,8 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
sts_presence_rss_score = average_score;
|
||||
|
||||
STS_Yunhorn_DistanceStandardDeviation();
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nAverage Distance: %d (mm) Score: %d Singularity: %d \r\n",(int)average_distance, (int)average_score, sts_presence_singularity);
|
||||
|
||||
// APP_LOG(TS_OFF, VLEVEL_H, "\r\nAverage Distance: %d (mm) Score: %d Singularity: %d \r\n",(int)average_distance, (int)average_score, sts_presence_singularity);
|
||||
// uint8_t pre_sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0;
|
||||
// sts_rss_result=STS_RSS_Filter(pre_sts_rss_result);
|
||||
|
||||
|
@ -947,12 +948,7 @@ void STS_Yunhorn_DistanceStandardDeviation(void)
|
|||
sum_presence_distance += (uint32_t)(sts_motion_dataset[j].presence_distance - average_presence_distance);
|
||||
}
|
||||
|
||||
if (sum_presence_distance > 0)
|
||||
{
|
||||
sts_presence_singularity = 0;
|
||||
} else {
|
||||
sts_presence_singularity = 1;
|
||||
}
|
||||
sts_presence_singularity = (sum_presence_distance > 0)? 0:1;
|
||||
|
||||
// APP_LOG(TS_OFF, VLEVEL_M, "\r\n*** STS_Singularity=%u ***\r\n", sts_presence_singularity);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ volatile static bool r_b=true;
|
|||
static uint8_t nvm_stored_value[2*YUNHORN_STS_MAX_NVM_CFG_SIZE]={0x0};
|
||||
static uint8_t sts_cfg_nvm_factory_default[YUNHORN_STS_MAX_NVM_CFG_SIZE];
|
||||
static void STS_Show_STS_CFG_NVM(uint8_t * store_value, uint16_t store_size);
|
||||
extern volatile uint8_t sts_rss_cfg_slid_win_threshold;
|
||||
extern volatile uint8_t sts_rss_cfg_slid_win_size;
|
||||
|
||||
volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
||||
sts_mtmcode1,
|
||||
|
@ -2381,6 +2383,39 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size)
|
|||
}
|
||||
break;
|
||||
|
||||
case 'W': // YWXYY --- CHANGE RSS SLIDING WINDOW X: THRESHOLD, YY: WINDOW LENGTH
|
||||
if ( ((char)tlv_buf[CFG_CMD3] >= '0') && ((char)tlv_buf[CFG_CMD3] <= '9')
|
||||
&& ((char)tlv_buf[CFG_CMD4] >= '0') && ((char)tlv_buf[CFG_CMD4] <= '9')
|
||||
&& ((char)tlv_buf[CFG_CMD5] >= '0') && ((char)tlv_buf[CFG_CMD5] <= '9'))
|
||||
{
|
||||
uint8_t slid_win_threshold=0, slid_win_size=0;
|
||||
slid_win_threshold = (tlv_buf[CFG_CMD3] - 0x30)&0x0f;
|
||||
slid_win_size = ((tlv_buf[CFG_CMD4] - 0x30)*10 + (tlv_buf[CFG_CMD5] - 0x30))&0x0f;
|
||||
if (slid_win_size > slid_win_threshold)
|
||||
{
|
||||
sts_rss_cfg_slid_win_threshold = slid_win_threshold;
|
||||
sts_rss_cfg_slid_win_size = slid_win_size;
|
||||
|
||||
sts_cfg_nvm.p[RSS_CFG_SLID_WIN] = (slid_win_threshold<<4)|(slid_win_size&0x0f);
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSliding win threshold:%d window length: %d stored cfg:0x%02x \r\n",
|
||||
sts_rss_cfg_slid_win_threshold, sts_rss_cfg_slid_win_size, sts_cfg_nvm.p[RSS_CFG_SLID_WIN]);
|
||||
|
||||
OnStoreSTSCFGContextRequest();
|
||||
|
||||
} else
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nCFG ERR, sliding win threshold/length incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf));
|
||||
UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf,tlv_buf_size);
|
||||
i = tlv_buf_size;
|
||||
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
//STS_SENSOR_Upload_Config_Invalid_Message();
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue