good at work mode switch and system reboot
This commit is contained in:
parent
095b0428ed
commit
e75d6a1a83
|
@ -56,13 +56,14 @@ enum sts_oo_work_mode {
|
|||
STS_REEDSWITCH_MODE, // 2 REED SWITCH ONLY
|
||||
STS_RSS_MODE, // 3 RSS ONLY
|
||||
STS_DUAL_MODE, // 4 RSS + REED SWITCH IN ONE UNIT
|
||||
STS_REMOTE_REED_RSS_MODE, // 5 REMOTE REED SWITCH + RSS MODE 2023-05-04
|
||||
STS_DUAL_RSS_MODE, // 6 RSS_1 + RSS_2 IN TWO UNITS
|
||||
STS_TOF_RSS_MODE, // 7 TOF + RSS MODE
|
||||
STS_TOF_DISTANCE_MODE, // 8 TOF DISTANCE
|
||||
STS_TOF_PRESENCE_MODE, // 9 TOF PRESENCE OCCUPANCY
|
||||
STS_TOF_IN_OUT_MODE, // A TOF IN OUT COUNT
|
||||
STS_FALL_DETECTION_MODE, // B DUAL_MODE + FALL DETECTION
|
||||
STS_UNI_MODE, // 5 DUAL_MODE + FALL DETECTION
|
||||
STS_REMOTE_REED_RSS_MODE, // 6 REMOTE REED SWITCH + RSS MODE 2023-05-04
|
||||
STS_DUAL_RSS_MODE, // 7 RSS_1 + RSS_2 IN TWO UNITS
|
||||
STS_TOF_RSS_MODE, // 8 TOF + RSS MODE
|
||||
STS_TOF_DISTANCE_MODE, // 9 TOF DISTANCE
|
||||
STS_TOF_PRESENCE_MODE, // A TOF PRESENCE OCCUPANCY
|
||||
STS_TOF_IN_OUT_MODE, // B TOF IN OUT COUNT
|
||||
|
||||
|
||||
STS_OTHER_MODE // ? OTHER MODE
|
||||
};
|
||||
|
|
|
@ -258,7 +258,7 @@ void STS_Combined_Status_Processing(void)
|
|||
sts_status_color = STS_RED;
|
||||
}
|
||||
break;
|
||||
case STS_DUAL_MODE:
|
||||
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;
|
||||
|
@ -286,6 +286,35 @@ void STS_Combined_Status_Processing(void)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case STS_UNI_MODE: //FOR STS-O7
|
||||
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;
|
||||
|
||||
} 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;
|
||||
switch(sts_fall_rising_detected_result) {
|
||||
case STS_PRESENCE_LAYDOWN:
|
||||
sts_lamp_bar_color = STS_YELLOW;
|
||||
sts_status_color = STS_YELLOW;
|
||||
break;
|
||||
case STS_PRESENCE_FALL: //RED_BLUE FLASH
|
||||
sts_lamp_bar_color = STS_RED_BLUE;
|
||||
sts_status_color = STS_RED_BLUE;
|
||||
break;
|
||||
case STS_PRESENCE_RISING: //NORMAL OCCUPANCY STATUS
|
||||
sts_lamp_bar_color = STS_RED;
|
||||
sts_status_color = STS_RED;
|
||||
break;
|
||||
}
|
||||
if (sts_reed_hall_2_result == STS_Status_SOS_Pushdown )
|
||||
{
|
||||
sts_status_color = STS_RED_BLUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case STS_REMOTE_REED_RSS_MODE:
|
||||
if ((sts_rss_result == STS_RESULT_NO_MOTION) && (sts_reed_hall_result == STS_Status_Door_Open ))
|
||||
{
|
||||
|
|
|
@ -503,7 +503,7 @@ void STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE(void)
|
|||
void STS_PRESENCE_SENSOR_Init_Send_Data(void)
|
||||
{
|
||||
sts_o7_sensorData.lamp_bar_color = STS_GREEN;
|
||||
sts_o7_sensorData.workmode = STS_DUAL_MODE;
|
||||
sts_o7_sensorData.workmode = sts_work_mode; //STS_DUAL_MODE;
|
||||
|
||||
sts_o7_sensorData.state_sensor1_on_off = 0x0;
|
||||
sts_o7_sensorData.state_sensor2_on_off = 0x0;
|
||||
|
@ -592,7 +592,7 @@ void STS_PRESENCE_SENSOR_Init(void)
|
|||
{
|
||||
APP_LOG(TS_ON, VLEVEL_M, "##### YunHorn SmarToilets(r) Presence Sensor Started\r\n");
|
||||
|
||||
sts_o7_sensorData.workmode = (uint8_t)STS_DUAL_MODE;
|
||||
sts_o7_sensorData.workmode = (uint8_t)sts_work_mode; //STS_DUAL_MODE;
|
||||
sts_o7_sensorData.lamp_bar_color = (uint8_t)STS_GREEN;
|
||||
sts_o7_sensorData.battery_Pct = 99;
|
||||
sts_o7_sensorData.dutycycletimelevel = 1;
|
||||
|
|
|
@ -148,6 +148,7 @@ char sts_work_mode_code[15][25] ={
|
|||
"REEDSWITCH_MODE",
|
||||
"RSS_MODE",
|
||||
"DUAL_MODE",
|
||||
"UNI_MODE",
|
||||
"REMOTE_REED_RSS_MODE",
|
||||
"DUAL_RSS_MODE",
|
||||
"TOF_RSS_MODE",
|
||||
|
@ -157,7 +158,6 @@ char sts_work_mode_code[15][25] ={
|
|||
"FALL_DETECTION_MODE",
|
||||
"OTHER_MODE1",
|
||||
"OTHER_MODE2",
|
||||
"OTHER_MODE3",
|
||||
};
|
||||
#endif
|
||||
/* USER CODE END EV */
|
||||
|
@ -871,31 +871,49 @@ static void SendTxData(void)
|
|||
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.lamp_bar_color)&0xff; //01
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.workmode)&0xff; //02 WORK MODE
|
||||
if (sts_work_mode == STS_DUAL_MODE)
|
||||
{
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status
|
||||
} else if (sts_work_mode == STS_UNI_MODE)
|
||||
{
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance)&0xff; //08 LSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score>>8)&0xff; //09 MSB score
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score)&0xff; //10 LSB score
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.unconcious_state)&0xff; //11 unconcious state detected or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_state)&0xff; //12 fall detected or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //13 occupancy over time or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //14 occupancy over stay duration MSB
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //15 occupancy over stay duration LSB
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance)&0xff; //08 LSB distance
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score>>8)&0xff; //09 MSB score
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score)&0xff; //10 LSB score
|
||||
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.unconcious_state)&0xff; //11 unconcious state detected or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_state)&0xff; //12 fall detected or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //13 occupancy over time or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //14 occupancy over stay duration MSB
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //15 occupancy over stay duration LSB
|
||||
}
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| Color = %4s | Mode = %5s |\r\n",(char *)sts_lamp_color_code[sensorData.lamp_bar_color], (char*)sts_work_mode_code[sensorData.workmode]);
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| S1-DoorOpen | S2-Motion | S3-SOS | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay | Fall Detected|"
|
||||
"\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n",
|
||||
sensorData.state_sensor1_on_off, sensorData.state_sensor2_on_off,sensorData.state_sensor3_on_off, sensorData.state_sensor4_on_off,
|
||||
(uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score,
|
||||
sensorData.unconcious_state, sensorData.unconcious_duration, sensorData.fall_state );
|
||||
"\r\n######| Color = %4s | Mode = %5s |\r\n",(char *)sts_lamp_color_code[0x0f&sensorData.lamp_bar_color], (char*)sts_work_mode_code[sensorData.workmode]);
|
||||
if (sts_work_mode == STS_UNI_MODE)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| S1-DoorOpen | S2-Motion | S3-SOS | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay | Fall Detected|"
|
||||
"\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n",
|
||||
sensorData.state_sensor1_on_off, sensorData.state_sensor2_on_off,sensorData.state_sensor3_on_off, sensorData.state_sensor4_on_off,
|
||||
(uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score,
|
||||
sensorData.unconcious_state, sensorData.unconcious_duration, sensorData.fall_state );
|
||||
} else if (sts_work_mode == STS_DUAL_MODE) {
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_L,
|
||||
"\r\n######| S1-DoorOpen | S2-Motion | S3-SOS |\r\n"
|
||||
"\r\n######| %1d | %1d | %1d |\r\n",
|
||||
sensorData.state_sensor1_on_off, sensorData.state_sensor2_on_off,sensorData.state_sensor3_on_off);
|
||||
}
|
||||
}
|
||||
|
||||
AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
|
||||
|
@ -956,7 +974,7 @@ static void OnTxTimerEvent(void *context)
|
|||
//heart_beat_timer = 1;
|
||||
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
#if 0
|
||||
if (sts_ac_code[0]==0x0) {
|
||||
/* RFAC Challenge */
|
||||
if (rfac_timer < (STS_BURN_IN_RFAC+3)) {
|
||||
|
@ -966,7 +984,7 @@ static void OnTxTimerEvent(void *context)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
/*Wait for next tx slot*/
|
||||
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
|
@ -1779,7 +1797,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\nTime YYYYMMDD=%4d:%2d:%2d HHMMSS=%2d:%2d:%2d \r\n",
|
||||
mylocal.tm_year, mylocal.tm_mon, mylocal.tm_mday, mylocal.tm_hour, mylocal.tm_min, mylocal.tm_sec);
|
||||
|
||||
#endif
|
||||
outbuf[i++] = (uint8_t) mylocal.tm_year>>8&0xff;
|
||||
outbuf[i++] = (uint8_t) mylocal.tm_year&0xff;
|
||||
outbuf[i++] = (uint8_t) mylocal.tm_mon;
|
||||
|
@ -1787,7 +1805,7 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
outbuf[i++] = (uint8_t) mylocal.tm_hour;
|
||||
outbuf[i++] = (uint8_t) mylocal.tm_min;
|
||||
outbuf[i++] = (uint8_t) mylocal.tm_sec;
|
||||
#endif
|
||||
|
||||
STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, (uint8_t *)outbuf);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "###### YUNHORN Report Version [ %10x ] \r\n", (uint8_t *)outbuf);
|
||||
}
|
||||
|
@ -2070,6 +2088,10 @@ void USER_APP_AUTO_RESPONDER_Parse(char *tlv_buf, size_t tlv_buf_size)
|
|||
OnStoreSTSCFGContextRequest();
|
||||
|
||||
STS_Combined_Status_Processing();
|
||||
HAL_Delay(2000);
|
||||
|
||||
OnSystemReset();
|
||||
|
||||
} else {
|
||||
invalid_flag = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue