From f49d4afb244125018341fef76cd39589e3025a6e Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Mon, 5 Aug 2024 17:05:07 +0800 Subject: [PATCH] ---- revised for reboot issue..not yet --- Core/Inc/yunhorn_sts_prd_conf.h | 4 ++-- Core/Src/yunhorn_sts_presence_rss.c | 28 ++++++++++++++++++---------- Core/Src/yunhorn_sts_process.c | 4 +++- LoRaWAN/App/lora_app.c | 4 ++-- STM32CubeIDE/.cproject | 6 ++++-- STM32CubeIDE/Release/makefile | 22 +++------------------- 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/Core/Inc/yunhorn_sts_prd_conf.h b/Core/Inc/yunhorn_sts_prd_conf.h index 42f8fc2..6c0b0a3 100644 --- a/Core/Inc/yunhorn_sts_prd_conf.h +++ b/Core/Inc/yunhorn_sts_prd_conf.h @@ -265,8 +265,8 @@ #define sts_sendhtbtport (YUNHORN_STS_O6_LORA_APP_HTBT_PORT) #endif #ifdef STS_O7 -#define sts_senddataport (YUNHORN_STS_O6_LORA_APP_DATA_PORT) -#define sts_sendhtbtport (YUNHORN_STS_O6_LORA_APP_HTBT_PORT) +#define sts_senddataport (YUNHORN_STS_O7_LORA_APP_DATA_PORT) +#define sts_sendhtbtport (YUNHORN_STS_O7_LORA_APP_HTBT_PORT) #endif #if defined(STS_O6)||defined(STS_O7) #define sts_appctrlport (YUNHORN_STS_O7_USER_APP_CTRL_PORT) diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 36c1937..ce61366 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -319,7 +319,9 @@ static void print_result(acc_detector_presence_result_t result) { if (result.presence_detected) { - uint32_t detected_zone = (uint32_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH); + //uint32_t detected_zone = (uint32_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH); + // 2024-08-05 + uint32_t detected_zone = (uint32_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH); APP_LOG(TS_OFF, VLEVEL_H,"Motion in zone: %u, distance: %d, score: %d\n", (unsigned int)detected_zone, (int)(result.presence_distance * 1000.0f), (int)(result.presence_score * 1000.0f)); @@ -418,15 +420,18 @@ int sts_presence_rss_fall_rise_detection(void) break; } - print_result(result); + //print_result(result); if (!result.data_saturated) { if (result.presence_detected) { + print_result(result); average_result++; average_distance += result.presence_distance; average_score += result.presence_score; - detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH); + //detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH); + //2024-08-05 + detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH); motion_in_zone[detected_zone]++; // new add 2024-06-18 //detected_hs_zone = (uint16_t)((float)(sts_sensor_install_height/1000.0f - (result.presence_distance))/(float)DEFAULT_ZONE_LENGTH); @@ -489,15 +494,18 @@ int sts_presence_rss_fall_rise_detection(void) break; } - print_result(result); + //print_result(result); if (!result.data_saturated) { if (result.presence_detected) { + print_result(result); average_result++; average_distance += result.presence_distance; average_score += result.presence_score; - detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH); + //detected_zone = (uint16_t)((float)(result.presence_distance - DEFAULT_START_M) / (float)DEFAULT_ZONE_LENGTH); + // 2024-08-05 + detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH); motion_in_zone[detected_zone]++; // new add 2024-06-18 @@ -530,7 +538,7 @@ int sts_presence_rss_fall_rise_detection(void) } //APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count); - //uint8_t thiscnt= motion_detected_count; + uint8_t thiscnt= motion_detected_count; if (motion_detected_count++ == 10) { motion_detected_count=0; @@ -562,7 +570,7 @@ int sts_presence_rss_fall_rise_detection(void) -#ifdef LOG_RSS +//#ifdef LOG_RSS APP_LOG(TS_OFF, VLEVEL_L,"\r\nSensor at Ceiling Height: %4u mm\r\n",(int)sts_sensor_install_height); for (uint8_t k=0; k<12; k++) { @@ -575,7 +583,7 @@ int sts_presence_rss_fall_rise_detection(void) APP_LOG(TS_OFF, VLEVEL_L,"\r\nMotion Distance Zone: %2u %4s", k, " "); } } -#endif +//#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; @@ -701,10 +709,10 @@ void STS_YunhornCheckStandardDeviation(void) APP_LOG(TS_OFF, VLEVEL_L, "\r\n---Sensor Install Height=%6u-----Distance Average =%6u; Variance = %6u ; Standard =%6u \r\n", (int)sts_sensor_install_height, (int)(average_presence_distance*1000.0f), (int)(variance_presence_distance*1000.0f), (int)(standard_variance_presence_distance*1000.0f)); #endif -#ifdef LOG_RSS +//#ifdef LOG_RSS 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)); -#endif +//#endif #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 5ccf1ef..9191467 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -39,6 +39,8 @@ extern volatile sts_cfg_nvm_t sts_cfg_nvm; extern volatile uint8_t sts_ac_code[20]; +volatile uint8_t sts_work_mode = STS_UNI_MODE; +#if 0 #if defined(STS_O7) volatile uint8_t sts_work_mode = STS_UNI_MODE; #elif defined(STS_O6) @@ -46,7 +48,7 @@ volatile uint8_t sts_work_mode = STS_DUAL_MODE; #elif defined(STS_O2) volatile uint8_t sts_work_mode = STS_RSS_MODE; #endif - +#endif volatile uint8_t sts_service_mask=0; volatile uint32_t rfac_timer; volatile uint8_t sensor_data_ready=0; diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 333efe9..017846b 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -2376,7 +2376,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) STS_Combined_Status_Processing(); HAL_Delay(2000); - OnSystemReset(); + //OnSystemReset(); } else { invalid_flag = 1; @@ -2611,7 +2611,7 @@ void OnStoreSTSCFGContextRequest(void) nvm_store_value[i++] = sts_cfg_nvm.work_mode; nvm_store_value[i++] = sts_cfg_nvm.sts_service_mask; nvm_store_value[i++] = sts_cfg_nvm.sts_ioc_mask; - nvm_store_value[i++] = (uint8_t) STS_O7_NVM_CFG_SIZE; //sts_cfg_nvm.length; + nvm_store_value[i++] = sts_cfg_nvm.length; //(uint8_t) STS_O7_NVM_CFG_SIZE; //sts_cfg_nvm.length; for (j = 0; j < STS_O7_CFG_PCFG_SIZE; j++) { nvm_store_value[i++] = (sts_cfg_nvm.p[j]); diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index 24a19c7..cb5c54d 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -39,7 +39,7 @@