WiFi DipCortex / CC3000 Demo - Contains a menu driven set of tests to initalise and control the CC3000 radio. Also allowing you to test various TCP and UDP connections.

Dependencies:   NTPClient WebSocketClient cc3000_hostdriver_mbedsocket mbed HTTPClient

http://www.soldersplash.co.uk/products/wifi-dipcortex/

Please Note, this example uses the serial port so you will need an external RS232 TTL to USB adapter.

Files at this revision

API Documentation at this revision

Comitter:
SolderSplashLabs
Date:
Mon Oct 07 21:18:18 2013 +0000
Child:
1:18644f239f30
Commit message:
First commit, work in progress

Changed in this revision

NTPClient.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
wifi.cpp Show annotated file Show diff for this revision Revisions of this file
wifi.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NTPClient.lib	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NTPClient/#76d570815832
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cc3000_hostdriver_mbedsocket.lib	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/SolderSplashLabs/code/cc3000_hostdriver_mbedsocket/#e62d7252401e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,609 @@
+ 
+#include "mbed.h"
+#include "cc3000.h"
+
+#include "Websocket.h"
+#include "wifi.h"
+
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+
+#include "UDPSocket.h"
+
+#include "NTPClient.h"
+#include "main.h"
+
+using namespace mbed_cc3000;
+
+// TODO : List internal varibles & CC3000 buffers
+// AP point scanning
+// List open sockets
+// Overkill mode 2 TCP 2 UDP echo ports?
+
+#define SERIAL_BAUD_RATE    115200
+Serial pc(p19, p20);
+extern cc3000 wifi;
+//Serial pc(USBTX, USBRX);
+
+const char* ECHO_SERVER_ADDRESS = "192.168.0.10";
+const int ECHO_SERVER_PORT_TCP = 80;
+const int ECHO_SERVER_PORT_UDP = 81;
+uint8_t *HostToPing = (uint8_t *)"google.com";
+char hello[] = "Hello World\r\n";
+const char WEB_SOCKET_URL[] = {"ws://sockets.mbed.org/ws/SolderSplashLabs/wo"};
+
+typedef enum MENU_LEVEL
+{
+    MENU_TOP = 0,
+    MENU_CONNECTION,
+    MENU_TCP,
+    MENU_UDP    
+} MENU_LEVEL;
+
+MENU_LEVEL currentMenu = MENU_TOP;
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Resolve a hostname and ping it
+*/
+// ------------------------------------------------------------------------------------------------------------
+void PingTest ( void )
+{
+uint32_t ip;
+int32_t resolveRetCode = 0;
+    
+    printf("Get an IP address for %s\r\n",HostToPing);
+    resolveRetCode = wifi._socket.gethostbyname(HostToPing,strlen((const char *)HostToPing), &ip);
+    printf("gethostbyname Returned code : %i \r\n", resolveRetCode);
+    
+    if (resolveRetCode > -1) 
+    {
+        uint8_t add0 = (ip >> 24);
+        uint8_t add1 = (ip >> 16);
+        uint8_t add2 = (ip >> 8);
+        uint8_t add3 = (ip >> 0);
+        printf("IP address of %s: %d.%d.%d.%d \r\n", HostToPing, add0, add1, add2, add3);
+        
+        printf("Sending ping\r\n");
+        uint32_t reply_count = wifi.ping(ip, 5, 500, 32);
+        printf("Received %d replies\r\n", reply_count);
+        printf("Ping complete.\r\n");
+    } 
+    else 
+    {
+        printf("Failed to resolve\r\n");
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Test the NTP library
+*/
+// ------------------------------------------------------------------------------------------------------------
+void NtpTest ( void )
+{
+NTPClient ntp;
+
+    if (ntp.setTime("0.pool.ntp.org",123,10000) == 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("NTP Update Failed\r\n");
+    } 
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Open a WebSocket, send string a string
+*/
+// ------------------------------------------------------------------------------------------------------------
+void WebSocketTest ( void )
+{
+int res = 0;
+uint32_t counter = 0;
+
+    Websocket ws((char *)WEB_SOCKET_URL);
+    if ( ws.connect() )
+    {
+        printf("Connected to websocket server.\r\n");
+        
+        printf("\r\n!! Press any key to stop sending !!\r\n\r\n");
+        while (1)
+        {   
+            counter ++;
+            res = ws.send("WiFi DipCortex / CC3000 - Says Hello");
+            printf("%05d : Websocket send returned : %d.\r\n", counter, res);
+        
+            if ( -1 == res ) break;
+            
+            wait_ms(1000);
+            
+            if ( pc.readable() )
+            {
+                pc.getc();
+                break;
+            }
+        }
+        
+        ws.close();
+        printf("Websocket Closed \r\n");
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Open a TCP port send a string and wait for a reply
+*/
+// ------------------------------------------------------------------------------------------------------------
+void TcpClientTest ( void )
+{
+uint16_t counter = 0;
+TCPSocketConnection socket;
+char buf[256];
+int n = 0;
+        
+    if (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT_TCP) < 0) 
+    {
+        printf("Unable to connect to (%s) on port (%d)\r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT_TCP);
+    }
+    else
+    {
+        // Block for 1 second
+        socket.set_blocking( true, 1000 );
+        
+        printf("\r\n!! Press any key to stop sending !!\r\n\r\n");
+        while (1)
+        {   
+            counter ++;
+        
+            n = socket.send_all(hello, sizeof(hello) - 1);
+            
+            if ( n > 0 )
+            {
+                printf("%05d : TCP Socket Sent : Hello World\r\n", counter);
+            }
+            else
+            {
+                printf("Failed to send\r\n");
+                break;
+            }
+     
+            n = socket.receive(buf, 256);
+            
+            if ( n > 0 )
+            {
+                printf("TCP Socket Recv'd : %s \r\n", buf);
+                buf[n] = '\0';
+            }
+            else
+            {
+                buf[0] = '\0';
+                printf("Failed to Recv\r\n");
+                break;
+            }
+            
+            wait_ms(250);
+            
+            // Should we stop?
+            if ( pc.readable() )
+            {
+                pc.getc();
+                break;
+            }
+        }
+        socket.close();
+        printf("Completed.\r\n");
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Opens a sockets to listen for connections
+*/
+// ------------------------------------------------------------------------------------------------------------
+void TcpServerTest ( void )
+{
+int32_t status;
+char buffer[256];
+TCPSocketServer server;
+TCPSocketConnection client;
+    
+    server.bind(15000);
+    server.listen();
+    while (1) 
+    {
+        status = server.accept(client);
+        if (status >= 0) 
+        {
+            client.set_blocking(false, 1500); // Timeout after (1.5)s
+            printf("Connection from: %s \r\n", client.get_address());
+            char buffer[256];
+            //client.receive(buffer, sizeof(buffer));
+            //printf("Received: %s \r\n",buffer);
+            printf("Sending the message to the server. \r\n");
+            client.send_all(hello, sizeof(hello));
+            client.close();
+        }
+        
+        // Should we stop?
+        if ( pc.readable() )
+        {
+            pc.getc();
+            break;
+        }
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Send a UDP Packet, wait for response
+*/
+// ------------------------------------------------------------------------------------------------------------
+void UdpClientTest ( void )
+{
+UDPSocket socket;
+char buf[256];
+int n = 0;
+Endpoint outEndpoint;
+Endpoint inEndpoint;
+
+    if (0 == socket.bind(ECHO_SERVER_PORT_UDP) )
+    {
+        
+        // 2 second timeout
+        socket.set_blocking(false, 2000);
+    
+        while (1)
+        {
+            if( outEndpoint.set_address(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT_UDP) < 0 )
+            {
+                printf("Failed to set endpoint address.\r\n");
+                break;
+            }
+            else if ( socket.sendTo( outEndpoint, hello, sizeof(hello) ) < 0 )
+            {
+                printf("Failed to send the packet.\r\n");
+            }
+            else
+            {
+                // Message sent, recv reply
+                printf("UDP Socket Sent : %s \r\n", hello);   
+                n = socket.receiveFrom( inEndpoint, buf, sizeof(buf) );
+                if ( n < 0 )
+                {
+                    printf("Failed to recv the UDP packet.\r\n");
+                }
+                else
+                {
+                    buf[n] = '\0';
+                    printf("UDP Socket Recv'd : %s \r\n", buf);    
+                }
+            }
+    
+            // Should we stop?
+            if ( pc.readable() )
+            {
+                pc.getc();
+                break;
+            }
+        }
+        
+        socket.close();
+    }
+    else
+    {
+        // Failed to bind to the socket
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Listen on a UDP port for messages
+*/
+// ------------------------------------------------------------------------------------------------------------
+void UdpServerTest ( void )
+{
+UDPSocket socket;
+Endpoint client;
+char buffer[256];
+int n = 0;
+
+    if (0 == socket.bind(ECHO_SERVER_PORT_UDP) )
+    {   
+        while (true) 
+        {
+            printf("Waiting for packet...\r\n");
+            n = socket.receiveFrom(client, buffer, sizeof(buffer));
+        
+            printf("Received packet from: %s\n", client.get_address());
+            socket.sendTo(client, buffer, n);
+        
+            // Should we stop?
+            if ( pc.readable() )
+            {
+                pc.getc();
+                break;
+            }
+        }
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Print menu header
+*/
+// ------------------------------------------------------------------------------------------------------------
+void Menu_PrintHeader ( void )
+{
+tNetappIpconfigRetArgs ipinfo;
+
+    if ( wifi.is_dhcp_configured() ) 
+    {
+        wifi.get_ip_config(&ipinfo);
+    }
+    
+    printf("\r\n");
+    printf("+-------------------------------------------+\r\n");
+    printf("|   WiFi DipCortex / CC3000 Kitchen Sink    |\r\n");
+    printf("+-------------------------------------------+\r\n");
+    if ( wifi.is_dhcp_configured() ) 
+    {
+        printf("|   SSID : %-33s|\r\n", ipinfo.uaSSID);
+        printf("|   IP : %d.%d.%d.%d                        |\r\n", ipinfo.aucIP[3], ipinfo.aucIP[2], ipinfo.aucIP[1], ipinfo.aucIP[0]);   
+    }
+    else
+    {
+        printf("|   Not Connected                           |\r\n");   
+    }
+    printf("+-------------------------------------------+\r\n");
+    printf("\r\n");
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Control the wifi connection
+*/
+// ------------------------------------------------------------------------------------------------------------
+char WaitForSerialCommand ( void )
+{
+char charIn = 0;
+char prevCharIn;
+
+    while (1)
+    {
+        prevCharIn = charIn;
+        charIn = pc.getc();
+        printf("%c", charIn);
+        if ((charIn == '\n') || (charIn == '\r'))
+        {
+            break;
+        }
+    }
+    
+    return ( prevCharIn );
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Control the wifi connection
+*/
+// ------------------------------------------------------------------------------------------------------------
+void Menu_ConnectionControl ( void )
+{
+    Menu_PrintHeader();
+    printf(" 1 - Enable auto connect to any previous access point\r\n");
+    printf(" 2 - Disable auto connect \r\n");
+    printf(" 3 - Connect to %s \r\n", SSID);
+    printf(" 4 - Disconnect \r\n");
+    printf(" 5 - Get Status \r\n");
+    printf(" x - Top Menu \r\n");
+    
+    printf("\r\n");
+    printf("Enter command character : ");
+        
+    switch(WaitForSerialCommand()) 
+    {
+        case '1':      
+            wifi._wlan.ioctl_set_connection_policy(0, 1, 1);
+        break;
+        
+        case '2':      
+            wifi._wlan.ioctl_set_connection_policy(0, 0, 0);
+        break;
+        
+        case '3':      
+            if ( AP_SECURITY == NONE )
+            {
+                connect_to_ssid((uint8_t *)SSID);
+            }
+            else
+            {
+                connect_to_ssid(SSID,AP_KEY,AP_SECURITY);
+            }      
+        break;
+        
+        case '4' :
+            wifi.disconnect();
+        break;
+        
+        case '5' :
+            print_cc3000_info();
+        break;
+        
+        case 'x':      
+            currentMenu = MENU_TOP;
+        break;
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief 
+*/
+// ------------------------------------------------------------------------------------------------------------
+void Menu_UdpControl ( void )
+{
+    Menu_PrintHeader();
+
+    printf(" 1 - UDP Client, Connect to %s:%d\r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT_UDP);
+    printf(" 2 - UDP Server \r\n");
+    printf(" 3 - NTP Client \r\n");
+    printf(" x - Exit to top menu \r\n");
+    
+    printf("\r\n");
+    printf("Enter command character : ");
+    
+    switch(WaitForSerialCommand())  
+    {
+        case '1':      
+            UdpClientTest();
+        break;
+        case '2':      
+            UdpServerTest();
+        break;
+        case '3':      
+            NtpTest();
+        break;
+        case 'x':      
+            currentMenu = MENU_TOP;
+        break;
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief 
+*/
+// ------------------------------------------------------------------------------------------------------------
+void Menu_TcpControl ( void )
+{
+    Menu_PrintHeader();
+
+    printf(" 1 - TCP Client, Connect to %s:%d\r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT_TCP);
+    printf(" 2 - TCP Server, listen on port\r\n", ECHO_SERVER_PORT_TCP);
+    printf(" 3 - Web Socket Write \r\n");
+    printf(" 4 - Web Socket Read \r\n");
+    printf(" x - Exit to top menu ");
+    printf("\r\n");
+    printf("Enter command character : ");
+    
+    switch(WaitForSerialCommand()) 
+    {
+        case '1':      
+            TcpClientTest();
+        break;
+        case '2':      
+            TcpServerTest();
+        break;
+        case '3':      
+            WebSocketTest();
+        break;
+        case 'x':      
+            currentMenu = MENU_TOP;
+        break;
+    }
+}
+
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Display a menu to the user
+*/
+// ------------------------------------------------------------------------------------------------------------
+void Menu_Top ( void )
+{
+    Menu_PrintHeader();
+    
+    printf(" 1 - Connection control menu \r\n" );
+    printf(" 2 - TCP test menu \r\n" );
+    printf(" 3 - UDP test menu \r\n" );
+    printf(" 4 - Connection status \r\n");
+    printf(" 5 - Ping - %s \r\n", HostToPing);
+    
+    printf("\r\n");
+    printf("Enter command character : ");
+ 
+    switch(WaitForSerialCommand()) 
+    {
+        case '1':      
+            currentMenu = MENU_CONNECTION;
+        break;
+        case '2':      
+            currentMenu = MENU_TCP;
+        break;
+        case '3':      
+            currentMenu = MENU_UDP;
+        break;
+        case '4':      
+            print_cc3000_info();
+        break;
+        case '5':      
+            PingTest();
+        break;
+        case 'x':      
+            currentMenu = MENU_TOP;
+        break;
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief Pick which menu to display
+*/
+// ------------------------------------------------------------------------------------------------------------
+void MenuSwitch ( void )
+{
+bool connected = false;
+
+    if ( wifi.is_dhcp_configured() )
+    {
+        connected = true;
+    }
+    
+    switch ( currentMenu )
+    {
+        case MENU_TOP :
+            if (connected) Menu_Top();
+        break;
+        
+        case MENU_CONNECTION :
+            Menu_ConnectionControl();
+        break;
+        
+        case MENU_TCP :
+            if (connected) Menu_TcpControl();
+        break;
+        
+        case MENU_UDP :
+            if (connected) Menu_UdpControl();
+        break;
+        
+        default :
+            printf("Unknown command\r\n");
+        break;
+    }
+}
+
+// ------------------------------------------------------------------------------------------------------------
+/*!
+    @brief main loop
+*/
+// ------------------------------------------------------------------------------------------------------------
+int main( void ) 
+{   
+    // Initalise the WiFi Module
+    init(); 
+    pc.baud(SERIAL_BAUD_RATE);
+
+    wifi.start(0);
+
+    while (1)
+    {
+        MenuSwitch();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,7 @@
+
+#ifndef MAIN_H
+#define MAIN_H
+
+extern cc3000 wifi;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wifi.cpp	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,184 @@
+#include "mbed.h"
+#include "cc3000.h"
+#include "wifi.h"
+
+using namespace mbed_cc3000;
+
+tUserFS user_info;
+const char * WIFI_STATUS[] = {"Disconnected", "Scanning", "Connecting", "Connected"};
+
+/* cc3000 module declaration specific for user's board. Check also init() */
+#if (MY_BOARD == WIGO)
+cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), PORTA_IRQn);
+#elif (MY_BOARD == WIFI_DIPCORTEX)
+cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), PIN_INT0_IRQn);
+#else
+
+#endif
+
+#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
+  const uint8_t smartconfigkey[] = {0x73,0x6d,0x61,0x72,0x74,0x63,0x6f,0x6e,0x66,0x69,0x67,0x41,0x45,0x53,0x31,0x36};
+#else
+  const uint8_t smartconfigkey = 0;
+#endif
+
+#if (MY_BOARD == WIGO)
+
+#include "NVIC_set_all_priorities.h"
+
+/**
+ *  \brief Wi-Go initialization
+ *  \param none
+ *  \return none
+ */
+void init() {
+    DigitalOut PWR_EN1(PTB2);
+    DigitalOut PWR_EN2(PTB3);
+
+    // Wi-Go set current to 500mA since we're turning on the Wi-Fi
+    PWR_EN1 = 0;
+    PWR_EN2 = 1;
+
+    NVIC_set_all_irq_priorities(3);
+    NVIC_SetPriority(SPI0_IRQn, 0x0);     // Wi-Fi SPI interrupt must be higher priority than SysTick
+    NVIC_SetPriority(PORTA_IRQn, 0x1);
+    NVIC_SetPriority(SysTick_IRQn, 0x2);  // SysTick set to lower priority than Wi-Fi SPI bus interrupt
+    PORTA->PCR[16] |=PORT_PCR_ISF_MASK;
+    PORTA->ISFR |= (1<<16);
+}
+
+#elif (MY_BOARD == WIFI_DIPCORTEX)
+
+/**
+ *  \brief Wifi DipCortex initialization
+ *  \param none
+ *  \return none
+ */
+void init() 
+{
+    NVIC_SetPriority(SSP1_IRQn, 0x0); 
+    NVIC_SetPriority(PIN_INT0_IRQn, 0x1);
+    
+    // SysTick set to lower priority than Wi-Fi SPI bus interrupt
+    NVIC_SetPriority(SysTick_IRQn, 0x2); 
+}
+
+#else
+
+/**
+ *  \brief Place here init routine for your board
+ *  \param none
+ *  \return none
+ */
+void init() {
+
+}
+
+#endif
+
+
+
+
+
+/**
+ *  \brief Print cc3000 information
+ *  \param none
+ *  \return none
+ */
+void print_cc3000_info() {
+uint8_t myMAC[8];
+uint8_t buffer[2];
+int32_t status = 0;
+tNetappIpconfigRetArgs ipinfo2;
+
+    wifi.get_user_file_info((uint8_t *)&user_info, sizeof(user_info));
+    wifi.get_mac_address(myMAC);
+    printf(" MAC address : %02x:%02x:%02x:%02x:%02x:%02x\r\n", myMAC[0], myMAC[1], myMAC[2], myMAC[3], myMAC[4], myMAC[5]);
+    
+    if (! wifi._nvmem.read_sp_version( (unsigned char*)&buffer ) )
+    {
+        printf(" CC3000 Firmware Version : %u.%u \r\n", buffer[0], buffer[1]);
+    }
+    else
+    {
+        printf(" CC3000 Read nvmem failed!");
+    }
+    
+    status = wifi._wlan.ioctl_statusget();
+    if (( status > -1 ) && ( status < 4 ))
+    {
+        printf(" Wifi Status    : %s\r\n", WIFI_STATUS[status]);
+    }
+    else
+    {
+        printf(" Wifi Status    : %d\r\n", status);
+    }
+    
+    if ( wifi.is_dhcp_configured() ) 
+    {
+        wifi.get_ip_config(&ipinfo2);
+        printf(" Connected to   : %s \r\n", ipinfo2.uaSSID);
+        printf(" IP             : %d.%d.%d.%d \r\n", ipinfo2.aucIP[3], ipinfo2.aucIP[2], ipinfo2.aucIP[1], ipinfo2.aucIP[0]);   
+        printf(" Gateway        : %d.%d.%d.%d \r\n", ipinfo2.aucDefaultGateway[3], ipinfo2.aucDefaultGateway[2], ipinfo2.aucDefaultGateway[1], ipinfo2.aucDefaultGateway[0]);  
+        printf(" Subnet         : %d.%d.%d.%d \r\n", ipinfo2.aucSubnetMask[3], ipinfo2.aucSubnetMask[2], ipinfo2.aucSubnetMask[1], ipinfo2.aucSubnetMask[0]);  
+        printf(" DNS            : %d.%d.%d.%d \r\n", ipinfo2.aucDNSServer[3], ipinfo2.aucDNSServer[2], ipinfo2.aucDNSServer[1], ipinfo2.aucDNSServer[0]);  
+    }
+    else
+    {
+         printf(" Not connected \r\n");
+    }
+
+    // This doesn't work for the wifi dip
+    printf(" FTC        %i\r\n",user_info.FTC);
+    printf(" PP_version %i.%i\r\n",user_info.PP_version[0], user_info.PP_version[1]);
+    printf(" SERV_PACK  %i.%i\r\n",user_info.SERV_PACK[0], user_info.SERV_PACK[1]);
+    printf(" DRV_VER    %i.%i.%i\r\n",user_info.DRV_VER[0], user_info.DRV_VER[1], user_info.DRV_VER[2]);
+    printf(" FW_VER     %i.%i.%i\r\n",user_info.FW_VER[0], user_info.FW_VER[1], user_info.FW_VER[2]);
+}
+
+/**
+ *  \brief Connect to SSID with a timeout
+ *  \param ssid     Name of SSID
+ *  \param key      Password
+ *  \param sec_mode Security mode
+ *  \return none
+ */
+void connect_to_ssid(char *ssid, char *key, unsigned char sec_mode) {
+    printf("Connecting to SSID: %s. Timeout is 10s.\n",ssid);
+    if (wifi.connect_to_AP((uint8_t *)ssid, (uint8_t *)key, sec_mode) == true) {
+        printf(" Connected\r\n");
+    } else {
+        printf(" Connection timed-out (error). Please restart.\r\n");
+        while(1);
+  }
+}
+
+/**
+ *  \brief Connect to SSID without security
+ *  \param ssid Name of SSID
+ *  \return none
+ */
+void connect_to_ssid(uint8_t *ssid) {
+    wifi.connect_open((uint8_t *)ssid);
+}
+
+/**
+ *  \brief First time configuration
+ *  \param none
+ *  \return none
+ */
+void do_FTC(void) 
+{
+/*
+    printf("Running First Time Configuration\r\n");
+    wifi.start_smart_config(smartconfigkey);
+    while (wifi.is_dhcp_configured() == false) {
+         wait_ms(500);
+         printf("Waiting for dhcp to be set.\r\n");
+    }
+    user_info.FTC = 1;
+    wifi.set_user_file_info((uint8_t *)&user_info, sizeof(user_info));
+    wifi._wlan.stop();
+    printf("FTC finished.\r\n");
+*/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wifi.h	Mon Oct 07 21:18:18 2013 +0000
@@ -0,0 +1,46 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef WIFI_H
+#define WIFI_H
+
+#include "cc3000.h"
+
+#define WIGO           1
+#define WIFI_DIPCORTEX 2
+#define UNDEFINED      3
+
+#define MY_BOARD WIFI_DIPCORTEX
+
+// use this defines in AP_SECURITY 
+#define NONE 0
+#define WEP  1
+#define WPA  2
+#define WPA2 3
+
+// use smart config
+#define USE_SMART_CONFIG    0
+
+ // Default SSID Settings
+ #define SSID            "soldersplash"
+#define AP_KEY          "wifidipcortex"
+#define AP_SECURITY     WPA2 
+
+void init();
+void connect_to_ssid(uint8_t *ssid);
+void connect_to_ssid(char *ssid, char *key, unsigned char sec_mode);
+void print_cc3000_info();
+
+#endif