diff options
author | Sven Gothel <[email protected]> | 2020-12-03 07:32:02 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-12-03 07:32:02 +0100 |
commit | e9fbbc847a7b64b5774563a74bc22905d775fa5f (patch) | |
tree | 3ea5acce610afc2d3ed33b522d36006ac257d3ee | |
parent | f68533d3b6fc4c01dcafba34d9fc954efbd44e37 (diff) |
Add Mapping from MgmtStatus -> HCIStatusCode, include value subset of former within latter (general HCIStatusCode use)
-rw-r--r-- | api/direct_bt/HCITypes.hpp | 23 | ||||
-rw-r--r-- | api/direct_bt/MgmtTypes.hpp | 1 | ||||
-rw-r--r-- | src/direct_bt/HCITypes.cpp | 18 | ||||
-rw-r--r-- | src/direct_bt/MgmtTypes.cpp | 28 |
4 files changed, 70 insertions, 0 deletions
diff --git a/api/direct_bt/HCITypes.hpp b/api/direct_bt/HCITypes.hpp index 9e008255..0f7070dd 100644 --- a/api/direct_bt/HCITypes.hpp +++ b/api/direct_bt/HCITypes.hpp @@ -190,6 +190,29 @@ namespace direct_bt { OPERATION_CANCELLED_BY_HOST = 0x44, PACKET_TOO_LONG = 0x45, + // MgmtStatus -> HCIStatusCode + + FAILED = 0xc3, + CONNECT_FAILED = 0xc4, + AUTH_FAILED = 0xc5, + NOT_PAIRED = 0xc6, + NO_RESOURCES = 0xc7, + TIMEOUT = 0xc8, + ALREADY_CONNECTED = 0xc9, + BUSY = 0xca, + REJECTED = 0xcb, + NOT_SUPPORTED = 0xcc, + INVALID_PARAMS = 0xcd, + DISCONNECTED = 0xce, + NOT_POWERED = 0xcf, + CANCELLED = 0xd0, + INVALID_INDEX = 0xd1, + RFKILLED = 0xd2, + ALREADY_PAIRED = 0xd3, + PERMISSION_DENIED = 0xd4, + + // Direct-BT + INTERNAL_TIMEOUT = 0xfd, INTERNAL_FAILURE = 0xfe, UNKNOWN = 0xff diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp index 76c0f159..3ff5b2a5 100644 --- a/api/direct_bt/MgmtTypes.hpp +++ b/api/direct_bt/MgmtTypes.hpp @@ -97,6 +97,7 @@ namespace direct_bt { PERMISSION_DENIED = 0x14 }; std::string getMgmtStatusString(const MgmtStatus opc) noexcept; + HCIStatusCode getHCIStatusCode(const MgmtStatus mstatus) noexcept; enum MgmtOption : uint32_t { EXTERNAL_CONFIG = 0x00000001, diff --git a/src/direct_bt/HCITypes.cpp b/src/direct_bt/HCITypes.cpp index fd1f7412..aa199b11 100644 --- a/src/direct_bt/HCITypes.cpp +++ b/src/direct_bt/HCITypes.cpp @@ -117,6 +117,24 @@ namespace direct_bt { X(LIMIT_REACHED) \ X(OPERATION_CANCELLED_BY_HOST) \ X(PACKET_TOO_LONG) \ + X(FAILED) \ + X(CONNECT_FAILED) \ + X(AUTH_FAILED) \ + X(NOT_PAIRED) \ + X(NO_RESOURCES) \ + X(TIMEOUT) \ + X(ALREADY_CONNECTED) \ + X(BUSY) \ + X(REJECTED) \ + X(NOT_SUPPORTED) \ + X(INVALID_PARAMS) \ + X(DISCONNECTED) \ + X(NOT_POWERED) \ + X(CANCELLED) \ + X(INVALID_INDEX) \ + X(RFKILLED) \ + X(ALREADY_PAIRED) \ + X(PERMISSION_DENIED) \ X(INTERNAL_TIMEOUT) \ X(INTERNAL_FAILURE) \ X(UNKNOWN) diff --git a/src/direct_bt/MgmtTypes.cpp b/src/direct_bt/MgmtTypes.cpp index 468a9fbc..c947f086 100644 --- a/src/direct_bt/MgmtTypes.cpp +++ b/src/direct_bt/MgmtTypes.cpp @@ -463,3 +463,31 @@ HCIStatusCode MgmtEvtDeviceDisconnected::getHCIReason(DisconnectReason mgmtReaso return HCIStatusCode::UNKNOWN; } } + +HCIStatusCode direct_bt::getHCIStatusCode(const MgmtStatus mstatus) noexcept { + switch(mstatus) { + case MgmtStatus::SUCCESS: return HCIStatusCode::SUCCESS; + case MgmtStatus::UNKNOWN_COMMAND: return HCIStatusCode::UNKNOWN_HCI_COMMAND; + case MgmtStatus::NOT_CONNECTED: return HCIStatusCode::UNKNOWN_CONNECTION_IDENTIFIER; + case MgmtStatus::FAILED: return HCIStatusCode::FAILED; + case MgmtStatus::CONNECT_FAILED: return HCIStatusCode::CONNECT_FAILED; + case MgmtStatus::AUTH_FAILED: return HCIStatusCode::AUTH_FAILED; + case MgmtStatus::NOT_PAIRED: return HCIStatusCode::NOT_PAIRED; + case MgmtStatus::NO_RESOURCES: return HCIStatusCode::NO_RESOURCES; + case MgmtStatus::TIMEOUT: return HCIStatusCode::TIMEOUT; + case MgmtStatus::ALREADY_CONNECTED: return HCIStatusCode::ALREADY_CONNECTED; + case MgmtStatus::BUSY: return HCIStatusCode::BUSY; + case MgmtStatus::REJECTED: return HCIStatusCode::REJECTED; + case MgmtStatus::NOT_SUPPORTED: return HCIStatusCode::NOT_SUPPORTED; + case MgmtStatus::INVALID_PARAMS: return HCIStatusCode::INVALID_PARAMS; + case MgmtStatus::DISCONNECTED: return HCIStatusCode::DISCONNECTED; + case MgmtStatus::NOT_POWERED: return HCIStatusCode::NOT_POWERED; + case MgmtStatus::CANCELLED: return HCIStatusCode::CANCELLED; + case MgmtStatus::INVALID_INDEX: return HCIStatusCode::INVALID_INDEX; + case MgmtStatus::RFKILLED: return HCIStatusCode::RFKILLED; + case MgmtStatus::ALREADY_PAIRED: return HCIStatusCode::ALREADY_PAIRED; + case MgmtStatus::PERMISSION_DENIED: return HCIStatusCode::PERMISSION_DENIED; + default: + return HCIStatusCode::UNKNOWN; + } +} |