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