From 2ca532122d60cff4dbdc7f24fbc5783bcc5ad68d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 12 Apr 2016 20:06:47 +0200 Subject: Soil Moisture: Adding support for controlling lights. Bluetooth: refectorying, trying to be more c++ idiomatic and modern. SM/Diller: adding bluetooth to Diller bridge. --- apps/SoilMoisture.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'apps/SoilMoisture.h') 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 #include +#include namespace trygvis { namespace sensor { using namespace trygvis::bluetooth; -template -using o = boost::optional; +template +using o = std::experimental::optional; 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 readTemperature(); + void setLight(uint8_t light, uint8_t value); + private: - SoilMoisture(const shared_ptr &gatt, BluetoothGattService &s, - const BluetoothGattCharacteristic &soilMoistureCharacteristic, - const o temperatureCharacteristic); + SoilMoisture(const shared_ptr &gatt, + const shared_ptr &s, + const shared_ptr &soilMoistureCharacteristic, + const o temperatureCharacteristic, + const o lightCharacteristic); - ByteBuffer writeAndRead(const BluetoothGattCharacteristic &c, ByteBuffer &requestBytes); + ByteBuffer writeAndRead(const BluetoothGattCharacteristicPtr &c, ByteBuffer &requestBytes); shared_ptr gatt; - BluetoothGattService &s; - const BluetoothGattCharacteristic &soilMoistureCharacteristic; - const o temperatureCharacteristic; + shared_ptr s; + const BluetoothGattCharacteristicPtr soilMoistureCharacteristic; + const o temperatureCharacteristic; + const o lightCharacteristic; }; } } -- cgit v1.2.3