From d720fa36ad4768ed1b948a92ba5287c30093fbec Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 26 Jul 2015 18:33:15 +0200 Subject: 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. --- include/ble/Bluetooth.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'include/ble/Bluetooth.h') 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 #include #include +#include #include "ByteBuffer.h" @@ -115,7 +116,7 @@ public: virtual void addCharacteristic(BluetoothGattCharacteristic *characteristic) = 0; - virtual const boost::optional findCharacteristic(boost::uuids::uuid uuid) const = 0; + virtual const boost::optional findCharacteristic(boost::uuids::uuid uuid) const = 0; }; class BluetoothGatt { @@ -165,9 +166,9 @@ public: virtual void stopScan() = 0; - virtual void runScan(std::function) = 0; + virtual void runScan(std::function &device)>) = 0; - virtual BluetoothDevice &getDevice(Mac &mac) = 0; + virtual shared_ptr getDevice(Mac &mac) = 0; protected: BluetoothAdapter(); @@ -185,6 +186,11 @@ public: BluetoothSystem(); ~BluetoothSystem(); + + shared_ptr getAdapter(string name); + +private: + map> 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 parse(ByteBuffer &bytes, AttPduType type); @@ -247,10 +253,6 @@ private: AttributeData(uint16_t handle, ByteBuffer value); }; -shared_ptr getAdapter(int hciDevice); - -void shutdown(); - boost::uuids::uuid makeUuid(const boost::uuids::uuid base, uint8_t a, uint8_t b); } -- cgit v1.2.3