Commit 995d3cf6dfc00f4329fc73e4224298450b0495bd
1 parent
a4db05fe
--no commit message
Showing
4 changed files
with
171 additions
and
118 deletions
Project/applications/smartcities/.dep/main.o.d
1 | 1 | build/obj/main.o: main.c ../..//econais/libwismart.h \ |
2 | 2 | ../..//os/kernel/include/ch.h ../..//econais/inc/STM32F1/chconf.h \ |
3 | 3 | ../..//os/ports/GCC/ARMCMx/chtypes.h \ |
4 | - c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h \ | |
5 | - c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h \ | |
6 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdint.h \ | |
4 | + c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h \ | |
5 | + c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h \ | |
6 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdint.h \ | |
7 | 7 | ../..//os/kernel/include/chlists.h ../..//os/ports/GCC/ARMCMx/chcore.h \ |
8 | 8 | ../..//os/ports/GCC/ARMCMx/STM32F1xx/cmparams.h \ |
9 | 9 | ../..//os/ports/GCC/ARMCMx/chcore_v7m.h \ |
... | ... | @@ -20,28 +20,28 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ |
20 | 20 | ../..//os/kernel/include/chinline.h ../..//os/kernel/include/chqueues.h \ |
21 | 21 | ../..//os/kernel/include/chstreams.h ../..//os/kernel/include/chioch.h \ |
22 | 22 | ../..//os/kernel/include/chfiles.h ../..//os/kernel/include/chdebug.h \ |
23 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdio.h \ | |
24 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ | |
25 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/newlib.h \ | |
26 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h \ | |
27 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h \ | |
28 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h \ | |
29 | - c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h \ | |
30 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h \ | |
31 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ | |
32 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h \ | |
33 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h \ | |
34 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h \ | |
35 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h \ | |
36 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h \ | |
37 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h \ | |
38 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h \ | |
39 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/string.h \ | |
40 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h \ | |
41 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h \ | |
42 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h \ | |
43 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h \ | |
44 | - c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/alloca.h \ | |
23 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdio.h \ | |
24 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ | |
25 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/newlib.h \ | |
26 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h \ | |
27 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h \ | |
28 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h \ | |
29 | + c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h \ | |
30 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h \ | |
31 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h \ | |
32 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h \ | |
33 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h \ | |
34 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h \ | |
35 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h \ | |
36 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h \ | |
37 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h \ | |
38 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h \ | |
39 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/string.h \ | |
40 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h \ | |
41 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h \ | |
42 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h \ | |
43 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h \ | |
44 | + c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/alloca.h \ | |
45 | 45 | ../..//econais/libwismart_mcu.h \ |
46 | 46 | ../..//econais/inc/STM32F1/libwismart_irqs.h \ |
47 | 47 | ../..//econais/STM32_Libs/F1/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h \ |
... | ... | @@ -83,7 +83,9 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ |
83 | 83 | ../..//externalModules/lwip_v141/src/include/lwip/sys.h \ |
84 | 84 | ../..//externalModules/lwip_v141/port/arch/sys_arch.h \ |
85 | 85 | ../..//externalModules/lwip_v141/src/include/lwip/api.h \ |
86 | - ../..//externalModules/lwip_v141/src/include/lwip/netbuf.h | |
86 | + ../..//externalModules/lwip_v141/src/include/lwip/netbuf.h \ | |
87 | + include/callbacks.h include/buffer.h include/json.h include/globals.h \ | |
88 | + include/sensors.h include/module.h | |
87 | 89 | |
88 | 90 | ../..//econais/libwismart.h: |
89 | 91 | |
... | ... | @@ -93,11 +95,11 @@ build/obj/main.o: main.c ../..//econais/libwismart.h \ |
93 | 95 | |
94 | 96 | ../..//os/ports/GCC/ARMCMx/chtypes.h: |
95 | 97 | |
96 | -c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h: | |
98 | +c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stddef.h: | |
97 | 99 | |
98 | -c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h: | |
100 | +c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdint.h: | |
99 | 101 | |
100 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdint.h: | |
102 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdint.h: | |
101 | 103 | |
102 | 104 | ../..//os/kernel/include/chlists.h: |
103 | 105 | |
... | ... | @@ -153,49 +155,49 @@ c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdint.h: |
153 | 155 | |
154 | 156 | ../..//os/kernel/include/chdebug.h: |
155 | 157 | |
156 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdio.h: | |
158 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdio.h: | |
157 | 159 | |
158 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: | |
160 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: | |
159 | 161 | |
160 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/newlib.h: | |
162 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/newlib.h: | |
161 | 163 | |
162 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h: | |
164 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/config.h: | |
163 | 165 | |
164 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h: | |
166 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/ieeefp.h: | |
165 | 167 | |
166 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h: | |
168 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/features.h: | |
167 | 169 | |
168 | -c:\yagarto\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h: | |
170 | +c:\yagarto-20121222\bin\../lib/gcc/arm-none-eabi/4.7.2/include/stdarg.h: | |
169 | 171 | |
170 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h: | |
172 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/reent.h: | |
171 | 173 | |
172 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: | |
174 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/_ansi.h: | |
173 | 175 | |
174 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h: | |
176 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/_types.h: | |
175 | 177 | |
176 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h: | |
178 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_types.h: | |
177 | 179 | |
178 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h: | |
180 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/_default_types.h: | |
179 | 181 | |
180 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h: | |
182 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/lock.h: | |
181 | 183 | |
182 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h: | |
184 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/types.h: | |
183 | 185 | |
184 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h: | |
186 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/types.h: | |
185 | 187 | |
186 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h: | |
188 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/stdio.h: | |
187 | 189 | |
188 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/string.h: | |
190 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/string.h: | |
189 | 191 | |
190 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h: | |
192 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/cdefs.h: | |
191 | 193 | |
192 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h: | |
194 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/sys/string.h: | |
193 | 195 | |
194 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h: | |
196 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/stdlib.h: | |
195 | 197 | |
196 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h: | |
198 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/machine/stdlib.h: | |
197 | 199 | |
198 | -c:/yagarto/lib/gcc/../../arm-none-eabi/sys-include/alloca.h: | |
200 | +c:/yagarto-20121222/lib/gcc/../../arm-none-eabi/sys-include/alloca.h: | |
199 | 201 | |
200 | 202 | ../..//econais/libwismart_mcu.h: |
201 | 203 | |
... | ... | @@ -282,3 +284,15 @@ include/httpClient.h: |
282 | 284 | ../..//externalModules/lwip_v141/src/include/lwip/api.h: |
283 | 285 | |
284 | 286 | ../..//externalModules/lwip_v141/src/include/lwip/netbuf.h: |
287 | + | |
288 | +include/callbacks.h: | |
289 | + | |
290 | +include/buffer.h: | |
291 | + | |
292 | +include/json.h: | |
293 | + | |
294 | +include/globals.h: | |
295 | + | |
296 | +include/sensors.h: | |
297 | + | |
298 | +include/module.h: | ... | ... |
Project/applications/smartcities/buffer.c
... | ... | @@ -3,30 +3,31 @@ |
3 | 3 | #include "buffer.h" |
4 | 4 | #include "globals.h" |
5 | 5 | |
6 | -void put_message(char* info, char** buf,uint32_t* index){ | |
6 | +char** put_message(char* info, char** buf,uint32_t* index, uint32_t* buf_len){ | |
7 | 7 | |
8 | 8 | uint32_t i; |
9 | 9 | i= *index; |
10 | - | |
11 | -if((BUFFER_LENGTH-1)==i) | |
10 | +if(buf_len==i) | |
12 | 11 | { |
13 | - i=0; | |
14 | - p[i] = chHeapAlloc(NULL,strlen(info)+1); | |
15 | - buf[i]=info; | |
16 | - i++; | |
12 | + char** buffer=join_buf(buf, buf_len); | |
13 | + buffer[i]=chHeapAlloc(NULL,strlen(info)+1); | |
14 | + buffer[i]=info; | |
15 | + *index = i++; | |
16 | + return buffer; | |
17 | 17 | } |
18 | 18 | else{ |
19 | - p[i] = chHeapAlloc(NULL,strlen(info)+1); | |
20 | - buf[i]=info; | |
21 | - i++; | |
19 | + buf[i] = chHeapAlloc(NULL,strlen(info)+1); | |
20 | + buf[i]=info; | |
21 | + *index = i++; | |
22 | + return buf; | |
22 | 23 | } |
23 | -*index = i++; | |
24 | + | |
24 | 25 | } |
25 | 26 | |
26 | 27 | int check_memory(){ |
27 | 28 | |
28 | 29 | int mem_free=libwismart_GetMemFree_Ram().free; |
29 | - int mem=20480-mem_free; | |
30 | + int mem=25600-mem_free; | |
30 | 31 | |
31 | 32 | if(mem>=HARD_LIMIT) |
32 | 33 | { |
... | ... | @@ -40,23 +41,44 @@ int check_memory(){ |
40 | 41 | |
41 | 42 | int send(char** buf, uint32_t index, char *provider_ID, char *sensor_ID){ |
42 | 43 | |
43 | - char* statement=prepare_json_observation_statement(buf, *index+1); | |
44 | + char* statement=prepare_json_observation_statement(buf, index+1); | |
44 | 45 | uint32_t size = strlen(statement); |
45 | - uint8_t res=send_json(statement, size, char* provider_ID, char* sensor_ID); | |
46 | - for(int i;i<*index+1;i++){ | |
46 | + uint8_t res=send_json(statement, size, provider_ID, sensor_ID); | |
47 | + int i; | |
48 | + for(i=0;i<index+1;i++){ | |
47 | 49 | chHeapFree(buf[i]); |
48 | 50 | } |
49 | 51 | return res; |
50 | 52 | } |
51 | 53 | |
52 | -void destroy(char** buf){ | |
54 | +void destroy(char** master_buf[]){ | |
53 | 55 | |
56 | +//[j] buffer index [i] string index | |
54 | 57 | int i=0; |
55 | - | |
56 | -while(check_memory()==HARD_LIMIT) | |
57 | -{ | |
58 | - chHeapFree(buf[i]); | |
58 | +int j; | |
59 | +while(check_memory()!=MEMORY_OK) | |
60 | +{ | |
61 | +for(j=0;j<4;j++){ | |
62 | + if(master_buf[j]!=NULL) | |
63 | + chHeapFree(master_buf[j][i]); | |
64 | +} | |
59 | 65 | i++; |
60 | 66 | } |
61 | 67 | |
62 | 68 | } |
69 | + | |
70 | +char** join_buf(char** buf, int* buf_len){ | |
71 | + char** n_buf; | |
72 | + int len= *buf_len; | |
73 | + n_buf=chHeapalloc (NULL,sizeof (char *) * (len+1)); | |
74 | + int i; | |
75 | + for(i=0; i<len;i++){ | |
76 | + char* aux=buf[i]; | |
77 | + n_buf[i]=chHeapAlloc(NULL,strlen(aux)+1); | |
78 | + n_buf[i]=aux; | |
79 | + chHeapFree(buf[i]); | |
80 | + } | |
81 | + chHeapFree(buf); | |
82 | + *buf_len=len++; | |
83 | + return n_buf; | |
84 | +} | ... | ... |
Project/applications/smartcities/include/buffer.h
... | ... | @@ -10,9 +10,10 @@ |
10 | 10 | #define SOFT_REACHED 1 |
11 | 11 | #define HARD_REACHED 2 |
12 | 12 | |
13 | -void put_message(char* info, char** buf,uint32_t* index); | |
13 | +char** put_message(char* info, char** buf,uint32_t* index, uint32_t* buf_len); | |
14 | 14 | int check_memory(void); |
15 | 15 | int send(char** buf, uint32_t index, char *provider_ID, char *sensor_ID); |
16 | 16 | void destroy(char** buf); |
17 | +char** join_buf(char** buf, int* buf_len); | |
17 | 18 | |
18 | 19 | #endif |
19 | 20 | \ No newline at end of file | ... | ... |
Project/applications/smartcities/main.c
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | #include "httpClient.h" |
6 | 6 | #include "callbacks.h" |
7 | 7 | #include "buffer.h" |
8 | +#include "i2c.h" | |
8 | 9 | |
9 | 10 | #define WIFI_MODE WIFI_MODE_CLIENT |
10 | 11 | #define NETWORK_SSID "linksys" |
... | ... | @@ -20,60 +21,75 @@ void initLibwismart(void) |
20 | 21 | |
21 | 22 | int main(void) |
22 | 23 | { |
23 | - uint32_t ind=0; | |
24 | - char **buffer; | |
25 | - buffer = malloc (sizeof (char *) * BUFFER_LENGTH); | |
26 | - struct wpa_param wpa; | |
27 | - wpa.eap_method = WISMART_EAP_METHOD_TTLS; | |
28 | - wpa.u.ttls.identity=WPA_USER; | |
29 | - wpa.u.ttls.password=WPA_PASS; | |
30 | - wpa.u.ttls.ca_cert=NULL; | |
24 | + //if(libwismart_RegistryIsValueEmpty(wismart_registryKey_t* key)){ | |
31 | 25 | |
32 | - struct httpHeaders head200 = { get, "/", 1, "http://www.w3.org/", 19 }; | |
33 | - struct httpHeaders head301 = { get, "/", 1, "w3.org", 6 }; | |
34 | - struct httpHeaders head404 = { get, "/errorerrorerror", 15, "www.w3.org" }; | |
35 | - | |
36 | - initLibwismart(); | |
37 | - libwismart_PowerSave_Enable(); | |
38 | - libwismart_PowerSave_HigherProfile(TRUE); | |
26 | + //} | |
27 | + //else { | |
28 | + uint32_t ind[4]={0}; | |
29 | + char** buffers[4]; | |
30 | + int sizes[4]={0}; | |
31 | + int i; | |
32 | + for(i=0;i<4;i++){ | |
39 | 33 | |
40 | - libwismart_RegisterDhcpCB(dhcp_connect_result_cb); | |
34 | + buffers[i]=NULL; | |
35 | + } | |
36 | + struct wpa_param wpa; | |
37 | + wpa.eap_method = WISMART_EAP_METHOD_TTLS; | |
38 | + wpa.u.ttls.identity=WPA_USER; | |
39 | + wpa.u.ttls.password=WPA_PASS; | |
40 | + wpa.u.ttls.ca_cert=NULL; | |
41 | + | |
42 | + struct httpHeaders head200 = { get, "/", 1, "http://www.w3.org/", 19 }; | |
43 | + struct httpHeaders head301 = { get, "/", 1, "w3.org", 6 }; | |
44 | + struct httpHeaders head404 = { get, "/errorerrorerror", 15, "www.w3.org" }; | |
45 | + | |
46 | + initLibwismart(); | |
47 | + libwismart_PowerSave_Enable(); | |
48 | + libwismart_PowerSave_HigherProfile(TRUE); | |
49 | + | |
50 | + libwismart_RegisterDhcpCB(dhcp_connect_result_cb); | |
41 | 51 | |
42 | - libwismart_WiFiInit(); | |
43 | - //falta definir les variables de la xarxa | |
44 | - libwismart_WiFiConnectEnterprise(NETWORK_SSID, &wpa, wifi_connect_result_cb); | |
52 | + libwismart_WiFiInit(); | |
53 | + //falta definir les variables de la xarxa | |
54 | + libwismart_WiFiConnectEnterprise(NETWORK_SSID, &wpa, wifi_connect_result_cb); | |
45 | 55 | |
46 | - //int httpRequest(struct httpHeaders head, char* content, int content_size) | |
47 | - //chThdSleepMilliseconds(5000); | |
48 | - | |
49 | - //httpRequest(head200, NULL, 0); | |
50 | - /*httpRequest(head301, NULL, 0); | |
51 | - httpRequest(head404, NULL, 0);*/ | |
56 | + //int httpRequest(struct httpHeaders head, char* content, int content_size) | |
57 | + //chThdSleepMilliseconds(5000); | |
52 | 58 | |
53 | - for(;;) | |
54 | - { | |
55 | - // i2c get info= data | |
56 | - char* data=NULL; | |
57 | - put_message(data, buffer ,&ind); | |
58 | - int res=check_memory(); | |
59 | - if(res==SOFT_REACHED){ | |
59 | + //httpRequest(head200, NULL, 0); | |
60 | + /*httpRequest(head301, NULL, 0); | |
61 | + httpRequest(head404, NULL, 0);*/ | |
62 | + // i2c scans the sensors active and returns how many thay are | |
60 | 63 | |
61 | - int ok=send(buffer, ind, "", ""); | |
62 | - if(ok==JSON_COMM_ERROR) | |
63 | - { | |
64 | - printf("wismart is not connected\r\n"); | |
64 | + for(;;) | |
65 | + { | |
66 | + | |
67 | + for(i=0;i<4;i++){ | |
68 | + // i2c gets the data and combines it with the time stamp | |
69 | + char* data=NULL; | |
70 | + put_message(data, buffers[i] ,&ind[i],sizes[i]); | |
71 | + int res=check_memory(); | |
72 | + if(res==SOFT_REACHED){ | |
73 | + | |
74 | + int ok=send(buffers[i], ind[i], "", ""); | |
75 | + if(ok==JSON_COMM_ERROR) | |
76 | + { | |
77 | + printf("wismart is not connected\r\n"); | |
78 | + } | |
79 | + else if( ok==JSON_OTHER_ERROR){ | |
80 | + printf("some error ocurred\r\n"); | |
81 | + } | |
82 | + else if(ok ==JSON_POST_OK){ | |
83 | + printf(" send OK \r\n"); | |
84 | + } | |
65 | 85 | } |
66 | - else if( ok==JSON_OTHER_ERROR){ | |
67 | - printf("some error ocurred\r\n"); | |
86 | + else if(res==HARD_REACHED){ | |
87 | + destroy(buffer[i]); | |
68 | 88 | } |
69 | - else if(ok ==JSON_POST_OK){ | |
70 | - printf(" send OK \r\n"); | |
71 | 89 | } |
90 | + | |
91 | + | |
92 | + chThdSleepMilliseconds(500); | |
72 | 93 | } |
73 | - else if(res==HARD_REACHED){ | |
74 | - destroy(buffer); | |
75 | - } | |
76 | - chThdSleepMilliseconds(500); | |
77 | - } | |
94 | + //} | |
78 | 95 | } |
79 | - | ... | ... |