#include #include #include "dht22.h" #include #include #include "sendmysql.h" #include "configreader.h" #include "restcurl.h" #include int main(void) { if (wiringPiSetup () == -1) exit(EXIT_FAILURE) ; if (setuid(getuid()) < 0) { perror("Dropping privileges failed\n"); exit(EXIT_FAILURE); } cfginit(); sensor data; //data of the raspberrypi data.node_id = 0; //Node ID 0 --> RaspberryPi int i; for (i = 0; i < cfgreadpinamount(); i++) { data.pin = cfgreadpinnumber(i); //getData(&data); //printf("Pin: %i, %.2f, %.2f\n", data.pin, data.temperature, data.humidity); //insertData(&data); } sensornode nodes; //Settings of ESP8266 sensor nodes int nodecount = 0; printf("Reading Sensornodes\n"); cfgreadsensornodes(&nodes, nodecount); //read settings printf("Reading Sensornodes done Nodecount: %i\n", nodecount); sensor nodedata; //Should be a linked list for further data usage sensornode *currentNode = &nodes; printf("First IP: %s\n", nodes.ip); for (i = 0; i <= nodecount; i++) { //start rest requests strcpy(nodedata.ip, currentNode->ip); getRestSensor(&nodedata); printf("Acquiring rest response\n"); printf("Temperature: %f, Humidity: %f, NodeID: %i\n", nodedata.temperature, nodedata.humidity, nodedata.node_id); //Insert data into database currentNode = currentNode->next; } cfgdestroy(); return 0; }