From 764eed4584d861dff5e16f26563f5a0b5bd89e0e Mon Sep 17 00:00:00 2001
From: sundp <dp.s@yunhorn.com>
Date: Sun, 15 Oct 2023 21:00:03 +0800
Subject: [PATCH]  add heartbeatEvent and RFAC process

---
 LoRaWAN/App/lora_app.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 0b96810..1a2c8cf 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -54,9 +54,9 @@ volatile uint8_t sts_ac_code[YUNHORN_STS_AC_CODE_SIZE]={0x0};
 volatile uint8_t heart_beat_timer=0, sts_lorawan_joined=0;
 volatile sts_cfg_nvm_t sts_cfg_nvm={sts_mtmcode1,sts_mtmcode2, sts_version, sts_hardware_ver, 
 0x00,'M', 0x05,'M', 0x04,0x00,0x00,0x20, 
-{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, 
+{0x0,0x0,0x0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, 
  0x01,0x03,0x00,0x02, 
- {0x0,0x0,0x0,0x0,0x0,   0x0,0x0,0x0,0x0,0x0,    0x0,0x0,0x0,0x0,0x0,   0x0,0x0,0x0,0x0,0x0}
+ {0xFF,0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF}
 };
 volatile uint32_t SamplingPeriodicity = 1000; 		//unit ms
 volatile uint32_t HeartBeatPeriodicity = 120000; 		//unit ms
@@ -254,6 +254,31 @@ static void OnRxTimerLedEvent(void *context);
   */
 static void OnJoinTimerLedEvent(void *context);
 
+/**
+  * @brief  Yunhorn STS Heart Beat Periodicity Chagne function
+  * @param  duration of periodicty in ms (1/1000 sec)
+  */
+static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity);
+
+/**
+  * @brief  Yunhorn STS Heart Beat callback function
+  * @param  context ptr of STS Sampling Check context
+  */
+static void OnYunhornSTSHeartBeatTimerEvent(void *context);
+
+
+/**
+  * @brief  Yunhorn STS Uploading Message periodically
+  * @param  context ptr of context
+  */
+//static void OnYunhornSTSUploadingMessageEvent(void *context);
+
+/**
+  * @brief  Yunhorn RFAC Handle process
+  * @param  void
+  */
+static void STS_YUNHORN_RFAC_HANDLE_PROCESS(void);
+
 /* USER CODE END PFP */
 
 /* Private variables ---------------------------------------------------------*/
@@ -462,7 +487,8 @@ void LoRaWAN_Init(void)
 	UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), UTIL_SEQ_RFU, STS_YunhornSTSEventRFAC_Process);	
 	
 	STS_REBOOT_CONFIG_Init();
-
+	UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, HeartBeatPeriodicity, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);	
+  UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
   /* USER CODE END LoRaWAN_Init_Last */
 }