try send changed status to uplink message

This commit is contained in:
Yunhorn 2024-03-25 12:00:26 +08:00
parent aa2cbe2709
commit 85a9fe722f
3 changed files with 18 additions and 9 deletions

View File

@ -59,8 +59,8 @@ void MX_GPIO_Init(void)
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = BUT1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#if 0

View File

@ -94,9 +94,9 @@ void PWR_EnterStopMode(void)
/* USER CODE BEGIN EnterStopMode_1 */
/* USER CODE END EnterStopMode_1 */
//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET);
//HAL_GPIO_WritePin(GPIOC, GPIO_PIN_All, GPIO_PIN_RESET);
//HAL_GPIO_WritePin(GPIOA, GPIO_PIN_All, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, ~GPIO_PIN_0, GPIO_PIN_RESET);
HAL_SuspendTick();
/* Clear Status Flag before entering STOP/STANDBY Mode */
LL_PWR_ClearFlag_C1STOP_C1STB();

View File

@ -342,7 +342,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;
/* USER CODE END EF */
void LoRaWAN_Init(void)
@ -666,12 +666,21 @@ static void SendTxData(void)
static void OnTxTimerEvent(void *context)
{
/* USER CODE BEGIN OnTxTimerEvent_1 */
door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
if (door_status != door_previous_status)
{
door_changed_flag = 1;
door_previous_status = door_status;
}
/* USER CODE END OnTxTimerEvent_1 */
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
if (door_changed_flag ==1 )
{
door_changed_flag = 0;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
/*Wait for next tx slot*/
UTIL_TIMER_Start(&TxTimer);
/*Wait for next tx slot*/
UTIL_TIMER_Start(&TxTimer);
}
/* USER CODE BEGIN OnTxTimerEvent_2 */
/* USER CODE END OnTxTimerEvent_2 */