diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-07-26 18:33:15 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-07-26 18:41:40 +0200 |
commit | d720fa36ad4768ed1b948a92ba5287c30093fbec (patch) | |
tree | 3d566e0d4ab47981af85a783f81ebbd363d57f15 /include/ble/Bluetooth.h | |
parent | 33c537c84fea53c899fb5275256518598f66101e (diff) | |
download | ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.tar.gz ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.tar.bz2 ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.tar.xz ble-toys-d720fa36ad4768ed1b948a92ba5287c30093fbec.zip |
o Overhaul of the bluetooth code.
- Adding support for reading FLOAT (specified in IEEE 11073-20601) values from a bluetooth device.
- More shared pointers to help keep track of the object's lifecycle. Makes sure that the connections are released back to Linux, Linux is way to sensitive with crashing applications.
o Adding support for reading the temperature sensors from the SoilMoisture device.
Diffstat (limited to 'include/ble/Bluetooth.h')
-rw-r--r-- | include/ble/Bluetooth.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/include/ble/Bluetooth.h b/include/ble/Bluetooth.h index d238377..8da602f 100644 --- a/include/ble/Bluetooth.h +++ b/include/ble/Bluetooth.h @@ -7,6 +7,7 @@ #include <stdexcept> #include <vector> #include <cstdint> +#include <map> #include "ByteBuffer.h" @@ -115,7 +116,7 @@ public: virtual void addCharacteristic(BluetoothGattCharacteristic *characteristic) = 0; - virtual const boost::optional<BluetoothGattCharacteristic &> findCharacteristic(boost::uuids::uuid uuid) const = 0; + virtual const boost::optional<const BluetoothGattCharacteristic &> findCharacteristic(boost::uuids::uuid uuid) const = 0; }; class BluetoothGatt { @@ -165,9 +166,9 @@ public: virtual void stopScan() = 0; - virtual void runScan(std::function<void(BluetoothDevice &device)>) = 0; + virtual void runScan(std::function<void(const shared_ptr<BluetoothDevice> &device)>) = 0; - virtual BluetoothDevice &getDevice(Mac &mac) = 0; + virtual shared_ptr <BluetoothDevice> getDevice(Mac &mac) = 0; protected: BluetoothAdapter(); @@ -185,6 +186,11 @@ public: BluetoothSystem(); ~BluetoothSystem(); + + shared_ptr<BluetoothAdapter> getAdapter(string name); + +private: + map<string, shared_ptr<BluetoothAdapter>> adapters; }; enum AttPduType { @@ -227,7 +233,7 @@ public: static void makeWrite(ByteBuffer &req, uint16_t handle, const ByteBuffer &bytes); private: - static void checkType(ByteBuffer &bytes, AttPduType type); +// static void checkType(ByteBuffer &bytes, AttPduType type); static vector<AttributeData> parse(ByteBuffer &bytes, AttPduType type); @@ -247,10 +253,6 @@ private: AttributeData(uint16_t handle, ByteBuffer value); }; -shared_ptr<BluetoothAdapter> getAdapter(int hciDevice); - -void shutdown(); - boost::uuids::uuid makeUuid(const boost::uuids::uuid base, uint8_t a, uint8_t b); } |