Rest return fixes; Sensornode delay fix

This commit is contained in:
2017-08-31 19:22:57 +02:00
parent e6b7bdf721
commit c2b7c1eed7
3 changed files with 16 additions and 10 deletions

View File

@@ -107,8 +107,8 @@ void loop() {
//set new milli counter
//millis will overflow after approx. 52 days. To prevent errors we're checking the limits
if (millis() + MEASURESECONDS * 1000 <= ULONG_MAX) {
millitotal = millis() + 2000;
if (millis() + (MEASURESECONDS * 1000) <= ULONG_MAX) {
millitotal = millis() + (MEASURESECONDS * 1000);
} else {
millitotal = 0;
}

View File

@@ -61,16 +61,17 @@ int main(void) {
//start rest requests
nodedata[i].pin = 0; //This data isn't relevant for a sensornode
strcpy(nodedata[i].ip, currentNode->ip);
getRestSensor(&nodedata[i]);
nodedata[i].isoutside = currentNode->isoutside; //copy the boolean value
printf("Acquiring rest response\n");
if (getRestSensor(&nodedata[i])) {
nodedata[i].isoutside = currentNode->isoutside; //copy the boolean value
printf("Acquiring rest response\n");
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata[i].temperature, nodedata[i].humidity, nodedata[i].node_id, nodedata[i].isoutside ? "Yes" : "No", absoluteHumidity(&nodedata[i]));
//Insert data into database
printf("Insert data into stats table\n");
insertData(&nodedata[i]);
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata[i].temperature, nodedata[i].humidity, nodedata[i].node_id, nodedata[i].isoutside ? "Yes" : "No", absoluteHumidity(&nodedata[i]));
//Insert data into database
printf("Insert data into stats table\n");
insertData(&nodedata[i]);
}
currentNode = currentNode->next;
}

View File

@@ -86,6 +86,11 @@ int getRestSensor(sensor *sensor) {
sensor->temperature = (float)temperature->valuedouble;
sensor->humidity = (float)humidity->valuedouble;
sensor->node_id = atoi(id->valuestring);
} else {
//free
cJSON_Delete(jsondata);
free(data);
return 0;
}
//free
cJSON_Delete(jsondata);