aboutsummaryrefslogtreecommitdiff
path: root/apps/SoilMoisture.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/SoilMoisture.h')
-rw-r--r--apps/SoilMoisture.h26
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;
};
}
}