Two errors in the device handler to fix. Adjust the receiving of the packet in the 0.18s window and solve the problem of automatic passage to MODE OFf.

This commit is contained in:
2021-09-15 20:46:06 +02:00
parent 02bde1133e
commit d366b3ca22
9 changed files with 25 additions and 8 deletions
+8 -1
View File
@@ -78,6 +78,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
performOperationHook();
}
if (mode == MODE_OFF) {
sif::debug<<"DH_base: Mode off"<<std::endl;
return RETURN_OK;
}
switch (getComAction()) {
@@ -293,6 +294,7 @@ void DeviceHandlerBase::doStateMachine() {
}
break;
case _MODE_POWER_DOWN:
sif::debug<<"DH_base: mode power down"<<std::endl;
commandSwitch(PowerSwitchIF::SWITCH_OFF);
setMode(_MODE_WAIT_OFF);
break;
@@ -322,6 +324,7 @@ void DeviceHandlerBase::doStateMachine() {
}
break;
case _MODE_WAIT_OFF: {
sif::debug<<"DH_base: mode power down"<<std::endl;
uint32_t currentUptime;
Clock::getUptime(&currentUptime);
@@ -358,6 +361,7 @@ void DeviceHandlerBase::doStateMachine() {
break;
default:
triggerEvent(OBJECT_IN_INVALID_MODE, mode, submode);
sif::debug<<"object in invalid mode"<<std::endl;
setMode(_MODE_POWER_DOWN, 0);
break;
}
@@ -661,9 +665,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
// scanForReply routines.
uint32_t remainingLength = receivedDataLen;
for (uint32_t count = 0; count < receivedDataLen; count++) {
sif::debug<<"DH_base: debug0"<<std::endl;
result = scanForReply(receivedData, remainingLength, &foundId,
&foundLen);
sif::debug<<"DH_base: debug01"<<std::endl;
switch (result) {
case RETURN_OK:
handleReply(receivedData, foundId, foundLen);
@@ -684,6 +689,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
case IGNORE_FULL_PACKET:
return;
default:
sif::debug<<"DH_base: debug02"<<std::endl;
//We need to wait for timeout.. don't know what command failed and who sent it.
replyRawReplyIfnotWiretapped(receivedData, foundLen);
triggerEvent(DEVICE_READING_REPLY_FAILED, result, foundLen);
@@ -911,6 +917,7 @@ Mode_t DeviceHandlerBase::getBaseMode(Mode_t transitionMode) {
return _MODE_TO_ON;
}
if (transitionMode == _MODE_SHUT_DOWN) {
sif::debug<<"mode shut down"<<std::endl;
return _MODE_POWER_DOWN;
}
return transitionMode