diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 12fed74..25748bd 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -471,13 +471,13 @@ int sts_presence_rss_fall_rise_detection(void) APP_LOG(TS_OFF, VLEVEL_H,"Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count); sts_rss_result = (average_result > 0)? 1: 0; - +#if 0 APP_LOG(TS_OFF, VLEVEL_H,"Average Motion Result = %u OUTPUT RSS RESULT=%u \r\n", (int)average_result, sts_rss_result); for (k=0; k<10; k++) { if (motion_in_zone[k]>0) - APP_LOG(TS_OFF, VLEVEL_L,"\nMotion in Zone %u, Count=%u \r\n", k, motion_in_zone[k]); + APP_LOG(TS_OFF, VLEVEL_H,"\nMotion in Zone %u, Count=%u \r\n", k, motion_in_zone[k]); } - +#endif average_distance = (1000.0f*average_distance)/average_result; // in meters average_score = (1000.0f*average_score)/average_result; sts_presence_rss_distance = average_distance; @@ -594,10 +594,10 @@ void STS_YunhornCheckStandardDeviation(void) #ifdef LOG_RSS APP_LOG(TS_OFF, VLEVEL_L, "\r\n-------------Distance Average =%6u; Variance = %6u ; Standard =%6u \r\n", (int)(average_presence_distance*1000.0f), (int)(variance_presence_distance*1000.0f), (int)(standard_variance_presence_distance*1000.0f)); -#endif + APP_LOG(TS_OFF, VLEVEL_M, "-------------Motion Average =%6u; Variance = %6u ; Standard =%6u \r\n", (int)(average_presence_score*1000.0f), (int)(variance_presence_score*1000.0f), (int)(standard_variance_presence_score*1000.0f)); -#ifdef LOG_RSS + APP_LOG(TS_OFF, VLEVEL_L, "-------------ROC Dist Average =%6u; Variance = %6u ; Standard =%6u \r\n", (int)(average_roc_distance), (int)(variance_roc_distance), (int)(standard_variance_roc_distance)); diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 929803b..e83f5e2 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -532,18 +532,15 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) sts_o7_sensorData.state_sensor2_on_off = sts_rss_result; sts_o7_sensorData.state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read sts_o7_sensorData.state_sensor4_on_off = sts_rss_2nd_result; - APP_LOG(TS_OFF, VLEVEL_M, "\r\nPrepare Upload Message............\r\n"); if (sts_rss_result == STS_RESULT_MOTION) { - APP_LOG(TS_OFF, VLEVEL_M, "\r\n......STS_RESULT MOTION............\r\n"); - sts_o7_sensorData.rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF; sts_o7_sensorData.rss_presence_score = (uint16_t)(sts_presence_rss_score)&0xFFFF; // uint8_t sts_unconcious_state; // uint16_t sts_unconcious_threshold, sts_unconcious_threshold_duration; } else { - APP_LOG(TS_OFF, VLEVEL_M, "\r\n......STS_NO MOTION............\r\n"); + sts_o7_sensorData.rss_presence_distance = 0x0; sts_o7_sensorData.rss_presence_score = 0x0; } @@ -553,7 +550,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) if (sts_fall_rising_detected_result != STS_PRESENCE_NONE) { -#ifdef STS_O7 +#if (defined(STS_O7)&&!defined(STS_O6)) APP_LOG(TS_OFF, VLEVEL_M, "\r\n......FALL RISING DETECTION RESULT: %25s............\r\n",sts_presence_fall_detection_message[sts_fall_rising_detected_result] ); #endif sts_o7_sensorData.fall_speed = (uint8_t)sts_fall_rising_pattern_factor1; @@ -570,7 +567,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) if (check_time_tmp > sts_occupancy_overtime_threshold*60) { - APP_LOG(TS_OFF, VLEVEL_M, "\r\n......OVER STAY............\r\n"); + sts_occupancy_overtime_state = 1U; sts_o7_sensorData.overtime = sts_occupancy_overtime_state; sts_o7_sensorData.over_stay_duration = check_time_tmp; diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index a5c112d..f52b4dd 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -807,12 +807,10 @@ static void SendTxData(void) UTIL_TIMER_Time_t nextTxIn = 0; uint8_t i = 0; - APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter \r\n\n"); - //if (LmHandlerIsBusy() == false) { AppData.Port = LORAWAN_USER_APP_PORT; - //AppData.Buffer[i++] = AppLedStateOn; //#01 + //AppData.Buffer[i++] = AppLedStateOn; //#01 STS_PRESENCE_SENSOR_Prepare_Send_Data(); if ((heart_beat_timer != 0L)) // sensor data OVERWRITE heart-beat message, 2024-05-12 @@ -820,18 +818,12 @@ static void SendTxData(void) heart_beat_timer=0; AppData.Port = sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1; AppData.Buffer[i++]= AppLedStateOn|0x80; - AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05 - APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter Heart-Beat \r\n\n"); + AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05 - } else if ((upload_message_timer != 0U)||(sensor_data_ready!= 0U)) //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) { - - APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter Sensor Data Ready \r\n\n"); sensor_data_ready =0; - - //AppData.Buffer[i++] = AppLedStateOn; - //STS_PRESENCE_SENSOR_Prepare_Send_Data(); AppData.Buffer[i++] = (uint8_t)(sts_o7_sensorData.lamp_bar_color)&0xff; //01 @@ -857,12 +849,12 @@ static void SendTxData(void) #endif #if 1 APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color | Mode |\r\n######| %6s | %5s |\r\n",(char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]]); + "\r\n######| Color | Mode |\r\n######| %6s | %5s |\r\n",(char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]]); - APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 | Distance(mm) | MotionScore|\r\n######| %6u | %6u | %6u | %6u | %6u | %6u |\r\n", + APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 | Distance(mm) | MotionScore|\r\n######| %6u | %6u | %6u | %6u | %06u | %04u |\r\n", AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4],AppData.Buffer[5],AppData.Buffer[6]<<8|AppData.Buffer[7],AppData.Buffer[8]<<8|AppData.Buffer[9]); - APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Unconcious | Fall state | Over_Stay state| Over stay duration |\r\n######| %1d | %1d | %1d | %4d |", + APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Unconcious | Fall state| Over_Stay state| Over Stay duration|\r\n######| %1d | %1d | %1d | %4d |\r\n", sts_o7_sensorData.unconcious_state, sts_o7_sensorData.fall_state, sts_o7_sensorData.over_stay_duration, sts_o7_sensorData.unconcious_duration ); #endif @@ -870,9 +862,7 @@ static void SendTxData(void) AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i); - - APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n** ** AppData.PORT =%3d ** ** AppData.BufferSize=%3d ** Count Size=%3d\r\n", AppData.Port, AppData.BufferSize, i); - //AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i); + //AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i); if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET)) {