improve door open/close logic with timer
This commit is contained in:
parent
f25c396a8d
commit
764e5a9d91
|
@ -344,6 +344,7 @@ static UTIL_TIMER_Object_t JoinLedTimer;
|
|||
/* Exported functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EF */
|
||||
volatile uint8_t door_status=0, door_changed_flag=0, door_previous_status=0;
|
||||
volatile uint32_t checking_sn=0;
|
||||
/* USER CODE END EF */
|
||||
|
||||
void LoRaWAN_Init(void)
|
||||
|
@ -424,7 +425,7 @@ void LoRaWAN_Init(void)
|
|||
if (EventType == TX_ON_TIMER)
|
||||
{
|
||||
/* send every time timer elapses */
|
||||
UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_ONESHOT, OnTxTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_PERIODIC, OnTxTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
else
|
||||
|
@ -447,8 +448,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
{
|
||||
case BUT1_Pin:
|
||||
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
|
||||
door_changed_flag = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSP1CheckingEvent), CFG_SEQ_Prio_0);
|
||||
APP_LOG(TS_OFF,VLEVEL_M,"... BUT1............. \r\n");
|
||||
|
||||
if (EventType == TX_ON_EVENT)
|
||||
{
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
@ -474,14 +476,15 @@ static void OnYunhornSTSP1CheckingEvent(void)
|
|||
|
||||
|
||||
door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
|
||||
APP_LOG(TS_OFF,VLEVEL_M,"\r\nDOOR_STATUS= %u \r\n",door_status);
|
||||
|
||||
if (door_status != door_previous_status)
|
||||
{
|
||||
door_previous_status = door_status;
|
||||
door_changed_flag = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
APP_LOG(TS_OFF,VLEVEL_M,"\r\n----- Door Status Changed-------------\r\n");
|
||||
}
|
||||
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
/* USER CODE END PrFD */
|
||||
|
||||
|
@ -687,7 +690,7 @@ static void OnTxTimerEvent(void *context)
|
|||
{
|
||||
door_changed_flag =0;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
//UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
/* USER CODE BEGIN OnTxTimerEvent_2 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue