aboutsummaryrefslogtreecommitdiff
path: root/apps/SoilMoisture.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-02-22 16:16:48 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-02-22 16:16:48 +0100
commitd0fb1850606ce003887259675e271a9aade4fda0 (patch)
tree0bf3be59348c0fd64f17c9e9a727e85ffc7bd98b /apps/SoilMoisture.h
parentba6324930118a62e05d3869f99543c4a7507f105 (diff)
downloadble-toys-d0fb1850606ce003887259675e271a9aade4fda0.tar.gz
ble-toys-d0fb1850606ce003887259675e271a9aade4fda0.tar.bz2
ble-toys-d0fb1850606ce003887259675e271a9aade4fda0.tar.xz
ble-toys-d0fb1850606ce003887259675e271a9aade4fda0.zip
o Starting a new class for all SoilMoisture GATT stuff.
Diffstat (limited to 'apps/SoilMoisture.h')
-rw-r--r--apps/SoilMoisture.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/SoilMoisture.h b/apps/SoilMoisture.h
new file mode 100644
index 0000000..ea64032
--- /dev/null
+++ b/apps/SoilMoisture.h
@@ -0,0 +1,47 @@
+#ifndef SOIL_MOISTURE_H
+#define SOIL_MOISTURE_H
+
+#include <ble/Bluetooth.h>
+#include <boost/uuid/uuid.hpp>
+
+namespace trygvis {
+namespace soil_moisture {
+
+using namespace trygvis::bluetooth;
+
+enum class sm_cmd_code : uint8_t {
+ SM_CMD_GET_SENSOR_COUNT = 1,
+ SM_CMD_GET_VALUE = 2,
+ SM_CMD_SET_WARNING_VALUE = 3,
+ SM_CMD_GET_WARNING_VALUE = 4,
+ SM_CMD_SET_SENSOR_NAME = 5,
+ SM_CMD_GET_SENSOR_NAME = 6,
+ SM_CMD_SET_UPDATE_INTERVAL = 7,
+ SM_CMD_FAIL = 255,
+};
+
+extern const boost::uuids::uuid soil_moisture_service;
+extern const boost::uuids::uuid soil_moisture_characteristic;
+
+class SoilMoisture {
+public:
+ static SoilMoisture create(BluetoothGatt &gatt);
+
+ uint8_t getSensorCount();
+
+ uint16_t getValue(uint8_t sensor);
+
+private:
+ SoilMoisture(BluetoothGatt &gatt, BluetoothGattService &s, BluetoothGattCharacteristic &c);
+
+ ByteBuffer writeAndRead(ByteBuffer &requestBytes);
+
+ BluetoothGatt &gatt;
+ BluetoothGattService &s;
+ BluetoothGattCharacteristic &c;
+};
+
+}
+}
+
+#endif