Commit a66a2b04ddf74c343506910b37ae597f96891c9b

Authored by Ferràn Quer i Guerrero
1 parent 0962964e

--no commit message

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 27  
28 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 33 int mem=38920-mem_free;
34 34 printf("mem ocupada=%d\r\n",mem);
35 35 if(mem>=HARD_LIMIT)
... ... @@ -43,20 +43,19 @@ int check_memory(){
43 43 }
44 44  
45 45 int send(char** buf, uint32_t *index, uint32_t *size_buf, char *provider_ID, char *sensor_ID){
46   - printf("1\r\n");
47 46 char* statement=prepare_json_observation_statement(buf, *index);
48   - printf("2\r\n");
49 47 uint32_t size = strlen(statement);
50   - printf("3\r\n");
  48 + if(buf==NULL)
  49 + { return 2; }
51 50 uint8_t res=send_json(statement, size, provider_ID, sensor_ID);
52   - printf("4\r\n");
53 51 int i;
54   - printf("res=%d\r\n",res);
  52 + printf("JSON_POST_OK ? %d\r\n",res == JSON_POST_OK);
55 53 if(res==JSON_POST_OK){
56   -
57 54 for(i=0;i<*index;i++){
58 55 chHeapFree(buf[i]);
59 56 }
  57 + printf("djfkhvldkfjhdñkfgv\r\n");
  58 + chHeapFree(buf);
60 59 printf(" posant la mida i l'index a 0\r\n");
61 60 *index=0;
62 61 *size_buf=0;
... ... @@ -71,8 +70,10 @@ int i=0;
71 70 int j;
72 71 while(check_memory()!=MEMORY_OK)
73 72 {
  73 +printf("alliberant posicio %d \r\n",i);
74 74 for(j=0;j<4;j++){
75 75 if(master_buf[j]!=NULL)
  76 + printf("alliberant buffer %d\r\n",j);
76 77 chHeapFree(master_buf[j][i]);
77 78 }
78 79 i++;
... ... @@ -90,8 +91,8 @@ char** join_buf(char** buf, uint32_t *buf_len){
90 91 strcpy(n_buf[i],buf[i]);
91 92 chHeapFree(buf[i]);
92 93 }
93   - if(len!=0){
94   - chHeapFree(buf);}
  94 + if(len!=0)
  95 + { chHeapFree(buf); }
95 96 len++;
96 97 *buf_len=len;
97 98 return n_buf;
... ...