Many bugfixes - fixed warnings and compile errors
This commit is contained in:
@@ -47,8 +47,10 @@ static float dd(float relativeHumidity, float temperature) {
|
||||
return relativeHumidity / 100 * sdd(temperature);
|
||||
}
|
||||
|
||||
/* CURRENTLY UNUSED
|
||||
|
||||
static float r(float temperature, float dewTemperature) {
|
||||
/* This is optional. Necessary with dew point measurements. */
|
||||
// This is optional. Necessary with dew point measurements.
|
||||
return 100 * sdd(dewTemperature) / sdd(temperature);
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ static float td(float relativeHumidity, float temperature) {
|
||||
}
|
||||
return b * v(relativeHumidity, temperature) / (a - v(relativeHumidity, temperature));
|
||||
}
|
||||
|
||||
*/
|
||||
static float af(float relativeHumidity, float temperature) {
|
||||
float tk = temperature + 273.15;
|
||||
return pow(10, 5) * mw/R * dd(relativeHumidity, temperature) / tk;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
config_t cfg;
|
||||
const config_setting_t *pins;
|
||||
|
||||
@@ -60,7 +61,7 @@ int cfgreadsensornodes(sensornode *nodes, int nodecount) {
|
||||
if (!config_setting_lookup_string(sensornodesetting, "ip", &ip))
|
||||
continue;
|
||||
|
||||
currentNode->ip = ip;
|
||||
strcpy(currentNode->ip, ip);
|
||||
//if (i < count - 1) { //stop at last item
|
||||
currentNode->next = malloc(sizeof(sensornode));
|
||||
currentNode = currentNode->next;
|
||||
@@ -70,5 +71,5 @@ int cfgreadsensornodes(sensornode *nodes, int nodecount) {
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,10 +1,20 @@
|
||||
#ifndef cfgreader_H
|
||||
#define cfgreader_H
|
||||
|
||||
|
||||
typedef struct sensornode {
|
||||
char *ip;
|
||||
struct sensornode *next;
|
||||
} sensornode;
|
||||
|
||||
|
||||
|
||||
void cfginit(void);
|
||||
void cfgdestroy(void);
|
||||
void cfgreinit(void);
|
||||
int cfgreadpinnumber(int element);
|
||||
int cfgreadpinamount(void);
|
||||
int cfgreadsensornodes(sensornode *nodes, int nodecount);
|
||||
|
||||
typedef struct sensornode {
|
||||
char *ip;
|
||||
struct sensornode *next;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "sendmysql.h"
|
||||
#include "configreader.h"
|
||||
#include "restcurl.h"
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
if (wiringPiSetup () == -1)
|
||||
@@ -26,20 +27,20 @@ int main(void) {
|
||||
data.pin = cfgreadpinnumber(i);
|
||||
getData(&data);
|
||||
printf("Pin: %i, %.2f, %.2f\n", data.pin, data.temperature, data.humidity);
|
||||
insertData(&data);
|
||||
//insertData(&data);
|
||||
}
|
||||
|
||||
sensornode nodes; //Settings of ESP8266 sensor nodes
|
||||
int nodecount;
|
||||
int nodecount = 0;
|
||||
cfgreadsensornodes(&nodes, nodecount); //read settings
|
||||
sensor nodedata; //Should be a linked list for further data usage
|
||||
sensornode *currentNode = nodes;
|
||||
sensornode *currentNode = &nodes;
|
||||
|
||||
|
||||
for (i = 0; i < nodecount; i++) {
|
||||
//start rest requests
|
||||
nodedata.ip = currentNode->ip;
|
||||
getRestSensor(&nodedate);
|
||||
strcpy(nodedata.ip, currentNode->ip);
|
||||
getRestSensor(&nodedata);
|
||||
|
||||
printf("Temperature: %f, Humidity: %f, NodeID: %i", nodedata.temperature, nodedata.humidity, nodedata.node_id);
|
||||
|
||||
|
@@ -1,8 +1,10 @@
|
||||
#include "restcurl.h"
|
||||
#include <curl/curl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "cJSON.h"
|
||||
|
||||
static struct url_data {
|
||||
struct url_data {
|
||||
size_t size;
|
||||
char* data;
|
||||
};
|
||||
@@ -66,7 +68,7 @@ static char *handle_url(char *url) {
|
||||
|
||||
int getRestSensor(sensor *sensor) {
|
||||
char url[25];
|
||||
url = "http://";
|
||||
strcpy(url, "http://");
|
||||
strcat(url, sensor->ip);
|
||||
char *data = handle_url(url);
|
||||
if (data) {
|
||||
|
Reference in New Issue
Block a user