improved service period check
This commit is contained in:
parent
0027a4d285
commit
abd78f5156
Binary file not shown.
Binary file not shown.
|
@ -99,6 +99,16 @@ typedef struct
|
||||||
} STS_PRESENCE_SENSOR_Event_Status_t;
|
} STS_PRESENCE_SENSOR_Event_Status_t;
|
||||||
|
|
||||||
//#define STS_ALERT_NORMAL 0x00 // (1) WELCOME MESSAGE, NORMAL
|
//#define STS_ALERT_NORMAL 0x00 // (1) WELCOME MESSAGE, NORMAL
|
||||||
|
#define STS_PROJECTOR_CMD_POWER_OFF 4
|
||||||
|
#define STS_PROJECTOR_CMD_POWER_ON 1
|
||||||
|
#define STS_PROJECTOR_CMD_PIC_FIRST 2
|
||||||
|
#define STS_PROJECTOR_CMD_PIC_NEXT 3
|
||||||
|
|
||||||
|
#define STS_PROJECTOR_CMD_PIC_1 5
|
||||||
|
#define STS_PROJECTOR_CMD_PIC_2 6
|
||||||
|
#define STS_PROJECTOR_CMD_PIC_3 7
|
||||||
|
#define STS_PROJECTOR_CMD_PIC_4 8
|
||||||
|
|
||||||
#define STS_ALERT_HUMIDITY_NORMAL 0x01 // (1) WELCOME MESSAGE, NORMAL
|
#define STS_ALERT_HUMIDITY_NORMAL 0x01 // (1) WELCOME MESSAGE, NORMAL
|
||||||
#define STS_ALERT_HUMIDITY_HIGH 0x02 // (2) CAUTION WET FLOOR
|
#define STS_ALERT_HUMIDITY_HIGH 0x02 // (2) CAUTION WET FLOOR
|
||||||
#define STS_ALERT_TEMP_HIGH 0x04
|
#define STS_ALERT_TEMP_HIGH 0x04
|
||||||
|
@ -106,6 +116,17 @@ typedef struct
|
||||||
#define STS_ALERT_CLEAN_IN_PROGRESS 0x10 // (4) CLEAN IN PROGRESS,
|
#define STS_ALERT_CLEAN_IN_PROGRESS 0x10 // (4) CLEAN IN PROGRESS,
|
||||||
#define STS_ALERT_OTHER1 0x20
|
#define STS_ALERT_OTHER1 0x20
|
||||||
#define STS_ALERT_OTHER2 0x40
|
#define STS_ALERT_OTHER2 0x40
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t rc_dev_eui[3]; // address 20bit, 3 bytes
|
||||||
|
uint8_t rc_dev_button_num;
|
||||||
|
uint8_t rc_dev_button_cmd[16]; // button cmd, 4 bits
|
||||||
|
char rc_dev_button_name[16][20]; // button name
|
||||||
|
|
||||||
|
uint8_t rf_dev_power_state; // controlled RF projector power state
|
||||||
|
uint8_t rf_dev_slide_id; // controlled RF projector slide id
|
||||||
|
|
||||||
|
} remote_control_sensor_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,7 @@ uint8_t sts_alert_id=STS_ALERT_HUMIDITY_NORMAL, prev_alert_id=0;
|
||||||
|
|
||||||
t_service_period_per_day rc_service_period[4]={
|
t_service_period_per_day rc_service_period[4]={
|
||||||
{1,6,30,12,00},
|
{1,6,30,12,00},
|
||||||
{1,13,00, 18,00},
|
{1,13,00, 19,30},
|
||||||
{0,0,0,0,0},
|
{0,0,0,0,0},
|
||||||
{0,0,0,0,0}
|
{0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
@ -679,23 +679,24 @@ void STS_YunhornSTSEventP6_Process(void)
|
||||||
void STS_YunhornRCRFSendCMD(uint8_t rf_cmd)
|
void STS_YunhornRCRFSendCMD(uint8_t rf_cmd)
|
||||||
{
|
{
|
||||||
switch (rf_cmd) {
|
switch (rf_cmd) {
|
||||||
case 0:
|
case STS_PROJECTOR_CMD_POWER_OFF:
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #0 \n\n======================\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #0 POWER OFF \n\n======================\r\n");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case STS_PROJECTOR_CMD_POWER_ON:
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #1 \n\n======================\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #1 POWER ON\n\n======================\r\n");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case STS_PROJECTOR_CMD_PIC_FIRST:
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #2 \n\n======================\r\n");
|
case STS_PROJECTOR_CMD_PIC_1:
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #2 PIC-#1 WELCOME\n\n======================\r\n");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case STS_PROJECTOR_CMD_PIC_2:
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #3 \n\n======================\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #3 PIC-#2 CAUTION WET FLOOR\n\n======================\r\n");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case STS_PROJECTOR_CMD_PIC_3:
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #5 \n\n======================\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #5 PIC-#3 FULL OCCUPIED\n\n======================\r\n");
|
||||||
break;
|
break;
|
||||||
case 5:
|
case STS_PROJECTOR_CMD_PIC_4:
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #6 \n\n======================\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n ======================\n\n RF CMD_BUTTON #6 PIC-#4 CLEAN IN PROGRESS \n\n======================\r\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -710,7 +711,8 @@ void STS_YunhornSTSEventP7_Process(void)
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n P7 Testing Process\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n P7 Testing Process\r\n");
|
||||||
#if defined(STS_K1)
|
#if defined(STS_K1)
|
||||||
|
if (STS_Check_Service_Period())
|
||||||
|
{
|
||||||
if (STS_IAQ_Generate_Alert())
|
if (STS_IAQ_Generate_Alert())
|
||||||
{
|
{
|
||||||
//STS_RF_Show_pic(cause_wet_floor);
|
//STS_RF_Show_pic(cause_wet_floor);
|
||||||
|
@ -738,6 +740,14 @@ void STS_YunhornSTSEventP7_Process(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (prev_alert_id != STS_ALERT_HUMIDITY_NORMAL)
|
||||||
|
{
|
||||||
|
sts_alert_id = STS_ALERT_HUMIDITY_NORMAL;
|
||||||
|
prev_alert_id = sts_alert_id;
|
||||||
|
STS_YunhornRCRFSendCMD(STS_PROJECTOR_CMD_POWER_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -845,24 +855,35 @@ static bool STS_Check_Service_Period(void)
|
||||||
struct tm time_now={0};
|
struct tm time_now={0};
|
||||||
SysTime_t UnixEpoch = SysTimeGet();
|
SysTime_t UnixEpoch = SysTimeGet();
|
||||||
UnixEpoch.Seconds -= 18; /*removing leap seconds*/
|
UnixEpoch.Seconds -= 18; /*removing leap seconds*/
|
||||||
|
UnixEpoch.Seconds += 3600 * 8; /*adding 8 hours GMT+8 */
|
||||||
SysTimeLocalTime(UnixEpoch.Seconds, &time_now);
|
SysTimeLocalTime(UnixEpoch.Seconds, &time_now);
|
||||||
|
|
||||||
bool sts_rc_in_service_period_try = false;
|
bool sts_rc_in_service_period_try = false;
|
||||||
|
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Current Time: %2d:%2d \r\n", time_now.tm_hour, time_now.tm_min);
|
||||||
|
|
||||||
for (uint8_t i=0; i<4; i++)
|
for (uint8_t i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
if (rc_service_period[i].enable_mask)
|
if (rc_service_period[i].enable_mask)
|
||||||
{
|
{
|
||||||
if ((time_now.tm_hour >= rc_service_period[i].start_hour) && (time_now.tm_min < rc_service_period[i].end_hour))
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n Service Period #%i : Start: %2d:%2d Till %2d:%2d \r\n",
|
||||||
|
i,rc_service_period[i].start_hour, rc_service_period[i].start_minute,
|
||||||
|
rc_service_period[i].end_hour, rc_service_period[i].end_minute);
|
||||||
|
|
||||||
|
if (((time_now.tm_hour*60+time_now.tm_min) >= (rc_service_period[i].start_hour*60+rc_service_period[i].start_minute))
|
||||||
|
&& ((time_now.tm_hour*60+time_now.tm_min) < (rc_service_period[i].end_hour*60+rc_service_period[i].end_minute)))
|
||||||
{
|
{
|
||||||
if ((time_now.tm_min >= rc_service_period[i].start_minute) && (time_now.tm_min < rc_service_period[i].end_minute))
|
|
||||||
sts_rc_in_service_period_try = true;
|
sts_rc_in_service_period_try = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APP_LOG(TS_OFF,VLEVEL_M, "\r\n ------ In Service Period %d state: %d \r\n", i, (sts_rc_in_service_period_try)?1:0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sts_rc_in_service_period = sts_rc_in_service_period_try;
|
sts_rc_in_service_period = sts_rc_in_service_period_try;
|
||||||
return sts_rc_in_service_period_try;
|
|
||||||
|
APP_LOG(TS_OFF,VLEVEL_M, "\r\n ------ In Service Period: %d \r\n", (sts_rc_in_service_period)?1:0);
|
||||||
|
return sts_rc_in_service_period;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* STS P8 Process, Detection ETR Sensors, Water flow sensors, pulse counting
|
* STS P8 Process, Detection ETR Sensors, Water flow sensors, pulse counting
|
||||||
|
|
Loading…
Reference in New Issue