aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/HCIHandler.hpp6
-rw-r--r--src/direct_bt/DBTAdapter.cpp6
-rw-r--r--src/direct_bt/HCIHandler.cpp29
3 files changed, 22 insertions, 19 deletions
diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp
index e25f70d0..1b3ad394 100644
--- a/api/direct_bt/HCIHandler.hpp
+++ b/api/direct_bt/HCIHandler.hpp
@@ -299,7 +299,7 @@ namespace direct_bt {
/**
* Bring up this adapter into a POWERED functional state.
*/
- bool startAdapter();
+ HCIStatusCode startAdapter();
/**
* Bring down this adapter into a non-POWERED non-functional state.
@@ -311,7 +311,7 @@ namespace direct_bt {
* </pre>
* </p>
*/
- bool stopAdapter();
+ HCIStatusCode stopAdapter();
/**
* Reset the adapter.
@@ -324,7 +324,7 @@ namespace direct_bt {
* BT Core Spec v5.2: Vol 4, Part E HCI: 7.3.2 Reset command
* </pre>
*/
- bool resetAdapter();
+ HCIStatusCode resetAdapter();
/**
* BT Core Spec v5.2: Vol 4, Part E HCI: 7.3.2 Reset command
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 {