aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-20 22:31:33 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-20 22:31:33 +0200
commitf085ec61273a5fa680c337d0ae7d5a85294aaeba (patch)
treec803363a7b30b44ff27badc9ad365a8b6d4c76f3 /apps
parent06b0a16d2635dba071ea7967f32c2aabe2b9cbcc (diff)
downloadble-toys-f085ec61273a5fa680c337d0ae7d5a85294aaeba.tar.gz
ble-toys-f085ec61273a5fa680c337d0ae7d5a85294aaeba.tar.bz2
ble-toys-f085ec61273a5fa680c337d0ae7d5a85294aaeba.tar.xz
ble-toys-f085ec61273a5fa680c337d0ae7d5a85294aaeba.zip
o Sending only a single sample after all values have been read.
Diffstat (limited to 'apps')
-rw-r--r--apps/sm-get-value.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/apps/sm-get-value.cpp b/apps/sm-get-value.cpp
index 19b0066..92ef5f9 100644
--- a/apps/sm-get-value.cpp
+++ b/apps/sm-get-value.cpp
@@ -74,7 +74,7 @@ public:
do {
try {
- LOG4CPLUS_INFO(execution.logger, "Connecting to device: " + device.getMac().str());
+ LOG4CPLUS_INFO(execution.logger, "Connecting to device: " << device.getMac().str());
auto gatt = device.connectGatt();
withConnection(format, gatt);
@@ -83,8 +83,8 @@ public:
}
if (loop) {
- LOG4CPLUS_DEBUG(execution.logger,
- "Sleeping for " + std::to_string(sleepTime) + " seconds after failure.");
+ LOG4CPLUS_DEBUG(execution.logger, "Sleeping for " << std::to_string(sleepTime)
+ << " seconds after failure.");
auto targetTime = system_clock::now() + seconds(sleepTime);
this_thread::sleep_until(targetTime);
@@ -107,6 +107,11 @@ public:
auto unique_output_stream = open_sample_output_stream(shared_ptr<ostream>(&cout, noop_deleter), dict, format);
shared_ptr<SampleOutputStream> output_stream{std::move(unique_output_stream)};
+ auto sample = SampleRecord(dict)
+ .set(hostname_key, get_hostname())
+ .set(device_key, mac)
+ .set(timestamp_key, std::to_string(timestamp));
+
int i = 0;
for (auto s : sensors) {
auto sensor = s.first;
@@ -117,17 +122,12 @@ public:
auto sensor_key = dict.indexOf("sensor" + std::to_string(i));
auto sensor_name_key = dict.indexOf("sensor_name" + std::to_string(i));
- auto sample = SampleRecord(dict)
- .set(hostname_key, get_hostname())
- .set(device_key, mac)
- .set(timestamp_key, std::to_string(timestamp))
- .set(sensor_key, std::to_string(value))
- .set(sensor_name_key, name);
-
- output_stream->write(sample);
+ sample.set(sensor_key, std::to_string(value)).set(sensor_name_key, name);
i++;
}
+
+ output_stream->write(sample);
}
void withConnection(sample_format_type format, shared_ptr<BluetoothGatt> gatt) {