Commit b0c12c0a9510b085a0de0bedb648dac5682c69aa
1 parent
2da24931
--no commit message
Showing
1 changed file
with
22 additions
and
7 deletions
Project/applications/smartcities/main2.c
... | ... | @@ -108,13 +108,26 @@ void send_data(char** buffers[j], uint32_t ind[], uint32_t sizes[j], uint8_t sen |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | -void put_buffers(char** buffers,uint32_t ind[],uint32_t sizes[],char* valueSensors[]){ | |
112 | -int i; | |
111 | +void put_buffers(char** buffers,uint32_t ind[],uint32_t sizes[],char** cooked){ | |
112 | + int i; | |
113 | 113 | for(i=0;i<TOTAL_SENSORS;i++){ |
114 | - put_message(valueSensors[i], buffers[i] ,&ind[i],&sizes[i]); | |
114 | + put_message(cooked[i], buffers[i] ,&ind[i],&sizes[i]); | |
115 | + chHeapFree(cooked[i]); | |
115 | 116 | } |
116 | 117 | |
117 | 118 | } |
119 | +char** timestamp_datas(char* value[],unsigned long timestamp){ | |
120 | + | |
121 | + char** cooked_data; | |
122 | + Date t=getDate(timestamp); | |
123 | + int i; | |
124 | + for(i=0;i<TOTAL_SENSORS;i++){ | |
125 | + cooked_data[i]=timestamp_data(value[i], t); | |
126 | + chHeapFree(value[i]); | |
127 | + } | |
128 | + return cooked_data; | |
129 | +} | |
130 | + | |
118 | 131 | |
119 | 132 | int main(void) |
120 | 133 | { |
... | ... | @@ -135,14 +148,15 @@ int main(void) |
135 | 148 | //unsigned int time = getNTPTime(); |
136 | 149 | unsigned int time = getSecsSince1900(); |
137 | 150 | |
138 | - unsigned int timestamp = 0; | |
139 | - unsigned int delay = getSystemTime(); | |
140 | - unsigned int delay2 = 0; | |
151 | + unsigned long timestamp = 0; | |
152 | + unsigned long delay = getSystemTime(); | |
153 | + unsigned long delay2 = 0; | |
141 | 154 | sleep_thread(SHORT_PERIOD - time%SHORT_PERIOD); |
142 | 155 | |
143 | 156 | uint32_t ind[4]={0}; |
144 | 157 | char** buffers[4]; |
145 | 158 | uint32_t sizes[4]={0}; |
159 | + char* cooked_data[TOTAL_SENSORS]; | |
146 | 160 | |
147 | 161 | init_registry(); |
148 | 162 | |
... | ... | @@ -192,7 +206,8 @@ int main(void) |
192 | 206 | /* Add data to the buffer with timestamp*/ |
193 | 207 | |
194 | 208 | //a_cookedData = format_data(a_rawData, timestamp); |
195 | - put_buffers(buffers,ind,sizes,valueSensors); | |
209 | + char** values=timestamp_datas(valueSensors,timestamp); | |
210 | + put_buffers(buffers,ind,sizes,values); | |
196 | 211 | printf("mirant memoria\r\n"); |
197 | 212 | int res=check_memory(); |
198 | 213 | if(res==SOFT_REACHED){ | ... | ... |