From 4d2339c65548cf553891b049200e6a845de293e9 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 18 Feb 2015 23:03:57 +0100 Subject: o Successfully decoding GATT services. --- Bluetooth.h | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'Bluetooth.h') diff --git a/Bluetooth.h b/Bluetooth.h index 1b5d5f0..157ae0b 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -3,20 +3,23 @@ #include #include - -// For now -#include "log.h" +#include #include "ByteBuffer.h" namespace trygvis { namespace bluetooth { using namespace std; +//using namespace boost; class BluetoothAdapter; class BluetoothDevice; +class BluetoothGattService; + +class BluetoothGattCharacteristic; + class BluetoothException : public runtime_error { public: BluetoothException(const BluetoothAdapter *adapter, string const &what) : @@ -62,8 +65,28 @@ private: uint8_t bytes[6]; }; +class BluetoothGattCharacteristic { +public: + virtual BluetoothGattService &getService() const = 0; + + virtual const boost::uuids::uuid getUuid() const = 0; +}; + +class BluetoothGattService { +public: + virtual BluetoothDevice &getDevice() const = 0; + + virtual boost::uuids::uuid getUuid() const = 0; + + virtual vector::const_iterator getCharacteristics() const = 0; +}; + class BluetoothDevice { public: + BluetoothDevice(); + + virtual ~BluetoothDevice(); + virtual Mac const &mac() = 0; virtual BluetoothAdapter &adapter() = 0; @@ -73,10 +96,14 @@ public: virtual void disconnect() = 0; virtual void discoverServices() = 0; + + virtual vector::const_iterator getServices() const = 0; }; class BluetoothAdapter { public: + virtual void startScan() = 0; + virtual void stopScan() = 0; virtual void runScan(void (callback)(BluetoothDevice &device)) = 0; @@ -91,8 +118,10 @@ protected: enum AttPduType { ERROR = 0x00, + READ_BY_TYPE_REQ = 0x08, + READ_BY_TYPE_RES = 0x09, READ_BY_GROUP_TYPE_REQ = 0x10, - READ_BY_GROUP_TYPE_RES = 0x11 + READ_BY_GROUP_TYPE_RES = 0x11, }; class AttributeData; @@ -109,6 +138,8 @@ public: static void makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid); + static void makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid); + private: static void checkType(ByteBuffer &bytes, AttPduType type); -- cgit v1.2.3