diff --git a/Project/applications/smartcities/include/globals.h b/Project/applications/smartcities/include/globals.h index fb98a33..6109a45 100644 --- a/Project/applications/smartcities/include/globals.h +++ b/Project/applications/smartcities/include/globals.h @@ -5,7 +5,6 @@ #define SERVER_HOSTNAME SERVER_IP #define MODULE_ID_LENGTH 6 #define BUFFER_LENGTH 30 - #define MAX_RAM 30000 #endif \ No newline at end of file diff --git a/Project/applications/smartcities/main2.c b/Project/applications/smartcities/main2.c index 17579d9..f4587be 100644 --- a/Project/applications/smartcities/main2.c +++ b/Project/applications/smartcities/main2.c @@ -8,6 +8,7 @@ #include "buffer.h" #include "i2c.h" #include "configServer.h" +#include "timer-loop.h" #define WIFI_MODE WIFI_MODE_CLIENT #define NETWORK_SSID_AP "modularsens" @@ -15,7 +16,6 @@ #define NETWORK_CHANNEL_AP 1 #define HARD_LIMIT_WAIT_TIME 10*1000 //5*60*1000 -#define NUMSENSORS 4 wismart_registryKey_t geo; @@ -29,6 +29,7 @@ void initLibwismart(void) uint8_t connected=0; uint8_t timeout=0; uint8_t retries=0; +uint8_t total_sensors=0; void init_registry(void) { @@ -88,7 +89,7 @@ void init_registry(void) 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]; - char* valueSensors[TOTAL_SENSORS]; + sensor_scan(); + char* valueSensors[total_sensors]; I2C_scan(sensors); - + //conectar wifi //unsigned int time = getNTPTime(); unsigned int time = getSecsSince1900(); + //desconectarwifi unsigned long timestamp = 0; unsigned long delay = getSystemTime(); @@ -156,7 +168,7 @@ int main(void) uint32_t ind[4]={0}; char** buffers[4]; uint32_t sizes[4]={0}; - char* cooked_data[TOTAL_SENSORS]; + char* cooked_data[total_sensors]; init_registry(); @@ -194,6 +206,7 @@ int main(void) send_data(); //time = getNTPTime(); time = getSecsSince1900(); + //desconectar wifi printf("time (absolute):\t%d\r\ntime mod LONG_PERIOD:\t%d\r\ntime mod SHORT_PERIOD:\t%d\r\n",time,time%LONG_PERIOD,time%SHORT_PERIOD); i = 0; } @@ -228,7 +241,7 @@ int main(void) chThdSleepMilliseconds(HARD_LIMIT_WAIT_TIME); } int j; - for(j=1;j