@@ -118,10 +118,8 @@ HardwareSerial Serial1(PA10, PA9);
118
118
119
119
#define INTERVAL 10 // Interval of Packet Send(Second)
120
120
#define NTP_SERVER " time.google.com" // NTP Server
121
- // #define NTP_SERVER "216.239.35.4" // NTP Server
122
121
#define NTP_PORT 123 // NTP Port
123
122
#define LOCAL_PORT 2390 // Local Port
124
- #define LINK_ID 3 // Link ID
125
123
#define NTP_PACKET_SIZE 48 // NTP Packet Size
126
124
#define TIME_ZONE 9 // Time Difference from GMT
127
125
#define DNS_SERVER1 " 8.8.8.8" // DNS SERVER1
@@ -179,17 +177,17 @@ void sendNTPpacket(char *ntpSrv, int ntpPort)
179
177
// (see URL above for details on the packets)
180
178
181
179
packetBuffer[0 ] = 0b11100011 ; // LI, Version, Mode
182
- packetBuffer[1 ] = 0 ; // Stratum, or type of clock
183
- packetBuffer[2 ] = 6 ; // Polling Interval
184
- packetBuffer[3 ] = 0xEC ; // Peer Clock Precision
180
+ packetBuffer[1 ] = 0 ; // Stratum, or type of clock
181
+ packetBuffer[2 ] = 6 ; // Polling Interval
182
+ packetBuffer[3 ] = 0xEC ; // Peer Clock Precision
185
183
// 8 bytes of zero for Root Delay & Root Dispersion
186
- packetBuffer[12 ] = 49 ;
187
- packetBuffer[13 ] = 0x4E ;
188
- packetBuffer[14 ] = 49 ;
189
- packetBuffer[15 ] = 52 ;
184
+ packetBuffer[12 ] = 49 ;
185
+ packetBuffer[13 ] = 0x4E ;
186
+ packetBuffer[14 ] = 49 ;
187
+ packetBuffer[15 ] = 52 ;
190
188
191
189
// Send Data
192
- int ret = sendData (LINK_ID , packetBuffer, NTP_PACKET_SIZE, ntpSrv, ntpPort);
190
+ int ret = sendData (- 1 , packetBuffer, NTP_PACKET_SIZE, ntpSrv, ntpPort);
193
191
if (ret) {
194
192
errorDisplay (" sendData Fail" );
195
193
}
@@ -265,23 +263,15 @@ void setup(void)
265
263
}
266
264
clearBuffer ();
267
265
268
- // Enable multi connections
269
- sendCommand (" AT+CIPMUX=1" );
270
- if (!waitForString (" OK" , 2 , 1000 )) {
271
- errorDisplay (" AT+CIPMUX Fail" );
272
- }
273
- clearBuffer ();
274
-
275
266
// Establish UDP Transmission
276
- // AT+CIPSTART=<link ID>,< type="UDP">,<remoteIP="0">,<remote port=0>,<UDP local port>,<UDP mode=2>
277
- sprintf (cmd," AT+CIPSTART=%d, \" UDP\" ,\" 0\" ,0,%u,2" , LINK_ID , LOCAL_PORT);
278
- // sendCommand("AT+CIPSTART=3, \"UDP\",\"0\",0,2390,2");
267
+ // AT+CIPSTART=<type="UDP">,<remoteIP="0">,<remote port=0>,<UDP local port>,<UDP mode=2>
268
+ sprintf (cmd," AT+CIPSTART=\" UDP\" ,\" 0\" ,0,%u,2" , LOCAL_PORT);
269
+ // sendCommand("AT+CIPSTART=\"UDP\",\"0\",0,2390,2");
279
270
sendCommand (cmd);
280
271
if (!waitForString (" OK" , 2 , 1000 )) {
281
272
errorDisplay (" AT+CIPSTART Fail" );
282
273
}
283
274
clearBuffer ();
284
-
285
275
Serial.println (" Start NTP Client [" + String (_MODEL_) + " ] using " + String (NTP_SERVER));
286
276
287
277
// send an NTP packet to a time server
@@ -311,7 +301,7 @@ void loop(void) {
311
301
}
312
302
313
303
// Read data from NTP server
314
- int readLen = readResponse (LINK_ID , packetBuffer, NTP_PACKET_SIZE, 1000 );
304
+ int readLen = readResponse (- 1 , packetBuffer, NTP_PACKET_SIZE, 1000 );
315
305
// Serial.print("packet received, length=");
316
306
// Serial.println(readLen);
317
307
if (readLen == NTP_PACKET_SIZE) {
0 commit comments