
NTPClient using the mbed_official WiflyInterface
Dependencies: NTPClient WiflyInterface mbed
main.cpp
- Committer:
- samux
- Date:
- 2012-08-24
- Revision:
- 1:8b6ea44e02bb
- Parent:
- 0:42b732f6238c
File content as of revision 1:8b6ea44e02bb:
#include "mbed.h" #include "WiflyInterface.h" #include "NTPClient.h" /* wifly interface: * - p9 and p10 are for the serial communication * - p19 is for the reset pin * - p26 is for the connection status * - "mbed" is the ssid of the network * - "password" is the password * - WPA is the security */ WiflyInterface wifly(p9, p10, p19, p26, "mbed", "password", WPA); NTPClient ntp; int main() { wifly.init(); //Use DHCP wifly.connect(); printf("Trying to update time...\r\n"); if (ntp.setTime("0.pool.ntp.org") == 0) { printf("Set time successfully\r\n"); time_t ctTime; ctTime = time(NULL); printf("Time is set to (UTC): %s\r\n", ctime(&ctTime)); } else { printf("Error\r\n"); } wifly.disconnect(); while(1) { } }