diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-06-21 13:26:55 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-06-21 13:26:55 +0200 |
commit | 47b736139f242a8fd2e5c6513b0c2e0b31110d77 (patch) | |
tree | 94aeca3afb607a2b60cca2a146c8532d431f2b1f /apps/SoilMoisture.cpp | |
parent | f4afc04ee7a085a89ad84ba89344bb50ca9e6e04 (diff) | |
download | ble-toys-47b736139f242a8fd2e5c6513b0c2e0b31110d77.tar.gz ble-toys-47b736139f242a8fd2e5c6513b0c2e0b31110d77.tar.bz2 ble-toys-47b736139f242a8fd2e5c6513b0c2e0b31110d77.tar.xz ble-toys-47b736139f242a8fd2e5c6513b0c2e0b31110d77.zip |
SoilMoisture:
o Adding getName().
sm-get-value:
o More cleanup.
Diffstat (limited to 'apps/SoilMoisture.cpp')
-rw-r--r-- | apps/SoilMoisture.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/SoilMoisture.cpp b/apps/SoilMoisture.cpp index d1d8b7c..5edba0e 100644 --- a/apps/SoilMoisture.cpp +++ b/apps/SoilMoisture.cpp @@ -116,5 +116,17 @@ uint16_t SoilMoisture::getValue(uint8_t sensor) { return writeAndRead(req).read16le(); } + +string SoilMoisture::getName(uint8_t sensor) { + auto req = createGetSensorName(sensor); + + auto buffer = writeAndRead(req); + size_t bytesLeft = buffer.getBytesLeft(); + uint8_t bytes[bytesLeft]; + buffer.copy(bytes, bytesLeft); + + return string((char *) bytes, (unsigned long) bytesLeft); +} + } } |