diff --git a/doorlockd/lib/door.cpp b/doorlockd/lib/door.cpp index 9b19c64..90eb473 100644 --- a/doorlockd/lib/door.cpp +++ b/doorlockd/lib/door.cpp @@ -38,7 +38,7 @@ Door::~Door() _ioThread.join(); } -bool Door::readByte(char &byte, std::chrono::milliseconds timeout) +bool Door::_readByte(char &byte, std::chrono::milliseconds timeout) { std::unique_lock lock(_receiveLock); _receivedCondition.wait_for(lock, timeout); @@ -156,17 +156,17 @@ void Door::unlock() while (_state == State::Unlocked) { if (_state == State::Unlocked) { - writeCMD(DOOR_CMD_UNLOCK); + _writeCMD(DOOR_CMD_UNLOCK); if (_schnapper) { _schnapper = false; - writeCMD(DOOR_CMD_SCHNAPER); + _writeCMD(DOOR_CMD_SCHNAPER); } } _heartbeatCondition.wait_for(lock, Milliseconds(400)); } - writeCMD(DOOR_CMD_LOCK); + _writeCMD(DOOR_CMD_LOCK); }); _logger(LogLevel::notice, "Door opened"); @@ -176,13 +176,13 @@ void Door::unlock() system(POST_UNLOCK_SCRIPT); } -bool Door::writeCMD(char c) +bool Door::_writeCMD(char c) { std::lock_guard l(_serialMutex); _port.write_some(boost::asio::buffer(&c, sizeof(c))); char response; - if (readByte(response, Milliseconds(100))) + if (_readByte(response, Milliseconds(100))) { if (c != response) { _logger(LogLevel::error, "Sent command '%c' but got response '%c'", c, response); diff --git a/doorlockd/lib/door.h b/doorlockd/lib/door.h index 3c516a0..c75f622 100644 --- a/doorlockd/lib/door.h +++ b/doorlockd/lib/door.h @@ -69,9 +69,9 @@ private: Logger &_logger; // Writed command to AVR board - bool writeCMD(char c); + bool _writeCMD(char c); // Receives one byte and returns true or returns false on timeout - bool readByte(char &byte, Milliseconds timeout); + bool _readByte(char &byte, Milliseconds timeout); }; #endif