From 0522f994cd37f453ea98fdd1b91dbc1dba2b4b1a Mon Sep 17 00:00:00 2001 From: Maria Jorba Brosa Date: Tue, 1 Apr 2014 10:06:58 +0000 Subject: [PATCH] --- Project/applications/smartcities/include/globals.h | 1 + Project/applications/smartcities/main.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/Project/applications/smartcities/include/globals.h b/Project/applications/smartcities/include/globals.h index 591d1f9..936b4e5 100644 --- a/Project/applications/smartcities/include/globals.h +++ b/Project/applications/smartcities/include/globals.h @@ -4,5 +4,6 @@ #define SERVER_IP "10.0.60.241" #define SERVER_HOSTNAME SERVER_IP #define MODULE_ID_LENGTH 6 +#define BUFFER_LENGTH 30 #endif \ No newline at end of file diff --git a/Project/applications/smartcities/main.c b/Project/applications/smartcities/main.c index a85f962..1274771 100644 --- a/Project/applications/smartcities/main.c +++ b/Project/applications/smartcities/main.c @@ -4,6 +4,7 @@ #include "globals.h" #include "httpClient.h" #include "callbacks.h" +#include "Buffer.h" #define WIFI_MODE WIFI_MODE_CLIENT #define NETWORK_SSID "linksys" @@ -19,6 +20,9 @@ void initLibwismart(void) int main(void) { + uint32_t* ind=0; + char **buffer; + buffer = malloc (sizeof (char *) * BUFFER_LENGTH); struct wpa_param wpa; wpa.eap_method = WISMART_EAP_METHOD_TTLS; wpa.u.ttls.identity=WPA_USER; @@ -48,6 +52,26 @@ int main(void) for(;;) { + // i2c get info= data + put_message(data, buffer ,&ind); + int res=check_memory(); + if(res==SOFT_REACHED){ + + int ok=send(buffer, ind, char *provider_ID, char *sensor_ID); + if(ok==JSON_COMM_ERROR) + { + printf("wismart is not connected\r\n"); + } + else if( ok==JSON_OTHER_ERROR){ + printf("some error ocurred\r\n"); + } + else if(ok ==JSON_POST_OK){ + printf(" send OK \r\n"); + } + } + else if(res==HARD_REACHED){ + //destroy + } chThdSleepMilliseconds(500); } } -- libgit2 0.22.2