From 6bcf0e2c18966cd6661763d7f4c138cec9de3e44 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Thu, 8 May 2014 07:08:31 +0000 Subject: [PATCH] --- Project/applications/smartcities/ADC | 7 +++++++ Project/applications/smartcities/include/ntp.h | 1 + Project/applications/smartcities/main_demo.c | 3 +-- Project/applications/smartcities/ntp.c | 32 +++++++++++++++++++++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 Project/applications/smartcities/ADC diff --git a/Project/applications/smartcities/ADC b/Project/applications/smartcities/ADC new file mode 100644 index 0000000..205f076 --- /dev/null +++ b/Project/applications/smartcities/ADC @@ -0,0 +1,7 @@ +PA2 ADC +PA3 ADDR1 +PA5 ADDR2 +PA6 ADDR3 +PA7 ADDR4 + +ADDR's POR NIVEL ALTO \ No newline at end of file diff --git a/Project/applications/smartcities/include/ntp.h b/Project/applications/smartcities/include/ntp.h index afd73cc..4dec285 100644 --- a/Project/applications/smartcities/include/ntp.h +++ b/Project/applications/smartcities/include/ntp.h @@ -18,6 +18,7 @@ typedef struct { int year; }Date; +char* timestamp_data(char* value,Date time); unsigned long getSecsSince1900(void); Date getDate(unsigned long); void udpNtp_test(void); diff --git a/Project/applications/smartcities/main_demo.c b/Project/applications/smartcities/main_demo.c index dc11452..9fda350 100644 --- a/Project/applications/smartcities/main_demo.c +++ b/Project/applications/smartcities/main_demo.c @@ -66,8 +66,7 @@ int main(void) char **buffer; buffer = chHeapAlloc(NULL,sizeof (char *) * 1); - udpNTP_Setup(); - Date time=getDate(); + Date time=getDate(getSecsSince1900()); libwismart_EnableBsdSocketAPI(); diff --git a/Project/applications/smartcities/ntp.c b/Project/applications/smartcities/ntp.c index e3e3f77..887ccf3 100644 --- a/Project/applications/smartcities/ntp.c +++ b/Project/applications/smartcities/ntp.c @@ -182,4 +182,34 @@ void udpNtp_test(){ printf("Hora:%i:%i:%i\r\n", var2.hour, var2.minute, var2.second); printf("Fecha:%i|%i|%i\r\n", var2.day,var2.month,var2.year); -} \ No newline at end of file +} + +char* timestamp_data(char* value,Date time) +{ + uint8_t length = strlen(value) + strlen(",00/00/0000T00:00:00") + 1; + char str_day[3],str_month[3],str_year[5],str_hour[3],str_minute[3],str_second[3]; + char* data = chHeapAlloc(NULL,length*sizeof(char)); + + sprintf(str_day,"%d",time.day); + sprintf(str_month,"%d",time.month); + sprintf(str_year,"%d",time.year); + sprintf(str_hour,"%d",time.hour); + sprintf(str_minute,"%d",time.minute); + sprintf(str_second,"%d",time.second); + + strcpy(data,value); + strcat(data,","); + strcat(data, str_day); + strcat(data,"/"); + strcat(data, str_month); + strcat(data,"/"); + strcat(data, str_year); + strcat(data,"T"); + strcat(data, str_hour); + strcat(data,":"); + strcat(data, str_minute); + strcat(data,":"); + strcat(data, str_second); + data[length-1] = '\0'; + return data; +} -- libgit2 0.22.2