added gpio read function

This commit is contained in:
2021-02-14 09:25:40 +01:00
parent 3f41adf340
commit e00667ba0b
18 changed files with 161 additions and 56 deletions

View File

@ -214,21 +214,13 @@ void HeaterHandler::handleSwitchOnCommand(HeaterMapIter heaterMapIter) {
gpioId_t gpioId = getGpioIdFromSwitchNr(switchNr);
result = gpioInterface->pullHigh(gpioId);
if (result != RETURN_OK) {
sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id"
<< gpioId << "high" << std::endl;
sif::error << "HeaterHandler::handleSwitchOnCommand: Failed to pull gpio with id "
<< gpioId << " high" << std::endl;
triggerEvent(GPIO_PULL_HIGH_FAILED, result);
}
else {
switchStates[switchNr] = ON;
}
int gpioState;
result = gpioInterface->readGpio(gpioId, &gpioState);
if (result != RETURN_OK) {
sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to read gpio"
<< std::endl;
}
sif::debug << "HeaterHandler::handleSwitchOnCommand: GPIO state: " << gpioState
<< std::endl;
}
else {
triggerEvent(SWITCH_ALREADY_ON, switchNr);
@ -283,14 +275,6 @@ void HeaterHandler::handleSwitchOffCommand(HeaterMapIter heaterMapIter) {
mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF);
}
}
int gpioState;
result = gpioInterface->readGpio(gpioId, &gpioState);
if (result != RETURN_OK) {
sif::debug << "HeaterHandler::handleSwitchOnCommand: Failed to read gpio"
<< std::endl;
}
sif::debug << "HeaterHandler::handleSwitchOnCommand: GPIO state: " << gpioState
<< std::endl;
}
else {
sif::info << "HeaterHandler::handleSwitchOffCommand: Switch already off" << std::endl;