revised for sum of day
This commit is contained in:
parent
25fef2cd4c
commit
7c35b1a55e
|
@ -47,6 +47,7 @@
|
|||
uint8_t outbuf[128]={0x0};
|
||||
extern volatile uint8_t *sts_ac_code;
|
||||
extern volatile uint32_t rfac_timer;
|
||||
extern volatile uint32_t STS_HeartBeatTimerPeriod_sec;
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -239,6 +240,13 @@ static void OnRxTimerLedEvent(void *context);
|
|||
*/
|
||||
static void OnJoinTimerLedEvent(void *context);
|
||||
|
||||
/**
|
||||
* @brief STS Wake Up Scan timer callback function
|
||||
* @param context ptr of VL53LX TOF People Counting Process context
|
||||
*/
|
||||
static void OnYunhornSTSWakeUpScanTimerEvent(void *context);
|
||||
|
||||
|
||||
/**
|
||||
* @brief STS Lamp Bar timer callback function
|
||||
* @param context ptr of Lamp Bar LED context
|
||||
|
@ -272,11 +280,8 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context);
|
|||
*/
|
||||
static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity);
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS AC Code handle Process
|
||||
* @param void
|
||||
*/
|
||||
static void STS_YUNHORN_RFAC_HANDLE_PROCESS(void);
|
||||
|
||||
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
|
@ -344,10 +349,18 @@ static UTIL_TIMER_Object_t TxTimer;
|
|||
/**
|
||||
* @brief Timer to handle the application ToF Ranging Scan
|
||||
*/
|
||||
static UTIL_TIMER_Object_t WakeUpScanTimer;
|
||||
static UTIL_TIMER_Object_t YunhornSTSWakeUpScanTimer;
|
||||
|
||||
/**
|
||||
* @brief Timer to handle the application Heart beat timer
|
||||
*/
|
||||
static UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer;
|
||||
|
||||
/**
|
||||
* @brief Timer to handle the application Lamp Bar LED Timer refresh
|
||||
*/
|
||||
static UTIL_TIMER_Object_t YunhornSTSLampBarColorTimer;
|
||||
|
||||
/**
|
||||
* @brief Tx Timer period
|
||||
*/
|
||||
|
@ -485,8 +498,19 @@ void LoRaWAN_Init(void)
|
|||
}
|
||||
|
||||
/* USER CODE BEGIN LoRaWAN_Init_Last */
|
||||
UTIL_TIMER_Create(&WakeUpScanTimer, 50, UTIL_TIMER_PERIODIC, (void*)STS_TOF_VL53LX_PeopleCounting_Process_Start, NULL);
|
||||
UTIL_TIMER_Start(&WakeUpScanTimer);
|
||||
#ifdef STS_P2
|
||||
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP5), UTIL_SEQ_RFU, STS_YunhornSTSEventP5_Process);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
UTIL_TIMER_Create(&YunhornSTSWakeUpScanTimer, 50, UTIL_TIMER_PERIODIC, OnYunhornSTSWakeUpScanTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
|
||||
|
||||
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||
|
||||
|
||||
/* USER CODE END LoRaWAN_Init_Last */
|
||||
}
|
||||
|
@ -533,8 +557,9 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
|||
|
||||
if (params != NULL)
|
||||
{
|
||||
#ifndef STM32WLE5xx
|
||||
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET); /* LED_BLUE */
|
||||
|
||||
#endif
|
||||
UTIL_TIMER_Start(&RxLedTimer);
|
||||
|
||||
if (params->IsMcpsIndication)
|
||||
|
@ -589,12 +614,16 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
|||
if (AppLedStateOn == RESET)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "LED OFF\r\n");
|
||||
#ifndef STM32WLE5xx
|
||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); /* LED_RED */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "LED ON\r\n");
|
||||
#ifndef STM32WLE5xx
|
||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET); /* LED_RED */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -602,11 +631,6 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
|||
if (appData->BufferSize != 1)
|
||||
{
|
||||
if (appData->BufferSize < 128) {
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n OnTxData: Port=%d \n\t", appData->Port);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\t");
|
||||
for (uint8_t x=0; x< appData->BufferSize; x++)
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "%02x\t", appData->Buffer[x]);;
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n");
|
||||
USER_APP_AUTO_RESPONDER_Parse((uint8_t*)appData->Buffer, appData->BufferSize);
|
||||
}
|
||||
}
|
||||
|
@ -1141,126 +1165,70 @@ static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size)
|
|||
/* USER CODE END OnRestoreContextRequest_Last */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Occupancy RSS WakeUP timer callback function, act as sampling process
|
||||
* @brief STS Lamp Bar timer callback function
|
||||
* @param context ptr of Lamp Bar LED context
|
||||
*/
|
||||
static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
||||
{
|
||||
#ifdef STS_O6
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), CFG_SEQ_Prio_0);
|
||||
|
||||
UTIL_TIMER_Start(&YunhornSTSLampBarColorTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SYS occupancy, door lock, motion duration check timer callback function
|
||||
* @param context ptr of duration check context
|
||||
*/
|
||||
static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||
{
|
||||
#ifdef STS_O6
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Occupancy RSS WakeUP timer callback function
|
||||
* @param context ptr of STS RSS WakeUp context
|
||||
*/
|
||||
|
||||
static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context)
|
||||
{
|
||||
#if 0
|
||||
if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_UNI_MODE))
|
||||
{
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), CFG_SEQ_Prio_0);
|
||||
#ifdef STS_O6
|
||||
|
||||
if ((sts_rss_result_changed_flag == 1) || (sts_fall_rising_detected_result_changed_flag == 1))
|
||||
{
|
||||
//SendTxData();
|
||||
sts_rss_result_changed_flag = 0;
|
||||
sts_fall_rising_detected_result_changed_flag = 0;
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
//if ((last_sts_rss_result ==STS_RESULT_NO_MOTION)&& (sts_rss_result==STS_RESULT_MOTION))
|
||||
{
|
||||
//OnSensor3StateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Heart Beat Timer callback function
|
||||
* @param context ptr of STS Sampling Check context
|
||||
* @brief Yunhorn STS Heart beat timer callback function
|
||||
* @param context ptr of context
|
||||
*/
|
||||
|
||||
static void OnYunhornSTSHeartBeatTimerEvent(void *context)
|
||||
{
|
||||
//heart_beat_timer = 1;
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
AppData.Port = YUNHORN_STS_P2_LORA_APP_HTBT_PORT;
|
||||
AppData.BufferSize = 2;
|
||||
AppData.Buffer[0]=0x80;
|
||||
AppData.Buffer[1]=0x63; //TODO XXX change to battery level %
|
||||
|
||||
LmHandlerErrorStatus_t status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
||||
if(LORAMAC_HANDLER_SUCCESS == status) APP_LOG(TS_OFF, VLEVEL_L, "\nHeart-beat Sent out \r\n");
|
||||
|
||||
if ((sts_ac_code[0]==0x0) && (sts_ac_code[19]==0x0)) /* simple validation of non-empty ac code */
|
||||
{
|
||||
/* RFAC Challenge */
|
||||
if (rfac_timer < (STS_BURN_IN_RFAC+3)) {
|
||||
rfac_timer ++;
|
||||
}
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), CFG_SEQ_Prio_0);
|
||||
}
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Live Heart Beat Periodicity/interval Change callback function
|
||||
* @param context ptr of STS Live Heart Beat context
|
||||
* YL x x x
|
||||
* */
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Heart Beat Periodicity Chagne function
|
||||
* @param duration of periodicty in ms (1/1000 sec)
|
||||
*/
|
||||
static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
|
||||
if (periodicity == 0)
|
||||
{
|
||||
/* Revert to application default periodicity */
|
||||
periodicity = 10*APP_TX_DUTYCYCLE; //10*10 000 ms
|
||||
}
|
||||
|
||||
/* Update timer periodicity */
|
||||
|
||||
UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
|
||||
UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, periodicity);
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
|
||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Sampling Periodicity/interval Change callback function
|
||||
* @param context ptr of STS RSS WakeUp context
|
||||
*/
|
||||
|
||||
static void OnYunhornSTSSamplingPeriodicityChanged(uint32_t periodicity)
|
||||
/* USER CODE BEGIN PrFD_YunhornSTSWakeUpScanTimerEvents */
|
||||
static void OnYunhornSTSWakeUpScanTimerEvent(void *context)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP5), CFG_SEQ_Prio_0);
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
|
||||
|
||||
if (periodicity == 0)
|
||||
{
|
||||
/* Revert to application default periodicity */
|
||||
periodicity = APP_TX_DUTYCYCLE;
|
||||
}
|
||||
|
||||
/* Update timer periodicity */
|
||||
|
||||
#if defined(STS_O6)||defined(STS_O7)
|
||||
UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer);
|
||||
UTIL_TIMER_SetPeriod(&YunhornSTSRSSWakeUpTimer, periodicity);
|
||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"**************** Sampling Timer Periodicity = %u (sec)\r\n", (SamplingPeriodicity/1000) );
|
||||
#else
|
||||
#ifdef STS_E2
|
||||
UTIL_TIMER_Stop(&YunhornSTSSamplingCheckTimer);
|
||||
UTIL_TIMER_SetPeriod(&YunhornSTSSamplingCheckTimer, periodicity);
|
||||
UTIL_TIMER_Start(&YunhornSTSSamplingCheckTimer);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"**************** SamplingPeriodicity = %u (sec)\r\n", (SamplingPeriodicity/1000) );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
#include "flash_if.h"
|
||||
#include "lora_app.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
#ifdef STS_P2
|
||||
#include "app_tof.h"
|
||||
|
||||
#include "app_tof_peoplecount.h"
|
||||
#endif
|
||||
volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
||||
sts_mtmcode1,
|
||||
sts_mtmcode2,
|
||||
|
@ -99,6 +101,7 @@ volatile uint8_t sts_work_mode=4;
|
|||
volatile uint32_t rfac_timer=0;
|
||||
volatile uint16_t sts_sensor_install_height=3000;
|
||||
volatile uint8_t sensor_data_ready=0;
|
||||
volatile uint32_t STS_TOFScanPeriod_sec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec;
|
||||
static uint8_t outbuf[128]={0x0};
|
||||
extern volatile hmac_result_t hmac_result;
|
||||
extern uint16_t sensor_id;
|
||||
|
@ -159,7 +162,7 @@ extern volatile float sts_presence_rss_distance;
|
|||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
extern UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer;
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -186,7 +189,6 @@ extern volatile float sts_presence_rss_distance;
|
|||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
@ -393,7 +395,7 @@ void STS_YunhornSTSEventP4_Process(void)
|
|||
void STS_YunhornSTSEventP5_Process(void)
|
||||
{
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n P5 Testing Process\r\n");
|
||||
STS_TOF_VL53LX_PeopleCounting_Process_Start();
|
||||
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1212,6 @@ void USER_APP_AUTO_RESPONDER_Parse(uint8_t *parse_buffer, uint8_t parse_buffer_s
|
|||
sts_ac_code[j] = (uint8_t) tlv_buf[2+j];
|
||||
}
|
||||
|
||||
//STS_YUNHORN_RFAC_HANDLE_PROCESS();
|
||||
STS_YunhornAuthenticationCode_Process();
|
||||
|
||||
if ((hmac_result.ac_pass == 1U))
|
||||
|
@ -1484,8 +1485,10 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
|
||||
if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
|
||||
{ // ensure it's not in production yet
|
||||
OnTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit
|
||||
//OnTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit
|
||||
//OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); TODO XXXX
|
||||
OnTxPeriodicityChanged(10000); // APP_TX_DUTYCYCLE in msec unit
|
||||
|
||||
} else
|
||||
{
|
||||
//OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
||||
|
@ -1630,6 +1633,128 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Occupancy RSS WakeUP timer callback function, act as sampling process
|
||||
* @param context ptr of STS RSS WakeUp context
|
||||
*/
|
||||
void OnYunhornSTSOORSSWakeUpTimerEvent(void *context)
|
||||
{
|
||||
#if 0
|
||||
if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_UNI_MODE))
|
||||
{
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), CFG_SEQ_Prio_0);
|
||||
|
||||
if ((sts_rss_result_changed_flag == 1) || (sts_fall_rising_detected_result_changed_flag == 1))
|
||||
{
|
||||
//SendTxData();
|
||||
sts_rss_result_changed_flag = 0;
|
||||
sts_fall_rising_detected_result_changed_flag = 0;
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
//if ((last_sts_rss_result ==STS_RESULT_NO_MOTION)&& (sts_rss_result==STS_RESULT_MOTION))
|
||||
{
|
||||
//OnSensor3StateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Heart Beat Timer callback function
|
||||
* @param context ptr of STS Sampling Check context
|
||||
*/
|
||||
void OnYunhornSTSHeartBeatTimerEvent(void *context)
|
||||
{
|
||||
uint8_t appDataPort, appBufferSize, appDataBuffer[32];
|
||||
appDataPort = YUNHORN_STS_P2_LORA_APP_HTBT_PORT;
|
||||
appBufferSize = 2;
|
||||
appDataBuffer[0]=0x80;
|
||||
appDataBuffer[1]=0x63; //TODO XXX change to battery level %
|
||||
|
||||
STS_SENSOR_Upload_Message(appDataPort, appBufferSize, (uint8_t*)appDataBuffer);
|
||||
|
||||
if ((sts_ac_code[0]==0x0) && (sts_ac_code[19]==0x0)) /* simple validation of non-empty ac code */
|
||||
{
|
||||
/* RFAC Challenge */
|
||||
if (rfac_timer < (STS_BURN_IN_RFAC+3)) {
|
||||
rfac_timer ++;
|
||||
}
|
||||
STS_YunhornSTSEventRFAC_Process();
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), CFG_SEQ_Prio_0);
|
||||
}
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Live Heart Beat Periodicity/interval Change callback function
|
||||
* @param context ptr of STS Live Heart Beat context
|
||||
* YL x x x
|
||||
* */
|
||||
|
||||
void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
|
||||
if (periodicity == 0)
|
||||
{
|
||||
/* Revert to application default periodicity */
|
||||
periodicity = 10*APP_TX_DUTYCYCLE; //10*10 000 ms
|
||||
}
|
||||
|
||||
/* Update timer periodicity */
|
||||
|
||||
UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
|
||||
UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, periodicity);
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
|
||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Sampling Periodicity/interval Change callback function
|
||||
* @param context ptr of STS RSS WakeUp context
|
||||
*/
|
||||
|
||||
void OnYunhornSTSSamplingPeriodicityChanged(uint32_t periodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
|
||||
if (periodicity == 0)
|
||||
{
|
||||
/* Revert to application default periodicity */
|
||||
periodicity = APP_TX_DUTYCYCLE;
|
||||
}
|
||||
|
||||
/* Update timer periodicity */
|
||||
|
||||
#if defined(STS_O6)||defined(STS_O7)
|
||||
UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer);
|
||||
UTIL_TIMER_SetPeriod(&YunhornSTSRSSWakeUpTimer, periodicity);
|
||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"**************** Sampling Timer Periodicity = %u (sec)\r\n", (SamplingPeriodicity/1000) );
|
||||
#else
|
||||
#ifdef STS_E2
|
||||
UTIL_TIMER_Stop(&YunhornSTSSamplingCheckTimer);
|
||||
UTIL_TIMER_SetPeriod(&YunhornSTSSamplingCheckTimer, periodicity);
|
||||
UTIL_TIMER_Start(&YunhornSTSSamplingCheckTimer);
|
||||
APP_LOG(TS_OFF, VLEVEL_M,"**************** SamplingPeriodicity = %u (sec)\r\n", (SamplingPeriodicity/1000) );
|
||||
#endif
|
||||
#endif
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ void MX_TOF_Init(void)
|
|||
APP_LOG(TS_OFF,VLEVEL_L,"\r\n###################### MX TOF Init... \r\n");
|
||||
|
||||
//MX_53L1A2_SimpleRanging_Init();
|
||||
STS_TOF_VL53LX_PeopleCounting_Process();
|
||||
//STS_TOF_VL53LX_PeopleCounting_Process();
|
||||
/* USER CODE BEGIN TOF_Init_PostTreatment */
|
||||
|
||||
/* USER CODE END TOF_Init_PostTreatment */
|
||||
|
@ -95,7 +95,7 @@ void MX_TOF_Process(void)
|
|||
//STS_TOF_VL53LX_Range_Process();
|
||||
//STS_TOF_VL53LX_PeopleCounting_Process();
|
||||
|
||||
sts_tof_vl53lx_peoplecount_subprocess();
|
||||
//sts_tof_vl53lx_peoplecount_subprocess();
|
||||
|
||||
/* USER CODE BEGIN TOF_Process_PostTreatment */
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ void MX_TOF_Init(void);
|
|||
void MX_TOF_Process(void);
|
||||
uint16_t MX_TOF_Ranging_Process(void);
|
||||
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process(void);
|
||||
int sts_tof_vl53lx_peoplecount_subprocess(void);
|
||||
//void STS_TOF_VL53LX_PeopleCounting_Process(void);
|
||||
//int sts_tof_vl53lx_peoplecount_subprocess(void);
|
||||
typedef enum {
|
||||
STS_TOF_SHORT_RANGE=0,
|
||||
STS_TOF_LONG_RANGE,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
/* Private variables ---------------------------------------------------------*/
|
||||
extern I2C_HandleTypeDef hi2c2;
|
||||
volatile sts_people_count_sensor_data_t sts_people_count_sensor_data={0,0,0,2,'M',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
|
||||
|
||||
extern volatile uint32_t STS_TOFScanPeriod_sec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec;
|
||||
volatile sts_ppc_cfg_type_t ppc_cfg[3] = {
|
||||
{DOOR_JAM_2000, 8, 2000,0,1600,8,33,DISTANCE_MODE_SHORT,175,247},
|
||||
{DOOR_JAM_2000, 8, 2000,0,1600,8,33,DISTANCE_MODE_SHORT,175,247},
|
||||
|
@ -27,6 +27,8 @@ volatile sts_zone_center_by_rows_of_spads_t zone_center[3]={
|
|||
};
|
||||
volatile uint8_t sts_distance_mode = DISTANCE_MODE_LONG;
|
||||
volatile uint8_t sts_people_count_number_changed = 0;
|
||||
static uint32_t cnt_today=0, cnt_week=0;
|
||||
static uint8_t last_year=0, this_year=0,last_month=0, this_month=0,last_week=0, this_week=0,last_day=0, this_day=0;
|
||||
uint16_t dev=0x52;
|
||||
extern uint16_t sensor_id;
|
||||
int status = 0;
|
||||
|
@ -225,11 +227,8 @@ int ProcessPeopleCountingData(int16_t Distance, uint8_t zone, uint8_t RangeStatu
|
|||
|
||||
void STS_people_count_sensor_Read(sts_people_count_sensor_data_t *sts_p2_sensor_data)
|
||||
{
|
||||
if (0 == sts_people_count_sensor_data.Count_Valid)
|
||||
{
|
||||
sts_p2_sensor_data->Count_Valid = sts_people_count_sensor_data.Count_Valid;
|
||||
return;
|
||||
}
|
||||
|
||||
sts_p2_sensor_data->Count_Valid = sts_people_count_sensor_data.Count_Valid;
|
||||
|
||||
sts_p2_sensor_data->Walk_In_People_Count = sts_people_count_sensor_data.Walk_In_People_Count;
|
||||
sts_p2_sensor_data->Walk_Out_People_Count = sts_people_count_sensor_data.Walk_Out_People_Count;
|
||||
|
@ -296,14 +295,57 @@ void STS_people_count_sensor_Read(sts_people_count_sensor_data_t *sts_p2_sensor_
|
|||
sts_people_count_sensor_data.Sum_LifeCycle_Walk_Out_People_Count += sts_people_count_sensor_data.Sum_Day_Walk_Out_People_Count;
|
||||
sts_people_count_sensor_data.Sum_LifeCycle_Walk_Around_People_Count += sts_people_count_sensor_data.Sum_Day_Walk_Around_People_Count;
|
||||
|
||||
//reset counter of counting period
|
||||
|
||||
sts_people_count_sensor_data.Walk_In_People_Count = 0;
|
||||
sts_people_count_sensor_data.Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Walk_Around_People_Count = 0;
|
||||
|
||||
// reset counter at end of day TODO XXX
|
||||
// reset counter at end of week TODO XXX
|
||||
// reset counter at end of month TODO XXX
|
||||
//reset counter of counting period
|
||||
cnt_today ++;
|
||||
if (cnt_today*STS_TxPeriod_sec > 86400)
|
||||
{
|
||||
cnt_today = 0;
|
||||
sts_people_count_sensor_data.Walk_In_People_Count = 0;
|
||||
sts_people_count_sensor_data.Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Walk_Around_People_Count = 0;
|
||||
}
|
||||
|
||||
if (cnt_today ==0)
|
||||
{ // new day, then check week/month/year, not check every time
|
||||
// reset counter at end of day TODO XXX
|
||||
if (last_day != this_day) {
|
||||
cnt_today = 0;
|
||||
|
||||
sts_people_count_sensor_data.Sum_Day_Walk_In_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Day_Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Day_Walk_Around_People_Count = 0;
|
||||
}
|
||||
if (cnt_week)
|
||||
// reset counter at end of week TODO XXX
|
||||
if (last_week != this_week) {
|
||||
|
||||
|
||||
sts_people_count_sensor_data.Sum_Week_Walk_In_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Week_Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Week_Walk_Around_People_Count = 0;
|
||||
}
|
||||
|
||||
// reset counter at end of month TODO XXX
|
||||
if (last_month != this_month) {
|
||||
|
||||
sts_people_count_sensor_data.Sum_Month_Walk_In_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Month_Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Month_Walk_Around_People_Count = 0;
|
||||
}
|
||||
|
||||
if (last_year != this_year) {
|
||||
|
||||
sts_people_count_sensor_data.Sum_Year_Walk_In_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Year_Walk_Out_People_Count = 0;
|
||||
sts_people_count_sensor_data.Sum_Year_Walk_Around_People_Count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// reset counter at end of year TODO XXX
|
||||
// reset counter at end of year TODO XXX
|
||||
|
||||
|
@ -318,7 +360,7 @@ void STS_TOF_VL53LX_PeopleCounting_Process_Init(void)
|
|||
|
||||
}
|
||||
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process_Start(void* context)
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process_Start(void)
|
||||
{
|
||||
|
||||
//APP_LOG(TS_OFF, VLEVEL_M,"############### TOF VL53LX_ PEOPLE COUNTING SUB-PROCESS \r\n");
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
} sts_people_count_sensor_data_t;
|
||||
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process_Init(void);
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process_Start(void*);
|
||||
void STS_TOF_VL53LX_PeopleCounting_Process_Start(void);
|
||||
int sts_tof_vl53lx_peoplecount_init(void);
|
||||
int sts_tof_vl53lx_peoplecount_start(void);
|
||||
//int sts_tof_vl53lx_peoplecount(void);
|
||||
|
|
Loading…
Reference in New Issue