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 /apps/SoilMoisture.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 'apps/SoilMoisture.h')
-rw-r--r-- | apps/SoilMoisture.h | 15 |
1 files changed, 12 insertions, 3 deletions
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 <typename T> +using o = boost::optional<T>; 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<double> readTemperature(); + private: - SoilMoisture(shared_ptr<BluetoothGatt> gatt, BluetoothGattService &s, BluetoothGattCharacteristic &c); + SoilMoisture(const shared_ptr<BluetoothGatt> &gatt, BluetoothGattService &s, + const BluetoothGattCharacteristic &soilMoistureCharacteristic, + const o<const BluetoothGattCharacteristic &> temperatureCharacteristic); - ByteBuffer writeAndRead(ByteBuffer &requestBytes); + ByteBuffer writeAndRead(const BluetoothGattCharacteristic &c, ByteBuffer &requestBytes); shared_ptr<BluetoothGatt> gatt; BluetoothGattService &s; - BluetoothGattCharacteristic &c; + const BluetoothGattCharacteristic &soilMoistureCharacteristic; + const o<const BluetoothGattCharacteristic &> temperatureCharacteristic; }; } } |