aboutsummaryrefslogtreecommitdiff
path: root/ble/Bluetooth.h
diff options
context:
space:
mode:
Diffstat (limited to 'ble/Bluetooth.h')
-rw-r--r--ble/Bluetooth.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/ble/Bluetooth.h b/ble/Bluetooth.h
index d6be783..6ed9c76 100644
--- a/ble/Bluetooth.h
+++ b/ble/Bluetooth.h
@@ -22,9 +22,9 @@ public:
};
namespace uuids {
-static const SpecUuid PRIMARY_SERVICE = SpecUuid(0x2800);
-static const SpecUuid SECONDARY_SERVICE = SpecUuid(0x2801);
-static const SpecUuid CHARACTERISTIC = SpecUuid(0x2803);
+const SpecUuid PRIMARY_SERVICE = SpecUuid(0x2800);
+const SpecUuid SECONDARY_SERVICE = SpecUuid(0x2801);
+const SpecUuid CHARACTERISTIC = SpecUuid(0x2803);
}
class BluetoothAdapter;
@@ -72,7 +72,7 @@ public:
void copy(uint8_t &_0, uint8_t &_1, uint8_t &_2, uint8_t &_3, uint8_t &_4, uint8_t &_5) const;
- static Mac parseMac(string s) throw(BluetoothException);
+ static Mac parseMac(string s);
friend bool operator<(const Mac &a, const Mac &b);
@@ -113,7 +113,7 @@ public:
virtual void addCharacteristic(BluetoothGattCharacteristic *characteristic) = 0;
- virtual const boost::optional<BluetoothGattCharacteristic *> findCharacteristic(boost::uuids::uuid uuid) const = 0;
+ virtual const boost::optional<BluetoothGattCharacteristic &> findCharacteristic(boost::uuids::uuid uuid) const = 0;
};
class BluetoothGatt {
@@ -128,11 +128,15 @@ public:
virtual void disconnect() = 0;
+ virtual void writeValue(const BluetoothGattCharacteristic &c, const ByteBuffer &bytes) = 0;
+
+ virtual ByteBuffer readValue(const BluetoothGattCharacteristic &c) = 0;
+
virtual void discoverServices() = 0;
virtual const vector<BluetoothGattService *> getServices() const = 0;
- virtual const boost::optional<BluetoothGattService *> findService(boost::uuids::uuid uuid) const = 0;
+ virtual const boost::optional<BluetoothGattService &> findService(boost::uuids::uuid uuid) const = 0;
};
class BluetoothDevice {
@@ -179,8 +183,12 @@ enum AttPduType {
INVALID_HANDLE = 0x01,
READ_BY_TYPE_REQ = 0x08,
READ_BY_TYPE_RES = 0x09,
+ READ_REQ = 0x0a,
+ READ_RES = 0x0b,
READ_BY_GROUP_TYPE_REQ = 0x10,
READ_BY_GROUP_TYPE_RES = 0x11,
+ WRITE_REQ = 0x12,
+ WRITE_RES = 0x13,
};
class AttributeData;
@@ -197,10 +205,18 @@ public:
static vector<AttributeData> parseReadByType(ByteBuffer &bytes);
+ static void parseRead(ByteBuffer &bytes);
+
+ static void parseWrite(ByteBuffer &bytes);
+
static void makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, SpecUuid uuid);
static void makeReadByType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, SpecUuid uuid);
+ static void makeRead(ByteBuffer &bytes, uint16_t handle);
+
+ static void makeWrite(ByteBuffer &req, uint16_t handle, const ByteBuffer &bytes);
+
private:
static void checkType(ByteBuffer &bytes, AttPduType type);