From cf94e623ff3c3dcdd4ca6a59632d48bd17b75d55 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 2 Aug 2015 22:52:48 +0200 Subject: o Adding better --help handling. SM: Using "timestamp_ms" instead of "timestamp" as the timestamp key. SM: On reception, send a "cooked" message with the value of each device. To be improved. --- raw-mqtt-consumer.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'raw-mqtt-consumer.cpp') diff --git a/raw-mqtt-consumer.cpp b/raw-mqtt-consumer.cpp index 421d18c..86815c6 100644 --- a/raw-mqtt-consumer.cpp +++ b/raw-mqtt-consumer.cpp @@ -25,10 +25,6 @@ static string keyspace_name = "soil_moisture"; static unique_ptr current_cassandra_session; -struct measurement { - KeyDictionary dict; -}; - class raw_mqtt_client : private mosqpp::mosquittopp { public: typedef std::function callback_t; @@ -148,7 +144,7 @@ void on_message(const struct mosquitto_message *message) { std::for_each(sample_buffer->samples.cbegin(), sample_buffer->samples.cend(), [&](auto &sample) { cout << "Sample: " << sample.to_string() << endl; - insert_into_raw(current_cassandra_session, sample)->then([&](cassandra_future2 &f) { + insert_into_raw(current_cassandra_session, sample)->then([&](auto &f) { if (f) cout << "Success!" << endl; else { @@ -169,6 +165,7 @@ int main(int argc, const char **argv) { string cassandra_cluster; po::options_description all("Options"); + all.add_options()("help", "Show command options"); all.add_options()("cassandra-cluster", po::value(&cassandra_cluster)->default_value("127.0.0.1")); all.add_options()("mqtt-host", po::value<>(&mqtt_host)->default_value("trygvis.io")); all.add_options()("mqtt-port", po::value<>(&mqtt_port)->default_value(1883)); @@ -182,12 +179,13 @@ int main(int argc, const char **argv) { auto unrecognized = po::collect_unrecognized(parsed.options, po::include_positional); if (vm.count("help")) { - cerr << all << "\n"; + cerr << all << endl; return EXIT_FAILURE; } if (unrecognized.size()) { - cerr << "Unrecognized option: " << unrecognized.at(0) << "\n"; + cerr << "Unrecognized option: " << unrecognized.at(0) << endl; + cerr << all << endl; return EXIT_FAILURE; } -- cgit v1.2.3