MINOR IMPROVE
This commit is contained in:
parent
cb73171c44
commit
ec8dbf5591
|
@ -47,12 +47,12 @@ extern "C" {
|
|||
/**
|
||||
* @brief Verbose level for all trace logs
|
||||
*/
|
||||
#define VERBOSE_LEVEL VLEVEL_OFF
|
||||
#define VERBOSE_LEVEL VLEVEL_M
|
||||
|
||||
/**
|
||||
* @brief Enable trace logs
|
||||
*/
|
||||
#define APP_LOG_ENABLED 0
|
||||
#define APP_LOG_ENABLED 1
|
||||
|
||||
/**
|
||||
* @brief Activate monitoring (probes) of some internal RF signals for debug purpose
|
||||
|
@ -75,7 +75,7 @@ extern "C" {
|
|||
* @brief Enable/Disable MCU Debugger pins (dbg serial wires)
|
||||
* @note by HW serial wires are ON by default, need to put them OFF to save power
|
||||
*/
|
||||
#define DEBUGGER_ENABLED 0
|
||||
#define DEBUGGER_ENABLED 1
|
||||
|
||||
/**
|
||||
* @brief Disable Low Power mode
|
||||
|
|
|
@ -266,6 +266,7 @@ void STS_Combined_Status_Processing(void)
|
|||
} else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown ))
|
||||
{
|
||||
sts_status_color = STS_RED;
|
||||
#if 0
|
||||
switch(sts_fall_rising_detected_result) {
|
||||
case STS_PRESENCE_LAYDOWN:
|
||||
sts_lamp_bar_color = STS_YELLOW;
|
||||
|
@ -280,6 +281,7 @@ void STS_Combined_Status_Processing(void)
|
|||
sts_status_color = STS_RED;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown )
|
||||
{
|
||||
sts_status_color = STS_RED_BLUE;
|
||||
|
|
|
@ -353,7 +353,6 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
}
|
||||
// BEFORE MERGE FIRST AND SECOND HALF FALL RISE DETECTION
|
||||
|
||||
|
||||
if (!acc_detector_presence_activate(handle))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "Failed to activate detector \n");
|
||||
|
@ -370,7 +369,6 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
uint16_t motion_in_zone[10]={0x0};
|
||||
uint16_t detected_zone=0;
|
||||
//for (k=0; k<5; k++) {motion_in_zone[k]=0;}
|
||||
|
||||
#if 1
|
||||
for (int i = 0; i < (iterations/2); i++)
|
||||
{
|
||||
|
@ -410,11 +408,12 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
}
|
||||
|
||||
acc_detector_presence_deactivate(handle);
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
#endif
|
||||
// ******** Second Half detection of fall down and rise up
|
||||
//if (sts_presence_fall_detection == 1)
|
||||
{
|
||||
//{
|
||||
set_default_fall_rise_configuration(presence_configuration);
|
||||
|
||||
if (!acc_detector_presence_reconfigure(&handle, presence_configuration))
|
||||
|
@ -433,7 +432,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
return false;
|
||||
}
|
||||
acc_detector_presence_configuration_destroy(&presence_configuration);
|
||||
// set to full lenght of iteration
|
||||
// set to full length of iteration
|
||||
for (int i = 0; i < (iterations/2); i++)
|
||||
{
|
||||
success = acc_detector_presence_get_next(handle, &result);
|
||||
|
@ -470,10 +469,9 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
|
||||
acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // DEFAULT_UPDATE_RATE);
|
||||
}
|
||||
|
||||
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
APP_LOG(TS_OFF, VLEVEL_H,"Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
}
|
||||
|
||||
sts_rss_result = (average_result > 1)? 1: 0;
|
||||
if ((last_sts_rss_result ==STS_RESULT_NO_MOTION)&& (sts_rss_result==STS_RESULT_MOTION))
|
||||
{
|
||||
|
|
|
@ -240,7 +240,8 @@ void STS_YunhornSTSEventP2_Process(void)
|
|||
//STS_Lamp_Bar_Refresh(); //TODO XXX eliminate refresh every second.... try
|
||||
if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE))
|
||||
{
|
||||
STS_RSS_Smart_Presence_Detection();
|
||||
//STS_RSS_Smart_Presence_Detection();
|
||||
sts_presence_rss_fall_rise_detection();
|
||||
|
||||
sts_rss_result_changed_flag = (sts_rss_result == last_sts_rss_result)? 0:1;
|
||||
last_sts_rss_result = sts_rss_result;
|
||||
|
|
|
@ -854,25 +854,31 @@ static void SendTxData(void)
|
|||
uint32_t i = 0;
|
||||
|
||||
STS_PRESENCE_SENSOR_Prepare_Send_Data(&sensorData);
|
||||
if (sts_work_mode == STS_DUAL_MODE) {
|
||||
|
||||
AppData.Port = LORAWAN_USER_APP_PORT;
|
||||
if (sts_work_mode == STS_DUAL_MODE)
|
||||
{
|
||||
AppData.Port = (uint8_t)YUNHORN_STS_O6_LORA_APP_DATA_PORT;
|
||||
|
||||
} else if (sts_work_mode == STS_UNI_MODE) {
|
||||
|
||||
AppData.Port = (uint8_t)YUNHORN_STS_O7_LORA_APP_DATA_PORT;
|
||||
}
|
||||
|
||||
if ((heart_beat_timer != 0L)) // sensor data OVERWRITE heart-beat message, 2024-05-12
|
||||
{
|
||||
heart_beat_timer=0;
|
||||
AppData.Port = (uint8_t)sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1;
|
||||
if (sts_work_mode == STS_DUAL_MODE)
|
||||
AppData.Port = (uint8_t)YUNHORN_STS_O6_LORA_APP_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
||||
else if (sts_work_mode == STS_UNI_MODE)
|
||||
AppData.Port = (uint8_t)YUNHORN_STS_O7_LORA_APP_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
||||
|
||||
//AppData.Port = (uint8_t)sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1;
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(AppLedStateOn|0x80)&0x0ff;
|
||||
AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05
|
||||
|
||||
} else if ((sensor_data_ready!= 0U)) //sensor_data_ready for manual push button-1 trigger)
|
||||
{
|
||||
sensor_data_ready =0;
|
||||
AppData.Buffer[i++] = (uint8_t)(AppLedStateOn|0x80)&0xff; //00 ************ MUST KEEP IT HERE, NON-ZERO ******
|
||||
AppData.Buffer[i++] = (uint8_t)(AppLedStateOn|0x80)&0x0ff; //00 ************ MUST KEEP IT HERE, NON-ZERO ******
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.lamp_bar_color)&0xff; //01
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.workmode)&0xff; //02 WORK MODE
|
||||
|
@ -930,16 +936,6 @@ static void SendTxData(void)
|
|||
if (LORAMAC_HANDLER_SUCCESS == status) {
|
||||
OnSysTimeUpdate();
|
||||
}
|
||||
|
||||
#if 0 //debug line
|
||||
struct tm localtime;
|
||||
SysTime_t UnixEpoch = SysTimeGet();
|
||||
UnixEpoch.Seconds -= 18; /*removing leap seconds*/
|
||||
UnixEpoch.Seconds += 3600 * TIME_ZONE_SHIFT; /*adding time-zone-shift hours*/
|
||||
SysTimeSet(UnixEpoch);
|
||||
SysTimeLocalTime(UnixEpoch.Seconds, &localtime);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
|
||||
|
@ -951,12 +947,15 @@ static void SendTxData(void)
|
|||
}
|
||||
|
||||
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n-----Send status =%d------------\r\n", status);
|
||||
|
||||
if (LORAMAC_HANDLER_SUCCESS == status)
|
||||
{
|
||||
APP_LOG(TS_ON, VLEVEL_H, "SEND REQUEST\r\n");
|
||||
APP_LOG(TS_ON, VLEVEL_M, "SEND REQUEST \r\n");
|
||||
}
|
||||
else if (LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED == status)
|
||||
{
|
||||
|
||||
nextTxIn = LmHandlerGetDutyCycleWaitTime();
|
||||
if (nextTxIn > 0)
|
||||
{
|
||||
|
@ -1182,7 +1181,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
if (joinParams->Status == LORAMAC_HANDLER_SUCCESS)
|
||||
{
|
||||
UTIL_TIMER_Stop(&JoinLedTimer);
|
||||
STS_Lamp_Bar_Set_Dark();
|
||||
//STS_Lamp_Bar_Set_Dark();
|
||||
sts_lamp_bar_color = STS_GREEN;
|
||||
STS_WS2812B_Refresh();
|
||||
#ifndef STM32WLE5xx
|
||||
|
@ -1213,7 +1212,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
|||
}
|
||||
heart_beat_timer = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
HAL_Delay(5000);
|
||||
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
||||
/* USER CODE END OnJoinRequest_1 */
|
||||
}
|
||||
|
@ -1815,7 +1814,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nTime YYYYMMDD=%4d:%2d:%2d HHMMSS=%2d:%2d:%2d \r\n",
|
||||
mylocal.tm_year, mylocal.tm_mon, mylocal.tm_mday, mylocal.tm_hour, mylocal.tm_min, mylocal.tm_sec);
|
||||
#endif
|
||||
outbuf[i++] = (uint8_t) (localtime.tm_year+1900)>>8&0xff;
|
||||
outbuf[i++] = (uint8_t) (localtime.tm_year+1900)>>8&0x0ff;
|
||||
outbuf[i++] = (uint8_t) (localtime.tm_year+1900)&0xff;
|
||||
outbuf[i++] = (uint8_t) localtime.tm_mon+1;
|
||||
outbuf[i++] = (uint8_t) localtime.tm_mday;
|
||||
|
|
Loading…
Reference in New Issue