diff options
Diffstat (limited to 'apps/SoilMoisture.h')
-rw-r--r-- | apps/SoilMoisture.h | 47 |
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 |