diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 604f1ed..c3e9b58 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -520,7 +520,7 @@ void STS_Combined_Status_Processing(void) else { - if ((last_lamp_bar_color != sts_status_color)) + //if ((last_lamp_bar_color != sts_status_color)) { sts_lamp_bar_color = ((sts_service_mask == STS_SERVICE_MASK_L0)? sts_status_color:STS_DARK); diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index fb088be..7b6057f 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -397,7 +397,7 @@ int sts_presence_rss_fall_rise_detection(void) } acc_detector_presence_deactivate(handle); - APP_LOG(TS_OFF, VLEVEL_L,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count); + APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count); // ******** Second Half detection of fall down and rise up @@ -455,7 +455,7 @@ 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,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count); sts_rss_result = (average_result > 3)? 1: 0; average_distance = (1000.0f*average_distance)/average_result; // in meters @@ -572,26 +572,26 @@ void STS_YunhornCheckStandardDeviation(void) // print result - APP_LOG(TS_OFF, VLEVEL_L, "\r\n-------------Distance Average =%6u; Variance = %6u ; Standard =%6u \r\n", + APP_LOG(TS_OFF, VLEVEL_H, "\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)); - APP_LOG(TS_OFF, VLEVEL_L, "-------------Motion Average =%6u; Variance = %6u ; Standard =%6u \r\n", + APP_LOG(TS_OFF, VLEVEL_H, "-------------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)); - APP_LOG(TS_OFF, VLEVEL_L, "-------------ROC Dist Average =%6u; Variance = %6u ; Standard =%6u \r\n", + APP_LOG(TS_OFF, VLEVEL_H, "-------------ROC Dist Average =%6u; Variance = %6u ; Standard =%6u \r\n", (int)(average_roc_distance), (int)(variance_roc_distance), (int)(standard_variance_roc_distance)); - APP_LOG(TS_OFF, VLEVEL_L, "-------------ROC ACC Average =%6u; Variance = %6u ; Standard =%6u \r\n", + APP_LOG(TS_OFF, VLEVEL_H, "-------------ROC ACC Average =%6u; Variance = %6u ; Standard =%6u \r\n", (int)(average_roc_acc), (int)(variance_roc_acc), (int)(standard_variance_roc_acc)); sts_fall_rising_pattern_factor1 = (int)(standard_variance_roc_distance); sts_fall_rising_pattern_factor2 = (int)(fabs(average_presence_distance - fmax(0,last_average_presence_distance))*100.0f); // in cm - APP_LOG(TS_OFF, VLEVEL_L,"Avg-Dist =%6u, Last_AVG-Dist =%6u \r\n", (int)(average_presence_distance*1000.0f), (int)(last_average_presence_distance*1000.0f)); + APP_LOG(TS_OFF, VLEVEL_H,"Avg-Dist =%6u, Last_AVG-Dist =%6u \r\n", (int)(average_presence_distance*1000.0f), (int)(last_average_presence_distance*1000.0f)); - APP_LOG(TS_OFF, VLEVEL_L, "Threshold 1: \r\nAcc = %6u \r\nMeasure 1 = %6u ---- \r\n", + APP_LOG(TS_OFF, VLEVEL_H, "Threshold 1: \r\nAcc = %6u \r\nMeasure 1 = %6u ---- \r\n", (int)(sts_fall_detection_acc_threshold), (int)(sts_fall_rising_pattern_factor1)); - APP_LOG(TS_OFF, VLEVEL_L, "Threshold 2: \r\nDis = %6u cm \r\nMeasure 2 = %6u cm ---- \r\n", + APP_LOG(TS_OFF, VLEVEL_H, "Threshold 2: \r\nDis = %6u cm \r\nMeasure 2 = %6u cm ---- \r\n", (int)(sts_fall_detection_depth_threshold), (int)(sts_fall_rising_pattern_factor2)); @@ -623,7 +623,7 @@ void STS_YunhornCheckStandardDeviation(void) if ( sts_fall_rising_detected_result == STS_PRESENCE_FALL ) { - APP_LOG(TS_OFF, VLEVEL_L, "\r\n Suspecious Object FALL DOWN detected \r\n"); + APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n >>>>>>>>>>>>>>>>> Suspecious Object FALL DOWN detected \r\n"); } //if (average_presence_distance > DEFAULT_START_M) { @@ -639,7 +639,7 @@ void STS_YunhornCheckStandardDeviation(void) if ( sts_fall_rising_detected_result == STS_PRESENCE_RISING ) { - APP_LOG(TS_OFF, VLEVEL_L, "\r\n Suspecious Object RISING UP detected \r\n"); + APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n >>>>>>>>>>>>>>>>> Suspecious Object RISING UP detected \r\n"); } diff --git a/Core/Src/yunhorn_sts_presence_sensor.c b/Core/Src/yunhorn_sts_presence_sensor.c index 97427f7..ac6a2b1 100644 --- a/Core/Src/yunhorn_sts_presence_sensor.c +++ b/Core/Src/yunhorn_sts_presence_sensor.c @@ -56,6 +56,7 @@ extern volatile uint16_t sts_fall_rising_pattern_factor1; extern volatile uint16_t sts_roc_acc_standard_variance; extern uint8_t luminance_level; SysTime_t mems_event_time; + #endif /* USER CODE END Includes */ @@ -136,24 +137,27 @@ void STS_YunhornSTSEventRFAC_Process(void) void STS_FallDetection_LampBarProcess(void) { + char buf[32]=""; uint8_t i=0; - char outbuf[128]=""; - switch (sts_fall_rising_detected_result) { case STS_PRESENCE_LAYDOWN: - case STS_PRESENCE_FALL: - sts_lamp_bar_color = STS_RED_BLUE; - //sts_status_color = STS_RED_BLUE; - STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); - outbuf[i++] = (uint8_t)sts_lamp_bar_color; - outbuf[i++] = (uint8_t)sts_work_mode; - outbuf[i++] = (uint8_t)sts_fall_rising_detected_result; - outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF; - outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF; - outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF; - outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF; + break; + case STS_PRESENCE_FALL: + sts_lamp_bar_color = STS_BLUE; //STS_RED_BLUE; + sts_status_color = STS_BLUE; //STS_RED_BLUE; + sts_rss_result = STS_RESULT_MOTION; + STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); + + buf[i++] = (uint8_t)sts_lamp_bar_color; + buf[i++] = (uint8_t)sts_work_mode; + buf[i++] = (uint8_t)sts_fall_rising_detected_result; + + buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF; + buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF; + buf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF; + buf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF; break; case STS_PRESENCE_RISING: @@ -161,24 +165,22 @@ void STS_FallDetection_LampBarProcess(void) sts_status_color = STS_RED; // normal occupancy status sts_rss_result = STS_RESULT_MOTION; STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); - outbuf[i++] = (uint8_t)sts_lamp_bar_color; - outbuf[i++] = (uint8_t)sts_work_mode; - outbuf[i++] = (uint8_t)sts_fall_rising_detected_result; + buf[i++] = (uint8_t)sts_lamp_bar_color; + buf[i++] = (uint8_t)sts_work_mode; + buf[i++] = (uint8_t)sts_fall_rising_detected_result; // TESTING ONLY TO BE REMOVED - outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF; - outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF; - outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF; - outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF; - - + buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF; + buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF; + buf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF; + buf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF; break; default: break; } - STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, outbuf); + STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, buf); sts_fall_rising_detected_result = STS_PRESENCE_NONE; diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 480f8fd..51e8812 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -698,7 +698,10 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params) /* USER CODE END OnRxData_1 */ } +static void PrepareSendTxData(void) +{ +} static void SendTxData(void) { /* USER CODE BEGIN SendTxData_1 */ @@ -2044,7 +2047,7 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char AppData.Port = appDataPort; AppData.BufferSize = (sts_service_mask >1 ?0:appBufferSize); - //APP_LOG(TS_OFF, VLEVEL_L, "###########Service Mask = %d Buffer Size =%d \r\n", sts_service_mask, AppData.BufferSize); + APP_LOG(TS_OFF, VLEVEL_L, "###########Service Mask = %d Buffer Size =%d \r\n", sts_service_mask, AppData.BufferSize); if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET)) { @@ -2055,14 +2058,14 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false); if (LORAMAC_HANDLER_SUCCESS == status) { - APP_LOG(TS_ON, VLEVEL_L, "SEND REQUEST\r\n"); + APP_LOG(TS_ON, VLEVEL_H, "SEND REQUEST\r\n"); } else if (LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED == status) { nextTxIn = LmHandlerGetDutyCycleWaitTime(); if (nextTxIn > 0) { - APP_LOG(TS_ON, VLEVEL_L, "Next Tx in : ~%d second(s)\r\n", (nextTxIn / 1000)); + APP_LOG(TS_ON, VLEVEL_H, "Next Tx in : ~%d second(s)\r\n", (nextTxIn / 1000)); } } @@ -2354,8 +2357,8 @@ void STS_SENSOR_Function_Test_Process(void) #endif } - memset(outbuf,sizeof(outbuf),0x30); - memcpy(outbuf, tstbuf, i); + memset((void*)outbuf,sizeof(outbuf),0x30); + memcpy((void*)outbuf, tstbuf, i); //STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf); } diff --git a/STM32CubeIDE/.settings/language.settings.xml b/STM32CubeIDE/.settings/language.settings.xml index 31d4722..4686da5 100644 --- a/STM32CubeIDE/.settings/language.settings.xml +++ b/STM32CubeIDE/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/STM32CubeIDE/Release/Application/User/Core/sts_lamp_bar.cyclo b/STM32CubeIDE/Release/Application/User/Core/sts_lamp_bar.cyclo index a67b02d..43151f6 100644 --- a/STM32CubeIDE/Release/Application/User/Core/sts_lamp_bar.cyclo +++ b/STM32CubeIDE/Release/Application/User/Core/sts_lamp_bar.cyclo @@ -15,7 +15,7 @@ sts_lamp_bar.c:342:6:STS_Lamp_Bar_Refresh 1 sts_lamp_bar.c:163:6:STS_RSS_Smart_Presence_Detection 1 sts_lamp_bar.c:180:6:STS_YunhornSTSEventP3_Process 2 sts_lamp_bar.c:386:6:STS_Reed_Hall_Working 1 -sts_lamp_bar.c:390:6:STS_Combined_Status_Processing 54 +sts_lamp_bar.c:390:6:STS_Combined_Status_Processing 53 sts_lamp_bar.c:84:6:STS_YunhornSTSEventP1_Process 5 sts_lamp_bar.c:103:6:STS_YunhornSTSEventP2_Process 6 sts_lamp_bar.c:549:6:HAL_TIM_PWM_PulseFinishedCallback 1 diff --git a/STM32CubeIDE/Release/Application/User/Core/yunhorn_sts_presence_sensor.cyclo b/STM32CubeIDE/Release/Application/User/Core/yunhorn_sts_presence_sensor.cyclo index e65f176..6c5f945 100644 --- a/STM32CubeIDE/Release/Application/User/Core/yunhorn_sts_presence_sensor.cyclo +++ b/STM32CubeIDE/Release/Application/User/Core/yunhorn_sts_presence_sensor.cyclo @@ -1,27 +1,27 @@ -yunhorn_sts_presence_sensor.c:486:6:STS_SENSOR_Power_ON.part.0 1 -yunhorn_sts_presence_sensor.c:100:6:STS_YunhornAuthenticationCode_Process 3 -yunhorn_sts_presence_sensor.c:115:6:STS_YunhornSTSEventRFAC_Process 6 -yunhorn_sts_presence_sensor.c:137:6:STS_FallDetection_LampBarProcess 3 -yunhorn_sts_presence_sensor.c:187:6:STS_YunhornSTSFallDetection 1 -yunhorn_sts_presence_sensor.c:195:6:STS_PRESENCE_SENSOR_NVM_CFG 1 -yunhorn_sts_presence_sensor.c:225:6:STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE 1 -yunhorn_sts_presence_sensor.c:235:6:STS_PRESENCE_SENSOR_Init_Send_Data 1 -yunhorn_sts_presence_sensor.c:257:6:STS_PRESENCE_SENSOR_Prepare_Send_Data 3 -yunhorn_sts_presence_sensor.c:285:6:STS_PRESENCE_SENSOR_Read 1 -yunhorn_sts_presence_sensor.c:305:6:STS_PRESENCE_SENSOR_GetValue 1 -yunhorn_sts_presence_sensor.c:310:6:STS_PRESENCE_SENSOR_WakeUp_Process_Sampling 1 -yunhorn_sts_presence_sensor.c:317:6:STS_PRESENCE_SENSOR_After_Wake_Up 1 -yunhorn_sts_presence_sensor.c:348:6:STS_PRESENCE_SENSOR_TOF_Init 1 -yunhorn_sts_presence_sensor.c:353:6:STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init 1 -yunhorn_sts_presence_sensor.c:359:6:STS_PRESENCE_SENSOR_RSS_Init 1 -yunhorn_sts_presence_sensor.c:329:6:STS_PRESENCE_SENSOR_Init 1 -yunhorn_sts_presence_sensor.c:373:6:STS_MOTION_SENSOR_ACT_INACT_DURATION_Init 1 -yunhorn_sts_presence_sensor.c:378:6:STS_PRESENCE_SENSOR_Get_Event_Status 1 -yunhorn_sts_presence_sensor.c:407:6:STS_PRESENCE_SENSOR_Distance_Measure_Process 1 -yunhorn_sts_presence_sensor.c:423:6:STS_PRESENCE_SENSOR_Function_Test_Process 2 -yunhorn_sts_presence_sensor.c:448:6:STS_PRESENCE_SENSOR_Enable_Wake_Up_Detection 1 -yunhorn_sts_presence_sensor.c:453:6:STS_PRESENCE_SENSOR_Disable_Wake_Up_Detection 1 -yunhorn_sts_presence_sensor.c:458:9:STS_SENSOR_MEMS_Get_ID 2 -yunhorn_sts_presence_sensor.c:486:6:STS_SENSOR_Power_ON 2 -yunhorn_sts_presence_sensor.c:504:6:STS_SENSOR_Power_OFF 2 -yunhorn_sts_presence_sensor.c:522:6:STS_SENSOR_MEMS_Reset 2 +yunhorn_sts_presence_sensor.c:488:6:STS_SENSOR_Power_ON.part.0 1 +yunhorn_sts_presence_sensor.c:101:6:STS_YunhornAuthenticationCode_Process 3 +yunhorn_sts_presence_sensor.c:116:6:STS_YunhornSTSEventRFAC_Process 6 +yunhorn_sts_presence_sensor.c:138:6:STS_FallDetection_LampBarProcess 3 +yunhorn_sts_presence_sensor.c:189:6:STS_YunhornSTSFallDetection 1 +yunhorn_sts_presence_sensor.c:197:6:STS_PRESENCE_SENSOR_NVM_CFG 1 +yunhorn_sts_presence_sensor.c:227:6:STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE 1 +yunhorn_sts_presence_sensor.c:237:6:STS_PRESENCE_SENSOR_Init_Send_Data 1 +yunhorn_sts_presence_sensor.c:259:6:STS_PRESENCE_SENSOR_Prepare_Send_Data 3 +yunhorn_sts_presence_sensor.c:287:6:STS_PRESENCE_SENSOR_Read 1 +yunhorn_sts_presence_sensor.c:307:6:STS_PRESENCE_SENSOR_GetValue 1 +yunhorn_sts_presence_sensor.c:312:6:STS_PRESENCE_SENSOR_WakeUp_Process_Sampling 1 +yunhorn_sts_presence_sensor.c:319:6:STS_PRESENCE_SENSOR_After_Wake_Up 1 +yunhorn_sts_presence_sensor.c:350:6:STS_PRESENCE_SENSOR_TOF_Init 1 +yunhorn_sts_presence_sensor.c:355:6:STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init 1 +yunhorn_sts_presence_sensor.c:361:6:STS_PRESENCE_SENSOR_RSS_Init 1 +yunhorn_sts_presence_sensor.c:331:6:STS_PRESENCE_SENSOR_Init 1 +yunhorn_sts_presence_sensor.c:375:6:STS_MOTION_SENSOR_ACT_INACT_DURATION_Init 1 +yunhorn_sts_presence_sensor.c:380:6:STS_PRESENCE_SENSOR_Get_Event_Status 1 +yunhorn_sts_presence_sensor.c:409:6:STS_PRESENCE_SENSOR_Distance_Measure_Process 1 +yunhorn_sts_presence_sensor.c:425:6:STS_PRESENCE_SENSOR_Function_Test_Process 2 +yunhorn_sts_presence_sensor.c:450:6:STS_PRESENCE_SENSOR_Enable_Wake_Up_Detection 1 +yunhorn_sts_presence_sensor.c:455:6:STS_PRESENCE_SENSOR_Disable_Wake_Up_Detection 1 +yunhorn_sts_presence_sensor.c:460:9:STS_SENSOR_MEMS_Get_ID 2 +yunhorn_sts_presence_sensor.c:488:6:STS_SENSOR_Power_ON 2 +yunhorn_sts_presence_sensor.c:506:6:STS_SENSOR_Power_OFF 2 +yunhorn_sts_presence_sensor.c:524:6:STS_SENSOR_MEMS_Reset 2 diff --git a/STM32CubeIDE/Release/YUNHORN_STS_E5CC_AS923_POC.elf b/STM32CubeIDE/Release/YUNHORN_STS_E5CC_AS923_POC.elf index ddce70e..668557d 100644 Binary files a/STM32CubeIDE/Release/YUNHORN_STS_E5CC_AS923_POC.elf and b/STM32CubeIDE/Release/YUNHORN_STS_E5CC_AS923_POC.elf differ