Table of Contents

Overview

The Get Time application connects to a SNTP server, request for time, process the data and displays the time on Hyperterminal. The communication between the device and server is based on the Network Time Protocol (NTP).

Application details

The Get Time application connects to an AP with parameters set in common.h. This example requires an Access Point connected to the internet. If the connection to this AP is unsuccessful, the user is prompted on the terminal to enter AP details which must be entered in the format as specified below:

<ap_ssid>:<security_type>:<password>:<wep_key_id>:

The red LED continuously blinks as long as a connection with AP is not established. Once established, the red LED stays continuously on.

Users can use any of the listed servers to get the time by changing the variable g_acSNTPserver.

//!    ######################### list of SNTP servers ##################################
//!    ##
//!    ##          hostname         |        IP       |       location
//!    ## -----------------------------------------------------------------------------
//!    ##   time-a.nist.gov         | 129.6.15.28     |  NIST, Gaithersburg, Maryland
//!    ##   time-b.nist.gov         | 129.6.15.29     |  NIST, Gaithersburg, Maryland
//!    ##   time-c.nist.gov         | 129.6.15.30     |  NIST, Gaithersburg, Maryland
//!    ##   nist1-macon.macon.ga.us | 98.175.203.200  |  Macon, Georgia
//!    ##   For more SNTP server link visit 'http://tf.nist.gov/tf-cgi/servers.cgi'
//!    ###################################################################################
const char g_acSNTPserver[30] = "time-a.nist.gov";

Depending on the region of interest, the GMT offset can be changed by changing the macro:

#define GMT_DIFF_TIME_HRS 5
#define GMT_DIFF_TIME_MINS 30

Get time application gives the current time in the configured time zone. This application can be used to become familiar with UDP sockets to communicate with a server.

Source Files briefly explained

Usage

  1. Setup a serial communication application. Open a serial terminal on a PC with the following settings:
    • Port: Enumerated COM port
    • Baud rate: 115200
    • Data: 8 bit
    • Parity: None
    • Stop: 1 bit
    • Flow control: None
  2. Edit common.h and modify the values of the below macros for the device to connect to the AP:

    #define SSID_NAME           "<ap_name>"         /* AP SSID */
    #define SECURITY_TYPE       SL_SEC_TYPE_OPEN    /* Security type (OPEN or WEP or WPA*/
    #define SECURITY_KEY        ""                  /* Password of the secured AP */
  3. Run the reference application.
    • Open the project in CCS/IAR. Build the application and debug to load to the device, or flash the binary using UniFlash.
  4. If the connection to the default AP is unsuccessful, the user will be prompted on the terminal to enter AP details.
  5. The red LED will continuously blinks while a connection with the AP is not established. Once established, the red LED will stay continuously on.
  6. The current time as obtained from the SNTP server and is printed to the terminal.

Limitations/Known Issues