diff options
author | Sven Gothel <[email protected]> | 2020-10-13 03:06:02 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-13 03:06:02 +0200 |
commit | b93de7cf27b835b42c486dd40656deaad701155e (patch) | |
tree | 9ce704fa2a4f800c8e5eb02dfe87f8b21e2b17de /src/direct_bt | |
parent | e710b13bac1723ea8d5d4bae9e6a361cc7eadc3e (diff) |
HCIHandler::resetAdapter(): Generalize returning HCIStatusCode, adding #warning on !__linux__
Diffstat (limited to 'src/direct_bt')
-rw-r--r-- | src/direct_bt/DBTAdapter.cpp | 6 | ||||
-rw-r--r-- | src/direct_bt/HCIHandler.cpp | 29 |
2 files changed, 19 insertions, 16 deletions
diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/DBTAdapter.cpp index df5be3ce..bde124a2 100644 --- a/src/direct_bt/DBTAdapter.cpp +++ b/src/direct_bt/DBTAdapter.cpp @@ -330,11 +330,7 @@ HCIStatusCode DBTAdapter::reset() noexcept { } return status; #else - if( hci->resetAdapter() ) { - return HCIStatusCode::SUCCESS; - } else { - return HCIStatusCode::UNSPECIFIED_ERROR; - } + return hci->resetAdapter(); #endif } diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp index 104b3b19..218c064d 100644 --- a/src/direct_bt/HCIHandler.cpp +++ b/src/direct_bt/HCIHandler.cpp @@ -576,38 +576,45 @@ void HCIHandler::close() noexcept { DBG_PRINT("HCIHandler::close: End"); } -bool HCIHandler::startAdapter() { +HCIStatusCode HCIHandler::startAdapter() { #ifdef __linux__ int res; if( ( res = ioctl(comm.getSocketDescriptor(), HCIDEVUP, dev_id) ) < 0 ) { if (errno != EALREADY) { ERR_PRINT("HCIHandler::startAdapter(dev_id %d): FAILED: %d", dev_id, res); - return false; + return HCIStatusCode::INTERNAL_FAILURE; } } - return true; + return HCIStatusCode::SUCCESS; #else - return false; + #warning add implementation #endif + return HCIStatusCode::INTERNAL_FAILURE; } -bool HCIHandler::stopAdapter() { + +HCIStatusCode HCIHandler::stopAdapter() { #ifdef __linux__ int res; if( ( res = ioctl(comm.getSocketDescriptor(), HCIDEVDOWN, dev_id) ) < 0) { ERR_PRINT("HCIHandler::stopAdapter(dev_id %d): FAILED: %d", dev_id, res); - return false; + return HCIStatusCode::INTERNAL_FAILURE; } - return true; + return HCIStatusCode::SUCCESS; #else - return false; + #warning add implementation #endif + return HCIStatusCode::INTERNAL_FAILURE; } -bool HCIHandler::resetAdapter() { + +HCIStatusCode HCIHandler::resetAdapter() { #ifdef __linux__ - return stopAdapter() && startAdapter(); + if( HCIStatusCode::SUCCESS == stopAdapter() && HCIStatusCode::SUCCESS == startAdapter() ) { + return HCIStatusCode::SUCCESS; + } #else - return false; + #warning add implementation #endif + return HCIStatusCode::INTERNAL_FAILURE; } HCIStatusCode HCIHandler::reset() noexcept { |