periodic reply map param is bool now

This commit is contained in:
Robin Müller 2020-06-19 01:05:51 +02:00
parent b412ef587a
commit cda3130b34
2 changed files with 9 additions and 9 deletions

View File

@ -184,7 +184,7 @@ void DeviceHandlerBase::decrementDeviceReplyMap() {
if (iter->second.delayCycles != 0) { if (iter->second.delayCycles != 0) {
iter->second.delayCycles--; iter->second.delayCycles--;
if (iter->second.delayCycles == 0) { if (iter->second.delayCycles == 0) {
if (iter->second.periodic != 0) { if (iter->second.periodic) {
iter->second.delayCycles = iter->second.maxDelayCycles; iter->second.delayCycles = iter->second.maxDelayCycles;
} }
replyToReply(iter, TIMEOUT); replyToReply(iter, TIMEOUT);
@ -344,7 +344,7 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode,
} }
ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand,
uint16_t maxDelayCycles, size_t replyLen, uint8_t periodic, uint16_t maxDelayCycles, size_t replyLen, bool periodic,
bool hasDifferentReplyId, DeviceCommandId_t replyId) { bool hasDifferentReplyId, DeviceCommandId_t replyId) {
//No need to check, as we may try to insert multiple times. //No need to check, as we may try to insert multiple times.
insertInCommandMap(deviceCommand); insertInCommandMap(deviceCommand);
@ -356,7 +356,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(DeviceCommandId_t de
} }
ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
uint16_t maxDelayCycles, size_t replyLen, uint8_t periodic) { uint16_t maxDelayCycles, size_t replyLen, bool periodic) {
DeviceReplyInfo info; DeviceReplyInfo info;
info.maxDelayCycles = maxDelayCycles; info.maxDelayCycles = maxDelayCycles;
info.periodic = periodic; info.periodic = periodic;
@ -385,7 +385,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm
} }
ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply, ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply,
uint16_t delayCycles, uint16_t maxDelayCycles, uint8_t periodic) { uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic) {
std::map<DeviceCommandId_t, DeviceReplyInfo>::iterator iter = std::map<DeviceCommandId_t, DeviceReplyInfo>::iterator iter =
deviceReplyMap.find(deviceReply); deviceReplyMap.find(deviceReply);
if (iter == deviceReplyMap.end()) { if (iter == deviceReplyMap.end()) {
@ -741,7 +741,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
if (info->delayCycles != 0) { if (info->delayCycles != 0) {
if (info->periodic != 0) { if (info->periodic) {
info->delayCycles = info->maxDelayCycles; info->delayCycles = info->maxDelayCycles;
} else { } else {
info->delayCycles = 0; info->delayCycles = 0;

View File

@ -381,7 +381,7 @@ protected:
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand,
uint16_t maxDelayCycles, size_t replyLen = 0, uint8_t periodic = 0, uint16_t maxDelayCycles, size_t replyLen = 0, bool periodic = false,
bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0); bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0);
/** /**
@ -395,7 +395,7 @@ protected:
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand,
uint16_t maxDelayCycles, size_t replyLen = 0, uint8_t periodic = 0); uint16_t maxDelayCycles, size_t replyLen = 0, bool periodic = false);
/** /**
* @brief A simple command to add a command to the commandList. * @brief A simple command to add a command to the commandList.
@ -421,7 +421,7 @@ protected:
*/ */
ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply, ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply,
uint16_t delayCycles, uint16_t maxDelayCycles, uint16_t delayCycles, uint16_t maxDelayCycles,
uint8_t periodic = 0); bool periodic = false);
/** /**
* @brief Can be implemented by child handler to * @brief Can be implemented by child handler to
@ -625,7 +625,7 @@ protected:
uint16_t maxDelayCycles; //!< The maximum number of cycles the handler should wait for a reply to this command. uint16_t maxDelayCycles; //!< The maximum number of cycles the handler should wait for a reply to this command.
uint16_t delayCycles; //!< The currently remaining cycles the handler should wait for a reply, 0 means there is no reply expected uint16_t delayCycles; //!< The currently remaining cycles the handler should wait for a reply, 0 means there is no reply expected
size_t replyLen = 0; //!< Expected size of the reply. size_t replyLen = 0; //!< Expected size of the reply.
uint8_t periodic; //!< if this is !=0, the delayCycles will not be reset to 0 but to maxDelayCycles bool periodic; //!< if this is !=0, the delayCycles will not be reset to 0 but to maxDelayCycles
DeviceCommandMap::iterator command; //!< The command that expects this reply. DeviceCommandMap::iterator command; //!< The command that expects this reply.
}; };