aboutsummaryrefslogtreecommitdiff
path: root/Bluetooth.h
diff options
context:
space:
mode:
Diffstat (limited to 'Bluetooth.h')
-rw-r--r--Bluetooth.h39
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);