STS_R1D for Japan Production image
This commit is contained in:
parent
6a12609a50
commit
cc688aa3b8
|
@ -47,12 +47,12 @@ extern "C" {
|
|||
/**
|
||||
* @brief Verbose level for all trace logs
|
||||
*/
|
||||
#define VERBOSE_LEVEL VLEVEL_H
|
||||
#define VERBOSE_LEVEL VLEVEL_L
|
||||
|
||||
/**
|
||||
* @brief Enable trace logs
|
||||
*/
|
||||
#define APP_LOG_ENABLED 1
|
||||
#define APP_LOG_ENABLED 0
|
||||
|
||||
/**
|
||||
* @brief Activate monitoring (probes) of some internal RF signals for debug purpose
|
||||
|
|
|
@ -165,6 +165,7 @@ void STS_YunhornSTSEventRFAC_Process(void)
|
|||
sts_service_mask = (sts_hmac_verify()!= 0)? STS_SERVICE_MASK_L2:STS_SERVICE_MASK_L0;
|
||||
if (sts_service_mask == STS_SERVICE_MASK_L2) {
|
||||
sts_ac_code[0] = 0x0;
|
||||
sts_ac_code[19] = 0x0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -795,10 +795,6 @@ static void SendTxData(void)
|
|||
#endif
|
||||
UTIL_TIMER_Time_t nextTxIn = 0;
|
||||
|
||||
APP_LOG(TS_ON, VLEVEL_H, "\r\n Flag: Heart-beat-timer = %u \r\n upload_message_timer %u \r\n sensor_data_ready = %u \r\n",
|
||||
heart_beat_timer, upload_message_timer, sensor_data_ready);
|
||||
|
||||
//APP_LOG(TS_ON, VLEVEL_H, "\r\nVDDA: %4d (mV)\r\n", batteryLevelmV);
|
||||
//if (LmHandlerIsBusy() == false)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
@ -1006,10 +1002,10 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
}
|
||||
|
||||
STS_LoRa_WAN_Joined = (uint8_t) joinParams->Mode;
|
||||
//STS_REBOOT_CONFIG_Init();
|
||||
//OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||
//OnTxPeriodicityChanged(TxPeriodicity);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,"\r\n STS_LoRa_WAN_Joined = %s \r\n", (STS_LoRa_WAN_Joined == 1)?"ABP":"OTAA");
|
||||
|
||||
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||
OnTxPeriodicityChanged(TxPeriodicity);
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"\r\n STS_LoRa_WAN_Joined = %s \r\n", (STS_LoRa_WAN_Joined == 1)?"ABP":"OTAA");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1312,75 +1308,6 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Uploading MessagePeriodicity/interval Change callback function
|
||||
* @param context ptr of STS Uploading message context
|
||||
*/
|
||||
|
||||
//static void OnYunhornSTSUploadingMessagePeriodicityChanged(uint32_t periodicity)
|
||||
//{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
// UploadingMessagePeriodicity = periodicity;
|
||||
|
||||
//if (UploadingMessagePeriodicity == 0)
|
||||
//{
|
||||
/* Revert to application default periodicity */
|
||||
//UploadingMessagePeriodicity = APP_TX_DUTYCYCLE;
|
||||
//}
|
||||
|
||||
/* Update timer periodicity */
|
||||
|
||||
|
||||
// UTIL_TIMER_Stop(&YunhornSTSUploadingMessageTimer);
|
||||
// UTIL_TIMER_SetPeriod(&YunhornSTSUploadingMessageTimer, UploadingMessagePeriodicity);
|
||||
// UTIL_TIMER_Start(&YunhornSTSUploadingMessageTimer);
|
||||
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||
// APP_LOG(TS_OFF, VLEVEL_M,"**************** UploadingMessagePeriodicity = %u (ms)\r\n", UploadingMessagePeriodicity );
|
||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Sampling Periodicity/interval Change callback function
|
||||
* @param context ptr of STS RSS WakeUp context
|
||||
*/
|
||||
|
||||
//static void OnYunhornSTSSamplingPeriodicityChanged(uint32_t periodicity)
|
||||
//{
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_1 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_1 */
|
||||
// SamplingPeriodicity = periodicity;
|
||||
|
||||
// if (SamplingPeriodicity == 0)
|
||||
// {
|
||||
/* Revert to application default periodicity */
|
||||
// SamplingPeriodicity = APP_TX_DUTYCYCLE;
|
||||
// }
|
||||
|
||||
/* Update timer periodicity */
|
||||
|
||||
//#if (defined(YUNHORN_STS_O6_ENABLED) || defined(YUNHORN_STS_R0_ENABLED))
|
||||
// UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer);
|
||||
// UTIL_TIMER_SetPeriod(&YunhornSTSRSSWakeUpTimer, SamplingPeriodicity);
|
||||
// UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||
// APP_LOG(TS_OFF, VLEVEL_L,"**************** Sampling Timer Periodicity = %u (sec)\r\n", (SamplingPeriodicity/1000) );
|
||||
|
||||
//#else
|
||||
// UTIL_TIMER_Stop(&YunhornSTSSamplingCheckTimer);
|
||||
// UTIL_TIMER_SetPeriod(&YunhornSTSSamplingCheckTimer, SamplingPeriodicity);
|
||||
// UTIL_TIMER_Start(&YunhornSTSSamplingCheckTimer);
|
||||
// APP_LOG(TS_OFF, VLEVEL_L,"**************** SamplingPeriodicity = %u (sec)\r\n", (SamplingPeriodicity/1000) );
|
||||
//#endif
|
||||
|
||||
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
|
||||
|
||||
/* USER CODE END OnTxPeriodicityChanged_2 */
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
// UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0);
|
||||
|
@ -1394,25 +1321,6 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
|
|||
// P8 --- AIR QUALITY AND ODOR LEVEL, SMOKING DETECTION
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Uploading Message Event callback function
|
||||
* @param context ptr of STS Uploading Message context
|
||||
*/
|
||||
/*
|
||||
static void OnYunhornSTSUploadingMessageEvent(void *context)
|
||||
{
|
||||
if (STS_LoRa_WAN_Joined )
|
||||
{
|
||||
|
||||
#ifdef YUNHORN_STS_R0_ENABLED
|
||||
|
||||
heart_beat_timer = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
UTIL_TIMER_Start(&YunhornSTSUploadingMessageTimer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* @brief Yunhorn STS Sensor Sampling Check Timer callback function
|
||||
* @param context ptr of STS Sampling Check context
|
||||
|
@ -1589,12 +1497,19 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
outbuf[i++] = (uint8_t) (((uint16_t)sts_distance_rss_distance)%10+0x30)&0xff;
|
||||
#endif
|
||||
#if (defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)||defined(YUNHORN_STS_R1_ENABLED))
|
||||
#ifdef TOF_1
|
||||
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[0])/100)&0xff;
|
||||
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[0])%100)&0xff;
|
||||
#endif
|
||||
#ifdef TOF_2
|
||||
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[1])/100)&0xff;
|
||||
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[1])%100)&0xff;
|
||||
#endif
|
||||
|
||||
#ifdef TOF_3
|
||||
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[2])/100)&0xff;
|
||||
outbuf[i++] = (uint8_t) (((uint16_t)sts_tof_distance_data[2])%100)&0xff;
|
||||
#endif
|
||||
#endif
|
||||
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
|
||||
|
||||
|
@ -2018,9 +1933,10 @@ void OnStoreSTSCFGContextRequest(void)
|
|||
nvm_store_value[i++] = sts_cfg_nvm.fall_detection_depth_threshold;
|
||||
nvm_store_value[i++] = sts_cfg_nvm.fall_detection_reserve;
|
||||
nvm_store_value[i++] = sts_cfg_nvm.occupancy_overtime_threshold;
|
||||
|
||||
for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) {
|
||||
nvm_store_value[i++] = (sts_cfg_nvm.ac[j]);
|
||||
if ((sts_cfg_nvm.ac[0]!=0x0) && (sts_cfg_nvm.ac[19]!=0x0)) {
|
||||
for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) {
|
||||
nvm_store_value[i++] = (sts_cfg_nvm.ac[j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* USER CODE END OnStoreContextRequest_1 */
|
||||
|
@ -2113,12 +2029,14 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
}
|
||||
periodicity = (periodicity > 10)? periodicity : 10; // in seconds unit
|
||||
TxPeriodicity= periodicity*1000; // to ms
|
||||
if (sts_ac_code[0] !=0 )
|
||||
{ // ensure it's not in production yet
|
||||
OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
||||
} else
|
||||
|
||||
if ((sts_cfg_nvm.ac[0] ==0x0 )&& (sts_cfg_nvm.ac[19]==0x0))
|
||||
{
|
||||
OnTxPeriodicityChanged(APP_TX_DUTYCYCLE); // in msec unit
|
||||
|
||||
} else
|
||||
{ // ensure it's not in production yet
|
||||
OnTxPeriodicityChanged(TxPeriodicity); // in msec unit
|
||||
}
|
||||
|
||||
uint32_t samplingperiodicity = (sts_cfg_nvm.sampling); //Heart-beat or Sampling interval
|
||||
|
@ -2132,12 +2050,13 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
|
||||
//Heart-beat or Sampling interval
|
||||
samplingperiodicity = (samplingperiodicity > 0)? samplingperiodicity : 1; // in seconds unit
|
||||
#ifdef YUNHORN_STS_O6_ENABLED
|
||||
OnYunhornSTSSamplingPeriodicityChanged(samplingperiodicity*1000); // in m-sec unit
|
||||
HeartBeatPeriodicity = samplingperiodicity*1000;
|
||||
#if defined(YUNHORN_STS_O6_ENABLED) ||defined(YUNHORN_STS_O5_ENABLED)
|
||||
OnYunhornSTSSamplingPeriodicityChanged(HeartBeatPeriodicity); // in m-sec unit
|
||||
#endif
|
||||
|
||||
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
|
||||
OnYunhornSTSHeartBeatPeriodicityChanged(samplingperiodicity*1000);
|
||||
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||
#endif
|
||||
|
||||
sts_work_mode = sts_cfg_nvm.work_mode;
|
||||
|
@ -2188,14 +2107,14 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
{
|
||||
char tstbuf[128] =""; uint8_t i=0;
|
||||
uint8_t count = 0;
|
||||
uint8_t mems_Dev_ID[2] = "";
|
||||
uint8_t mems_Dev_ID[2] = {0x0,0x0};
|
||||
|
||||
tstbuf[i++] = (uint8_t) 'S';
|
||||
tstbuf[i++] = (uint8_t) sts_mtmcode1;
|
||||
tstbuf[i++] = (uint8_t) sts_mtmcode2;
|
||||
tstbuf[i++] = (uint8_t) sts_version;
|
||||
tstbuf[i++] = (uint8_t) sts_hardware_ver;
|
||||
tstbuf[i++] = (uint8_t) (99*((GetBatteryLevel()/254)&0xff));
|
||||
tstbuf[i++] = (uint8_t) (99*GetBatteryLevel()/254)&0xff;
|
||||
|
||||
|
||||
count = STS_SENSOR_MEMS_Get_ID(mems_Dev_ID);
|
||||
|
@ -2207,6 +2126,7 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
tstbuf[i++] = (uint8_t) (count*2+1)&0xff; //length of following data
|
||||
#ifdef YUNHORN_STS_O6_ENABLED
|
||||
tstbuf[i++] = (uint8_t)20; //length of following data
|
||||
uint8_t self_test_result[10]={0,0,0,0,0, 0,0,0,0,0};
|
||||
|
@ -2224,16 +2144,23 @@ void STS_SENSOR_Function_Test_Process(void)
|
|||
tstbuf[i++] = (uint8_t) (((uint16_t)sts_distance_rss_distance)%10+0x30)&0xff;
|
||||
#endif
|
||||
|
||||
#if (defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED))
|
||||
tstbuf[i++] = (uint8_t)6; //length of following data
|
||||
MX_TOF_Process();
|
||||
#if (defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)||defined(YUNHORN_STS_R1_ENABLED))
|
||||
tstbuf[i++] = (uint8_t) (count)&0xff;
|
||||
//MX_TOF_Process();
|
||||
STS_TOF_VL53L0X_Range_Process();
|
||||
|
||||
#ifdef TOF_1
|
||||
tstbuf[i++] = (uint8_t) ((sts_tof_distance_data[0] >>8 ) &0xff);
|
||||
tstbuf[i++] = (uint8_t) (sts_tof_distance_data[0] &0xff);
|
||||
#endif
|
||||
#ifdef TOF_2
|
||||
tstbuf[i++] = (uint8_t) ((sts_tof_distance_data[1] >>8 ) &0xff);
|
||||
tstbuf[i++] = (uint8_t) (sts_tof_distance_data[1] &0xff);
|
||||
#endif
|
||||
#ifdef TOF_3
|
||||
tstbuf[i++] = (uint8_t) ((sts_tof_distance_data[2] >>8 ) &0xff);
|
||||
tstbuf[i++] = (uint8_t) (sts_tof_distance_data[2] &0xff);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue