From 995d3cf6dfc00f4329fc73e4224298450b0495bd Mon Sep 17 00:00:00 2001 From: Maria Jorba Brosa Date: Thu, 3 Apr 2014 09:35:44 +0000 Subject: [PATCH] --- Project/applications/smartcities/.dep/main.o.d | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------- Project/applications/smartcities/buffer.c | 62 ++++++++++++++++++++++++++++++++++++++++++-------------------- Project/applications/smartcities/include/buffer.h | 3 ++- Project/applications/smartcities/main.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- 4 files changed, 171 insertions(+), 118 deletions(-) diff --git a/Project/applications/smartcities/.dep/main.o.d b/Project/applications/smartcities/.dep/main.o.d index 59adb4d..65cd7ad 100644 --- a/Project/applications/smartcities/.dep/main.o.d +++ b/Project/applications/smartcities/.dep/main.o.d @@ -1,9 +1,9 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ ../..//os/kernel/include/ch.h ../..//econais/inc/STM32F1/chconf.h \ ../..//os/ports/GCC/ARMCMx/chtypes.h \ - c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h \ - c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdint.h \ + c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h \ + c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdint.h \ ../..//os/kernel/include/chlists.h ../..//os/ports/GCC/ARMCMx/chcore.h \ ../..//os/ports/GCC/ARMCMx/STM32F1xx/cmparams.h \ ../..//os/ports/GCC/ARMCMx/chcore_v7m.h \ @@ -20,28 +20,28 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ ../..//os/kernel/include/chinline.h ../..//os/kernel/include/chqueues.h \ ../..//os/kernel/include/chstreams.h ../..//os/kernel/include/chioch.h \ ../..//os/kernel/include/chfiles.h ../..//os/kernel/include/chdebug.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdio.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/newlib.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h \ - c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/string.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h \ - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/alloca.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdio.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/newlib.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h \ + c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/string.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h \ + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/alloca.h \ ../..//econais/libwismart_mcu.h \ ../..//econais/inc/STM32F1/libwismart_irqs.h \ ../..//econais/STM32_Libs/F1/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h \ @@ -83,7 +83,9 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ ../..//externalModules/lwip_v141/src/include/lwip/sys.h \ ../..//externalModules/lwip_v141/port/arch/sys_arch.h \ ../..//externalModules/lwip_v141/src/include/lwip/api.h \ - ../..//externalModules/lwip_v141/src/include/lwip/netbuf.h + ../..//externalModules/lwip_v141/src/include/lwip/netbuf.h \ + include/callbacks.h include/buffer.h include/json.h include/globals.h \ + include/sensors.h include/module.h ../..//econais/libwismart.h: @@ -93,11 +95,11 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ ../..//os/ports/GCC/ARMCMx/chtypes.h: -c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h: +c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h: -c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h: +c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdint.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdint.h: ../..//os/kernel/include/chlists.h: @@ -153,49 +155,49 @@ c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdint.h: ../..//os/kernel/include/chdebug.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdio.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdio.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/newlib.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/newlib.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h: -c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h: +c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/string.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/string.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h: -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/alloca.h: +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/alloca.h: ../..//econais/libwismart_mcu.h: @@ -282,3 +284,15 @@ include/httpClient.h: ../..//externalModules/lwip_v141/src/include/lwip/api.h: ../..//externalModules/lwip_v141/src/include/lwip/netbuf.h: + +include/callbacks.h: + +include/buffer.h: + +include/json.h: + +include/globals.h: + +include/sensors.h: + +include/module.h: diff --git a/Project/applications/smartcities/buffer.c b/Project/applications/smartcities/buffer.c index 4dbd3ff..2eb88ca 100644 --- a/Project/applications/smartcities/buffer.c +++ b/Project/applications/smartcities/buffer.c @@ -3,30 +3,31 @@ #include "buffer.h" #include "globals.h" -void put_message(char* info, char** buf,uint32_t* index){ +char** put_message(char* info, char** buf,uint32_t* index, uint32_t* buf_len){ uint32_t i; i= *index; - -if((BUFFER_LENGTH-1)==i) +if(buf_len==i) { - i=0; - p[i] = chHeapAlloc(NULL,strlen(info)+1); - buf[i]=info; - i++; + char** buffer=join_buf(buf, buf_len); + buffer[i]=chHeapAlloc(NULL,strlen(info)+1); + buffer[i]=info; + *index = i++; + return buffer; } else{ - p[i] = chHeapAlloc(NULL,strlen(info)+1); - buf[i]=info; - i++; + buf[i] = chHeapAlloc(NULL,strlen(info)+1); + buf[i]=info; + *index = i++; + return buf; } -*index = i++; + } int check_memory(){ int mem_free=libwismart_GetMemFree_Ram().free; - int mem=20480-mem_free; + int mem=25600-mem_free; if(mem>=HARD_LIMIT) { @@ -40,23 +41,44 @@ int check_memory(){ int send(char** buf, uint32_t index, char *provider_ID, char *sensor_ID){ - char* statement=prepare_json_observation_statement(buf, *index+1); + char* statement=prepare_json_observation_statement(buf, index+1); uint32_t size = strlen(statement); - uint8_t res=send_json(statement, size, char* provider_ID, char* sensor_ID); - for(int i;i<*index+1;i++){ + uint8_t res=send_json(statement, size, provider_ID, sensor_ID); + int i; + for(i=0;i