1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-11-16 03:59:11 +01:00

doorlockd now uses doorcmds.h

This commit is contained in:
Ralf Ramsauer 2015-09-17 14:53:19 +02:00
parent aaf47ab0c7
commit 5808ef8677

View File

@ -1,6 +1,8 @@
#include "config.h" #include "config.h"
#include "door.h" #include "door.h"
#include "../doorcmds.h"
Door::Door(const std::string &serDev, Door::Door(const std::string &serDev,
unsigned int baudrate) : unsigned int baudrate) :
_baudrate(baudrate), _baudrate(baudrate),
@ -68,17 +70,17 @@ void Door::_asyncRead()
goto out; goto out;
} }
if (recvBuf == 'U') { if (recvBuf == DOOR_BUTTON_UNLOCK) {
// In case that someone pushed the unlock button - just log it. // In case that someone pushed the unlock button - just log it.
// No further actions required // No further actions required
_logger(LogLevel::notice, "Someone pushed the unlock button"); _logger(LogLevel::notice, "Someone pushed the unlock button");
goto out; goto out;
} else if (recvBuf == 'L') { } else if (recvBuf == DOOR_BUTTON_LOCK) {
_logger(LogLevel::notice, "Someone pushed the lock button"); _logger(LogLevel::notice, "Someone pushed the lock button");
_logger(LogLevel::notice, "Locking..."); _logger(LogLevel::notice, "Locking...");
lock(); lock();
goto out; goto out;
} else if (recvBuf == 'E') { } else if (recvBuf == DOOR_EMERGENCY_UNLOCK) {
_logger(LogLevel::warning, "Someone did an emergency unlock!"); _logger(LogLevel::warning, "Someone did an emergency unlock!");
// TODO: Trigger Emergency unlock script // TODO: Trigger Emergency unlock script
goto out; goto out;
@ -145,17 +147,17 @@ void Door::unlock()
while (_state == State::Unlocked) { while (_state == State::Unlocked) {
if (_state == State::Unlocked) { if (_state == State::Unlocked) {
writeCMD('u'); writeCMD(DOOR_CMD_UNLOCK);
if (_schnapper) { if (_schnapper) {
_schnapper = false; _schnapper = false;
writeCMD('s'); writeCMD(DOOR_CMD_SCHNAPER);
} }
} }
_heartbeatCondition.wait_for(lock, Milliseconds(400)); _heartbeatCondition.wait_for(lock, Milliseconds(400));
} }
writeCMD('l'); writeCMD(DOOR_CMD_LOCK);
}); });
_logger(LogLevel::info, "Door opened"); _logger(LogLevel::info, "Door opened");