Bringinh all the pieces together. #2 #7

This commit is contained in:
2017-08-27 16:31:46 +02:00
parent 98a0e3ff5f
commit eca544a421
6 changed files with 72 additions and 6 deletions

View File

@@ -5,6 +5,7 @@
#include <unistd.h>
#include "sendmysql.h"
#include "configreader.h"
#include "restcurl.h"
int main(void) {
if (wiringPiSetup () == -1)
@@ -18,8 +19,8 @@ int main(void) {
cfginit();
sensor data;
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);
@@ -27,6 +28,25 @@ int main(void) {
printf("Pin: %i, %.2f, %.2f\n", data.pin, data.temperature, data.humidity);
insertData(&data);
}
sensornode nodes; //Settings of ESP8266 sensor nodes
int nodecount;
cfgreadsensornodes(&nodes, nodecount); //read settings
sensor nodedata; //Should be a linked list for further data usage
sensornode *currentNode = nodes;
for (i = 0; i < nodecount; i++) {
//start rest requests
nodedata.ip = currentNode->ip;
getRestSensor(&nodedate);
printf("Temperature: %f, Humidity: %f, NodeID: %i", nodedata.temperature, nodedata.humidity, nodedata.node_id);
currentNode = currentNode->next;
}
return 0;
}