Commit 6bcf0e2c18966cd6661763d7f4c138cec9de3e44
1 parent
26c6a495
--no commit message
Showing
4 changed files
with
40 additions
and
3 deletions
Project/applications/smartcities/ADC
0 → 100644
Project/applications/smartcities/include/ntp.h
Project/applications/smartcities/main_demo.c
Project/applications/smartcities/ntp.c
... | ... | @@ -182,4 +182,34 @@ void udpNtp_test(){ |
182 | 182 | |
183 | 183 | printf("Hora:%i:%i:%i\r\n", var2.hour, var2.minute, var2.second); |
184 | 184 | printf("Fecha:%i|%i|%i\r\n", var2.day,var2.month,var2.year); |
185 | -} | |
186 | 185 | \ No newline at end of file |
186 | +} | |
187 | + | |
188 | +char* timestamp_data(char* value,Date time) | |
189 | +{ | |
190 | + uint8_t length = strlen(value) + strlen(",00/00/0000T00:00:00") + 1; | |
191 | + char str_day[3],str_month[3],str_year[5],str_hour[3],str_minute[3],str_second[3]; | |
192 | + char* data = chHeapAlloc(NULL,length*sizeof(char)); | |
193 | + | |
194 | + sprintf(str_day,"%d",time.day); | |
195 | + sprintf(str_month,"%d",time.month); | |
196 | + sprintf(str_year,"%d",time.year); | |
197 | + sprintf(str_hour,"%d",time.hour); | |
198 | + sprintf(str_minute,"%d",time.minute); | |
199 | + sprintf(str_second,"%d",time.second); | |
200 | + | |
201 | + strcpy(data,value); | |
202 | + strcat(data,","); | |
203 | + strcat(data, str_day); | |
204 | + strcat(data,"/"); | |
205 | + strcat(data, str_month); | |
206 | + strcat(data,"/"); | |
207 | + strcat(data, str_year); | |
208 | + strcat(data,"T"); | |
209 | + strcat(data, str_hour); | |
210 | + strcat(data,":"); | |
211 | + strcat(data, str_minute); | |
212 | + strcat(data,":"); | |
213 | + strcat(data, str_second); | |
214 | + data[length-1] = '\0'; | |
215 | + return data; | |
216 | +} | ... | ... |