aboutsummaryrefslogtreecommitdiff
path: root/Bluetooth.h
diff options
context:
space:
mode:
Diffstat (limited to 'Bluetooth.h')
-rw-r--r--Bluetooth.h38
1 files changed, 23 insertions, 15 deletions
diff --git a/Bluetooth.h b/Bluetooth.h
index 9496983..586ac66 100644
--- a/Bluetooth.h
+++ b/Bluetooth.h
@@ -30,15 +30,15 @@ namespace trygvis {
class BluetoothException : public runtime_error {
public:
BluetoothException(const BluetoothAdapter *adapter, string const &what) :
- adapter(adapter), device(nullptr), runtime_error(what) {
+ runtime_error(what), adapter(adapter), device(nullptr) {
}
BluetoothException(const BluetoothDevice *device, string const &what) :
- adapter(nullptr), device(device), runtime_error(what) {
+ runtime_error(what), adapter(nullptr), device(device) {
}
BluetoothException(string const &what) :
- adapter(nullptr), device(nullptr), runtime_error(what) {
+ runtime_error(what), adapter(nullptr), device(nullptr) {
}
const BluetoothAdapter *adapter;
@@ -60,10 +60,13 @@ namespace trygvis {
bool operator==(Mac &other) const;
+ bool operator!=(Mac &other) const;
+
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);
+ static Mac *parseMac(string s) throw(BluetoothException);
+ friend bool operator<(const Mac &a, const Mac &b);
private:
uint8_t bytes[6];
};
@@ -91,6 +94,8 @@ namespace trygvis {
virtual void stopScan() = 0;
virtual void runScan(void (callback)(BluetoothDevice &device)) = 0;
+
+ virtual BluetoothDevice &getDevice(Mac& mac) = 0;
};
enum AttPduType {
@@ -99,6 +104,8 @@ namespace trygvis {
READ_BY_GROUP_TYPE_RES = 0x11
};
+ class AttributeData;
+
class AttPdu {
public:
AttPdu(ByteBuffer &bytes);
@@ -107,29 +114,30 @@ namespace trygvis {
AttPduType getType();
- static AttPdu parse(ByteBuffer & bytes);
- private:
- ByteBuffer &bytes;
- };
+ static vector<AttributeData*>* parseReadByGroupType(ByteBuffer &bytes);
- class AttributeDataList {
- public:
- AttributeDataList(ByteBuffer &bytes);
+ static void makeReadByGroupType(ByteBuffer &bytes, uint16_t startHandle, uint16_t endHandle, uint16_t uuid);
private:
+ static void checkType(ByteBuffer &bytes, AttPduType type);
+
ByteBuffer &bytes;
};
class AttributeData {
public:
- AttributeData(ByteBuffer &bytes);
+ static AttributeData* fromByteBuffer(ByteBuffer &bytes, uint8_t length);
private:
- ByteBuffer &bytes;
+ AttributeData(uint16_t handle, uint8_t* bytes);
+ ~AttributeData();
+
+ uint16_t handle;
+ uint8_t *bytes;
};
-// BluetoothAdapter &getDevice(int hciDevice);
- BluetoothAdapter *getDevice(int hciDevice);
+// BluetoothAdapter &getAdapter(int hciDevice);
+ BluetoothAdapter *getAdapter(int hciDevice);
}
#endif