diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index 2661f50..6059cf0 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_M /** * @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/Inc/yunhorn_sts_sensors.h b/Core/Inc/yunhorn_sts_sensors.h index 91a26f2..e4645cd 100644 --- a/Core/Inc/yunhorn_sts_sensors.h +++ b/Core/Inc/yunhorn_sts_sensors.h @@ -314,6 +314,11 @@ typedef struct #define DEFAULT_NBR_REMOVED_PC_2 (0) #define DEFAULT_ZONE_LENGTH (0.4f) //default 0.4 unit(meter) +#define STS_COLOR_DEFAULT_VACANT (sts_color_occupy_vacant&0x0f) +#define STS_COLOR_DEFAULT_OCCUPY ((sts_color_occupy_vacant>>4)&0x0f) +#define STS_COLOR_SEVERITY_L2 ((sts_color_severify_l2_l3>>4&0x0f)) +#define STS_COLOR_SEVERITY_L3 ((sts_color_severify_l2_l3&0x0f)) + /* #define DEFAULT_PROFILE ACC_SERVICE_PROFILE_4 #define DEFAULT_UPDATE_RATE (10) @@ -653,7 +658,7 @@ typedef struct sts_cfg_nvm { uint8_t p[STS_O7_CFG_PCFG_SIZE]; uint8_t color_occupy_vacant; // occupy color and vacant color define, C_OCCUPY<<4|C_VACANT - uint8_t reserve03; + uint8_t color_severity_l2_l3; // 2025 06 30, for emergency l2 l3 such as yellow, blue config uint8_t sensor_install_height_in_10cm; uint8_t alarm_parameter05; uint8_t alarm_mute_reset_timer_in_10sec; //60(0x3C) sec alarm_mute_or_reset_expire_timer_in_sec diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 0d321ab..0da9c61 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -58,8 +58,10 @@ volatile uint8_t sts_reed_hall_ext_int = 0; volatile uint8_t sts_status_color = STS_GREEN; #ifdef ATAL volatile uint8_t sts_color_occupy_vacant = (STS_RED<<4)|(STS_DARK&0x0f); +volatile uint8_t sts_color_severity_l2_l3 = ((STS_YELLOW<<4)|(STS_RED&0x0F)); #else volatile uint8_t sts_color_occupy_vacant = (STS_RED<<4)|(STS_GREEN&0x0f); +volatile uint8_t sts_color_severity_l2_l3 = ((STS_YELLOW<<4)|(STS_RED&0x0F)); #endif volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor diff --git a/Core/Src/yunhorn_sts_presence_rss.c b/Core/Src/yunhorn_sts_presence_rss.c index 1adad4b..43652ae 100644 --- a/Core/Src/yunhorn_sts_presence_rss.c +++ b/Core/Src/yunhorn_sts_presence_rss.c @@ -653,7 +653,7 @@ static void sts_print_result(acc_detector_presence_result_t result) //Out1_ON //Out2_OFF sts_rss_result=1; - APP_LOG(TS_OFF, VLEVEL_M,"Motion (%5d), Distance: %4dmm [start: %4d length: %4d gain: %3d Threshold:%6d Yes:%d No:%d \r\n", + APP_LOG(TS_OFF, VLEVEL_H,"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>(sts_time_c_threshold-1)) @@ -661,7 +661,7 @@ static void sts_print_result(acc_detector_presence_result_t result) //Out1_OFF //Out2_ON sts_rss_result=0; - APP_LOG(TS_OFF, VLEVEL_M,"No Motion(%5d), Distance: %4dmm [start: %4d length: %4d gain: %3d Threshold:%6d Yes:%d No:%d \r\n", + APP_LOG(TS_OFF, VLEVEL_H,"No 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); } diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 23761f8..20c8b90 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -137,8 +137,8 @@ char sts_presence_fall_detection_message[10][20]={ #endif -#define STS_COLOR_DEFAULT_VACANT (sts_color_occupy_vacant&0x0f) -#define STS_COLOR_DEFAULT_OCCUPY ((sts_color_occupy_vacant>>4)&0x0f) +//#define STS_COLOR_DEFAULT_VACANT (sts_color_occupy_vacant&0x0f) +//#define STS_COLOR_DEFAULT_OCCUPY ((sts_color_occupy_vacant>>4)&0x0f) /* @@ -587,20 +587,20 @@ void STS_Combined_Status_Processing(void) break; case STS_RSS_MODE: if (sts_rss_result == STS_RESULT_NO_MOTION){ - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_rss_result == STS_RESULT_MOTION)) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; case STS_DUAL_MODE: // FOR STS_O6 if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release )) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown )) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) { @@ -613,12 +613,12 @@ void STS_Combined_Status_Processing(void) if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_SOS_Release ) && (sts_reed_hall_3_result == STS_Status_Alarm_Mute_Release )&& (sts_reed_hall_4_result == STS_Status_Alarm_Reset_Release )) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) || (sts_reed_hall_3_result == STS_Status_Alarm_Mute_Pushdown )|| (sts_reed_hall_4_result == STS_Status_Alarm_Reset_Pushdown )) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown ) { @@ -643,8 +643,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_COLOR_DEFAULT_OCCUPY; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; break; default: @@ -658,53 +658,53 @@ void STS_Combined_Status_Processing(void) case STS_REMOTE_REED_RSS_MODE: if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_result == STS_Status_Door_Open )) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_result == STS_Status_Door_Close )) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; case STS_DUAL_RSS_MODE: if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_rss_2nd_result == STS_RESULT_NO_MOTION)) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_rss_2nd_result == STS_RESULT_MOTION)) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; case STS_TOF_RSS_MODE: if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_tof_result == STS_RESULT_NO_PRESENCE)){ - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_tof_result == STS_RESULT_PRESENCE)) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; // TO-DO LIST *********************************************************** case STS_TOF_DISTANCE_MODE: if ((sts_tof_result == STS_RESULT_NO_PRESENCE)) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_tof_result == STS_RESULT_PRESENCE)) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; case STS_TOF_PRESENCE_MODE: if ((sts_tof_result == STS_RESULT_NO_PRESENCE)) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_tof_result == STS_RESULT_PRESENCE)) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; case STS_TOF_IN_OUT_MODE: if ((sts_tof_result == STS_RESULT_NO_PRESENCE)) { - sts_status_color = STS_GREEN; + sts_status_color = STS_COLOR_DEFAULT_VACANT; } else if ((sts_tof_result == STS_RESULT_PRESENCE)) { - sts_status_color = STS_RED; + sts_status_color = STS_COLOR_DEFAULT_OCCUPY; } break; // TO-DO LIST *********************************************************** diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index aedb5cb..0f754c3 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -57,9 +57,10 @@ extern volatile uint8_t sts_hall1_read, sts_hall2_read, sts_hall3_read, sts_hall volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=STS_Status_SOS_Release, last_sts_hall3_read=STS_Status_Door_Open, last_sts_hall4_read=STS_Status_Door_Open ; volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close -extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, sts_color_occupy_vacant; +extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, sts_color_occupy_vacant, sts_color_severity_l2_l3; extern volatile uint8_t sts_lamp_bar_flashing_color; volatile uint8_t last_sts_lamp_bar_color=STS_DARK; +extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor extern volatile uint8_t sts_rss_result; extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag; volatile uint8_t sts_fall_detection_acc_threshold = 30, //0.3g @@ -133,7 +134,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = { #else 0x21, // color occupy (red:2) | color vacant (green:1) or other 0x20 occupy(red:2) | color vacant (dark:0) for ATAL-HK 20241230 #endif - 0x00, //reserve3 + 0x43, // color severity l2 l3, yellow blue 0x20, //sensor install height in 10 cm, default 32*10=320cm, 3.2meter 0x00, //reserve5 alarm_parameter05 @@ -1119,7 +1120,7 @@ static void SendTxData(void) } uint8_t ich= (sts_lamp_bar_color>>4 & 0x0f); - //uint8_t icl= (sts_lamp_bar_color & 0x0f); + uint8_t icl= (sts_lamp_bar_color & 0x0f); char colorshow[30]=""; strcpy(colorshow, (ich==0)?"":sts_lamp_color_code[ich]); @@ -2579,7 +2580,8 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) } else if (tlv_buf_size == 6 && tlv_buf[CFG_CMD4]=='L') //switch LAMP BAR OCCUPY VACANT COLOR { invalid_flag = 0; // P 1 1 L O V - if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0'))) + //if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='9')) && ((tlv_buf[CFG_CMD6]<='9') && (tlv_buf[CFG_CMD6]>='0'))) + if (((tlv_buf[CFG_CMD5] >='0') && (tlv_buf[CFG_CMD5]<='7')) && ((tlv_buf[CFG_CMD6]<='7') && (tlv_buf[CFG_CMD6]>='0'))) { sts_cfg_nvm.color_occupy_vacant = ((uint8_t)(tlv_buf[CFG_CMD5]-0x30)<<4)|((uint8_t)(tlv_buf[CFG_CMD6]-0x30)); sts_color_occupy_vacant = sts_cfg_nvm.color_occupy_vacant; @@ -2587,6 +2589,8 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, uint8_t tlv_buf_size) OnStoreSTSCFGContextRequest(); + } else { + invalid_flag = 1; } i=0; // Step 1: Prepare status update message @@ -3097,7 +3101,7 @@ void STS_REBOOT_CONFIG_Init(void) sts_cfg_nvm.p[j] = (uint8_t)nvm_stored_value[NVM_CFG_START+j]; } sts_cfg_nvm.color_occupy_vacant =(uint8_t)nvm_stored_value[NVM_RESERVE02]; - sts_cfg_nvm.reserve03 =(uint8_t)nvm_stored_value[NVM_RESERVE03]; + sts_cfg_nvm.color_severity_l2_l3 =(uint8_t)nvm_stored_value[NVM_RESERVE03]; sts_cfg_nvm.sensor_install_height_in_10cm =(uint8_t)nvm_stored_value[NVM_SENSOR_INSTALL_HEIGHT]; sts_cfg_nvm.alarm_parameter05 =(uint8_t)nvm_stored_value[NVM_ALARM_PARAMETER05]; sts_cfg_nvm.alarm_mute_reset_timer_in_10sec = (uint8_t)nvm_stored_value[NVM_ALARM_MUTE_RESET_TIMER]; @@ -3186,6 +3190,7 @@ void OnRestoreSTSCFGContextProcess(void) sts_service_mask = sts_cfg_nvm.sts_service_mask; sts_lamp_bar_flashing_color = sts_cfg_nvm.alarm_lamp_bar_flashing_color; sts_color_occupy_vacant = sts_cfg_nvm.color_occupy_vacant; + sts_color_severity_l2_l3 = sts_cfg_nvm.color_severity_l2_l3; if (sts_work_mode == STS_UNI_MODE){ sts_presence_fall_detection =TRUE; } else { diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index 141c70e..8803edb 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ