diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/sm-get-value.cpp | 22 |
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) { |