refine
This commit is contained in:
parent
dc390dd12d
commit
3c1fcb7a32
Core
LoRaWAN
STM32CubeIDE/Release
STS
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
/**
|
||||
* @brief Verbose level for all trace logs
|
||||
*/
|
||||
#define VERBOSE_LEVEL VLEVEL_M
|
||||
#define VERBOSE_LEVEL VLEVEL_L
|
||||
|
||||
/**
|
||||
* @brief Enable trace logs
|
||||
|
|
|
@ -125,7 +125,7 @@ int main(void)
|
|||
//MX_USART2_UART_Init();
|
||||
#ifdef STS_P2
|
||||
STS_TOF_VL53LX_PeopleCounting_Process_Init();
|
||||
#elif defined(STS_T6)
|
||||
#elif defined(STS_T6)
|
||||
STS_TOF_VL53LX_PresenceDetection_Process_Init();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1104,7 +1104,7 @@ static void SendTxData(void)
|
|||
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
||||
if (LORAMAC_HANDLER_SUCCESS == status)
|
||||
{
|
||||
APP_LOG(TS_ON, VLEVEL_L, "SEND REQUEST\r\n");
|
||||
APP_LOG(TS_ON, VLEVEL_M, "SEND REQUEST\r\n");
|
||||
}
|
||||
else if (LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED == status)
|
||||
{
|
||||
|
|
|
@ -109,7 +109,7 @@ extern "C" {
|
|||
* - CHANNEL_PLAN_GROUP_AS923_4 (Freq offset = -5.90 MHz / Freq range = 917-920MHz)
|
||||
* - CHANNEL_PLAN_GROUP_AS923_1_JP (Freq offset = 0.0 MHz / Freq range = 920.6-923.4MHz)
|
||||
*/
|
||||
#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1_JP
|
||||
#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1
|
||||
|
||||
/*!
|
||||
* @brief Limits the number usable channels by default for AU915, CN470 and US915 regions
|
||||
|
|
Binary file not shown.
|
@ -1910,7 +1910,7 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
#if (defined(STS_P2)||defined(STS_T6))
|
||||
STS_SENSOR_MEMS_Get_ID(&sensor_id);
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor_id=%04x\r\n", sensor_id);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\nSensor_id=%04x\r\n", sensor_id);
|
||||
|
||||
if (((sensor_id & 0xff)!= 0xCC) && (((sensor_id >>8) & 0xFF)!=0xEA)) // no VL53L1X found
|
||||
{
|
||||
|
@ -1924,7 +1924,7 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
if ((status ==0) && (range_distance !=0))
|
||||
{
|
||||
sts_sensor_install_height = range_distance;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\nSensor Install Height =%4d mm\n", sts_sensor_install_height);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\nSensor Install Height =%4d mm\n", sts_sensor_install_height);
|
||||
tstbuf[i++] = (uint8_t) (4)&0xff; //length of following data
|
||||
tstbuf[i++] = (uint8_t) (sensor_id>>8)&0xff;
|
||||
tstbuf[i++] = (uint8_t) (sensor_id)&0xff;
|
||||
|
@ -1956,7 +1956,7 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
|
||||
if (sts_sensor_install_height >= 3500)
|
||||
sts_door_jam_profile ++; //DOOR_JAM_4000, profile = 5
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nDOOR JAM PROFILE=%d \r\n", sts_door_jam_profile);
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\nDOOR JAM PROFILE=%d \r\n", sts_door_jam_profile);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,11 +36,11 @@ extern volatile uint8_t sts_lamp_bar_color, sts_color_occupy_vacant;
|
|||
volatile sts_ppc_cfg_type_t ppc_cfg[10] = {
|
||||
{DOOR_SIDE_1300,10, 1300,0, 1200,8,33, DISTANCE_MODE_SHORT,175,231},
|
||||
{DOOR_JAM_1600, 10, 1600,0, 1300,8,33, DISTANCE_MODE_SHORT,175,231},
|
||||
{DOOR_JAM_2400, 10, 2400,400, 1900,8,100, DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_3000, 10, 3000,1200, 2500,8,200,DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_3500, 10, 3500,1700, 3000,8,200,DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_2400, 10, 2400,400, 1900,8,50, DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_3000, 10, 3000,1200, 2500,8,100,DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_3500, 10, 3500,1700, 3000,8,100,DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_4000, 10, 4000,2200, 3500,8,200,DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_NOW, 10, 2200, 400, 1800,8,200,DISTANCE_MODE_LONG,175,231},
|
||||
{DOOR_JAM_NOW, 10, 2200, 400, 1800,8,100,DISTANCE_MODE_LONG,175,231},
|
||||
};
|
||||
volatile sts_zone_center_by_rows_of_spads_t zone_center[4]={
|
||||
{4, 151, 247},
|
||||
|
@ -376,7 +376,7 @@ int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatu
|
|||
// reset the table filling size in case an entry or exit just found
|
||||
DistancesTableSize[0] = 0;
|
||||
DistancesTableSize[1] = 0;
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"Walk In, People Count=%d\n", PeopleCount);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Walk In, People Count=%d\n", PeopleCount);
|
||||
sts_people_count_sensor_data.Walk_In_People_Count ++;
|
||||
sts_people_count_number_changed = 1;
|
||||
LED_RED_OFF;
|
||||
|
@ -394,7 +394,7 @@ int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatu
|
|||
// reset the table filling size in case an entry or exit just found
|
||||
DistancesTableSize[0] = 0;
|
||||
DistancesTableSize[1] = 0;
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"Walk Out, People Count=%d\n", PeopleCount);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Walk Out, People Count=%d\n", PeopleCount);
|
||||
sts_people_count_sensor_data.Walk_Out_People_Count ++;
|
||||
//LED1_ON; //TODO XXX, CHANGE TO (LED_IN_OFF && LED_OUT_ON);
|
||||
//LED1_TOGGLE;
|
||||
|
@ -409,7 +409,7 @@ int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatu
|
|||
DistancesTableSize[0] = 0;
|
||||
DistancesTableSize[1] = 0;
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"Walk Around ie. Wrong path\n");
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Walk Around ie. Wrong path\n");
|
||||
sts_people_count_sensor_data.Walk_Around_People_Count ++;
|
||||
|
||||
LED_RED_ON;
|
||||
|
@ -638,7 +638,7 @@ void STS_people_count_sensor_Read(sts_people_count_sensor_data_t *sts_p2_sensor_
|
|||
#if (defined(STS_P2))
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process_Init(void)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"\n\n# YUNHORN STS-P2 PEOPLE COUNTING PROCESS #\r\n");
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\n\n# YUNHORN STS-P2 PEOPLE COUNTING PROCESS #\r\n");
|
||||
sts_tof_vl53lx_peoplecount_init();
|
||||
sts_people_count_sensor_data.Count_Period = sts_cfg_nvm.periodicity;
|
||||
sts_people_count_sensor_data.Count_Period_Unit = sts_cfg_nvm.unit;
|
||||
|
@ -671,9 +671,13 @@ void STS_TOF_VL53LX_PeopleCounting_Process_Start(void)
|
|||
|
||||
//APP_LOG(TS_OFF, VLEVEL_M,"############### TOF VL53LX_ PEOPLE COUNTING SUB-PROCESS \r\n");
|
||||
{
|
||||
uint8_t status =0;
|
||||
status = sts_tof_vl53lx_peoplecount_start();
|
||||
if (status !=0)
|
||||
|
||||
int status = sts_tof_vl53lx_peoplecount_start();
|
||||
if (status == -1)
|
||||
{
|
||||
sts_tof_vl53lx_peoplecount_init();
|
||||
return ;
|
||||
} else if (status !=0)
|
||||
{
|
||||
sts_people_count_sensor_data.Count_Valid = 0;
|
||||
//APP_LOG(TS_OFF, VLEVEL_M,"# Counting time out... \r\n");
|
||||
|
@ -924,11 +928,11 @@ int sts_tof_vl53lx_peoplecount_init(void)
|
|||
|
||||
// Those basic I2C read functions can be used to check your own I2C functions */
|
||||
status = VL53L1_RdByte(dev, 0x010F, &byteData);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"VL53L1X Model_ID: %X\n", byteData);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"VL53L1X Model_ID: %X\n", byteData);
|
||||
status = VL53L1_RdByte(dev, 0x0110, &byteData);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"VL53L1X Module_Type: %X\n", byteData);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"VL53L1X Module_Type: %X\n", byteData);
|
||||
status = VL53L1_RdWord(dev, 0x010F, &wordData);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"VL53L1X: %X\n", wordData);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"VL53L1X: %X\n", wordData);
|
||||
sensor_id = wordData;
|
||||
wordData = 0;
|
||||
while (sensorState == 0) {
|
||||
|
@ -936,17 +940,17 @@ int sts_tof_vl53lx_peoplecount_init(void)
|
|||
HAL_Delay(2);
|
||||
wordData ++;
|
||||
if (wordData > 8000) {
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"\n\n ***Failed to boot Chip***\n\n\n");
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\n\n ***Failed to boot Chip***\n\n\n");
|
||||
return status;
|
||||
}
|
||||
}
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"\nChip booted\n\n");
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\nChip booted\n\n");
|
||||
|
||||
/* Initialize and configure the device according to people counting need */
|
||||
status = VL53L1X_SensorInit(dev);
|
||||
|
||||
sts_distance_mode = (sts_door_jam_profile ==0)?DISTANCE_MODE_SHORT:DISTANCE_MODE_LONG;
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n MaxDistance=%d, \nMinDistance=%d \ndist_threshold=%d \n timing_budget=%d \n distance_mode=%d \r\n",
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n MaxDistance=%d, \nMinDistance=%d \ndist_threshold=%d \n timing_budget=%d \n distance_mode=%d \r\n",
|
||||
ppc_cfg[sts_door_jam_profile].max_distance,
|
||||
ppc_cfg[sts_door_jam_profile].min_distance,
|
||||
ppc_cfg[sts_door_jam_profile].dist_threshold,
|
||||
|
@ -956,13 +960,16 @@ int sts_tof_vl53lx_peoplecount_init(void)
|
|||
status += VL53L1X_SetTimingBudgetInMs(dev, ppc_cfg[sts_door_jam_profile].timing_budget); /* TIMING_BUDGET, in ms possible values [15, 20, 50, 100, 200, 500] */
|
||||
status += VL53L1X_SetInterMeasurementInMs(dev, ppc_cfg[sts_door_jam_profile].timing_budget);
|
||||
status += VL53L1X_SetROI(dev, ppc_cfg[sts_door_jam_profile].rows_of_SPADS, 16); /* minimum ROI 4,4 */
|
||||
|
||||
// status += VL53L1X_SetDistanceThreshold(dev,ppc_cfg[sts_door_jam_profile].min_distance,ppc_cfg[sts_door_jam_profile].max_distance, 3, 1); // 3= in window, 1= int on target
|
||||
|
||||
center[0]=ppc_cfg[sts_door_jam_profile].front_zone_center;
|
||||
center[1]=ppc_cfg[sts_door_jam_profile].back_zone_center;
|
||||
if (status != 0) {
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"Initialization or configuration of the device\n");
|
||||
return (-1);
|
||||
}
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"\n\nInit finished...\r\nStart counting people with profile : %d \r\n\n\n\n", sts_door_jam_profile);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\n\nInit finished...\r\nStart counting people with profile : %d \r\n\n\n\n", sts_door_jam_profile);
|
||||
status = VL53L1X_StartRanging(dev); /* This function has to be called to enable the ranging */
|
||||
|
||||
if (status != 0) {
|
||||
|
@ -990,7 +997,7 @@ int sts_tof_vl53lx_peoplecount_start(void)
|
|||
status = VL53L1X_CheckForDataReady(dev, &dataReady);
|
||||
HAL_Delay(1);
|
||||
wordData++;
|
||||
if (wordData > 30) return -1; // 50 ms timer, so make this 60% to fail back
|
||||
if (wordData > 500) return -1; // 50 ms timer, so make this 60% to fail back
|
||||
}
|
||||
dataReady = 0;
|
||||
status = 0; wordData =0;
|
||||
|
@ -1005,7 +1012,7 @@ int sts_tof_vl53lx_peoplecount_start(void)
|
|||
//HAL_Delay(WAIT_BEFORE_PROGRAMMING_OTHER_ZONE_CENTER); // 10, 8, 7, 6 tested OK
|
||||
status = VL53L1X_SetROICenter(dev, center[Zone]);
|
||||
if (status != 0) {
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Error in chaning the center of the ROI\n");
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"Error in changing the center of the ROI\n");
|
||||
return (-1);
|
||||
}
|
||||
// check the status of the ranging. In case of error, lets assume the distance is the max of the use case
|
||||
|
@ -1018,6 +1025,7 @@ int sts_tof_vl53lx_peoplecount_start(void)
|
|||
// 7 VL53L1_RANGESTATUS_WRAP_TARGET_ FAIL Wrapped target, not matching phases
|
||||
// 8 VL53L1_RANGESTATUS_PROCESSING_ FAIL Internal algorithm underflow or overflow
|
||||
// 14 VL53L1_RANGESTATUS_RANGE_INVALID The reported range is invalid
|
||||
#if 0
|
||||
if ((RangeStatus == 0) || (RangeStatus == 4) || (RangeStatus == 7)) {
|
||||
if (Distance <= ppc_cfg[sts_door_jam_profile].min_distance) //MIN_DISTANCE) // wraparound case see the explanation at the constants definition place
|
||||
Distance = ppc_cfg[sts_door_jam_profile].max_distance + ppc_cfg[sts_door_jam_profile].min_distance; //MAX_DISTANCE + MIN_DISTANCE;
|
||||
|
@ -1025,6 +1033,7 @@ int sts_tof_vl53lx_peoplecount_start(void)
|
|||
}
|
||||
else // severe error cases
|
||||
Distance = ppc_cfg[sts_door_jam_profile].max_distance; //MAX_DISTANCE;
|
||||
#endif
|
||||
// inject the new ranged distance in the people counting algorithm
|
||||
PplCounter = ProcessPeopleCountingData(Distance, Zone, RangeStatus);
|
||||
//printf("\nPplCounter =%d \n\r", PplCounter);
|
||||
|
@ -1061,7 +1070,7 @@ int sts_tof_vl53lx_range_distance(uint16_t *range_distance)
|
|||
return (-1);
|
||||
} else if (Distance != 0 )
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"\r\nVL53L1X RANGE DISTANCE =%d \r\n", Distance);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\nVL53L1X RANGE DISTANCE =%d \r\n", Distance);
|
||||
*range_distance = Distance;
|
||||
}
|
||||
return status;
|
||||
|
|
Loading…
Reference in New Issue