aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2015-11-11 01:36:45 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2015-11-11 01:36:45 +0100
commit3baadec22ceb664726d2b3c2cc756d96c808f42b (patch)
tree91adc8a8b6985828e4d3d10f87c0b28595650ea0
parent395eadfb1d6f3f2b97849394b22a31fb7a42d622 (diff)
database, username, and password must now be provided to spark_angel_receiver
-rw-r--r--rpi/spark_counter_receiver.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/rpi/spark_counter_receiver.cpp b/rpi/spark_counter_receiver.cpp
index 2ff4a6a..7c6939b 100644
--- a/rpi/spark_counter_receiver.cpp
+++ b/rpi/spark_counter_receiver.cpp
@@ -47,10 +47,24 @@ uint8_t iv[16] = {0xff,0xee,0xdd,0xcc,0xbb,0xaa,0x99,0x88,0x77,0x66,0x55,0x44,0x
int main(int argc, char** argv){
+ if (argc!=4) {
+ fprintf(stderr, "provide database name, username, and password as argument (spaces, ':', special characters, or very long arguments not supported)\n");
+ return 1;
+ }
+
// configure influxdb connection
curl = curl_easy_init();
- if(curl) {
- curl_easy_setopt(curl, CURLOPT_URL, "http://localhost:8086/write?db=electricity");
+ if (curl) {
+ char url[256];
+ snprintf(url, sizeof(url), "http://localhost:8086/write?db=%s", argv[1]);
+ curl_easy_setopt(curl, CURLOPT_URL, url);
+ char auth[256];
+ snprintf(auth, sizeof(auth), "%s:%s", argv[2], argv[3]);
+ curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+ curl_easy_setopt(curl, CURLOPT_USERPWD, auth);
+ } else {
+ fprintf(stderr, "could not initialize curl\n");
+ return 1;
}
// configure nRF24L01+ radio