Rest return fixes; Sensornode delay fix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ 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]);
|
||||
if (getRestSensor(&nodedata[i])) {
|
||||
nodedata[i].isoutside = currentNode->isoutside; //copy the boolean value
|
||||
printf("Acquiring rest response\n");
|
||||
|
||||
@@ -70,6 +70,7 @@ int main(void) {
|
||||
//Insert data into database
|
||||
printf("Insert data into stats table\n");
|
||||
insertData(&nodedata[i]);
|
||||
}
|
||||
|
||||
currentNode = currentNode->next;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user