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. --- apps/SoilMoisture.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'apps/SoilMoisture.h') diff --git a/apps/SoilMoisture.h b/apps/SoilMoisture.h index b5a8749..99b698d 100644 --- a/apps/SoilMoisture.h +++ b/apps/SoilMoisture.h @@ -7,6 +7,8 @@ namespace trygvis { namespace sensor { using namespace trygvis::bluetooth; +template +using o = boost::optional; enum class sm_cmd_code : uint8_t { SM_CMD_GET_SENSOR_COUNT = 1, @@ -32,14 +34,21 @@ public: string getName(uint8_t sensor); + bool hasTemperatureSensor(); + + o readTemperature(); + private: - SoilMoisture(shared_ptr gatt, BluetoothGattService &s, BluetoothGattCharacteristic &c); + SoilMoisture(const shared_ptr &gatt, BluetoothGattService &s, + const BluetoothGattCharacteristic &soilMoistureCharacteristic, + const o temperatureCharacteristic); - ByteBuffer writeAndRead(ByteBuffer &requestBytes); + ByteBuffer writeAndRead(const BluetoothGattCharacteristic &c, ByteBuffer &requestBytes); shared_ptr gatt; BluetoothGattService &s; - BluetoothGattCharacteristic &c; + const BluetoothGattCharacteristic &soilMoistureCharacteristic; + const o temperatureCharacteristic; }; } } -- cgit v1.2.3