PROJECTOR_CTRL: consistent logging of [DIS]CONNECTs

This commit is contained in:
Jan Bubík 2021-03-06 23:20:09 +01:00
parent 2793402027
commit 93b9f14fc5
1 changed files with 8 additions and 2 deletions

View File

@ -324,10 +324,16 @@ projector_ctrl_loop(struct projector_ctrl_softc_s *sc)
oldstate = sc->sc_ser_state;
switch (sc->sc_ser_state = (projector_ctrl_serial_state_e)projector_ctrl_parse(sc, serial->read())) {
case PROJECTOR_CTRL_S_UNCONNECTED:
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
if (sc->sc_dev_state!=PROJECTOR_CTRL_DEV_UNKNOWN){
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(unexpected input)"));
}
break;
case PROJECTOR_CTRL_S_IDLE:
if ((oldstate==PROJECTOR_CTRL_S_QRY_PWR)&&(sc->sc_ser_result==PROJECTOR_CTRL_R_PASS)){
if(sc->sc_dev_state==PROJECTOR_CTRL_DEV_UNKNOWN){
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": CONNECTED"));
};
if(( (sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_ON)
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_COOLING)
||(sc->sc_ser_value==PROJECTOR_CTRL_QRYPWR_STARTING)
@ -383,7 +389,7 @@ projector_ctrl_tick(struct projector_ctrl_softc_s *sc)
};
}else if(sc->sc_ticks > sc->sc_cmd_info->timeout_ticks){
//current CMD has ran out of time, drop connection
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED"));
AddLog_P(LOG_LEVEL_INFO,PSTR(PROJECTOR_CTRL_LOGNAME ": DISCONNECTED(timeout)"));
sc->sc_dev_state=PROJECTOR_CTRL_DEV_UNKNOWN;
sc->sc_ser_state=PROJECTOR_CTRL_S_UNCONNECTED;
};