![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Dust Sesnsor PMS5003
Dependencies: DustSenzor NetServices ThingSpeakEthernet mbed
Fork of PMS5003 by
Diff: main.cpp
- Revision:
- 1:57f922fe8fb5
- Parent:
- 0:2419d81ee03d
- Child:
- 2:16857d9ab50d
diff -r 2419d81ee03d -r 57f922fe8fb5 main.cpp --- a/main.cpp Tue Nov 09 21:28:45 2010 +0000 +++ b/main.cpp Tue Nov 16 20:04:25 2010 +0000 @@ -1,9 +1,11 @@ #include "mbed.h" #include "EthernetNetIf.h" #include "HTTPClient.h" +#include "NTPClient.h" EthernetNetIf eth("mbedSE"); HTTPClient http; +NTPClient ntp; int main() { @@ -14,8 +16,10 @@ return -1; } - printf("Connected ok, IP : %d.%d.%d.%d\n", eth.getIp()[0], eth.getIp()[1], eth.getIp()[2], eth.getIp()[3]); + IpAddr ethIp = eth.getIp(); + printf("Connected ok, IP : %d.%d.%d.%d\n", ethIp[0], ethIp[1], ethIp[2], ethIp[3]); + printf("\nHTTPClient get...\n"); HTTPText txt; HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt); if (r==HTTP_OK) { @@ -24,5 +28,16 @@ printf("Error %d\n", r); } + time_t ctTime; + ctTime = time(NULL); + printf("\nCurrent time is (UTC): %d %s\n", ctTime, ctime(&ctTime)); + printf("NTP setTime...\n"); + Host server(IpAddr(), 123, "pool.ntp.org"); + printf("Result : %d\n", ntp.setTime(server)); + + ctTime = time(NULL); + printf("\nTime is now (UTC): %d %s\n", ctTime, ctime(&ctTime)); + + printf("Done!\n"); return 0; } \ No newline at end of file