diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-04-12 20:06:47 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-04-12 20:06:47 +0200 |
commit | 2ca532122d60cff4dbdc7f24fbc5783bcc5ad68d (patch) | |
tree | 19f9ce796886e216a608fa5e938bd2bd4f0d0b55 /apps/SoilMoisture.h | |
parent | ce07550c57172443c10a66957b50085e273d20b3 (diff) | |
download | ble-toys-2ca532122d60cff4dbdc7f24fbc5783bcc5ad68d.tar.gz ble-toys-2ca532122d60cff4dbdc7f24fbc5783bcc5ad68d.tar.bz2 ble-toys-2ca532122d60cff4dbdc7f24fbc5783bcc5ad68d.tar.xz ble-toys-2ca532122d60cff4dbdc7f24fbc5783bcc5ad68d.zip |
Soil Moisture: Adding support for controlling lights.
Bluetooth: refectorying, trying to be more c++ idiomatic and modern.
SM/Diller: adding bluetooth to Diller bridge.
Diffstat (limited to 'apps/SoilMoisture.h')
-rw-r--r-- | apps/SoilMoisture.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/apps/SoilMoisture.h b/apps/SoilMoisture.h index 99b698d..0ad1d15 100644 --- a/apps/SoilMoisture.h +++ b/apps/SoilMoisture.h @@ -2,13 +2,14 @@ #include <ble/Bluetooth.h> #include <boost/uuid/uuid.hpp> +#include <experimental/optional> namespace trygvis { namespace sensor { using namespace trygvis::bluetooth; -template <typename T> -using o = boost::optional<T>; +template<typename T> +using o = std::experimental::optional<T>; enum class sm_cmd_code : uint8_t { SM_CMD_GET_SENSOR_COUNT = 1, @@ -18,6 +19,8 @@ enum class sm_cmd_code : uint8_t { SM_CMD_SET_SENSOR_NAME = 5, SM_CMD_GET_SENSOR_NAME = 6, SM_CMD_SET_UPDATE_INTERVAL = 7, + // 8 is used + SM_CMD_SET_LIGHT = 9, SM_CMD_FAIL = 255, }; @@ -38,17 +41,22 @@ public: o<double> readTemperature(); + void setLight(uint8_t light, uint8_t value); + private: - SoilMoisture(const shared_ptr<BluetoothGatt> &gatt, BluetoothGattService &s, - const BluetoothGattCharacteristic &soilMoistureCharacteristic, - const o<const BluetoothGattCharacteristic &> temperatureCharacteristic); + SoilMoisture(const shared_ptr<BluetoothGatt> &gatt, + const shared_ptr<BluetoothGattService> &s, + const shared_ptr<BluetoothGattCharacteristic> &soilMoistureCharacteristic, + const o<BluetoothGattCharacteristicPtr> temperatureCharacteristic, + const o<BluetoothGattCharacteristicPtr> lightCharacteristic); - ByteBuffer writeAndRead(const BluetoothGattCharacteristic &c, ByteBuffer &requestBytes); + ByteBuffer writeAndRead(const BluetoothGattCharacteristicPtr &c, ByteBuffer &requestBytes); shared_ptr<BluetoothGatt> gatt; - BluetoothGattService &s; - const BluetoothGattCharacteristic &soilMoistureCharacteristic; - const o<const BluetoothGattCharacteristic &> temperatureCharacteristic; + shared_ptr<BluetoothGattService> s; + const BluetoothGattCharacteristicPtr soilMoistureCharacteristic; + const o<BluetoothGattCharacteristicPtr> temperatureCharacteristic; + const o<BluetoothGattCharacteristicPtr> lightCharacteristic; }; } } |