diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 51b8517..6933937 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -83,7 +83,7 @@ enum RSS_CFG_order{ RSS_CFG_ITR_WEIGHT, // 13 RSS_CFG_OUTPUT_TIME, // 14 RSS_CFG_DOWNSAMPLING_FACTOR, // 15 - RSS_CFG_POWER_MODE, // 16 + RSS_CFG_TIME_C_THRESHOLD, // 16 RSS_CFG_UPDATE_FLAG, // 17 ADD AT 2025-04-11 RSS_CFG_BG_MOTION_NOISE, // 18 RSS_CFG_SLID_WIN, // 19 THRESHOLD AND WIN @@ -375,7 +375,7 @@ typedef struct STS_OO_RSS_SensorTuneDataTypeDef float default_receiver_gain; //[45](0.45f) //default 0.9 gain mdB [4] uint8_t default_config_update_flag; // 1,2,3,4,5 - + uint8_t default_time_c_threshold; // 4 ++ } STS_OO_RSS_SensorTuneDataTypeDef; diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 07a8744..1adad4b 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -154,7 +154,7 @@ extern uint8_t sts_lamp_bar_color; acc_detector_presence_handle_t rss_handle=NULL; acc_detector_presence_result_t rss_result; volatile float sts_rss_threshold=1.6f, sts_run_start, sts_run_length, sts_run_threshold, sts_run_gain, sts_run_profile, sts_run_f_inter_fast_cutoff,sts_run_f_inter_slow_cutoff; - +volatile uint8_t sts_time_c_threshold=20; /* USER CODE END Includes */ /* External variables ---------------------------------------------------------*/ @@ -575,7 +575,8 @@ static void print_current_configuration(acc_detector_presence_configuration_t pr static uint8_t yes_count=0; static uint8_t no_count=0; -#define TIME_C 4 +// #define TIME_C 4 +// replaced by sts_time_c_threshold static void sts_print_result(acc_detector_presence_result_t result) { @@ -595,7 +596,7 @@ static void sts_print_result(acc_detector_presence_result_t result) if(signal>(threshold+1000)) { LED1_ON; - if(yes_count(TIME_C-1)) + if(yes_count>(sts_time_c_threshold-1)) { //Out1_ON //Out2_OFF @@ -655,7 +656,7 @@ static void sts_print_result(acc_detector_presence_result_t result) APP_LOG(TS_OFF, VLEVEL_M,"Motion (%5d), Distance: %4dmm [start: %4d length: %4d gain: %3d Threshold:%6d Yes:%d No:%d \r\n", signal,dist,(int)(sts_run_start*1000.0f), (int)(sts_run_length*1000.0f), (int)(sts_run_gain*100.0f), (int)(sts_run_threshold*1000.0f), yes_count, no_count); } - else if(no_count>(TIME_C-1)) + else if(no_count>(sts_time_c_threshold-1)) { //Out1_OFF //Out2_ON @@ -836,109 +837,11 @@ int sts_presence_rss_detection_deinit(void) int sts_presence_rss_fall_rise_detection(void) { - const acc_hal_t *hal = acc_hal_integration_get_implementation(); - - if (!acc_rss_activate(hal)) - { - APP_LOG(TS_OFF, VLEVEL_H,"Failed to activate RSS\n"); - return EXIT_FAILURE; - } - - acc_rss_override_sensor_id_check_at_creation(true); - - acc_detector_presence_configuration_t presence_configuration = acc_detector_presence_configuration_create(); - if (presence_configuration == NULL) - { - APP_LOG(TS_OFF, VLEVEL_H,"Failed to create configuration\n"); - acc_rss_deactivate(); - return EXIT_FAILURE; - } - if ((sts_rss_config_updated_flag != STS_RSS_CONFIG_NON) || (sts_rss_init_ok != 1)) - { - APP_LOG(TS_OFF, VLEVEL_H, "\r\n ------ ---------- rss cfg update flag=%02x \r\n", sts_rss_config_updated_flag); - - - if (sts_rss_init_ok==0) - { - if (sts_work_mode ==STS_UNI_MODE) - { - sts_rss_config_updated_flag = STS_RSS_CONFIG_FALL_DETECTION; - } - else if ((sts_work_mode == STS_RSS_MODE) || (sts_work_mode == STS_DUAL_MODE)) - { - if (sts_rss_config_updated_flag == STS_RSS_CONFIG_NON) - sts_rss_config_updated_flag = STS_RSS_CONFIG_DEFAULT; - } - //set_default_configuration(presence_configuration); - //APP_LOG(TS_OFF, VLEVEL_M, "\r\n First Time RSS init, update flag=%02x\r\n", sts_rss_config_updated_flag); - //print_current_configuration(presence_configuration); - sts_rss_init_ok = 1; - } - - APP_LOG(TS_OFF, VLEVEL_H, "\r\n Update flag=%02x, workmode=%2d \r\n", sts_rss_config_updated_flag, sts_work_mode); - update_configuration_with_type(presence_configuration, sts_rss_config_updated_flag); -#if 0 - switch (sts_rss_config_updated_flag) - { - #if 0 - case STS_RSS_CONFIG_NON: - APP_LOG(TS_OFF, VLEVEL_H,"\r\n##### YUNHORN STS *** Non *** cfg \n"); - // return EXIT_SUCCESS; - break; - #endif - case STS_RSS_CONFIG_DEFAULT: - set_default_configuration(presence_configuration); - APP_LOG(TS_OFF, VLEVEL_H,"\r\n##### YUNHORN STS *** Default *** cfg applied\n"); - break; - case STS_RSS_CONFIG_SIMPLE: - sts_rss_set_current_configuration_simple(presence_configuration); - APP_LOG(TS_OFF, VLEVEL_H,"\r\n##### YUNHORN STS *** Simple *** cfg applied\n"); - break; - case STS_RSS_CONFIG_FULL: - sts_rss_set_current_configuration_full(presence_configuration); - APP_LOG(TS_OFF, VLEVEL_H,"\r\n######### YUNHORN STS *** FULL *** cfg applied\n"); - break; - case STS_RSS_CONFIG_FALL_DETECTION: - set_default_fall_rise_configuration(presence_configuration); - APP_LOG(TS_OFF, VLEVEL_H,"\r\n######### YUNHORN STS *** FALL DETECTION *** cfg applied\n"); - break; - default: - break; - } -#endif - // sts_rss_config_updated_flag = STS_RSS_CONFIG_NON; //update finished, set to 0 - } - - acc_detector_presence_handle_t handle = acc_detector_presence_create(presence_configuration); - if (handle == NULL) - { - APP_LOG(TS_OFF, VLEVEL_H,"Failed to create detector\n"); - acc_detector_presence_configuration_destroy(&presence_configuration); - acc_detector_presence_destroy(&handle); - acc_rss_deactivate(); - return EXIT_FAILURE; - } - - - APP_LOG(TS_OFF, VLEVEL_H,"\r\n============= Start Scan\n"); - - print_current_configuration(presence_configuration); - - acc_detector_presence_configuration_destroy(&presence_configuration); - -// BEFORE MERGE FIRST AND SECOND HALF FALL RISE DETECTION - - if (!acc_detector_presence_activate(handle)) - { - APP_LOG(TS_OFF, VLEVEL_H, "Failed to activate detector \n"); - return false; - } - bool deactivated = false; bool success = true; const int iterations = 1; //(DEFAULT_UPDATE_RATE_PRESENCE); - acc_detector_presence_result_t result; + uint8_t average_result = 0; float average_distance =0.0f; float average_score =0.0f; @@ -956,100 +859,13 @@ int sts_presence_rss_fall_rise_detection(void) //past 10 times of detection with 5 zones from ground to ceiling //for (k=0; k<5; k++) {motion_in_zone[k]=0;} - if ((sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_RSS_MODE)) + { - for (int i = 0; i < (iterations); i++) - { - success = acc_detector_presence_get_next(handle, &result); - success = acc_detector_presence_get_next(handle, &result); - if (!success) - { - APP_LOG(TS_OFF, VLEVEL_H,"acc_detector_presence_get_next() failed\n"); - break; - } - - //print_result(result); - sts_print_result(result); - if (!result.data_saturated) - { - //APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i); - //print_result(result); - 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); - //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); - //if (detected_hs_zone == 0) - //APP_LOG(TS_OFF, VLEVEL_L, "\r\nPresence_Distance=%u \r\n", (int)result.presence_distance*1000.0); - //APP_LOG(TS_OFF, VLEVEL_L, "\r\nHS_ZONE=%u", (int)detected_hs_zone); - //detected_hs_zone = 12 - detected_zone; - detected_hs_zone = (sts_sensor_install_height/1000)/(DEFAULT_ZONE_LENGTH) - detected_zone; - //motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++; - motion_in_hs_zone[detected_hs_zone][motion_detected_count]++; - - sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance; - sts_motion_dataset[motion_count].presence_score = 1000*result.presence_score; - - motion_count++; - - } - } - - //acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE); - //acc_integration_sleep_ms(10); // --- around 1500 ms in total - //acc_integration_sleep_ms(2); //--- around 1000ms in total - //acc_integration_sleep_ms(1000 / 20); - } - - deactivated = acc_detector_presence_deactivate(handle); - acc_detector_presence_destroy(&handle); - acc_rss_deactivate(); - - APP_LOG(TS_OFF, VLEVEL_H, "\r\n First Half --- Motion Count = %u \r\n", motion_count); - - //acc_detector_presence_deactivate(handle); - } - else if ((sts_work_mode == STS_UNI_MODE)) - { - - // ******** Second Half detection of fall down and rise up - //if (sts_presence_fall_detection == TRUE) - //{ - // the following has been updated, no need to re-cofig -#if 0 - set_default_fall_rise_configuration(presence_configuration); - - if (!acc_detector_presence_reconfigure(&handle, presence_configuration)) - { - APP_LOG(TS_OFF, VLEVEL_H,"Failed to reconfigure detector\n"); - acc_detector_presence_configuration_destroy(&presence_configuration); - acc_detector_presence_destroy(&handle); - acc_rss_deactivate(); - return EXIT_FAILURE; - } -#endif - // activated already -#if 0 - if (!acc_detector_presence_activate(handle)) - { - APP_LOG(TS_OFF, VLEVEL_H, "Failed to activate detector \n"); - return false; - } -#endif - - acc_detector_presence_configuration_destroy(&presence_configuration); // set to full length of iteration for (int i = 0; i < (iterations); i++) { - success = acc_detector_presence_get_next(handle, &result); + success = acc_detector_presence_get_next(rss_handle, &rss_result); if (!success) { APP_LOG(TS_OFF, VLEVEL_H,"acc_detector_presence_get_next() failed\n"); @@ -1057,19 +873,19 @@ int sts_presence_rss_fall_rise_detection(void) } - if (!result.data_saturated) + if (!rss_result.data_saturated) { //APP_LOG(TS_OFF, VLEVEL_L,"\n%u ", i); //print_result(result); - if ((result.presence_detected) && (result.presence_score > DEFAULT_THRESHOLD)) + if ((rss_result.presence_detected) && (rss_result.presence_score > DEFAULT_THRESHOLD)) { //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); + average_distance += rss_result.presence_distance; + average_score += rss_result.presence_score; + // 2024-08-05 - detected_zone = (uint16_t)((float)(result.presence_distance) / (float)DEFAULT_ZONE_LENGTH); + detected_zone = (uint16_t)((float)(rss_result.presence_distance) / (float)DEFAULT_ZONE_LENGTH); motion_in_zone[detected_zone]++; // new add 2024-06-18 @@ -1082,8 +898,8 @@ int sts_presence_rss_fall_rise_detection(void) //motion_in_hs_zone[detected_hs_zone][(motion_detected_count)]++; motion_in_hs_zone[detected_hs_zone][motion_detected_count]++; - sts_motion_dataset[motion_count].presence_distance = 1000*result.presence_distance; - sts_motion_dataset[motion_count].presence_score = 1000*result.presence_score; + sts_motion_dataset[motion_count].presence_distance = 1000*rss_result.presence_distance; + sts_motion_dataset[motion_count].presence_score = 1000*rss_result.presence_score; motion_count++; @@ -1095,9 +911,6 @@ int sts_presence_rss_fall_rise_detection(void) //acc_integration_sleep_ms(10); //--- around 1500 ms in total acc_integration_sleep_ms(2); //--- around 1000ms in total } - deactivated = acc_detector_presence_deactivate(handle); - acc_detector_presence_destroy(&handle); - acc_rss_deactivate(); APP_LOG(TS_OFF, VLEVEL_H, "\r\n Second Half --- Motion Count Sum to = %u \r\n", motion_count); @@ -1116,25 +929,6 @@ int sts_presence_rss_fall_rise_detection(void) } - average_distance = (float)(1000.0f*average_distance)/(float)average_result; // in meters - average_score = (float)(1000.0f*average_score)/(float)average_result; - - sts_presence_rss_distance = average_distance; - sts_presence_rss_score = average_score; - - //STS_Yunhorn_DistanceStandardDeviation(); - - // APP_LOG(TS_OFF, VLEVEL_H, "\r\nAverage Distance: %d (mm) Score: %d Singularity: %d \r\n",(int)average_distance, (int)average_score, sts_presence_singularity); - // uint8_t pre_sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0; - // sts_rss_result=STS_RSS_Filter(pre_sts_rss_result); - - - //APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Result=%d Distance=%d, Score=%d MotionCount=%d \r\n", -// (int)average_result, (int)average_distance, (int)average_score, (int)motion_count); - - // sts_rss_result = (average_result > (DEFAULT_UPDATE_RATE_PRESENCE/5))? 1: 0; - // sts_rss_result = (average_result > 0)? 1: 0; - uint8_t pre_sts_rss_result=0; if (sts_work_mode == STS_UNI_MODE) { @@ -1148,24 +942,8 @@ int sts_presence_rss_fall_rise_detection(void) //STS_RSS_Filter_ring(); STS_RSS_Filter(pre_sts_rss_result); - //else { -// sts_rss_result = 0; -// } - - // APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotionCount=%4d Overall Motion=%d \r\n", (int)motion_count, (int)sts_rss_result); - //APP_LOG(TS_OFF, VLEVEL_M, "\r\nAverage Result=%d Distance=%d, Score=%d MotionCount=%d ---Overall Result=%d \r\n", - // (int)average_result, (int)average_distance, (int)average_score, (int)motion_count, (int)sts_rss_result); APP_LOG(TS_OFF, VLEVEL_M, "\r\nMotion Status: %d %d (mm) %d singularity: %d Rated-> %d \r\n",(int)average_result, (int)average_distance, (int)average_score, (int)sts_presence_singularity, (int)sts_rss_result); -#if 0 - if (sts_rss_result) //if (average_score !=0) //if (sts_rss_result) - { - APP_LOG(TS_OFF, VLEVEL_L,"\r\n######## MotionLevel=%4u (level) Gain=%2u (%) Start=%4u (mm) Length=%4u (mm)\r\n", - (int)(1000.0f*sts_presence_rss_config.default_threshold),(int)(100.0f*sts_presence_rss_config.default_receiver_gain), - (int)(1000.0f*sts_presence_rss_config.default_start_m), (int)(1000.0f*sts_presence_rss_config.default_length_m)); - APP_LOG(TS_OFF, VLEVEL_M,"\r\n######## Motion: %u Distance=%u mm, Score=%u Average_result=%u out of %u \r\n", - (uint8_t)sts_rss_result,(int) sts_presence_rss_distance, (int)(sts_presence_rss_score), (int)average_result, (int)iterations); - } -#endif + // RSS feature 1: Motion, No-motion process @@ -1226,15 +1004,9 @@ int sts_presence_rss_fall_rise_detection(void) #endif - if (deactivated && success) - { - APP_LOG(TS_OFF, VLEVEL_H,"Application finished OK\n"); - return EXIT_SUCCESS; - } - - return EXIT_FAILURE; } + void STS_Yunhorn_DistanceStandardDeviation(void) { uint16_t i,j; diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 23a075c..94ad41c 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -79,7 +79,7 @@ extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_dep extern volatile uint8_t sts_fall_rising_detected_result, sts_fall_rising_detected_result_changed_flag; extern volatile uint8_t sts_presence_fall_detection; extern volatile uint8_t last_sts_fall_rising_detected_result; - +extern volatile uint8_t sts_time_c_threshold; extern volatile uint16_t sts_motionless_duration_threshold_in_min; extern volatile uint8_t sts_status_color, sts_lamp_bar_color;//puColor extern volatile uint8_t sts_cloud_netcolor; //netColor @@ -769,7 +769,7 @@ void STS_PRESENCE_SENSOR_NVM_CFG(void) //filter parameter sts_presence_rss_config.default_downsampling_factor = (float)(sts_cfg_nvm.p[RSS_CFG_DOWNSAMPLING_FACTOR]); - sts_presence_rss_config.default_power_save_mode = (float)(sts_cfg_nvm.p[RSS_CFG_POWER_MODE]); + sts_presence_rss_config.default_time_c_threshold = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_TIME_C_THRESHOLD]); // sts_rss_config_updated_flag = (sts_rss_config_updated_flag|STS_RSS_CONFIG_FULL); //set to 2 for FULL config effect in next detection //sts_rss_config_updated_flag = (STS_RSS_CONFIG_FULL); //set to 2 for FULL config effect in next detection @@ -777,7 +777,7 @@ void STS_PRESENCE_SENSOR_NVM_CFG(void) sts_rss_config_updated_flag = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_UPDATE_FLAG]); sts_rss_cfg_slid_win_threshold = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_SLID_WIN])>>4; sts_rss_cfg_slid_win_size = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_SLID_WIN])&0x0F; - + sts_time_c_threshold = (uint8_t)(sts_cfg_nvm.p[RSS_CFG_TIME_C_THRESHOLD]); APP_LOG(TS_ON, VLEVEL_H, "\r\n##### Reboot --- with NVM CFG'ED RSS flag =%02x \r\n", sts_rss_config_updated_flag); } diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 1a82771..8e10613 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -92,6 +92,7 @@ static void STS_Show_STS_CFG_NVM(uint8_t * store_value, uint16_t store_size); extern volatile uint8_t sts_rss_cfg_slid_win_threshold; extern volatile uint8_t sts_rss_cfg_slid_win_size; extern volatile uint8_t self_test_result[18]; +extern volatile uint8_t sts_time_c_threshold; volatile sts_cfg_nvm_t sts_cfg_nvm = { sts_mtmcode1, sts_mtmcode2, @@ -122,7 +123,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { 0x0A, //intra frame weight, 0x00=[0]*0.1=0.0F 0x0A=10, 10*0.1=1 FOR FAST MOVEMENT TRACKING FALL DETECTION 0x01, //output time const 0x05=[5]*0.1=0.5 0.5--> 0.9 2025-03-26 TODO XXXXXX 0x01, //downsampling factor [2]=2 - 0x03, //power saving mode ACTIVE [3] = 3U + 0x14, //default time_c threshold 4 0x02, //P[17] RSS CFG UPDATE FLAG 2025-04-14 0x6E, //P[18] RSS_CFG_BG_MOTION_NOISE 2025-04-14 0x8C, //P[19] RSS SLIDING WINDOW CFG: 0x08 AS threshold, 0x0C as window size @@ -2008,7 +2009,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) uint8_t i=0, mems_ver, invalid_flag=1; UTIL_MEM_set_8((void*)outbuf,0x0, sizeof(outbuf)); - if (((char)tlv_buf[CFG_CMD1] == 'Y') && (tlv_buf_size <=5)) // BEGIN OF *** BOARD LEVEL CONTROL OR REPORT + if (((char)tlv_buf[CFG_CMD1] == 'Y') && (tlv_buf_size <=7)) // BEGIN OF *** BOARD LEVEL CONTROL OR REPORT { switch ((char)tlv_buf[CFG_CMD2]) { @@ -2431,6 +2432,60 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) break; + case 'T': // YTCCC --- CHANGE RSS Internal yes no threshold + if ( ((char)tlv_buf[CFG_CMD3] >= '0') && ((char)tlv_buf[CFG_CMD3] <= '2') + && ((char)tlv_buf[CFG_CMD4] >= '0') && ((char)tlv_buf[CFG_CMD4] <= '9') + && ((char)tlv_buf[CFG_CMD5] >= '0') && ((char)tlv_buf[CFG_CMD5] <= '9')) + { + uint8_t time_c_threshold=0; + + time_c_threshold = ( (tlv_buf[CFG_CMD3]-0x30)*100 + (tlv_buf[CFG_CMD4] - 0x30)*10 + (tlv_buf[CFG_CMD5] - 0x30))&0xFF; + + sts_cfg_nvm.p[RSS_CFG_TIME_C_THRESHOLD] = (time_c_threshold)&0xff; + sts_time_c_threshold = time_c_threshold; + APP_LOG(TS_OFF, VLEVEL_M, "\r\nRSS interval yes no counting threshold: %d \r\n", time_c_threshold); + + OnStoreSTSCFGContextRequest(); + + } else { + APP_LOG(TS_OFF, VLEVEL_M, "\r\nCFG ERR, sliding win threshold/length incorrect"); + } + + UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf)); + UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf,tlv_buf_size); + i = tlv_buf_size; + STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf); + + break; + + case 'C': // YCXXYY --- CHANGE RSS FAST CUT OFF AND SLOW CUT OFF THRESHOLD + if ( ((char)tlv_buf[CFG_CMD3] >= '0') && ((char)tlv_buf[CFG_CMD3] <= '9') + && ((char)tlv_buf[CFG_CMD4] >= '0') && ((char)tlv_buf[CFG_CMD4] <= '9') + && ((char)tlv_buf[CFG_CMD5] >= '0') && ((char)tlv_buf[CFG_CMD5] <= '9') + && ((char)tlv_buf[CFG_CMD6] >= '0') && ((char)tlv_buf[CFG_CMD6] <= '9')) + { + uint8_t ite_fast_cut=0, ite_slow_cut=0; + ite_fast_cut = ((tlv_buf[CFG_CMD3] - 0x30)*10 + (tlv_buf[CFG_CMD4] - 0x30))&0xff; + ite_slow_cut = ((tlv_buf[CFG_CMD5] - 0x30)*10 + (tlv_buf[CFG_CMD6] - 0x30))&0xff; + + { + sts_cfg_nvm.p[RSS_CFG_ITE_FAST_CUTOFF] = ite_fast_cut; + sts_cfg_nvm.p[RSS_CFG_ITE_SLOW_CUTOFF] = ite_slow_cut; + + APP_LOG(TS_OFF, VLEVEL_M, "\r\nite_fast_cut threshold: %d ite_slow_cut:0.%2d \r\n", ite_fast_cut, ite_slow_cut); + + OnStoreSTSCFGContextRequest(); + + } + } + + UTIL_MEM_set_8((void*)outbuf, 0x0, sizeof(outbuf)); + UTIL_MEM_cpy_8((void*)outbuf,(void*)tlv_buf,tlv_buf_size); + i = tlv_buf_size; + STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf); + + + break; default: //STS_SENSOR_Upload_Config_Invalid_Message(); @@ -2690,7 +2745,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) sts_cfg_nvm.p[RSS_CFG_OUTPUT_TIME] = (uint8_t)((tlv_buf[CFG_CMD30]- 0x30)*10+(tlv_buf[CFG_CMD31]- 0x30)); sts_cfg_nvm.p[RSS_CFG_DOWNSAMPLING_FACTOR] = (uint8_t)((tlv_buf[CFG_CMD32]- 0x30)); - sts_cfg_nvm.p[RSS_CFG_POWER_MODE] = (uint8_t)((tlv_buf[CFG_CMD33]- 0x30)); + sts_cfg_nvm.p[RSS_CFG_TIME_C_THRESHOLD] = (uint8_t)((tlv_buf[CFG_CMD33]- 0x30)); diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index 233e3b6..3cb99a1 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ