Commit a66a2b04ddf74c343506910b37ae597f96891c9b
1 parent
0962964e
--no commit message
Showing
8 changed files
with
42592 additions
and
42397 deletions
Too many changes to show.
To preserve performance only 1 of 8 files are displayed.
Project/applications/smartcities/buffer.c
@@ -27,9 +27,9 @@ else{ | @@ -27,9 +27,9 @@ else{ | ||
27 | 27 | ||
28 | int check_memory(){ | 28 | int check_memory(){ |
29 | 29 | ||
30 | - //int mem_free=libwismart_GetMemFree_Ram().free_core; | ||
31 | - //printf("mem lliure=%d\r\n",mem_free); | ||
32 | - int mem_free=20000; | 30 | + int mem_free=libwismart_GetMemFree_Ram().free_core; |
31 | + printf("mem lliure=%d\r\n",mem_free); | ||
32 | + //int mem_free=20000; | ||
33 | int mem=38920-mem_free; | 33 | int mem=38920-mem_free; |
34 | printf("mem ocupada=%d\r\n",mem); | 34 | printf("mem ocupada=%d\r\n",mem); |
35 | if(mem>=HARD_LIMIT) | 35 | if(mem>=HARD_LIMIT) |
@@ -43,20 +43,19 @@ int check_memory(){ | @@ -43,20 +43,19 @@ int check_memory(){ | ||
43 | } | 43 | } |
44 | 44 | ||
45 | int send(char** buf, uint32_t *index, uint32_t *size_buf, char *provider_ID, char *sensor_ID){ | 45 | int send(char** buf, uint32_t *index, uint32_t *size_buf, char *provider_ID, char *sensor_ID){ |
46 | - printf("1\r\n"); | ||
47 | char* statement=prepare_json_observation_statement(buf, *index); | 46 | char* statement=prepare_json_observation_statement(buf, *index); |
48 | - printf("2\r\n"); | ||
49 | uint32_t size = strlen(statement); | 47 | uint32_t size = strlen(statement); |
50 | - printf("3\r\n"); | 48 | + if(buf==NULL) |
49 | + { return 2; } | ||
51 | uint8_t res=send_json(statement, size, provider_ID, sensor_ID); | 50 | uint8_t res=send_json(statement, size, provider_ID, sensor_ID); |
52 | - printf("4\r\n"); | ||
53 | int i; | 51 | int i; |
54 | - printf("res=%d\r\n",res); | 52 | + printf("JSON_POST_OK ? %d\r\n",res == JSON_POST_OK); |
55 | if(res==JSON_POST_OK){ | 53 | if(res==JSON_POST_OK){ |
56 | - | ||
57 | for(i=0;i<*index;i++){ | 54 | for(i=0;i<*index;i++){ |
58 | chHeapFree(buf[i]); | 55 | chHeapFree(buf[i]); |
59 | } | 56 | } |
57 | + printf("djfkhvldkfjhdñkfgv\r\n"); | ||
58 | + chHeapFree(buf); | ||
60 | printf(" posant la mida i l'index a 0\r\n"); | 59 | printf(" posant la mida i l'index a 0\r\n"); |
61 | *index=0; | 60 | *index=0; |
62 | *size_buf=0; | 61 | *size_buf=0; |
@@ -71,8 +70,10 @@ int i=0; | @@ -71,8 +70,10 @@ int i=0; | ||
71 | int j; | 70 | int j; |
72 | while(check_memory()!=MEMORY_OK) | 71 | while(check_memory()!=MEMORY_OK) |
73 | { | 72 | { |
73 | +printf("alliberant posicio %d \r\n",i); | ||
74 | for(j=0;j<4;j++){ | 74 | for(j=0;j<4;j++){ |
75 | if(master_buf[j]!=NULL) | 75 | if(master_buf[j]!=NULL) |
76 | + printf("alliberant buffer %d\r\n",j); | ||
76 | chHeapFree(master_buf[j][i]); | 77 | chHeapFree(master_buf[j][i]); |
77 | } | 78 | } |
78 | i++; | 79 | i++; |
@@ -90,8 +91,8 @@ char** join_buf(char** buf, uint32_t *buf_len){ | @@ -90,8 +91,8 @@ char** join_buf(char** buf, uint32_t *buf_len){ | ||
90 | strcpy(n_buf[i],buf[i]); | 91 | strcpy(n_buf[i],buf[i]); |
91 | chHeapFree(buf[i]); | 92 | chHeapFree(buf[i]); |
92 | } | 93 | } |
93 | - if(len!=0){ | ||
94 | - chHeapFree(buf);} | 94 | + if(len!=0) |
95 | + { chHeapFree(buf); } | ||
95 | len++; | 96 | len++; |
96 | *buf_len=len; | 97 | *buf_len=len; |
97 | return n_buf; | 98 | return n_buf; |