From b93de7cf27b835b42c486dd40656deaad701155e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 13 Oct 2020 03:06:02 +0200 Subject: HCIHandler::resetAdapter(): Generalize returning HCIStatusCode, adding #warning on !__linux__ --- src/direct_bt/DBTAdapter.cpp | 6 +----- src/direct_bt/HCIHandler.cpp | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src/direct_bt') 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 { -- cgit v1.2.3