RM2_1 #2

Merged
sundp merged 208 commits from RM2_1 into master 2024-09-13 09:16:14 +08:00
5 changed files with 35 additions and 27 deletions
Showing only changes of commit 3cc1000622 - Show all commits

View File

@ -32,6 +32,8 @@ extern "C" {
#define STS_Status_Door_Close (0) //Normal Close NC:Open #define STS_Status_Door_Close (0) //Normal Close NC:Open
#define STS_Status_Door_Open (1) //Normal Close NC:Close #define STS_Status_Door_Open (1) //Normal Close NC:Close
#define STS_Status_SOS_Pushdown (0) //Normal Open NO:Open
#define STS_Status_SOS_Release (1) //Normal Open NO:Close
enum sts_lamp_color { enum sts_lamp_color {
STS_DARK = 0, //灭0 STS_DARK = 0, //灭0

View File

@ -56,13 +56,13 @@ uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
extern volatile uint8_t sts_service_mask; extern volatile uint8_t sts_service_mask;
extern volatile uint8_t sts_work_mode; extern volatile uint8_t sts_work_mode;
volatile uint8_t sts_reed_hall_ext_int = 0; volatile uint8_t sts_reed_hall_ext_int = 0;
volatile uint8_t sts_status_color = STS_DARK; volatile uint8_t sts_status_color = STS_GREEN;
volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor
volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor
extern volatile uint8_t sts_occupancy_status; extern volatile uint8_t sts_occupancy_status;
extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_pushed; // inital 0 = close extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_pushed; // inital 0 = close
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_hall1_read=STS_Status_Door_Open,sts_hall2_read=STS_Status_SOS_Release; // Above hall1_read == reed_hall_result, hall2_read == emergency_button
extern volatile uint8_t sts_reed_hall_1_result, sts_reed_hall_2_result; extern volatile uint8_t sts_reed_hall_1_result, sts_reed_hall_2_result;
extern volatile uint8_t sts_tof_result_changed_flag; extern volatile uint8_t sts_tof_result_changed_flag;
@ -74,7 +74,7 @@ extern volatile uint8_t sts_rss_2nd_result; //2nd RSS sensor status
extern volatile uint8_t sts_tof_result; extern volatile uint8_t sts_tof_result;
//extern volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1 //extern volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1
volatile uint8_t last_lamp_bar_color; volatile uint8_t last_lamp_bar_color=STS_GREEN;
extern volatile uint8_t sts_presence_fall_detection; extern volatile uint8_t sts_presence_fall_detection;
extern volatile uint8_t sts_fall_rising_detected_result; extern volatile uint8_t sts_fall_rising_detected_result;
extern volatile float sts_presence_rss_distance; extern volatile float sts_presence_rss_distance;
@ -231,7 +231,7 @@ void STS_Combined_Status_Processing(void)
{ {
mems_event_time = SysTimeGetMcuTime(); mems_event_time = SysTimeGetMcuTime();
if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close)|| (sts_reed_hall_2_result == STS_Status_Door_Close) || (sts_tof_result == STS_RESULT_PRESENCE)) 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_tof_result == STS_RESULT_PRESENCE))
{ {
if (event_start_time == 0) { if (event_start_time == 0) {
@ -243,7 +243,7 @@ void STS_Combined_Status_Processing(void)
} }
} else if ((sts_rss_result != STS_RESULT_MOTION) || (sts_reed_hall_1_result != STS_Status_Door_Close)|| (sts_reed_hall_2_result != STS_Status_Door_Close) || (sts_tof_result != STS_RESULT_PRESENCE)) } 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_tof_result != STS_RESULT_PRESENCE))
{ {
if (event_stop_time ==0) if (event_stop_time ==0)
{ {
@ -281,11 +281,11 @@ void STS_Combined_Status_Processing(void)
} }
break; break;
case STS_DUAL_MODE: case STS_DUAL_MODE:
if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_1_result == STS_Status_Door_Open )&& (sts_reed_hall_2_result == STS_Status_Door_Open )) 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_GREEN;
} else if ((sts_rss_result == STS_RESULT_MOTION) || (sts_reed_hall_1_result == STS_Status_Door_Close )||(sts_reed_hall_2_result == STS_Status_Door_Close )) } 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_RED;
if (sts_fall_rising_detected_result == STS_PRESENCE_LAYDOWN) { if (sts_fall_rising_detected_result == STS_PRESENCE_LAYDOWN) {
@ -298,7 +298,8 @@ void STS_Combined_Status_Processing(void)
sts_lamp_bar_color = STS_RED; sts_lamp_bar_color = STS_RED;
sts_status_color = STS_RED; sts_status_color = STS_RED;
} }
if (sts_reed_hall_2_result == STS_Status_Door_Close ) { if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown )
{
sts_status_color = STS_RED_BLUE; sts_status_color = STS_RED_BLUE;
} }
} }

View File

@ -471,10 +471,10 @@ int sts_presence_rss_fall_rise_detection(void)
} }
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count); //APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
APP_LOG(TS_OFF, VLEVEL_L,"Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count); APP_LOG(TS_OFF, VLEVEL_H,"Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
sts_rss_result = (average_result > 3)? 1: 0; sts_rss_result = (average_result > 3)? 1: 0;
APP_LOG(TS_OFF, VLEVEL_L,"Average Motion Result = %u OUTPUT RSS RESULT=%u \r\n", (int)average_result, sts_rss_result); APP_LOG(TS_OFF, VLEVEL_H,"Average Motion Result = %u OUTPUT RSS RESULT=%u \r\n", (int)average_result, sts_rss_result);
for (k=0; k<10; k++) { for (k=0; k<10; k++) {
if (motion_in_zone[k]>0) if (motion_in_zone[k]>0)
APP_LOG(TS_OFF, VLEVEL_L,"\nMotion in Zone %u, Count=%u \r\n", k, motion_in_zone[k]); APP_LOG(TS_OFF, VLEVEL_L,"\nMotion in Zone %u, Count=%u \r\n", k, motion_in_zone[k]);

View File

@ -51,7 +51,7 @@ volatile STS_PRESENCE_SENSOR_Event_Status_t sts_o7_event_status;
volatile float sts_distance_rss_distance; volatile float sts_distance_rss_distance;
extern volatile float sts_presence_rss_distance, sts_presence_rss_score; extern volatile float sts_presence_rss_distance, sts_presence_rss_score;
extern volatile uint8_t sts_hall1_read,sts_hall2_read; extern volatile uint8_t sts_hall1_read,sts_hall2_read;
volatile uint8_t sts_reed_hall_1_result=0,sts_reed_hall_2_result=0, last_sts_reed_hall_1_result=0, last_sts_reed_hall_2_result=0; volatile uint8_t sts_reed_hall_1_result=STS_Status_Door_Open,sts_reed_hall_2_result=STS_Status_SOS_Release, last_sts_reed_hall_1_result=STS_Status_Door_Open, last_sts_reed_hall_2_result=STS_Status_SOS_Release;
volatile uint8_t sts_reed_hall_1_changed=0, sts_reed_hall_2_changed=0; volatile uint8_t sts_reed_hall_1_changed=0, sts_reed_hall_2_changed=0;
volatile uint8_t sts_rss_config_updated_flag = 0; volatile uint8_t sts_rss_config_updated_flag = 0;
extern volatile uint8_t mems_int1_detected, link_wakeup, link_sleep; extern volatile uint8_t mems_int1_detected, link_wakeup, link_sleep;
@ -213,16 +213,14 @@ void STS_YunhornSTSEventRFAC_Process(void)
void STS_YunhornSTSEventP1_Process(void) void STS_YunhornSTSEventP1_Process(void)
{ {
sts_reed_hall_1_result = (sts_hall1_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
sts_reed_hall_2_result = (sts_hall2_read==0)?STS_Status_Door_Close:STS_Status_Door_Open;
sts_reed_hall_1_changed = (sts_reed_hall_1_result != last_sts_reed_hall_1_result);
sts_reed_hall_2_changed = (sts_reed_hall_2_result != last_sts_reed_hall_2_result);
sts_reed_hall_1_result = sts_hall1_read;
sts_reed_hall_1_changed =0;
last_sts_reed_hall_1_result = sts_reed_hall_1_result; last_sts_reed_hall_1_result = sts_reed_hall_1_result;
last_sts_reed_hall_2_result = sts_reed_hall_2_result;
sts_emergency_button_pushed = sts_reed_hall_2_result; sts_reed_hall_2_result = sts_hall2_read;
sts_reed_hall_2_changed =0;
last_sts_reed_hall_2_result = sts_reed_hall_2_result;
STS_Combined_Status_Processing(); STS_Combined_Status_Processing();
} }

View File

@ -51,6 +51,7 @@ volatile uint8_t sts_ac_code[YUNHORN_STS_AC_CODE_SIZE]={0x0};
extern hmac_result_t hmac_result; extern hmac_result_t hmac_result;
extern volatile uint8_t sts_reed_hall_ext_int; extern volatile uint8_t sts_reed_hall_ext_int;
extern volatile uint8_t sts_hall1_read, sts_hall2_read; extern volatile uint8_t sts_hall1_read, sts_hall2_read;
extern volatile uint8_t sts_reed_hall_1_changed, sts_reed_hall_2_changed;
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close 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; extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color;
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag; extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
@ -634,9 +635,11 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{ {
#ifdef STS_O7 #ifdef STS_O7
case HALL1_Pin: case HALL1_Pin:
HAL_Delay(150); //de-bouncing if (sts_reed_hall_1_changed)
{
HAL_Delay(250); //de-bouncing
sts_hall1_read = HALL1_STATE; sts_hall1_read = HALL1_STATE;
APP_LOG(TS_OFF, VLEVEL_M, "\n\n Door Contact Read = %02X \r\n", HALL1_STATE); APP_LOG(TS_OFF, VLEVEL_M, "\n\n Door Contact Read = %02x --%20s\r\n", HALL1_STATE, (HALL1_STATE==STS_Status_Door_Close)?"Door Closed":"Door Opened");
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */ /* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
// if (EventType == TX_ON_EVENT) // if (EventType == TX_ON_EVENT)
@ -645,16 +648,22 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
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); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
} }
//sts_reed_hall_1_changed =0;
}
break; break;
case HALL2_Pin: case HALL2_Pin:
HAL_Delay(150); //de-bouncing if (sts_reed_hall_2_changed)
{
HAL_Delay(250); //de-bouncing
sts_hall2_read = HALL2_STATE; sts_hall2_read = HALL2_STATE;
APP_LOG(TS_OFF, VLEVEL_M, "\n\n SOS Button Read = %02X \r\n", HALL2_STATE); APP_LOG(TS_OFF, VLEVEL_M, "\n\n SOS Button Read = %02x --%20s\r\n", HALL2_STATE, (HALL2_STATE==STS_Status_SOS_Pushdown)?"SOS Pushdown":"SOS Released");
//sensor_data_ready =1; //sensor_data_ready =1;
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); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
//sts_reed_hall_2_changed =0;
}
break; break;
#else #else
@ -906,13 +915,11 @@ static void SendTxData(void)
UTIL_TIMER_Time_t nextTxIn = 0; UTIL_TIMER_Time_t nextTxIn = 0;
uint8_t i = 0; uint8_t i = 0;
if (LmHandlerIsBusy() != false){ if (LmHandlerIsBusy() == false)
APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n** ** LmHandlerIsBusy ** **\r\n\n\n");
} else
{ {
AppData.Port = LORAWAN_USER_APP_PORT; AppData.Port = LORAWAN_USER_APP_PORT;
//AppData.Buffer[i++] = AppLedStateOn; //#01 //AppData.Buffer[i++] = AppLedStateOn; //#01
STS_PRESENCE_SENSOR_Prepare_Send_Data(); //STS_PRESENCE_SENSOR_Prepare_Send_Data();
if ((heart_beat_timer != 0L)) // sensor data OVERWRITE heart-beat message, 2024-05-12 if ((heart_beat_timer != 0L)) // sensor data OVERWRITE heart-beat message, 2024-05-12
{ {
@ -927,7 +934,7 @@ static void SendTxData(void)
sensor_data_ready =0; sensor_data_ready =0;
AppData.Buffer[i++] = AppLedStateOn; //AppData.Buffer[i++] = AppLedStateOn;
//i = PrepareSendTxData(); //i = PrepareSendTxData();
//STS_PRESENCE_SENSOR_Prepare_Send_Data(); //STS_PRESENCE_SENSOR_Prepare_Send_Data();