Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

CC3100 Get Time Application

From Texas Instruments Wiki
Jump to: navigation, search
Cc31xx cc32xx return home.png
Cc31xx return sample apps.png

Overview and application details

This sample application demonstrates how to connect to an SNTP server and request for time information. The application processes the received data and displays the time on console.

NoteNote: This wiki page is only applicable for CC3100-SDK v1.0.0 and upward releases. For documentation on older SDKs' examples, refer corresponding file in <cc3100-sdk-installation-location>\cc3100-sdk\docs\examples\'

Source Files briefly explained

i. main - Initializes the device, connects to an AP, open an UDP socket, requests and displays the time information.

Usage

Prerequisite: This application requires an access-point with internet connectivity

  • Connect the board to a Windows-PC and configure the terminal-program for seeing the logs - Terminal Setting page has detailed instructions for configuring the terminal-program
  • Edit main.c to set the SNTP server's name (in variable SNTPserver) - Any server from the below list can be used for demo
   /*! ######################### List of SNTP servers ############################
    *! ##
    *! ##          hostname         |        IP        |       location
    *! ## ------------------------------------------------------------------------
    *! ## nist1-nj2.ustiming.org    | 165.193.126.229  | Weehawken, NJ
    *! ## nist1-pa.ustiming.org     | 206.246.122.250  | Hatfield, PA
    *! ## 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
    *! ## ntp-nist.ldsbc.edu        | 198.60.73.8      | LDSBC, Salt Lake City, Utah
    *! ## nist1-macon.macon.ga.us   | 98.175.203.200   | Macon, Georgia
    *! ## 0.in.pool.ntp.org         | 123.108.225.6    | India
    *! ## For more SNTP server link visit 'http://tf.nist.gov/tf-cgi/servers.cgi'
    *! ###########################################################################
    */
    const _u8 SNTPserver[30] = "nist1-pa.ustiming.org"; /* Add any one of the above servers */
  • Edit sl_common.h and update the following parameters for the device to establish connection w/ the access-point
   #define SSID_NAME       "<ap_name>"
   #define SEC_TYPE        <security-type>
   #define PASSKEY         ""
  • Edit main.c and modify values for below macros for settings the GMT time-offset
   #define GMT_TIME_ZONE_HR        0
   #define GMT_TIME_ZONE_MIN       00
  • Build and run the application
  • See the self explanatory logs on the terminal-program's console.
   The application connects to the SNTP server and opens an UDP socket to communicate w/ it.
   It receives and processes the time-information and displays it on the console
  • On success, below message will be displayed on the terminal
Get_time_1.png

Limitations/Known Issues

None

Links