database, username, and password must now be provided to spark_angel_receiver

This commit is contained in:
King Kévin 2015-11-11 01:36:45 +01:00
parent 395eadfb1d
commit 3baadec22c
1 changed files with 16 additions and 2 deletions

View File

@ -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