diff options
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); +} + } } |