diff --git a/Core/Inc/main.h b/Core/Inc/main.h index d52a238..f7ade35 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -302,21 +302,22 @@ void Error_Handler(void); // STS_M1, WATER LEAKAGE PA1 READ DATA, PA1 -#ifdef STS_M1 -#define WATER_DETECT_Pin GPIO_PIN_1 -#define WATER_DETECT_Port GPIOA -#define WATER_DETECT_STATE HAL_GPIO_ReadPin(WATER_DETECT_Port, WATER_DETECT_Pin) -#endif +//#ifdef STS_M1 +//#define WATER_DETECT_Pin GPIO_PIN_1 +//#define WATER_DETECT_Port GPIOA +//#define WATER_DETECT_STATE HAL_GPIO_ReadPin(WATER_DETECT_Port, WATER_DETECT_Pin) +//#endif #if defined(STS_M1) /* Water leakage MEMS_IF_1, PA1 */ -#define WATER_LEAKAGE_STATUS_Pin GPIO_PIN_1 +#define WATER_LEAKAGE_STATUS_Pin GPIO_PIN_10 #define WATER_LEAKAGE_STATUS_GPIO_Port GPIOA /* Water leakageON_OFF, MEMS_IF_1, PB5 */ #define WATER_LEAKAGE_SWITCH_Pin GPIO_PIN_5 #define WATER_LEAKAGE_SWITCH_GPIO_Port GPIOB - +#define WATER_LEAKAGE_ENABLE HAL_GPIO_WritePin(WATER_LEAKAGE_SWITCH_GPIO_Port, WATER_LEAKAGE_SWITCH_Pin, GPIO_PIN_SET ) +#define WATER_LEAKAGE_DISABLE HAL_GPIO_WritePin(WATER_LEAKAGE_SWITCH_GPIO_Port, WATER_LEAKAGE_SWITCH_Pin, GPIO_PIN_RESET ) #define WATER_LEAKAGE_DATA HAL_GPIO_ReadPin(WATER_LEAKAGE_STATUS_GPIO_Port,WATER_LEAKAGE_STATUS_Pin) #endif diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c index eb308e1..9e99f26 100644 --- a/Core/Src/gpio.c +++ b/Core/Src/gpio.c @@ -76,7 +76,7 @@ void MX_GPIO_Init(void) #else /*Configure GPIO pins : PAPin PAPin */ - GPIO_InitStruct.Pin = BUT1_Pin|BUT2_Pin; + GPIO_InitStruct.Pin = BUT1_Pin; //|BUT2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -173,6 +173,26 @@ void MX_GPIO_Init(void) HAL_GPIO_Init(SOAP_SWITCH_GPIO_Port, &GPIO_InitStruct); #endif + +#if defined(STS_M1) + + HAL_GPIO_WritePin(WATER_LEAKAGE_SWITCH_GPIO_Port, WATER_LEAKAGE_SWITCH_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PAPin PAPin */ + GPIO_InitStruct.Pin = WATER_LEAKAGE_STATUS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; //GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(WATER_LEAKAGE_STATUS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = WATER_LEAKAGE_SWITCH_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(WATER_LEAKAGE_SWITCH_GPIO_Port, &GPIO_InitStruct); + +#endif + /* ============== SOAP LEVEL DETECTION ========================= */ /* EXTI interrupt init*/ @@ -182,8 +202,12 @@ void MX_GPIO_Init(void) HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI1_IRQn); - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + + +// HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); +// HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); #ifdef STS_O5 HAL_NVIC_SetPriority(HALL1_EXTI_IRQn, 10, 0); diff --git a/Core/Src/main.c b/Core/Src/main.c index bc1a023..3e0fcae 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -114,7 +114,8 @@ int main(void) MX_DMA_Init(); MX_LoRaWAN_Init(); } - +//PME_ON; +//WATER_LEAKAGE_ENABLE; /* USER CODE BEGIN 2 */ //MX_USART2_UART_Init(); /* USER CODE END 2 */ diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c index 8aa30e7..3398948 100644 --- a/Core/Src/stm32wlxx_it.c +++ b/Core/Src/stm32wlxx_it.c @@ -243,11 +243,11 @@ void EXTI1_IRQHandler(void) /* USER CODE BEGIN EXTI1_IRQn 0 */ /* USER CODE END EXTI1_IRQn 0 */ -#if defined(STS_M1) - HAL_GPIO_EXTI_IRQHandler(WATER_LEAKAGE_STATUS_Pin); -#else - HAL_GPIO_EXTI_IRQHandler(BUT2_Pin); -#endif +//#if defined(STS_M1) + //HAL_GPIO_EXTI_IRQHandler(WATER_LEAKAGE_STATUS_Pin); +//#else +// HAL_GPIO_EXTI_IRQHandler(BUT2_Pin); +//#endif /* USER CODE BEGIN EXTI1_IRQn 1 */ /* USER CODE END EXTI1_IRQn 1 */ @@ -403,6 +403,9 @@ void EXTI15_10_IRQHandler(void) #ifdef STS_O5 HAL_GPIO_EXTI_IRQHandler(HALL2_Pin); #endif +#ifdef STS_M1 + HAL_GPIO_EXTI_IRQHandler(WATER_LEAKAGE_STATUS_Pin); +#endif #if defined(L8)||defined(STS_P2)||defined(STS_R1D)||defined(STS_R5) HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN); #endif diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 99f2170..cc5bc56 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -491,7 +491,7 @@ void LoRaWAN_Init(void) LmHandlerJoin(ActivationType, ForceRejoin); - UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL); + UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL); UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); if (EventType == TX_ON_TIMER) @@ -540,9 +540,9 @@ void LoRaWAN_Init(void) UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer); #endif - UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL); + //UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL); // UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL); - UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); + //UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer); /* USER CODE END LoRaWAN_Init_Last */ } diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf index 4184ab3..1b95cfe 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS.elf b/STS/BIN/WLE5CC_NODE_STS.elf new file mode 100644 index 0000000..4184ab3 Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS_L8_OK_20241015.elf b/STS/BIN/WLE5CC_NODE_STS_L8_OK_20241015.elf new file mode 100644 index 0000000..abc1f10 Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS_L8_OK_20241015.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS_R1D_JP_20241030.elf b/STS/BIN/WLE5CC_NODE_STS_R1D_JP_20241030.elf new file mode 100644 index 0000000..0491df2 Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS_R1D_JP_20241030.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS_STS_M1_JP_20241031.elf b/STS/BIN/WLE5CC_NODE_STS_STS_M1_JP_20241031.elf new file mode 100644 index 0000000..4184ab3 Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS_STS_M1_JP_20241031.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS_STS_O5_JP_20241031.elf b/STS/BIN/WLE5CC_NODE_STS_STS_O5_JP_20241031.elf new file mode 100644 index 0000000..565b218 Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS_STS_O5_JP_20241031.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS_STS_R4_JP_20241030.elf b/STS/BIN/WLE5CC_NODE_STS_STS_R4_JP_20241030.elf new file mode 100644 index 0000000..86a3d89 Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS_STS_R4_JP_20241030.elf differ diff --git a/STS/BIN/WLE5CC_NODE_STS_STS_R5_20241030A.elf b/STS/BIN/WLE5CC_NODE_STS_STS_R5_20241030A.elf new file mode 100644 index 0000000..7f19afb Binary files /dev/null and b/STS/BIN/WLE5CC_NODE_STS_STS_R5_20241030A.elf differ diff --git a/STS/Core/Inc/yunhorn_sts_prd_conf.h b/STS/Core/Inc/yunhorn_sts_prd_conf.h index ee128a5..01927c2 100644 --- a/STS/Core/Inc/yunhorn_sts_prd_conf.h +++ b/STS/Core/Inc/yunhorn_sts_prd_conf.h @@ -190,7 +190,7 @@ #ifdef STS_M1 #define YUNHORN_STS_M1_LORA_APP_DATA_PORT 6U -#define YUNHORN_STS_M1_LORA_APP_HTBT_PORT 6U +#define YUNHORN_STS_M1_LORA_APP_HTBT_PORT 66U #define YUNHORN_STS_PRD_STRING "STS_M1" #define sts_mtmcode1 0U #define sts_mtmcode2 6U diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index 6f003da..b544663 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -314,8 +314,28 @@ void STS_YunhornSTSEventP1_Process(void) /* STS-M1 Water leakage sensor */ #if defined(STS_M1) + + PME_ON; APP_LOG(TS_OFF, VLEVEL_M, "\r\n WATER LEAKAGE DETECTION Process \n"); + WATER_LEAKAGE_ENABLE; + HAL_Delay(50); + WATER_LEAKAGE_ENABLE; + LED1_ON; + //HAL_Delay(40); + sts_water_leakage_state = WATER_LEAKAGE_DATA; + APP_LOG(TS_OFF, VLEVEL_M, "\r\n DETECTION RESULT =%d \r\n", sts_water_leakage_state); + //LED1_OFF; + //HAL_Delay(50); + WATER_LEAKAGE_DISABLE; + //HAL_Delay(50); + //LED1_ON; + HAL_Delay(40); + sts_water_leakage_state = WATER_LEAKAGE_DATA; + APP_LOG(TS_OFF, VLEVEL_M, "\r\n DETECTION RESULT =%d \r\n", sts_water_leakage_state); + + //PME_OFF; + LED1_OFF; #endif } @@ -573,7 +593,9 @@ void STS_R4_sensor_read(sts_r_sensor_data_t *sts_r_sensor_data) #ifdef STS_M1 void STS_M1_sensor_read(sts_r_sensor_data_t *sts_m_sensor_data) { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n M1 sensor read =%d \r\n", WATER_LEAKAGE_DATA); sts_m_sensor_data->on_off_event = sts_water_leakage_state; + sts_m_sensor_data->on_off_event = WATER_LEAKAGE_DATA; sts_m_sensor_data->measure_tech = 0; //weak current detection } #endif @@ -1658,7 +1680,7 @@ void OnRestoreSTSCFGContextProcess(void) #endif -#if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)||defined(STS_O5) +#if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D)||defined(STS_O5)||defined(STS_M1) OnYunhornSTSHeartBeatPeriodicityChanged(sampling_heartbeat_periodicity*1000); #endif }