From 58a894f7184fe118f087c4b22a82f82a305db961 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Mon, 29 Jul 2024 12:35:31 +0800 Subject: [PATCH] --- remove unused code --- Core/Inc/sys_conf.h | 6 ++-- Core/Src/yunhorn_sts_process.c | 59 ++++++++-------------------------- LoRaWAN/App/lora_app.c | 6 ++-- 3 files changed, 21 insertions(+), 50 deletions(-) diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index 2661f50..2b87ca3 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -50,12 +50,12 @@ extern "C" { * #define VLEVEL_M 2 functional traces * #define VLEVEL_H 3 all traces */ -#define VERBOSE_LEVEL VLEVEL_OFF +#define VERBOSE_LEVEL VLEVEL_L /** * @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 @@ -78,7 +78,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 diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 98af6cd..134bb2a 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -310,7 +310,7 @@ void STS_YunhornSTSEventP3_Process(void) */ void STS_YunhornSTSEventP4_Process(void) { - STS_SENSOR_Power_ON(0); + PME_ON; #ifdef LED_ONBOARD LED_ON; HAL_Delay(10); @@ -326,7 +326,7 @@ void STS_YunhornSTSEventP4_Process(void) STS_TOF250_Range_Process(); #endif - STS_SENSOR_Power_OFF(0); + PME_OFF; } @@ -351,7 +351,7 @@ void STS_YunhornSTSEventP5_Process(void) void STS_YunhornSTSEventP6_Process(void) { APP_LOG(TS_OFF, VLEVEL_H, "\r\n P6 Testing Process\r\n"); - STS_SENSOR_Power_ON(0); + PME_ON; HAL_Delay(50); #ifdef LED_ONBOARD LED_ON; @@ -381,7 +381,7 @@ void STS_YunhornSTSEventP6_Process(void) #endif /* 3. Sensor Power Off */ - STS_SENSOR_Power_OFF(0); + PME_OFF; } @@ -392,9 +392,9 @@ void STS_YunhornSTSEventP6_Process(void) void STS_YunhornSTSEventP7_Process(void) { APP_LOG(TS_OFF, VLEVEL_L, "\r\n P7 Testing Process\r\n"); - STS_SENSOR_Power_ON(0); + PME_ON; - STS_SENSOR_Power_OFF(0); + PME_OFF; } @@ -522,8 +522,8 @@ void STS_Combined_Status_Processing(void) break; case STS_PRESENCE_RISING: //NORMAL OCCUPANCY STATUS - // sts_lamp_bar_color = STS_RED; - // sts_status_color = STS_RED; + sts_lamp_bar_color = STS_RED; + sts_status_color = STS_RED; break; default: @@ -611,7 +611,6 @@ void STS_Combined_Status_Processing(void) } } - //STS_Lamp_Bar_Refresh(); if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag)) { @@ -742,7 +741,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso sensor_data->rss_presence_score = 0x0; } - // no_movement or unconcious duration + // no_movement or unconscious duration sensor_data->unconscious_state = ((sts_fall_rising_detected_result == STS_PRESENCE_UNCONSCIOUS) || (sts_fall_rising_detected_result==STS_PRESENCE_STAYSTILL) || (sts_fall_rising_detected_result==STS_PRESENCE_NO_MOVEMENT))? 1:0; @@ -788,6 +787,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso // For occupancy over time process //SysTime_t occupy_check_time = SysTimeGetMcuTime(); +#if 0 if ((sts_occupancy_overtime_threshold_in_10min != 0) && (event_start_time !=0)) { if (sts_occupancy_overtime_state == 1U) { @@ -796,7 +796,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso } //STS_Lamp_Bar_Refresh(); } - +#endif sensor_data_ready = 1; } @@ -850,7 +850,7 @@ void STS_PRESENCE_SENSOR_Init(void) sts_o7_sensorData.unconscious_state = 0; sts_o7_sensorData.unconscious_duration = 0; - STS_SENSOR_Power_ON(0); + PME_ON; STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init(); //STS_PRESENCE_SENSOR_TOF_Init(); //HAL_Delay(2000); @@ -874,7 +874,7 @@ void STS_PRESENCE_SENSOR_RSS_Init(void) { APP_LOG(TS_ON, VLEVEL_H, "##### YunHorn SmarToilets(r) MEMS RSS Initializing \r\n"); - STS_SENSOR_Power_ON(0); + PME_ON; if ((sts_distance_rss_distance==0)&&(sts_sensor_install_height==0)) { @@ -898,37 +898,6 @@ void STS_PRESENCE_SENSOR_RSS_Init(void) } - -#ifdef STS_M7 -void STS_PRESENCE_SENSOR_Get_Event_Status(STS_PRESENCE_SENSOR_Event_Status_t *Status) -{ - uint8_t int_source=0; - SysTime_t mems_event_time; - //int_source = ADXL345_GetRegisterValue(ADXL345_REG_INT_SOURCE); - - if (int_source & 0x10) { - mems_event_time = SysTimeGetMcuTime(); - Status->WakeUpStatus = 1U; - event_start_time = mems_event_time.Seconds; - } - else { - Status->WakeUpStatus =0U; - } - - if (int_source & 0x08) { - mems_event_time = SysTimeGetMcuTime(); - Status->SleepStatus = 1U; - event_stop_time = mems_event_time.Seconds; - } - else { - Status->SleepStatus = 0U; - - } - - -} -#endif - void STS_PRESENCE_SENSOR_Distance_Measure_Process(void) { uint8_t exit_status = EXIT_SUCCESS, i=0; @@ -950,7 +919,7 @@ void STS_PRESENCE_SENSOR_Distance_Measure_Process(void) void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_t count) { uint8_t bring_up_result[20]; - STS_SENSOR_Power_ON(0); + PME_ON; HAL_Init(); MX_GPIO_Init(); HAL_Delay(150); //wait for sensor ready diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 5c35752..ef668bd 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -2070,7 +2070,8 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) // TODO # of modules if (((uint8_t)(tlv_buf[CFG_CMD3]-0x30) >= 0) && ((uint8_t)tlv_buf[CFG_CMD3]-0x30) <=9) { - STS_SENSOR_Power_ON((uint8_t)(tlv_buf[CFG_CMD3]-0x30)); + //STS_SENSOR_Power_ON((uint8_t)(tlv_buf[CFG_CMD3]-0x30)); + PME_ON; i=0; outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD1]; outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD2]; @@ -2084,7 +2085,8 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) case 'F': // TODO # of modules if (((uint8_t)(tlv_buf[CFG_CMD3]-0x30) >= 0) && ((uint8_t)tlv_buf[CFG_CMD3]-0x30) <=9) { - STS_SENSOR_Power_OFF((tlv_buf[CFG_CMD3]-0x30)); + //STS_SENSOR_Power_OFF((tlv_buf[CFG_CMD3]-0x30)); + PME_OFF; i=0; outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD1]; outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD2];