fix two diff measure inconsistant distance issue
This commit is contained in:
parent
24b35d7bd3
commit
f427cdf2ec
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
/**
|
||||
* @brief Verbose level for all trace logs
|
||||
*/
|
||||
#define VERBOSE_LEVEL VLEVEL_L
|
||||
#define VERBOSE_LEVEL VLEVEL_M
|
||||
|
||||
/**
|
||||
* @brief Enable trace logs
|
||||
|
|
|
@ -94,11 +94,11 @@ int sts_distance_rss_detector_distance(void)
|
|||
}
|
||||
|
||||
bool success = true;
|
||||
const int iterations = 2; //5;
|
||||
uint16_t number_of_peaks = 10;
|
||||
const int iterations = 1; //5;
|
||||
uint16_t number_of_peaks = 10.0f;
|
||||
acc_detector_distance_result_t result[number_of_peaks];
|
||||
acc_detector_distance_result_info_t result_info;
|
||||
sts_distance_rss_distance = 0.0;
|
||||
float tmp_distance = 0.0f;
|
||||
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
|
@ -109,11 +109,14 @@ int sts_distance_rss_detector_distance(void)
|
|||
APP_LOG(TS_OFF, VLEVEL_M, "acc_detector_distance_get_next() failed\n");
|
||||
break;
|
||||
}
|
||||
sts_distance_rss_distance += result->distance_m;
|
||||
for(uint8_t j=0; j< number_of_peaks; j++)
|
||||
tmp_distance += result[j].distance_m;
|
||||
print_distances(result, result_info.number_of_peaks);
|
||||
}
|
||||
|
||||
sts_distance_rss_distance = 1000.0f*sts_distance_rss_distance/iterations;
|
||||
sts_distance_rss_distance = (uint16_t)(1000*tmp_distance/number_of_peaks);
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Distance= %u mm\r\n", (uint16_t)sts_distance_rss_distance);
|
||||
|
||||
bool deactivated = acc_detector_distance_deactivate(distance_handle);
|
||||
|
||||
|
|
|
@ -674,15 +674,15 @@ void STS_PRESENCE_SENSOR_Distance_Measure_Process(void)
|
|||
{
|
||||
uint8_t exit_status = EXIT_SUCCESS, i=0;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n ****start_m=%u length_m=%u profile=%u hwaas=%u \r\n",
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n ****start_m=%u length_m=%u profile=%u hwaas=%u \r\n",
|
||||
(unsigned int)(distance_cfg.start_m*1000),(unsigned int)(distance_cfg.length_m*1000),
|
||||
(unsigned int)(distance_cfg.acc_profile),(unsigned int)(distance_cfg.hwaas));
|
||||
do
|
||||
//do
|
||||
{
|
||||
exit_status = sts_distance_rss_detector_distance();
|
||||
HAL_Delay(100);
|
||||
i++;
|
||||
} while ((exit_status == EXIT_FAILURE) && (i < 1));
|
||||
//HAL_Delay(100);
|
||||
//i++;
|
||||
} //while ((exit_status == EXIT_FAILURE) && (i < 1));
|
||||
|
||||
}
|
||||
|
||||
|
@ -704,7 +704,7 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_
|
|||
HAL_Delay(1000);
|
||||
sts_presence_rss_bring_up_test(bring_up_result);
|
||||
|
||||
HAL_Delay(5000);
|
||||
HAL_Delay(1000);
|
||||
|
||||
STS_PRESENCE_SENSOR_Distance_Measure_Process();
|
||||
|
||||
|
|
|
@ -1768,24 +1768,25 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
outbuf[i++] = (uint8_t) (0x41+ deviceClass); //translate to 'A','B','C'
|
||||
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
} else if ((char)tlv_buf[CFG_CMD3] == 'D') { // Distance Measure "YZD"
|
||||
i=0;
|
||||
outbuf[i++] = (uint8_t) 'Y';
|
||||
outbuf[i++] = (uint8_t) 'Z';
|
||||
outbuf[i++] = (uint8_t) 'D';
|
||||
//i=0;
|
||||
//outbuf[i++] = (uint8_t) 'Y';
|
||||
//outbuf[i++] = (uint8_t) 'Z';
|
||||
//outbuf[i++] = (uint8_t) 'D';
|
||||
//STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
|
||||
STS_SENSOR_Distance_Test_Process();
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nRSS Measured Distance=[%u] mm \r\n", (int)sts_distance_rss_distance);
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\nRSS Measured Distance=[%u] mm \r\n", (uint16_t)sts_distance_rss_distance);
|
||||
|
||||
i=0;
|
||||
memset((void*)outbuf,0x0, sizeof(outbuf));
|
||||
//memset((void*)outbuf,0x0, sizeof(outbuf));
|
||||
outbuf[i++] = (uint8_t)'D';
|
||||
outbuf[i++] = (uint8_t)sts_mtmcode1;
|
||||
outbuf[i++] = (uint8_t)sts_mtmcode2;
|
||||
outbuf[i++] = (uint8_t)sts_version;
|
||||
outbuf[i++] = (uint8_t)sts_hardware_ver;
|
||||
outbuf[i++] = (uint8_t)(99*((GetBatteryLevel()/254)&0xff));
|
||||
|
||||
#if defined(STS_O7)||defined(STS_O6)
|
||||
outbuf[i++] = (uint8_t)0x04; //length of following data
|
||||
outbuf[i++] = (uint8_t) ((((uint16_t)sts_distance_rss_distance)/1000)%10+0x30)&0xff;
|
||||
|
@ -2670,13 +2671,14 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
void STS_SENSOR_Distance_Test_Process(void)
|
||||
{
|
||||
#if defined(STS_O6)||defined(STS_O7)
|
||||
sts_distance_rss_distance =0;
|
||||
do {
|
||||
sts_distance_rss_distance =0; uint8_t i=0;
|
||||
//do {
|
||||
STS_PRESENCE_SENSOR_Distance_Measure_Process();
|
||||
HAL_Delay(200);
|
||||
} while(sts_distance_rss_distance == 0);
|
||||
// HAL_Delay(200);
|
||||
// i++;
|
||||
// } while((sts_distance_rss_distance == 0)&&(i<2));
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\nSensor Function Test: Distance Measured =%u mm\r\n", (int)sts_distance_rss_distance);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\nSensor Function Test: Distance Measured =%u mm\r\n", (uint16_t)sts_distance_rss_distance);
|
||||
#endif
|
||||
|
||||
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
|
||||
|
@ -2713,7 +2715,7 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
for (uint8_t j=0; j < 10; j++)
|
||||
tstbuf[i++] = (uint8_t) (self_test_result[j])&0xff;
|
||||
|
||||
STS_PRESENCE_SENSOR_Distance_Measure_Process();
|
||||
//STS_PRESENCE_SENSOR_Distance_Measure_Process();
|
||||
|
||||
tstbuf[i++] = (uint8_t) ((((uint16_t)sts_distance_rss_distance)/1000)%10+0x30)&0xff;
|
||||
tstbuf[i++] = (uint8_t) ((((uint16_t)sts_distance_rss_distance)/100)%10+0x30)&0xff;
|
||||
|
|
Loading…
Reference in New Issue