diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index effadae..349f490 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -771,7 +771,7 @@ void STS_SENSOR_Distance_Test_Process(void); void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_t count); void STS_PRESENCE_SENSOR_Distance_Measure_Process(void); void STS_PRESENCE_SENSOR_Background_Measure_Process(uint16_t *bg_distance, uint16_t *bg_motion_noise); -void sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score); +int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score); void STS_Sensor_Init(void); void STS_Sensor_Prepare(void); diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index c8957d7..5299007 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -431,7 +431,7 @@ static void print_result(acc_detector_presence_result_t result) * sts_rss_result */ -void sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score) +int sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance, uint16_t *evaluated_score) { const acc_hal_t *hal = acc_hal_integration_get_implementation(); @@ -527,6 +527,8 @@ void sts_presence_rss_background_evaluation_process(uint16_t *evaluated_distance *evaluated_score = (uint16_t)average_score; LED1_ON; + + return EXIT_SUCCESS; } int sts_presence_rss_fall_rise_detection(void) @@ -832,7 +834,6 @@ int sts_presence_rss_fall_rise_detection(void) } else { pre_sts_rss_result = ((average_result > 0)&&(sts_presence_singularity ==0))? 1: 0; - } //Write_RingBuff(pre_sts_rss_result); @@ -866,7 +867,6 @@ int sts_presence_rss_fall_rise_detection(void) OnSensorRSS3AStateChanged(); } else { LED1_OFF; - } // RSS feature 2: Fall Detection process @@ -886,7 +886,7 @@ int sts_presence_rss_fall_rise_detection(void) // RSS feature 3: No motion, or stay still , or unconscious process // APP_LOG(TS_OFF, VLEVEL_M,"\r\n|Motion Detected Count =%u \r\n", motion_detected_count); - uint8_t thiscnt= motion_detected_count++; + //uint8_t thiscnt= motion_detected_count++; // APP_LOG(TS_OFF, VLEVEL_M,"\r\n|Motion Detected Count =%u and thiscnt=%u \r\n", motion_detected_count, thiscnt); if (motion_detected_count == 10) { //for (uint8_t j=0; j<12; j++) motion_in_hs_zone[j][thiscnt]=0; diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index c57cf3b..340830d 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -1551,12 +1551,12 @@ void Radar_Filtering_clutter(volatile uint8_t *color) // static uint8_t motion_read[FILTER_LEN]={0}; static uint8_t idx_filter=0; -static uint8_t sts_cnt_singularity=0; +//static uint8_t sts_cnt_singularity=0; void STS_RSS_Filter(uint8_t pre_sts_rss_result) { uint8_t j=0; - uint8_t sum_sliding_win=0; + //uint8_t sum_sliding_win = 0; motion_read[idx_filter] = pre_sts_rss_result; diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 92200ea..ed9e0c4 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -2886,48 +2886,8 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, uint8 void OnStoreSTSCFGContextRequest(void) { /* USER CODE BEGIN OnStoreContextRequest_1 */ - uint8_t i=0,j=0; -#if 0 -//#if (defined(STS_O7)||defined(STS_O5) || defined(STS_O6) || defined(STS_R0) || defined(STS_R5)|| defined(STS_R4)|| defined(STS_R1D)) - sts_cfg_nvm.length = STS_O7_NVM_CFG_SIZE; - nvm_store_value[i++] = sts_cfg_nvm.mtmcode1; - nvm_store_value[i++] = sts_cfg_nvm.mtmcode2; - nvm_store_value[i++] = sts_cfg_nvm.version; - nvm_store_value[i++] = sts_cfg_nvm.hardware_ver; - nvm_store_value[i++] = sts_cfg_nvm.periodicity; - nvm_store_value[i++] = sts_cfg_nvm.unit; - nvm_store_value[i++] = sts_cfg_nvm.sampling; - nvm_store_value[i++] = sts_cfg_nvm.s_unit; - 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++] = 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]); - } - nvm_store_value[i++] = sts_cfg_nvm.reserve02; - nvm_store_value[i++] = sts_cfg_nvm.reserve03; - nvm_store_value[i++] = sts_cfg_nvm.sensor_install_height_in_10cm; - nvm_store_value[i++] = sts_cfg_nvm.alarm_parameter05; - nvm_store_value[i++] = sts_cfg_nvm.alarm_mute_reset_timer_in_10sec; - nvm_store_value[i++] = sts_cfg_nvm.alarm_lamp_bar_flashing_color; - nvm_store_value[i++] = sts_cfg_nvm.occupancy_overtime_threshold_in_10min; - nvm_store_value[i++] = sts_cfg_nvm.motionless_duration_threshold_in_min; - nvm_store_value[i++] = sts_cfg_nvm.unconscious_or_motionless_level_threshold; - nvm_store_value[i++] = sts_cfg_nvm.fall_detection_acc_threshold; - nvm_store_value[i++] = sts_cfg_nvm.fall_detection_depth_threshold; - nvm_store_value[i++] = sts_cfg_nvm.fall_confirm_threshold_in_10sec; - - if ((sts_cfg_nvm.ac[0]!=0x0) && (sts_cfg_nvm.ac[19]!=0x0)) { - for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) { - nvm_store_value[i++] = (sts_cfg_nvm.ac[j]); - } - } -//#endif -#endif - - UTIL_MEM_cpy_8(nvm_stored_value, &sts_cfg_nvm, sizeof(sts_cfg_nvm)); + UTIL_MEM_cpy_8(nvm_stored_value,(void*)&sts_cfg_nvm, sizeof(sts_cfg_nvm)); UTIL_MEM_cpy_8(nvm_stored_value + YUNHORN_STS_MAX_NVM_CFG_SIZE, (const void*)sts_cfg_nvm_factory_default, sizeof(sts_cfg_nvm_factory_default)); /* USER CODE END OnStoreContextRequest_1 */ @@ -2935,59 +2895,6 @@ void OnStoreSTSCFGContextRequest(void) if (FLASH_IF_Erase(STS_CONFIG_NVM_BASE_ADDRESS, FLASH_PAGE_SIZE) == FLASH_IF_OK) { -#if 0 - APP_LOG(TS_OFF, VLEVEL_M, "\r\n %%%%% transfer CFG to normal NVM section \r\n"); - - // FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE); - // FLASH_IF_Write(FLASH_MFG_DEFAULT_START_ADDR, (const void *)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE); - - //uint8_t nvm_state=(uint8_t *)FLASH_MFG_DEFAULT_START_ADDR; - - switch (nvm_state) - { - case 0xF0: // Initial state - - break; - case 0xF2: - - break; - - case 0xF3: - - break; - default: - - break; - } - if (sts_cfg_nvm_factory_default[0] == 0xF0) - { - APP_LOG(TS_OFF, VLEVEL_M, "\r\n %%%%% write CFG to MFG DEFAULT SECTOR NVM \r\n"); - - UTIL_MEM_cpy_8((void*)sts_cfg_nvm_factory_default, (void*)nvm_store_value, YUNHORN_STS_MAX_NVM_CFG_SIZE); - - if ((sts_cfg_nvm.ac[0] != 0x0) && (sts_cfg_nvm.ac[19] != 0x0)) { - sts_cfg_nvm_factory_default[0] = 0xF3; // with good ac code already - } else { - sts_cfg_nvm_factory_default[0] = 0xF2; // no good ac code yet - } - // FLASH_IF_Write(FLASH_MFG_DEFAULT_START_ADDR, (const void *)sts_cfg_nvm_factory_default, YUNHORN_STS_MAX_NVM_CFG_SIZE); - - APP_LOG(TS_OFF, VLEVEL_M, "\r\n $$$$$$$$$ FINISHED write CFG to MFG DEFAULT SECTOR NVM \r\n"); - - } else if ((sts_cfg_nvm_factory_default[0] == 0xF2) && (hmac_result.ac_pass==1) ) //only store ac code at first time of ac_pass=1 - { - if ((sts_cfg_nvm.ac[0]!=0x0) && (sts_cfg_nvm.ac[19]!=0x0)) { - for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) { - sts_cfg_nvm_factory_default[YUNHORN_STS_MAX_NVM_CFG_SIZE-YUNHORN_STS_AC_CODE_SIZE+j] = (sts_cfg_nvm.ac[j]); - } - } - APP_LOG(TS_OFF, VLEVEL_M, "\r\n %%%%% write CFG to Factory Default NVM with good AC code\r\n"); - - sts_cfg_nvm_factory_default[0] = 0xF3; // with valid ac code - // FLASH_IF_Write(FLASH_MFG_DEFAULT_START_ADDR, (const void *)sts_cfg_nvm_factory_default, YUNHORN_STS_MAX_NVM_CFG_SIZE); - - } -#endif // final write once only FLASH_IF_Write(STS_CONFIG_NVM_BASE_ADDRESS, (const void *)nvm_stored_value, sizeof(sts_cfg_nvm)+sizeof(sts_cfg_nvm_factory_default)); @@ -3008,8 +2915,8 @@ void OnRestoreSTSCFG_FactoryDefault_ContextRequest(void) /* USER CODE END OnRestoreSTSCFGContextRequest_1 */ FLASH_IF_Read((void*)sts_cfg_nvm_factory_default, (void*)STS_CONFIG_NVM_BASE_ADDRESS+YUNHORN_STS_MAX_NVM_CFG_SIZE, YUNHORN_STS_MAX_NVM_CFG_SIZE); - UTIL_MEM_cpy_8(nvm_stored_value, sts_cfg_nvm_factory_default, YUNHORN_STS_MAX_NVM_CFG_SIZE); - UTIL_MEM_cpy_8(&nvm_stored_value+YUNHORN_STS_MAX_NVM_CFG_SIZE, sts_cfg_nvm_factory_default, YUNHORN_STS_MAX_NVM_CFG_SIZE); + UTIL_MEM_cpy_8((void*)nvm_stored_value, (void*)sts_cfg_nvm_factory_default, YUNHORN_STS_MAX_NVM_CFG_SIZE); + UTIL_MEM_cpy_8((void*)&nvm_stored_value+YUNHORN_STS_MAX_NVM_CFG_SIZE, (void*)sts_cfg_nvm_factory_default, YUNHORN_STS_MAX_NVM_CFG_SIZE); STS_Show_STS_CFG_NVM((uint8_t*)nvm_stored_value, sizeof(nvm_stored_value)); @@ -3053,18 +2960,7 @@ void STS_REBOOT_CONFIG_Init(void) /* USER CODE END OnRestoreContextRequest_1 */ //UTIL_MEM_cpy_8(nvm_stored_value, (void *)STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE); FLASH_IF_Read(nvm_stored_value, STS_CONFIG_NVM_BASE_ADDRESS, 2*YUNHORN_STS_MAX_NVM_CFG_SIZE); -#if 0 - if (sts_cfg_nvm_factory_default[0] != 0x46) // for normal boot process - { - FLASH_IF_Read(nvm_stored_value, STS_CONFIG_NVM_BASE_ADDRESS, YUNHORN_STS_MAX_NVM_CFG_SIZE); - APP_LOG(TS_OFF, VLEVEL_M, "\r\n %%%%% read config from normal nvm \r\n"); - } else if (sts_cfg_nvm_factory_default[0] == 0x46) - { // RESET TO FACTORY DEFAULT,CONFIG TO ORIGINAL SETTINGS, which 'F' flag set - FLASH_IF_Read(nvm_stored_value, FLASH_MFG_DEFAULT_START_ADDR, YUNHORN_STS_MAX_NVM_CFG_SIZE); - APP_LOG(TS_OFF, VLEVEL_M, "\r\n %%%%% read config from Factory Default nvm \r\n"); - } -#endif STS_Show_STS_CFG_NVM((uint8_t*)nvm_stored_value, sizeof(nvm_stored_value)); /* USER CODE BEGIN OnRestoreContextRequest_Last */ @@ -3073,7 +2969,7 @@ void STS_REBOOT_CONFIG_Init(void) if ((nvm_stored_value[NVM_MTM1] != sts_mtmcode1) || (nvm_stored_value[NVM_MTM2] != sts_mtmcode2) || (nvm_stored_value[NVM_VER] != sts_version)) { APP_LOG(TS_OFF, VLEVEL_M, "Initial Boot with Empty Config, Flash with default config....\r\n"); - UTIL_MEM_cpy_8(sts_cfg_nvm_factory_default, &sts_cfg_nvm, (sizeof(sts_cfg_nvm))); + UTIL_MEM_cpy_8(sts_cfg_nvm_factory_default, (void*)&sts_cfg_nvm, (sizeof(sts_cfg_nvm))); OnStoreSTSCFGContextRequest(); //UTIL_MEM_set_8((void *)sts_ac_code, 0x00, YUNHORN_STS_AC_CODE_SIZE); HAL_Delay(1000); @@ -3117,13 +3013,6 @@ void STS_REBOOT_CONFIG_Init(void) sts_cfg_nvm.ac[j] = (uint8_t)nvm_stored_value[NVM_AC_CODE_START +j]; } -#if 0 - if ((sts_cfg_nvm.ac[0] != 0x0) && (sts_cfg_nvm.ac[19] != 0x0)) { - sts_cfg_nvm_factory_default[0] = 0xF3; // with good ac code already - } else { - sts_cfg_nvm_factory_default[0] = 0xF2; // no good ac code yet - } -#endif } //#endif diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index b3c65db..912cda6 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ