REVISED UPLOAD PERIOD AND HEART-BEAT PERIOD
This commit is contained in:
parent
738ce4fc43
commit
454af4fa92
|
@ -531,6 +531,12 @@ typedef struct sts_cfg_nvm {
|
|||
uint8_t ac[YUNHORN_STS_AC_CODE_SIZE]; // authorization code, 20 bytes MCU UUID coded
|
||||
} sts_cfg_nvm_t;
|
||||
|
||||
#define STS_SERVICE_MASK_L0 (0) // Service normal , no mask off
|
||||
#define STS_SERVICE_MASK_L1 (1) // service mask level 1, sensing data upload in silence mode, node appearance silence (no LED, No display, no sound, no vibration)
|
||||
#define STS_SERVICE_MASK_L2 (2) // service mask level 2, NO sensing data upload (event or periodicity)
|
||||
#define STS_SERVICE_MASK_L3 (3) // service mask level 3, NO responsing to cloud control command, or config change/responding, EXCEPT STS_SERVICE_MASK_ON_OFF cmd
|
||||
|
||||
|
||||
/**
|
||||
* @brief Store/Write/Flash Configuration in RW RAM
|
||||
*/
|
||||
|
|
|
@ -56,10 +56,9 @@ extern volatile uint8_t sts_soap_level_state;
|
|||
extern volatile uint8_t ToF_EventDetected;
|
||||
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 uint32_t HeartBeatPeriodicity = 300000; //unit ms
|
||||
volatile uint8_t STS_LoRa_WAN_Joined = 0;
|
||||
volatile uint8_t mems_int1_detected = 0;
|
||||
volatile uint8_t periodicity_level=0;
|
||||
|
||||
volatile uint8_t heart_beat_timer =0;
|
||||
char outbuf[128]="";
|
||||
volatile uint8_t upload_message_timer =0;
|
||||
|
@ -68,15 +67,15 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
|||
sts_mtmcode2,
|
||||
sts_version,
|
||||
sts_hardware_ver,
|
||||
0x05, //Regular TxPeriodicity interval
|
||||
0x01, //Regular TxPeriodicity interval
|
||||
'M', //unit of Regular TxPeriodicity interval
|
||||
0x01, //Heart-beat interval or Sampling interval
|
||||
'H', //unit of Heart-beat interval or Sampling interval
|
||||
0x05, //Heart-beat interval or Sampling interval
|
||||
'M', //unit of Heart-beat interval or Sampling interval
|
||||
0x04, // dual mode
|
||||
0x00, // service mask
|
||||
0x00, // reserve01
|
||||
0x20, //32 bytes, below start of p[0]
|
||||
{ // below 28 bytes
|
||||
{ // *******************below 28 bytes
|
||||
0x08, //start_m [8]*0.1 meter =0.8
|
||||
0x19, //lenght_m 0x19=[25]*0.1=2.5f meter
|
||||
0x0F, //threshold 0X0F=[15]*0.1=1.5f
|
||||
|
@ -94,25 +93,26 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
|
|||
0x05, //output time const 0x05=[5]*0.1=0.5
|
||||
0x02, //downsampling factor [2]=2
|
||||
0x03, //power saving mode ACTIVE [3] = 3U
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
0x00, //reserve
|
||||
}, // above 28 bytes
|
||||
// below 4 bytes
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xFF, //reserve
|
||||
0xF, //reserve
|
||||
}, // ******************* above 28 bytes28 bytes
|
||||
// ******************* below 4 bytes
|
||||
0x01, //fall_detection_acc_threshold = *10 acceleration measure
|
||||
0x03, //fall detection_depth_threshold *10cm
|
||||
0x00, //reserve
|
||||
0x02, //occupancy over time threshold *10 minutes
|
||||
// below 20 bytes
|
||||
{0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0}
|
||||
// ******************* ABOVE 4 bytes
|
||||
// below 20 bytes AC
|
||||
{0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF}
|
||||
};
|
||||
|
||||
|
||||
|
@ -581,7 +581,7 @@ void LoRaWAN_Init(void)
|
|||
// UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), UTIL_SEQ_RFU, STS_YunhornSTSEventP3_Process);
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), UTIL_SEQ_RFU, STS_YunhornSTSEventP4_Process);
|
||||
// UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP5), UTIL_SEQ_RFU, STS_YunhornSTSEventP5_Process);
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), UTIL_SEQ_RFU, STS_YunhornSTSEventP6_Process);
|
||||
// UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), UTIL_SEQ_RFU, STS_YunhornSTSEventP6_Process);
|
||||
// UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP7), UTIL_SEQ_RFU, STS_YunhornSTSEventP7_Process);
|
||||
// UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP8), UTIL_SEQ_RFU, STS_YunhornSTSEventP8_Process);
|
||||
// UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventPIORS485), UTIL_SEQ_RFU, STS_YunhornSTSEventPIORS485_Process);
|
||||
|
@ -596,10 +596,10 @@ void LoRaWAN_Init(void)
|
|||
// Uploading Message
|
||||
// FOR Periodically upload message sensor, use this as Heart Beat interval
|
||||
#ifdef YUNHORN_STS_MM_ENABLED
|
||||
// UTIL_TIMER_Create(&YunhornSTSUploadingMessageTimer,
|
||||
// YUNHORN_STS_UPLOADING_MESSAGE_TIME,
|
||||
// UTIL_TIMER_PERIODIC, OnYunhornSTSUploadingMessageEvent, NULL);
|
||||
// UTIL_TIMER_Start(&YunhornSTSUploadingMessageTimer);
|
||||
UTIL_TIMER_Create(&YunhornSTSUploadingMessageTimer,
|
||||
YUNHORN_STS_UPLOADING_MESSAGE_TIME,
|
||||
UTIL_TIMER_PERIODIC, OnYunhornSTSUploadingMessageEvent, NULL);
|
||||
UTIL_TIMER_Start(&YunhornSTSUploadingMessageTimer);
|
||||
#endif
|
||||
|
||||
// for IAQ sensor, multiple sampling, result in one average result between upload interval
|
||||
|
@ -613,7 +613,7 @@ void LoRaWAN_Init(void)
|
|||
|
||||
// Heart Beat Timer
|
||||
// FOR Event trigger type sensor, use this as Heart Beat Timer, such as O1/O2/O3/M1
|
||||
#if (defined(YUNHORN_STS_R0_ENABLED))
|
||||
#if (defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED))
|
||||
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, HeartBeatPeriodicity,
|
||||
UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
|
@ -636,7 +636,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
|
||||
sensor_data_ready =1;
|
||||
uint8_t pinstate = HAL_GPIO_ReadPin(BUT1_GPIO_Port,BUT1_Pin);
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "##################################### BUTTON-1 DETECTED: %2d \r\n", pinstate);
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "## BUTTON-1 DETECTED: %2d \r\n", pinstate);
|
||||
|
||||
//if (EventType == TX_ON_EVENT)
|
||||
if (pinstate == 1)
|
||||
|
@ -644,7 +644,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
} else {
|
||||
LED_ON;
|
||||
HAL_Delay(50);
|
||||
HAL_Delay(20);
|
||||
LED_OFF;
|
||||
}
|
||||
|
||||
|
@ -823,9 +823,9 @@ static void SendTxData(void)
|
|||
AppData.Buffer[i++] = (uint8_t)(r0_data.battery_Pct); //#05
|
||||
#endif
|
||||
|
||||
if (heart_beat_timer)
|
||||
if (heart_beat_timer != 0)
|
||||
{
|
||||
heart_beat_timer = 0;
|
||||
heart_beat_timer = 0U;
|
||||
AppData.Port = LORAWAN_USER_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
||||
#ifdef ROCTEC_R5
|
||||
AppData.Buffer[i++] = AppLedStateOn;
|
||||
|
@ -835,9 +835,8 @@ static void SendTxData(void)
|
|||
APP_LOG(TS_ON, VLEVEL_H, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
||||
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
||||
|
||||
} else if ((upload_message_timer)||(sensor_data_ready)) //sensor_data_ready for manual push button-1 trigger)
|
||||
} else if ((upload_message_timer !=0U)||(sensor_data_ready!=0U)) //sensor_data_ready for manual push button-1 trigger)
|
||||
{
|
||||
|
||||
sensor_data_ready =0;
|
||||
upload_message_timer =0;
|
||||
#ifdef ROCTEC_R5
|
||||
|
@ -903,7 +902,7 @@ static void OnTxTimerEvent(void *context)
|
|||
/* USER CODE BEGIN OnTxTimerEvent_1 */
|
||||
|
||||
/* USER CODE END OnTxTimerEvent_1 */
|
||||
upload_message_timer =1U;
|
||||
//upload_message_timer =1U;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
/*Wait for next tx slot*/
|
||||
|
@ -992,7 +991,8 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
|
||||
STS_LoRa_WAN_Joined = (uint8_t) joinParams->Mode;
|
||||
//STS_REBOOT_CONFIG_Init();
|
||||
|
||||
//OnTxPeriodicityChanged(HeartBeatPeriodicity);
|
||||
OnTxPeriodicityChanged(TxPeriodicity);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\n STS_LoRa_WAN_Joined = %d \r\n", STS_LoRa_WAN_Joined);
|
||||
|
||||
|
||||
|
@ -1428,7 +1428,7 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
|
|||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||
|
||||
if ((STS_LoRa_WAN_Joined ) && (sts_ac_code[0]==0x0))
|
||||
if ((STS_LoRa_WAN_Joined ) && (sts_ac_code[0]==0xFF))
|
||||
{
|
||||
/* RFAC Challenge */
|
||||
if (rfac_timer < (STS_BURN_IN_RFAC+3)) {
|
||||
|
@ -1750,7 +1750,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
SamplingPeriodicity = heart_beat_or_sampling_periodicity_length*1000; //translate to 1000ms=1s
|
||||
OnYunhornSTSSamplingPeriodicityChanged(SamplingPeriodicity);
|
||||
#endif
|
||||
#ifdef YUNHORN_STS_R0_ENABLED
|
||||
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
|
||||
HeartBeatPeriodicity = heart_beat_or_sampling_periodicity_length*1000; //translate to 1000ms=1s
|
||||
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||
#endif
|
||||
|
@ -2045,7 +2045,7 @@ void STS_REBOOT_CONFIG_Init(void)
|
|||
UTIL_MEM_cpy_8(nvm_stored_value, (void *)STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE);
|
||||
/* USER CODE BEGIN OnRestoreContextRequest_Last */
|
||||
|
||||
#if (defined(YUNHORN_STS_O6_ENABLED) || defined(YUNHORN_STS_R0_ENABLED))
|
||||
#if defined(YUNHORN_STS_O6_ENABLED) || defined(YUNHORN_STS_R0_ENABLED) || defined(YUNHORN_STS_R5_ENABLED)
|
||||
if ((nvm_stored_value[NVM_MTM1] != sts_mtmcode1) || (nvm_stored_value[NVM_MTM2] != sts_mtmcode2) || (nvm_stored_value[NVM_VER] != sts_version))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\nInitial Boot with Empty Config, Flash with default config....\r\n");
|
||||
|
@ -2116,7 +2116,7 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
OnYunhornSTSSamplingPeriodicityChanged(samplingperiodicity*1000); // in m-sec unit
|
||||
#endif
|
||||
|
||||
#ifdef YUNHORN_STS_R0_ENABLED
|
||||
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
|
||||
OnYunhornSTSHeartBeatPeriodicityChanged(samplingperiodicity*1000);
|
||||
#endif
|
||||
|
||||
|
@ -2159,7 +2159,7 @@ void STS_SENSOR_Distance_Test_Process(void)
|
|||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nSensor Function Test: Distance Measured =%u mm\r\n", (int)sts_distance_rss_distance);
|
||||
#endif
|
||||
|
||||
#ifdef YUNHORN_STS_R0_ENABLED
|
||||
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
|
||||
MX_TOF_Process();
|
||||
#endif
|
||||
}
|
||||
|
@ -2204,8 +2204,8 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
tstbuf[i++] = (uint8_t) (((uint16_t)sts_distance_rss_distance)%10+0x30)&0xff;
|
||||
#endif
|
||||
|
||||
#ifdef YUNHORN_STS_R0_ENABLED
|
||||
tstbuf[i++] = (uint8_t)2; //length of following data
|
||||
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
|
||||
tstbuf[i++] = (uint8_t)6; //length of following data
|
||||
MX_TOF_Process();
|
||||
tstbuf[i++] = (uint8_t) ((sts_tof_distance_data[0] >>8 ) &0xff);
|
||||
tstbuf[i++] = (uint8_t) (sts_tof_distance_data[0] &0xff);
|
||||
|
@ -2220,6 +2220,6 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
memset((void*)outbuf,sizeof(outbuf),0x30);
|
||||
memcpy((void*)outbuf, tstbuf, i);
|
||||
|
||||
//STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
|
||||
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ extern "C" {
|
|||
/*!
|
||||
* LoRaWAN default class
|
||||
*/
|
||||
#define LORAWAN_DEFAULT_CLASS CLASS_A
|
||||
#define LORAWAN_DEFAULT_CLASS CLASS_C
|
||||
|
||||
/*!
|
||||
* LoRaWAN default confirm state
|
||||
|
|
Loading…
Reference in New Issue