diff options
author | Sven Gothel <[email protected]> | 2020-06-04 04:24:24 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-04 04:24:24 +0200 |
commit | e6d1ec031165eb10471426a71f1640ebb8e1159f (patch) | |
tree | 9d82164355a623d078f881dca5a09c850c788abd /api | |
parent | 73f5b4fc21d7a14aa174f2c48657ca3f2229dda1 (diff) |
Rename HCIErrorCode -> HCIStatusCode for clarity and pleasing the eyes
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/DBTAdapter.hpp | 8 | ||||
-rw-r--r-- | api/direct_bt/DBTDevice.hpp | 4 | ||||
-rw-r--r-- | api/direct_bt/DBTManager.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/HCIHandler.hpp | 14 | ||||
-rw-r--r-- | api/direct_bt/HCITypes.hpp | 34 | ||||
-rw-r--r-- | api/direct_bt/MgmtTypes.hpp | 28 |
6 files changed, 45 insertions, 45 deletions
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/DBTAdapter.hpp index a7dc43b3..3dc1f003 100644 --- a/api/direct_bt/DBTAdapter.hpp +++ b/api/direct_bt/DBTAdapter.hpp @@ -120,10 +120,10 @@ namespace direct_bt { /** * DBTDevice got disconnected * @param device the device which connection state has changed - * @param reason the HCIErrorCode reason for disconnection + * @param reason the HCIStatusCode reason for disconnection * @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds(). */ - virtual void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIErrorCode reason, const uint64_t timestamp) = 0; + virtual void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIStatusCode reason, const uint64_t timestamp) = 0; virtual ~AdapterStatusListener() {} @@ -174,7 +174,7 @@ namespace direct_bt { friend std::shared_ptr<DBTDevice> DBTDevice::getSharedInstance() const; friend void DBTDevice::releaseSharedInstance() const; friend std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo(); - friend void DBTDevice::disconnect(const bool sentFromManager, const bool ioErrorCause,const HCIErrorCode reason); + friend void DBTDevice::disconnect(const bool sentFromManager, const bool ioErrorCause,const HCIStatusCode reason); friend uint16_t DBTDevice::connectLE(HCIAddressType peer_mac_type, HCIAddressType own_mac_type, uint16_t interval, uint16_t window, uint16_t min_interval, uint16_t max_interval, @@ -184,7 +184,7 @@ namespace direct_bt { bool addConnectedDevice(const std::shared_ptr<DBTDevice> & device); bool removeConnectedDevice(const DBTDevice & device); - int disconnectAllDevices(const HCIErrorCode reason=HCIErrorCode::REMOTE_USER_TERMINATED_CONNECTION ); + int disconnectAllDevices(const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ); std::shared_ptr<DBTDevice> findConnectedDevice (EUI48 const & mac) const; bool addDiscoveredDevice(std::shared_ptr<DBTDevice> const &device); diff --git a/api/direct_bt/DBTDevice.hpp b/api/direct_bt/DBTDevice.hpp index 91866987..1ece6f83 100644 --- a/api/direct_bt/DBTDevice.hpp +++ b/api/direct_bt/DBTDevice.hpp @@ -87,7 +87,7 @@ namespace direct_bt { void notifyConnected(); void disconnect(const bool sentFromManager, const bool ioErrorCause, - const HCIErrorCode reason=HCIErrorCode::REMOTE_USER_TERMINATED_CONNECTION ); + const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ); public: const uint64_t ts_creation; @@ -237,7 +237,7 @@ namespace direct_bt { * An open GATTHandler will also be closed via disconnectGATT() * </p> */ - void disconnect(const HCIErrorCode reason=HCIErrorCode::REMOTE_USER_TERMINATED_CONNECTION ) { + void disconnect(const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ) { disconnect(false /* sentFromManager */, false /* ioErrorCause */, reason); } diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp index c2e1e7a4..3578c350 100644 --- a/api/direct_bt/DBTManager.hpp +++ b/api/direct_bt/DBTManager.hpp @@ -255,7 +255,7 @@ namespace direct_bt { bool disconnect(const bool ioErrorCause, const int dev_id, const EUI48 &peer_bdaddr, const BDAddressType peer_mac_type, - const HCIErrorCode reason=HCIErrorCode::REMOTE_USER_TERMINATED_CONNECTION ); + const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ); std::shared_ptr<ConnectionInfo> getConnectionInfo(const int dev_id, const EUI48 &address, const BDAddressType address_type); std::shared_ptr<NameAndShortName> setLocalName(const int dev_id, const std::string & name, const std::string & short_name); diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp index e5e87371..afc250a8 100644 --- a/api/direct_bt/HCIHandler.hpp +++ b/api/direct_bt/HCIHandler.hpp @@ -104,17 +104,17 @@ namespace direct_bt { std::shared_ptr<HCIEvent> sendWithCmdStatusReply(HCICommand &req, HCICommandStatusEvent **res); template<typename hci_cmd_event_struct> - std::shared_ptr<HCIEvent> processCmdCompleteCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIErrorCode *status); + std::shared_ptr<HCIEvent> processCmdCompleteCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIStatusCode *status); template<typename hci_command_struct, typename hci_cmd_event_struct> std::shared_ptr<HCIEvent> processStructCommand(HCIOpcode opc, hci_command_struct &cp, HCIEventType evc, const hci_cmd_event_struct **res, - HCIErrorCode *status); + HCIStatusCode *status); template<typename hci_command_struct, typename hci_cmd_event_struct> std::shared_ptr<HCIEvent> processStructCommand(HCIOpcode opc, hci_command_struct &cp, HCIMetaEventType mec, const hci_cmd_event_struct **res, - HCIErrorCode *status); + HCIStatusCode *status); HCIHandler(const HCIHandler&) = delete; void operator=(const HCIHandler&) = delete; @@ -141,7 +141,7 @@ namespace direct_bt { /** * BT Core Spec v5.2: Vol 4, Part E HCI: 7.3.2 Reset command */ - HCIErrorCode reset(); + HCIStatusCode reset(); /** * Establish a connection to the given LE peer. @@ -168,7 +168,7 @@ namespace direct_bt { * @param supervision_timeout in units of 10ms, default value 1000 for 10000ms or 10s. * @return */ - HCIErrorCode le_create_conn(uint16_t * handle_return, const EUI48 &peer_bdaddr, + HCIStatusCode le_create_conn(uint16_t * handle_return, const EUI48 &peer_bdaddr, const HCIAddressType peer_mac_type=HCIAddressType::HCIADDR_LE_PUBLIC, const HCIAddressType own_mac_type=HCIAddressType::HCIADDR_LE_PUBLIC, const uint16_t le_scan_interval=48, const uint16_t le_scan_window=48, @@ -181,7 +181,7 @@ namespace direct_bt { * BT Core Spec v5.2: Vol 4, Part E HCI: 7.1.5 Create Connection command * </p> */ - HCIErrorCode create_conn(uint16_t * handle_return, const EUI48 &bdaddr, + HCIStatusCode create_conn(uint16_t * handle_return, const EUI48 &bdaddr, const uint16_t pkt_type=HCI_DM1 | HCI_DM3 | HCI_DM5 | HCI_DH1 | HCI_DH3 | HCI_DH5, const uint16_t clock_offset=0x0000, const uint8_t role_switch=0x01); @@ -191,7 +191,7 @@ namespace direct_bt { * BT Core Spec v5.2: Vol 4, Part E HCI: 7.1.6 Disconnect command * </p> */ - HCIErrorCode disconnect(const uint16_t conn_handle, const HCIErrorCode reason=HCIErrorCode::REMOTE_USER_TERMINATED_CONNECTION); + HCIStatusCode disconnect(const uint16_t conn_handle, const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION); }; } // namespace direct_bt diff --git a/api/direct_bt/HCITypes.hpp b/api/direct_bt/HCITypes.hpp index e07783f2..6ccc9aa6 100644 --- a/api/direct_bt/HCITypes.hpp +++ b/api/direct_bt/HCITypes.hpp @@ -95,7 +95,7 @@ namespace direct_bt { * BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 2 Error code descriptions * </p> */ - enum class HCIErrorCode : uint8_t { + enum class HCIStatusCode : uint8_t { SUCCESS = 0x00, UNKNOWN_HCI_COMMAND = 0x01, UNKNOWN_CONNECTION_IDENTIFIER = 0x02, @@ -167,10 +167,10 @@ namespace direct_bt { INTERNAL_FAILURE = 0xfe, UNKNOWN = 0xff }; - inline uint8_t number(const HCIErrorCode rhs) { + inline uint8_t number(const HCIStatusCode rhs) { return static_cast<uint8_t>(rhs); } - std::string getHCIErrorCodeString(const HCIErrorCode ec); + std::string getHCIStatusCodeString(const HCIStatusCode ec); enum class HCIConstU8 : uint8_t { /** HCIPacketType::COMMAND header size including HCIPacketType */ @@ -474,7 +474,7 @@ namespace direct_bt { class HCIDisconnectCmd : public HCICommand { public: - HCIDisconnectCmd(const uint16_t handle, HCIErrorCode reason) + HCIDisconnectCmd(const uint16_t handle, HCIStatusCode reason) : HCICommand(HCIOpcode::DISCONNECT, 3) { pdu.put_uint16(number(HCIConstU8::COMMAND_HDR_SIZE),handle); @@ -597,7 +597,7 @@ namespace direct_bt { }; /** - * Generic HCIEvent wrapper for any HCI IOCTL 'command complete' alike event struct having a HCIErrorCode uint8_t status field. + * Generic HCIEvent wrapper for any HCI IOCTL 'command complete' alike event struct having a HCIStatusCode uint8_t status field. * @tparam hcistruct the template typename, e.g. 'hci_ev_conn_complete' for 'struct hci_ev_conn_complete' */ template<typename hcistruct> @@ -615,7 +615,7 @@ namespace direct_bt { pdu.is_range_valid(0, number(HCIConstU8::EVENT_HDR_SIZE)+sizeof(hcistruct)); } const hcistruct * getStruct() const { return (const hcistruct *)(getParam()); } - HCIErrorCode getStatus() const { return static_cast<HCIErrorCode>( getStruct()->status ); } + HCIStatusCode getStatus() const { return static_cast<HCIStatusCode>( getStruct()->status ); } }; @@ -633,9 +633,9 @@ namespace direct_bt { protected: std::string baseString() const override { return HCIEvent::baseString()+ - ", status "+uint8HexString(static_cast<uint8_t>(getStatus()), true)+" "+getHCIErrorCodeString(getStatus())+ + ", status "+uint8HexString(static_cast<uint8_t>(getStatus()), true)+" "+getHCIStatusCodeString(getStatus())+ ", handle "+std::to_string(getHandle())+ - ", reason "+uint8HexString(static_cast<uint8_t>(getReason()), true)+" "+getHCIErrorCodeString(getReason()); + ", reason "+uint8HexString(static_cast<uint8_t>(getReason()), true)+" "+getHCIStatusCodeString(getReason()); } public: @@ -646,9 +646,9 @@ namespace direct_bt { pdu.check_range(0, number(HCIConstU8::EVENT_HDR_SIZE)+4); } - HCIErrorCode getStatus() const { return static_cast<HCIErrorCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)) ); } + HCIStatusCode getStatus() const { return static_cast<HCIStatusCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)) ); } uint16_t getHandle() const { return pdu.get_uint16(number(HCIConstU8::EVENT_HDR_SIZE)+1); } - HCIErrorCode getReason() const { return static_cast<HCIErrorCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)+3) ); } + HCIStatusCode getReason() const { return static_cast<HCIStatusCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)+3) ); } bool validate(const HCICommand & cmd) const override { return cmd.getOpcode() == HCIOpcode::DISCONNECT; @@ -696,12 +696,12 @@ namespace direct_bt { uint8_t getReturnParamSize() const { return getParamSize() - 3; } const uint8_t* getReturnParam() const { return pdu.get_ptr(number(HCIConstU8::EVENT_HDR_SIZE)+3); } - HCIErrorCode getReturnStatus(const int returnParamOffset=0) const { + HCIStatusCode getReturnStatus(const int returnParamOffset=0) const { const uint8_t returnParamSize = getReturnParamSize(); if( returnParamSize < returnParamOffset + 1 /* status size */ ) { - return HCIErrorCode::UNKNOWN; + return HCIStatusCode::UNKNOWN; } - return static_cast<HCIErrorCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE) + 3 + returnParamOffset) ); + return static_cast<HCIStatusCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE) + 3 + returnParamOffset) ); } bool validate(const HCICommand & cmd) const override { @@ -725,7 +725,7 @@ namespace direct_bt { return HCIEvent::baseString()+", opcode="+uint16HexString(static_cast<uint16_t>(getOpcode()))+ " "+getHCIOpcodeString(getOpcode())+ ", ncmd "+std::to_string(getNumCommandPackets())+ - ", status "+uint8HexString(static_cast<uint8_t>(getStatus()), true)+" "+getHCIErrorCodeString(getStatus()); + ", status "+uint8HexString(static_cast<uint8_t>(getStatus()), true)+" "+getHCIStatusCodeString(getStatus()); } public: @@ -736,7 +736,7 @@ namespace direct_bt { pdu.check_range(0, number(HCIConstU8::EVENT_HDR_SIZE)+4); } - HCIErrorCode getStatus() const { return static_cast<HCIErrorCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)) ); } + HCIStatusCode getStatus() const { return static_cast<HCIStatusCode>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)) ); } /** * The Number of HCI Command packets which are allowed to be sent to the Controller from the Host. @@ -789,7 +789,7 @@ namespace direct_bt { }; /** - * Generic HCIMetaEvent wrapper for any HCI IOCTL 'command complete' alike meta event struct having a HCIErrorCode uint8_t status field. + * Generic HCIMetaEvent wrapper for any HCI IOCTL 'command complete' alike meta event struct having a HCIStatusCode uint8_t status field. * @tparam hcistruct the template typename, e.g. 'hci_ev_le_conn_complete' for 'struct hci_ev_le_conn_complete' */ template<typename hcistruct> @@ -807,7 +807,7 @@ namespace direct_bt { pdu.is_range_valid(0, number(HCIConstU8::EVENT_HDR_SIZE)+1+sizeof(hcistruct)); } const hcistruct * getStruct() const { return (const hcistruct *)( pdu.get_ptr(number(HCIConstU8::EVENT_HDR_SIZE)+1) ); } - HCIErrorCode getStatus() const { return static_cast<HCIErrorCode>( getStruct()->status ); } + HCIStatusCode getStatus() const { return static_cast<HCIStatusCode>( getStruct()->status ); } }; } // namespace direct_bt diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp index 9e0b0d43..e4ffb0ec 100644 --- a/api/direct_bt/MgmtTypes.hpp +++ b/api/direct_bt/MgmtTypes.hpp @@ -926,39 +926,39 @@ namespace direct_bt { static std::string getDisconnectReasonString(DisconnectReason mgmtReason); /** - * BlueZ Kernel Mgmt has reduced information by HCIErrorCode -> DisconnectReason, + * BlueZ Kernel Mgmt has reduced information by HCIStatusCode -> DisconnectReason, * now the inverse surely can't repair this loss. * <p> - * See getDisconnectReason(HCIErrorCode) below for the mentioned mapping. + * See getDisconnectReason(HCIStatusCode) below for the mentioned mapping. * </p> */ - static HCIErrorCode getHCIReason(DisconnectReason mgmtReason); + static HCIStatusCode getHCIReason(DisconnectReason mgmtReason); /** * BlueZ Kernel Mgmt mapping of HCI disconnect reason, which reduces some information. */ - static DisconnectReason getDisconnectReason(HCIErrorCode hciReason); + static DisconnectReason getDisconnectReason(HCIStatusCode hciReason); private: - const HCIErrorCode hciRootReason; + const HCIStatusCode hciRootReason; protected: std::string baseString() const override { const DisconnectReason reason1 = getReason(); - const HCIErrorCode reason2 = getHCIReason(); + const HCIStatusCode reason2 = getHCIReason(); return MgmtEvent::baseString()+", address="+getAddress().toString()+ ", addressType "+getBDAddressTypeString(getAddressType())+ ", reason[mgmt["+uint8HexString(static_cast<uint8_t>(reason1))+" ("+getDisconnectReasonString(reason1)+")]"+ - ", hci["+uint8HexString(static_cast<uint8_t>(reason2))+" ("+getHCIErrorCodeString(reason2)+")]]"; + ", hci["+uint8HexString(static_cast<uint8_t>(reason2))+" ("+getHCIStatusCodeString(reason2)+")]]"; } public: MgmtEvtDeviceDisconnected(const uint8_t* buffer, const int buffer_len) - : MgmtEvent(buffer, buffer_len), hciRootReason(HCIErrorCode::UNKNOWN) + : MgmtEvent(buffer, buffer_len), hciRootReason(HCIStatusCode::UNKNOWN) { checkOpcode(getOpcode(), Opcode::DEVICE_DISCONNECTED); } - MgmtEvtDeviceDisconnected(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, HCIErrorCode hciRootReason) + MgmtEvtDeviceDisconnected(const uint16_t dev_id, const EUI48 &address, const BDAddressType addressType, HCIStatusCode hciRootReason) : MgmtEvent(Opcode::DEVICE_DISCONNECTED, dev_id, 6+1+1), hciRootReason(hciRootReason) { DisconnectReason disconnectReason = getDisconnectReason(hciRootReason); @@ -972,12 +972,12 @@ namespace direct_bt { DisconnectReason getReason() const { return static_cast<DisconnectReason>(pdu.get_uint8(MGMT_HEADER_SIZE+7)); } - /** Return the root reason in non reduced HCIErrorCode space, if available. Otherwise this value will be HCIErrorCode::UNKNOWN. */ - HCIErrorCode getHCIRootReason() const { return hciRootReason; } + /** Return the root reason in non reduced HCIStatusCode space, if available. Otherwise this value will be HCIStatusCode::UNKNOWN. */ + HCIStatusCode getHCIRootReason() const { return hciRootReason; } - /** Returns either the getHCIRootReason() if not HCIErrorCode::UNKNOWN, or the translated DisconnectReason. */ - HCIErrorCode getHCIReason() const { - if( HCIErrorCode::UNKNOWN != hciRootReason ) { + /** Returns either the getHCIRootReason() if not HCIStatusCode::UNKNOWN, or the translated DisconnectReason. */ + HCIStatusCode getHCIReason() const { + if( HCIStatusCode::UNKNOWN != hciRootReason ) { return hciRootReason; } return getHCIReason(getReason()); |