From c23a8c4548e43d7a49cbd6ca399c41eb28b8b1c4 Mon Sep 17 00:00:00 2001 From: Maria Jorba Brosa Date: Thu, 22 May 2014 09:20:47 +0000 Subject: [PATCH] --- Project/applications/smartcities/main2.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------ 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/Project/applications/smartcities/main2.c b/Project/applications/smartcities/main2.c index f4587be..bd8f41f 100644 --- a/Project/applications/smartcities/main2.c +++ b/Project/applications/smartcities/main2.c @@ -29,7 +29,7 @@ void initLibwismart(void) uint8_t connected=0; uint8_t timeout=0; uint8_t retries=0; -uint8_t total_sensors=0; +uint8_t first_sensor=0; void init_registry(void) { @@ -86,55 +86,62 @@ void init_registry(void) } -void send_data(char** buffers[j], uint32_t ind[], uint32_t sizes[j], uint8_t sensors[]); +void send_data(char** buffers[j], uint32_t ind[], uint32_t sizes[j], uint8_t* sensors); { int j; - for(j=0;j retorna un vector con las direcciones en cada posición del vector, si la posición del vector retorna un cero -> no existe el sensor uint8_t sensors[TOTAL_SENSORS]; - sensor_scan(); - char* valueSensors[total_sensors]; + char* valueSensors[TOTAL_SENSORS]; I2C_scan(sensors); - //conectar wifi //unsigned int time = getNTPTime(); unsigned int time = getSecsSince1900(); @@ -231,7 +236,7 @@ int main(void) printf("--------------hard limit-------------\r\n"); // fem servir 085 de prova, però haurem de fer servir sensor_id[0] - while( send(buffers[0],&ind[0],&sizes[0], mod.ID, sensors[j]) != JSON_POST_OK ) + while( send(buffers[first_sensor],&ind[first_sensor],&sizes[first_sensor], mod.ID, sensors[first_sensor]) != JSON_POST_OK ) { // El servidor no ens sap dir si tenim permisos o no sense registrar una mostra. // Intentem enviar un buffer sencer, a veure si ja podem buidar. @@ -241,22 +246,24 @@ int main(void) chThdSleepMilliseconds(HARD_LIMIT_WAIT_TIME); } int j; - for(j=1;j