diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-10 21:29:19 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-10 21:29:19 +0100 |
commit | b55df0b8e46f46fea4d69f98a729cd237d77a6ed (patch) | |
tree | 25e12c22d844bb449dd08d7661d20d42ca8ab0f5 /Bluetooth.h | |
parent | 1c97f6df59c825b26ecb18975fd9f62e14fc46ce (diff) | |
download | ble-toys-b55df0b8e46f46fea4d69f98a729cd237d77a6ed.tar.gz ble-toys-b55df0b8e46f46fea4d69f98a729cd237d77a6ed.tar.bz2 ble-toys-b55df0b8e46f46fea4d69f98a729cd237d77a6ed.tar.xz ble-toys-b55df0b8e46f46fea4d69f98a729cd237d77a6ed.zip |
o wip.
Diffstat (limited to 'Bluetooth.h')
-rw-r--r-- | Bluetooth.h | 38 |
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 |