aboutsummaryrefslogtreecommitdiffstats
path: root/api/direct_bt/BTAddress.hpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-04-25 20:37:17 +0200
committerSven Gothel <[email protected]>2020-04-25 20:37:17 +0200
commit3460be939b76ef3a1895e27afe2dcfa53ff21b3f (patch)
tree5d7e48c78788413eebf781bf65564c354a5af0f6 /api/direct_bt/BTAddress.hpp
parentcd0fbb59946a0d9ca0fd0bf1fc27228bc3d90f91 (diff)
Use Kernel BlueZ Manager for Discovery, Connect, etc. (Initial Commit - Java part probably broken)
We have experienced the following using the official HCI communication channel: - Lower connect performance with discovery enabled - Instability with enabled discovery and breaking general BT adapter state requiring a 'hciconfig hci0 reset' - Lack of notifications: start/stop discovery/connect/... - Lack of certain settings in general: pin, .. This commit implements discovery including listening to all BlueZ kernel events from the BlueZ Manager channel using DBTManager. TODO: Figure out how to enforce quick connect! - EInfoReport (EIR) added: FLAGS, DEVICE_CLASS, APPEARANCE, HASH, RANDOMIZER and DEVICE_ID - including parsing new segments in read_data(..) and dataSetToString(..) exposure - DBTManager adds: - manager-reader thread, putting all command status/completes to its ringbuffer and sending out all other events to its listener. - Respecting the chosen BTMode (side-effect to discovery etc) - add: start/stop discovery - add: connect/disconnect (incomplete) - DBTAdapter: - discoverDevices -> discoverDevicesMgmt is becoming redundant, now simply waiting for the DeviceFound event. Will be deleted - TODO! - mgmtEvDeviceFoundCB shall perform remaining EIR parsing and enqueing the devices plus issuing respective discovery callbacks! TODO. - DBTDevice adds: - BDAddressType - HCISession's HCIComm is now no more used (to be deleted!) - HCIComm adds generic read/write methods, mutex free. - Remaining HCI 'managment' methods are also subject to deletion! - GATTHandler / DBTManager: only use a mtx_write for communication, as reading is performed on their respective threads using a ringbuffer. Here only concurrent write access needs to be managed. (DBTManager uses its own HCIComm's mutex.) - MgmtTypes adds: - BTMode for dual, BREDR or LE only. - MgmtRequest -> MgmtCommand - Unifies the command opcodes to global 'MgmtOpcode', removing duplicate MgmtCommand::Opcode (which was also incomplete) - Adding MgmtDisconnectCmd, MgmtEvtDiscovering, MgmtEvtDeviceFound MgmtEvtDeviceConnected, MgmtEvtDeviceDisconnected - TOctets adding get_int8(..) and get_eui48(..) - TOctets adding put_eui48(..) ++++++++++++++ New ClassFunction: Introducing versatile C++ function-method type used for our DBTManager callbacks. In contrast to std::function and std::bind, ClassFunction allows using its specific type (return- and argument types) and offering the equality operation to test its identity. The latter is essential to remove a callback ClassFunction from a list of callbacks. +++++++++++++++++ Further code cleanup is also included - Address_T -> BDAddressType(incl string presentation) + HCIAddressType - ManufactureSpecificData using POctets - Convenient default param: uint*HexString(.., const bool leading0X=true); - MgmtTypes's get/put for events and commands use MGMT_HEADER_SIZE offset - MgmtTypes: Remove doubled 'btohs', as the pdu.get* commands already perform endian conversion. - EInfoReport::read_data(..) validate segment size before type conversion
Diffstat (limited to 'api/direct_bt/BTAddress.hpp')
-rw-r--r--api/direct_bt/BTAddress.hpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/api/direct_bt/BTAddress.hpp b/api/direct_bt/BTAddress.hpp
index 4fd6807d..01bc4fa1 100644
--- a/api/direct_bt/BTAddress.hpp
+++ b/api/direct_bt/BTAddress.hpp
@@ -93,17 +93,23 @@ namespace direct_bt {
*
* +++
*
- * Couldn't yet find a reference to the L2CAP Address Type, which differs from HCI Address Type!
+ * Couldn't yet find a reference to the BDADDR/L2CAP Address Type, which differs from HCI Address Type!
*/
- enum Address_T : uint8_t {
+ enum BDAddressType : uint8_t {
+ BDADDR_BREDR = 0x00,
+ BDADDR_LE_PUBLIC = 0x01,
+ BDADDR_LE_RANDOM = 0x02,
+ BDADDR_UNDEFINED = 0xff
+ };
+
+ enum HCIAddressType : uint8_t {
HCIADDR_LE_PUBLIC = 0x00,
HCIADDR_LE_RANDOM = 0x01,
-
- L2CAPADDR_BREDR = 0x00,
- L2CAPADDR_LE_PUBLIC = 0x01,
- L2CAPADDR_LE_RANDOM = 0x02
+ HCIADDR_UNDEFINED = 0xff
};
+ std::string getBDAddressTypeString(const BDAddressType op);
+
} // namespace direct_bt
#endif /* BT_ADDRESS_HPP_ */