added option to disable it as well

This commit is contained in:
Robin Müller 2021-09-11 17:42:29 +02:00
parent c9bfc8464a
commit 11a3c8c21f
No known key found for this signature in database
GPG Key ID: BE6480244DFE612C
2 changed files with 10 additions and 4 deletions

View File

@ -481,7 +481,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep
} }
} }
ReturnValue_t DeviceHandlerBase::enablePeriodicReply(DeviceCommandId_t deviceReply) { ReturnValue_t DeviceHandlerBase::enablePeriodicReply(bool enable, DeviceCommandId_t deviceReply) {
auto replyIter = deviceReplyMap.find(deviceReply); auto replyIter = deviceReplyMap.find(deviceReply);
if (replyIter == deviceReplyMap.end()) { if (replyIter == deviceReplyMap.end()) {
triggerEvent(INVALID_DEVICE_COMMAND, deviceReply); triggerEvent(INVALID_DEVICE_COMMAND, deviceReply);
@ -491,7 +491,12 @@ ReturnValue_t DeviceHandlerBase::enablePeriodicReply(DeviceCommandId_t deviceRep
if(not info->periodic) { if(not info->periodic) {
return COMMAND_NOT_SUPPORTED; return COMMAND_NOT_SUPPORTED;
} }
info->delayCycles = info->maxDelayCycles; if(enable) {
info->delayCycles = info->maxDelayCycles;
}
else {
info->delayCycles = 0;
}
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -486,10 +486,11 @@ protected:
/** /**
* Enables a periodic reply for a given command. It sets to delay cycles to the specified * Enables a periodic reply for a given command. It sets to delay cycles to the specified
* maximum delay cycles for a given reply ID. * maximum delay cycles for a given reply ID if enabled or to 0 if disabled.
* @param enable Specify whether to enable or disable a given periodic reply
* @return * @return
*/ */
ReturnValue_t enablePeriodicReply(DeviceCommandId_t deviceReply); ReturnValue_t enablePeriodicReply(bool enable, DeviceCommandId_t deviceReply);
/** /**
* @brief This function returns the reply length of the next reply to read. * @brief This function returns the reply length of the next reply to read.