*** stable *** for P110/P113/P114/P115-(motion mode)

This commit is contained in:
Yunhorn 2024-08-13 19:46:52 +08:00
parent db022db0c2
commit 3ed5130aeb
1 changed files with 16 additions and 12 deletions

View File

@ -488,7 +488,7 @@ static LmHandlerParams_t LmHandlerParams =
/** /**
* @brief Type of Event to generate application Tx * @brief Type of Event to generate application Tx
*/ */
static TxEventType_t EventType = TX_ON_TIMER; //TX_ON_TIMER;//TX_ON_EVENT; static TxEventType_t EventType = TX_ON_EVENT; //TX_ON_TIMER; //TX_ON_TIMER;
/** /**
* @brief Timer to handle the application Tx * @brief Timer to handle the application Tx
@ -648,8 +648,6 @@ void LoRaWAN_Init(void)
/* USER CODE BEGIN LoRaWAN_Init_2 */ /* USER CODE BEGIN LoRaWAN_Init_2 */
UTIL_TIMER_Start(&JoinLedTimer); UTIL_TIMER_Start(&JoinLedTimer);
/* USER CODE END LoRaWAN_Init_2 */ /* USER CODE END LoRaWAN_Init_2 */
LmHandlerJoin(ActivationType, ForceRejoin); LmHandlerJoin(ActivationType, ForceRejoin);
@ -689,11 +687,11 @@ void LoRaWAN_Init(void)
//UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer); //UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, YUNHORN_STS_HEART_BEAT_CHECK_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL); UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, YUNHORN_STS_HEART_BEAT_CHECK_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
//UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
UTIL_TIMER_Start(&STSLampBarColorTimer); UTIL_TIMER_Start(&STSLampBarColorTimer);
UTIL_TIMER_Start(&STSDurationCheckTimer); //UTIL_TIMER_Start(&STSDurationCheckTimer);
#else #else
UTIL_TIMER_Create(&YunhornSTSSamplingCheckTimer, YUNHORN_STS_SAMPLING_CHECK_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSSamplingCheckTimerEvent, NULL); UTIL_TIMER_Create(&YunhornSTSSamplingCheckTimer, YUNHORN_STS_SAMPLING_CHECK_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSSamplingCheckTimerEvent, NULL);
@ -1106,7 +1104,7 @@ static void SendTxData(void)
} }
} }
if (EventType == TX_ON_TIMER) if ((EventType == TX_ON_TIMER)||((EventType == TX_ON_EVENT)&&(nextTxIn >0)))
{ {
UTIL_TIMER_Stop(&TxTimer); UTIL_TIMER_Stop(&TxTimer);
UTIL_TIMER_SetPeriod(&TxTimer, MAX(nextTxIn, TxPeriodicity)); UTIL_TIMER_SetPeriod(&TxTimer, MAX(nextTxIn, TxPeriodicity));
@ -1759,6 +1757,7 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */ /* USER CODE BEGIN OnTxPeriodicityChanged_1 */
/* USER CODE END OnTxPeriodicityChanged_1 */ /* USER CODE END OnTxPeriodicityChanged_1 */
#if 0
HeartBeatPeriodicity = periodicity; HeartBeatPeriodicity = periodicity;
if (HeartBeatPeriodicity == 0) if (HeartBeatPeriodicity == 0)
@ -1766,15 +1765,15 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
/* Revert to application default periodicity */ /* Revert to application default periodicity */
HeartBeatPeriodicity = 10*APP_TX_DUTYCYCLE; HeartBeatPeriodicity = 10*APP_TX_DUTYCYCLE;
} }
#endif
/* Update timer periodicity */ /* Update timer periodicity */
UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer); UTIL_TIMER_Stop(&YunhornSTSHeartBeatTimer);
UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, HeartBeatPeriodicity); UTIL_TIMER_SetPeriod(&YunhornSTSHeartBeatTimer, periodicity);
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */ /* USER CODE BEGIN OnTxPeriodicityChanged_2 */
APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity = %u (sec)\r\n", HeartBeatPeriodicity/1000 ); APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
/* USER CODE END OnTxPeriodicityChanged_2 */ /* USER CODE END OnTxPeriodicityChanged_2 */
} }
@ -2907,8 +2906,13 @@ void OnRestoreSTSCFGContextProcess(void)
HeartBeatPeriodicity = samplingperiodicity*1000; HeartBeatPeriodicity = samplingperiodicity*1000;
#endif #endif
#if defined(STS_O7)|| defined(STS_O6) ||defined(STS_O5) #if defined(STS_O7)|| defined(STS_O6) ||defined(STS_O5)
if (STS_LoRa_WAN_Joined !=0) {
HeartBeatPeriodicity = periodicity; HeartBeatPeriodicity = periodicity;
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity); OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
} else {
OnYunhornSTSHeartBeatPeriodicityChanged(APP_TX_DUTYCYCLE);
}
OnYunhornSTSSamplingPeriodicityChanged(sampling); // in m-sec unit OnYunhornSTSSamplingPeriodicityChanged(sampling); // in m-sec unit
#endif #endif
@ -3030,7 +3034,7 @@ void STS_SENSOR_Function_Test_Process(void)
uint32_t STS_Get_Date_Time_Stamp(void) uint32_t STS_Get_Date_Time_Stamp(void)
{ {
struct tm localtime; struct tm localtime={0};
SysTime_t UnixEpoch = SysTimeGet(); SysTime_t UnixEpoch = SysTimeGet();
UnixEpoch.Seconds -= 18; /*removing leap seconds*/ UnixEpoch.Seconds -= 18; /*removing leap seconds*/