IsOutside boolean added to config and insertData. Readme updated

This commit is contained in:
2017-08-27 22:04:17 +02:00
parent 27ed59b52f
commit 18c7d610b9
8 changed files with 32 additions and 10 deletions

View File

@@ -8,6 +8,20 @@
#include "restcurl.h"
#include <string.h>
void freeNodeLinkedList(sensornode *node) {
void *victim;
if (node != NULL) {
while (node) {
victim = node;
node = node->next;
free(victim);
}
}
}
int main(void) {
if (wiringPiSetup () == -1)
exit(EXIT_FAILURE) ;
@@ -37,23 +51,27 @@ int main(void) {
printf("Reading Sensornodes done Nodecount: %i\n", nodecount);
sensor nodedata; //Should be a linked list for further data usage
sensornode *currentNode = &nodes;
nodedata.pin = 0; //This data isn't relevant for a sensornode
printf("First IP: %s\n", nodes.ip);
for (i = 0; i <= nodecount; i++) {
//start rest requests
strcpy(nodedata.ip, currentNode->ip);
getRestSensor(&nodedata);
nodedata.isoutside = currentNode->isoutside; //copy the boolean value
printf("Acquiring rest response\n");
printf("Temperature: %f, Humidity: %f, NodeID: %i\n", nodedata.temperature, nodedata.humidity, nodedata.node_id);
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s\n", nodedata.temperature, nodedata.humidity, nodedata.node_id, nodedata.isoutside ? "Yes" : "No");
//Insert data into database
printf("Insert data into stats table\n");
insertData(&nodedata);
currentNode = currentNode->next;
}
//free
//freeNodeLinkedList(nodes.next);
cfgdestroy();
return 0;
}