diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index 871fadc..bcb45b4 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -47,7 +47,7 @@ extern "C" { /** * @brief Verbose level for all trace logs */ -#define VERBOSE_LEVEL VLEVEL_M +#define VERBOSE_LEVEL VLEVEL_L /** * @brief Enable trace logs diff --git a/Core/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index de4ea83..89ffce9 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -169,10 +169,14 @@ typedef struct STS_OO_SensorStatusDataTypeDef uint8_t state_sensor4_on_off; /* reserved_sensor_on_off sensor state */ uint16_t rss_presence_distance; // in mm uint16_t rss_presence_score; // in 1000*score + uint8_t unconcious_state; + uint16_t unconcious_threshold; + uint16_t unconcious_duration; uint8_t fall_state; // FALL DETECION NONE, FALL DOWN, RISE UP, LAYDOWN_STILL uint8_t fall_speed; // speed of fall down measure uint8_t fall_gravity; // gravity of fall down measure uint8_t overtime; // occupancy over time or not 0:1 + uint16_t over_stay_duration; // time lenght of overstay in seconds uint8_t battery_Pct; /* % of battery two digits, 88% (00-99)% */ uint8_t dutycycletimelevel; /* level=0,255 */ uint8_t sts_service_mask; /* sts service mask */ @@ -528,7 +532,7 @@ enum nvm_order { //39, P[27] NVM_FALL_DETECTION_ACC_THRESHOLD=40, //40 NVM_FALL_DETECTION_DEPTH_THRESHOLD, //41 - NVM_FALL_DETECTION_RESERVE, //42 + NVM_FALL_UNCONCIOUS_THRESHOLD, //42 NVM_OCCUPANCY_OVERTIME_THRESHOLD, //43 NVM_AC_CODE_START=44 //STORED, NO UPLOAD //63, 20 bytes for AC code @@ -550,7 +554,7 @@ typedef struct sts_cfg_nvm { uint8_t p[STS_O7_CFG_PCFG_SIZE]; uint8_t fall_detection_acc_threshold; // 0 - 9: 0:disable: 1-9 accelaration mg/s2 uint8_t fall_detection_depth_threshold; // 0 - 9: 0:disable: 1-9 fall down depth * 10 cm - uint8_t fall_detection_reserve; + uint8_t fall_unconcious_threshold; //motion level *10 uint8_t occupancy_overtime_threshold; // 0 - 9: 0:disable, 1-9 occupy over time threshold * 10 min uint8_t ac[YUNHORN_STS_AC_CODE_SIZE]; // authorization code, 20 bytes MCU UUID coded } sts_cfg_nvm_t; diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index efba2ce..38506a4 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -60,18 +60,18 @@ volatile uint8_t sts_status_color = STS_DARK; volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor volatile uint8_t sts_occupancy_status; -volatile uint8_t sts_reed_hall_changed_flag = 1; + volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close -volatile uint8_t sts_hall1_read=0,sts_hall2_read=0; +volatile uint8_t sts_hall1_read=0,sts_hall2_read=0; // Above hall1_read == reed_hall_result, hall2_read == emergency_button volatile uint8_t sts_tof_result_changed_flag = 0; volatile uint8_t sts_water_leakage_result=0; volatile uint8_t sts_water_leakage_changed_flag=0; -volatile uint8_t sts_rss_result_changed_flag = 0; +volatile uint8_t sts_rss_result_changed_flag = 0, sts_hall1_changed_flag=0, sts_hall2_changed_flag=0, sts_reed_hall_changed_flag = 0; volatile uint8_t sts_rss_result = STS_RESULT_NO_MOTION; volatile uint8_t sts_rss_2nd_result = STS_RESULT_NO_MOTION; //2nd RSS sensor status volatile uint8_t sts_tof_result = STS_RESULT_NO_MOTION; -volatile uint8_t last_sts_rss_result; +volatile uint8_t last_sts_rss_result, last_sts_hall1_result, last_sts_hall2_result; volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1 volatile uint8_t last_lamp_bar_color; extern volatile uint8_t sts_presence_fall_detection; @@ -107,14 +107,17 @@ void STS_YunhornSTSEventP2_Process(void) { STS_RSS_Smart_Presence_Detection(); STS_Reed_Hall_Presence_Detection(); - +#if 0 if (sts_rss_result == last_sts_rss_result) { sts_rss_result_changed_flag =0; } else { sts_rss_result_changed_flag =1; last_sts_rss_result = sts_rss_result; } - +#endif + sts_rss_result_changed_flag = (sts_rss_result == last_sts_rss_result)? 0:1; + last_sts_rss_result = sts_rss_result; +#if 0 if (sts_reed_hall_result == last_sts_reed_hall_result) { sts_reed_hall_changed_flag = 0; @@ -123,6 +126,15 @@ void STS_YunhornSTSEventP2_Process(void) { sts_reed_hall_changed_flag = 1; } +#endif + sts_hall1_changed_flag = (sts_hall1_read == last_sts_hall1_result)? 0:1; + last_sts_hall1_result = sts_hall1_read; + sts_hall2_changed_flag = (sts_hall2_read == last_sts_hall2_result)? 0:1; + last_sts_hall2_result = sts_hall2_read; + sts_reed_hall_changed_flag = sts_hall1_changed_flag|sts_hall2_changed_flag; + sts_reed_hall_result = last_sts_hall2_result|last_sts_hall1_result; + sts_reed_hall_changed_flag = (sts_reed_hall_result == last_sts_reed_hall_result)? 0:1; + if (sts_service_mask > 0 ) { sts_rss_result_changed_flag =0; sts_reed_hall_changed_flag = 0; @@ -403,7 +415,7 @@ void STS_Combined_Status_Processing(void) event_start_time = mems_event_time.Seconds; event_stop_time = 0; - APP_LOG(TS_OFF, VLEVEL_L, "\r\n Event Started at %6u Seconds \r\n", event_start_time); + APP_LOG(TS_OFF, VLEVEL_M, "\r\n Event Started at %6u Seconds \r\n", event_start_time); } @@ -415,7 +427,7 @@ void STS_Combined_Status_Processing(void) event_start_time = 0; - APP_LOG(TS_OFF, VLEVEL_L, "\r\n Event Stop at %6u Seconds \r\n", event_stop_time); + APP_LOG(TS_OFF, VLEVEL_M, "\r\n Event Stop at %6u Seconds \r\n", event_stop_time); } } @@ -447,9 +459,12 @@ void STS_Combined_Status_Processing(void) { sts_status_color = STS_GREEN; - } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_result == STS_Status_Door_Close )) + } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_result == STS_Status_Door_Close )||(sts_emergency_button_pushed ==STS_Status_Door_Close)) { sts_status_color = STS_RED; + if (sts_emergency_button_pushed) { + sts_status_color = STS_RED_BLUE; + } } break; case STS_REMOTE_REED_RSS_MODE: @@ -509,14 +524,17 @@ void STS_Combined_Status_Processing(void) break; } - +#if 0 if (sts_status_color == STS_RED_BLUE) { //STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); STS_Lamp_Bar_Set_STS_RGB_Color(STS_RED, luminance_level); HAL_Delay(100); STS_Lamp_Bar_Set_STS_RGB_Color(STS_BLUE, luminance_level); + HAL_Delay(100); + STS_Lamp_Bar_Set_STS_RGB_Color(STS_RED_BLUE, luminance_level); } +#endif if ((sts_work_mode == STS_WIRED_MODE) || (sts_service_mask > STS_SERVICE_MASK_L0)) { sts_status_color = STS_DARK; @@ -541,7 +559,7 @@ void STS_Combined_Status_Processing(void) last_lamp_bar_color = sts_lamp_bar_color; } } - +#if 1 if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag) || (sts_tof_result_changed_flag) || (sts_water_leakage_changed_flag)) { sensor_data_ready = 1; @@ -551,6 +569,7 @@ void STS_Combined_Status_Processing(void) sts_tof_result_changed_flag =0; sts_water_leakage_changed_flag=0; } +#endif } void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 0250d25..d0fe90f 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -82,6 +82,8 @@ extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold; +volatile uint8_t sts_unconcious_state=0; +volatile uint16_t sts_unconcious_threshold=1280, sts_unconcious_duration=0; extern volatile uint8_t sts_rss_result, sts_rss_config_updated_flag; extern volatile float sts_distance_rss_distance; volatile float sts_presence_rss_distance, sts_presence_rss_score; diff --git a/Core/Src/yunhorn_sts_presence_sensor.c b/Core/Src/yunhorn_sts_presence_sensor.c index 31ce6aa..27f1376 100644 --- a/Core/Src/yunhorn_sts_presence_sensor.c +++ b/Core/Src/yunhorn_sts_presence_sensor.c @@ -45,10 +45,13 @@ extern volatile float sts_presence_rss_distance, sts_presence_rss_score; extern volatile uint8_t sts_hall1_read,sts_hall2_read; volatile uint8_t sts_rss_config_updated_flag = 0; extern volatile uint8_t mems_int1_detected, link_wakeup, link_sleep; -volatile uint32_t event_start_time, event_stop_time, sensor_data_ready; +volatile uint32_t event_start_time=0, event_stop_time=0, sensor_data_ready; +extern volatile uint8_t sts_occupancy_overtime_state; extern volatile STS_OO_RSS_SensorTuneDataTypeDef sts_presence_rss_config; extern volatile sts_cfg_nvm_t sts_cfg_nvm; extern volatile uint8_t sts_fall_detection_acc_threshold, sts_fall_detection_depth_threshold, sts_occupancy_overtime_threshold; +extern volatile uint8_t sts_unconcious_state; +extern volatile uint16_t sts_unconcious_threshold, sts_unconcious_duration; extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_pushed, sts_rss_result, sts_rss_2nd_result,sts_tof_result, sts_status_color, sts_lamp_bar_color, sts_work_mode, sts_service_mask; extern volatile distance_measure_cfg_t distance_cfg; extern uint8_t sts_fall_rising_detected_result; @@ -262,6 +265,9 @@ void STS_PRESENCE_SENSOR_Init_Send_Data(void) sts_o7_sensorData.event_start_time = 0x0; sts_o7_sensorData.event_stop_time = 0x0; sts_o7_sensorData.overtime = 0x0; + sts_o7_sensorData.over_stay_duration = 0x0; + sts_o7_sensorData.unconcious_state = 0x0; + sts_o7_sensorData.unconcious_duration = 0x0; sts_o7_sensorData.battery_Pct = 99; // 99% as init value sts_o7_sensorData.dutycycletimelevel = 1; @@ -271,14 +277,23 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) { sts_o7_sensorData.lamp_bar_color = sts_lamp_bar_color; sts_o7_sensorData.workmode = sts_work_mode; - sts_o7_sensorData.state_sensor1_on_off = sts_reed_hall_result; + sts_o7_sensorData.state_sensor1_on_off = sts_reed_hall_result; // sts_hall1_read sts_o7_sensorData.state_sensor2_on_off = sts_rss_result; - sts_o7_sensorData.state_sensor3_on_off = sts_emergency_button_pushed; + sts_o7_sensorData.state_sensor3_on_off = sts_emergency_button_pushed; //sts_hall2_read sts_o7_sensorData.state_sensor4_on_off = sts_rss_2nd_result; if (sts_rss_result == STS_RESULT_MOTION) { sts_o7_sensorData.rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF; sts_o7_sensorData.rss_presence_score = (uint16_t)(sts_presence_rss_score)&0xFFFF; + // uint8_t sts_unconcious_state; + // uint16_t sts_unconcious_threshold, sts_unconcious_threshold_duration; + if (sts_presence_rss_score < sts_unconcious_threshold) + { + sts_o7_sensorData.unconcious_state = sts_presence_rss_score; + } else + { + sts_o7_sensorData.unconcious_state = 0; + } } else { sts_o7_sensorData.rss_presence_distance = 0x0; sts_o7_sensorData.rss_presence_score = 0x0; @@ -290,11 +305,32 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) sts_o7_sensorData.fall_gravity = (uint8_t)sts_roc_acc_standard_variance; } - sts_o7_sensorData.overtime = (event_stop_time - event_start_time)> (sts_occupancy_overtime_threshold*60)? 1:0; - sts_o7_sensorData.event_start_time = event_start_time; - sts_o7_sensorData.event_stop_time = event_stop_time; -} + // For occupancy over time process + SysTime_t occupy_check_time = SysTimeGetMcuTime(); + if ((sts_occupancy_overtime_threshold != 0) && (event_start_time !=0)) + { + uint32_t check_time_tmp = occupy_check_time.Seconds - event_start_time; + //APP_LOG(TS_OFF, VLEVEL_L, "\r\n Check time at %6u Seconds, time lag =%6u, Started at %6u \r\n", occupy_check_time.Seconds, check_time_tmp, event_start_time); + + if (check_time_tmp > sts_occupancy_overtime_threshold*60) + { + sts_occupancy_overtime_state = 1U; + sts_o7_sensorData.overtime = sts_occupancy_overtime_state; + sts_o7_sensorData.over_stay_duration = check_time_tmp; + + sts_status_color = STS_RED_BLUE; + sts_lamp_bar_color = STS_RED_BLUE; + + STS_Lamp_Bar_Refresh(); + } + } else + { + sts_occupancy_overtime_state = 0U; + } + +} +#if 0 void STS_PRESENCE_SENSOR_Read(STS_OO_SensorStatusDataTypeDef *oo_data) { oo_data->lamp_bar_color = (uint8_t)sts_o7_sensorData.lamp_bar_color; @@ -306,15 +342,17 @@ void STS_PRESENCE_SENSOR_Read(STS_OO_SensorStatusDataTypeDef *oo_data) oo_data->state_sensor4_on_off = (uint8_t)sts_o7_sensorData.state_sensor4_on_off; oo_data->rss_presence_distance = (uint16_t)sts_o7_sensorData.rss_presence_distance; oo_data->rss_presence_score = (uint16_t)sts_o7_sensorData.rss_presence_score; + oo_data->fall_state = (uint8_t)sts_o7_sensorData.fall_state; oo_data->event_start_time = (uint32_t)sts_o7_sensorData.event_start_time; oo_data->event_stop_time = (uint32_t)sts_o7_sensorData.event_stop_time; oo_data->overtime = (uint8_t)sts_o7_sensorData.overtime; + oo_data->over_stay_duration = (uint16_t)sts_o7_sensorData.over_stay_duration; oo_data->battery_Pct = (uint8_t)sts_o7_sensorData.battery_Pct; oo_data->dutycycletimelevel = (uint8_t)sts_o7_sensorData.dutycycletimelevel; } - +#endif void STS_PRESENCE_SENSOR_GetValue(void) { @@ -349,6 +387,8 @@ void STS_PRESENCE_SENSOR_Init(void) sts_o7_sensorData.dutycycletimelevel = 1; sts_o7_sensorData.event_start_time = 0; sts_o7_sensorData.event_stop_time = 0; + sts_o7_sensorData.overtime = 0; + sts_o7_sensorData.over_stay_duration = 0; STS_SENSOR_Power_ON(0); STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init(); diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 9c186d6..8143dcb 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -52,9 +52,9 @@ extern hmac_result_t hmac_result; extern volatile uint8_t sts_reed_hall_ext_int; extern volatile uint8_t sts_hall1_read, sts_hall2_read; extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color; - volatile uint8_t sts_fall_detection_acc_threshold = 10, sts_fall_detection_depth_threshold=30, sts_occupancy_overtime_threshold=20; extern volatile uint32_t event_start_time, event_stop_time; +extern volatile uint16_t sts_unconcious_threshold; volatile uint8_t sts_occupancy_overtime_state = 0; volatile uint8_t sts_presence_fall_detection=1; volatile uint32_t SamplingPeriodicity = 1000; //unit ms @@ -110,7 +110,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { // below 4 bytes 0x01, //fall_detection_acc_threshold = *10 acceleration measure 0x03, //fall detection_depth_threshold *10cm - 0x00, //reserve + 0x80, //fall unconcious threshold * 10, 1280 motion level 0x02, //occupancy over time threshold *10 minutes // below 20 bytes {0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0} @@ -632,7 +632,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) case HALL1_Pin: //sts_reed_hall_ext_int = 1; sts_hall1_read = HALL1_STATE; - UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); + //UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); /* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */ // if (EventType == TX_ON_EVENT) { @@ -642,7 +642,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) case HALL2_Pin: sts_hall2_read = HALL2_STATE; - UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); + // UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); break; @@ -780,33 +780,15 @@ static uint8_t PrepareSendTxData(void) uint8_t i = 0; uint8_t batteryLevel = GetBatteryLevel(); uint16_t batteryLevelmV = SYS_GetBatteryLevel(); - SysTime_t occupy_check_time = SysTimeGetMcuTime(); + //SysTime_t occupy_check_time = SysTimeGetMcuTime(); //sensor_t sensor_data; - //STS_OO_SensorStatusDataTypeDef o7_data; + STS_PRESENCE_SENSOR_Prepare_Send_Data(); - //STS_PRESENCE_SENSOR_Read(&o7_data); + sts_o7_sensorData.battery_Pct = (uint8_t)(99*batteryLevel/254); - // For occupancy over time process - if ((sts_occupancy_overtime_threshold != 0) && (event_start_time !=0)) - { - uint32_t check_time_tmp = occupy_check_time.Seconds - event_start_time; - - APP_LOG(TS_OFF, VLEVEL_L, "\r\n Check time at %6u Seconds, time lag =%6u, Started at %6u \r\n", occupy_check_time.Seconds, check_time_tmp, event_start_time); - - if (check_time_tmp > sts_occupancy_overtime_threshold*60) - { - sts_occupancy_overtime_state = 1U; - sts_status_color = STS_RED_BLUE; - sts_lamp_bar_color = STS_RED_BLUE; - STS_Lamp_Bar_Refresh(); - } - } else - { - sts_occupancy_overtime_state = 0U; - } // For occupancy over time process @@ -888,11 +870,19 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_score >>8); //09 MSB score AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_score); //10 LSB score } - AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //11 occupancy over time or not + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.unconcious_state); //11 unconcious state detected or not + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.fall_state); //12 fall detected or not + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.overtime); //13 occupancy over time or not + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.over_stay_duration>>8); //13 occupancy over time or not + AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.over_stay_duration); //13 occupancy over time or not APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color | Mode | S1-Open | S2-Motion | S3-Open | S4 |Distance(mm) | MotionScore|" - "\r\n######|%10s | %15s | %1d | %1d | %1d | %1d | %04d | %04d |\r\n", - (char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]],AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score); + "\r\n######| Color | Mode |\r\n######| %4s | %5s |\r\n",(char *)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[AppData.Buffer[1]]); + APP_LOG(TS_OFF, VLEVEL_L, + "\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay| Fall Detected|" + "\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n", + AppData.Buffer[2], AppData.Buffer[3],AppData.Buffer[4], AppData.Buffer[5], + (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score, + sts_o7_sensorData.unconcious_state, sts_o7_sensorData.unconcious_duration, sts_o7_sensorData.fall_state ); default: break; } @@ -1827,19 +1817,20 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD5]; STS_Combined_Status_Processing(); - } else if (tlv_buf_size == 7 && tlv_buf[CFG_CMD4]=='F') // Change fall detection, occupancy overtime threshold + } else if (tlv_buf_size == 8 && tlv_buf[CFG_CMD4]=='F') // Change fall detection, occupancy overtime threshold { - invalid_flag = 0; // P 1 1 F A B C + invalid_flag = 0; // P 1 1 F A B C D if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0')) - && ((tlv_buf[CFG_CMD7]<='9') && (tlv_buf[CFG_CMD7]>='0'))) + && ((tlv_buf[CFG_CMD7]<='9') && (tlv_buf[CFG_CMD7]>='0'))&& ((tlv_buf[CFG_CMD8]<='9') && (tlv_buf[CFG_CMD8]>='0'))) { sts_fall_detection_acc_threshold = (uint8_t)(tlv_buf[CFG_CMD5] - 0x30)*10; //acc *10 mg/s2 sts_fall_detection_depth_threshold = (uint8_t)(tlv_buf[CFG_CMD6] - 0x30)*10; //depth *10 in cm - sts_occupancy_overtime_threshold = (uint8_t)(tlv_buf[CFG_CMD7] - 0x30)*10; // overtime *10 min + sts_unconcious_threshold = (uint8_t)(tlv_buf[CFG_CMD7] - 0x30+10)*10; //motion level over 1000 , less than 1900 *10 in cm + sts_occupancy_overtime_threshold = (uint8_t)(tlv_buf[CFG_CMD8] - 0x30)*10; // overtime *10 min sts_cfg_nvm.fall_detection_acc_threshold = (uint8_t)(tlv_buf[CFG_CMD5] - 0x30); sts_cfg_nvm.fall_detection_depth_threshold = (uint8_t)(tlv_buf[CFG_CMD6] - 0x30); - sts_cfg_nvm.fall_detection_reserve = 0x0; - sts_cfg_nvm.occupancy_overtime_threshold = (uint8_t)(tlv_buf[CFG_CMD7] - 0x30); + sts_cfg_nvm.fall_unconcious_threshold = (uint8_t)(tlv_buf[CFG_CMD7] - 0x30+10); + sts_cfg_nvm.occupancy_overtime_threshold = (uint8_t)(tlv_buf[CFG_CMD8] - 0x30); if ((sts_fall_detection_acc_threshold ==0)&&(sts_fall_detection_depth_threshold==0)) { @@ -1856,7 +1847,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size) outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD5]; outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD6]; outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD7]; - + outbuf[i++] = (uint8_t) tlv_buf[CFG_CMD8]; STS_Combined_Status_Processing(); } @@ -2140,7 +2131,7 @@ void OnStoreSTSCFGContextRequest(void) 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_detection_reserve; + nvm_store_value[i++] = sts_cfg_nvm.fall_unconcious_threshold; nvm_store_value[i++] = sts_cfg_nvm.occupancy_overtime_threshold; for (j = 0; j < YUNHORN_STS_AC_CODE_SIZE; j++) { @@ -2218,7 +2209,7 @@ void STS_REBOOT_CONFIG_Init(void) sts_cfg_nvm.fall_detection_acc_threshold = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_ACC_THRESHOLD]; sts_cfg_nvm.fall_detection_depth_threshold = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_DEPTH_THRESHOLD]; - sts_cfg_nvm.fall_detection_reserve = (uint8_t)nvm_stored_value[NVM_FALL_DETECTION_RESERVE]; + sts_cfg_nvm.fall_unconcious_threshold = (uint8_t)nvm_stored_value[NVM_FALL_UNCONCIOUS_THRESHOLD]; sts_cfg_nvm.occupancy_overtime_threshold = (uint8_t)nvm_stored_value[NVM_OCCUPANCY_OVERTIME_THRESHOLD]; for (uint8_t j=0; j< YUNHORN_STS_AC_CODE_SIZE; j++) { diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index 8b4bee5..b70228a 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -43,7 +43,7 @@ diff --git a/STM32CubeIDE/Debug/makefile b/STM32CubeIDE/Debug/makefile index 508b8c7..6ab2205 100644 --- a/STM32CubeIDE/Debug/makefile +++ b/STM32CubeIDE/Debug/makefile @@ -68,7 +68,7 @@ main-build: STS_O7.elf secondary-outputs # Tool invocations STS_O7.elf STS_O7.map: $(OBJS) $(USER_OBJS) D:\ONEDRIVE\STM32WLV13\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\YUNHORN_STS_E5CC_AS923_POC\STM32CubeIDE\STM32WLE5CCUX_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS) - arm-none-eabi-gcc -o "STS_O7.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m4 -T"D:\ONEDRIVE\STM32WLV13\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\YUNHORN_STS_E5CC_AS923_POC\STM32CubeIDE\STM32WLE5CCUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="STS_O7.map" -Wl,--gc-sections -static -L"D:\ONEDRIVE\STM32WLV13\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\STS_O7\STM32CubeIDE\rss\lib" -Xlinker -no-enum-size-warning --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group + arm-none-eabi-gcc -o "STS_O7.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m4 -T"D:\ONEDRIVE\STM32WLV13\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\YUNHORN_STS_E5CC_AS923_POC\STM32CubeIDE\STM32WLE5CCUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="STS_O7.map" -Wl,--gc-sections -static -L"D:\ONEDRIVE\STM32WLV13\Projects\NUCLEO-WL55JC\Applications\LoRaWAN\STS_O7\STM32CubeIDE\rss\lib" -Xlinker -no-enum-size-warning -z noexecstack --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group @echo 'Finished building target: $@' @echo ' ' diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index cc4abc1..1cb6d31 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ