Commit c352e1674e41b08193835f522705864382cf55a3
1 parent
d53ffdcd
--no commit message
Showing
3 changed files
with
7 additions
and
15 deletions
Project/applications/smartcities/buffer.c
@@ -69,9 +69,10 @@ int send(char** buf, uint32_t *index, uint32_t *size_buf, char *provider_ID, cha | @@ -69,9 +69,10 @@ int send(char** buf, uint32_t *index, uint32_t *size_buf, char *provider_ID, cha | ||
69 | chHeapFree(buf[i]); | 69 | chHeapFree(buf[i]); |
70 | } | 70 | } |
71 | if(buf!=NULL) | 71 | if(buf!=NULL) |
72 | + { | ||
72 | chHeapFree(buf); | 73 | chHeapFree(buf); |
73 | - | ||
74 | - printf(" posant la mida i l'index a 0\r\n"); | 74 | + } |
75 | + printf("posant la mida i l'index a 0\r\n"); | ||
75 | *index=0; | 76 | *index=0; |
76 | *size_buf=0; | 77 | *size_buf=0; |
77 | } | 78 | } |
Project/applications/smartcities/flash.bat
@@ -4,4 +4,4 @@ | @@ -4,4 +4,4 @@ | ||
4 | 4 | ||
5 | :: -HardRst | 5 | :: -HardRst |
6 | ECHO flash | 6 | ECHO flash |
7 | -C:\ST-LINK_Utility\ST-LINK_CLI.exe -c SWD -p build/buttonExample.bin 0x08000000 -Run | 7 | +"C:\Program Files\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe" -c SWD -p build/smartcities.bin 0x08000000 -Run |
Project/applications/smartcities/ntp.c
@@ -98,17 +98,11 @@ unsigned long getSecsSince1900 (void) | @@ -98,17 +98,11 @@ unsigned long getSecsSince1900 (void) | ||
98 | // Set recv timeout. | 98 | // Set recv timeout. |
99 | sendUDPNetConn->recv_timeout = SNTP_RECV_TIMEOUT; | 99 | sendUDPNetConn->recv_timeout = SNTP_RECV_TIMEOUT; |
100 | // Receive SNTP server response. | 100 | // Receive SNTP server response. |
101 | - //receiveUDPNetBuf = netconn_recv(sendUDPNetConn); | ||
102 | errLWIP=netconn_recv(sendUDPNetConn, &receiveUDPNetBuf); | 101 | errLWIP=netconn_recv(sendUDPNetConn, &receiveUDPNetBuf); |
103 | - | ||
104 | - | ||
105 | - //if (NULL != receiveUDPNetBuf) | ||
106 | if(errLWIP==ERR_OK) | 102 | if(errLWIP==ERR_OK) |
107 | { | 103 | { |
108 | // Get pointer to response data. | 104 | // Get pointer to response data. |
109 | netbuf_data(receiveUDPNetBuf, (void **) &sntp_response, (u16_t *) &dataLen); | 105 | netbuf_data(receiveUDPNetBuf, (void **) &sntp_response, (u16_t *) &dataLen); |
110 | - | ||
111 | - | ||
112 | // If the response size is good. | 106 | // If the response size is good. |
113 | if (dataLen == SNTP_MAX_DATA_LEN) | 107 | if (dataLen == SNTP_MAX_DATA_LEN) |
114 | { | 108 | { |
@@ -117,7 +111,6 @@ unsigned long getSecsSince1900 (void) | @@ -117,7 +111,6 @@ unsigned long getSecsSince1900 (void) | ||
117 | { | 111 | { |
118 | /* extract GMT time from response */ | 112 | /* extract GMT time from response */ |
119 | memcpy(×tamp, (sntp_response + SNTP_RCV_TIME_OFS), sizeof(timestamp)); | 113 | memcpy(×tamp, (sntp_response + SNTP_RCV_TIME_OFS), sizeof(timestamp)); |
120 | - //timestamp = (ntohl(timestamp) - DIFF_SEC_1900_1970); | ||
121 | timestamp=(ntohl(timestamp)); | 114 | timestamp=(ntohl(timestamp)); |
122 | 115 | ||
123 | printf("Received timestamp %u\r\n", timestamp); | 116 | printf("Received timestamp %u\r\n", timestamp); |
@@ -136,25 +129,23 @@ unsigned long getSecsSince1900 (void) | @@ -136,25 +129,23 @@ unsigned long getSecsSince1900 (void) | ||
136 | } | 129 | } |
137 | else | 130 | else |
138 | { | 131 | { |
139 | - //printf("Netconn receive failed with %d\r\n", netconn_err(sendUDPNetConn)); | ||
140 | printf("Netconn receive failed with %d\r\n", netconn_err(sendUDPNetConn)); | 132 | printf("Netconn receive failed with %d\r\n", netconn_err(sendUDPNetConn)); |
141 | } | 133 | } |
142 | - } // netconn_send(sendUDPNetConn, sendUDPNetBuf); | 134 | + } |
143 | else | 135 | else |
144 | { | 136 | { |
145 | printf("Netconn sendto failed with %d\r\n", errLWIP); | 137 | printf("Netconn sendto failed with %d\r\n", errLWIP); |
146 | } | 138 | } |
147 | - } //netconn_connect(sendUDPNetConn, &sntp_server_address, SNTP_PORT); | 139 | + } |
148 | else | 140 | else |
149 | { | 141 | { |
150 | printf("Netconn connect to server %X, port %u failed with %d\r\n", sntp_server_address.addr, SNTP_PORT, errLWIP); | 142 | printf("Netconn connect to server %X, port %u failed with %d\r\n", sntp_server_address.addr, SNTP_PORT, errLWIP); |
151 | } | 143 | } |
152 | - } // if ((NULL != sendUDPNetConn) && (NULL != sendUDPNetBuf) && (NULL != sntp_request)) | 144 | + } |
153 | else | 145 | else |
154 | { | 146 | { |
155 | printf("Netconn or netbuf or data allocation failed.\r\n"); | 147 | printf("Netconn or netbuf or data allocation failed.\r\n"); |
156 | } | 148 | } |
157 | - | ||
158 | // Deallocate space hold for netconn and netbuf structure. | 149 | // Deallocate space hold for netconn and netbuf structure. |
159 | netbuf_delete(sendUDPNetBuf); | 150 | netbuf_delete(sendUDPNetBuf); |
160 | netconn_delete(sendUDPNetConn); | 151 | netconn_delete(sendUDPNetConn); |