Smart Config Application development information - Java Applet

From Texas Instruments Wiki
Jump to: navigation, search

Overview

TI provides Smart Config example application for Web browsers.

This application is the configuring side in the process of connecting a CC3000 device to a specific AP using the Smart Config feature.

This application runs the Java Script which uses specific API from a binary library file.

Source code is available for download from here , and includes the java script files and the binary library.

For a real time Smart Config Java demo on the www.ti.com web site click here

In order to develop similar application for your product, please use the following sections in this wiki page to understand which are the APIs provided, and the correct way to use them.


It is highly recommended to use the Smart Config application example, and complete a full Smart config process before continuing any further.

For further details regarding the Smart Config process please refer to our Smart Config wiki page.


 

Limitations:


1. SSID and Gateway are detected automatically only with Win7 and Linux. For other OS please apply these parameters manually.

2. Connection via wireless interface is required.

3. The configuring wireless device MUST NOT be connected via MIMO, as CC3000 will not be able to connect. Instead of changing

    AP's configuration, it is possible to limit the configuring device to 11g only.

4. MTU minimal size must be set to 1500.  

5. Supported browsers: Internet Explorer, Chrome and Firefox.

    MTU size is the maximum packet size supported in your PC. Most PCs are set by default to 1500 bytes, and work well with      

    Smart Config. If MTU size in your PC is set to a value lower than 1500, you will receive the  following error message:            

    "MTU is too small. Please increase MTU to at least 1500 bytes". Setting MTU size:

  • Win7 - netsh interface ipv4 set subinterface "Interface name" mtu=1500 store=persistent
  • Win XP - modify the TCP/IP parameters for the adapter in Windows Registry
  • Linux -    ifconfig wlan0 mtu 1500



 

Application Description

Smart Config Application is used in order to configure a CC3000 device to connect to a specific network.

In order to perform the above, SSID and IP address of the designated network are required.

The application sends configuration packets to the CC3000 device according to the network characteristic (IP, SSID, security type).

The application can send the configuration packets with or without AES encryption.

The device which runs the web brower application has to be connected to the same network that the CC3000 is about to connect to.

  Win7 and Linux - the application retrieves the SSID and IP gateway according to the network the device is currently connected to, and uses this information to configure the remote device.

  Other OS - SSID and IP should be entered by the user in the appropriate fields. 

The application will continue sending the configuration packets until an acknowledgment packet will be received from the CC3000 device.


Please use the following flow chart in order to understand the application operation:

AppletFlow.PNG
 


Using the SmartConfig library

In order to use the library it is necessary to import it to the project.

The library exports the FirstTimeConfig class.

In order to use the FirstTimeConfig class you just need to:

 1.  Implement onSmartConfigConnect to handle each one of the events: FTC_SUCCESS, FTC_ERROR, FTC_TIMEOUT

 2.  Create a new applet instance

 3.  Retrieve SSID and IP address and set them as the applet parameters

 4.  Call startTransmitting() with network parameters, which opens a new library thread and returns immediately


At this point one of the following could happen:

  •  The App decides to stop the smartConfig, so it calls stopTransmitting()

     When this method returns, the library thread has already been stopped by the library itself, so no further transmission is occurring

  •  ACK is received, so the library calls the listener's FtcEvent method with FTC_SUCCESS parameter, within the library thread.

    The library thread also stops transmitting, and the thread is stopped

  • The defined timeout is reached, so the library calls the listener's FtcEvent method with FTC_TIMEOUT parameter, within the library thread.

    The library thread also stops transmitting, and the thread is stopped

  • An error occurs. The library calls the listener's FtcEvent method with FTC_ERROR parameter within the library thread.

    The library thread also stops transmitting, and the thread is stopped


Please Note:

  • onSmartConfigConnect() should be implemented in order to handle each one of the events: FTC_SUCCESS, FTC_TIMEOUT or FTC_ERROR (See example code).


First Time Config Class

Create a new applet instance

applet = document.applets[0];


Retrieve network parameters

This method is used in order to retrieve a network parameter which was found by the lib (Win7 and Linux) automatically, or entered by the user manually.

This is done in order to check for proper functionality with no limitations (is interface wireless, is MTU not too small, is transmition is on 5G...)

This API should be called for every network parameter needed: interfaceName, SSID, default gateway, MTU, 5GHz.

/* *parameter - The parameter to request */
/* *arg1 - user defined argument */
/* return - string result of the request */
 
public String getNetworkParameter(final String parameter, final String arg1)
 

Start transmiting

This method begins the transmission of the configuration packets. The API parameters retrieved either from the lib (Win7 and Linux - auto detection of SSID and default gateway) or by the user.

/* interfaceName - The interface to transmit on */
/* ssid - The Wi-Fi network name which you wish to configure */
/* gatewayIpAddress - The gateway ip address */
/* password - The Wi-Fi key which you wish to configure */
/* encryptionKey - A key used by the protocol to encrypt the Wi-Fi key. (Must be shared with the target device) */
/* ackString - The acknowledgment string which the target device is expected to send (over mDNS) after successful configuration (default "CC3000", must match the target device settings) */
 
public void startTransmitting(final String interfaceName, final String ssid, final String gatewayIpAddress, final String password, final String encryptionKey, final String ackString)

StopTransmitting

This method stops sending the configuration packets to the remote device.

public void stopTransmitting()