diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 5ef68ef..efba2ce 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -61,7 +61,7 @@ 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 =1, sts_emergency_button_pushed=1; // inital 1 = open +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_tof_result_changed_flag = 0; volatile uint8_t sts_water_leakage_result=0; @@ -150,8 +150,9 @@ void STS_Reed_Hall_Presence_Detection(void) } #endif - sts_reed_hall_result = (STS_Reed_Hall_State==STS_Status_Door_Open)? 1:0; - sts_emergency_button_pushed = (STS_Emergency_Button_State==STS_Status_Door_Open)? 1:0; + sts_reed_hall_result = (sts_hall1_read==0)?STS_Status_Door_Close:STS_Status_Door_Open; + + sts_emergency_button_pushed = (sts_hall2_read==0)?STS_Status_Door_Close:STS_Status_Door_Open; //(STS_Emergency_Button_State==STS_Status_Door_Open)? 0:1; //sts_reed_hall_result = ((STS_Reed_Hall_State)&STS_Status_Door_Open); diff --git a/Core/Src/yunhorn_sts_presence_sensor.c b/Core/Src/yunhorn_sts_presence_sensor.c index a2ed031..31ce6aa 100644 --- a/Core/Src/yunhorn_sts_presence_sensor.c +++ b/Core/Src/yunhorn_sts_presence_sensor.c @@ -49,7 +49,7 @@ volatile uint32_t event_start_time, event_stop_time, sensor_data_ready; 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_reed_hall_result, 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 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; extern volatile uint16_t sts_fall_rising_pattern_factor1; @@ -271,9 +271,9 @@ 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_hall1_read; + sts_o7_sensorData.state_sensor1_on_off = sts_reed_hall_result; sts_o7_sensorData.state_sensor2_on_off = sts_rss_result; - sts_o7_sensorData.state_sensor3_on_off = sts_hall2_read; + sts_o7_sensorData.state_sensor3_on_off = sts_emergency_button_pushed; sts_o7_sensorData.state_sensor4_on_off = sts_rss_2nd_result; if (sts_rss_result == STS_RESULT_MOTION) { diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 014162c..9c186d6 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -642,6 +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_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); break; @@ -781,7 +782,7 @@ static uint8_t PrepareSendTxData(void) uint16_t batteryLevelmV = SYS_GetBatteryLevel(); SysTime_t occupy_check_time = SysTimeGetMcuTime(); //sensor_t sensor_data; - STS_OO_SensorStatusDataTypeDef o7_data; + //STS_OO_SensorStatusDataTypeDef o7_data; STS_PRESENCE_SENSOR_Prepare_Send_Data(); //STS_PRESENCE_SENSOR_Read(&o7_data); @@ -819,7 +820,7 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.battery_Pct); //02 Battery Level % AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB - APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1 BAT % BAT mV |" + APP_LOG(TS_OFF, VLEVEL_L,"\r\n######| Mode S1-Open BAT % BAT mV |" "\r\n######| %1d | %1d | %2d% | %4d mV|\r\n", (char*)sts_work_mode_code[(uint8_t)sts_work_mode], AppData.Buffer[2], AppData.Buffer[3], batteryLevelmV); @@ -834,7 +835,7 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor3_on_off); //05 Sensor head #3 status AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.state_sensor4_on_off); //06 Sensor head #4 status APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color | Mode | S1 | S2 | S3 | S4 |" + "\r\n######| Color | Mode | S1-Open | S2-Motion | S3-Open | S4 |" "\r\n######|%10s | %15s | %1d | %1d | %1d | %1d |\r\n", (char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2],AppData.Buffer[3], AppData.Buffer[4],AppData.Buffer[5]); break; @@ -848,8 +849,8 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV >>8); //03 Battery mV MSB AppData.Buffer[i++] = (uint8_t)(0xFF & batteryLevelmV ); //04 Battery mV LSB APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color | Mode | S1 | VBAT in mV|" - "\r\n######|%10s | %15s | %1d | %2d% | %4d mV|\r\n", + "\r\n######| Color | Mode | S1-Open | VBAT in mV|" + "\r\n######|%10s | %15s | %1d | %2d% | %4d mV|\r\n", (char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2],AppData.Buffer[3], batteryLevelmV); break; @@ -866,8 +867,8 @@ static uint8_t PrepareSendTxData(void) AppData.Buffer[i++] = (uint8_t)(0xFF & sts_o7_sensorData.rss_presence_score); //07 LSB score AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //08 occupancy over time or not APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color | Mode | S2 | |Distance(mm) | MotionScore|" - "\r\n######|%10s | %15s | %1d | %04d | %04d |\r\n", + "\r\n######| Color | Mode | S2-Motion | |Distance(mm) | MotionScore|" + "\r\n######|%10s | %15s | %1d | %04d | %04d |\r\n", (char*)sts_lamp_color_code[(uint8_t)(AppData.Buffer[0])], (char*)sts_work_mode_code[(uint8_t)AppData.Buffer[1]], AppData.Buffer[2], (uint16_t)sts_o7_sensorData.rss_presence_distance,(uint16_t)sts_o7_sensorData.rss_presence_score); @@ -889,8 +890,8 @@ static uint8_t PrepareSendTxData(void) } AppData.Buffer[i++] = (uint8_t)(0xFF & sts_occupancy_overtime_state); //11 occupancy over time or not APP_LOG(TS_OFF, VLEVEL_L, - "\r\n######| Color | Mode | S1 | S2 | S3 | S4 |Distance(mm) | MotionScore|" - "\r\n######|%10s | %15s | %1d | %1d | %1d | %1d | %04d | %04d |\r\n", + "\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); default: break; diff --git a/STM32CubeIDE/Release/STS_O7.bin b/STM32CubeIDE/Release/STS_O7.bin index ba411ab..cc4abc1 100644 Binary files a/STM32CubeIDE/Release/STS_O7.bin and b/STM32CubeIDE/Release/STS_O7.bin differ