Commit 6bcf0e2c18966cd6661763d7f4c138cec9de3e44

Authored by Imanol-Mikel Barba Sabariego
1 parent 26c6a495

--no commit message

Project/applications/smartcities/ADC 0 → 100644
  1 +PA2 ADC
  2 +PA3 ADDR1
  3 +PA5 ADDR2
  4 +PA6 ADDR3
  5 +PA7 ADDR4
  6 +
  7 +ADDR's POR NIVEL ALTO
0 \ No newline at end of file 8 \ No newline at end of file
Project/applications/smartcities/include/ntp.h
@@ -18,6 +18,7 @@ typedef struct { @@ -18,6 +18,7 @@ typedef struct {
18 int year; 18 int year;
19 }Date; 19 }Date;
20 20
  21 +char* timestamp_data(char* value,Date time);
21 unsigned long getSecsSince1900(void); 22 unsigned long getSecsSince1900(void);
22 Date getDate(unsigned long); 23 Date getDate(unsigned long);
23 void udpNtp_test(void); 24 void udpNtp_test(void);
Project/applications/smartcities/main_demo.c
@@ -66,8 +66,7 @@ int main(void) @@ -66,8 +66,7 @@ int main(void)
66 char **buffer; 66 char **buffer;
67 buffer = chHeapAlloc(NULL,sizeof (char *) * 1); 67 buffer = chHeapAlloc(NULL,sizeof (char *) * 1);
68 68
69 - udpNTP_Setup();  
70 - Date time=getDate(); 69 + Date time=getDate(getSecsSince1900());
71 70
72 libwismart_EnableBsdSocketAPI(); 71 libwismart_EnableBsdSocketAPI();
73 72
Project/applications/smartcities/ntp.c
@@ -182,4 +182,34 @@ void udpNtp_test(){ @@ -182,4 +182,34 @@ void udpNtp_test(){
182 182
183 printf("Hora:%i:%i:%i\r\n", var2.hour, var2.minute, var2.second); 183 printf("Hora:%i:%i:%i\r\n", var2.hour, var2.minute, var2.second);
184 printf("Fecha:%i|%i|%i\r\n", var2.day,var2.month,var2.year); 184 printf("Fecha:%i|%i|%i\r\n", var2.day,var2.month,var2.year);
185 -}  
186 \ No newline at end of file 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 +}