Fixed segfault in configreader

This commit is contained in:
2017-08-27 18:28:26 +02:00
parent eda866b36d
commit 27ed59b52f
4 changed files with 22 additions and 10 deletions

View File

@@ -25,29 +25,35 @@ int main(void) {
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);
//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++) {
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", nodedata.temperature, nodedata.humidity, nodedata.node_id);
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;
}