CC3000 Basic Wi-Fi example application for MSP430

From Texas Instruments Wiki
Jump to: navigation, search

Return to CC3000 Main page

An updated service pack v1.12 is available. This update is highly recommended. Please use the Patch Programmer  to burn the new version to your module.



Objective

This application gives the user a sample application to evaluate basic commands and build upon or change as their custom application needs.
The current application version number is v1.13.7.15
Service pack 1.12 or later must be used with this application

Prerequisites

Hardware

1. 1x LSR SimpleLink Wi-fi CC3000 FRAM Evaluation Kit, orderable from the TI eStore, which is comprised of the following individually orderable components:

2. 1x Wi-fi Access Point (will be using TP-Link WR740N)

Software

  1. Download the Patch programmer installer for MSP430FR5739 
  2. Obtain the Basic WiFi Application for MSP430 FRAM from the main download page.
  3. One of the following evaluation software is required in order to view and compile the patch programmer sources. Alternatively the binary can be used to burn directly to the board(Included in Patch Programmer download)
  • IAR Embedded Workbench v5.51.4 (MSP430).
  • CCSv5.3
  1. Download Application support release 1.12:CC3000 Downloads
  2. (Optional) Hyper Terminal: Such as PuTTY

Assumptions & Knowledge Base

  1. The MSP430 FRAM kit is assumed to be delivered with the preflashed MSP430 program.
  2. The user should have knowledge of or be familiar with:


Environment Setup

Connecting the CC3000 Device to a PC

  1. Connect the CC3000 module to the MSP430 board.
  2. Connect the USB miniport on the MSP430 board to a PC.
  3. Download and install the IAR Embedded Workbench for the MSP from here.
  4. Following installation of the IAR Embedded Workbench, the USB mini driver is detected automatically. A yellow light indicates that power is connected.

          For more information please refer to the CC3000 + MSP430 FRAM Hardware Description 

  

FRAMconnection.png

Configuring the HyperTerminal

The HyperTerminal is the interface through which commands are sent to the CC3000 basic Wi-Fi example application. The HyperTerminal connects to the MSP430FRAM board, as shown in the figure below. 


Connecting the HyperTerminal to the Stellaris ICDI Port.png


The figure below shows the HyperTerminal Computer Management window with the MSP430 application UART selected.
MSP430 Application UART Selected in the Content Management Window.png

Baud Rate Configuration

Configure the baud rate as follows (see also the figure below):

  • Bits per second: 115200
  • Data bits: 8
  • Parity: None
  • Stop bits: 1
  • Flow control: None
Baud Rate Configuration.png

ASCII Settings

Configure the HyperTerminal ASCII settings as follows (see also the figure below):

  • ASCII Sending: Echo typed characters locally selected
  • ASCII Receiving: Wrap lines that exceed terminal width selected
HyperTerminal Settings.png


If the configuration is correct, powering up the MSP430FRAM Board displays the HyperTerminal string shown in the figure below. Note that the latest software will display "version 1.13.7.15". 

Hyperterminal-28102012.png


In addition, LED5 turns blue indicates Driver init (see the figure below).

CC3000-HostDriverInit.png


The following figure provides the details about all LEDs used by Basic WiFi application.

MSP-430-Board-BasicWiFiupd.JPG


Evaluation Software User Guide

Within the package is provided an IAR workspace and a binary file that can be burned directly to the FRAM Using MSP430 Flasher and does not require IAR Embedded Workbench to be installed. Please use it if you are not interested in building an application.

Either IAR and CCS compiler can be used to compile the application and burn it onto the board. Please refer to the respective user guide section for the compiler of your choice


Running Basic WiFi Application with IAR

Working with IAR Embedded Workbench will require opening the provided workspace, and compiling and burning it to the board following these instructions:


In order to open a workspace and compile an application by yourself, please follow these steps:

   Open the IAR Embedded Workbench:

  1. Select File → Open → Workspace (see the figure below).
    Opening the IAR Embedded Workbench.png

    The Open Workspace dialog box appears.
  2. Open the CC3000 basic Wi-Fi example application (BasicWiFiApplication_workspace.eww) as shown in the figure below.
    Opening the Example Application.png
    At this step, a workspace will be opened:(see the figure below).
    Example Workspace.png

Project overview:


Project-structure-24102012.png


  3. Build your workspace as follows:

                   i. In the Workspace window, right-click CC3000 Host Driver - Debug to open a menu. From the menu, select Rebuild All to build the CC3000 host driver (see the figure below).
Host-Driver-Rebuild.png

                  ii. In the Workspace window, right-click CC3000Spi - Debug to open a menu. From the menu, select Rebuild All to build the CC3000_Spi (see the figure below).
Spi-Debug-Rebuild.png

               iii. In the Workspace window, right-click HyperTerminalDriver - Debug to open a menu. From the menu, select Rebuild All to build the HyperTerminal driver (see the figure below).
HyperTerminal-Rebuild.png

              iv. In the Workspace window, right-click BasicWiFiApplication-Debug to open a menu. From the menu,select Rebuild All to build the example application (see the figure below).
Basic-WiFi-Rebuild.png

   4. To download and debug the CC3000 basic Wi-Fi example application, click the button (see the figure below).
DownloadAndDebugging251012.jpg

Running Basic WiFi Application with CCS V5

Working with CCS will require opening the provided workspace, and compiling and burning it to the board following these instructions:

In order to open a workspace and compile an application by yourself, please follow these steps:

1.  Open Code Composer Studio v5.

2.  Set the workspace to ..\ Basic WiFi Application\Basic WiFi Application CCS (see the figure below).

Open workspace.png

 3. Select Project->Import Existing CCS/CCE Eclipse Project as shown in the figure below.

Import.png

  4. Select Browse and open Basic WiFi Application Folder as shown in the figure below.

Open.png

   5. Select Select All and Finish as shown in the figure below.

Select.png


 

 6. At this step a workspace will be created:</font>

 
Created.png

 7. Build your workspace as follows:

     i.   In the Workspace window, click CC3000 Host Driver and press the hammer icon in order to build.


Cc3000hostDriver.png

     ii.   In the Workspace window, click CC3000 Spi and press the hammer icon in order to build.


Spi.png

     iii.   In the Workspace window, click Hyper Terminal Driver and press the hammer icon in order to build.


Uart.png

     iv.  In the Workspace window, click Basic WiFi Application and press the hammer icon in order to build.


Basic wifi application.png
 8. To download and debug the CC3000 basic Wi-Fi example application, click the button (see the figure below).
Debug.png


Running the Application

Configuring the Basic Wi-Fi Example Application

The example application demonstrates basic WLAN connectivity together with the capability of sending data over the WLAN transport with the help of the standard BSD socket interface.

General Description

Each HyperTerminal command-line interface (CLI) command used in the basic Wi-Fi example application consists of a minimum of 2 bytes opcode. To execute a command, type the command and press Enter. When command execution completes, DONE appears in the HyperTerminal window (see the figure below). 


CC300-HyperterminalCmdExample.png
Note: The first operation performed is a first-time configuration (see the section Static IP
Configuration).

Before moving to socket-based operations, additional AP and static IP connections must be configured.

The table below lists the supported commands. 

CommandsSummary 04112012.png
 
Each command must be typed as an ASCII string in the HyperTerminal (see figure above). To test the basic connectivity of the CC3000 device with the AP, perform the following steps:
  1. To connect to the AP, execute SmartConfig command (01). If the AP is ready, the device connection is successful.
  2. To configure the IP address of the CC3000 device, execute the IP Configure command (08). This command may define an AP as a default gateway for the CC3000 device.
  3. Connect the PC behind the AP with the same subnet address as that of the AP.
  4. To test connectivity between the CC3000 device and the PC, execute the ping command


Smart Configuration

  • Execute the SmartConfig command (01) from the HyperTerminal.
During the SmartConfig command processing, LED6 on the MSP430 board starts blinking.
When the device finds an AP, the HyperTerminal displays Smart config DONE (see the figure below).
SmartConfig.png

The example application now reboots the CC3000 device. After the reboot, the CC3000 device tries to connect to the AP detected.


  • Following the reboot and as soon as the CC3000 device connects to the AP, LED7 is constantly on.
  • Once CC3000 obtain IP address using DHCP LED8 is constantly on.


Please Note: For the Basic WiFi Application the following parameters need to be set in the iOS\Android application:

  • Device name: home_assistant
  • AES encryption key: smartconfigAES16


For more detailed description on how to perform this step, you may refer to the CC3000 Smart Configuration  wiki page.

For programmers:

/* The function triggers a smart configuration process on CC3000 it exists upon completion of the process. */

void wlan_smart_time_config_start(void);


 From the CC3000 Basic Wi-Fi Example application code:

StartSmartConfig();


Static IP Configuration

The example application supports the configuration of the CC3000 device with a static IP.

To configure the device IP, execute the command 08XXYYZZUUAABBCCDD where:

  • XXYYZZUU is an IP address assigned to the CC3000 device in hexadecimal form. For example, if the required address is 192.168.39.10, the hexadecimal value is c0a8270a. Lower case only is supported.
  • AABBCCDD is an IP address of the default gateway in hexadecimal form as well (which can be an IP address of the AP). The example application assumes that the network mask is 255.255.255.0.

To test connectivity, execute the ping command.


In order to configure DHCP, execute the command with zero value for all fields.


For programmers:

/* aucIP specifies the static IP for configuration. In case of dynamic address, set this value to 0. */ /* aucSubnetMask specifies the static subnet mask address. In case of dynamic address, set this value to 0. */ /* aucDefaultGateway specifies the static Gateway address. In case of dynamic address, set this value to 0. */ /* aucDNSServer specifies the static DNS server address. In case of dynamic address, set this value to 0. */

long netapp_dhcp ( unsigned long * aucIP, unsigned long * aucSubnetMask, unsigned long * aucDefaultGateway, unsigned long * aucDNSServer );

 From the CC3000 Basic Wi-Fi Example application code:

netapp_dhcp((unsigned long *)pucIP_Addr, (unsigned long *)pucSubnetMask, (unsigned long *)pucIP_DefaultGWAddr, (unsigned long *)pucDNS);   where all the parameters are taken from the UART command that was applied.


Open UDP Socket

To open a UDP socket, execute the Socket Open command (03).


For programmers:

/* domain selects the protocol family which will be used for communication. AF_INET is supported. */ /* type specifies the communication semantics. SOCK_STREAM and SOCK_DGRAM, SOCK_RAW are supported. */ /* protocol specifies a particular protocol to be used with the socket. IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are supported. */ /* On success the return value is the socket handle that is used for consequent socket operations. On error, -1 is returned. */

int socket ( long domain , long type , long protocol );


From the CC3000 Basic Wi-Fi Example application code:

ulSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

 


Send UDP Data

To transmit a data packet:

  1. Execute the Socket Open command (03) as described in the section "Open Socket".
  2. Execute the sendto command (04AAX…Y02BCDEFGHIKLMN)

where:

  • AA is the hexadecimal presentation of the length of data. For example, to send 5 bytes, type 05.
  • The field following AA is data. For example, to send the string 12345, type 12345.
  • 02 stands for the family type which is AF_INET and is the only supported
  • BCDE is the hexadecimal presentation of the destination port.
  • FGHIKLMN is the hexadecimal presentation of the destination IP address.


Example:
Send 5 bytes of data (“12345”) to a peer device at 192.168.1.101 port 4444.
Port number = 4444 (0x115c)
IP Address= 192.168.1.101 (0xc0a80165)


04051234502115cc0a80165

Description:

 Opcode  Data length  Data  Family Type  Port number  IP address
    04        05 12345         02       115c   c0a80165


For programmers:

/* sd specifies the socket handle. */ /* buf points to a buffer containing the message to be sent. */ /* len specifies the message size in bytes. Range: 1-1460 bytes . */ /* flags specifies the type of message transmission. On this version, this parameter is not supported. */ /* On success the return value is the number of transmitted bytes. On error, -1 is returned. */

int sendto ( long sd , const void * buf , long len , long flags , const sockaddr * to , socklen_t tolen );

From the CC3000 Basic Wi-Fi Example application code: sendto ( ulSocket , pcData , ulDataLength , 0 , &tSocketAddr , sizeof(sockaddr) );

Where all the parameters are taken from the UART command that was applied.


Receive UDP Data

  1. Execute the Socket Open command (03) as described in Section 6.4, Open Socket.
  2. Execute the bind command (06XXYY) where XXYY is the port in hexadecimal form. For example, if a port is 51000, the value typed is c738.
  3. Execute the Receive Data command (05). The HyperTerminal displays the received data.


For programmers:

/* sd specifies the socket handle. */ /* buf points to the buffer where the message should be stored. */ /* len specifies the length in bytes of the buffer pointed to by the buffer argument. Range: 1-1460 bytes. */ /* flag specifies the type of message reception. On this version, this parameter is not supported. */ /* len specifies the length in bytes of the buffer pointed to by the buffer argument. Range: 1-1460 bytes. */ /* from is a pointer to an address structure indicating the source address: sockaddr. */ /* On success the return return the number of bytes received. On error, -1 is returned. 0 if timeout occurred. */

int recvfrom ( long sd , void * buf , long len , long flags , sockaddr * from , socklen_t * fromlen );

From the CC3000 Basic Wi-Fi Example application code:

recvfrom ( ulSocket , pucCC3000_Rx_Buffer , CC3000_RX_BUFFER_SIZE , 0 , &tSocketAddr, &tRxPacketLength );

Where all the parameters are taken from the UART command that was applied.

Close Socket

To close a UDP socket, execute the Socket Close command (07).

For programmers:

/* sd specifies the socket handle . */ /* On success, zero is returned. On error, -1 is returned. */

closesocket ( long sd );

From the CC3000 Basic Wi-Fi Example application code:

closesocket( ulSocket ); Where ulSocket specifies the socket handle we request to close.


Connect to AP

Note: The Connect-to-AP command is for advanced users. 

To connect to the AP manually (that is, not during the simple configuration process), execute the command 02XA...D where:

  • X is the SSID name length in hexadecimal presentation (for hex presentation use small letters)
  • A...D is the SSID name length


For programmers:

/* sec_type - selects the security options: WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2. */ /* ssid specifies the SSID of the AP, up to 32 bytes and is ASCII. */ /* ssid_len specifies the length of the SSID. */ /* bssid specifies the SSID, up to 6 bytes. */ /* key specifies the key, up to 16 bytes. */ /* key_len specifies the key length. */ /* sec_type selects the security options: WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2. */ /* On success, zero is returned. On error, negative is returned. Note that even though a zero is returned on success to trigger connection operation, it does not mean that CCC3000 is already connected.

An asynchronous "Connected" event is generated upon the finish of connection process. */

long wlan_connect ( unsigned long ulSecType , char * ssid , long ssid_len , unsigned char * bssid , unsigned char * key , long key_len );

From the CC3000 Basic Wi-Fi Example application code:

wlan_connect( 0 , pcSsid , ulSsidLen , NULL , NULL , 0 ) ;

Where all the parameters are taken from the UART command that was applied.



Disconnect from AP

To disconnect the CC3000 device from the AP, execute the CC3000 Disconnect command (09).

Note: By default, the CC3000 device tries to reconnect to the AP automatically as programmed by the Simple Configuration process within the Example Application. To disconnect without reconnecting, the user 
 must remove the policy as described in the section ''Delete Policy''. 

For programmers:

/* On success the return value is 0. For any other value returned other - already disconnected. */

long wlan_disconnect ( void );


From the CC3000 Basic Wi-Fi Example application code: wlan_disconnect();

Delete Policy

Note: The Delete Policy command (0a) is for advanced users. 

To delete the policy of automatic connection to the AP (as programmed by the Simple Configuration process), execute the CC3000 Delete Policy command (0a). After the following reset, automatic reconnection to the AP is not attempted.


For programmers:

/* should_connect_to_open_ap specifies if to connect to any available AP. enable =1 , disable = 0. */ /* should_use_fast_connect specifies if to connect to the last connected AP or not. enable =1 , disable = 0 . */ /* auto_start specifies if to perform auto connect after reset and periodically reconnect if needed. enable =1 , disable = 0. */ /* On success zero is returned. On error, -1 is returned. */

long wlan_ioctl_set_connection_policy ( unsigned long should_connect_to_open_ap , unsigned long should_use_fast_connect , unsigned long ulUseProfiles ) ;

From the CC3000 Basic Wi-Fi Example application code:

wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE);
Where the first parameter disable connection the any available AP, the second parameter dissable fast connect and the last parameter disable auto connect after reset.


Send mDNS Advertizement

Note: The Send mDNS Advertizement command (0b) is for advanced users. 

This command sending mDNS Query packet with the data predefined in Basic WiFi application.

For programmers:

/**

* \Set CC3000 in mDNS advertiser mode in order to advertise itself
* 
* This function is used to make the CC3000 seen by mDNS browsers
* \param[in] mdnsEnabled flag to enable/disable the mDNS feature
* \param[in] deviceServiceName the service name as part of the published canonical domain 
name
* \param[in] deviceServiceNameLength the length of the service name
* \return On success, zero is returned, return SOC_ERROR if socket was not opened successfully, 
* or if an error occurred.
*
* \sa 
* \note 
* \warning 
*/

int mdnsAdvertiser(unsigned short mdnsEnabled,

char * deviceServiceName, 
unsigned short deviceServiceNameLength)

 


For more information please refer to our CC3000 mDNS wiki page.

Additional Resources

Related Wiki pages


Site Map


Archives