From d0fb1850606ce003887259675e271a9aade4fda0 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 22 Feb 2015 16:16:48 +0100 Subject: o Starting a new class for all SoilMoisture GATT stuff. --- apps/SoilMoisture.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 apps/SoilMoisture.h (limited to 'apps/SoilMoisture.h') 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 +#include + +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 -- cgit v1.2.3