add gpio output for bluetooth communication active

This commit is contained in:
technyon
2025-10-06 17:51:00 +07:00
parent e05ff0fdd0
commit 0e1caf6211
8 changed files with 27 additions and 22 deletions

View File

@@ -1,9 +1,10 @@
#include "NukiRetryHandler.h"
#include "Logger.h"
NukiRetryHandler::NukiRetryHandler(std::string reference, Gpio* gpio, std::vector<uint8_t> pinsCommError, int nrOfRetries, int retryDelay)
NukiRetryHandler::NukiRetryHandler(std::string reference, Gpio* gpio, std::vector<uint8_t> pinsComm, std::vector<uint8_t> pinsCommError, int nrOfRetries, int retryDelay)
: _reference(reference),
_gpio(gpio),
_pinsComm(pinsComm),
_pinsCommError(pinsCommError),
_nrOfRetries(nrOfRetries),
_retryDelay(retryDelay)
@@ -16,6 +17,8 @@ const Nuki::CmdResult NukiRetryHandler::retryComm(std::function<Nuki::CmdResult(
int retryCount = 0;
setCommPins(HIGH);
while(retryCount < _nrOfRetries + 1 && cmdResult != Nuki::CmdResult::Success)
{
cmdResult = func();
@@ -36,11 +39,20 @@ const Nuki::CmdResult NukiRetryHandler::retryComm(std::function<Nuki::CmdResult(
vTaskDelay(_retryDelay / portTICK_PERIOD_MS);
}
}
setCommPins(LOW);
setCommErrorPins(LOW);
return cmdResult;
}
void NukiRetryHandler::setCommPins(const uint8_t& value)
{
for (uint8_t pin : _pinsComm)
{
_gpio->setPinOutput(pin, value);
}
}
void NukiRetryHandler::setCommErrorPins(const uint8_t& value)
{
for (uint8_t pin : _pinsCommError)

View File

@@ -6,17 +6,19 @@
class NukiRetryHandler
{
public:
NukiRetryHandler(std::string reference, Gpio* gpio, std::vector<uint8_t> pinsCommError, int nrOfRetries, int retryDelay);
NukiRetryHandler(std::string reference, Gpio* gpio, std::vector<uint8_t> pinsComm, std::vector<uint8_t> pinsCommError, int nrOfRetries, int retryDelay);
const Nuki::CmdResult retryComm(std::function<Nuki::CmdResult ()> func);
private:
void setCommPins(const uint8_t& value);
void setCommErrorPins(const uint8_t& value);
std::string _reference;
Gpio* _gpio = nullptr;
int _nrOfRetries = 0;
int _retryDelay = 0;
std::vector<uint8_t> _pinsComm;
std::vector<uint8_t> _pinsCommError;
};