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. --- BluetoothImpl.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'BluetoothImpl.h') diff --git a/BluetoothImpl.h b/BluetoothImpl.h index ba44853..3d3ce29 100644 --- a/BluetoothImpl.h +++ b/BluetoothImpl.h @@ -1,9 +1,86 @@ #ifndef BLUETOOTH_IMPL_H #define BLUETOOTH_IMPL_H +#include "Bluetooth.h" +#include + +#define BLUETOOTH_UUID_INITIALIZER \ + { \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, \ + 0x10, 0x00, \ + 0x80, 0x00, \ + 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb \ + }; + namespace trygvis { namespace bluetooth { +typedef boost::uuids::uuid uuid_t; + +class DefaultBluetoothGattCharacteristic : public BluetoothGattCharacteristic { +public: + DefaultBluetoothGattCharacteristic(BluetoothGattService& service, uuid_t uuid) : service(service), uuid(uuid) { + } + + virtual ~DefaultBluetoothGattCharacteristic() { + } + + const uuid_t getUuid() const { + return uuid; + }; + + BluetoothGattService& getService() const { + return service; + }; + +protected: + BluetoothGattService& service; + uuid_t uuid; +}; + +class DefaultBluetoothGattService : public BluetoothGattService { +public: + DefaultBluetoothGattService(BluetoothDevice& device, const uuid_t uuid) : + device(device), uuid(uuid) { + } + + virtual ~DefaultBluetoothGattService() { + } + + BluetoothDevice& getDevice() const { + return device; + } + + uuid_t getUuid() const { + return uuid; + } + + vector::const_iterator getCharacteristics() const { + return characteristics.begin(); + } + +protected: + BluetoothDevice &device; + const uuid_t uuid; + const vector characteristics; +}; + +class DefaultBluetoothDevice : public BluetoothDevice { +public: + virtual vector::const_iterator getServices() const { + return services.begin(); + }; + +protected: + virtual ~DefaultBluetoothDevice() { + for (auto s: services) { + delete s; + } + } + vector services; +}; + BluetoothAdapter &getAdapterImpl(int hciDevice); void shutdownImpl(); -- cgit v1.2.3