revised for bring up message upload after rejoined
This commit is contained in:
parent
450ba1b1e5
commit
f2874f9248
|
@ -60,7 +60,7 @@ extern volatile int sts_tof_distance_data[MAX_TOF_COUNT];
|
|||
volatile uint32_t SamplingPeriodicity = 1000; //unit ms
|
||||
volatile uint32_t HeartBeatPeriodicity = 120000; //unit ms
|
||||
volatile uint8_t STS_LoRa_WAN_Joined = 0;
|
||||
|
||||
volatile uint8_t bring_up_mark=0, bring_up_count=0;
|
||||
#ifdef STS_TMG
|
||||
volatile float env_temperature= 25.0;
|
||||
extern volatile uint8_t waterTempThreshold;
|
||||
|
@ -811,7 +811,7 @@ static void SendTxData(void)
|
|||
#if defined(YUNHORN_STS_M1A_ENABLED)
|
||||
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP9), CFG_SEQ_Prio_0);
|
||||
|
||||
STS_YunhornSTSEventP9_Process();
|
||||
STS_M1A_SENSOR_Read(&m1a_data);
|
||||
|
||||
m1a_data.battery_Pct = (uint8_t)(99*batteryLevel/254);
|
||||
|
@ -962,11 +962,32 @@ static void OnTxTimerEvent(void *context)
|
|||
|
||||
/* USER CODE END OnTxTimerEvent_1 */
|
||||
upload_message_timer =1U;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP9), CFG_SEQ_Prio_0);
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP9), CFG_SEQ_Prio_0);
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
/*Wait for next tx slot*/
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
if (bring_up_mark == 1)
|
||||
{
|
||||
if (bring_up_count ++ >3)
|
||||
{
|
||||
uint32_t periodicity = (sts_cfg_nvm.periodicity); //TxPeriodicty interval
|
||||
if ((char)sts_cfg_nvm.unit =='M') {
|
||||
periodicity *= 60;
|
||||
} else if ((char) sts_cfg_nvm.unit =='H') {
|
||||
periodicity *= 3600;
|
||||
} else if ((char) sts_cfg_nvm.unit =='S') {
|
||||
periodicity *= 1;
|
||||
}
|
||||
|
||||
TxPeriodicity= periodicity*1000; // to ms
|
||||
OnTxPeriodicityChanged(TxPeriodicity);
|
||||
bring_up_mark = 0;
|
||||
bring_up_count =0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*Wait for next tx slot*/
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
/* USER CODE BEGIN OnTxTimerEvent_2 */
|
||||
|
||||
/* USER CODE END OnTxTimerEvent_2 */
|
||||
|
@ -1051,10 +1072,24 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
STS_LoRa_WAN_Joined = (uint8_t) joinParams->Mode;
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\n STS_LoRa_WAN_Joined = %s \r\n", (STS_LoRa_WAN_Joined == 1)?"ABP":"OTAA");
|
||||
|
||||
//STS_SENSOR_Upload_Message(LORAWAN_USER_APP_PORT, 30, (char*)"YunHorn SmarToilets 2024");
|
||||
bring_up_mark = 1;
|
||||
// for warm up upload quickly
|
||||
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
//restore NVM TxPeriodicity interval
|
||||
//TxPeriodicity= periodicity*1000; // to ms
|
||||
|
||||
//OnTxPeriodicityChanged(TxPeriodicity);
|
||||
/*
|
||||
UTIL_TIMER_Stop(&TxTimer);
|
||||
UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
*/
|
||||
/*
|
||||
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_PORT, 30, (char*)"YunHorn SmarToilets 2024");
|
||||
|
||||
uint32_t periodicity = (sts_cfg_nvm.periodicity); //TxPeriodicty interval
|
||||
if ((char)sts_cfg_nvm.unit =='M') {
|
||||
periodicity *= 60;
|
||||
|
@ -1064,11 +1099,15 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
periodicity *= 1;
|
||||
}
|
||||
|
||||
TxPeriodicity= periodicity*1000; // to ms
|
||||
// TxPeriodicity= periodicity*1000; // to ms
|
||||
|
||||
OnTxPeriodicityChanged(TxPeriodicity);
|
||||
// OnTxPeriodicityChanged(TxPeriodicity);
|
||||
|
||||
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||
|
||||
// UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
|
||||
// UTIL_TIMER_Start(&TxTimer);
|
||||
*/
|
||||
// OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1079,6 +1118,8 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* USER CODE END OnJoinRequest_1 */
|
||||
}
|
||||
|
||||
|
@ -1147,7 +1188,7 @@ static void OnMacProcessNotify(void)
|
|||
static void OnTxPeriodicityChanged(uint32_t periodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
TxPeriodicity = periodicity;
|
||||
|
||||
|
@ -1352,7 +1393,7 @@ static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context)
|
|||
static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
HeartBeatPeriodicity = periodicity;
|
||||
|
||||
|
@ -2054,14 +2095,14 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
if (EventType == TX_ON_TIMER)
|
||||
{
|
||||
UTIL_TIMER_Stop(&TxTimer);
|
||||
UTIL_TIMER_SetPeriod(&TxTimer, MAX(nextTxIn, TxPeriodicity));
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ extern "C" {
|
|||
/*!
|
||||
* LoRaWAN default class
|
||||
*/
|
||||
#define LORAWAN_DEFAULT_CLASS CLASS_C
|
||||
#define LORAWAN_DEFAULT_CLASS CLASS_A
|
||||
|
||||
/*!
|
||||
* LoRaWAN default confirm state
|
||||
|
|
Loading…
Reference in New Issue