aboutsummaryrefslogtreecommitdiff
path: root/raw-mqtt-consumer.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-08-02 22:52:48 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-08-02 22:52:48 +0200
commitcf94e623ff3c3dcdd4ca6a59632d48bd17b75d55 (patch)
tree32aab58a0df0054e4e5c3bfe47c0299bfacddf25 /raw-mqtt-consumer.cpp
parent06c78fe0e2e4e7f0a5ba791571e1986a2e0dab42 (diff)
downloadmqtt-cassandra-bridge-cf94e623ff3c3dcdd4ca6a59632d48bd17b75d55.tar.gz
mqtt-cassandra-bridge-cf94e623ff3c3dcdd4ca6a59632d48bd17b75d55.tar.bz2
mqtt-cassandra-bridge-cf94e623ff3c3dcdd4ca6a59632d48bd17b75d55.tar.xz
mqtt-cassandra-bridge-cf94e623ff3c3dcdd4ca6a59632d48bd17b75d55.zip
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.
Diffstat (limited to 'raw-mqtt-consumer.cpp')
-rw-r--r--raw-mqtt-consumer.cpp12
1 files changed, 5 insertions, 7 deletions
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<cassandra_session> current_cassandra_session;
-struct measurement {
- KeyDictionary dict;
-};
-
class raw_mqtt_client : private mosqpp::mosquittopp {
public:
typedef std::function<void(const struct mosquitto_message *)> 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<string>(&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;
}