diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index 92da7ad..b5f3f66 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -109,15 +109,15 @@ void MX_GPIO_Init(void) /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = BUT3_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct); #ifdef STS_O7 - HAL_NVIC_SetPriority(HALL1_EXTI_IRQn, 0, 0); + HAL_NVIC_SetPriority(HALL1_EXTI_IRQn, 15, 0); HAL_NVIC_EnableIRQ(HALL1_EXTI_IRQn); - HAL_NVIC_SetPriority(HALL2_EXTI_IRQn, 0, 0); + HAL_NVIC_SetPriority(HALL2_EXTI_IRQn, 15, 0); HAL_NVIC_EnableIRQ(HALL2_EXTI_IRQn); HAL_NVIC_SetPriority(A111_SENSOR_INTERRUPT_EXTI_IRQn, 0, 0); diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c index dc32780..73a5012 100644 --- a/Core/Src/stm32wlxx_it.c +++ b/Core/Src/stm32wlxx_it.c @@ -232,7 +232,7 @@ void EXTI0_IRQHandler(void) /* USER CODE END EXTI0_IRQn 0 */ #ifdef STS_O7 HAL_GPIO_EXTI_IRQHandler(HALL1_Pin); - sts_reed_hall_change_flag = 1; + //sts_reed_hall_change_flag = 1; #else HAL_GPIO_EXTI_IRQHandler(BUT1_Pin); sts_reed_hall_change_flag = 1; diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 11fa6ec..62e3d95 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -399,7 +399,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 @@ -457,7 +457,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 @@ -574,26 +574,26 @@ void STS_YunhornCheckStandardDeviation(void) // print result #ifdef LOG_RSS - 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)); #endif diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 833ec05..9c5de05 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -632,6 +632,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) case HALL1_Pin: //sts_reed_hall_ext_int = 1; sts_hall1_read = HALL1_STATE; + APP_LOG(TS_OFF, VLEVEL_M, "DOOR CONTACT CHANGED TO =%d \r\n", HALL1_STATE); //UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); /* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */ // if (EventType == TX_ON_EVENT) @@ -642,6 +643,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) case HALL2_Pin: sts_hall2_read = HALL2_STATE; + APP_LOG(TS_OFF, VLEVEL_M, "EMERGENCY BUTTON CHANGED TO =%d \r\n", HALL2_STATE); // UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); break; @@ -875,9 +877,9 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.overtime); //13 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.over_stay_duration>>8); //13 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.over_stay_duration); //13 occupancy over time or not - APP_LOG(TS_OFF, VLEVEL_L, + APP_LOG(TS_OFF, VLEVEL_M, "\r\n######| Color | Mode |\r\n######| %4s | %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, + APP_LOG(TS_OFF, VLEVEL_M, "\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay| Fall Detected|" "\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n", AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], @@ -915,7 +917,7 @@ static void SendTxData(void) i = PrepareSendTxData(); } - if (i!=0) + if (i !=0 ) { AppData.BufferSize = (sts_service_mask >= STS_SERVICE_MASK_L2? 0:i); diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index 942aeaa..b45829e 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ