diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-18 23:03:57 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-18 23:11:43 +0100 |
commit | 4d2339c65548cf553891b049200e6a845de293e9 (patch) | |
tree | 296acd302b61ca1e4ff673d102283485a3b4c9fe /Bluetooth.h | |
parent | 67478ec6b3f09c14195b8aea1099afb9bcaf9532 (diff) | |
download | ble-toys-4d2339c65548cf553891b049200e6a845de293e9.tar.gz ble-toys-4d2339c65548cf553891b049200e6a845de293e9.tar.bz2 ble-toys-4d2339c65548cf553891b049200e6a845de293e9.tar.xz ble-toys-4d2339c65548cf553891b049200e6a845de293e9.zip |
o Successfully decoding GATT services.
Diffstat (limited to 'Bluetooth.h')
-rw-r--r-- | Bluetooth.h | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/Bluetooth.h b/Bluetooth.h index 1b5d5f0..157ae0b 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -3,20 +3,23 @@ #include <string> #include <stdexcept> - -// For now -#include "log.h" +#include <boost/uuid/uuid.hpp> #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<BluetoothGattCharacteristic *>::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<BluetoothGattService *>::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); |