Port from Avnet's Internet Of Things full WiGo demo: SmartConfig - WebServer - Exosite - Android sensor Fusion App

Dependencies:   NVIC_set_all_priorities mbed cc3000_hostdriver_mbedsocket TEMT6200 TSI Wi-Go_eCompass_Lib_V3 WiGo_BattCharger

Wi-Go Reference Design Overview


For additional information on Wi-Go, please visit http://www.em.avnet.com/wi-go
For additional information on Freescale eCompass, please visit
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=E-Compass
Ported from Avnet's Wi-Go KEIL code.
Special thanks to Jim Carver from Avnet for providing the Wi-Go board and for his assistance.


Multiple Wi-Fi applications are provided within the latest version of Wi-Go software:

  • SmartConfig App for auto-setup of Wi-Go network parameters.
  • WebServer display of live sensor data.
  • Exosite portal sensor data feed by Wi-Go.
  • Freescale's Sensor Fusion App data feed by Wi-Go.

Wi-Go is intended for "untethered" portable operation (using it's high-capacity Lithium-Polymer battery). The serial terminal text interface is only required for initial setup, thereafter selection of an application from those available is via finger position on the Touch Slider during the initial 6 second startup period.

Running the Wi-Go Demo Suite

Warning

The on-board Firmware must be updated to mbed enable a Wi-Go system.
Goto the Component page to get the FirmwareUpdate tool (scroll down to the FirmwareUpdate topic).

MAG3110 sensor and eCompass Calibration!

As with the other sensor applications, the eCompass function requires quality calibration data to achieve best accuracy.
For the first 15 seconds after power-up it is recommended that "Figure 8" movements with Wi-Go be done in a smooth, repetitive pattern. Don't touch the slider pad during calibration.

Startup
The RGB LED blinks in a GREEN-ORANGE sequence to inform the user the module is waiting for input.
The RGB LED color designates which of the following Apps to launch.

RGB LED ColorApplication to Launch
OrangeErase all wireless profiles
PurpleSmartConfig
BlueWebServer
RedExosite Data Client
GreenAndroid Server

Swipe your index finger across the slider pad, the RGB LED color will change at approximately 20% intervals.
Removing your finger latches the last color displayed. After about 3 seconds, the selected app will start.
Another app can be selected when the slider pad is touched again within the 3 seconds timeout.

After launch of Exosite or Android Server Apps, the eCompass function then controls the RGB LED.
(not in WebServer mode where RGB LEDs are manually controlled by the User).

RGB LED ColorDirection Indication
BlueNear to North
GreenNorth
RedEast / West
PurpleSouth

__Note!__ The D1, D2 and D3 User LEDs on Wi-Go adhere to the following convention for the different Apps

User LED#Description of function controlling the LED
D1is the board heartbeat, derived from the timer interrupt
D2indicates network activity as follows:
Web Server Wi-Go webpage is being served.
Exosite Client Wi-Go is sending data.
Android App Wi-Go is sending data
D3WLAN Network is Connected

Detail of Wi-Go Applications

App #1: SmartConfig
See TI's pages on how to use the SmartConfig tool:

  • Preferred method : Configuration using the SmartConfig tool
  • SmartConfig download: Smart Config and Home Automation
    • iOS app : available at Apple app store.
    • Android app : download and install the Android SmartConfig Application on a PC.
      This file contains the source code as well as the compiled APK file.
      The APK file is stored in ti\CC3000AndroidApp\SmartConfigCC3X\bin.

App #2: WebServer display of live sensor data
__Note!__
When using the WebServer for the first time on a Wi-Fi network you will need to determine the IP address that's assigned to Wi-Go by the DHCP Server. To do this, it is recommended you use one of the following two methods:

  • While Wi-Go is initially tethered to a laptop via USB, launch of the WebServer Application and note the IP address that is reported on the terminal screen immediately after selection of this App.
  • Alternatively, use a 3rd party LAN SCAN type tool to view Wi-Go's IP address.
    eg. FING, - available for free download from Google Play or iTunes App Stores…

Wi-Go's WebServer Application is selected as follows:

  • Press RESET, followed by the eCompass Calibration (mentioned at the top of this page).
    Then use index finger on slider to select the WebServer App (RGB LED = BLUE).
    At end of the 3 second selection period the WebServer App shall launch.
  • If you are tethered to a laptop and have a terminal open the Wi-Fi network connection confirmation will be seen, eg.

'*** Wi-Go board DHCP assigned IP Address = 192.168.43.102
  • Once you have noted Wi-Go's reported IP address, the USB cable may be disconnected and Wi-Go then used as intended, running on it's own battery power.
  • Use an Internet Browser on SmartPhone/Tablet/Laptop (connected to same Hot-Spot/Wireless Router subnet), to now connect to the noted Wi-Go IP address and view the WebServer output: /media/uploads/frankvnk/wi-go_webserver.png
  • the Webserver sensor data is auto-updated every 2 seconds a manual refresh (F5 on laptop).
  • In the event of an error, press refresh to regenerate the screen.
  • Use the mouse (or touch-screen) to exercise the RGB LED output.

App #3: Exosite Data Client
Wi-Go's sensor data gets transmitted via Wi-Fi to a cloud-based Exosite portal where the sensor measurements are displayed graphically on a "dashboard". Users can create unique customized dashboards using drag and drop GUI widgets from the library provided on the Exosite website.
__Note!__ For the Exosite application a "live" connection to the Internet is required !!!

  • Press RESET, followed by the eCompass Calibration (mentioned at the top of this page).
    Then use index finger on slider to select the Exosite Client App (RGB LED = RED)
  • On launching this App, note Wi-Go's MAC address displayed on your terminal
    (if not running a terminal use FING or other WLAN Scan tool to determine Wi-Go's MAC address) /media/uploads/frankvnk/mac_address.png
  • Using your computer's internet browser, go to avnet.exosite.com and sign-up for a free Avnet Trial Exosite Account: /media/uploads/frankvnk/avnet_trial_exosite.png
  • On the next screen, click on the Sign-Up Now button in the displayed Avnet Trial account option.
  • Complete the Account Info and Contact Info then click on Create Account (make sure to use a valid email address!).
  • Check for new incoming email from avnet.exosite.com to the address you provided and click on the link in this email to activate your new Exosite account.
  • Once activated, login using the email address and password that you chose in your registration. Your Exosite Portal and Dashboard should now display. The first time you log-in to your new account, the default Home dashboard will be displayed, pre-configured with two widgets. On the left is the Welcome widget for tips and information. On the right is the Device List widget.
    Dashboards are configurable, so at any time this default dashboard can be changed, widgets deleted and added (Clicking the upside-down triangle icon in a widget's Title bar will allow you to edit it).
  • Before going further with the Dashboard, you need to connect your Wi-Go device to your Exosite account. Do this by going to the left sidebar and selecting Devices followed by selecting the +Add Device link (on right of screen). /media/uploads/frankvnk/add_device.png
  • In the Setup screens that follow, enter the following
Select a supported deviceWi-Go
Enter device MAC Addressnn:nn:nn:nn:nn:nn [your Wi-Go's MAC address including colons]
Enter device Name[choose a descriptive name]
Enter device Location[description of your location]
  • Once completed, under Devices the name chosen for the added Wi-Go device should now be listed.
  • Click on this new Wi-Go device to examine (and edit if necessary) it's Device Information screen.
    /media/uploads/frankvnk/device_information.png
  • Click the CLOSE button to exit the Device Information screen.
  • On your Wi-Go kit now press RESET, followed by the eCompass Calibration (mentioned at the top of this page)
    and again select the Exosite Client App (RGB LED = RED) using your index finger.
  • Refresh your browser (press F5) a couple've times until the Active indicator changes to On (Green).
    /media/uploads/frankvnk/active_indicator.png
  • From the left sidebar click on Home and click on the recently named Wi-Go device which is located under the Device List.
    This will bring-up a default dashboard display similar to what's shown below.
    (Dashboards are typically accessed via the Dashboards menu entry). Check the dashboard is updating with live data by moving your Wi-Go Kit through different orientations.
    /media/uploads/frankvnk/dashboard.png
  • To create a custom dashboard, select Dashboards from the sidebar menu, followed by +Add Dashboard (on right side of Your Dashboards title bar). After completion of the initial configuration screen you will then be able to add Widgets to display the various Wi-Go data sources as well as pictures and text to support your application.
  • More guidance on the creation, editing and sharing of custom dashboards is available under the Exosite support pages

App #4: Android Sensor Fusion App

  • Press RESET, followed by the eCompass Calibration (mentioned at the top of this page)
    , then use index finger on slider to select the Android App (RGB LED = GREEN)
  • Freescale's ''Xtrinsic Sensor Fusion Toolbox'" will run on Android 3.0 or above phone or tablet. Free to download from Google Play, type Sensor fusion in the search box to find it. freescale.sensors.sfusion /media/uploads/frankvnk/sensor_fusion_toolbox.png
  • The Freescale App is well documented. To access the built-in documentation, press the NAV button at top of screen followed by Documentation from the scroll-down menu:
    /media/uploads/frankvnk/sensor_fusion_doc.png
  • Freescale's sensors site provides additional resources such as this overview: free-android-app-teaches-sensor-fusion-basics
  • Go to the Options Menu and select Preferences… /media/uploads/frankvnk/sensor_fusion_preferences.png
  • The following items need to be taken care of:
Enter WiGo's IP address
Enter the SSID (of the Hot-Spot or Wireless Access Point used by Wi-Go)
  • Press Save and Exit!
    /media/uploads/frankvnk/sensor_fusion_save_and_exit.png
  • Exit the Application completely then re-launch the Sensor Fusion Application.
  • Select the ''Source/Algorithm'" menu and change the data source to Wi-Go mag/accel /media/uploads/frankvnk/sensor_fusion_wigo_mag_accel.png
  • The Android App should now be displaying a 3-D image of Wi-Go that you can rotate and flip-over by moving the Wi-Go board accordingly…
  • Use NAV > Device View to display if this view does not come-up by default. /media/uploads/frankvnk/sensor_fusion_nav_device_view.png
  • A Serial Terminal connection is not necessary but if you happen to have one open you should see the following messages as Wi-Go connects to the Android App:
    "Server waiting for connection" followed by
    "connected, transmit buffer size= 96", and then
    "input = 0123456789"
    at which time Wi-Go starts streaming data to the Android App.

Files at this revision

API Documentation at this revision

Comitter:
frankvnk
Date:
Sun Dec 01 15:06:46 2013 +0000
Parent:
3:1851b5d6f69d
Child:
5:bd9705c7cf51
Commit message:
Solved sensor read errors.
; Added i2c unlock.
;

Changed in this revision

I2C_busreset/I2C_busreset.cpp Show annotated file Show diff for this revision Revisions of this file
I2C_busreset/I2C_busreset.h Show annotated file Show diff for this revision Revisions of this file
Sensors/FRDM_MMA8451Q.lib Show diff for this revision Revisions of this file
Sensors/MAG3110.lib Show diff for this revision Revisions of this file
Sensors/MAG3110/MAG3110.cpp Show annotated file Show diff for this revision Revisions of this file
Sensors/MAG3110/MAG3110.h Show annotated file Show diff for this revision Revisions of this file
Sensors/MMA8451Q/MMA8451Q.cpp Show annotated file Show diff for this revision Revisions of this file
Sensors/MMA8451Q/MMA8451Q.h Show annotated file Show diff for this revision Revisions of this file
Sensors/MPL3115A2.lib Show diff for this revision Revisions of this file
Sensors/MPL3115A2/MPL3115A2.cpp Show annotated file Show diff for this revision Revisions of this file
Sensors/MPL3115A2/MPL3115A2.h Show annotated file Show diff for this revision Revisions of this file
Sensors/TEMT6200.lib Show diff for this revision Revisions of this file
Sensors/TSI.lib Show diff for this revision Revisions of this file
Sensors/Wi-Go_eCompass_Lib_V3.lib Show diff for this revision Revisions of this file
Sensors/WiGo_BattCharger.lib Show diff for this revision Revisions of this file
Utilities/strlib.cpp Show annotated file Show diff for this revision Revisions of this file
Utilities/strlib.h Show annotated file Show diff for this revision Revisions of this file
Webserver/AvnetHTML.h Show diff for this revision Revisions of this file
Webserver/demo.cpp Show diff for this revision Revisions of this file
Webserver/demo.h Show diff for this revision Revisions of this file
Webserver/doTCPIP.cpp Show annotated file Show diff for this revision Revisions of this file
Webserver/doTCPIP.h Show annotated file Show diff for this revision Revisions of this file
Webserver/run_exosite.cpp Show annotated file Show diff for this revision Revisions of this file
Webserver/run_exosite.h 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
cc3000_hostdriver_mbedsocket/Helper/def.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/Endpoint.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/Endpoint.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/Socket.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/Socket.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/TCPSocketConnection.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/TCPSocketConnection.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/TCPSocketServer.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/TCPSocketServer.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/UDPSocket.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/Socket/UDPSocket.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_common.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_event.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_event.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_hci.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_netapp.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_netapp.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_nvmem.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_nvmem.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_security.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_simplelink.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_simplelink.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_socket.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_socket.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_spi.cpp Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_spi.h Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket/cc3000_wlan.cpp Show diff for this revision Revisions of this file
init.cpp 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C_busreset/I2C_busreset.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,58 @@
+/**************************************************************************************************
+ *****                                                                                        *****
+ *****  Name: KL25Z I2C_busreset.cpp                                                          *****
+ *****  Date: 24/11/2013                                                                      *****
+ *****  Auth: Frank Vannieuwkerke                                                             *****
+ *****  Func: library for unblocking I2C bus on KL25Z board                                   *****
+ *****  Info: MPL3115A2-AN4481                                                                *****
+ **************************************************************************************************/
+
+#include "I2C_busreset.h"
+
+void I2C_busreset(void)
+{
+    I2C0->C1 &= 0x7f;                 // Disable I2C0 bus
+    I2C1->C1 &= 0x7f;                 // Disable I2C1 bus
+    PORTE->PCR[1] = PORT_PCR_MUX(1);  // PTE1 Alt1 (pin)
+    PORTE->PCR[0] = PORT_PCR_MUX(1);  // PTE0 Alt1 (pin)
+    PORTE->PCR[24] = PORT_PCR_MUX(1); // PTE24 Alt1 (pin)
+    PORTE->PCR[25] = PORT_PCR_MUX(1); // PTE25 Alt1 (pin)
+    if((PTE->PDIR & 0x3) != 3)        // When PTE0 / PTE1 are not 1 : I2C1 bus lock-up
+    {
+        PTE->PDDR |= 0x2;             // Set PTE1 as a GPIO output so we can bit bang it
+        PTE->PDOR |= 0x2;             // Set PTE1 (SCL) pin high;
+        wait_ms(1);
+        while(!(PTE->PDIR & 0x1))     // bit bang SCL until the offending device releases the bus
+        {   
+            PTE->PDOR &= 0xfffffffd;  // Set PTE1 (SCL) pin low;
+            wait_ms(1);
+            PTE->PDOR |= 0x2;         // Set PTE1 (SCL) pin high;
+            wait_ms(1);
+        }
+    }
+    if((PTE->PDIR & 0x03000000) != 0x03000000)  // When PTE24 / PTE25 are not 1 : I2C0 bus lock-up
+    {
+        PTE->PDDR |= 0x01000000;      // Set PTE24 as a GPIO output so we can bit bang it
+        PTE->PDOR |= 0x01000000;      // Set PTE24 (SCL) pin high;
+        wait_ms(1);
+        while(!(PTE->PDIR & 0x1))     // bit bang SCL until the offending device releases the bus
+        {   
+            PTE->PDOR &= 0xfeffffff;  // Set PTE24 (SCL) pin low;
+            wait_ms(1);
+            PTE->PDOR |= 0x01000000;  // Set PTE24 (SCL) pin high;
+            wait_ms(1);
+        }
+    }
+    // Reinstate I2C bus pins
+    PORTE->PCR[1] = PORT_PCR_MUX(6);  // PTE1 Alt6 (SCL)
+    PORTE->PCR[0] = PORT_PCR_MUX(6);  // PTE0 Alt6 (SDA)
+    PORTE->PCR[24] = PORT_PCR_MUX(5); // PTE24 Alt6 (SCL)
+    PORTE->PCR[25] = PORT_PCR_MUX(5); // PTE25 Alt6 (SDA)
+    I2C0->C1 |= 0x80;                 // Enable I2C0 bus
+    I2C1->C1 |= 0x80;                 // Enable I2C1 bus
+}
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2C_busreset/I2C_busreset.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,17 @@
+/**************************************************************************************************
+ *****                                                                                        *****
+ *****  Name: KL25Z I2C_busreset.h                                                            *****
+ *****  Date: 24/11/2013                                                                      *****
+ *****  Auth: Frank Vannieuwkerke                                                             *****
+ *****  Func: library for unblocking I2C bus on KL25Z board                                   *****
+ *****  Info: MPL3115A2-AN4481                                                                *****
+ **************************************************************************************************/
+
+#include "mbed.h"
+
+#ifndef KL25Z_I2C_RES_H
+#define KL25Z_I2C_RES_H
+ 
+void I2C_busreset(void);
+
+#endif
--- a/Sensors/FRDM_MMA8451Q.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/clemente/code/FRDM_MMA8451Q/#13e2af71e2cf
--- a/Sensors/MAG3110.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/SomeRandomBloke/code/MAG3110/#cf40601402b7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensors/MAG3110/MAG3110.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,59 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "MAG3110.h"
+
+/******************************************************************************
+ * Constructors
+ ******************************************************************************/
+
+MAG3110::MAG3110(PinName sda, PinName scl, int addr): m_i2c(sda, scl),  m_addr(addr)
+{
+//    m_i2c.frequency(375000);
+    unsigned char data[2] = {MAG_CTRL_REG2, MAG_3110_AUTO_MRST_EN};
+    writeRegs(data, 2);
+    data[0] = MAG_CTRL_REG1;
+    data[1] = MAG_3110_ACTIVE;
+    writeRegs(data, 2);
+}
+
+uint8_t MAG3110::isDataAvailable(void)
+{
+    uint8_t status;
+    status = readReg(MAG_DR_STATUS);
+    return (status & 0x07);
+}
+
+void MAG3110::readXYZ(uint8_t * data)
+{
+    char t[1] = {MAG_OUT_X_MSB};
+    m_i2c.write(m_addr, t, 1, true);
+    m_i2c.read(m_addr, (char *)data, 6);
+}
+
+uint8_t MAG3110::readReg(uint8_t addr) {
+    char t[1] = {addr};
+    m_i2c.write(m_addr, t, 1, true);
+    m_i2c.read(m_addr, t, 1);
+    return t[0];
+}
+
+void MAG3110::writeRegs(uint8_t * data, int len) {
+    m_i2c.write(m_addr, (char *)data, len);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensors/MAG3110/MAG3110.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,105 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+ 
+#ifndef MAG3110_H
+#define MAG3110_H
+
+#include "mbed.h"
+
+// define registers
+#define MAG_DR_STATUS 0x00
+#define MAG_OUT_X_MSB 0x01
+#define MAG_OUT_X_LSB 0x02
+#define MAG_OUT_Y_MSB 0x03
+#define MAG_OUT_Y_LSB 0x04
+#define MAG_OUT_Z_MSB 0x05
+#define MAG_OUT_Z_LSB 0x06
+#define MAG_WHO_AM_I  0x07
+#define MAG_SYSMOD    0x08
+#define MAG_OFF_X_MSB 0x09
+#define MAG_OFF_X_LSB 0x0A
+#define MAG_OFF_Y_MSB 0x0B
+#define MAG_OFF_Y_LSB 0x0C
+#define MAG_OFF_Z_MSB 0x0D
+#define MAG_OFF_Z_LSB 0x0E
+#define MAG_DIE_TEMP  0x0F
+#define MAG_CTRL_REG1 0x10
+#define MAG_CTRL_REG2 0x11
+
+// Fields in registers
+// CTRL_REG1: dr2,dr1,dr0  os1,os0  fr tm ac
+
+// Sampling rate from 80Hz down to 0.625Hz
+#define MAG_3110_SAMPLE80 0
+#define MAG_3110_SAMPLE40 0x20
+#define MAG_3110_SAMPLE20 0x40
+#define MAG_3110_SAMPLE10 0x60
+#define MAG_3110_SAMPLE5 0x80
+#define MAG_3110_SAMPLE2_5 0xA0
+#define MAG_3110_SAMPLE1_25 0xC0
+#define MAG_3110_SAMPLE0_625 0xE0
+
+// How many samples to average (lowers data rate)
+#define MAG_3110_OVERSAMPLE1 0
+#define MAG_3110_OVERSAMPLE2 0x08
+#define MAG_3110_OVERSAMPLE3 0x10
+#define MAG_3110_OVERSAMPLE4 0x18
+
+// read only 1 byte per axis
+#define MAG_3110_FASTREAD 0x04
+// do one measurement (even if in standby mode)
+#define MAG_3110_TRIGGER 0x02
+// put in active mode
+#define MAG_3110_ACTIVE 0x01
+
+// CTRL_REG2: AUTO_MRST_EN  _ RAW MAG_RST _ _ _ _ _
+// reset sensor after each reading
+#define MAG_3110_AUTO_MRST_EN 0x80
+// don't subtract user offsets
+#define MAG_3110_RAW 0x20
+// reset magnetic sensor after too-large field
+#define MAG_3110_MAG_RST 0x10
+
+// DR_STATUS Register ZYXOW ZOW YOW XOW ZYXDR ZDR YDR XDR
+#define MAG_3110_ZYXDR  0x08
+
+/**
+ * MAG3110 Class to read X/Y/Z data from the magnetometer
+ *
+ */
+class MAG3110
+{
+public:
+    /**
+     * Main constructor
+     * @param sda SDA pin
+     * @param sdl SCL pin
+     * @param addr addr of the I2C peripheral
+     */
+    MAG3110(PinName sda, PinName scl, int addr);
+
+    uint8_t isDataAvailable(void);
+    void readXYZ(uint8_t * data);
+    uint8_t readReg(uint8_t addr);
+    void writeRegs(uint8_t * data, int len);
+
+private:
+    I2C m_i2c;
+    int m_addr;
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensors/MMA8451Q/MMA8451Q.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,54 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+ 
+#include "MMA8451Q.h"
+ 
+#define REG_STATUS        0x00
+#define REG_CTRL_REG_1    0x2A
+#define REG_OUT_X_MSB     0x01
+#define REG_OUT_Y_MSB     0x03
+#define REG_OUT_Z_MSB     0x05
+ 
+MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {
+    // activate the peripheral
+    unsigned char t;
+    t = readReg(REG_CTRL_REG_1);
+    unsigned char data[2] = {REG_CTRL_REG_1, t|0x01};
+    writeRegs(data, 2);
+}
+ 
+uint8_t MMA8451Q::isDataAvailable(void)
+{
+    uint8_t status;
+    status = readReg( REG_STATUS);
+    return (status & 0xf);
+}
+
+uint8_t MMA8451Q::readReg(uint8_t addr) {
+    char t[1] = {addr};
+    m_i2c.write(m_addr, t, 1, true);
+    m_i2c.read(m_addr, t, 1);
+    return t[0];
+}
+
+void MMA8451Q::writeRegs(uint8_t * data, int len) {
+    m_i2c.write(m_addr, (char *)data, len);
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensors/MMA8451Q/MMA8451Q.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,45 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+ 
+#ifndef MMA8451Q_H
+#define MMA8451Q_H
+ 
+#include "mbed.h"
+ 
+class MMA8451Q
+{
+public:
+    /**
+    * MMA8451Q constructor
+    *
+    * @param sda SDA pin
+    * @param sdl SCL pin
+    * @param addr addr of the I2C peripheral
+    */
+    MMA8451Q(PinName sda, PinName scl, int addr);
+ 
+    uint8_t isDataAvailable( void);
+    uint8_t readReg(uint8_t addr);
+    void writeRegs(uint8_t * data, int len);
+
+private:
+    I2C m_i2c;
+    int m_addr;
+};
+ 
+#endif
--- a/Sensors/MPL3115A2.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/clemente/code/MPL3115A2/#59e9ba115d0a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensors/MPL3115A2/MPL3115A2.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,88 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+ 
+#include "MPL3115A2.h"
+
+#define REG_WHO_AM_I        0x0C        // return 0xC4 by default
+#define REG_STATUS          0x00
+#define REG_CTRL_REG_1      0x26
+#define REG_CTRL_REG_3      0x28
+#define REG_CTRL_REG_4      0x29
+#define REG_CTRL_REG_5      0x2A
+#define REG_PRESSURE_MSB    0x01        // 3 byte pressure data
+#define REG_ALTIMETER_MSB   0x01        // 3 byte altimeter data
+#define REG_TEMP_MSB        0x04        // 2 byte temperature data
+#define REG_PT_DATA_CFG     0x13
+#define REG_P_TGT_MSB       0x16
+#define REG_P_WND_MSB       0x19
+
+// Status flag for data ready.
+#define PTDR_STATUS       0x03        // Pressure Altitude and Temperature ready
+#define PDR_STATUS        0x02        // Pressure and Altitude data ready
+#define TDR_STATUS        0x01        // Temperature data ready
+
+MPL3115A2::MPL3115A2(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {
+    unsigned char data[2] = {REG_CTRL_REG_1, 0xB8};
+    writeRegs(data, 2);
+    data[0] = REG_PT_DATA_CFG;
+    data[1] = 0x07;
+    writeRegs(data, 2);
+    data[0] = REG_CTRL_REG_1;
+    data[1] = 0xB9;
+    writeRegs(data, 2);
+}
+
+uint8_t MPL3115A2::isDataAvailable( void)
+{
+    unsigned char status;
+    readRegs( REG_STATUS, &status, 1);
+    return ((status>>1) & 0x07);
+    
+}
+
+uint8_t MPL3115A2::getAltimeterRaw( unsigned char *dt)
+{
+    if ( isDataAvailable() & PDR_STATUS)
+    {
+        readRegs( REG_ALTIMETER_MSB, &dt[0], 2);
+        return 1;    
+    }
+    else
+        return 0;
+}
+
+uint8_t MPL3115A2::getTemperatureRaw( unsigned char *dt)
+{
+    if ( isDataAvailable() & TDR_STATUS)
+    {
+        readRegs( REG_TEMP_MSB, &dt[0], 1);
+        return 1;
+    }
+    else
+        return 0;
+}
+
+void MPL3115A2::readRegs(int addr, uint8_t * data, int len) {
+    char t[1] = {addr};
+    m_i2c.write(m_addr, t, 1, true);
+    m_i2c.read(m_addr, (char *)data, len);
+}
+
+void MPL3115A2::writeRegs(uint8_t * data, int len) {
+    m_i2c.write(m_addr, (char *)data, len);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensors/MPL3115A2/MPL3115A2.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,81 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+ 
+#ifndef MPL3115A2_H
+#define MPL3115A2_H
+
+#include "mbed.h"
+
+// Oversampling value and minimum time between sample
+#define OVERSAMPLE_RATIO_1      0       // 6 ms
+#define OVERSAMPLE_RATIO_2      1       // 10 ms
+#define OVERSAMPLE_RATIO_4      2       // 18 ms
+#define OVERSAMPLE_RATIO_8      3       // 34 ms
+#define OVERSAMPLE_RATIO_16     4       // 66 ms
+#define OVERSAMPLE_RATIO_32     5       // 130 ms
+#define OVERSAMPLE_RATIO_64     6       // 258 ms
+#define OVERSAMPLE_RATIO_128    7       // 512 ms
+
+/* Mode */
+#define ALTIMETER_MODE      1
+#define BAROMETRIC_MODE     2
+
+class MPL3115A2
+{
+public:
+    /**
+    * MPL3115A2 constructor
+    *
+    * @param sda SDA pin
+    * @param sdl SCL pin
+    * @param addr addr of the I2C peripheral
+    */
+    MPL3115A2(PinName sda, PinName scl, int addr);
+    
+    /**
+    * Get the altimeter value in raw mode
+    *
+    * @param    dt      pointer to unsigned char array
+    * @returns 1 if data are available, 0 if not.
+    */
+    uint8_t getAltimeterRaw( unsigned char *dt);
+
+    /**
+    * Get the temperature value in raw mode
+    *
+    * @param    dt      pointer to unsigned char array
+    * @returns 1 if data are available, 0 if not.
+    */
+    uint8_t getTemperatureRaw( unsigned char *dt);
+    
+    /** 
+    * Return if there are date available
+    * 
+    * @return 0 for no data available, bit0 set for Temp data available, bit1 set for Press/Alti data available
+    *         bit2 set for both Temp and Press/Alti data available
+    */
+    uint8_t isDataAvailable( void);
+
+private:
+    I2C m_i2c;
+    int m_addr;
+    void readRegs(int addr, uint8_t * data, int len);
+    void writeRegs(uint8_t * data, int len);
+};
+
+#endif
--- a/Sensors/TEMT6200.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/frankvnk/code/TEMT6200/#5d1118cb5702
--- a/Sensors/TSI.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
--- a/Sensors/Wi-Go_eCompass_Lib_V3.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/frankvnk/code/Wi-Go_eCompass_Lib_V3/#c37fee2125c6
--- a/Sensors/WiGo_BattCharger.lib	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/frankvnk/code/WiGo_BattCharger/#fb966ae74766
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utilities/strlib.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,193 @@
+/*****************************************************************************
+*
+*  strlib.c - String Library functions implementation
+*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+*
+*  Redistribution and use in source and binary forms, with or without
+*  modification, are permitted provided that the following conditions
+*  are met:
+*
+*    Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+*
+*    Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the   
+*    distribution.
+*
+*    Neither the name of Texas Instruments Incorporated nor the names of
+*    its contributors may be used to endorse or promote products derived
+*    from this software without specific prior written permission.
+*
+*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*****************************************************************************/
+
+/*#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>*/
+#include "mbed.h"
+#include "strlib.h"
+
+//*****************************************************************************
+//
+//! \brief   Integer to ASCII
+//!
+//! \param  n is the number to be converted to ASCII
+//! \param s is a pointer to an array where the ASCII string will be placed
+//! \param b is the base (10 for decimal)
+//!
+//! \return none
+//
+//*****************************************************************************
+char *itoa(int n, char *s, int b)
+{
+    const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+    unsigned int i = 0;
+    int sign;
+    
+    if ((sign = n) < 0)
+        n = -n;
+
+    do {
+        s[i++] = digits[n % b];
+    } while ((n /= b) > 0);
+
+    if (sign < 0)
+        s[i++] = '-';
+    s[i] = '\0';
+
+    return strrev(s);
+}
+
+//*****************************************************************************
+//
+//! \brief   Reverses a string
+//!
+//! \param  str is a pointer to the string to be reversed
+//!
+//! \return none
+//
+//*****************************************************************************
+char *strrev(char *str)
+{
+    char *p1, *p2;
+
+    if (!str || !*str)
+        return str;
+
+    for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) {
+        *p1 ^= *p2;
+        *p2 ^= *p1;
+        *p1 ^= *p2;
+    }
+
+    return str;
+}
+
+//*****************************************************************************
+//
+//! atoc
+//!
+//! \param  none
+//!
+//! \return none
+//!
+//! \brief  Convert nibble to hexdecimal from ASCII
+//
+//*****************************************************************************
+unsigned char
+atoc(char data)
+{
+    unsigned char ucRes = 0;
+
+    if ((data >= 0x30) && (data <= 0x39))
+    {
+        ucRes = data - 0x30;
+    }
+    else
+    {
+        if (data == 'a')
+        {
+            ucRes = 0x0a;;
+        }
+        else if (data == 'b')
+        {
+            ucRes = 0x0b;
+        }
+        else if (data == 'c')
+        {
+            ucRes = 0x0c;
+        }
+        else if (data == 'd')
+        {
+            ucRes = 0x0d;
+        }
+        else if (data == 'e')
+        {
+            ucRes = 0x0e;
+        }
+        else if (data == 'f')
+        {
+            ucRes = 0x0f;
+        }
+    }
+
+
+    return ucRes;
+}
+
+
+//*****************************************************************************
+//
+//! atoshort
+//!
+//! \param  none
+//!
+//! \return none
+//!
+//! \brief  Convert 2 nibbles in ASCII into a short number
+//
+//*****************************************************************************
+
+unsigned short
+atoshort(char b1, char b2)
+{
+    unsigned short usRes;
+
+    usRes = (atoc(b1)) * 16 | atoc(b2);
+
+    return usRes;
+}
+
+//*****************************************************************************
+//
+//! ascii_to_char
+//!
+//! \param  none
+//!
+//! \return none
+//!
+//! \brief  Convert 2 bytes in ASCII into one character
+//
+//*****************************************************************************
+
+unsigned char
+ascii_to_char(char b1, char b2)
+{
+    unsigned char ucRes;
+
+    ucRes = (atoc(b1)) << 4 | (atoc(b2));
+
+    return ucRes;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utilities/strlib.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,55 @@
+/*****************************************************************************
+*
+*  strlib.h - String Library functions definitions
+*
+*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+*
+*  Redistribution and use in source and binary forms, with or without
+*  modification, are permitted provided that the following conditions
+*  are met:
+*
+*    Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+*
+*    Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the   
+*    distribution.
+*
+*    Neither the name of Texas Instruments Incorporated nor the names of
+*    its contributors may be used to endorse or promote products derived
+*    from this software without specific prior written permission.
+*
+*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*****************************************************************************/
+
+#ifndef STRLIB_H
+#define STRLIB_H
+
+#ifdef    __cplusplus
+extern "C" {
+#endif
+
+char *itoa(int n, char *s, int b);
+char *strrev(char *str);
+unsigned char atoc(char data);
+unsigned short atoshort(char b1, char b2);
+unsigned char ascii_to_char(char b1, char b2);
+
+#ifdef    __cplusplus
+}
+#endif // __cplusplus
+
+#endif // STRLIB_H
+
--- a/Webserver/AvnetHTML.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-#ifndef AVNET_HTML_H
-#define AVNET_HTML_H
-
-#ifdef    __cplusplus
-extern "C" {
-#endif
-
-// ---------- HTML Webpage Content is defined here ----------
-// Caution! Field labels and spaces in the HTML should not be edited without making corresponding changes in the C-code!
-char index[] = {
-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html lang=\"en-US\">"
-"<head>"
-"<META content=\"text/html;charset=ISO-8859-1\" http-equiv=\"content-type\">"
-"<title>Wi-Go WebServer</title>"
-"<META HTTP-EQUIV=\"refresh\" content=\"1\">"   // Uncomment for auto-refresh every 2 seconds
-"</head>"
-
-"<body><div style=\"text-align: left\"><font size=\"6\" color=\"Red\" face=\"Tahoma\">"
-"<b>Avnet Wi-Go Webserver</b></font>"
-"<hr size=3 width=600 align=left>"
-"<font size=\"5\" color=\"Red\" face=\"Tahoma\"><b>LED RGB color select...</b></font>"
-
-//"<font size=\"5\" color=\"Black\" face=\"monospace\"></font>" 
-"<form method=\"get\" action=\"index.html\" name=\"server\">"
-"<input name=\"ledCon\" type=\"submit\" value=\"-Red-\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
-"<input name=\"ledCon\" type=\"submit\" value=\"Green\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
-"<input name=\"ledCon\" type=\"submit\" value=\"Blue-\">"
-"</form></div>" 
-
-"<hr size=3 width=600 align=left>"
-"<div style=\"text-align: left\"><font size=\"5\" color=\"Red\" face=\"Tahoma\">"
-"<b>Navigation Sensors</b></font></div>"
-
-"<div style=\"text-align:left\"><font size=\"4\" color=\"Black\" face=\"monospace\"><b>"
-"Acceleration(G)..                                       <br>"
-"Magnetometer(uT).                                       <br>"
-"eCompass.........                                         <br>"
-"Altitude.........                <br></b></font></div>"
-
-"<hr size=3 width=600 align=left>"
-"<div style=\"text-align: left\"><font size=\"5\" color=\"Red\" face=\"Tahoma\">"
-"<b>Status and Control</b></font></div>"
-
-"<div style=\"text-align:left\"><font size=\"4\" color=\"Black\" face=\"monospace\"><b>"
-"Battery Voltage..       <br>"
-"Ambient Light....       <br>"
-"Temperature......          <br>"
-"Slider Position..          <br>"
-"Page Views.......        </b></font>"
-"<hr size=3 width=600 align=left>"
-"</body></html>"};  // delete this line if adding the SVG code below...
-
-// Optional section 1: Full SVG graphic example: Uncomment this section to display the standard Wi-Fi logo in lower area of webpage
-// Browsers supporting SVG: Chrome and FireFox (all versions), Android (3.0 onwards), Safari (5.0 onwards), IE (9.0 onwards?)
-/*
-"<!--[if !IE]><!-->"  // This prevents SVG content being sent to Internet Explorer
-"<svg>" 
-"xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"175.49\" width=\"400\""
-"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\""
-"xmlns:cc=\"http://creativecommons.org/ns#\""
-"xmlns:dc=\"http://purl.org/dc/elements/1.1/\">"
-"<defs></defs>"
-"<metadata>"
-"<rdf:RDF>"
-"<cc:Work rdf:about=\"\">"
-"<dc:format>image/svg+xml</dc:format>"
-"<dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>"
-"<dc:title/>"
-"</cc:Work>"
-"</rdf:RDF>"
-"</metadata>"
-"<g transform=\"translate(-309.85919,-343.20843)\">"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,576.05074,474.82936)\">"
-"<path fill-rule=\"nonzero\" fill=\"#231f20\" d=\"m0,0c4.977,0,9.049,4.077,9.049,9.049v5.389c0,4.973-4.072,9.048-9.049,9.048h-35.433c-4.973,0-9.049-4.075-9.049-9.048v-5.389c0-4.972,4.076-9.049,9.049-9.049\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,514.3818,441.01715)\">"
-"<path fill-rule=\"nonzero\" fill=\"#FFF\" d=\"m0,0,0,5.389c0,4.072,3.314,7.32,7.32,7.32h9.187c4.007,0,7.253-3.248,7.253-7.32v-5.389c0-4.005-3.246-7.32-7.253-7.32h-20.239c2.281,1.656,3.732,4.284,3.732,7.32\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,469.99257,451.60916)\">"
-"<path fill-rule=\"nonzero\" fill=\"#FFF\" d=\"m0,0-3.043,0-0.55,2.56c-0.345,1.794-0.692,4.005-0.761,4.833-0.069-0.828-0.416-3.039-0.825-4.833l-0.555-2.56h-2.968l-2.767,11.748h3.317l0.343-2.004c0.276-1.66,0.556-3.659,0.695-5.044,0.136,1.385,0.481,3.384,0.896,5.044l0.412,2.004h2.972l0.413-2.004c0.348-1.66,0.693-3.659,0.833-5.044,0.136,1.385,0.482,3.384,0.757,5.044l0.278,2.004h3.313\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,491.40819,416.23898)\">"
-"<path fill-rule=\"nonzero\" fill=\"#FFF\" d=\"m0,0c-0.968,0-1.727,0.553-1.727,1.451,0,0.899,0.759,1.45,1.727,1.45,1.036,0,1.796-0.551,1.796-1.45,0-0.898-0.76-1.451-1.796-1.451m-1.521-0.968,3.0401,0,0-8.4984-3.0401,0,0,8.4984z\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,541.9845,418.05849)\">"
-"<path fill-rule=\"nonzero\" fill=\"#231f20\" d=\"m0,0,0-2.618,6.22,0,0-2.767-6.22,0,0-3.593-3.247,0,0,11.748,10.156,0,0-2.77\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,580.44446,416.23898)\">"
-"<path fill-rule=\"nonzero\" fill=\"#231f20\" d=\"m0,0c-0.97,0-1.727,0.553-1.727,1.451,0,0.899,0.757,1.45,1.727,1.45,1.035,0,1.797-0.551,1.797-1.45,0-0.898-0.762-1.451-1.797-1.451m-1.521-0.968,3.0371,0,0-8.4984-3.0371,0,0,8.4984z\"/>"
-"</g>"
-"</g>"
-"</svg>"
-"<!--<![endif]-->"  
-*/                // end of conditional inclusion of SVG graphic (excludes Internet Explorer browser)
-// ---- End of Wi-Fi logo SVG image definition ----
-
-// Optional section 2: Simple SVG graphic example: Uncomment this section to generate a filled circle  in lower area of webpage
-// eg. Could use to indicate RGB LED color (with addition of applicable C-code to dynamically update specified "fill=" color)
-/*
-"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
-"<circle cx=\"155\" cy=\"22\" r=\"20\" stroke=\"DimGrey\" stroke-width=\"2\" fill=\"Red\"/>"
-"</svg>"
-"</body></html>"};
-*/
-
-#ifdef    __cplusplus
-}
-#endif // __cplusplus
-#endif // AVNET_HTML_H
-
-
-
-
--- a/Webserver/demo.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,588 +0,0 @@
-
-/*****************************************************************************
-* Dynamic HTML string handlers: 
-* Nine dynamic HTML fields are updated on browser refresh or button press: 
-*     Acceleration
-*     Magnetometer                  
-*     eCompass      
-*     Altitude
-*     Battery Voltage
-*     Ambient Light
-*     Temperature                   
-*     Slider Position       
-*     Page Views
-*
-* CGI HTML forms: 
-* Three CGI form inputs are used to submit data from browser to the Server: 
-* On screen buttons: -Red-, Green, Blue (for control of RGB LED output color) 
-*
-* myindex[] contains the HTML string that defines the webpage that is served
-* Use an online HTML validator to verify HTML code before running it on the MCU
-* eg. 
-* www.w3schools.com/tags/tryit.asp?filename=tryhtml_div_test
-* www.onlinewebcheck.com/check.php?adv=1
-* Note: Before checking the HTML in one of these validators, 
-* strip-out all “\” backslash characters (using search & replace)
-*
-* Webserver code is based on TI's CC3000 Simple HTTP Webserver:  
-* http://processors.wiki.ti.com/index.php/CC3000_Wi-Fi_for_MCU
-* 
-* More detail on implementation of this Webserver App is available here:
-* http://processors.wiki.ti.com/index.php/CC3000_HTTP_Server_Demo_Session
-*
-* A more advanced Webserver and Client App is also available from TI for the CC3000:
-* http://processors.wiki.ti.com/index.php/CC3000_Web_Server_Client_Application
-* (at this time not yet ported to Kinetis-L as the host processor)
-* 
-******************************************************************************
-*
-*  demo.c - CC3000 Main Demo Application
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-
-#include "mbed.h"
-#include "defLED.h"
-#include "demo.h"
-//#include "doTCPIP.h"
-//#include "httpserver.h"
-#include "TCPSocketConnection.h"
-#include "TCPSocketServer.h"
-
-#include "AvnetHTML.h"
-#include "TSISensor.h"
-#include "Wi-Go_eCompass_Lib_V3.h"
-
-
-
-
-
-
-
-extern DigitalOut ledr;
-extern DigitalOut ledg;
-extern DigitalOut ledb;
-extern DigitalOut led1;
-extern DigitalOut led2;
-extern DigitalOut led3;
-extern TSISensor tsi;
-
-// Setup the functions to handle our CGI parameters
-cgi_handler pHandlers;
-dyn_html_handler htmlHandlers;
-
-extern tNetappIpconfigRetArgs ipinfo2;
-
-extern axis6_t axis6;
-extern int server_running;
-extern unsigned char newData;
-extern unsigned short adc_sample3;
-
-/** \brief Pointer to the index HTML page */
-char * indexPage;
-
-/** \brief Pointer to CGI handler structure */
-cgi_handler * chList;
-
-/** \brief Pointer to Dynamic HTML handler structure */
-dyn_html_handler * htmlList;
-
-/** \brief Pointer to Dynamic HTML handler structure */
-http_server_event_handler * eventHandlers = NULL;
-
-
-/** \brief Page view counter */
-int viewCounter = 1;
-#define REQ_BUFFER_SIZE     400
-#define HTTP_TX_BLOCK_SIZE  256
-//#define HTTP_TX_BLOCK_SIZE  1024
-//#define HTTP_TX_BLOCK_SIZE  512
-
-
-// Setup the functions to handle our CGI parameters
-char requestBuffer[REQ_BUFFER_SIZE];
-
-
-
-
-
-/*
-// ---------- HTML Webpage Content is defined here ----------
-// Caution! Field labels and spaces in the HTML should not be edited without making corresponding changes in the C-code!
-char index[] = {
-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html lang=\"en-US\">"
-"<head>"
-"<META content=\"text/html;charset=ISO-8859-1\" http-equiv=\"content-type\">"
-"<title>Wi-Go WebServer</title>"
-//"<META HTTP-EQUIV=\"refresh\" content=\"2\">"   // Uncomment for auto-refresh every 2 seconds
-"</head>"
-
-"<body><div style=\"text-align: left\"><font size=\"6\" color=\"Red\" face=\"Tahoma\">"
-"<b>Avnet Wi-Go Webserver</b></font>"
-"<hr size=3 width=600 align=left>"
-"<font size=\"5\" color=\"Red\" face=\"Tahoma\"><b>LED RGB color select...</b></font>"
-
-//"<font size=\"5\" color=\"Black\" face=\"monospace\"></font>" 
-"<form method=\"get\" action=\"index.html\" name=\"server\">"
-"<input name=\"ledCon\" type=\"submit\" value=\"-Red-\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
-"<input name=\"ledCon\" type=\"submit\" value=\"Green\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
-"<input name=\"ledCon\" type=\"submit\" value=\"Blue-\">"
-"</form></div>" 
-
-"<hr size=3 width=600 align=left>"
-"<div style=\"text-align: left\"><font size=\"5\" color=\"Red\" face=\"Tahoma\">"
-"<b>Navigation Sensors</b></font></div>"
-
-"<div style=\"text-align:left\"><font size=\"4\" color=\"Black\" face=\"monospace\"><b>"
-"Acceleration(G)..                                       <br>"
-"Magnetometer(uT).                                       <br>"
-"eCompass.........                                         <br>"
-"Altitude.........                <br></b></font></div>"
-
-"<hr size=3 width=600 align=left>"
-"<div style=\"text-align: left\"><font size=\"5\" color=\"Red\" face=\"Tahoma\">"
-"<b>Status and Control</b></font></div>"
-
-"<div style=\"text-align:left\"><font size=\"4\" color=\"Black\" face=\"monospace\"><b>"
-"Battery Voltage..       <br>"
-"Ambient Light....       <br>"
-"Temperature......          <br>"
-"Slider Position..          <br>"
-"Page Views.......        </b></font>"
-"<hr size=3 width=600 align=left>"
-"</body></html>"};  // delete this line if adding the SVG code below...
-*/
-// Optional section 1: Full SVG graphic example: Uncomment this section to display the standard Wi-Fi logo in lower area of webpage
-// Browsers supporting SVG: Chrome and FireFox (all versions), Android (3.0 onwards), Safari (5.0 onwards), IE (9.0 onwards?)
-/*
-"<!--[if !IE]><!-->"  // This prevents SVG content being sent to Internet Explorer
-"<svg>" 
-"xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"175.49\" width=\"400\""
-"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\""
-"xmlns:cc=\"http://creativecommons.org/ns#\""
-"xmlns:dc=\"http://purl.org/dc/elements/1.1/\">"
-"<defs></defs>"
-"<metadata>"
-"<rdf:RDF>"
-"<cc:Work rdf:about=\"\">"
-"<dc:format>image/svg+xml</dc:format>"
-"<dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>"
-"<dc:title/>"
-"</cc:Work>"
-"</rdf:RDF>"
-"</metadata>"
-"<g transform=\"translate(-309.85919,-343.20843)\">"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,576.05074,474.82936)\">"
-"<path fill-rule=\"nonzero\" fill=\"#231f20\" d=\"m0,0c4.977,0,9.049,4.077,9.049,9.049v5.389c0,4.973-4.072,9.048-9.049,9.048h-35.433c-4.973,0-9.049-4.075-9.049-9.048v-5.389c0-4.972,4.076-9.049,9.049-9.049\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,514.3818,441.01715)\">"
-"<path fill-rule=\"nonzero\" fill=\"#FFF\" d=\"m0,0,0,5.389c0,4.072,3.314,7.32,7.32,7.32h9.187c4.007,0,7.253-3.248,7.253-7.32v-5.389c0-4.005-3.246-7.32-7.253-7.32h-20.239c2.281,1.656,3.732,4.284,3.732,7.32\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,469.99257,451.60916)\">"
-"<path fill-rule=\"nonzero\" fill=\"#FFF\" d=\"m0,0-3.043,0-0.55,2.56c-0.345,1.794-0.692,4.005-0.761,4.833-0.069-0.828-0.416-3.039-0.825-4.833l-0.555-2.56h-2.968l-2.767,11.748h3.317l0.343-2.004c0.276-1.66,0.556-3.659,0.695-5.044,0.136,1.385,0.481,3.384,0.896,5.044l0.412,2.004h2.972l0.413-2.004c0.348-1.66,0.693-3.659,0.833-5.044,0.136,1.385,0.482,3.384,0.757,5.044l0.278,2.004h3.313\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,491.40819,416.23898)\">"
-"<path fill-rule=\"nonzero\" fill=\"#FFF\" d=\"m0,0c-0.968,0-1.727,0.553-1.727,1.451,0,0.899,0.759,1.45,1.727,1.45,1.036,0,1.796-0.551,1.796-1.45,0-0.898-0.76-1.451-1.796-1.451m-1.521-0.968,3.0401,0,0-8.4984-3.0401,0,0,8.4984z\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,541.9845,418.05849)\">"
-"<path fill-rule=\"nonzero\" fill=\"#231f20\" d=\"m0,0,0-2.618,6.22,0,0-2.767-6.22,0,0-3.593-3.247,0,0,11.748,10.156,0,0-2.77\"/>"
-"</g>"
-"<g transform=\"matrix(3.7361528,0,0,-3.7361528,580.44446,416.23898)\">"
-"<path fill-rule=\"nonzero\" fill=\"#231f20\" d=\"m0,0c-0.97,0-1.727,0.553-1.727,1.451,0,0.899,0.757,1.45,1.727,1.45,1.035,0,1.797-0.551,1.797-1.45,0-0.898-0.762-1.451-1.797-1.451m-1.521-0.968,3.0371,0,0-8.4984-3.0371,0,0,8.4984z\"/>"
-"</g>"
-"</g>"
-"</svg>"
-"<!--<![endif]-->"  
-*/                // end of conditional inclusion of SVG graphic (excludes Internet Explorer browser)
-// ---- End of Wi-Fi logo SVG image definition ----
-
-// Optional section 2: Simple SVG graphic example: Uncomment this section to generate a filled circle  in lower area of webpage
-// eg. Could use to indicate RGB LED color (with addition of applicable C-code to dynamically update specified "fill=" color)
-/*
-"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
-"<circle cx=\"155\" cy=\"22\" r=\"20\" stroke=\"DimGrey\" stroke-width=\"2\" fill=\"Red\"/>"
-"</svg>"
-"</body></html>"};
-*/
-
-// ----------------------------------------------------------
-
-//char ssid_name[] = SSID;
-char testString[20];
-//int vcc = 0;
-//*****************************************************************************
-//
-//!  demo_wi-fi_main
-//!
-//!  \param  None
-//!
-//!  \return none
-//!
-//!  \brief   The main loop is executed here
-//
-//*****************************************************************************
-
-int demo_wifi_main(void)
-{
-    server_running = 1;
-    while(1)
-    {
-      /* Configure dynamic HTML string handlers
-         0 : Acceleration
-         1 : Magnetometer                   
-         2 : eCompass       
-         3 : Altitude
-         ------------------- 
-         4 : Battery Voltage
-         5 : Ambient Light
-         6 : Temperature                    
-         7 : Slider Position        
-         8 : Page Views
-      */                    
-        (htmlHandlers.dynHtmlFunc[0]) = getAccelXYZ_Str; 
-        memcpy(htmlHandlers.dynHtmlParamName[0],"Acceleration(G).. ",strlen("Acceleration(G).. "));
-        htmlHandlers.dynHtmlParamName[0][strlen("Acceleration(G).. ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[1]) = getM3110Str; 
-        memcpy(htmlHandlers.dynHtmlParamName[1],"Magnetometer(uT). ",strlen("Magnetometer(uT). "));
-        htmlHandlers.dynHtmlParamName[1][strlen("Magnetometer(uT). ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[2]) = getCompassStr;
-        memcpy(htmlHandlers.dynHtmlParamName[2],"eCompass......... ",strlen("eCompass......... "));
-        htmlHandlers.dynHtmlParamName[2][strlen("eCompass......... ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[3]) = getAltitudeStr; 
-        memcpy(htmlHandlers.dynHtmlParamName[3],"Altitude......... ",strlen("Altitude......... "));
-        htmlHandlers.dynHtmlParamName[3][strlen("Altitude......... ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[4]) = getBatteryVoltageStr;
-        memcpy(htmlHandlers.dynHtmlParamName[4],"Battery Voltage.. ",strlen("Battery Voltage.. "));
-        htmlHandlers.dynHtmlParamName[4][strlen("Battery Voltage.. ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[5]) = getLightVoltageStr;
-        memcpy(htmlHandlers.dynHtmlParamName[5],"Ambient Light.... ",strlen("Ambient Light.... "));
-        htmlHandlers.dynHtmlParamName[5][strlen("Ambient Light.... ")] ='\0';
-            
-        (htmlHandlers.dynHtmlFunc[6]) = getTemperatureStr; 
-        memcpy(htmlHandlers.dynHtmlParamName[6],"Temperature...... ",strlen("Temperature...... "));
-        htmlHandlers.dynHtmlParamName[6][strlen("Temperature...... ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[7]) = getTSI_sliderStr; 
-        memcpy(htmlHandlers.dynHtmlParamName[7],"Slider Position.. ",strlen("Slider Position.. "));
-        htmlHandlers.dynHtmlParamName[7][strlen("Slider Position.. ")] ='\0';
-
-        (htmlHandlers.dynHtmlFunc[8]) = getViewsNum;
-        memcpy(htmlHandlers.dynHtmlParamName[8],"Page Views....... ",strlen("Page Views....... "));
-        htmlHandlers.dynHtmlParamName[8][strlen("Page Views....... ")] ='\0';
-
-        // Configure CGI Handler
-        (pHandlers.cgiHandlerFunc[0]) = testFunc;
-
-        serverMain(HTTP_PORT,(char *)index, &pHandlers, &htmlHandlers);
-    }
-}
-
-
-void testFunc(char * str)
-{
-    memcpy(testString,str,strlen(str));
-    if(strcmp(str, "-Red-") == 0)
-    {
-        RED_ON; GREEN_OFF; BLUE_OFF; 
-    }
-    else if(strcmp(str, "Green") == 0) 
-    {
-        RED_OFF; GREEN_ON; BLUE_OFF;
-    }
-    else if (strcmp(str, "Blue-") == 0) 
-    {
-        RED_OFF; GREEN_OFF; BLUE_ON;
-    }      
-}
-
-void getBatteryVoltageStr(char * str)
-{
-    sprintf(str,"    "); //clears field (needed if previous string had more characters)
-    sprintf(str, "%d %%", adc_sample3);
-}
- 
-void getLightVoltageStr(char * str)
-{
-    int LightPercent = 0;
-    LightPercent = (axis6.light * 100) / 4096; 
-    sprintf(str,"    "); //clears field (needed if previous string had more characters)
-    sprintf(str, "%d %%", LightPercent);
-}
-
-void getAccelXYZ_Str(char * str) // MMA8451Q accelerometer - report axis with highest value 
-{
-    sprintf(str,"                                    "); //clears field (needed if previous string had more characters)   
-    sprintf(str, "X= %1.2f, Y= %1.2f, Z= %1.2f", axis6.fGax, axis6.fGay, axis6.fGaz);;  
-}  
-
-void getTemperatureStr(char * str) // 
-{
-    sprintf(str, "%+d C", axis6.temp); 
-}
-
-void getTSI_sliderStr(char * str) // TSI Slider position 
-{
-    uint8_t slider_position; 
-    
-    slider_position = tsi.readPercentage() * 100; // Slider position as percentage
-    sprintf(str,"    "); //clears field (needed if previous string had more characters)
-    sprintf(str, "%d %%", slider_position);
-}   
-
-void getCompassStr(char * str)   // Mag3110 generated Compass bearing 
-{
-    char *compass_points[9] = {"North", "N-East", "East", "S-East", "South", "S-West", "West", "N-West", "North"};
-    signed short compass_bearing = (axis6.compass + 23) / 45;
-    sprintf(str,"                                        "); //clears field (needed if previous string had more characters)
-    sprintf(str, "Roll=%-d  Pitch=%-d  Yaw=%-d [%s]", axis6.roll, axis6.pitch, axis6.yaw, compass_points[compass_bearing]);   // 
-}   
-
-void getM3110Str(char * str)   // Mag3110 displayed in units of UT 
-{
-    sprintf(str,"                                    "); //clears field (needed if previous string had more characters)
-    sprintf(str, "X= %3.1f, Y= %3.1f, Z= %3.1f", axis6.fUTmx, axis6.fUTmy, axis6.fUTmz);
-}   
-
-void getAltitudeStr(char * str)    // Get Altitude 
-{
-    sprintf(str, "%+d meters", axis6.alt);   // str = integer portion of result 
-}   
-
-
-
-//*****************************************************************************
-//
-//! \brief  Main HTTP Server
-//!
-//! \param none
-//!
-//! \return none
-//!
-//
-//*****************************************************************************
-void serverMain(int port,
-                char * ipage,
-                cgi_handler * handleList,
-                dyn_html_handler * dhList)
-{
-    static TCPSocketServer server;
-    static TCPSocketConnection client;
-
-    indexPage = ipage;
-    chList = handleList;
-    htmlList = dhList;
-
-    server.bind(port);
-
-    printf("Main HTTP server\r\n");
-
-    // Start Listening
-    if(server.listen() != 0);
-
-    // Handle Clients and Data
-    while(1)
-    {
-        int32_t status = server.accept(client);
-        if (status >= 0)
-        {
-            LED_D2_ON;
-            // Connection Accepted, Send Data
-            // Wait for a data update
-            client.set_blocking(true);
-            printf("Connection\r\n");
-//            printf("Connection from: %s \r\n", client.get_address());
-            if(newData) handleHTTPRequest(&client);
-            newData = 0;
-            client.close();
-            LED_D2_OFF;
-        }
-        else if(status == -57)
-        {
-            // BUG: Socket inactive so reopen socket
-            // Inactive Socket, close and reopen it
-            printf("Oops!!!\r\n");
-            server.close();
-            indexPage = ipage;
-            chList = handleList;
-            htmlList = dhList;
-            server.bind(port);
-
-            // Start Listening
-            if (server.listen() != 0);
-        }
-    }
-}
-
-//*****************************************************************************
-//
-//! \brief  Handles HTTP Requests
-//!
-//! \param cnum is the client socket handle to be used
-//!
-//! \return none
-//!
-//
-//*****************************************************************************
-void handleHTTPRequest(TCPSocketConnection *client)
-{
-    char * reqline[3];
-    char * cgiTok;
-
-    int i = 0;
-    char paramBuf[20];
-    int bytesRecvd;
-    char tempStr[40]; //PF was 26
-
-    memset(requestBuffer,0,sizeof (requestBuffer));
-    bytesRecvd = client->receive(requestBuffer, sizeof(requestBuffer));
-
-    printf("handleHTTPRequest\r\n");
-
-    if(bytesRecvd > 0)
-    {
-        // Received some data, check it and send data back
-        reqline[0] = strstr(requestBuffer, "GET");
-        if ( reqline[0] != NULL )
-        {
-            if (strstr (requestBuffer, "HTTP/1.0") != NULL && strstr (requestBuffer, "HTTP/1.1") != NULL )
-            {
-                client->send_all("HTTP/1.0 400 Bad Request\n", 25);
-            }
-            else
-            {
-
-#ifdef HTTP_CGI_ENABLED
-                // Do we have CGI parameters we need to parse?
-                if(strchr(requestBuffer, '?') != NULL)
-                {
-                    // Decode URL and handle each parameter sequentially
-                    // according to table previously setup.
-                    cgiTok = strstr(requestBuffer,"=");
-                    if(cgiTok != NULL)
-                    {
-                        memset(paramBuf,0,sizeof(paramBuf));
-                        memcpy(paramBuf,cgiTok+1,5);     // hard-coded for demo: 5 character parameter (-Red-/Green/Blue-)
-                        chList->cgiHandlerFunc[0](paramBuf);
-
-                    }
-                }
-#endif
-
-#ifdef HTTP_DYN_HTML_ENABLED
-                // The code below replaces data in the HTML page
-                // with that generated by the specified functions.
-                for(i = 0; i < 9; i++)  // change the range here for more dynamic fields on webpage
-                {
-                    memset(tempStr,0,sizeof(tempStr));
-                    htmlList->dynHtmlFunc[i](tempStr);
-                    tempStr[strlen(tempStr)]= ' ';
-                    pageReplace((char *)indexPage,
-                                (char *)htmlList->dynHtmlParamName[i],
-                                (char *)tempStr);
-                }
-#endif
-                viewCounter++;
-                sendHTTPData(HTTP_RESP, strlen(HTTP_RESP), client);
-                                
-                for(i = 0; i < strlen(indexPage); i += HTTP_TX_BLOCK_SIZE)
-                {
-                    if(strlen(indexPage) - i < HTTP_TX_BLOCK_SIZE)
-                    {
-                        sendHTTPData(&indexPage[i], strlen(indexPage) - i, client);
-                    }
-                    else
-                    {
-                        sendHTTPData(&indexPage[i], HTTP_TX_BLOCK_SIZE, client);
-                    }
-                }
-            }
-        }
-    }
-}
-
-//*****************************************************************************
-//
-//! \brief  Inserts characters in page that appear after an indicator ind
-//! with the value from val
-//!
-//! \param  page is a pointer to the array holding the page's HTML code
-//! \param ind is a pointer to a string that has the name of the parameter on the page to modify
-//! \param val is the pointer to a string holding the string to insert in the XXX
-//!
-//! \return none
-//!
-//
-//*****************************************************************************
-void pageReplace(char * page, char * ind, char * val)
-{
-    char * indicLoc;
-    indicLoc = strstr (page,ind);
-    memcpy(indicLoc+strlen(ind), val, strlen(val));
-}
-
-//*****************************************************************************
-//
-//! \brief  Returns a string with the number of views of the page
-//!
-//! \param  str is a pointer to the array where the number of views will be put
-//!
-//! \return none
-//!
-//
-//*****************************************************************************
-void getViewsNum(char * str)
-{
-    sprintf(str, "%d", viewCounter);
-}
-
-//*****************************************************************************
-//
-//! \brief  Sends HTTP Data
-//!
-//! \param sdesc is the socket descriptor of the socket used for sending data
-//! \param buf is a pointer to the buffer with the data to be sent
-//! \param len is the number of bytes to send
-//!
-//! \return none
-//!
-//
-//*****************************************************************************
-void sendHTTPData(char * buf, long len, TCPSocketConnection *client)
-{
-    int bytesSent = -2;
-    while(bytesSent == -2) bytesSent = client->send_all(buf, len);
-}
-
--- a/Webserver/demo.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#ifndef DEMO_H
-#define DEMO_H
-#include "TCPSocketConnection.h"
-#include "TCPSocketServer.h"
-
-#ifdef    __cplusplus
-extern "C" {
-#endif
-
-#define MAX_CGI_PARAMS 4
-#define MAX_DYN_HTML_PARAMS 9
-#define MAX_DYN_HTML_PARAM_SIZE 40
-#define ROOT "/"
-
-
-#define HTTP_RESP "HTTP/1.0 200 OK\n\n"
-
-#define HTTP_CGI_ENABLED
-#define HTTP_DYN_HTML_ENABLED
-#define HTTP_PORT     80
-
-#define MAX_REPLACE_CHAR 16
-
-
-// Struct that indicates all the elements necessary to handle
-typedef struct
-{
-    // name of parameter that will be analyzed
-    // Currently not implemented to verify each
-    // This would enable us to be flexible with parameter list
-    //char [][]
-    
-    // Array of functions that will handle each parameter
-    void (*cgiHandlerFunc[MAX_CGI_PARAMS])(char *);
-        
-} cgi_handler;
-
-
-typedef struct
-{
-     char dynHtmlParamName[MAX_DYN_HTML_PARAMS][MAX_DYN_HTML_PARAM_SIZE];
-     void (*dynHtmlFunc[40])(char *);  //PF was 20
-} dyn_html_handler;
-// HTTP Server Related
-
-/**
- *  A structure representing pointers to functions handling
- *  server events.
- *
- */
-typedef struct
-{
-    // Array of functions that will handle server events
-  void (*serverInitHandlerFunc)(char *);            /** Handler for Server Initialization Done */
-  void (*clientAcceptedHandlerFunc)(char *);        /** Handler for Client Accepted */
-  void (*httpRequestDoneHandlerFunc)(char *);       /** Handler for HTTP Request Done */
-        
-} http_server_event_handler;
-
-void serverMain(int port, char * ipage,  cgi_handler * handleList, dyn_html_handler * dhList);
-void handleHTTPRequest(TCPSocketConnection *client);
-void pageReplace(char * page, char * ind, char * val);
-void getViewsNum(char * str);
-void sendHTTPData(char * buf, long len, TCPSocketConnection *client);
-
-int demo_wifi_main(void);
-void testFunc(char * str);
-void getBatteryVoltageStr(char * str);
-void getLightVoltageStr(char * str);
-void getAccelXYZ_Str(char * str);
-void getTemperatureStr(char * str);
-void getTSI_sliderStr(char * str);
-void getCompassStr(char * str);
-void getM3110Str(char * str);
-void getAltitudeStr(char * str);
-
-#ifdef    __cplusplus
-}
-#endif // __cplusplus
-#endif // DEMO_H
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Webserver/doTCPIP.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,138 @@
+/****************************************************************************
+*
+*  doTCPIP.cpp - CC3000 TCP/IP
+*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+*
+*  Redistribution and use in source and binary forms, with or without
+*  modification, are permitted provided that the following conditions
+*  are met:
+*
+*    Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+*
+*    Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the
+*    distribution.
+*
+*    Neither the name of Texas Instruments Incorporated nor the names of
+*    its contributors may be used to endorse or promote products derived
+*    from this software without specific prior written permission.
+*
+*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*****************************************************************************/
+
+#include "mbed.h"
+#include "defLED.h"
+#include "doTCPIP.h"
+#include "Wi-Go_eCompass_Lib_V3.h"
+
+extern DigitalOut ledr;
+extern DigitalOut ledg;
+extern DigitalOut ledb;
+extern DigitalOut led1;
+extern DigitalOut led2;
+extern DigitalOut led3;
+
+extern int do_mDNS;
+extern axis6_t axis6;
+extern unsigned char newData;
+extern int HsecondFlag;
+extern unsigned int seconds;
+
+// Setup the functions to handle our CGI parameters
+extern char requestBuffer[];
+  
+//Device name - used for Smart config in order to stop the Smart phone configuration process
+extern char DevServname;
+
+void runTCPIPserver(void)
+{
+    while(1)
+    {
+        long temp, stat, sss, skip, skipc, newsock;
+        LED_D3_OFF;
+        LED_D2_OFF;
+        printf("\n\nStarting TCP/IP Server\n");
+        TCPSocketServer server;
+        server.bind(TCPIP_PORT);
+        server.listen();
+        printf("\r\nWait for new connection...\r\n");
+        skip = 0;
+        skipc = 0;
+        while(1)
+        {
+            newsock = -2;
+            printf("\r\nServer waiting for connection\r\n");
+            TCPSocketConnection client;
+            LED_D2_ON;
+            while((newsock == -1) || (newsock == -2))
+            {
+                newsock = server.accept(client);
+                client.set_blocking(true);
+                if(do_mDNS)
+                {
+                    printf("mDNS= 0x%08x\n", wifi._socket.mdns_advertiser(1, (uint8_t *)DevServname, sizeof(DevServname)));
+                    do_mDNS = 0;
+                }
+            }
+            printf("Connection from: %s \r\n", client.get_address());
+            sss = seconds;
+            //receive TCP data
+            temp = 0;   
+            if(newsock >= 0)
+            {
+                client.receive((char *)requestBuffer,20);
+                printf("Input = %s\n", requestBuffer);
+                HsecondFlag = 0;
+                while(1)
+                {
+                    while(!newData) __wfi();
+                    newData = 0;
+                    if(HsecondFlag)
+                    {
+                        printf("FB= %d\n", wifi._simple_link.get_number_free_buffers());
+                        HsecondFlag = 0;
+                    }
+                    LED_D2_ON;  
+                    stat = -2;
+                    stat = client.send_all((char *)&axis6, sizeof(axis6));
+                    LED_D2_OFF;
+                    if(stat != 96)
+                    {
+                        if(stat == -2)
+                        {
+                            skip++;
+                            skipc++;
+                        }
+                        if(stat == -1) break;
+                    }
+                    else
+                    {
+                        temp++;
+                        skipc = 0;
+                    }
+                    if(skipc > 150)
+                    {
+                        printf("Zero Buffer Error Sent=%d, time=%d\n", temp, seconds - sss);
+                        break;
+                    }
+                }   
+            } else printf("bad socket= %d\n", newsock);
+            client.close();
+            printf("Done %d, time= %d, skipped= %d\n", temp, seconds - sss, skip);
+            skip = 0;
+        }
+    }   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Webserver/doTCPIP.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,66 @@
+/****************************************************************************
+*
+*  doTCPIP.h - CC3000 TCP/IP
+*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+*
+*  Redistribution and use in source and binary forms, with or without
+*  modification, are permitted provided that the following conditions
+*  are met:
+*
+*    Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+*
+*    Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the
+*    distribution.
+*
+*    Neither the name of Texas Instruments Incorporated nor the names of
+*    its contributors may be used to endorse or promote products derived
+*    from this software without specific prior written permission.
+*
+*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*****************************************************************************/
+
+#ifndef DOTCPIP_H
+#define DOTCPIP_H
+
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+
+extern cc3000 wifi;
+extern tUserFS user_info;
+
+/** TCP/IP Functions
+*
+*/
+#ifdef    __cplusplus
+extern "C" {
+#endif
+
+// SMTP Specific
+#define HTTP_PORT     80
+#define TCPIP_PORT    15000
+
+#define REQ_BUFFER_SIZE 400
+
+void runTCPIPserver(void);
+
+#ifdef    __cplusplus
+}
+#endif // __cplusplus
+
+#endif // DOTCPIP_H
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Webserver/run_exosite.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,692 @@
+/*****************************************************************************
+*
+*  demo.c - CC3000 Main Demo Application
+*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+*
+*  Redistribution and use in source and binary forms, with or without
+*  modification, are permitted provided that the following conditions
+*  are met:
+*
+*    Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+*
+*    Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the   
+*    distribution.
+*
+*    Neither the name of Texas Instruments Incorporated nor the names of
+*    its contributors may be used to endorse or promote products derived
+*    from this software without specific prior written permission.
+*
+*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*****************************************************************************/
+
+#include "run_exosite.h"
+#include "Wi-Go_eCompass_Lib_V3.h"
+#include "mbed.h"
+#include "defLED.h"
+#include "strlib.h"
+
+extern DigitalOut ledr;
+extern DigitalOut ledg;
+extern DigitalOut ledb;
+extern DigitalOut led1;
+extern DigitalOut led2;
+extern DigitalOut led3;
+
+// local defines
+#define WRITE_INTERVAL 5
+#define EXO_BUFFER_SIZE 300 //reserve 300 bytes for our output buffer
+
+typedef struct
+{
+    float *p;
+    char *s;
+} exo_data_ft;
+
+typedef struct
+{
+    int16_t *p;
+    char *s;
+} exo_data_it;
+
+//extern tUserFS user_info;
+
+extern char requestBuffer[];
+
+extern unsigned int compass_type, seconds;
+
+char exo_meta[META_SIZE];
+
+#define RX_SIZE 60
+#define MAC_LEN 6
+
+typedef enum
+{
+    CIK_LINE,
+    HOST_LINE,
+    CONTENT_LINE,
+    ACCEPT_LINE,
+    LENGTH_LINE,
+    GETDATA_LINE,
+    POSTDATA_LINE,
+    VENDOR_LINE,
+    EMPTY_LINE
+} lineTypes;
+
+#define STR_CIK_HEADER "X-Exosite-CIK: c3c675e0601551c6d4d3230e162d62cc8bba3311\r\n"
+#define STR_CONTENT_LENGTH "Content-Length: "
+#define STR_GET_URL "GET /api:v1/stack/alias?"
+#define STR_HTTP "  HTTP/1.1\r\n"
+#define STR_HOST "Host: avnet.m2.exosite.com\r\n"
+#define STR_ACCEPT "Accept: application/x-www-form-urlencoded; charset=utf-8\r\n"
+#define STR_CONTENT "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"
+#define STR_VENDOR "vendor=avnet&model=wigosmartconfig&sn="
+#define STR_CRLF "\r\n"
+#define MY_CIK "27b9684751332589be52c8e5819e7c438f7e7479"
+char myCIK[] = "c3c675e0601551c6d4d3230e162d62cc8bba3311";
+
+// local functions
+void activate_device(TCPSocketConnection *socket);
+int readResponse(TCPSocketConnection *socket, char * expectedCode);
+long connect_to_exosite(TCPSocketConnection *socket);
+void sendLine(TCPSocketConnection *socket, unsigned char LINE, char * payload);
+void exosite_meta_write(unsigned char * write_buffer, unsigned short srcBytes, unsigned char element);
+void exosite_meta_read(unsigned char * read_buffer, unsigned short destBytes, unsigned char element);
+int Exosite_Write(TCPSocketConnection *socket, char * pbuf, unsigned char bufsize);
+int Exosite_Read(char * palias, char * pbuf, unsigned char bufsize);
+int Exosite_Init(TCPSocketConnection *socket);
+
+// global variables
+static unsigned char exositeWriteFailures = 0;
+
+// exported functions
+
+// externs
+extern char *itoa(int n, char *s, int b);
+
+extern axis6_t axis6;
+extern int secondFlag;
+extern int server_running;
+
+/** \brief Definition of data packet to be sent by server */
+unsigned char dataPacket[] = { '\r', 0xBE, 128, 128, 128, 70, 36, 0xEF };
+char activeCIK[41];
+
+exo_data_ft exo_fdata[] = {
+        &axis6.fGax,    "acc_x=%f&",
+        &axis6.fGay,    "acc_y=%f&",
+        &axis6.fGaz,    "acc_z=%f&",
+        &axis6.fUTmx,   "mag_x=%f&",
+        &axis6.fUTmy,   "mag_y=%f&",
+        &axis6.fUTmz,   "mag_z=%f&",    
+        &axis6.q0,      "q_w=%f&",  
+        &axis6.q1,      "q_x=%f&",  
+        &axis6.q2,      "q_y=%f&",  
+        &axis6.q3,      "q_z=%f&",  
+        0, 0 };
+
+exo_data_it exo_idata[] = {
+        &axis6.roll,    "roll=%d&",
+        &axis6.pitch,   "pitch=%d&",
+        &axis6.yaw,     "yaw=%d&",
+        &axis6.alt,     "alt=%d&",
+        &axis6.temp,    "temp=%d&",
+        &axis6.light,   "light=%d&",
+        0, 0
+};
+    
+//*****************************************************************************
+//
+//!  main
+//!
+//!  \param  None
+//!
+//!  \return none
+//!
+//!  \brief   The main loop is executed here
+//
+//*****************************************************************************
+void run_exosite(TCPSocketConnection *socket)
+{
+    int value;
+    exo_data_it *tsp;
+    exo_data_ft *tspf;
+    
+    printf("\nConnecting to Exosite\n");
+    //user_info.validCIK = 0; // uncomment this to force provisioning every time, only used for debug
+    
+    if(!user_info.validCIK)
+    {
+        printf("Activating Wi-Go System on Exosite\n");
+        uint8_t myMAC[8];
+        wifi.get_mac_address(myMAC);
+        printf(" MAC address %02x:%02x:%02x:%02x:%02x:%02x \r\n \r\n", myMAC[0], myMAC[1], myMAC[2], myMAC[3], myMAC[4], myMAC[5]);
+        wait_ms(100);
+        printf("Enter the device MAC on your Exosite device portal to prepare\n");
+        wait_ms(100);
+        printf("the system for provisioning your Wi-Go system onto Exosite\n");
+        wait_ms(100);
+        printf("Hit any key to continue.....\n");
+        getchar();
+        Exosite_Init(socket);
+    }
+    
+    for(value=0 ;value < CIK_LENGTH ; value++) activeCIK[value] = user_info.CIK[value];
+    activeCIK[value] = NULL;
+    // Main Loop
+    while (1)
+    {
+        while(!secondFlag) /*__wfi()*/;
+        secondFlag = 0;
+        LED_D2_ON;
+
+        // Build string
+        requestBuffer[0] = 0;
+        tsp     = &exo_idata[0];
+        tspf    = &exo_fdata[0];
+        while(tsp->p)
+        {
+            sprintf( requestBuffer + strlen(requestBuffer), tsp->s, *tsp->p);
+            tsp++;
+        }
+        while(tspf->p)
+        {
+            sprintf( requestBuffer + strlen(requestBuffer), tspf->s, *tspf->p);
+            tspf++;
+        }
+        sprintf( requestBuffer + strlen(requestBuffer), "time=%d\r\n", axis6.timestamp);
+
+        if(strlen(requestBuffer) > 300) printf("Buffer size= %d too small!!!", strlen(requestBuffer));
+        //printf("Buffer size= %d\n", strlen(requestBuffer));
+        value = Exosite_Write(socket, requestBuffer, strlen(requestBuffer));    //write all sensor values to the cloud
+        LED_D2_OFF; 
+        if(value == -1)
+        {
+            LED_D3_OFF;
+            wifi.stop();
+            if (wifi.connect() == -1)
+                printf("Failed to connect. Please verify connection details and try again. \r\n");
+            else
+            {
+                printf("Connected - IP address: %s \r\n",wifi.getIPAddress());
+                LED_D3_ON;
+            }
+        }
+    }
+}
+
+//*****************************************************************************
+//
+//! Exosite_Init
+//!
+//!  \param  None
+//!
+//!  \return 0 success; -1 failure
+//!
+//!  \brief  The function initializes the cloud connection to Exosite
+//
+//*****************************************************************************
+int Exosite_Init(TCPSocketConnection *socket)
+{
+    char strBuf[META_MARK_SIZE];
+    const unsigned char meta_server_ip[6] = {173,255,209,28,0,80};
+    uint8_t mac_status = 1;
+    uint8_t myMAC[8];
+    int i;
+    char tempCIK[CIK_LENGTH];
+
+    //check our meta mark - if it isn't there, we wipe the meta structure
+    exosite_meta_read((unsigned char *)strBuf, META_MARK_SIZE, META_MARK);
+    if (strncmp(strBuf, EXOMARK, META_MARK_SIZE))
+    {
+        memset(exo_meta, 0, META_SIZE); //erase the information currently in meta
+        exosite_meta_write((unsigned char *)meta_server_ip, 6, META_SERVER);     //store server IP
+        exosite_meta_write((unsigned char *)EXOMARK, META_MARK_SIZE, META_MARK); //store exosite mark
+    }
+
+    while(mac_status) mac_status = wifi.get_mac_address(myMAC);
+    exosite_meta_write((unsigned char *)myMAC, 17, META_UUID);
+
+    //setup some of our globals for operation
+    exositeWriteFailures = 0;
+
+    //exosite Re-init : Called after Init has been ran in the past, but maybe
+    //                  comms were down and we have to keep trying...
+    activate_device(socket);    //the moment of truth - can this device provision with the Exosite cloud?...
+    exosite_meta_read((unsigned char *)tempCIK, CIK_LENGTH, META_CIK); //sanity check on the CIK
+    for (i = 0; i < CIK_LENGTH; i++)
+    {
+        if (!(tempCIK[i] >= 'a' && tempCIK[i] <= 'f' || tempCIK[i] >= '0' && tempCIK[i] <= '9'))
+        {
+            return -1;
+        }
+    }
+    for(i=0;i<CIK_LENGTH;i++) user_info.CIK[i] = tempCIK[i];
+    user_info.validCIK = 1;
+    wifi._nvmem.write( NVMEM_USER_FILE_1_FILEID, sizeof(user_info), 0, (unsigned char *) &user_info);
+    return 0;
+}
+
+//*****************************************************************************
+//
+//! Exosite_Write
+//!
+//!  \param  pbuf - string buffer containing data to be sent
+//!          bufsize - number of bytes to send
+//!
+//!  \return 0 success; -1 failure
+//!
+//!  \brief  The function writes data to Exosite
+//
+//*****************************************************************************
+int Exosite_Write(TCPSocketConnection *socket, char * pbuf, unsigned char bufsize)
+{
+    char strBuf[10];
+    long sock = -1;
+
+    sock = connect_to_exosite(socket);
+    if(sock == -1) return(sock);
+
+// This is an example write POST...
+//  s.send('POST /api:v1/stack/alias HTTP/1.1\r\n')
+//  s.send('Host: m2.exosite.com\r\n')
+//  s.send('X-Exosite-CIK: 5046454a9a1666c3acfae63bc854ec1367167815\r\n')
+//  s.send('Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n')
+//  s.send('Content-Length: 6\r\n\r\n')
+//  s.send('temp=2')
+
+    sprintf(strBuf, "%d", (int)bufsize); //make a string for length
+
+    sendLine(socket, POSTDATA_LINE, "/onep:v1/stack/alias");
+    sendLine(socket, HOST_LINE, NULL);
+    sendLine(socket, CIK_LINE, NULL);
+    sendLine(socket, CONTENT_LINE, NULL);
+    sendLine(socket, LENGTH_LINE, strBuf);
+    //printf("Data=%s\n", pbuf);
+    socket->send_all(pbuf, bufsize); //alias=value
+    wifi._event.hci_unsolicited_event_handler();
+
+    if (0 == readResponse(socket, "204"))
+    {
+        exositeWriteFailures = 0;
+    }
+    else
+    {
+        exositeWriteFailures++;
+    }
+
+    socket->close();
+
+    if (exositeWriteFailures > 5)
+    {
+        // sometimes transport connect works even if no connection...
+        printf("ERROR %d\r\n", EXO_ERROR_WRITE);
+    }
+
+    if (!exositeWriteFailures)
+    {
+        //printf("ShowUIcode %d\n", EXO_CLIENT_RW);
+        return 0; // success
+    }
+    return 0;
+}    
+
+
+//*****************************************************************************
+//
+//! activate_device
+//!
+//!  \param  none
+//!
+//!  \return none
+//!
+//!  \brief  Calls activation API - if successful, it saves the returned
+//!          CIK to non-volatile
+//
+//*****************************************************************************
+void activate_device(TCPSocketConnection *socket)
+{
+    long sock = -1;
+    volatile int length;
+    char strLen[5];
+
+    while (sock < 0)
+    sock = connect_to_exosite(socket);
+    printf("Activating Device\n");
+
+    length = strlen(STR_VENDOR) + META_UUID_SIZE;
+    itoa(length, strLen, 10); //make a string for length
+
+    sendLine(socket, POSTDATA_LINE, "/provision/activate");
+    sendLine(socket, HOST_LINE, NULL);
+    sendLine(socket, CONTENT_LINE, NULL);
+    sendLine(socket, LENGTH_LINE, strLen);
+    sendLine(socket, VENDOR_LINE, NULL);
+
+    if (0 == readResponse(socket, "200"))
+    {
+        char strBuf[RX_SIZE];
+        unsigned char strLen, len;
+        char *p;
+        unsigned char crlf = 0;
+        unsigned char ciklen = 0;
+        char NCIK[CIK_LENGTH];
+
+        do
+        {
+            strLen = socket->receive(strBuf, RX_SIZE);
+            len = strLen;
+            p = strBuf;
+            // Find 4 consecutive \r or \n - should be: \r\n\r\n
+            while (0 < len && 4 > crlf)
+            {
+                if ('\r' == *p || '\n' == *p)
+                {
+                    ++crlf;
+                }
+                else
+                {
+                    crlf = 0;
+                }
+                ++p;
+                --len;
+            }
+
+            // The body is the CIK
+            if (0 < len && 4 == crlf && CIK_LENGTH > ciklen)
+            {
+                // TODO, be more robust - match Content-Length header value to CIK_LENGTH
+                unsigned char need, part;
+                need = CIK_LENGTH - ciklen;
+                part = need < len ? need : len;
+                strncpy(NCIK + ciklen, p, part);
+                ciklen += part;
+            }
+        } while (RX_SIZE == strLen);
+
+        if (CIK_LENGTH == ciklen)
+        {
+            exosite_meta_write((unsigned char *)NCIK, CIK_LENGTH, META_CIK);
+        }
+    }
+    else
+    {
+        printf("Activation failed\n");
+        getchar();
+    }
+    socket->close();
+}
+
+//*****************************************************************************
+//
+//! connect_to_exosite
+//!
+//!  \param  None
+//!
+//!  \return socket handle
+//!
+//!  \brief  Establishes a connection with the Exosite API server
+//
+//*****************************************************************************
+long connect_to_exosite(TCPSocketConnection *socket)
+{    
+    static unsigned char connectRetries = 0;
+    long sock;
+
+    if (connectRetries++ > 5)
+    {
+        connectRetries = 0;
+        printf("ERROR %d\r\n", EXO_ERROR_CONNECT);
+    }
+
+    const char* ECHO_SERVER_ADDRESS = "173.255.209.28"; //TODO - use DNS or check m2.exosite.com/ip to check for updates
+    const int ECHO_SERVER_PORT = 80;
+    
+    unsigned char server[META_SERVER_SIZE];
+    exosite_meta_read(server, META_SERVER_SIZE, META_SERVER);
+
+    sock = socket->connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
+    if(sock < 0)
+    {
+        printf("Connection to server failed\n");
+        socket->close();
+        wait_ms(200);
+        return -1;
+    }
+    else
+    {
+        connectRetries = 0;
+        //printf("ShowUIcode %d\n", EXO_SERVER_CONNECTED);
+    }
+
+    // Success
+    //printf("success\n");
+    return sock;
+}
+
+
+//*****************************************************************************
+//
+//! readResponse
+//!
+//!  \param  socket handle, pointer to expected HTTP response code
+//!
+//!  \return 0 if match, -1 if no match
+//!
+//!  \brief  Reads first 12 bytes of HTTP response and extracts the 3 byte code
+//
+//*****************************************************************************
+int readResponse(TCPSocketConnection *socket, char * code)
+{
+    char rxBuf[12];
+    unsigned char rxLen;
+    rxLen = socket->receive(rxBuf, 12);
+//PROBLEM : more than 12 chars are printed 
+    printf("rec %s\n", rxBuf);
+    if (12 == rxLen && code[0] == rxBuf[9] && code[1] == rxBuf[10] && code[2] == rxBuf[11])
+    {
+        return 0;
+    }
+
+    return -1;
+}
+
+
+//*****************************************************************************
+//
+//! sendLine
+//!
+//!  \param  Which line type
+//!
+//!  \return socket handle
+//!
+//!  \brief  Sends data out the socket
+//
+//*****************************************************************************
+void sendLine(TCPSocketConnection *socket, unsigned char LINE, char * payload)
+{
+    char strBuf[80];
+    unsigned char strLen = 0;
+
+    switch(LINE)
+    {
+    case CIK_LINE:
+        sprintf(strBuf, "X-Exosite-CIK: %s\r\n", activeCIK);    
+        strLen = strlen(strBuf);
+        //strLen = 57;
+        //memcpy(strBuf,STR_CIK_HEADER,strLen);
+        //exosite_meta_read((unsigned char *)&strBuf[strLen], CIK_LENGTH, META_CIK);
+        //strLen += CIK_LENGTH;
+        //memcpy(&strBuf[strLen],STR_CRLF, 2);
+        //strLen += 2;
+        break;
+    case HOST_LINE:
+        strLen = 28;
+        memcpy(strBuf,STR_HOST,strLen);
+        strBuf[strLen] = NULL;
+        break;
+    case CONTENT_LINE:
+        strLen = 64;
+        memcpy(strBuf,STR_CONTENT,strLen);
+        strBuf[strLen] = NULL;
+        break;
+    case ACCEPT_LINE:
+        strLen = 58;
+        memcpy(strBuf,STR_ACCEPT,strLen);
+        memcpy(&strBuf[strLen],payload, strlen(payload));
+        strLen += strlen(payload);
+        break;
+    case LENGTH_LINE: // Content-Length: NN
+        strLen = 16;
+        memcpy(strBuf,STR_CONTENT_LENGTH,strLen);
+        memcpy(&strBuf[strLen],payload, strlen(payload));
+        strLen += strlen(payload);
+        memcpy(&strBuf[strLen],STR_CRLF, 2);
+        strLen += 2;
+        memcpy(&strBuf[strLen],STR_CRLF, 2);
+        strLen += 2;
+        strBuf[strLen] = NULL;
+        break;
+    case GETDATA_LINE:
+        strLen = 24;
+        memcpy(strBuf,STR_GET_URL,strLen);
+        memcpy(&strBuf[strLen],payload, strlen(payload));
+        strLen += strlen(payload);
+        memcpy(&strBuf[strLen],STR_HTTP, 12);
+        strLen += 12;
+        break;
+    case VENDOR_LINE:
+        strLen = strlen(STR_VENDOR);
+        memcpy(strBuf, STR_VENDOR, strLen);
+        exosite_meta_read((unsigned char *)&strBuf[strLen], META_UUID_SIZE, META_UUID);
+        strLen += META_UUID_SIZE;
+        strBuf[strLen] = NULL;
+        break;
+    case POSTDATA_LINE:
+        strLen = 5;
+        memcpy(strBuf,"POST ", strLen);
+        memcpy(&strBuf[strLen],payload, strlen(payload));
+        strLen += strlen(payload);
+        memcpy(&strBuf[strLen],STR_HTTP, 12);
+        strLen += 12;
+        strBuf[strLen] = NULL;
+        break;
+    case EMPTY_LINE:
+        strLen = 2;
+        memcpy(strBuf,STR_CRLF,strLen);
+        break;
+    default:
+        break;
+    }
+    //printf("sendLine: %s\n", strBuf);
+    socket->send_all(strBuf, strLen);
+    wifi._event.hci_unsolicited_event_handler();
+    return;
+}
+
+//*****************************************************************************
+//
+//! exosite_meta_write
+//!
+//!  \param  write_buffer - string buffer containing info to write to meta;
+//!          srcBytes - size of string in bytes; element - item from
+//!          MetaElements enum.
+//!
+//!  \return None
+//!
+//!  \brief  Writes specific meta information to meta memory.
+//
+//*****************************************************************************
+void exosite_meta_write(unsigned char * write_buffer, unsigned short srcBytes, unsigned char element)
+{
+    exosite_meta * meta_info = 0;
+
+    //TODO - do not write if the data already there is identical...
+
+    switch (element)
+    {
+        case META_CIK:
+            if (srcBytes > META_CIK_SIZE) return;
+            memcpy((char *)(exo_meta + (int)meta_info->cik), write_buffer, srcBytes); //store CIK
+            break;
+        case META_SERVER:
+            if (srcBytes > META_SERVER_SIZE) return;
+            memcpy((char *)(exo_meta + (int)meta_info->server), write_buffer, srcBytes); //store server IP
+            break;
+        case META_MARK:
+            if (srcBytes > META_MARK_SIZE) return;
+            memcpy((char *)(exo_meta + (int)meta_info->mark), write_buffer, srcBytes); //store exosite mark
+            break;
+        case META_UUID:
+            if (srcBytes > META_UUID_SIZE) return;
+            memcpy((char *)(exo_meta + (int)meta_info->uuid), write_buffer, srcBytes); //store UUID
+            break;
+        case META_MFR:
+            if (srcBytes > META_MFR_SIZE) return;
+            memcpy((char *)(exo_meta + (int)meta_info->mfr), write_buffer, srcBytes); //store manufacturing info
+            break;
+        case META_NONE:
+        default:
+            break;
+    }
+    return;
+}
+
+
+//*****************************************************************************
+//
+//! exosite_meta_read
+//!
+//!  \param  read_buffer - string buffer to receive element data; destBytes -
+//!          size of buffer in bytes; element - item from MetaElements enum.
+//!
+//!  \return None
+//!
+//!  \brief  Writes specific meta information to meta memory.
+//
+//*****************************************************************************
+void exosite_meta_read(unsigned char * read_buffer, unsigned short destBytes, unsigned char element)
+{
+    exosite_meta * meta_info = 0;
+
+    switch (element)
+    {
+        case META_CIK:
+            if (destBytes < META_CIK_SIZE) return;
+            memcpy(read_buffer, (char *)(exo_meta + (int)meta_info->cik), destBytes); //read CIK
+            break;
+        case META_SERVER:
+            if (destBytes < META_SERVER_SIZE) return;
+            memcpy(read_buffer, (char *)(exo_meta + (int)meta_info->server), destBytes); //read server IP
+            break;
+        case META_MARK:
+            if (destBytes < META_MARK_SIZE) return;
+            memcpy(read_buffer, (char *)(exo_meta + (int)meta_info->mark), destBytes); //read exosite mark
+            break;
+        case META_UUID:
+            if (destBytes < META_UUID_SIZE) return;
+            memcpy(read_buffer, (char *)(exo_meta + (int)meta_info->uuid), destBytes); //read exosite mark
+            break;
+        case META_MFR:
+            if (destBytes < META_MFR_SIZE) return;
+            memcpy(read_buffer, (char *)(exo_meta + (int)meta_info->mfr), destBytes); //read exosite mark
+            break;
+        case META_NONE:
+            default:
+            break;
+    }
+    return;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Webserver/run_exosite.h	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,120 @@
+#ifndef RUN_EXOSITE_H
+#define RUN_EXOSITE_H
+
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+
+extern cc3000 wifi;
+extern tUserFS user_info;
+
+#ifdef    __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+void run_exosite(TCPSocketConnection *socket);
+
+// defines
+enum UUIDInterfaceTypes
+{
+    IF_WIFI,
+    IF_ENET,
+    IF_FILE,
+    IF_HDD,
+    IF_I2C,
+    IF_GPRS,
+    IF_NONE
+};
+
+enum ExositeStatusCodes
+{
+    EXO_STATUS_OK,
+    EXO_STATUS_INIT,
+    EXO_STATUS_BAD_UUID,
+    EXO_STATUS_BAD_VENDOR,
+    EXO_STATUS_BAD_MODEL,
+    EXO_STATUS_BAD_INIT,
+    EXO_STATUS_BAD_TCP,
+    EXO_STATUS_BAD_SN,
+    EXO_STATUS_CONFLICT,
+    EXO_STATUS_BAD_CIK,
+    EXO_STATUS_NOAUTH,
+    EXO_STATUS_END
+};
+
+#define EXOSITE_VENDOR_MAXLENGTH                20
+#define EXOSITE_MODEL_MAXLENGTH                 20
+#define EXOSITE_SN_MAXLENGTH                    EXOSITE_HAL_SN_MAXLENGTH
+#define EXOSITE_DEMO_UPDATE_INTERVAL            4000// ms
+#define CIK_LENGTH                              40
+
+// --------------   META   --------------
+// defines
+#define META_SIZE                 256
+#define META_CIK_SIZE             40
+#define META_SERVER_SIZE          6
+#define META_PAD0_SIZE            2
+#define META_MARK_SIZE            8
+#define META_UUID_SIZE            17
+#define META_PAD1_SIZE            4
+#define META_RSVD_SIZE            56
+#define META_MFR_SIZE             128
+typedef struct {
+  char cik[META_CIK_SIZE];                   // our client interface key
+  char server[META_SERVER_SIZE];             // ip address of m2.exosite.com (not using DNS at this stage)
+  char pad0[META_PAD0_SIZE];                 // pad 'server' to 8 bytes
+  char mark[META_MARK_SIZE];                 // watermark
+  char uuid[META_UUID_SIZE];                 // UUID in ascii
+  char pad1[META_PAD1_SIZE];                 // pad 'uuid' to 16 bytes
+  char rsvd[META_RSVD_SIZE];                 // reserved space - pad to ensure mfr is at end of RDK_META_SIZE
+  char mfr[META_MFR_SIZE];                   // manufacturer data structure
+} exosite_meta;
+
+#define EXOMARK "exosite!"
+
+typedef enum
+{
+    META_CIK,
+    META_SERVER,
+    META_MARK,
+    META_UUID,
+    META_MFR,
+    META_NONE
+} MetaElements;
+
+
+// --------------   HAL   --------------
+// defines
+/*typedef enum
+{
+    IF_WIFI,
+    IF_ENET,
+    IF_FILE,
+    IF_HDD,
+    IF_I2C,
+    IF_NONE
+} UUIDInterfaceTypes;*/
+
+typedef enum
+{
+    EXO_ERROR_WRITE,
+    EXO_ERROR_READ,
+    EXO_ERROR_CONNECT,
+    EXO_ERROR_UNKNOWN,
+    EXO_ERROR_END
+} ExositeErrorCodes;
+
+typedef enum
+{
+    EXO_SERVER_CONNECTED,
+    EXO_CLIENT_RW,
+    EXO_UI_END
+} ExositeUICodes;
+
+#ifdef    __cplusplus
+}
+#endif // __cplusplus
+
+#endif // RUN_EXOSITE_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cc3000_hostdriver_mbedsocket.lib	Sun Dec 01 15:06:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Kojto/code/cc3000_hostdriver_mbedsocket/#ca8c234997c0
--- a/cc3000_hostdriver_mbedsocket/Helper/def.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef DEF_H
-#define DEF_H
-
-#include "cmsis.h"
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/Socket/Endpoint.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include "Socket/Socket.h"
-#include "Socket/Endpoint.h"
-#include "Helper/def.h"
-#include <cstring>
-
- #include "cc3000.h"
-
-/* Copied from lwip */
-static char *inet_ntoa_r(const in_addr addr, char *buf, int buflen)
-{
-  uint32_t s_addr;
-  char inv[3];
-  char *rp;
-  uint8_t *ap;
-  uint8_t rem;
-  uint8_t n;
-  uint8_t i;
-  int len = 0;
-
-  s_addr = addr.s_addr;
-
-  rp = buf;
-  ap = (uint8_t *)&s_addr;
-  for(n = 0; n < 4; n++) {
-    i = 0;
-    do {
-      rem = *ap % (uint8_t)10;
-      *ap /= (uint8_t)10;
-      inv[i++] = '0' + rem;
-    } while(*ap);
-    while(i--) {
-      if (len++ >= buflen) {
-        return NULL;
-      }
-      *rp++ = inv[i];
-    }
-    if (len++ >= buflen) {
-      return NULL;
-    }
-    *rp++ = '.';
-    ap++;
-  }
-  *--rp = 0;
-  return buf;
-}
-
-Endpoint::Endpoint()  {
-    _cc3000_module = cc3000::get_instance();
-    if (_cc3000_module == NULL) {
-        error("Endpoint constructor error: no cc3000 instance available!\r\n");
-    }
-    reset_address();
-}
-Endpoint::~Endpoint() {}
-
-void Endpoint::reset_address(void) {
-    _ipAddress[0] = '\0';
-    std::memset(&_remote_host, 0, sizeof(sockaddr_in));
-}
-
-int Endpoint::set_address(const char* host, const int port) {
-    reset_address();
-
-    int resolveRetCode;
-    char address[5];
-    char *p_address = address;
-
-    signed int add[5];
-
-    // Dot-decimal notation
-    int result = std::sscanf(host, "%3u.%3u.%3u.%3u", &add[0], &add[1], &add[2], &add[3]);
-    for (int i=0;i<4;i++) {
-      address[i] = add[i];
-    }
-    std::memset(_ipAddress,0,sizeof(_ipAddress));
-
-    if (result != 4) {
-        //Resolve DNS address or populate hard-coded IP address
-        uint32_t address_integer;
-        resolveRetCode = _cc3000_module->_socket.gethostbyname((uint8_t *)host, strlen(host) , &address_integer);
-
-        if ((resolveRetCode > -1) && (0 != address_integer)) {
-            _remote_host.sin_addr.s_addr = htonl(address_integer);
-            inet_ntoa_r(_remote_host.sin_addr, _ipAddress, sizeof(_ipAddress));
-        } else {
-            // Failed to resolve the address
-            DBG_SOCKET("Failed to resolve the hostname : %s",host);
-            return (-1);
-        }
-    } else {
-        std::memcpy((char*)&_remote_host.sin_addr.s_addr, p_address, 4);
-    }
-
-    _remote_host.sin_family = AF_INET;
-    _remote_host.sin_port = htons(port);
-
-    DBG_SOCKET("remote host address (string): %s",get_address());
-    DBG_SOCKET("remote host address from s_addr : %d.%d.%d.%d",
-            int(_remote_host.sin_addr.s_addr & 0xFF),
-            int((_remote_host.sin_addr.s_addr & 0xFF00) >> 8),
-            int((_remote_host.sin_addr.s_addr & 0xFF0000) >> 16),
-            int((_remote_host.sin_addr.s_addr & 0xFF000000) >> 24));
-    DBG_SOCKET("port: %d", port);
-
-    return 0;
-}
-
-char* Endpoint::get_address() {
-    if ((_ipAddress[0] == '\0') && (_remote_host.sin_addr.s_addr != 0))
-            inet_ntoa_r(_remote_host.sin_addr, _ipAddress, sizeof(_ipAddress));
-    return _ipAddress;
-}
-
-
-int   Endpoint::get_port() {
-    return ntohs(_remote_host.sin_port);
-}
--- a/cc3000_hostdriver_mbedsocket/Socket/Endpoint.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#ifndef ENDPOINT_H
-#define ENDPOINT_H
-
-#include "cc3000.h"
-
-using namespace mbed_cc3000;
-
-class UDPSocket;
-
-/**
-IP Endpoint (address, port)
-*/
-class Endpoint {
-    friend class UDPSocket;
-
-public:
-    /** IP Endpoint (address, port)
-     */
-    Endpoint(void);
-
-    ~Endpoint(void);
-
-    /** Reset the address of this endpoint
-     */
-    void reset_address(void);
-
-    /** Set the address of this endpoint
-    \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS).
-    \param port The endpoint port
-    \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS).
-     */
-    int  set_address(const char* host, const int port);
-
-    /** Get the IP address of this endpoint
-    \return The IP address of this endpoint.
-     */
-    char* get_address(void);
-
-    /** Get the port of this endpoint
-    \return The port of this endpoint
-     */
-    int get_port(void);
-
-protected:
-    char _ipAddress[17];
-    sockaddr_in _remote_host;
-    cc3000 *_cc3000_module;
-};
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/Socket/Socket.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "Socket.h"
-#include <cstring>
-
-Socket::Socket() : _sock_fd(-1), _blocking(true), _timeout(1500) {
-    _cc3000_module = cc3000::get_instance();
-    if (_cc3000_module == NULL) {
-        error("Socket constructor error: no cc3000 instance available!\r\n");
-    }
-}
-
-int Socket::init_socket(int type, int protocol) {
-    if (_sock_fd != -1) {
-        DBG_SOCKET("Socket was initialized previously");
-        return -1;
-    }
-
-    int fd = _cc3000_module->_socket.socket(AF_INET, type, protocol);
-    if (fd < -1) {
-        DBG_SOCKET("Failed to create new socket (type: %d, protocol: %d)",type, protocol);
-        return -1;
-    }
-    
-    DBG_SOCKET("Socket created (fd: %d type: %d, protocol: %d)",fd, type, protocol);
-    _sock_fd = fd;
-
-    return 0;
-}
-
-void Socket::set_blocking(bool blocking, unsigned int timeout) {
-    _blocking = blocking;
-    _timeout = timeout;
-}
-
-int Socket::set_option(int level, int optname, const void *optval, socklen_t optlen) {
-    return _cc3000_module->_socket.setsockopt(_sock_fd, level, optname, optval, optlen);
-}
-
-int Socket::get_option(int level, int optname, void *optval, socklen_t *optlen) {
-    return _cc3000_module->_socket.getsockopt(_sock_fd, level, optname, optval, optlen);
-}
-
-int Socket::select(struct timeval *timeout, bool read, bool write) {
-    if (_sock_fd < 0) {
-        return -1;
-    }
-
-    fd_set fdSet;
-    FD_ZERO(&fdSet);
-    FD_SET(_sock_fd, &fdSet);
-
-    fd_set* readset  = (read ) ? (&fdSet) : (NULL);
-    fd_set* writeset = (write) ? (&fdSet) : (NULL);
-
-    int ret = _cc3000_module->_socket.select(_sock_fd+1, readset, writeset, NULL, timeout);
-    
-    DBG_SOCKET("Select on sock_fd: %d, returns %d. fdSet: %d", _sock_fd, ret, FD_ISSET(_sock_fd, &fdSet));
-    
-    // TODO
-    //return (ret <= 0 || !FD_ISSET(_sock_fd, &fdSet)) ? (-1) : (0);
-    if (FD_ISSET(_sock_fd, &fdSet)) {
-        return 0;
-    } else {
-        return -1;
-    }
-}
-
-int Socket::wait_readable(TimeInterval& timeout) {
-    return select(&timeout._time, true, false);
-}
-
-int Socket::wait_writable(TimeInterval& timeout) {
-    return select(&timeout._time, false, true);
-}
-
-int Socket::close() {
-    if (_sock_fd < 0 ) {
-        return -1;
-    }
-
-    _cc3000_module->_socket.closesocket(_sock_fd);
-    _sock_fd = -1;
-    return 0;
-}
-
-Socket::~Socket() {
-    close();
-}
-
-TimeInterval::TimeInterval(unsigned int ms) {
-    _time.tv_sec = ms / 1000;
-    _time.tv_usec = (ms - (_time.tv_sec * 1000)) * 1000;
-}
--- a/cc3000_hostdriver_mbedsocket/Socket/Socket.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#ifndef SOCKET_H
-#define SOCKET_H
-
-#include "cc3000.h"
-
-using namespace mbed_cc3000;
-
-class TimeInterval;
-
-/** Socket file descriptor and select wrapper
-  */
-class Socket {
-public:
-    /** Socket
-     */
-    Socket();
-
-    /** Set blocking or non-blocking mode of the socket and a timeout on
-        blocking socket operations
-    \param blocking  true for blocking mode, false for non-blocking mode.
-    \param timeout   timeout in ms [Default: (1500)ms].
-    */
-    void set_blocking(bool blocking, unsigned int timeout=1500);
-
-    /** Set socket options
-    \param level     stack level (see: lwip/sockets.h)
-    \param optname   option ID
-    \param optval    option value
-    \param socklen_t length of the option value
-    \return 0 on success, -1 on failure
-    */
-    int set_option(int level, int optname, const void *optval, socklen_t optlen);
-
-    /** Get socket options
-        \param level     stack level (see: lwip/sockets.h)
-        \param optname   option ID
-        \param optval    buffer pointer where to write the option value
-        \param socklen_t length of the option value
-        \return 0 on success, -1 on failure
-        */
-    int get_option(int level, int optname, void *optval, socklen_t *optlen);
-
-
-    /** Close the socket file descriptor
-     */
-    int close();
-
-    ~Socket();
-
-protected:
-    int _sock_fd;
-
-    int init_socket(int type, int protocol);
-
-    int wait_readable(TimeInterval& timeout);
-    int wait_writable(TimeInterval& timeout);
-
-    bool _blocking;
-    int _timeout;
-
-    cc3000 *_cc3000_module;
-private:
-    int select(struct timeval *timeout, bool read, bool write);
-};
-
-/** Time interval class used to specify timeouts
- */
-class TimeInterval {
-    friend class Socket;
-
-public:
-    /** Time Interval
-     \param ms time interval expressed in milliseconds
-      */
-    TimeInterval(unsigned int ms);
-
-private:
-    struct timeval _time;
-};
-
-#endif /* SOCKET_H */
--- a/cc3000_hostdriver_mbedsocket/Socket/TCPSocketConnection.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "TCPSocketConnection.h"
-#include <algorithm>
-
-TCPSocketConnection::TCPSocketConnection() : _is_connected(false) {
-    _cc3000_module = cc3000::get_instance();
-    if (_cc3000_module == NULL) {
-        error("Endpoint constructor error: no cc3000 instance available!\r\n");
-    }
-}
-
-int TCPSocketConnection::connect(const char *host, const int port) {
-    if (init_socket(SOCK_STREAM, IPPROTO_TCP) < 0) {
-        DBG_SOCKET("Failed to create tcp socket");
-        return -1;
-    }
-
-    if (set_address(host, port) != 0) {
-        DBG_SOCKET("Failed to set address (tcp)");
-        return -1;
-    }
-
-    if (_cc3000_module->_socket.connect(_sock_fd, (const sockaddr *)&_remote_host, sizeof(_remote_host)) < 0) {
-        DBG_SOCKET("Failed to connect (tcp)");
-        close();
-        return -1;
-    }
-
-    _is_connected = true;
-
-    return 0;
-}
-
-bool TCPSocketConnection::is_connected(void) {
-    return _is_connected;
-}
-
-int TCPSocketConnection::send(char* data, int length) {
-    if ((_sock_fd < 0) || !_is_connected) {
-        return -1;
-    }
-
-    if (!_blocking) {
-        TimeInterval timeout(_timeout);
-        if (wait_writable(timeout) != 0) {
-            return -1;
-        }
-    }
-
-    int n = _cc3000_module->_socket.send(_sock_fd, data, length, 0);
-    _is_connected = (n != 0);
-
-    return n;
-}
-
-int TCPSocketConnection::send_all(char *data, int length) {
-    if ((_sock_fd < 0) || !_is_connected) {
-        return -1;
-    }
-
-    int writtenLen = 0;
-    TimeInterval timeout(_timeout);
-    while (writtenLen < length) {
-        if (!_blocking) {
-            // Wait for socket to be writeable
-            if (wait_writable(timeout) != 0) {
-                return writtenLen;
-            }
-        }
-
-        int ret = _cc3000_module->_socket.send(_sock_fd, data + writtenLen, length - writtenLen, 0);
-        if (ret > 0) {
-            writtenLen += ret;
-            continue;
-        } else if (ret == 0) {
-            _is_connected = false;
-            return writtenLen;
-        } else {
-            return -1; //Connnection error
-        }
-    }
-
-    return writtenLen;
-}
-
-int TCPSocketConnection::receive(char *data, int length) {
-    if ((_sock_fd < 0) || !_is_connected) {
-        return -1;
-    }
-
-    if (!_blocking) {
-        TimeInterval timeout(_timeout);
-        if (wait_readable(timeout) != 0)
-            return -1;
-    }
-
-    int n = _cc3000_module->_socket.recv(_sock_fd, data, length, 0);
-    if (n >= 0) {
-        _is_connected = 1;
-    } else {
-        _is_connected = 0;
-    }
-
-    return n;
-}
-
-int TCPSocketConnection::receive_all(char *data, int length) {
-    if ((_sock_fd < 0) || !_is_connected) {
-        return -1;
-    }
-
-    int readLen = 0;
-    TimeInterval timeout(_timeout);
-    while (readLen < length) {
-        if (!_blocking) {
-            //Wait for socket to be readable
-            if (wait_readable(timeout) != 0)
-                return readLen;
-        }
-
-        int ret = _cc3000_module->_socket.recv(_sock_fd, data + readLen, length - readLen, 0);
-        if (ret > 0) {
-            readLen += ret;
-        } else if (ret == 0) {
-            _is_connected = false;
-            return readLen;
-        } else {
-            return -1; //Connnection error
-        }
-    }
-    return readLen;
-}
--- a/cc3000_hostdriver_mbedsocket/Socket/TCPSocketConnection.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef TCPSOCKET_H
-#define TCPSOCKET_H
-
-#include "Socket.h"
-#include "Endpoint.h"
-
-/**
-TCP socket connection
-*/
-class TCPSocketConnection: public Socket, public Endpoint {
-    friend class TCPSocketServer;
-
-public:
-    /** TCP socket connection
-    */
-    TCPSocketConnection();
-
-    /** Connects this TCP socket to the server
-    \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
-    \param port The host's port to connect to.
-    \return 0 on success, -1 on failure.
-    */
-    int connect(const char *host, const int port);
-
-    /** Check if the socket is connected
-    \return true if connected, false otherwise.
-    */
-    bool is_connected(void);
-
-    /** Send data to the remote host.
-    \param data The buffer to send to the host.
-    \param length The length of the buffer to send.
-    \return the number of written bytes on success (>=0) or -1 on failure
-     */
-    int send(char *data, int length);
-
-    /** Send all the data to the remote host.
-    \param data The buffer to send to the host.
-    \param length The length of the buffer to send.
-    \return the number of written bytes on success (>=0) or -1 on failure
-    */
-    int send_all(char *data, int length);
-
-    /** Receive data from the remote host.
-    \param data The buffer in which to store the data received from the host.
-    \param length The maximum length of the buffer.
-    \return the number of received bytes on success (>=0) or -1 on failure
-     */
-    int receive(char *data, int length);
-
-    /** Receive all the data from the remote host.
-    \param data The buffer in which to store the data received from the host.
-    \param length The maximum length of the buffer.
-    \return the number of received bytes on success (>=0) or -1 on failure
-    */
-    int receive_all(char *data, int length);
-private:
-    bool _is_connected;
-    cc3000 *_cc3000_module;
-};
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/Socket/TCPSocketServer.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "TCPSocketServer.h"
-#include <string>
-
-TCPSocketServer::TCPSocketServer() {
-
-}
-
-int TCPSocketServer::bind(int port) {
-    if (init_socket(SOCK_STREAM, IPPROTO_TCP) < 0) {
-        return -1;
-    }
-
-    sockaddr_in localHost;
-    memset(&localHost, 0, sizeof(localHost));
-
-    localHost.sin_family = AF_INET;
-    localHost.sin_port = htons(port);
-    localHost.sin_addr.s_addr = 0;
-
-    if (_cc3000_module->_socket.bind(_sock_fd, (const sockaddr *)&localHost, sizeof(localHost)) < 0) {
-        close();
-        return -1;
-    }
-
-    return 0;
-}
-
-int TCPSocketServer::listen(int max) {
-    if (_sock_fd < 0) {
-        return -1;
-    }
-
-    if (_cc3000_module->_socket.listen(_sock_fd, max) < 0) {
-        close();
-        return -1;
-    }
-
-    return 0;
-}
-
-
-int TCPSocketServer::accept(TCPSocketConnection& connection) {
-    if (_sock_fd < 0) {
-        return -1;
-    }
-
-    if (!_blocking) {
-        TimeInterval timeout(_timeout);
-        if (wait_readable(timeout) != 0) {
-            return -1;
-        }
-    }
-
-    connection.reset_address();
-    socklen_t newSockRemoteHostLen = sizeof(connection._remote_host);
-    int fd = _cc3000_module->_socket.accept(_sock_fd, (sockaddr *) &connection._remote_host, &newSockRemoteHostLen);
-    if (fd < 0) {
-        return -1;
-    }
-    /* s_addr is returned in the little endian */
-    connection._remote_host.sin_addr.s_addr = htonl(connection._remote_host.sin_addr.s_addr);
-    connection._sock_fd = fd;
-    connection._is_connected = true;
-
-    return 0;
-}
--- a/cc3000_hostdriver_mbedsocket/Socket/TCPSocketServer.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#ifndef TCPSOCKETSERVER_H
-#define TCPSOCKETSERVER_H
-
-#include "Socket/Socket.h"
-#include "TCPSocketConnection.h"
-
-/** TCP Server.
-  */
-class TCPSocketServer : public Socket {
-  public:
-    /** Instantiate a TCP Server.
-    */
-    TCPSocketServer();
-
-    /** Bind a socket to a specific port.
-    \param port The port to listen for incoming connections on.
-    \return 0 on success, -1 on failure.
-    */
-    int bind(int port);
-
-    /** Start listening for incoming connections.
-    \param backlog number of pending connections that can be queued up at any
-                   one time [Default: 1].
-    \return 0 on success, -1 on failure.
-    */
-    int listen(int backlog=1);
-
-    /** Accept a new connection.
-    \param connection A TCPSocketConnection instance that will handle the incoming connection.
-    \return 0 on success, -1 on failure.
-    */
-    int accept(TCPSocketConnection& connection);
-};
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/Socket/UDPSocket.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "UDPSocket.h"
-
-#include <string>
-#include <algorithm>
-
-UDPSocket::UDPSocket() {
-
-}
-
-int UDPSocket::init(void) {
-    return init_socket(SOCK_DGRAM, IPPROTO_UDP);
-}
-
-int UDPSocket::bind(int port) {
-    if (init_socket(SOCK_DGRAM, IPPROTO_UDP) < 0) {
-        return -1;
-    }
-
-    sockaddr_in localHost;
-    std::memset(&localHost, 0, sizeof(sockaddr_in));
-
-    localHost.sin_family = AF_INET;
-    localHost.sin_port = htons(port);
-    localHost.sin_addr.s_addr = 0;
-
-    if (_cc3000_module->_socket.bind(_sock_fd, (sockaddr *)&localHost, sizeof(sockaddr_in)) != 0) {
-        DBG_SOCKET("Failed to bind a socket (udp). Closing socket");
-        _cc3000_module->_socket.closesocket(_sock_fd);
-        _sock_fd = -1;
-        return -1;
-    }
-
-    return 0;
-}
-
-int UDPSocket::sendTo(Endpoint &remote, char *packet, int length)
-{
-    if (_sock_fd < 0) {
-        return -1;
-    }
-    // TODO - seems to be a bug, waiting for TI to respond
-    // if (!_blocking) {
-    //     TimeInterval timeout(_timeout);
-    //     if (wait_writable(timeout) != 0) {
-    //         DBG_SOCKET("The socket is not writeable. _sock_fd: %d", _sock_fd);
-    //         return 0;
-    //     }
-    // }
-
-    return _cc3000_module->_socket.sendto(_sock_fd, packet, length, 0, (sockaddr *)&remote._remote_host, sizeof(sockaddr));
-}
-
-int UDPSocket::receiveFrom(Endpoint &remote, char *buffer, int length)
-{
-    if (_sock_fd < 0) {
-        return -1;
-    }
-
-    if (!_blocking) {
-        TimeInterval timeout(_timeout);
-        if (wait_readable(timeout) != 0) {
-            DBG_SOCKET("The socket is not readable. _sock_fd: %d", _sock_fd);
-            return 0;
-        }
-    }
-
-    remote.reset_address();
-    socklen_t remote_host_length = sizeof(remote._remote_host);
-
-    return _cc3000_module->_socket.recvfrom(_sock_fd, buffer, length, 0, (sockaddr *)&remote._remote_host, &remote_host_length);
-}
-
-
--- a/cc3000_hostdriver_mbedsocket/Socket/UDPSocket.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/* Copyright (C) 2013 mbed.org, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef UDPSOCKET_H
-#define UDPSOCKET_H
-
-#include "Endpoint.h"
-#include "Socket.h"
-
-#include <cstdint>
-
-/**
-UDP Socket
-*/
-class UDPSocket: public Socket {
-
-public:
-    /** Instantiate an UDP Socket.
-    */
-    UDPSocket();
-
-    /** Init the UDP Client Socket without binding it to any specific port
-    \return 0 on success, -1 on failure.
-    */
-    int init(void);
-
-    /** Bind a UDP Server Socket to a specific port
-    \param port The port to listen for incoming connections on
-    \return 0 on success, -1 on failure.
-    */
-    int bind(int port = -1);
-
-    /** Send a packet to a remote endpoint
-    \param remote   The remote endpoint
-    \param packet   The packet to be sent
-    \param length   The length of the packet to be sent
-    \return the number of written bytes on success (>=0) or -1 on failure
-    */
-    int sendTo(Endpoint &remote, char *packet, int length);
-
-    /** Receive a packet from a remote endpoint
-    \param remote   The remote endpoint
-    \param buffer   The buffer for storing the incoming packet data. If a packet
-           is too long to fit in the supplied buffer, excess bytes are discarded
-    \param length   The length of the buffer
-    \return the number of received bytes on success (>=0) or -1 on failure
-    */
-    int receiveFrom(Endpoint &remote, char *buffer, int length);
-};
-
-#include "def.h"
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,452 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_event.h"
-
-namespace mbed_cc3000 {
-
-/* TODO this prefix remove? verify */
-static uint8_t cc3000_prefix[] = {'T', 'T', 'T'};
-cc3000 *cc3000::_inst;
-
-cc3000::cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port)
-            :  _event(_simple_link, _hci, _spi, *this), _socket(_simple_link, _hci, _event), _spi(cc3000_irq, cc3000_en, cc3000_cs, cc3000_spi, irq_port, _event, _simple_link), _hci(_spi),
-            _nvmem(_hci, _event, _simple_link), _netapp(_simple_link, _nvmem, _hci, _event), _wlan(_simple_link, _event, _spi, _hci) {
-    /* TODO - pIRQ riorities ?? */
-
-    _simple_link.set_tx_complete_signal(1);
-    _status.dhcp = 0;
-    _status.connected = 0;
-    _status.socket = 0;
-    _status.dhcp_configured = 0;
-    _status.smart_config_complete = 0;
-    _status.stop_smart_config = 0;
-    _status.ok_to_shut_down = 0;
-    _status.enabled = 0;
-
-    _inst = this;
-}
-
-cc3000::~cc3000() {
-
-}
-
-#if (CC3000_ETH_COMPAT == 1)
-// Ethernet library compatible, functions return strings
-// Caches the ipconfig from the usync callback
-static char mac_addr[19];
-static char ip_addr[17] = "\0";
-static char gateway[17] = "\0";
-static char networkmask[17] = "\0";
-
-char* cc3000::getMACAddress() {
-    return mac_addr;
-}
-
-char* cc3000::getIPAddress() {
-    return ip_addr;
-}
-
-char* cc3000::getGateway() {
-    return gateway;
-}
-
-char* cc3000::getNetworkMask() {
-    return networkmask;
-}
-#endif
-
-void cc3000::usync_callback(int32_t event_type, uint8_t *data, uint8_t length) {
-    if (event_type == HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE)
-    {
-        DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE");
-        _status.smart_config_complete = 1;
-        _status.stop_smart_config = 1;
-    }
-
-    if (event_type == HCI_EVNT_WLAN_UNSOL_CONNECT)
-    {
-        DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_CONNECT");
-        _status.connected = 1;
-        // Connect message is always followed by a DHCP message, connection is not useable until then
-        _status.dhcp      = 0;
-    }
-
-    if (event_type == HCI_EVNT_WLAN_UNSOL_DISCONNECT)
-    {
-        DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DISCONNECT");
-        _status.connected = 0;
-        _status.dhcp      = 0;
-        _status.dhcp_configured = 0;
-    }
-
-    if (event_type == HCI_EVNT_WLAN_UNSOL_DHCP)
-    {
-#if (CC3000_ETH_COMPAT == 1)
-        _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_IP_OFFSET]))), ip_addr, 17);
-        _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_GW_OFFSET]))), gateway, 17);
-        _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_SUBNET_OFFSET]))), networkmask, 17);
-        _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_MAC_OFFSET]))), mac_addr, 19);
-#endif
-        if (*(data + NETAPP_IPCONFIG_MAC_OFFSET) == 0) {
-            _status.dhcp = 1;
-            DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP %i.%i.%i.%i", data[3], data[2], data[1], data[0]);
-        } else {
-            DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP - Disconnecting");
-            _status.dhcp = 0;
-        }
-    }
-
-    if (event_type == HCI_EVENT_CC3000_CAN_SHUT_DOWN)
-    {
-        // Note this means the modules is idle, so it could be shutdown..
-        //DBG_CC("Callback : HCI_EVENT_CC3000_CAN_SHUT_DOWN");
-        _status.ok_to_shut_down = 1;
-    }
-
-    if (event_type == HCI_EVNT_WLAN_ASYNC_PING_REPORT)
-    {
-        DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_PING_REPORT");
-        memcpy(&_ping_report, data, length);
-    }
-
-    if (event_type == HCI_EVNT_BSD_TCP_CLOSE_WAIT) {
-        uint8_t socketnum;
-        socketnum = data[0];
-        DBG_CC("Callback : HCI_EVNT_BSD_TCP_CLOSE_WAIT - Socket : %d", socketnum);
-        if (socketnum < MAX_SOCKETS) {
-            _closed_sockets[socketnum] = true; /* clients socket is closed */
-        }
-    }
-}
-
-void cc3000::start_smart_config(const uint8_t *smart_config_key) {
-    _status.smart_config_complete = 0;
-    _wlan.ioctl_set_connection_policy(0, 0, 0);
-
-    if (_status.connected == 1)
-    {
-        disconnect();
-    }
-
-    //Wait until CC3000 is disconected
-    while (_status.connected == 1)
-    {
-        wait_us(5);
-        _event.hci_unsolicited_event_handler();
-    }
-
-    // Trigger the Smart Config process
-    _wlan.smart_config_set_prefix(cc3000_prefix);
-    // Start the Smart Config process with AES disabled
-    _wlan.smart_config_start(0);
-
-    DBG_CC("Waiting for smartconfig to be completed");
-
-    // Wait for Smart config finished
-    while (_status.smart_config_complete == 0)
-    {
-        wait_ms(100);
-    }
-
-    DBG_CC("Smartconfig finished");
-
-#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
-    // create new entry for AES encryption key
-    _nvmem.create_entry(NVMEM_AES128_KEY_FILEID, 16);
-    // write AES key to NVMEM
-    _security.aes_write_key((uint8_t *)(&smart_config_key[0]));
-    // Decrypt configuration information and add profile
-    _wlan.smart_config_process();
-#endif
-
-    // Configure to connect automatically to the AP retrieved in the
-    // Smart config process
-    _wlan.ioctl_set_connection_policy(0, 0, 1);
-
-    // reset the CC3000
-    _wlan.stop();
-    _status.enabled = 0;
-    wait(5);
-    _wlan.start(0);
-    _status.enabled = 1;
-
-    // Mask out all non-required events
-    _wlan.set_event_mask(HCI_EVNT_WLAN_KEEPALIVE | HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_ASYNC_PING_REPORT);
-}
-
-bool cc3000::connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) {
-    uint32_t ret;
-
-    //_wlan.disconnect();
-    wait_ms(3);
-    ret = _wlan.connect(security_mode, ssid, strlen((const char *)ssid), 0, (uint8_t *)key, strlen((const char *)key));
-    if (ret == 0) { /* TODO static internal cc3000 state 0 to TRUE */
-      ret = true;
-    } else {
-      ret = false;
-    }
-    return ret;
-}
-
-bool cc3000::connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode)
-{
-bool ret = false;
-
-    if (key == 0)
-    {
-        if (connect_open(ssid))
-        {
-            ret = true;
-        }
-    }
-    else
-    {
-    #ifndef CC3000_TINY_DRIVER
-        if (connect_secure(ssid,key,security_mode))
-        {
-            ret = true;
-        }
-    #else
-        /* secure connection not supported with TINY_DRIVER */
-    #endif
-    }
-
-    return ret;
-}
-
-bool cc3000::connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) {
-    Timer t;  /* TODO static? */
-    bool ret = true;
-
-    t.start();
-    while (is_connected() == false) {
-        if (key == 0) {
-            if (connect_open(ssid)) {
-                break;
-            }
-        } else {
-#ifndef CC3000_TINY_DRIVER
-            if (connect_secure(ssid,key,security_mode)) {
-                break;
-            }
-#else
-            return false; /* secure connection not supported with TINY_DRIVER */
-#endif
-        }
-
-        /* timeout 10 seconds */
-        if (t.read_ms() > 10000){
-            ret = false;
-
-            DBG_CC("Connection to AP failed");
-
-            break;
-        }
-    }
-
-    return ret;
-}
-
-void cc3000::start(uint8_t patch) {
-    _wlan.start(patch);
-    _status.enabled = 1;
-    _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE);
-}
-
-void cc3000::stop(void) {
-    _wlan.stop();
-    _status.enabled = 0;
-}
-
-void cc3000::restart(uint8_t patch) {
-    _wlan.stop();
-    _status.enabled = 0;
-    wait_ms(500);
-    _wlan.start(patch);
-    _status.enabled = 1;
-}
-
-bool cc3000::connect_open(const uint8_t *ssid) {
-    uint32_t ret;
-
-    _wlan.disconnect();
-    wait_ms(3);
-#ifndef CC3000_TINY_DRIVER
-    ret = _wlan.connect(0,ssid, strlen((const char *)ssid), 0, 0, 0);
-#else
-    ret = _wlan.connect(ssid, strlen((const char *)ssid));
-#endif
-    if (ret == 0) {
-        ret = true;
-    } else {
-        ret = false;
-    }
-    return ret;
-}
-
-bool cc3000::is_enabled()
-{
-    return _status.enabled;
-}
-
-bool cc3000::is_connected() {
-    if (( _status.connected ) && ( _status.dhcp ))
-    {
-        return( 1 );
-    }
-    else
-    {
-        return( 0 );
-    }
-}
-
-bool cc3000::is_dhcp_configured() {
-    return _status.dhcp;
-}
-
-bool cc3000::is_smart_confing_completed() {
-    return _status.smart_config_complete;
-}
-
-uint8_t cc3000::get_mac_address(uint8_t address[6]) {
-    return _nvmem.get_mac_address(address);
-}
-
-uint8_t cc3000::set_mac_address(uint8_t address[6]) {
-    return _nvmem.set_mac_address(address);
-}
-
-void cc3000::get_user_file_info(uint8_t *info_file, size_t size) {
-    _nvmem.read( NVMEM_USER_FILE_1_FILEID, size, 0, info_file);
-}
-
-#ifndef CC3000_TINY_DRIVER
-bool cc3000::get_ip_config(tNetappIpconfigRetArgs *ip_config) {
-    if ((_status.dhcp == false) || (_status.connected == false)) {
-        return false;
-    }
-
-    _netapp.ipconfig(ip_config);
-    return true;
-}
-#endif
-
-void cc3000::delete_profiles(void) {
-    tUserFS user_info;
-
-    _wlan.ioctl_set_connection_policy(0, 0, 0);
-    _wlan.ioctl_del_profile(255);
-
-    get_user_file_info((uint8_t *)&user_info, sizeof(user_info));
-    user_info.FTC = 0;
-    set_user_file_info((uint8_t *)&user_info, sizeof(user_info));
-}
-
-void cc3000::set_user_file_info(uint8_t *info_file, size_t size) {
-    _nvmem.write( NVMEM_USER_FILE_1_FILEID, size, 0, info_file);
-}
-
-bool cc3000::disconnect(void){
-    if (_wlan.disconnect()) {
-        return false;
-    } else {
-        return true;
-    }
-}
-
-uint32_t cc3000::ping(uint32_t ip, uint8_t attempts, uint16_t timeout, uint8_t size) {
-    uint32_t reversed_ip = (ip >> 24) | ((ip >> 8) & 0xFF00) | ((ip << 8) & 0xFF0000) | (ip << 24);
-
-    _ping_report.packets_received = 0;
-    if (_netapp.ping_send(&reversed_ip, attempts, size, timeout) == -1) {
-        DBG_CC("Failed to send ping");
-        return 0;
-    }
-    wait_ms(timeout*attempts*2);
-
-    /* known issue of cc3000 - sent number is send + received */
-    // TODO : Remove the Sent/recv'd counts until ti fix the firmware issue?
-    DBG_CC("Sent: %d",_ping_report.packets_sent);
-    DBG_CC("Received: %d",_ping_report.packets_received);
-    DBG_CC("Min time: %d",_ping_report.min_round_time);
-    DBG_CC("Max time: %d",_ping_report.max_round_time);
-    DBG_CC("Avg time: %d",_ping_report.avg_round_time);
-
-    return _ping_report.packets_received;
-}
-
-/* Conversion between uint types and C strings */
-uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32)
-{
-    *(p)++ = (uint8_t)(u32);
-    *(p)++ = (uint8_t)((u32) >> 8);
-    *(p)++ = (uint8_t)((u32) >> 16);
-    *(p)++ = (uint8_t)((u32) >> 24);
-    return p;
-}
-
-
-uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16)
-{
-    *(p)++ = (uint8_t)(u16);
-    *(p)++ = (uint8_t)((u16) >> 8);
-    return p;
-}
-
-
-uint16_t STREAM_TO_UINT16_f(uint8_t *p, uint16_t offset)
-{
-    return (uint16_t)((uint16_t)((uint16_t)
-           (*(p + offset + 1)) << 8) + (uint16_t)(*(p + offset)));
-}
-
-
-uint32_t STREAM_TO_UINT32_f(uint8_t *p, uint16_t offset)
-{
-    return (uint32_t)((uint32_t)((uint32_t)
-           (*(p + offset + 3)) << 24) + (uint32_t)((uint32_t)
-           (*(p + offset + 2)) << 16) + (uint32_t)((uint32_t)
-           (*(p + offset + 1)) << 8) + (uint32_t)(*(p + offset)));
-}
-
-} /* end of mbed_cc3000 namespace */
-
--- a/cc3000_hostdriver_mbedsocket/cc3000.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1783 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_H
-#define CC3000_H
-
-#include "mbed.h"
-#include "cc3000_common.h"
-#include "cc3000_spi.h"
-#include "cc3000_simplelink.h"
-#include "cc3000_netapp.h"
-#include "cc3000_nvmem.h"
-#include "cc3000_socket.h"
-
-#define MAX_SOCKETS 4
-// cc3000 Ethernet Interface - enabled by default
-#define CC3000_ETH_COMPAT   1
-
-/** Enable debug messages - set 1  */
-// Debug - Socket interface messages
-#define CC3000_DEBUG_SOCKET 0
-// Debug - HCI TX messages
-#define CC3000_DEBUG_HCI_TX 0
-// Debug - HCI Rx messages
-#define CC3000_DEBUG_HCI_RX 0
-// Debug - General Debug
-#define CC3000_DEBUG        0
-// Add colour to the debug messages, requires a VT100 terminal like putty, comment out to remove
-#define VT100_COLOUR        0
-
-#if (CC3000_DEBUG_SOCKET == 1)
-    #if (VT100_COLOUR == 1)
-        #define DBG_SOCKET(x, ...) std::printf("\x1b[2;32;40m[CC3000 : SOCKET] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
-    #else
-        #define DBG_SOCKET(x, ...) std::printf("[CC3000 : SOCKET] "x"\r\n", ##__VA_ARGS__);
-    #endif
-#else
-    #define DBG_SOCKET(x, ...)
-#endif
-
-#if (CC3000_DEBUG_HCI_TX == 1)
-    #if (VT100_COLOUR == 1)
-        #define DBG_HCI(x, ...) std::printf("\x1b[2;35;40m[CC3000 : HCI RX] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
-    #else
-        #define DBG_HCI(x, ...) std::printf("[CC3000 : HCI RX] "x"\r\n", ##__VA_ARGS__);
-    #endif
-#else
-    #define DBG_HCI(x, ...)
-#endif
-
-#if (CC3000_DEBUG_HCI_RX == 1)
-    #if (VT100_COLOUR == 1)
-        #define DBG_HCI_CMD(x, ...) std::printf("\x1b[2;36;40m[CC3000 : HCI TX] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
-    #else
-        #define DBG_HCI_CMD(x, ...) std::printf("[CC3000 : HCI TX] "x"\r\n", ##__VA_ARGS__);
-    #endif
-#else
-    #define DBG_HCI_CMD(x, ...)
-#endif
-
-#if (CC3000_DEBUG == 1)
-    #if (VT100_COLOUR == 1)
-        #define DBG_CC(x, ...) std::printf("\x1b[2;32;40m[CC3000] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
-    #else
-        #define DBG_CC(x, ...) std::printf("[CC3000] "x"\r\n", ##__VA_ARGS__);
-    #endif
-#else
-    #define DBG_CC(x, ...)
-#endif
-
-namespace mbed_cc3000 {
-
-/** User info structure
- */
-typedef struct {
-    uint8_t FTC;           // First time config performed
-    uint8_t PP_version[2]; // Patch Programmer version
-    uint8_t SERV_PACK[2];  // Service Pack Version
-    uint8_t DRV_VER[3];    // Driver Version
-    uint8_t FW_VER[3];     // Firmware Version
-    uint8_t validCIK;      // CIK[] is valid (Client Interface Key)
-    uint8_t CIK[40];
-} tUserFS;
-
-/** Function pointers which are not yet implemented
- */
-enum FunctionNumber {
-    FW_PATCHES          = 0,
-    DRIVER_PATCHES      = 1,
-    BOOTLOADER_PATCHES  = 2,
-};
-
-/** CC3000 Simple Link class which contains status of cc3000.
- */
-class cc3000_simple_link {
-public:
-    /**
-     *  \brief ctor - sets magic number in the buffers (overflow mark).
-     *  \param none
-     *  \return none
-     */
-    cc3000_simple_link();
-    /**
-     *  \brief dtor
-     *  \param none
-     *  \return none
-     */
-    ~cc3000_simple_link();
-    /**
-     *  \brief Returns data received flag.
-     *  \return Data received flag.
-     */
-    uint8_t get_data_received_flag();
-    /**
-     *  \brief Set data received flag.
-     *  \param value The value to be set.
-     */
-    void set_data_received_flag(uint8_t value);
-    /** Returns if tx was completed.
-     *  \return
-     *    true if tx was completed,
-     *    false otherwise.
-     */
-    bool get_tx_complete_signal();
-    /**
-     *  \brief Sets flag that tx was completed.
-     *  \param value Value to be set
-     *  \return none
-     */
-    void set_tx_complete_signal(bool value);
-    /**
-     *  \brief Get receive buffer.
-     *  \param none
-     *  \return Pointer to the receive buffer.
-     */
-    uint8_t *get_received_buffer();
-    /**
-     *  \brief Get transmit buffer.
-     *  \param none
-     *  \return Pointer to the transmit buffer.
-     */
-    uint8_t *get_transmit_buffer();
-    /**
-     *  \brief Get number of free buffers.
-     *  \param none
-     *  \return
-     *      Number of free buffers.
-     */
-    uint16_t get_number_free_buffers();
-    /**
-     *  \brief Set number of free buffers.
-     *  \param value Number of free buffers.
-     *  \return none
-     */
-    void set_number_free_buffers(uint16_t value);
-    /**
-     *  \brief Retrieve buffer length.
-     *  \param none
-     *  \return Buffer length
-     */
-    uint16_t get_buffer_length();
-    /**
-     *  \brief Set buffer length
-     *  \param value The length
-     *  \return none
-     */
-    void set_buffer_length(uint16_t value);
-    /**
-     *  \brief Retrieve pending data flag.
-     *  \param none
-     *  \return Pending data flag
-     */
-    uint16_t get_pending_data();
-    /**
-     *  \brief Set pending data flag.
-     *  \param value Pending data value.
-     *  \return none
-     */
-    void set_pending_data(uint16_t value);
-    /**
-     *  \brief Retreive op code.
-     *  \param none
-     *  \return Op code
-     */
-    uint16_t get_op_code();
-    /**
-     *  \brief Set op code.
-     *  \param code op code.
-     *  \return none
-     */
-    void set_op_code(uint16_t code);
-    /**
-     *  \brief Get number of released packets.
-     *  \param none
-     *  \return Number of released packets.
-     */
-    uint16_t get_released_packets();
-    /**
-     *  \brief Set number of released packets.
-     *  \param value Number of released packets.
-     *  \return none
-     */
-    void set_number_of_released_packets(uint16_t value);
-    /**
-     *  \brief Get number of sent packats
-     *  \param none
-     *  \return Number of sent packets.
-     */
-    uint16_t get_sent_packets();
-    /**
-     *  \brief Set number of sent packets
-     *  \param value Number of sent packets.
-     *  \return none
-     */
-    void set_sent_packets(uint16_t value);
-    /**
-     *  \brief Retrieve transmit error
-     *  \param none
-     *  \return Transmit error
-     */
-    int32_t get_transmit_error();
-    /**
-     *  \brief Set transmit error.
-     *  \param value Error to be set.
-     *  \return none
-     */
-    void set_transmit_error(int32_t value);
-    /**
-     *  \brief Get buffer size.
-     *  \param none
-     *  \return Size of buffer.
-     */
-    uint16_t get_buffer_size();
-    /**
-     *  \brief Set buffer size.
-     *  \param value Buffer size.
-     *  \return none
-     */
-    void set_buffer_size(uint16_t value);
-    /**
-     *  \brief Not used currently.
-     *  \param function Number of desired function.
-     *  \return void pointer to the function (need to recast).
-     */
-    void *get_func_pointer(FunctionNumber function);
-    /**
-     *  \brief Retreive pointer to the received data.
-     *  \param none
-     *  \return Pointer to the received data buffer.
-     */
-    uint8_t *get_received_data();
-    /**
-     *  \brief Set received data pointer.
-     *  \param pointer Pointer to the buffer.
-     *  \return none
-     */
-    void set_received_data(uint8_t *pointer);
-private:
-    uint8_t  _data_received_flag;
-    bool     _tx_complete_signal;
-    uint16_t _rx_event_opcode;
-    uint16_t _free_buffers;
-    uint16_t _buffer_length;
-    uint16_t _buffer_size;
-    uint16_t _rx_data_pending;
-    uint16_t _sent_packets;
-    uint16_t _released_packets;
-    int32_t  _transmit_data_error;
-    uint8_t  *_received_data;
-    uint8_t  _rx_buffer[CC3000_RX_BUFFER_SIZE];
-    uint8_t  _tx_buffer[CC3000_TX_BUFFER_SIZE];
-private:
-    /* Not used currently */
-    int8_t *(* _fFWPatches)(uint32_t *length);
-    int8_t *(* _fDriverPatches)(uint32_t *length);
-    int8_t *(* _fBootLoaderPatches)(uint32_t *length);
-};
-
-/** Forward declaration classes
- */
-class cc3000_hci;
-class cc3000_nvmem;
-class cc3000_spi;
-class cc3000;
-
-/** Event layer
- */
-class cc3000_event {
-public:
-    /**
-     *  \brief
-     *  \param simplelink Reference to simple link object.
-     *  \param hci        Reference to hci object.
-     *  \param spi        Reference to spi object.
-     *  \param cc3000     Reference to cc3000 object.
-     *  \return none
-     */
-    cc3000_event(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_spi &spi, cc3000 &cc3000);
-    /**
-     *  \brief Ctor
-     *  \param none
-     *  \return none
-     */
-     ~cc3000_event();
-    /**
-     *  \brief Handle unsolicited event from type patch request.
-     *  \param  event_hdr  event header
-     *  \return none
-     */
-    void hci_unsol_handle_patch_request(uint8_t *event_hdr);
-    /**
-    *  \brief  Parse the incoming event packets and issue corresponding event handler from global array of handlers pointers.
-    *  \param  ret_param      incoming data buffer
-    *  \param  from           from information (in case of data received)
-    *  \param  fromlen        from information length (in case of data received)
-    *  \return                none
-    */
-    uint8_t *hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen);
-    /**
-    *  \brief  Handle unsolicited events.
-    *  \param  event_hdr Event header
-    *  \return           1 if event supported and handled
-    *  \return           0 if event is not supported
-    */
-    int32_t hci_unsol_event_handler(uint8_t *event_hdr);
-    /**
-    *  \brief   Parse the incoming unsolicited event packets and start corresponding event handler.
-    *  \param   None
-    *  \return  ESUCCESS if successful, EFAIL if an error occurred.
-    */
-    int32_t hci_unsolicited_event_handler(void);
-    /**
-    *  \brief  Get the socket status.
-    *  \param  Sd Socket IS
-    *  \return Current status of the socket.
-    */
-    int32_t get_socket_active_status(int32_t sd);
-    /**
-    *  \brief Check if the socket ID and status are valid and set the global socket status accordingly.
-    *  \param Sd Sock descr
-    *  \param Status status to be set
-    *  \return  none
-    */
-    void set_socket_active_status(int32_t sd, int32_t status);
-    /**
-    *  \brief Keep track on the number of packets transmitted and update the number of free buffer in the SL device.
-    *  \brief Called when unsolicited event = HCI_EVNT_DATA_UNSOL_FREE_BUFF has received.
-    *  \param event pointer to the string contains parameters for IPERF.
-    *  \return ESUCCESS if successful, EFAIL if an error occurred.
-    */
-    int32_t hci_event_unsol_flowcontrol_handler(uint8_t *event);
-    /**
-    *  \brief Update the socket status.
-    *  \param resp_params Socket IS
-    *  \return Current status of the socket.
-    */
-    void update_socket_active_status(uint8_t *resp_params);
-    /**
-     *  \brief  Wait for event, pass it to the hci_event_handler and update the event opcode in a global variable.
-     *  \param  op_code   Command operation code
-     *  \param  ret_param Command return parameters
-     *  \return none
-     */
-    void simplelink_wait_event(uint16_t op_code, void *ret_param);
-    /**
-     *  \brief  Wait for data, pass it to the hci_event_handler and set the data available flag.
-     *  \param  buffer  Data buffer
-     *  \param  from    From information
-     *  \param  fromlen From information length
-     *  \return none
-     */
-    void simplelink_wait_data(uint8_t *buffer, uint8_t *from, uint8_t *fromlen);
-    /**
-     *  \brief Trigger Received event/data processing - called from the SPI library to receive the data
-     *  \param buffer pointer to the received data buffer\n
-     *                The function triggers Received event/data processing\n
-     *  \return none
-     */
-    void received_handler(uint8_t *buffer);
-private:
-    uint32_t            socket_active_status;
-    cc3000_simple_link  &_simple_link;
-    cc3000_hci          &_hci;
-    cc3000_spi          &_spi;
-    cc3000              &_cc3000;
-};
-
-/** Netapp layer
- */
-class cc3000_netapp {
-public:
-    /**
-     *  \brief Ctor
-     *  \param simple_link Reference to the simple link object.
-     *  \param nvmem       Reference to the nvmem object.
-     *  \param hci         Reference to the hci object.
-     *  \param event       Reference to the event object.
-     *  \return none
-     */
-    cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci, cc3000_event &event);
-    /**
-     *  \brief Dtor
-     *  \param none
-     *  \return none
-     */
-    ~cc3000_netapp();
-    /**
-     *  \brief Configure device MAC address and store it in NVMEM.
-     *         The value of the MAC address configured through the API will be\n
-     *         stored in CC3000 non volatile memory, thus preserved over resets.\n
-     *  \param  mac   device mac address, 6 bytes. Saved: yes
-     *  \return       return on success 0, otherwise error.
-     */
-    int32_t config_mac_adrress(uint8_t *mac);
-    /**
-     *  \brief Configure the network interface, static or dynamic (DHCP).
-     *         In order to activate DHCP mode, ip, subnet_mask, default_gateway must be 0.\n
-     *         The default mode of CC3000 is DHCP mode. The configuration is saved in non volatile memory\n
-     *         and thus preserved over resets.\n
-     *  \param  ip                device mac address, 6 bytes. Saved: yes
-     *  \param  subnet_mask       device mac address, 6 bytes. Saved: yes
-     *  \param  default_gateway   device mac address, 6 bytes. Saved: yes
-     *  \param  dns_server        device mac address, 6 bytes. Saved: yes
-     *  \return 0 on success, otherwise error.
-     *  \note   If the mode is altered, a reset of CC3000 device is required to apply the changes.\n
-     *          Also note that an asynchronous event of type 'DHCP_EVENT' is generated only when\n
-     *          a connection to the AP was established. This event is generated when an IP address\n
-     *          is allocated either by the DHCP server or by static allocation.\n
-     */
-    int32_t dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server);
-#ifndef CC3000_TINY_DRIVER
-    /**
-     *  \brief Get the CC3000 Network interface information.
-     *        This information is only available after establishing a WLAN connection.\n
-     *        Undefined values are returned when this function is called before association.\n
-     *  \param  ipconfig  pointer to a tNetappIpconfigRetArgs structure for storing the network interface configuration.\n
-     *          tNetappIpconfigRetArgs: aucIP             - ip address,\n
-     *                                  aucSubnetMask     - mask
-     *                                  aucDefaultGateway - default gateway address\n
-     *                                  aucDHCPServer     - dhcp server address\n
-     *                                  aucDNSServer      - dns server address\n
-     *                                  uaMacAddr         - mac address\n
-     *                                  uaSSID            - connected AP ssid\n
-     *  \return  none
-     *  \note    This function is useful for figuring out the IP Configuration of\n
-     *           the device when DHCP is used and for figuring out the SSID of\n
-     *           the Wireless network the device is associated with.\n
-     */
-    void ipconfig(tNetappIpconfigRetArgs *ipconfig);
-    /**
-     *  \brief Set new timeout values for DHCP lease timeout, ARP  refresh timeout, keepalive event timeout and socket inactivity timeout
-     *  \param  dhcp       DHCP lease time request, also impact\n
-     *                     the DHCP renew timeout.\n
-     *                     Range:               [0-0xffffffff] seconds,\n
-     *                                          0 or 0xffffffff = infinite lease timeout.\n
-     *                     Resolution:          10 seconds.\n
-     *                     Influence:           only after reconnecting to the AP. \n
-     *                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.\n
-     *                     The parameter is saved into the CC3000 NVMEM.\n
-     *                     The default value on CC3000 is 14400 seconds.\n
-     *
-     *  \param  arp        ARP refresh timeout, if ARP entry is not updated by\n
-     *                     incoming packet, the ARP entry will be  deleted by\n
-     *                     the end of the timeout. \n
-     *                     Range:               [0-0xffffffff] seconds, 0 = infinite ARP timeout\n
-     *                     Resolution:          10 seconds.\n
-     *                     Influence:           at runtime.\n
-     *                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds\n
-     *                     The parameter is saved into the CC3000 NVMEM.\n
-     *                     The default value on CC3000 is 3600 seconds.\n
-     *
-     *  \param  keep_alive     Keepalive event sent by the end of keepalive timeout\n
-     *                         Range:               [0-0xffffffff] seconds, 0 == infinite timeout\n
-     *                         Resolution:          10 seconds.\n
-     *                         Influence:           at runtime.\n
-     *                         Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec\n
-     *                         The parameter is saved into the CC3000 NVMEM. \n
-     *                         The default value on CC3000 is 10 seconds.\n
-     *
-     *  \param  inactivity      Socket inactivity timeout, socket timeout is\n
-     *                          refreshed by incoming or outgoing packet, by the\n
-     *                          end of the socket timeout the socket will be closed\n
-     *                          Range:               [0-0xffffffff] sec, 0 == infinite timeout.\n
-     *                          Resolution:          10 seconds.\n
-     *                          Influence:           at runtime.\n
-     *                          Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec\n
-     *                          The parameter is saved into the CC3000 NVMEM.\n
-     *                          The default value on CC3000 is 60 seconds.\n
-     *
-     *  \return 0 on success,otherwise error.
-     *
-     *  \note   A parameter set to a non zero value less than 20s automatically changes to 20s.
-     */
-    int32_t timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity);
-    /**
-     *  \brief send ICMP ECHO_REQUEST to network hosts
-     *  \param  ip              destination IP address
-     *  \param  ping_attempts   number of echo requests to send
-     *  \param  ping_size       send buffer size which may be up to 1400 bytes
-     *  \param  ping_timeout    Time to wait for a response,in milliseconds.
-     *  \return 0 on success, otherwise error.
-     *
-     *  \note     A succesful operation will generate an asynchronous ping report event.\n
-     *            The report structure is defined by structure netapp_pingreport_args_t.\n
-     *  \warning  Calling this function while a Ping Request is in progress will kill the ping request in progress.
-     */
-    int32_t ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout);
-    /**
-     *  \brief Ping status request.
-     *         This API triggers the CC3000 to send asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT.\n
-     *         This event will create the report structure in netapp_pingreport_args_t.\n
-     *         This structure is filled with ping results until the API is triggered.\n
-     *         netapp_pingreport_args_t: packets_sent     - echo sent\n
-     *                                   packets_received - echo reply\n
-     *                                   min_round_time   - minimum round time\n
-     *                                   max_round_time   - max round time\n
-     *                                   avg_round_time   - average round time\n
-     *
-     *  \param   none
-     *  \return  none
-     *  \note    When a ping operation is not active, the returned structure fields are 0.
-     */
-    void ping_report();
-    /**
-     *  \brief Stop any ping request.
-     *  \param none
-     *  \return 0 on success
-     *         -1 on error
-     */
-    int32_t ping_stop();
-    /**
-     *  \brief Flush ARP table
-     *  \param none
-     *  \return none
-     */
-    int32_t arp_flush();
-#endif
-private:
-    cc3000_simple_link  &_simple_link;
-    cc3000_nvmem        &_nvmem;
-    cc3000_hci          &_hci;
-    cc3000_event        &_event;
-};
-
-#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
-/** Security class used only if encrypted smart config is set
- */
-class cc3000_security {
-public:
-    /**
-     *  \brief Expand a 16 bytes key for AES128 implementation.
-     *  \param expanded_key expanded AES128 key
-     *  \param key AES128 key - 16 bytes
-     *  \return none
-     */
-    void expandKey(uint8_t *expanded_key, uint8_t *key);
-    /**
-     *  \brief multiply by 2 in the galois field.
-     *  \param value Argument to multiply
-     *  \return multiplied argument
-     */
-    uint8_t galois_mul2(uint8_t value);
-    /**
-     *  \brief internal implementation of AES128 encryption.
-     *      straight forward aes encryption implementation\n
-     *      first the group of operations
-     *      - addRoundKey
-     *      - subbytes
-     *      - shiftrows
-     *      - mixcolums\n
-     *
-     *      is executed 9 times, after this addroundkey to finish the 9th\n
-     *      round, after that the 10th round without mixcolums\n
-     *      no further subfunctions to save cycles for function calls\n
-     *      no structuring with "for (....)" to save cycles.\n
-     *  \param[in]     expanded_key expanded AES128 key
-     *  \param[in/out] state 16 bytes of plain text and cipher text
-     *  \return  none
-     */
-    void aes_encr(uint8_t *state, uint8_t *expanded_key);
-    /**
-     *  \brief internal implementation of AES128 decryption.
-     *      straightforward aes decryption implementation\n
-     *      the order of substeps is the exact reverse of decryption\n
-     *      inverse functions:
-     *      - addRoundKey is its own inverse
-     *      - rsbox is inverse of sbox
-     *      - rightshift instead of leftshift
-     *      - invMixColumns = barreto + mixColumns\n
-     *
-     *      no further subfunctions to save cycles for function calls\n
-     *      no structuring with "for (....)" to save cycles\n
-     *  \param[in]     expanded_key expanded AES128 key
-     *  \param[in\out] state 16 bytes of cipher text and plain text
-     *  \return  none
-     */
-    void aes_decr(uint8_t *state, uint8_t *expanded_key);
-    /**
-     *  \brief AES128 encryption.
-     *      Given AES128 key and 16 bytes plain text, cipher text of 16 bytes is computed.\n
-     *      The AES implementation is in mode ECB (Electronic Code Book).\n
-     *  \param[in]  key   AES128 key of size 16 bytes
-     *  \param[in\out] state   16 bytes of plain text and cipher text
-     *  \return  none
-     */
-    void aes_encrypt(uint8_t *state, uint8_t *key);
-    /**
-     *  \brief AES128 decryption.
-     *      Given AES128 key and  16 bytes cipher text, plain text of 16 bytes is computed.\n
-     *      The AES implementation is in mode ECB (Electronic Code Book).\n
-     *  \param[in]  key   AES128 key of size 16 bytes
-     *  \param[in\out] state   16 bytes of cipher text and plain text
-     *  \return  none
-     */
-    void aes_decrypt(uint8_t *state, uint8_t *key);
-    /**
-     *  \brief Read the AES128 key from fileID #12 in EEPROM.
-     *  \param[out]  key   AES128 key of size 16 bytes
-     *  \return  0 on success, error otherwise.
-     */
-    int32_t aes_read_key(uint8_t *key);
-    /**
-     *  \brief Write the AES128 key to fileID #12 in EEPROM.
-     *  \param[out]  key   AES128 key of size 16 bytes
-     *  \return  on success 0, error otherwise.
-     */
-    int32_t aes_write_key(uint8_t *key);
-private:
-    uint8_t _expanded_key[176];
-};
-#endif
-
-/** Socket layer
- */
-class cc3000_socket {
-public:
-    /**
-     *  \brief Ctor
-     *  \param simplelink Reference to simple link object.
-     *  \param hci        Reference to hci object.
-     *  \param event      Reference to event object.
-     *  \return none
-     */
-    cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event);
-    /**
-     *  \brief Dtor
-     *  \param
-     *  \return none
-     */
-    ~cc3000_socket();
-    /**
-     *  \brief create an endpoint for communication.
-     *      The socket function creates a socket that is bound to a specific transport service provider.\n
-     *      This function is called by the application layer to obtain a socket handle.\n
-     *
-     *  \param   domain    selects the protocol family which will be used for\n
-     *                     communication. On this version only AF_INET is supported\n
-     *  \param   type      specifies the communication semantics. On this version\n
-     *                     only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported\n
-     *  \param   protocol  specifies a particular protocol to be used with the\n
-     *                     socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are supported.\n
-     *  \return  On success, socket handle that is used for consequent socket operations\n
-     *           On error, -1 is returned.\n
-     */
-    int32_t socket(int32_t domain, int32_t type, int32_t protocol);
-    /**
-     *  \brief accept a connection on a socket.
-     *      This function is used with connection-based socket types\n
-     *      (SOCK_STREAM). It extracts the first connection request on the\n
-     *      queue of pending connections, creates a new connected socket, and\n
-     *      returns a new file descriptor referring to that socket.\n
-     *      The newly created socket is not in the listening state.\n
-     *      The original socket sd is unaffected by this call.\n
-     *      The argument sd is a socket that has been created with socket(),\n
-     *      bound to a local address with bind(), and is  listening for \n
-     *      connections after a listen(). The argument addr is a pointer \n
-     *      to a sockaddr structure. This structure is filled in with the \n
-     *      address of the peer socket, as known to the communications layer.\n
-     *      The exact format of the address returned addr is determined by the \n
-     *      socket's address family. The addrlen argument is a value-result\n
-     *      argument: it should initially contain the size of the structure\n
-     *      pointed to by addr, on return it will contain the actual\n
-     *      length (in bytes) of the address returned.\n
-     *
-     *  \param[in]   sd      socket descriptor (handle)\n
-     *  \param[out]  addr    the argument addr is a pointer to a sockaddr structure\n
-     *                       This structure is filled in with the address of the \n
-     *                       peer socket, as known to the communications layer.  \n
-     *                       determined. The exact format of the address returned \n
-     *                       addr is by the socket's address sockaddr. \n
-     *                       On this version only AF_INET is supported.\n
-     *                       This argument returns in network order.\n
-     *  \param[out] addrlen  the addrlen argument is a value-result argument: \n
-     *                       it should initially contain the size of the structure\n
-     *                       pointed to by addr.\n
-     *  \return  For socket in blocking mode:\n
-     *            - On success, socket handle. on failure negative\n
-     *           For socket in non-blocking mode:\n
-     *            - On connection establishment, socket handle\n
-     *            - On connection pending, SOC_IN_PROGRESS (-2)\n
-     *            - On failure, SOC_ERROR    (-1)\n
-     *  \sa     socket ; bind ; listen
-     */
-    int32_t accept(int32_t sd, sockaddr *addr, socklen_t *addrlen);
-    /**
-     *  \brief assign a name to a socket.
-     *      This function gives the socket the local address addr.\n
-     *      addr is addrlen bytes long. Traditionally, this is called when a \n
-     *      socket is created with socket, it exists in a name space (address \n
-     *      family) but has no name assigned.\n
-     *      It is necessary to assign a local address before a SOCK_STREAM\n
-     *      socket may receive connections.\n
-     *
-     *  \param[in]   sd      socket descriptor (handle)
-     *  \param[out]  addr    specifies the destination address. On this version\n
-     *                       only AF_INET is supported.\n
-     *  \param[out] addrlen  contains the size of the structure pointed to by addr.\n
-     *  \return      On success, zero is returned.\n
-     *               On error, -1 is returned.\n
-     *  \sa          socket ; accept ; listen
-     */
-    int32_t bind(int32_t sd, const sockaddr *addr, int32_t addrlen);
-    /**
-     *  \brief HostFlowControlConsumeBuff.
-     *      if SEND_NON_BLOCKING is not defined - block until a free buffer is available,\n
-     *      otherwise return the status of the available buffers.\n
-     *
-     *  \param  sd  socket descriptor
-     *  \return  0 in case there are buffers available, \n
-     *          -1 in case of bad socket\n
-     *          -2 if there are no free buffers present (only when SEND_NON_BLOCKING is enabled)\n
-     */
-    int32_t HostFlowControlConsumeBuff(int32_t sd);
-    /**
-     *  \brief The socket function closes a created socket.
-     *  \param   sd    socket handle.
-     *  \return  On success, zero is returned. On error, -1 is returned.
-     */
-    int32_t closesocket(int32_t sd);
-    /**
-     *  \brief listen for connections on a socket.
-     *      The willingness to accept incoming connections and a queue\n
-     *      limit for incoming connections are specified with listen(),\n
-     *      and then the connections are accepted with accept.\n
-     *      The listen() call applies only to sockets of type SOCK_STREAM\n
-     *      The backlog parameter defines the maximum length the queue of\n
-     *      pending connections may grow to. \n
-     *
-     *  \param[in]  sd       socket descriptor (handle)
-     *  \param[in]  backlog  specifies the listen queue depth. On this version\n
-     *                       backlog is not supported.\n
-     *  \return     On success, zero is returned.\n
-     *              On error, -1 is returned.\n
-     *  \sa         socket ; accept ; bind
-     *  \note       On this version, backlog is not supported
-     */
-    int32_t listen(int32_t sd, int32_t backlog);
-    /**
-     *  \brief initiate a connection on a socket.
-     *      Function connects the socket referred to by the socket descriptor\n
-     *      sd, to the address specified by addr. The addrlen argument \n
-     *      specifies the size of addr. The format of the address in addr is \n
-     *      determined by the address space of the socket. If it is of type \n
-     *      SOCK_DGRAM, this call specifies the peer with which the socket is \n
-     *      to be associated; this address is that to which datagrams are to be\n
-     *      sent, and the only address from which datagrams are to be received. \n
-     *      If the socket is of type SOCK_STREAM, this call attempts to make a \n
-     *      connection to another socket. The other socket is specified  by \n
-     *      address, which is an address in the communications space of the\n
-     *      socket. Note that the function implements only blocking behavior \n
-     *      thus the caller will be waiting either for the connection \n
-     *      establishment or for the connection establishment failure.\n
-     *
-     *  \param[in]   sd       socket descriptor (handle)
-     *  \param[in]   addr     specifies the destination addr. On this version\n
-     *                        only AF_INET is supported.\n
-     *  \param[out]  addrlen  contains the size of the structure pointed to by addr
-     *  \return      On success, zero is returned.\n
-                   On error, -1 is returned\n
-     *  \sa socket
-     */
-    int32_t connect(int32_t sd, const sockaddr *addr, int32_t addrlen);
-    /**
-     *  \brief Monitor socket activity.
-     *      Select allow a program to monitor multiple file descriptors,\n
-     *      waiting until one or more of the file descriptors become \n
-     *      "ready" for some class of I/O operation \n
-     *
-     *  \param[in]    nfds       the highest-numbered file descriptor in any of the\n
-     *                           three sets, plus 1.  \n
-     *  \param[out]   readsds    socket descriptors list for read monitoring\n
-     *  \param[out]   writesds   socket descriptors list for write monitoring\n
-     *  \param[out]   exceptsds  socket descriptors list for exception monitoring\n
-     *  \param[in]    timeout    is an upper bound on the amount of time elapsed\n
-     *                           before select() returns. Null means infinity \n
-     *                           timeout. The minimum timeout is 5 milliseconds,\n
-     *                          less than 5 milliseconds will be set\n
-     *                           automatically to 5 milliseconds.\n
-     *  \return    On success, select() returns the number of file descriptors\n
-     *             contained in the three returned descriptor sets (that is, the\n
-     *             total number of bits that are set in readfds, writefds,\n
-     *             exceptfds) which may be zero if the timeout expires before\n
-     *             anything interesting  happens.\n
-     *             On error, -1 is returned.\n
-     *                   *readsds - return the sockets on which Read request will\n
-     *                              return without delay with valid data.\n
-     *                   *writesds - return the sockets on which Write request \n
-     *                                 will return without delay.\n
-     *                   *exceptsds - return the sockets which closed recently.\n
-     *  \Note   If the timeout value set to less than 5ms it will automatically\n
-     *          change to 5ms to prevent overload of the system\n
-     *  \sa socket
-     */
-    int32_t select(int32_t nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout);
-    /**
-     *  \brief get socket options.
-     *      This function manipulate the options associated with a socket.\n
-     *      Options may exist at multiple protocol levels; they are always\n
-     *      present at the uppermost socket level.\n
-     *      When manipulating socket options the level at which the option \n
-     *      resides and the name of the option must be specified.  \n
-     *      To manipulate options at the socket level, level is specified as \n
-     *      SOL_SOCKET. To manipulate options at any other level the protocol \n
-     *      number of the appropriate protocol controlling the option is \n
-     *      supplied. For example, to indicate that an option is to be \n
-     *      interpreted by the TCP protocol, level should be set to the \n
-     *      protocol number of TCP; \n
-     *      The parameters optval and optlen are used to access optval -\n
-     *      use for setsockopt(). For getsockopt() they identify a buffer\n
-     *      in which the value for the requested option(s) are to \n
-     *      be returned. For getsockopt(), optlen is a value-result \n
-     *      parameter, initially containing the size of the buffer \n
-     *      pointed to by option_value, and modified on return to \n
-     *      indicate the actual size of the value returned. If no option \n
-     *      value is to be supplied or returned, option_value may be NULL.\n
-     *
-     *  \param[in]   sd          socket handle
-     *  \param[in]   level       defines the protocol level for this option
-     *  \param[in]   optname     defines the option name to Interrogate
-     *  \param[out]  optval      specifies a value for the option
-     *  \param[out]  optlen      specifies the length of the option value
-     *  \return      On success, zero is returned. On error, -1 is returned
-     *
-     *  \Note   On this version the following two socket options are enabled:\n
-     *          The only protocol level supported in this version is SOL_SOCKET (level).\n
-     *               1. SOCKOPT_RECV_TIMEOUT (optname)\n
-     *                  SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout in milliseconds.\n
-     *                  In that case optval should be pointer to unsigned long.\n
-     *               2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on or off.\n
-     *                  In that case optval should be SOCK_ON or SOCK_OFF (optval).\n
-     *  \sa setsockopt
-     */
-    int32_t getsockopt (int32_t sd, int32_t level, int32_t optname, void *optval, socklen_t *optlen);
-    /**
-     *  \brief Read data from socket (simple_link_recv).
-     *      Return the length of the message on successful completion.\n
-     *      If a message is too long to fit in the supplied buffer, excess bytes may\n
-     *      be discarded depending on the type of socket the message is received from.\n
-     *
-     *  \param sd       socket handle
-     *  \param buf      read buffer
-     *  \param len      buffer length
-     *  \param flags    indicates blocking or non-blocking operation
-     *  \param from     pointer to an address structure indicating source address
-     *  \param fromlen  source address structure size
-     *  \return         Return the number of bytes received, or -1 if an error occurred
-     */
-    int32_t simple_link_recv(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen, int32_t opcode);
-    /**
-     *  \brief Transmit a message to another socket (simple_link_send).
-     *  \param sd       socket handle
-     *  \param buf      write buffer
-     *  \param len      buffer length
-     *  \param flags    On this version, this parameter is not supported
-     *  \param to       pointer to an address structure indicating destination address
-     *  \param tolen    destination address structure size
-     *  \return         Return the number of bytes transmitted, or -1 if an error\n
-     *                  occurred, or -2 in case there are no free buffers available\n
-     *                  (only when SEND_NON_BLOCKING is enabled)\n
-     */
-    int32_t simple_link_send(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, int32_t tolen, int32_t opcode);
-    /**
-     *  \brief Receive a message from a connection-mode socket.
-     *  \param[in]  sd     socket handle
-     *  \param[out] buf    Points to the buffer where the message should be stored
-     *  \param[in]  len    Specifies the length in bytes of the buffer pointed to \n
-     *                     by the buffer argument.\n
-     *  \param[in] flags   Specifies the type of message reception. \n
-     *                     On this version, this parameter is not supported.\n
-     *  \return         Return the number of bytes received, or -1 if an error occurred
-     *  \sa recvfrom
-     *  \Note On this version, only blocking mode is supported.
-     */
-    int32_t recv(int32_t sd, void *buf, int32_t len, int32_t flags);
-    /**
-     *  \brief read data from socket (recvfrom).
-     *      Receives a message from a connection-mode or connectionless-mode socket.\n
-     *      Note that raw sockets are not supported.\n
-     *
-     *  \param[in]  sd       socket handle
-     *  \param[out] buf      Points to the buffer where the message should be stored
-     *  \param[in]  len      Specifies the length in bytes of the buffer pointed to \n
-     *                       by the buffer argument.\n
-     *  \param[in] flags     Specifies the type of message reception.\n
-     *                       On this version, this parameter is not supported.\n
-     *  \param[in] from      pointer to an address structure indicating the source\n
-     *                       address: sockaddr. On this version only AF_INET is\n
-     *                       supported.\n
-     *  \param[in] fromlen   source address structure size
-     *  \return              Return the number of bytes received, or -1 if an error occurred
-     *  \sa recv
-     *  \Note On this version, only blocking mode is supported.
-     */
-    int32_t recvfrom(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen);
-    /**
-     *  \brief Transmit a message to another socket (send).
-     *  \param sd       socket handle
-     *  \param buf      Points to a buffer containing the message to be sent
-     *  \param len      message size in bytes
-     *  \param flags    On this version, this parameter is not supported
-     *  \return         Return the number of bytes transmitted, or -1 if an\n
-     *                  error occurred\n
-     *  \Note           On this version, only blocking mode is supported.
-     *  \sa             sendto
-     */
-    int32_t send(int32_t sd, const void *buf, int32_t len, int32_t flags);
-    /**
-     *  \brief Transmit a message to another socket (sendto).
-     *  \param sd       socket handle
-     *  \param buf      Points to a buffer containing the message to be sent
-     *  \param len      message size in bytes
-     *  \param flags    On this version, this parameter is not supported
-     *  \param to       pointer to an address structure indicating the destination\n
-     *                  address: sockaddr. On this version only AF_INET is\n
-     *                  supported.\n
-     *  \param tolen    destination address structure size
-     *  \return         Return the number of bytes transmitted, or -1 if an error occurred
-     *  \Note           On this version, only blocking mode is supported.
-     *  \sa             send
-     */
-    int32_t sendto(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, socklen_t tolen);
-    /**
-     *  \brief Set CC3000 in mDNS advertiser mode in order to advertise itself.
-     *  \param[in] mdns_enabled                 flag to enable/disable the mDNS feature
-     *  \param[in] device_service_name          Service name as part of the published\n
-     *                                          canonical domain name\n
-     *  \param[in] device_service_name_length   Length of the service name
-     *  \return   On success, zero is returned,\n
-     *            return SOC_ERROR if socket was not opened successfully, or if an error occurred.\n
-     */
-    int32_t mdns_advertiser(uint16_t mdns_enabled, uint8_t * device_service_name, uint16_t device_service_name_length);
-    /**
-     *  \brief
-     *  \param[in] s_addr in host format ( little endian )
-     *  \param[in] *buf     buffer to write too
-     *  \param[in] buflen   length of supplied buffer
-     *  \return    pointer to buf \n
-     */
-    char * inet_ntoa_r(uint32_t s_addr, char *buf, int buflen);
-#ifndef CC3000_TINY_DRIVER
-    /**
-     *  \brief Get host IP by name.\n
-     *      Obtain the IP Address of machine on network\n
-     *
-     *  \param[in]   hostname     host name
-     *  \param[in]   name_length  name length
-     *  \param[out]  out_ip_addr  This parameter is filled in with host IP address.\n
-     *                            In case that host name is not resolved, \n
-     *                            out_ip_addr is zero.\n
-     *  \return      On success, positive is returned.\n
-     *               On error, negative is returned by its name.\n
-     *  \note  On this version, only blocking mode is supported. Also note that\n
-     *         The function requires DNS server to be configured prior to its usage.\n
-     */
-    int32_t gethostbyname(uint8_t *hostname, uint16_t name_length, uint32_t *out_ip_addr);
-    /**
-     *  \brief set socket options.
-     *      This function manipulate the options associated with a socket.\n
-     *      Options may exist at multiple protocol levels; they are always\n
-     *      present at the uppermost socket level.\n
-     *      When manipulating socket options the level at which the option \n
-     *      resides and the name of the option must be specified.\n
-     *      To manipulate options at the socket level, level is specified as\n
-     *      SOL_SOCKET. To manipulate options at any other level the protocol \n
-     *      number of the appropriate protocol controlling the option is \n
-     *      supplied. For example, to indicate that an option is to be \n
-     *      interpreted by the TCP protocol, level should be set to the \n
-     *      protocol number of TCP; \n
-     *      The parameters optval and optlen are used to access optval - \n
-     *      use for setsockopt(). For getsockopt() they identify a buffer\n
-     *      in which the value for the requested option(s) are to \n
-     *      be returned. For getsockopt(), optlen is a value-result \n
-     *      parameter, initially containing the size of the buffer \n
-     *      pointed to by option_value, and modified on return to \n
-     *      indicate the actual size of the value returned. If no option \n
-     *      value is to be supplied or returned, option_value may be NULL.\n
-     *
-     *  \param[in]   sd          socket handle
-     *  \param[in]   level       defines the protocol level for this option
-     *  \param[in]   optname     defines the option name to Interrogate
-     *  \param[in]   optval      specifies a value for the option
-     *  \param[in]   optlen      specifies the length of the option value
-     *  \return      On success, zero is returned.\n
-     *               On error, -1 is returned\n
-     *
-     *  \Note   On this version the following two socket options are enabled:\n
-     *          The only protocol level supported in this version is SOL_SOCKET (level).\n
-     *               1. SOCKOPT_RECV_TIMEOUT (optname)\n
-     *                  SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout in milliseconds.\n
-     *                  In that case optval should be pointer to unsigned long.\n
-     *               2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on or off.\n
-     *                  In that case optval should be SOCK_ON or SOCK_OFF (optval).\n
-     *  \sa getsockopt
-     */
-    int32_t setsockopt(int32_t sd, int32_t level, int32_t optname, const void *optval, socklen_t optlen);
-#endif
-private:
-    cc3000_simple_link  &_simple_link;
-    cc3000_hci          &_hci;
-    cc3000_event        &_event;
-};
-
-/** SPI communication layer
- */
-class cc3000_spi {
-public:
-    /**
-     *  \brief Ctor
-     *  \param irq         IRQ pin
-     *  \param cc3000_en   Enable pin
-     *  \param cc3000_cs   Chip select pin
-     *  \param cc3000_spi  SPI object
-     *  \param irq_port    Port for IRQ pin (needed for enable/disable interrupts)
-     *  \param event       Reference to the event object.
-     *  \param simple_link Reference to the simple link object.
-     *  \return none
-     */
-     cc3000_spi(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port, cc3000_event &event, cc3000_simple_link &simple_link);
-    /**
-     *  \brief Dtor
-     *  \param none
-     *  \return none
-     */
-     ~cc3000_spi();
-     /**
-      *  \brief Close SPI - disables IRQ and set received buffer to 0
-      *  \param none
-      *  \return none
-     */
-     void close();
-    /**
-     *  \brief Open the SPI interface
-     *  \param  none
-     *  \return none
-     */
-     void open();
-    /**
-     *  \brief First SPI write after powerup (delay needed between SPI header and body)
-     *  \param  buffer pointer to write buffer
-     *  \param  length buffer length
-     *  \return 0
-     */
-     uint32_t first_write(uint8_t *buffer, uint16_t length);
-    /**
-     *  \brief SPI Write function
-     *  \param  buffer pointer to write buffer
-     *  \param  length buffer length
-     *  \return 0
-     */
-     uint32_t write(uint8_t *buffer, uint16_t length);
-    /**
-     *  \brief Low level SPI write
-     *  \param  data pointer to data buffer
-     *  \param  size number of bytes
-     *  \return none
-     */
-     void write_synchronous(uint8_t *data, uint16_t size);
-    /**
-     *  \brief Low level SPI read
-     *  \param  data pointer to data buffer
-     *  \param  size number of bytes
-     *  \return none
-     */
-     void read_synchronous(uint8_t *data, uint16_t size);
-    /**
-     *  \brief Process the received SPI Header and in accordance with it - continue reading the packet
-     *  \param  None
-     *  \return 0
-     */
-     uint32_t read_data_cont();
-     /**
-     *  \brief Enable WLAN interrutp
-     *  \param  None
-     *  \return None
-     */
-    void wlan_irq_enable();
-     /**
-     *  \brief Disable WLAN interrutp
-     *  \param  None
-     *  \return None
-     */
-    void wlan_irq_disable();
-    /**
-     *  \brief Get WLAN interrupt status
-     *  \param   None
-     *  \return  0 : No interrupt occured
-     *           1 : Interrupt occured
-     */
-    uint32_t wlan_irq_read();
-    /**
-     *  \brief SPI interrupt Handler.
-     *      The external WLAN device asserts the IRQ line when data is ready.\n
-     *      The host CPU needs to acknowledges the IRQ by asserting CS.\n
-     *
-     *  \param  none
-     *  \return none
-     */
-    void WLAN_IRQHandler();
-    /**
-     *  \brief Enable/Disable the WLAN module
-     *  \param  value 1 : Enable
-     *                0 : Disable
-     *  \return None
-     */
-    void set_wlan_en(uint8_t value);
-private:
-    tSpiInfo            _spi_info;
-    InterruptIn         _wlan_irq;
-    DigitalOut          _wlan_en;
-    DigitalOut          _wlan_cs;
-    SPI                 _wlan_spi;
-    IRQn_Type           _irq_port;
-    pFunctionPointer_t  _function_pointer;
-    cc3000_event        &_event;
-    cc3000_simple_link  &_simple_link;
-};
-
-/** HCI layer
- */
-class cc3000_hci {
-public:
-    /**
-     *  \brief Ctor
-     *  \param spi Reference to the spi object.
-     *  \return none
-     */
-    cc3000_hci(cc3000_spi &spi);
-    /**
-     *  \brief Dtor
-     *  \param none
-     *  \return none
-     */
-    ~cc3000_hci();
-    /**
-     *  \brief Initiate an HCI command.
-     *  \param op_code command operation code
-     *  \param buffer  pointer to the command's arguments buffer
-     *  \param length  length of the arguments
-     *  \return 0
-     */
-    uint16_t command_send(uint16_t op_code, uint8_t *buffer, uint8_t length);
-    /**
-     *  \brief Initiate an HCI data write operation
-     *  \param op_code     command operation code
-     *  \param args        pointer to the command's arguments buffer
-     *  \param arg_length  length of the arguments
-     *  \param data_length length od data
-     *  \param tail        pointer to the data buffer
-     *  \param tail_length buffer length
-     *  \return ESUCCESS
-     */
-    uint32_t data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length,
-                        uint16_t data_length, const uint8_t *tail, uint16_t tail_length);
-    /**
-     *  \brief Prepare HCI header and initiate an HCI data write operation.
-     *  \param op_code     command operation code
-     *  \param buffer      pointer to the data buffer
-     *  \param arg_length  arguments length
-     *  \param data_length data length
-     *  \return none
-     */
-    void data_command_send(uint16_t op_code, uint8_t *buffer, uint8_t arg_length,
-                            uint16_t data_length);
-    /**
-     *  \brief Prepare HCI header and initiate an HCI patch write operation.
-     *  \param op_code     command operation code
-     *  \param buffer      pointer to the command's arguments buffer
-     *  \param patch       pointer to patch content buffer
-     *  \param data_length data length
-     *  \return none
-     */
-    void patch_send(uint8_t op_code, uint8_t *buffer, uint8_t *patch, uint16_t data_length);
-private:
-    cc3000_spi &_spi;
-};
-
-/** NVMEM layer
- */
-class cc3000_nvmem {
-public:
-    /**
-     *  \brief Ctor
-     *  \param hci         Reference to the hci object.
-     *  \param event       Reference to the event object.
-     *  \param simple_link Reference to the simple link object.
-     *  \return none
-     */
-    cc3000_nvmem(cc3000_hci &hci, cc3000_event &event, cc3000_simple_link &simple_link);
-    /**
-     *  \brief Dtor
-     *  \param none
-     *  \return none
-     */
-    ~cc3000_nvmem();
-    /**
-     *  \brief Reads data from the file referred by the file_id parameter.
-     *      Reads data from file offset till length. Err if the file can't be used,
-     *      is invalid, or if the read is out of bounds.
-     *  \param file_id nvmem file id.
-     *  \param length  number of bytes to read.
-     *  \param offset  offset in file from where to read.
-     *  \param buff    output buffer pointer.
-     *  \return
-     *      Number of bytes read, otherwise error.
-     */
-    int32_t read(uint32_t file_id, uint32_t length, uint32_t offset, uint8_t *buff);
-    /**
-     *  \brief Write data to nvmem.
-     *  \param file_id      Nvmem file id
-     *  \param length       number of bytes to write
-     *  \param entry_offset offset in file to start write operation from
-     *  \param buff         data to write
-     *  \return
-     *      On success 0, error otherwise.
-     */
-    int32_t write(uint32_t file_id, uint32_t length, uint32_t entry_offset, uint8_t *buff);
-    /**
-     *  \brief Write MAC address to EEPROM.
-     *  \param mac Mac address to be set
-     *  \return
-     *      On success 0, error otherwise.
-     */
-    uint8_t set_mac_address(uint8_t *mac);
-    /**
-     *  \brief Read MAC address from EEPROM.
-     *  \param mac Mac address
-     *  \return
-     *      On success 0, error otherwise.
-     */
-    uint8_t get_mac_address(uint8_t *mac);
-    /**
-     *  \brief Program a patch to a specific file ID. The SP data is assumed to be organized in 2-dimensional.
-     *      Each line is SP_PORTION_SIZE bytes long.
-     *  \param file_id nvmem file id/
-     *  \param length  number of bytes to write
-     *  \param data    SP data to write
-     *  \return
-     *      On success 0, error otherwise.
-     */
-    uint8_t write_patch(uint32_t file_id, uint32_t length, const uint8_t *data);
-    /**
-     *  \brief Create new file entry and allocate space on the NVMEM. Applies only to user files.
-     *  \param file_id nvmem file Id
-     *  \param new_len entry ulLength
-     *  \return
-     */
-    int32_t create_entry(uint32_t file_id, uint32_t new_len);
-#ifndef CC3000_TINY_DRIVER
-    /**
-     *  \brief Read patch version. read package version (WiFi FW patch, river-supplicant-NS patch,
-     *      bootloader patch)
-     *  \param patch_ver First number indicates package ID and the second number indicates
-     *      package build number
-     *  \return
-     *      On success 0, error otherwise.
-     */
-    uint8_t read_sp_version(uint8_t* patch_ver);
-#endif
-private:
-    cc3000_hci          &_hci;
-    cc3000_event        &_event;
-    cc3000_simple_link  &_simple_link;
-};
-
-/** WLAN layer
- */
-class cc3000_wlan {
-public:
-    /**
-     *  \brief Ctor
-     *  \param simple_link Reference to the simple link object.
-     *  \param event       Reference to the event object.
-     *  \param spi         Reference to the spi object.
-     *  \param hci         Reference to the hci object.
-     *  \return none
-     */
-    cc3000_wlan(cc3000_simple_link &simple_link, cc3000_event &event, cc3000_spi &spi, cc3000_hci &hci);
-    /**
-     *  \brief Dtor
-     *  \param none
-     *  \return none
-     */
-    ~cc3000_wlan();
-    /**
-     *  \brief Send SIMPLE LINK START to cc3000.
-     *  \param patches_available_host Flag to indicate if patches are available.
-     *  \return none
-     */
-    void simpleLink_init_start(uint16_t patches_available_host);
-    /**
-     *  \brief Start wlan device. Blocking call until init is completed.
-     *  \param patches_available_host Flag to indicate if patches are available.
-     *  \return none
-     */
-    void start(uint16_t patches_available_host);
-    /**
-     *  \brief Stop wlan device
-     *  \param none
-     *  \return none
-     */
-    void stop(void);
-#ifndef CC3000_TINY_DRIVER
-    /**
-     *  \brief Connect to AP.
-     *  \param sec_type    Security option.
-     *  \param ssid        up to 32 bytes, ASCII SSID
-     *  \param ssid_length length of SSID
-     *  \param b_ssid      6 bytes specified the AP bssid
-     *  \param key         up to 16 bytes specified the AP security key
-     *  \param key_len     key length
-     *  \return
-     *      On success, zero is returned. On error, negative is returned.
-     */
-    int32_t connect(uint32_t sec_type, const uint8_t *ssid, int32_t ssid_length, uint8_t *b_ssid, uint8_t *key, int32_t key_len);
-    /**
-     *  \brief Add profile. Up to 7 profiles are supported.
-     *  \param sec_type                      Security option.
-     *  \param ssid                          Up to 32 bytes, ASCII SSID
-     *  \param ssid_length                   Length of SSID
-     *  \param b_ssid                        6 bytes specified the AP bssid
-     *  \param priority                      Up to 16 bytes specified the AP security key
-     *  \param pairwise_cipher_or_tx_key_len Key length
-     *  \param group_cipher_tx_key_index     Key length for WEP security
-     *  \param key_mgmt                      KEY management
-     *  \param pf_or_key                     Security key
-     *  \param pass_phrase_length            Security key length for WPA\WPA2
-     *  \return
-     *      On success, zero is returned. On error, negative is returned.
-     */
-    int32_t add_profile(uint32_t sec_type, uint8_t* ssid, uint32_t ssid_length, uint8_t *b_ssid, uint32_t priority, uint32_t pairwise_cipher_or_tx_key_len, uint32_t group_cipher_tx_key_index,
-                          uint32_t key_mgmt, uint8_t* pf_or_key, uint32_t pass_phrase_length);
-    /**
-     *  \brief Gets entry from scan result table. The scan results are returned
-     *      one by one, and each entry represents a single AP found in the area.
-     *  \param scan_timeout Not supported yet
-     *  \param results      Scan result
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned
-     */
-    int32_t ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results);
-    /**
-     *  \brief Start and stop scan procedure. Set scan parameters.
-     *  \param enable             Start/stop application scan
-     *  \param min_dwell_time     Minimum dwell time value to be used for each channel, in ms. (Default: 20)
-     *  \param max_dwell_time     Maximum dwell time value to be used for each channel, in ms. (Default: 30)
-     *  \param num_probe_requests Max probe request between dwell time. (Default:2)
-     *  \param channel_mask       Bitwise, up to 13 channels (0x1fff).
-     *  \param rssi_threshold     RSSI threshold. Saved: yes (Default: -80)
-     *  \param snr_threshold      NSR threshold. Saved: yes (Default: 0)
-     *  \param default_tx_power   probe Tx power. Saved: yes (Default: 205)
-     *  \param interval_list      Pointer to array with 16 entries (16 channels)
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned.
-     */
-    int32_t ioctl_set_scan_params(uint32_t enable, uint32_t min_dwell_time, uint32_t max_dwell_time, uint32_t num_probe_requests,
-                                uint32_t channel_mask, int32_t rssi_threshold, uint32_t snr_threshold, uint32_t default_tx_power, uint32_t *interval_list);
-    /**
-     *  \brief Get wlan status: disconnected, scanning, connecting or connected
-     *  \param none
-     *  \return
-     *      WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, STATUS_CONNECTING or WLAN_STATUS_CONNECTED
-     */
-    int32_t ioctl_statusget(void);
-#else
-    /**
-     *  \brief Connect to AP
-     *  \param ssid        Up to 32 bytes and is ASCII SSID of the AP
-     *  \param ssid_length Length of the SSID
-     *  \return
-     *      On success, zero is returned. On error, negative is returned.
-     */
-    int32_t connect(const uint8_t *ssid, int32_t ssid_length);
-    /**
-     *  \brief When auto start is enabled, the device connects to station from the profiles table.
-     *      If several profiles configured the device choose the highest priority profile.
-     *  \param sec_type                      WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2
-     *  \param ssid                          SSID up to 32 bytes
-     *  \param ssid_length                   SSID length
-     *  \param b_ssid                        bssid 6 bytes
-     *  \param priority                      Profile priority. Lowest priority:0.
-     *  \param pairwise_cipher_or_tx_key_len Key length for WEP security
-     *  \param group_cipher_tx_key_index     Key index
-     *  \param key_mgmt                      KEY management
-     *  \param pf_or_key                     Security key
-     *  \param pass_phrase_length            Security key length for WPA\WPA2
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned
-     */
-    int32_t add_profile(uint32_t sec_type, uint8_t *ssid, uint32_t ssid_length, uint8_t *b_ssid, uint32_t priority,
-                      uint32_t pairwise_cipher_or_tx_key_len, uint32_t group_cipher_tx_key_index, uint32_t key_mgmt,
-                      uint8_t* pf_or_key, uint32_t pass_phrase_length);
-#endif
-#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
-    /**
-     *  \brief Process the acquired data and store it as a profile.
-     *  \param none
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned.
-     */
-    int32_t smart_config_process(void);
-#endif
-    /**
-     *  \brief Disconnect connection from AP.
-     *  \param none
-     *  \return
-     *      0 if disconnected done, other CC3000 already disconnected.
-     */
-    int32_t disconnect();
-    /**
-     *  \brief When auto is enabled, the device tries to connect according the following policy:
-     *      1) If fast connect is enabled and last connection is valid, the device will try to
-     *      connect to it without the scanning procedure (fast). The last connection will be
-     *      marked as invalid, due to adding/removing profile.
-     *      2) If profile exists, the device will try to connect it (Up to seven profiles).
-     *      3) If fast and profiles are not found, and open mode is enabled, the device
-     *      will try to connect to any AP.
-     *      Note that the policy settings are stored in the CC3000 NVMEM.
-     *  \param should_connect_to_open_ap Enable(1), disable(0) connect to any available AP.
-     *  \param use_fast_connect          Enable(1), disable(0). if enabled, tries to
-     *                                   connect to the last connected AP.
-     *  \param use_profiles              Enable(1), disable(0) auto connect after reset.
-     *                                   and periodically reconnect if needed.
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned
-     */
-    int32_t ioctl_set_connection_policy(uint32_t should_connect_to_open_ap, uint32_t use_fast_connect, uint32_t use_profiles);
-    /**
-     *  \brief Delete WLAN profile
-     *  \param index Number of profile to delete
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned
-     */
-    int32_t ioctl_del_profile(uint32_t index);
-    /**
-     *  \brief Mask event according to bit mask. In case that event is
-     *      masked (1), the device will not send the masked event to host.
-     *  \param mask event mask
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned
-     */
-    int32_t set_event_mask(uint32_t mask);
-    /**
-     *  \brief Start to acquire device profile. The device acquire its own
-     *      profile, if profile message is found.
-     *  \param encrypted_flag Indicates whether the information is encrypted
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned.
-     */
-    int32_t smart_config_start(uint32_t encrypted_flag);
-    /**
-     *  \brief Stop the acquire profile procedure.
-     *  \param none
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned
-     */
-    int32_t smart_config_stop(void);
-    /**
-     *  \brief Configure station ssid prefix.
-     *  \param new_prefix 3 bytes identify the SSID prefix for the Smart Config.
-     *  \return
-     *      On success, zero is returned. On error, -1 is returned.
-     */
-    int32_t smart_config_set_prefix(uint8_t *new_prefix);
-private:
-    cc3000_simple_link  &_simple_link;
-    cc3000_event        &_event;
-    cc3000_spi          &_spi;
-    cc3000_hci          &_hci;
-};
-
-/** The main object of cc3000 implementation
- */
-class cc3000 {
-public:
-    /** status structure */
-    typedef struct {
-        bool    dhcp;
-        bool    connected;
-        uint8_t socket;
-        bool    smart_config_complete;
-        bool    stop_smart_config;
-        bool    dhcp_configured;
-        bool    ok_to_shut_down;
-        bool    enabled;
-    } tStatus;
-    /**
-     *  \brief Ctor.
-     *  \param cc3000_irq IRQ pin
-     *  \param cc3000_en  Enable pin
-     *  \param cc3000_cs  Chip select pin
-     *  \param cc3000_spi SPI interface
-     *  \param irq_port   IRQ pin's port
-     */
-    cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port);
-    /**
-     *  \brief Dtor.
-     */
-    ~cc3000();
-    /**
-     *  \brief Initiate cc3000. It starts the wlan communication and deletes profiles.
-     *  \param patch Patch
-     */
-    void start(uint8_t patch);
-    /**
-     *  \brief Stops the wlan communication.
-     */
-    void stop();
-    /**
-     *  \brief Restarts the wlan communication.
-     */
-    void restart(uint8_t patch);
-    /**
-     *  \brief Disconnect wlan device
-     *
-     */
-    bool disconnect(void);
-    /**
-     *  \brief Callback which is called from the event class. This updates status of cc3000.
-     *  \param event_type Type of the event
-     *  \param data       Pointer to data
-     *  \param length     Length of data
-     *  \return none
-     */
-    void usync_callback(int32_t event_type, uint8_t *data, uint8_t length);
-    /**
-     *  \brief Start connection to SSID (open/secured) non-blocking
-     *  \param ssid          SSID name
-     *  \param key           Security key (if key = 0, open connection)
-     *  \param security_mode Security mode
-     *  \return true if connection was established, false otherwise.
-     */
-    bool connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
-    /**
-     *  \brief Connect to SSID (open/secured) with timeout (10s).
-     *  \param ssid          SSID name
-     *  \param key           Security key (if key = 0, open connection)
-     *  \param security_mode Security mode
-     *  \return true if connection was established, false otherwise.
-     */
-    bool connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
-    /**
-     *  \brief Connect to SSID which is secured
-     *  \param ssid          SSID name
-     *  \param key           Security key
-     *  \param security_mode Security mode
-     *  \return true if connection was established, false otherwise.
-     */
-    bool connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
-    /**
-     *  \brief Connect to SSID which is open (no security)
-     *  \param ssid          SSID name
-     *  \return true if connection was established, false otherwise.
-     */
-    bool connect_open(const uint8_t *ssid);
-    /**
-     *  \brief Status of the cc3000 module.
-     *  \return true if it's enabled, false otherwise.
-     */
-    bool is_enabled();
-    /**
-     *  \brief Status of the cc3000 connection.
-     *  \return true if it's connected, false otherwise.
-     */
-    bool is_connected();
-    /**
-     *  \brief Status of DHCP.
-     *  \param none
-     *  \return true if DCHP is configured, false otherwise.
-     */
-    bool is_dhcp_configured();
-    /**
-     *  \brief Status of smart confing completation.
-     *  \param none
-     *  \return smart config was set, false otherwise.
-     */
-    bool is_smart_confing_completed();
-    /**
-     *  \brief Return the cc3000's mac address.
-     *  \param address Retreived mac address.
-     *  \return
-     */
-    uint8_t get_mac_address(uint8_t address[6]);
-    /**
-     *  \brief Set the cc3000's mac address.
-     *  \param address Mac address to be set.
-     *  \return
-     */
-    uint8_t set_mac_address(uint8_t address[6]);
-    /**
-     *  \brief Get user file info.
-     *  \param  info_file Pointer where info will be stored.
-     *  \param  size      Available size.
-     *  \return none
-     */
-    void get_user_file_info(uint8_t *info_file, size_t size);
-    /**
-     *  \brief Set user filo info.
-     *  \param info_file Pointer to user's info.
-     *  \return none
-     */
-    void set_user_file_info(uint8_t *info_file, size_t size);
-    /**
-     *  \brief Start smart config.
-     *  \param smart_config_key Pointer to smart config key.
-     *  \return none
-     */
-    void start_smart_config(const uint8_t *smart_config_key);  /* TODO enable AES ? */
-#ifndef CC3000_TINY_DRIVER
-    /**
-     *  \brief Return ip configuration.
-     *  \param ip_config Pointer to ipconfig data.
-     *  \return true if it's connected and info was retrieved, false otherwise.
-     */
-    bool get_ip_config(tNetappIpconfigRetArgs *ip_config);
-#endif
-    /**
-     *  \brief Delete all stored profiles.
-     *  \param none
-     *  \return none
-     */
-    void delete_profiles(void);
-    /**
-     *  \brief Ping an ip address.
-     *  \param ip       Destination IP address
-     *  \param attempts Number of attempts
-     *  \param timeout  Time to wait for a response,in milliseconds.
-     *  \param size     Send buffer size which may be up to 1400 bytes
-     */
-    uint32_t ping(uint32_t ip, uint8_t attempts, uint16_t timeout, uint8_t size);
-    /**
-     *  \brief Returns cc3000 instance. Used in Socket interface.
-     *  \param none
-     *  \return Pointer to cc3000 object
-     */
-    static cc3000 *get_instance() {
-        return _inst;
-    }
-#if (CC3000_ETH_COMPAT == 1)
-    /**
-     *  \brief Get the MAC address of your Ethernet interface.
-     *  \param none
-     *  \return
-     *      Pointer to a string containing the MAC address.
-     */
-    char* getMACAddress();
-
-     /**
-     *  \brief Get the IP address of your Ethernet interface.
-     *  \param none
-     *  \return
-     *      Pointer to a string containing the IP address.
-     */
-    char* getIPAddress();
-
-     /**
-     *  \brief Get the Gateway address of your Ethernet interface
-     *  \param none
-     *  \return
-     *      Pointer to a string containing the Gateway address
-     */
-    char* getGateway();
-
-     /**
-     *  \brief Get the Network mask of your Ethernet interface
-     *  \param none
-     *  \return
-     *      Pointer to a string containing the Network mask
-     */
-    char* getNetworkMask();
-#endif
-public:
-    cc3000_simple_link  _simple_link;
-    cc3000_event        _event;
-#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
-    cc3000_security     _security;
-#endif
-    cc3000_socket       _socket;
-    cc3000_spi          _spi;
-    cc3000_hci          _hci;
-    cc3000_nvmem        _nvmem;
-    cc3000_netapp       _netapp;
-    cc3000_wlan         _wlan;
-protected:
-    static cc3000       *_inst;
-private:
-    tStatus                  _status;
-    netapp_pingreport_args_t _ping_report;
-    bool                     _closed_sockets[MAX_SOCKETS];
-};
-
-/**
- * Copy 32 bit to stream while converting to little endian format.
- * @param  p       pointer to the new stream
- * @param  u32     pointer to the 32 bit
- * @return         pointer to the new stream
- */
-uint8_t *UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32);
-
-/**
- * Copy 16 bit to stream while converting to little endian format.
- * @param  p       pointer to the new stream
- * @param  u32     pointer to the 16 bit
- * @return         pointer to the new stream
- */
-uint8_t *UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16);
-
-/**
- * Copy received stream to 16 bit in little endian format.
- * @param  p          pointer to the stream
- * @param  offset     offset in the stream
- * @return            pointer to the new 16 bit
- */
-uint16_t STREAM_TO_UINT16_f(uint8_t* p, uint16_t offset);
-
-/**
- * Copy received stream to 32 bit in little endian format.
- * @param  p          pointer to the stream
- * @param  offset     offset in the stream
- * @return            pointer to the new 32 bit
- */
-uint32_t STREAM_TO_UINT32_f(uint8_t* p, uint16_t offset);
-
-} /* end of mbed_cc3000 namespace */
-
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_common.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_COMMON_H
-#define CC3000_COMMON_H
-
-#include <errno.h>
-
-//#define CC3000_TINY_DRIVER                // Driver for small memory model CPUs
-
-#define ESUCCESS        0
-#define EFAIL          -1
-#define EERROR          EFAIL
-
-#define CC3000_UNENCRYPTED_SMART_CONFIG   // No encryption
-
-#define ERROR_SOCKET_INACTIVE   -57
-
-#define HCI_CC_PAYLOAD_LEN      5
-
-#define WLAN_ENABLE            (1)
-#define WLAN_DISABLE           (0)
-
-#define MAC_ADDR_LEN           (6)
-
-
-/*Defines for minimal and maximal RX buffer size. This size includes the spi
-  header and hci header.
-  maximal buffer size: MTU + HCI header + SPI header + sendto() args size
-  minimum buffer size: HCI header + SPI header + max args size
-
-  This buffer is used for receiving events and data.
-  The packet can not be longer than MTU size and CC3000 does not support
-  fragmentation. Note that the same buffer is used for reception of the data
-  and events from CC3000. That is why the minimum is defined.
-  The calculation for the actual size of buffer for reception is:
-  Given the maximal data size MAX_DATA that is expected to be received by
-  application, the required buffer Using recv() or recvfrom():
-
-    max(CC3000_MINIMAL_RX_SIZE, MAX_DATA + HEADERS_SIZE_DATA + fromlen + ucArgsize + 1)
-
-  Using gethostbyname() with minimal buffer size will limit the host name returned to 99 bytes.
-  The 1 is used for the overrun detection
-*/
-
-#define CC3000_MINIMAL_RX_SIZE      (118 + 1)
-#define CC3000_MAXIMAL_RX_SIZE      (511 + 1)
-
-/*Defines for minimal and maximal TX buffer size.
-  This buffer is used for sending events and data.
-  The packet can not be longer than MTU size and CC3000 does not support
-  fragmentation. Note that the same buffer is used for transmission of the data
-  and commands. That is why the minimum is defined.
-  The calculation for the actual size of buffer for transmission is:
-  Given the maximal data size MAX_DATA, the required buffer is:
-  Using Sendto():
-
-   max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
-   + SOCKET_SENDTO_PARAMS_LEN + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
-
-  Using Send():
-
-   max(CC3000_MINIMAL_TX_SIZE, MAX_DATA + SPI_HEADER_SIZE
-   + HCI_CMND_SEND_ARG_LENGTH + SIMPLE_LINK_HCI_DATA_HEADER_SIZE + 1)
-
-  The 1 is used for the overrun detection */
-
-#define CC3000_MINIMAL_TX_SIZE      (118 + 1)
-#define CC3000_MAXIMAL_TX_SIZE      (1519 + 1)
-
-//TX and RX buffer size - allow to receive and transmit maximum data at lengh 8.
-#ifdef CC3000_TINY_DRIVER
-#define TINY_CC3000_MAXIMAL_RX_SIZE 44
-#define TINY_CC3000_MAXIMAL_TX_SIZE 59
-#endif
-
-/*In order to determine your preferred buffer size,
-  change CC3000_MAXIMAL_RX_SIZE and CC3000_MAXIMAL_TX_SIZE to a value between
-  the minimal and maximal specified above.
-  Note that the buffers are allocated by SPI.
-*/
-
-#ifndef CC3000_TINY_DRIVER
-
-    #define CC3000_RX_BUFFER_SIZE   (CC3000_MAXIMAL_RX_SIZE)
-    #define CC3000_TX_BUFFER_SIZE   (CC3000_MAXIMAL_TX_SIZE)
-    #define SP_PORTION_SIZE         512
-
-//TINY DRIVER: We use smaller rx and tx buffers in order to minimize RAM consumption
-#else
-    #define CC3000_RX_BUFFER_SIZE   (TINY_CC3000_MAXIMAL_RX_SIZE)
-    #define CC3000_TX_BUFFER_SIZE   (TINY_CC3000_MAXIMAL_TX_SIZE)
-    #define SP_PORTION_SIZE         32
-#endif
-
-
-//Copy 8 bit to stream while converting to little endian format.
-#define UINT8_TO_STREAM(_p, _val)    {*(_p)++ = (_val);}
-//Copy 16 bit to stream while converting to little endian format.
-#define UINT16_TO_STREAM(_p, _u16)    (UINT16_TO_STREAM_f(_p, _u16))
-//Copy 32 bit to stream while converting to little endian format.
-#define UINT32_TO_STREAM(_p, _u32)    (UINT32_TO_STREAM_f(_p, _u32))
-//Copy a specified value length bits (l) to stream while converting to little endian format.
-#define ARRAY_TO_STREAM(p, a, l)     {uint32_t _i; for (_i = 0; _i < l; _i++) *(p)++ = ((uint8_t *) a)[_i];}
-//Copy received stream to 8 bit in little endian format.
-#define STREAM_TO_UINT8(_p, _offset, _u8)    {_u8 = (uint8_t)(*(_p + _offset));}
-//Copy received stream to 16 bit in little endian format.
-#define STREAM_TO_UINT16(_p, _offset, _u16)    {_u16 = STREAM_TO_UINT16_f(_p, _offset);}
-//Copy received stream to 32 bit in little endian format.
-#define STREAM_TO_UINT32(_p, _offset, _u32)    {_u32 = STREAM_TO_UINT32_f(_p, _offset);}
-#define STREAM_TO_STREAM(p, a, l)     {uint32_t _i; for (_i = 0; _i < l; _i++) *(a)++= ((uint8_t *) p)[_i];}
-
-typedef struct _sockaddr_t
-{
-    uint16_t  family;
-    uint8_t   data[14];
-} sockaddr;
-
-struct timeval
-{
-    int32_t tv_sec;       /* seconds */
-    int32_t tv_usec;      /* microseconds */
-};
-
-#define SMART_CONFIG_PROFILE_SIZE        67        // 67 = 32 (max ssid) + 32 (max key) + 1 (SSID length) + 1 (security type) + 1 (key length)
-
-/* patches type */
-#define PATCHES_HOST_TYPE_WLAN_DRIVER   0x01
-#define PATCHES_HOST_TYPE_WLAN_FW       0x02
-#define PATCHES_HOST_TYPE_BOOTLOADER    0x03
-
-#define SL_SET_SCAN_PARAMS_INTERVAL_LIST_SIZE    (16)
-#define SL_SIMPLE_CONFIG_PREFIX_LENGTH           (3)
-#define ETH_ALEN                                 (6)
-#define MAXIMAL_SSID_LENGTH                      (32)
-
-#define SL_PATCHES_REQUEST_DEFAULT               (0)
-#define SL_PATCHES_REQUEST_FORCE_HOST            (1)
-#define SL_PATCHES_REQUEST_FORCE_NONE            (2)
-
-
-#define      WLAN_SEC_UNSEC  (0)
-#define      WLAN_SEC_WEP    (1)
-#define      WLAN_SEC_WPA    (2)
-#define      WLAN_SEC_WPA2   (3)
-
-
-#define WLAN_SL_INIT_START_PARAMS_LEN           (1)
-#define WLAN_PATCH_PARAMS_LENGTH                (8)
-#define WLAN_SET_CONNECTION_POLICY_PARAMS_LEN   (12)
-#define WLAN_DEL_PROFILE_PARAMS_LEN             (4)
-#define WLAN_SET_MASK_PARAMS_LEN                (4)
-#define WLAN_SET_SCAN_PARAMS_LEN                (100)
-#define WLAN_GET_SCAN_RESULTS_PARAMS_LEN        (4)
-#define WLAN_ADD_PROFILE_NOSEC_PARAM_LEN        (24)
-#define WLAN_ADD_PROFILE_WEP_PARAM_LEN          (36)
-#define WLAN_ADD_PROFILE_WPA_PARAM_LEN          (44)
-#define WLAN_CONNECT_PARAM_LEN                  (29)
-#define WLAN_SMART_CONFIG_START_PARAMS_LEN      (4)
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_event.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,669 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_event.h"
-#include "cc3000_netapp.h"
-
-namespace mbed_cc3000 {
-
-#if (CC3000_DEBUG_HCI_RX == 1)
-const char *HCI_EVENT_STR[] =
-{
-    "Socket",
-    "Bind",
-    "Send",
-    "Recv",
-    "Accept",
-    "Listen",
-    "Connect",
-    "BSD Select",
-    "Set Socket Options",
-    "Get Socket Options",
-    "Close Socket",
-    "Unknown",
-    "Recv From",
-    "Write",
-    "Send To",
-    "Get Hostname",
-    "mDNS Advertise"
-};
-
-const char *HCI_NETAPP_STR[] =
-{
-    "DHCP",
-    "Ping Sent",
-    "Ping Report",
-    "Ping Stop",
-    "IP Config",
-    "ARP Flush",
-    "Unknown",
-    "Set Debug level",
-    "Set Timers"
-};
-
-// from 0-7
-const char *HCI_MISC_STR[] =
-{
-    "BASE - Error?",
-    "Connecting",
-    "Disconnect",
-    "Scan Param",
-    "Connect Policy",
-    "Add Profile",
-    "Del Profile",
-    "Get Scan Res",
-    "Event Mask",
-    "Status Req",
-    "Config Start",
-    "Config Stop",
-    "Config Set Prefix",
-    "Config Patch",
-};
-#endif
-
-cc3000_event::cc3000_event(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_spi &spi, cc3000 &cc3000)
-    : socket_active_status(SOCKET_STATUS_INIT_VAL), _simple_link(simplelink), _hci(hci), _spi(spi), _cc3000(cc3000) {
-
-}
-
-cc3000_event::~cc3000_event() {
-
-}
-
-/* TODO removed buffer, set it in init */
-void cc3000_event::received_handler(uint8_t *buffer) {
-    _simple_link.set_data_received_flag(1);
-    _simple_link.set_received_data(buffer);
-
-    hci_unsolicited_event_handler();
-}
-
-void cc3000_event::hci_unsol_handle_patch_request(uint8_t *event_hdr) {
-    uint8_t *params = (uint8_t *)(event_hdr) + HCI_EVENT_HEADER_SIZE;
-    uint32_t length = 0;
-    uint8_t *patch;
-
-    switch (*params)
-    {
-        case HCI_EVENT_PATCHES_DRV_REQ:
-        {
-            tDriverPatches func_pointer = (tDriverPatches)_simple_link.get_func_pointer(DRIVER_PATCHES);
-            if (func_pointer)
-            {
-                patch = func_pointer(&length);
-                if (patch)
-                {
-                    _hci.patch_send(HCI_EVENT_PATCHES_DRV_REQ, _simple_link.get_transmit_buffer(), patch, length);
-                    return;
-                }
-            }
-
-            // Send 0 length Patches response event
-            _hci.patch_send(HCI_EVENT_PATCHES_DRV_REQ, _simple_link.get_transmit_buffer(), 0, 0);
-            break;
-        }
-        case HCI_EVENT_PATCHES_FW_REQ:
-        {
-            tFWPatches func_pointer = (tFWPatches)_simple_link.get_func_pointer(FW_PATCHES);
-            if (func_pointer)
-            {
-                patch = func_pointer(&length);
-                // Build and send a patch
-                if (patch)
-                {
-                    _hci.patch_send(HCI_EVENT_PATCHES_FW_REQ, _simple_link.get_transmit_buffer(), patch, length);
-                    return;
-                }
-            }
-            // Send 0 length Patches response event
-            _hci.patch_send(HCI_EVENT_PATCHES_FW_REQ, _simple_link.get_transmit_buffer(), 0, 0);
-            break;
-        }
-        case HCI_EVENT_PATCHES_BOOTLOAD_REQ:
-        {
-            tBootLoaderPatches func_pointer = (tBootLoaderPatches)_simple_link.get_func_pointer(BOOTLOADER_PATCHES);
-            if (func_pointer)
-            {
-                patch = func_pointer(&length);
-                if (patch)
-                {
-                    _hci.patch_send(HCI_EVENT_PATCHES_BOOTLOAD_REQ, _simple_link.get_transmit_buffer(), patch, length);
-                    return;
-                }
-            }
-            // Send 0 length Patches response event
-            _hci.patch_send(HCI_EVENT_PATCHES_BOOTLOAD_REQ, _simple_link.get_transmit_buffer(), 0, 0);
-            break;
-        }
-    }
-}
-
-static void hci_event_debug_print(uint16_t hciEventNo)
-{
-#if (CC3000_DEBUG_HCI_RX == 1)
-    if ((hciEventNo > HCI_CMND_SOCKET_BASE) && ( hciEventNo <= HCI_CMND_MDNS_ADVERTISE))
-    {
-        DBG_HCI("Event Received : 0x%04X - %s", hciEventNo, HCI_EVENT_STR[hciEventNo-HCI_CMND_SOCKET]);
-    }
-    else if ((hciEventNo > HCI_CMND_NETAPP_BASE) && ( hciEventNo <= HCI_NETAPP_SET_TIMERS))
-    {
-        DBG_HCI("Event Received : 0x%04X - %s", hciEventNo, HCI_NETAPP_STR[hciEventNo-HCI_NETAPP_DHCP]);
-    }
-    else if (hciEventNo < HCI_CMND_WLAN_CONFIGURE_PATCH+1)
-    {
-        DBG_HCI("Event Received : 0x%04X - %s", hciEventNo, HCI_MISC_STR[hciEventNo]);
-    }
-    else
-    {
-        DBG_HCI("Event Received : 0x%04X", hciEventNo);
-    }
-#endif
-}
-
-uint8_t *cc3000_event::hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen) {
-    uint8_t *received_data, argument_size;
-    uint16_t length;
-    uint8_t *pucReceivedParams;
-    uint16_t received_op_code = 0;
-    uint32_t return_value;
-    uint8_t * RecvParams;
-    uint8_t *RetParams;
-
-    while (1)
-    {
-        if (_simple_link.get_data_received_flag() != 0)
-        {
-            received_data = _simple_link.get_received_data();
-            if (*received_data == HCI_TYPE_EVNT)
-            {
-                // Event Received
-                STREAM_TO_UINT16((uint8_t *)received_data, HCI_EVENT_OPCODE_OFFSET,received_op_code);
-                pucReceivedParams = received_data + HCI_EVENT_HEADER_SIZE;
-                RecvParams = pucReceivedParams;
-                RetParams = (uint8_t *)ret_param;
-
-                // unsolicited event received - finish handling
-                if (hci_unsol_event_handler((uint8_t *)received_data) == 0)
-                {
-                    STREAM_TO_UINT8(received_data, HCI_DATA_LENGTH_OFFSET, length);
-
-                    hci_event_debug_print( received_op_code );
-
-                    switch(received_op_code)
-                    {
-                    case HCI_CMND_READ_BUFFER_SIZE:
-                        {
-                            uint16_t temp = _simple_link.get_number_free_buffers();
-                            STREAM_TO_UINT8((uint8_t *)pucReceivedParams, 0, temp);
-                            _simple_link.set_number_free_buffers(temp);
-
-                            temp = _simple_link.get_buffer_length();
-                            STREAM_TO_UINT16((uint8_t *)pucReceivedParams, 1, temp);
-                            _simple_link.set_buffer_length(temp);
-                        }
-                        break;
-
-                    case HCI_CMND_WLAN_CONFIGURE_PATCH:
-                    case HCI_NETAPP_DHCP:
-                    case HCI_NETAPP_PING_SEND:
-                    case HCI_NETAPP_PING_STOP:
-                    case HCI_NETAPP_ARP_FLUSH:
-                    case HCI_NETAPP_SET_DEBUG_LEVEL:
-                    case HCI_NETAPP_SET_TIMERS:
-                    case HCI_EVNT_NVMEM_READ:
-                    case HCI_EVNT_NVMEM_CREATE_ENTRY:
-                    case HCI_CMND_NVMEM_WRITE_PATCH:
-                    case HCI_NETAPP_PING_REPORT:
-                    case HCI_EVNT_MDNS_ADVERTISE:
-
-                        STREAM_TO_UINT8(received_data, HCI_EVENT_STATUS_OFFSET, *(uint8_t *)ret_param);
-                        break;
-
-                    case HCI_CMND_SETSOCKOPT:
-                    case HCI_CMND_WLAN_CONNECT:
-                    case HCI_CMND_WLAN_IOCTL_STATUSGET:
-                    case HCI_EVNT_WLAN_IOCTL_ADD_PROFILE:
-                    case HCI_CMND_WLAN_IOCTL_DEL_PROFILE:
-                    case HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY:
-                    case HCI_CMND_WLAN_IOCTL_SET_SCANPARAM:
-                    case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START:
-                    case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP:
-                    case HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX:
-                    case HCI_CMND_EVENT_MASK:
-                    case HCI_EVNT_WLAN_DISCONNECT:
-                    case HCI_EVNT_SOCKET:
-                    case HCI_EVNT_BIND:
-                    case HCI_CMND_LISTEN:
-                    case HCI_EVNT_CLOSE_SOCKET:
-                    case HCI_EVNT_CONNECT:
-                    case HCI_EVNT_NVMEM_WRITE:
-
-                        STREAM_TO_UINT32((uint8_t *)pucReceivedParams,0, *(uint32_t *)ret_param);
-                        break;
-
-                    case HCI_EVNT_READ_SP_VERSION:
-
-                        STREAM_TO_UINT8(received_data, HCI_EVENT_STATUS_OFFSET, *(uint8_t *)ret_param);
-                        ret_param = ((uint8_t *)ret_param) + 1;
-                        STREAM_TO_UINT32((uint8_t *)pucReceivedParams, 0, return_value);
-                        UINT32_TO_STREAM((uint8_t *)ret_param, return_value);
-                        break;
-
-                    case HCI_EVNT_BSD_GETHOSTBYNAME:
-
-                        STREAM_TO_UINT32((uint8_t *)pucReceivedParams,GET_HOST_BY_NAME_RETVAL_OFFSET,*(uint32_t *)ret_param);
-                        ret_param = ((uint8_t *)ret_param) + 4;
-                        STREAM_TO_UINT32((uint8_t *)pucReceivedParams,GET_HOST_BY_NAME_ADDR_OFFSET,*(uint32_t *)ret_param);
-                        break;
-
-                    case HCI_EVNT_ACCEPT:
-                        {
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,ACCEPT_SD_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,ACCEPT_RETURN_STATUS_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-
-                            //This argument returns in network order
-                            memcpy((uint8_t *)ret_param, pucReceivedParams + ACCEPT_ADDRESS__OFFSET, sizeof(sockaddr));
-                            break;
-                        }
-
-                    case HCI_EVNT_RECV:
-                    case HCI_EVNT_RECVFROM:
-                        {
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SL_RECEIVE_SD_OFFSET ,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SL_RECEIVE_NUM_BYTES_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SL_RECEIVE__FLAGS__OFFSET,*(uint32_t *)ret_param);
-
-                            if(((tBsdReadReturnParams *)ret_param)->iNumberOfBytes == ERROR_SOCKET_INACTIVE)
-                            {
-                                set_socket_active_status(((tBsdReadReturnParams *)ret_param)->iSocketDescriptor,SOCKET_STATUS_INACTIVE);
-                            }
-                            break;
-                        }
-
-                    case HCI_EVNT_SEND:
-                    case HCI_EVNT_SENDTO:
-                        {
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SL_RECEIVE_SD_OFFSET ,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SL_RECEIVE_NUM_BYTES_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-
-                            break;
-                        }
-
-                    case HCI_EVNT_SELECT:
-                        {
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SELECT_STATUS_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SELECT_READFD_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SELECT_WRITEFD_OFFSET,*(uint32_t *)ret_param);
-                            ret_param = ((uint8_t *)ret_param) + 4;
-                            STREAM_TO_UINT32((uint8_t *)pucReceivedParams,SELECT_EXFD_OFFSET,*(uint32_t *)ret_param);
-                            break;
-                        }
-
-                    case HCI_CMND_GETSOCKOPT:
-
-                        STREAM_TO_UINT8(received_data, HCI_EVENT_STATUS_OFFSET,((tBsdGetSockOptReturnParams *)ret_param)->iStatus);
-                        //This argument returns in network order
-                        memcpy((uint8_t *)ret_param, pucReceivedParams, 4);
-                        break;
-
-                    case HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS:
-
-                        STREAM_TO_UINT32((uint8_t *)pucReceivedParams,GET_SCAN_RESULTS_TABlE_COUNT_OFFSET,*(uint32_t *)ret_param);
-                        ret_param = ((uint8_t *)ret_param) + 4;
-                        STREAM_TO_UINT32((uint8_t *)pucReceivedParams,GET_SCAN_RESULTS_SCANRESULT_STATUS_OFFSET,*(uint32_t *)ret_param);
-                        ret_param = ((uint8_t *)ret_param) + 4;
-                        STREAM_TO_UINT16((uint8_t *)pucReceivedParams,GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET,*(uint32_t *)ret_param);
-                        ret_param = ((uint8_t *)ret_param) + 2;
-                        STREAM_TO_UINT16((uint8_t *)pucReceivedParams,GET_SCAN_RESULTS_FRAME_TIME_OFFSET,*(uint32_t *)ret_param);
-                        ret_param = ((uint8_t *)ret_param) + 2;
-                        memcpy((uint8_t *)ret_param, (uint8_t *)(pucReceivedParams + GET_SCAN_RESULTS_FRAME_TIME_OFFSET + 2), GET_SCAN_RESULTS_SSID_MAC_LENGTH);
-                        break;
-
-                    case HCI_CMND_SIMPLE_LINK_START:
-                        break;
-
-                    case HCI_NETAPP_IPCONFIG:
-
-                        //Read IP address
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
-                        RecvParams += 4;
-
-                        //Read subnet
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
-                        RecvParams += 4;
-
-                        //Read default GW
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
-                        RecvParams += 4;
-
-                        //Read DHCP server
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
-                        RecvParams += 4;
-
-                        //Read DNS server
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_IP_LENGTH);
-                        RecvParams += 4;
-
-                        //Read Mac address
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_MAC_LENGTH);
-                        RecvParams += 6;
-
-                        //Read SSID
-                        STREAM_TO_STREAM(RecvParams,RetParams,NETAPP_IPCONFIG_SSID_LENGTH);
-                        break;
-
-                    default :
-                        DBG_HCI("UNKNOWN Event Received : 0x%04X ", received_op_code);
-                        break;
-                    }
-
-                }
-                if (received_op_code == _simple_link.get_op_code())
-                {
-                    _simple_link.set_op_code(0);
-                }
-            }
-            else
-            {
-                pucReceivedParams = received_data;
-                STREAM_TO_UINT8((uint8_t *)received_data, HCI_PACKET_ARGSIZE_OFFSET, argument_size);
-
-                STREAM_TO_UINT16((uint8_t *)received_data, HCI_PACKET_LENGTH_OFFSET, length);
-
-                // Data received: note that the only case where from and from length
-                // are not null is in recv from, so fill the args accordingly
-                if (from)
-                {
-                    STREAM_TO_UINT32((uint8_t *)(received_data + HCI_DATA_HEADER_SIZE), BSD_RECV_FROM_FROMLEN_OFFSET, *(uint32_t *)fromlen);
-                    memcpy(from, (received_data + HCI_DATA_HEADER_SIZE + BSD_RECV_FROM_FROM_OFFSET) ,*fromlen);
-                }
-
-                memcpy(ret_param, pucReceivedParams + HCI_DATA_HEADER_SIZE + argument_size, length - argument_size);
-
-                _simple_link.set_pending_data(0);
-            }
-
-            _simple_link.set_data_received_flag(0);
-
-            //tWlanInterruptEnable func_pointer = (tWlanInterruptEnable)_simple_link.get_func_pointer(WLAN_INTERRUPT_ENABLE);
-            //func_pointer();
-            _spi.wlan_irq_enable();
-
-            // Since we are going to TX - we need to handle this event after the ResumeSPi since we need interrupts
-            if ((*received_data == HCI_TYPE_EVNT) && (received_op_code == HCI_EVNT_PATCHES_REQ))
-            {
-                hci_unsol_handle_patch_request((uint8_t *)received_data);
-            }
-            if ((_simple_link.get_op_code() == 0) && (_simple_link.get_pending_data() == 0))
-            {
-                return NULL;
-            }
-        }
-    }
-}
-
-int32_t cc3000_event::hci_unsol_event_handler(uint8_t *event_hdr) {
-    uint8_t *data = NULL;
-    int32_t event_type;
-    uint32_t number_of_released_packets;
-    uint32_t number_of_sent_packets;
-
-    STREAM_TO_UINT16(event_hdr, HCI_EVENT_OPCODE_OFFSET,event_type);
-
-    if (event_type & HCI_EVNT_UNSOL_BASE) {
-        switch(event_type) {
-            case HCI_EVNT_DATA_UNSOL_FREE_BUFF:
-            {
-                hci_event_unsol_flowcontrol_handler(event_hdr);
-
-                number_of_released_packets = _simple_link.get_released_packets();
-                number_of_sent_packets = _simple_link.get_sent_packets();
-
-                if (number_of_released_packets == number_of_sent_packets)
-                {
-                    if (_simple_link.get_tx_complete_signal())
-                    {
-                        //tWlanCB func_pointer = (tWlanCB)_simple_link.get_func_pointer(WLAN_CB);
-                        _cc3000.usync_callback(HCI_EVENT_CC3000_CAN_SHUT_DOWN, NULL, 0);
-                    }
-                }
-                return 1;
-            }
-        }
-    }
-
-    if (event_type & HCI_EVNT_WLAN_UNSOL_BASE) {
-        switch(event_type) {
-            case HCI_EVNT_WLAN_KEEPALIVE:
-            case HCI_EVNT_WLAN_UNSOL_CONNECT:
-            case HCI_EVNT_WLAN_UNSOL_DISCONNECT:
-            case HCI_EVNT_WLAN_UNSOL_INIT:
-            case HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE:
-            // {
-                // tWlanCB func_pointer = (tWlanCB)_simple_link.get_func_pointer(WLAN_CB);
-                // if( func_pointer )
-                // {
-                //     func_pointer(event_type, 0, 0);
-                // }
-                _cc3000.usync_callback(event_type, 0, 0);
-                break;
-            // }
-            case HCI_EVNT_WLAN_UNSOL_DHCP:
-            {
-                uint8_t params[NETAPP_IPCONFIG_MAC_OFFSET + 1]; // extra byte is for the status
-                uint8_t *recParams = params;
-                data = (uint8_t *)(event_hdr) + HCI_EVENT_HEADER_SIZE;
-
-                //Read IP address
-                STREAM_TO_STREAM(data,recParams,NETAPP_IPCONFIG_IP_LENGTH);
-                data += 4;
-                //Read subnet
-                STREAM_TO_STREAM(data,recParams,NETAPP_IPCONFIG_IP_LENGTH);
-                data += 4;
-                //Read default GW
-                STREAM_TO_STREAM(data,recParams,NETAPP_IPCONFIG_IP_LENGTH);
-                data += 4;
-                //Read DHCP server
-                STREAM_TO_STREAM(data,recParams,NETAPP_IPCONFIG_IP_LENGTH);
-                data += 4;
-                //Read DNS server
-                STREAM_TO_STREAM(data,recParams,NETAPP_IPCONFIG_IP_LENGTH);
-                // read the status
-                STREAM_TO_UINT8(event_hdr, HCI_EVENT_STATUS_OFFSET, *recParams);
-
-                // tWlanCB func_pointer = (tWlanCB)_simple_link.get_func_pointer(WLAN_CB);
-                // if( func_pointer )
-                // {
-                    _cc3000.usync_callback(event_type, (uint8_t  *)params, sizeof(params));
-                // }
-                break;
-            }
-            case HCI_EVNT_WLAN_ASYNC_PING_REPORT:
-            {
-                netapp_pingreport_args_t params;
-                data = (uint8_t *)(event_hdr) + HCI_EVENT_HEADER_SIZE;
-                STREAM_TO_UINT32(data, NETAPP_PING_PACKETS_SENT_OFFSET, params.packets_sent);
-                STREAM_TO_UINT32(data, NETAPP_PING_PACKETS_RCVD_OFFSET, params.packets_received);
-                STREAM_TO_UINT32(data, NETAPP_PING_MIN_RTT_OFFSET, params.min_round_time);
-                STREAM_TO_UINT32(data, NETAPP_PING_MAX_RTT_OFFSET, params.max_round_time);
-                STREAM_TO_UINT32(data, NETAPP_PING_AVG_RTT_OFFSET, params.avg_round_time);
-
-                // tWlanCB func_pointer = (tWlanCB)_simple_link.get_func_pointer(WLAN_CB);
-                // if (func_pointer)
-                // {
-                    _cc3000.usync_callback(event_type, (uint8_t  *)&params, sizeof(params));
-                // }
-                break;
-            }
-            case HCI_EVNT_BSD_TCP_CLOSE_WAIT:
-            {
-                // tWlanCB func_pointer = (tWlanCB)_simple_link.get_func_pointer(WLAN_CB);
-                // if (func_pointer)
-                // {
-                    _cc3000.usync_callback(event_type, NULL, 0);
-                // }
-                break;
-            }
-
-            //'default' case which means "event not supported"
-            default:
-                return (0);
-        }
-        return(1);
-    }
-
-    if ((event_type == HCI_EVNT_SEND) || (event_type == HCI_EVNT_SENDTO) || (event_type == HCI_EVNT_WRITE)) {
-        uint8_t *pArg;
-        int32_t status;
-        pArg = M_BSD_RESP_PARAMS_OFFSET(event_hdr);
-        STREAM_TO_UINT32(pArg, BSD_RSP_PARAMS_STATUS_OFFSET,status);
-        if (ERROR_SOCKET_INACTIVE == status) {
-            // The only synchronous event that can come from SL device in form of
-            // command complete is "Command Complete" on data sent, in case SL device
-            // was unable to transmit
-            int32_t transmit_error  = _simple_link.get_transmit_error();
-            STREAM_TO_UINT8(event_hdr, HCI_EVENT_STATUS_OFFSET, transmit_error);
-            _simple_link.set_transmit_error(transmit_error);
-            update_socket_active_status(M_BSD_RESP_PARAMS_OFFSET(event_hdr));
-            return (1);
-        }
-        else {
-            return (0);
-        }
-    }
-    return(0);
-}
-
-int32_t cc3000_event::hci_unsolicited_event_handler(void) {
-    uint32_t res = 0;
-    uint8_t *received_data;
-
-    if (_simple_link.get_data_received_flag() != 0) {
-        received_data = (_simple_link.get_received_data());
-
-        if (*received_data == HCI_TYPE_EVNT) {
-            // unsolicited event received - finish handling
-            if (hci_unsol_event_handler((uint8_t *)received_data) == 1) {
-                // An unsolicited event was received:
-                // release the buffer and clean the event received
-                _simple_link.set_data_received_flag(0);
-
-                res = 1;
-                _spi.wlan_irq_enable();
-            }
-        }
-    }
-    return res;
-}
-
-void cc3000_event::set_socket_active_status(int32_t sd, int32_t status) {
-    if (M_IS_VALID_SD(sd) && M_IS_VALID_STATUS(status))
-    {
-        socket_active_status &= ~(1 << sd);      /* clean socket's mask */
-        socket_active_status |= (status << sd); /* set new socket's mask */
-    }
-}
-
-int32_t cc3000_event::hci_event_unsol_flowcontrol_handler(uint8_t *event) {
-    int32_t temp, value;
-    uint16_t i;
-    uint16_t pusNumberOfHandles=0;
-    uint8_t *pReadPayload;
-
-    STREAM_TO_UINT16((uint8_t *)event,HCI_EVENT_HEADER_SIZE,pusNumberOfHandles);
-    pReadPayload = ((uint8_t *)event + HCI_EVENT_HEADER_SIZE + sizeof(pusNumberOfHandles));
-    temp = 0;
-
-    for(i = 0; i < pusNumberOfHandles; i++) {
-        STREAM_TO_UINT16(pReadPayload, FLOW_CONTROL_EVENT_FREE_BUFFS_OFFSET, value);
-        temp += value;
-        pReadPayload += FLOW_CONTROL_EVENT_SIZE;
-    }
-
-    _simple_link.set_number_free_buffers(_simple_link.get_number_free_buffers() + temp);
-    _simple_link.set_number_of_released_packets(_simple_link.get_released_packets() + temp);
-
-    return(ESUCCESS);
-}
-
-int32_t cc3000_event::get_socket_active_status(int32_t sd) {
-    if(M_IS_VALID_SD(sd)) {
-        return (socket_active_status & (1 << sd)) ? SOCKET_STATUS_INACTIVE : SOCKET_STATUS_ACTIVE;
-    } else {
-        return SOCKET_STATUS_INACTIVE;
-    }
-}
-
-void cc3000_event::update_socket_active_status(uint8_t *resp_params) {
-    int32_t status, sd;
-
-    STREAM_TO_UINT32(resp_params, BSD_RSP_PARAMS_SOCKET_OFFSET,sd);
-    STREAM_TO_UINT32(resp_params, BSD_RSP_PARAMS_STATUS_OFFSET,status);
-
-    if(ERROR_SOCKET_INACTIVE == status) {
-        set_socket_active_status(sd, SOCKET_STATUS_INACTIVE);
-    }
-}
-
-void cc3000_event::simplelink_wait_event(uint16_t op_code, void *ret_param) {
-    // In the blocking implementation the control to caller will be returned only
-    // after the end of current transaction
-    _simple_link.set_op_code(op_code);
-    hci_event_handler(ret_param, 0, 0);
-}
-
-void cc3000_event::simplelink_wait_data(uint8_t *pBuf, uint8_t *from, uint8_t *fromlen) {
-    // In the blocking implementation the control to caller will be returned only
-    // after the end of current transaction, i.e. only after data will be received
-    _simple_link.set_pending_data(1);
-    hci_event_handler(pBuf, from, fromlen);
-}
-
-
-} /* end of cc3000 namespace */
--- a/cc3000_hostdriver_mbedsocket/cc3000_event.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_EVENT_H
-#define CC3000_EVENT_H
-
-typedef struct _bsd_read_return_t
-{
-    int32_t             iSocketDescriptor;
-    int32_t             iNumberOfBytes;
-    uint32_t    uiFlags;
-} tBsdReadReturnParams;
-
-typedef struct _bsd_getsockopt_return_t
-{
-    uint8_t ucOptValue[4];
-    uint8_t          iStatus;
-} tBsdGetSockOptReturnParams;
-
-typedef struct _bsd_accept_return_t
-{
-    int32_t             iSocketDescriptor;
-    int32_t             iStatus;
-    sockaddr         tSocketAddress;
-
-} tBsdReturnParams;
-
-typedef struct _bsd_select_return_t
-{
-    int32_t            iStatus;
-    uint32_t           uiRdfd;
-    uint32_t           uiWrfd;
-    uint32_t           uiExfd;
-} tBsdSelectRecvParams;
-
-typedef struct _bsd_gethostbyname_return_t
-{
-    int32_t  retVal;
-    int32_t  outputAddress;
-} tBsdGethostbynameParams;
-
-#define FLOW_CONTROL_EVENT_HANDLE_OFFSET        (0)
-#define FLOW_CONTROL_EVENT_BLOCK_MODE_OFFSET    (1)
-#define FLOW_CONTROL_EVENT_FREE_BUFFS_OFFSET    (2)
-#define FLOW_CONTROL_EVENT_SIZE                 (4)
-
-#define BSD_RSP_PARAMS_SOCKET_OFFSET            (0)
-#define BSD_RSP_PARAMS_STATUS_OFFSET            (4)
-
-#define GET_HOST_BY_NAME_RETVAL_OFFSET          (0)
-#define GET_HOST_BY_NAME_ADDR_OFFSET            (4)
-
-#define ACCEPT_SD_OFFSET                        (0)
-#define ACCEPT_RETURN_STATUS_OFFSET             (4)
-#define ACCEPT_ADDRESS__OFFSET                  (8)
-
-#define SL_RECEIVE_SD_OFFSET                    (0)
-#define SL_RECEIVE_NUM_BYTES_OFFSET             (4)
-#define SL_RECEIVE__FLAGS__OFFSET               (8)
-
-
-#define SELECT_STATUS_OFFSET                    (0)
-#define SELECT_READFD_OFFSET                    (4)
-#define SELECT_WRITEFD_OFFSET                   (8)
-#define SELECT_EXFD_OFFSET                      (12)
-
-
-#define NETAPP_IPCONFIG_IP_OFFSET               (0)
-#define NETAPP_IPCONFIG_SUBNET_OFFSET           (4)
-#define NETAPP_IPCONFIG_GW_OFFSET               (8)
-#define NETAPP_IPCONFIG_DHCP_OFFSET             (12)
-#define NETAPP_IPCONFIG_DNS_OFFSET              (16)
-#define NETAPP_IPCONFIG_MAC_OFFSET              (20)
-#define NETAPP_IPCONFIG_SSID_OFFSET             (26)
-
-#define NETAPP_IPCONFIG_IP_LENGTH               (4)
-#define NETAPP_IPCONFIG_MAC_LENGTH              (6)
-#define NETAPP_IPCONFIG_SSID_LENGTH             (32)
-
-
-#define NETAPP_PING_PACKETS_SENT_OFFSET         (0)
-#define NETAPP_PING_PACKETS_RCVD_OFFSET         (4)
-#define NETAPP_PING_MIN_RTT_OFFSET              (8)
-#define NETAPP_PING_MAX_RTT_OFFSET              (12)
-#define NETAPP_PING_AVG_RTT_OFFSET              (16)
-
-#define GET_SCAN_RESULTS_TABlE_COUNT_OFFSET              (0)
-#define GET_SCAN_RESULTS_SCANRESULT_STATUS_OFFSET        (4)
-#define GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET       (8)
-#define GET_SCAN_RESULTS_FRAME_TIME_OFFSET               (10)
-#define GET_SCAN_RESULTS_SSID_MAC_LENGTH                 (38)
-
-#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)((uint8_t *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
-
-#define SOCKET_STATUS_ACTIVE       0
-#define SOCKET_STATUS_INACTIVE     1
-/* Init socket_active_status = 'all ones': init all sockets with SOCKET_STATUS_INACTIVE.
-   Will be changed by 'set_socket_active_status' upon 'connect' and 'accept' calls */
-#define SOCKET_STATUS_INIT_VAL  0xFFFF
-#define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7))
-#define M_IS_VALID_STATUS(status) (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
-
-#define BSD_RECV_FROM_FROMLEN_OFFSET    (4)
-#define BSD_RECV_FROM_FROM_OFFSET       (16)
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_hci.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-
-namespace mbed_cc3000 {
-
-cc3000_hci::cc3000_hci(cc3000_spi &spi) : _spi(spi) {
-
-}
-
-cc3000_hci::~cc3000_hci() {
-
-}
-
-uint16_t  cc3000_hci::command_send(uint16_t op_code, uint8_t *buffer, uint8_t length) {
-    unsigned char *stream;
-    
-    DBG_HCI_CMD("Command Sent : 0x%04X", op_code);
-
-    stream = (buffer + SPI_HEADER_SIZE);
-
-    UINT8_TO_STREAM(stream, HCI_TYPE_CMND);
-    stream = UINT16_TO_STREAM(stream, op_code);
-    UINT8_TO_STREAM(stream, length);
-    //Update the opcode of the event we will be waiting for
-    _spi.write(buffer, length + SIMPLE_LINK_HCI_CMND_HEADER_SIZE);
-    return(0);
-}
-
-uint32_t  cc3000_hci::data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length,
-                    uint16_t data_length, const uint8_t *tail, uint16_t tail_length) {
-    unsigned char *stream;
-
-    stream = ((args) + SPI_HEADER_SIZE);
-
-    UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
-    UINT8_TO_STREAM(stream, op_code);
-    UINT8_TO_STREAM(stream, arg_length);
-    stream = UINT16_TO_STREAM(stream, arg_length + data_length + tail_length);
-
-    // Send the packet
-    _spi.write(args, SIMPLE_LINK_HCI_DATA_HEADER_SIZE + arg_length + data_length + tail_length);
-
-    return 0;
-}
-
-void  cc3000_hci::data_command_send(uint16_t op_code, uint8_t *buffer, uint8_t arg_length, uint16_t data_length) {
-     unsigned char *stream = (buffer + SPI_HEADER_SIZE);
-
-    UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
-    UINT8_TO_STREAM(stream, op_code);
-    UINT8_TO_STREAM(stream, arg_length);
-    stream = UINT16_TO_STREAM(stream, arg_length + data_length);
-
-    // Send the command
-    _spi.write(buffer, arg_length + data_length + SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE);
-
-    return;
-}
-
-void  cc3000_hci::patch_send(uint8_t op_code, uint8_t *buffer, uint8_t *patch, uint16_t data_length) {
-    unsigned short usTransLength;
-    unsigned char *stream = (buffer + SPI_HEADER_SIZE);
-    UINT8_TO_STREAM(stream, HCI_TYPE_PATCH);
-    UINT8_TO_STREAM(stream, op_code);
-    stream = UINT16_TO_STREAM(stream, data_length + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE);
-    if (data_length <= SL_PATCH_PORTION_SIZE)
-    {
-        UINT16_TO_STREAM(stream, data_length);
-        stream = UINT16_TO_STREAM(stream, data_length);
-        memcpy((buffer + SPI_HEADER_SIZE) + HCI_PATCH_HEADER_SIZE, patch, data_length);
-        // Update the opcode of the event we will be waiting for
-        _spi.write(buffer, data_length + HCI_PATCH_HEADER_SIZE);
-    }
-    else
-    {
-
-        usTransLength = (data_length/SL_PATCH_PORTION_SIZE);
-        UINT16_TO_STREAM(stream, data_length + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE + usTransLength*SIMPLE_LINK_HCI_PATCH_HEADER_SIZE);
-        stream = UINT16_TO_STREAM(stream, SL_PATCH_PORTION_SIZE);
-        memcpy(buffer + SPI_HEADER_SIZE + HCI_PATCH_HEADER_SIZE, patch, SL_PATCH_PORTION_SIZE);
-        data_length -= SL_PATCH_PORTION_SIZE;
-        patch += SL_PATCH_PORTION_SIZE;
-
-        // Update the opcode of the event we will be waiting for
-        _spi.write(buffer, SL_PATCH_PORTION_SIZE + HCI_PATCH_HEADER_SIZE);
-
-        stream = (buffer + SPI_HEADER_SIZE);
-        while (data_length)
-        {
-            if (data_length <= SL_PATCH_PORTION_SIZE)
-            {
-                usTransLength = data_length;
-                data_length = 0;
-
-            }
-            else
-            {
-                usTransLength = SL_PATCH_PORTION_SIZE;
-                data_length -= usTransLength;
-            }
-
-            *(unsigned short *)stream = usTransLength;
-            memcpy(stream + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch, usTransLength);
-            patch += usTransLength;
-
-            // Update the opcode of the event we will be waiting for
-            _spi.write((unsigned char *)stream, usTransLength + sizeof(usTransLength));
-        }
-    }
-}
-
-}
--- a/cc3000_hostdriver_mbedsocket/cc3000_netapp.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,199 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_netapp.h"
-
-namespace mbed_cc3000 {
-
-cc3000_netapp::cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci , cc3000_event &event) :
-    _simple_link(simple_link), _nvmem(nvmem), _hci(hci), _event(event) {
-
-}
-
-cc3000_netapp::~cc3000_netapp() {
-
-}
-
-int32_t cc3000_netapp::config_mac_adrress(uint8_t * mac) {
-    return  _nvmem.set_mac_address(mac);
-}
-
-int32_t cc3000_netapp::dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server) {
-    int8_t scRet;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    scRet = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    ARRAY_TO_STREAM(args,ip,4);
-    ARRAY_TO_STREAM(args,subnet_mask,4);
-    ARRAY_TO_STREAM(args,default_gateway,4);
-    args = UINT32_TO_STREAM(args, 0);
-    ARRAY_TO_STREAM(args,dns_server,4);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_DHCP, &scRet);
-
-    return(scRet);
-}
-
-#ifndef CC3000_TINY_DRIVER
-void cc3000_netapp::ipconfig( tNetappIpconfigRetArgs * ipconfig ) {
-    uint8_t *ptr;
-
-    ptr = _simple_link.get_transmit_buffer();
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_IPCONFIG, ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_IPCONFIG, ipconfig );
-}
-
-
-int32_t cc3000_netapp::timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity) {
-    int8_t scRet;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    scRet = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Set minimal values of timers
-    MIN_TIMER_SET(*dhcp)
-    MIN_TIMER_SET(*arp)
-    MIN_TIMER_SET(*keep_alive)
-    MIN_TIMER_SET(*inactivity)
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, *dhcp);
-    args = UINT32_TO_STREAM(args, *arp);
-    args = UINT32_TO_STREAM(args, *keep_alive);
-    args = UINT32_TO_STREAM(args, *inactivity);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_SET_TIMERS, &scRet);
-
-    return(scRet);
-}
-
-int32_t cc3000_netapp::ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout) {
-    int8_t scRet;
-    uint8_t *ptr, *args;
-
-    scRet = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, *ip);
-    args = UINT32_TO_STREAM(args, ping_attempts);
-    args = UINT32_TO_STREAM(args, ping_size);
-    args = UINT32_TO_STREAM(args, ping_timeout);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_PING_SEND, ptr, NETAPP_PING_SEND_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_PING_SEND, &scRet);
-
-    return(scRet);
-}
-
-void cc3000_netapp::ping_report() {
-    uint8_t *ptr;
-    int8_t scRet;
-    ptr = _simple_link.get_transmit_buffer();
-
-
-    scRet = EFAIL;
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_PING_REPORT, ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_PING_REPORT, &scRet);
-}
-
-int32_t cc3000_netapp::ping_stop() {
-    int8_t scRet;
-    uint8_t *ptr;
-
-    scRet = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_PING_STOP, ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_PING_STOP, &scRet);
-
-    return(scRet);
-}
-
-int32_t cc3000_netapp::arp_flush() {
-    int8_t scRet;
-    uint8_t *ptr;
-
-    scRet = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_NETAPP_ARP_FLUSH, ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_NETAPP_ARP_FLUSH, &scRet);
-
-    return(scRet);
-}
-#endif
-
-} /* end of cc3000 namespace */
--- a/cc3000_hostdriver_mbedsocket/cc3000_netapp.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_NETAPP_H
-#define CC3000_NETAPP_H
-
-#define MIN_TIMER_VAL_SECONDS      20
-#define MIN_TIMER_SET(t)    if ((0 != t) && (t < MIN_TIMER_VAL_SECONDS)) \
-                            { \
-                                t = MIN_TIMER_VAL_SECONDS; \
-                            }
-
-
-#define NETAPP_DHCP_PARAMS_LEN                 (20)
-#define NETAPP_SET_TIMER_PARAMS_LEN            (20)
-#define NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN      (4)
-#define NETAPP_PING_SEND_PARAMS_LEN            (16)
-
-
-typedef struct _netapp_dhcp_ret_args_t
-{
-    uint8_t aucIP[4];
-    uint8_t aucSubnetMask[4];
-    uint8_t aucDefaultGateway[4];
-    uint8_t aucDHCPServer[4];
-    uint8_t aucDNSServer[4];
-}tNetappDhcpParams;
-
-typedef struct _netapp_ipconfig_ret_args_t
-{
-    uint8_t aucIP[4];
-    uint8_t aucSubnetMask[4];
-    uint8_t aucDefaultGateway[4];
-    uint8_t aucDHCPServer[4];
-    uint8_t aucDNSServer[4];
-    uint8_t uaMacAddr[6];
-    uint8_t uaSSID[32];
-}tNetappIpconfigRetArgs;
-
-
-/*Ping send report parameters*/
-typedef struct _netapp_pingreport_args
-{
-    uint32_t packets_sent;
-    uint32_t packets_received;
-    uint32_t min_round_time;
-    uint32_t max_round_time;
-    uint32_t avg_round_time;
-} netapp_pingreport_args_t;
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_nvmem.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_nvmem.h"
-#include "cc3000_common.h"
-
-namespace mbed_cc3000 {
-
-cc3000_nvmem::cc3000_nvmem(cc3000_hci &hci, cc3000_event &event, cc3000_simple_link &simple_link)
-        : _hci(hci), _event(event), _simple_link(simple_link) {
-
-}
-
-cc3000_nvmem::~cc3000_nvmem() {
-
-}
-
-int32_t  cc3000_nvmem::read(uint32_t file_id, uint32_t length, uint32_t offset, uint8_t *buff) {
-    uint8_t ucStatus = 0xFF;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, file_id);
-    args = UINT32_TO_STREAM(args, length);
-    args = UINT32_TO_STREAM(args, offset);
-
-    // Initiate HCI command
-    _hci.command_send(HCI_CMND_NVMEM_READ, ptr, NVMEM_READ_PARAMS_LEN);
-    _event.simplelink_wait_event(HCI_CMND_NVMEM_READ, &ucStatus);
-
-    // If data is present, read it even when an error is returned.
-    // Note: It is the users responsibility to ignore the data when an error is returned.
-    // Wait for the data in a synchronous way.
-    //  We assume the buffer is large enough to also store nvmem parameters.
-    _event.simplelink_wait_data(buff, 0, 0);
-
-    return(ucStatus);
-}
-
-int32_t  cc3000_nvmem::write(uint32_t file_id, uint32_t length, uint32_t entry_offset, uint8_t *buff) {
-    int32_t iRes;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    iRes = EFAIL;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, file_id);
-    args = UINT32_TO_STREAM(args, 12);
-    args = UINT32_TO_STREAM(args, length);
-    args = UINT32_TO_STREAM(args, entry_offset);
-
-    memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE +
-                    NVMEM_WRITE_PARAMS_LEN),buff,length);
-
-    // Initiate a HCI command on the data channel
-    _hci.data_command_send(HCI_CMND_NVMEM_WRITE, ptr, NVMEM_WRITE_PARAMS_LEN, length);
-
-    _event.simplelink_wait_event(HCI_EVNT_NVMEM_WRITE, &iRes);
-
-    return(iRes);
-}
-
-uint8_t  cc3000_nvmem::set_mac_address(uint8_t *mac) {
-    return  write(NVMEM_MAC_FILEID, MAC_ADDR_LEN, 0, mac);
-}
-
-uint8_t  cc3000_nvmem::get_mac_address(uint8_t *mac) {
-    return  read(NVMEM_MAC_FILEID, MAC_ADDR_LEN, 0, mac);
-}
-
-uint8_t  cc3000_nvmem::write_patch(uint32_t file_id, uint32_t length, const uint8_t *data) {
-    uint8_t     status = 0;
-    uint16_t    offset = 0;
-    uint8_t*      spDataPtr = (uint8_t*)data;
-
-    while ((status == 0) && (length >= SP_PORTION_SIZE))
-    {
-        status = write(file_id, SP_PORTION_SIZE, offset, spDataPtr);
-        offset += SP_PORTION_SIZE;
-        length -= SP_PORTION_SIZE;
-        spDataPtr += SP_PORTION_SIZE;
-    }
-
-    if (status !=0)
-    {
-        // NVMEM error occurred
-        return status;
-    }
-
-    if (length != 0)
-    {
-        // If length MOD 512 is nonzero, write the remaining bytes.
-        status = write(file_id, length, offset, spDataPtr);
-    }
-
-    return status;
-}
-
-int32_t  cc3000_nvmem::create_entry(uint32_t file_id, uint32_t new_len) {
-    uint8_t *ptr;
-    uint8_t *args;
-    uint16_t retval;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, file_id);
-    args = UINT32_TO_STREAM(args, new_len);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_NVMEM_CREATE_ENTRY,ptr, NVMEM_CREATE_PARAMS_LEN);
-
-    _event.simplelink_wait_event(HCI_CMND_NVMEM_CREATE_ENTRY, &retval);
-
-    return(retval);
-}
-
-#ifndef CC3000_TINY_DRIVER
-uint8_t  cc3000_nvmem::read_sp_version(uint8_t* patch_ver) {
-    uint8_t *ptr;
-    // 1st byte is the status and the rest is the SP version
-    uint8_t retBuf[5];
-
-    ptr = _simple_link.get_transmit_buffer();
-
-   // Initiate a HCI command, no args are required
-    _hci.command_send(HCI_CMND_READ_SP_VERSION, ptr, 0);
-    _event.simplelink_wait_event(HCI_CMND_READ_SP_VERSION, retBuf);
-
-    // package ID
-    *patch_ver = retBuf[3];
-    // package build number
-    *(patch_ver+1) = retBuf[4];
-
-    return(retBuf[0]);
-}
-
-#endif
-
-}
--- a/cc3000_hostdriver_mbedsocket/cc3000_nvmem.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_NVMEM_H
-#define CC3000_NVMEM_H
-
-#define NVMEM_READ_PARAMS_LEN       (12)
-#define NVMEM_CREATE_PARAMS_LEN     (8)
-#define NVMEM_WRITE_PARAMS_LEN      (16)
-
-
-/****************************************************************************
-**
-**    Definitions for File IDs
-**
-****************************************************************************/
-/* --------------------------------------------------------- EEPROM FAT table ---------------------------------------------------------
-
- File ID                            Offset      File Size   Used Size   Parameter
- #  ID                              address     (bytes)     (bytes)
- --------------------------------------------------------------------------------------------------------------------------------------
- 0  NVMEM_NVS_FILEID                0x50        0x1A0       0x1A        RF Calibration results table(generated automatically by TX Bip)
- 1  NVMEM_NVS_SHADOW_FILEID         0x1F0       0x1A0       0x1A        NVS Shadow
- 2  NVMEM_WLAN_CONFIG_FILEID        0x390       0x1000      0x64        WLAN configuration
- 3  NVMEM_WLAN_CONFIG_SHADOW_FILEID 0x1390      0x1000      0x64        WLAN configuration shadow
- 4  NVMEM_WLAN_DRIVER_SP_FILEID     0x2390      0x2000      variable    WLAN Driver ROM Patches
- 5  NVMEM_WLAN_FW_SP_FILEID         0x4390      0x2000      variable    WLAN FW Patches
- 6  NVMEM_MAC_FILEID                0x6390      0x10        0x10        6 bytes of MAC address
- 7  NVMEM_FRONTEND_VARS_FILEID      0x63A0      0x10        0x10        Frontend Vars
- 8  NVMEM_IP_CONFIG_FILEID          0x63B0      0x40        0x40        IP configuration
- 9  NVMEM_IP_CONFIG_SHADOW_FILEID   0x63F0      0x40        0x40        IP configuration shadow
-10  NVMEM_BOOTLOADER_SP_FILEID      0x6430      0x400       variable    Bootloader Patches
-11  NVMEM_RM_FILEID                 0x6830      0x200       0x7F        Radio parameters
-12  NVMEM_AES128_KEY_FILEID         0x6A30      0x10        0x10        AES128 key file
-13  NVMEM_SHARED_MEM_FILEID         0x6A40      0x50        0x44        Host-CC3000 shared memory file
-14  NVMEM_USER_FILE_1_FILEID        0x6A90      variable    variable    1st user file
-15  NVMEM_USER_FILE_2_FILEID        variable    variable    variable    2nd user file
-*/
-/* NVMEM file ID - system files*/
-#define NVMEM_NVS_FILEID                             (0)
-#define NVMEM_NVS_SHADOW_FILEID                      (1)
-#define NVMEM_WLAN_CONFIG_FILEID                     (2)
-#define NVMEM_WLAN_CONFIG_SHADOW_FILEID              (3)
-#define NVMEM_WLAN_DRIVER_SP_FILEID                  (4)
-#define NVMEM_WLAN_FW_SP_FILEID                      (5)
-#define NVMEM_MAC_FILEID                             (6)
-#define NVMEM_FRONTEND_VARS_FILEID                   (7)
-#define NVMEM_IP_CONFIG_FILEID                       (8)
-#define NVMEM_IP_CONFIG_SHADOW_FILEID                (9)
-#define NVMEM_BOOTLOADER_SP_FILEID                   (10)
-#define NVMEM_RM_FILEID                              (11)
-
-/* NVMEM file ID - user files*/
-#define NVMEM_AES128_KEY_FILEID                      (12)
-#define NVMEM_SHARED_MEM_FILEID                      (13)
-#define NVMEM_USER_FILE_1_FILEID                     (14)
-#define NVMEM_USER_FILE_2_FILEID                     (15)
-
-/*  max entry in order to invalid nvmem              */
-#define NVMEM_MAX_ENTRY                              (16)
-
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_security.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,381 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-
-namespace mbed_cc3000 {
-
-#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
-
-// forward sbox
-static const uint8_t sbox[256] =   {
-//0     1    2      3     4    5     6     7      8    9     A      B    C     D     E     F
-0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0
-0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1
-0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, //2
-0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, //3
-0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, //4
-0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, //5
-0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, //6
-0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, //7
-0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, //8
-0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, //9
-0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, //A
-0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, //B
-0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C
-0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D
-0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E
-0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F
-// inverse sbox
-static const uint8_t rsbox[256] =
-{ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
-, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb
-, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e
-, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25
-, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92
-, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84
-, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06
-, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b
-, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73
-, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e
-, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b
-, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4
-, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f
-, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef
-, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61
-, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d };
-// round constant
-static const uint8_t Rcon[11] = {0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36};
-
-void cc3000_security::expandKey(uint8_t *expanded_key, uint8_t *key) {
-  uint16_t ii, buf1;
-  for (ii=0;ii<16;ii++)
-    expanded_key[ii] = key[ii];
-  for (ii=1;ii<11;ii++)
-  {
-    buf1 = expanded_key[ii*16 - 4];
-    expanded_key[ii*16 + 0] = sbox[expanded_key[ii*16 - 3]]^expanded_key[(ii-1)*16 + 0]^Rcon[ii];
-    expanded_key[ii*16 + 1] = sbox[expanded_key[ii*16 - 2]]^expanded_key[(ii-1)*16 + 1];
-    expanded_key[ii*16 + 2] = sbox[expanded_key[ii*16 - 1]]^expanded_key[(ii-1)*16 + 2];
-    expanded_key[ii*16 + 3] = sbox[buf1                  ]^expanded_key[(ii-1)*16 + 3];
-    expanded_key[ii*16 + 4] = expanded_key[(ii-1)*16 + 4]^expanded_key[ii*16 + 0];
-    expanded_key[ii*16 + 5] = expanded_key[(ii-1)*16 + 5]^expanded_key[ii*16 + 1];
-    expanded_key[ii*16 + 6] = expanded_key[(ii-1)*16 + 6]^expanded_key[ii*16 + 2];
-    expanded_key[ii*16 + 7] = expanded_key[(ii-1)*16 + 7]^expanded_key[ii*16 + 3];
-    expanded_key[ii*16 + 8] = expanded_key[(ii-1)*16 + 8]^expanded_key[ii*16 + 4];
-    expanded_key[ii*16 + 9] = expanded_key[(ii-1)*16 + 9]^expanded_key[ii*16 + 5];
-    expanded_key[ii*16 +10] = expanded_key[(ii-1)*16 +10]^expanded_key[ii*16 + 6];
-    expanded_key[ii*16 +11] = expanded_key[(ii-1)*16 +11]^expanded_key[ii*16 + 7];
-    expanded_key[ii*16 +12] = expanded_key[(ii-1)*16 +12]^expanded_key[ii*16 + 8];
-    expanded_key[ii*16 +13] = expanded_key[(ii-1)*16 +13]^expanded_key[ii*16 + 9];
-    expanded_key[ii*16 +14] = expanded_key[(ii-1)*16 +14]^expanded_key[ii*16 +10];
-    expanded_key[ii*16 +15] = expanded_key[(ii-1)*16 +15]^expanded_key[ii*16 +11];
-  }
-}
-
-uint8_t cc3000_security::galois_mul2(uint8_t value) {
-    if (value >> 7) {
-        value = value << 1;
-        return (value ^ 0x1b);
-    } else {
-        return (value << 1);
-    }
-}
-
-void cc3000_security::aes_encr(uint8_t *state, uint8_t *expanded_key) {
-  uint8_t buf1, buf2, buf3, round;
-
-  for (round = 0; round < 9; round ++)
-  {
-    // addroundkey, sbox and shiftrows
-    // row 0
-    state[ 0]  = sbox[(state[ 0] ^ expanded_key[(round*16)     ])];
-    state[ 4]  = sbox[(state[ 4] ^ expanded_key[(round*16) +  4])];
-    state[ 8]  = sbox[(state[ 8] ^ expanded_key[(round*16) +  8])];
-    state[12]  = sbox[(state[12] ^ expanded_key[(round*16) + 12])];
-    // row 1
-    buf1 = state[1] ^ expanded_key[(round*16) + 1];
-    state[ 1]  = sbox[(state[ 5] ^ expanded_key[(round*16) +  5])];
-    state[ 5]  = sbox[(state[ 9] ^ expanded_key[(round*16) +  9])];
-    state[ 9]  = sbox[(state[13] ^ expanded_key[(round*16) + 13])];
-    state[13]  = sbox[buf1];
-    // row 2
-    buf1 = state[2] ^ expanded_key[(round*16) + 2];
-    buf2 = state[6] ^ expanded_key[(round*16) + 6];
-    state[ 2]  = sbox[(state[10] ^ expanded_key[(round*16) + 10])];
-    state[ 6]  = sbox[(state[14] ^ expanded_key[(round*16) + 14])];
-    state[10]  = sbox[buf1];
-    state[14]  = sbox[buf2];
-    // row 3
-    buf1 = state[15] ^ expanded_key[(round*16) + 15];
-    state[15]  = sbox[(state[11] ^ expanded_key[(round*16) + 11])];
-    state[11]  = sbox[(state[ 7] ^ expanded_key[(round*16) +  7])];
-    state[ 7]  = sbox[(state[ 3] ^ expanded_key[(round*16) +  3])];
-    state[ 3]  = sbox[buf1];
-
-    // mixcolums //////////
-    // col1
-    buf1 = state[0] ^ state[1] ^ state[2] ^ state[3];
-    buf2 = state[0];
-    buf3 = state[0]^state[1]; buf3=galois_mul2(buf3); state[0] = state[0] ^ buf3 ^ buf1;
-    buf3 = state[1]^state[2]; buf3=galois_mul2(buf3); state[1] = state[1] ^ buf3 ^ buf1;
-    buf3 = state[2]^state[3]; buf3=galois_mul2(buf3); state[2] = state[2] ^ buf3 ^ buf1;
-    buf3 = state[3]^buf2;     buf3=galois_mul2(buf3); state[3] = state[3] ^ buf3 ^ buf1;
-    // col2
-    buf1 = state[4] ^ state[5] ^ state[6] ^ state[7];
-    buf2 = state[4];
-    buf3 = state[4]^state[5]; buf3=galois_mul2(buf3); state[4] = state[4] ^ buf3 ^ buf1;
-    buf3 = state[5]^state[6]; buf3=galois_mul2(buf3); state[5] = state[5] ^ buf3 ^ buf1;
-    buf3 = state[6]^state[7]; buf3=galois_mul2(buf3); state[6] = state[6] ^ buf3 ^ buf1;
-    buf3 = state[7]^buf2;     buf3=galois_mul2(buf3); state[7] = state[7] ^ buf3 ^ buf1;
-    // col3
-    buf1 = state[8] ^ state[9] ^ state[10] ^ state[11];
-    buf2 = state[8];
-    buf3 = state[8]^state[9];   buf3=galois_mul2(buf3); state[8] = state[8] ^ buf3 ^ buf1;
-    buf3 = state[9]^state[10];  buf3=galois_mul2(buf3); state[9] = state[9] ^ buf3 ^ buf1;
-    buf3 = state[10]^state[11]; buf3=galois_mul2(buf3); state[10] = state[10] ^ buf3 ^ buf1;
-    buf3 = state[11]^buf2;      buf3=galois_mul2(buf3); state[11] = state[11] ^ buf3 ^ buf1;
-    // col4
-    buf1 = state[12] ^ state[13] ^ state[14] ^ state[15];
-    buf2 = state[12];
-    buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;
-    buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;
-    buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;
-    buf3 = state[15]^buf2;      buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
-
-  }
-  // 10th round without mixcols
-  state[ 0]  = sbox[(state[ 0] ^ expanded_key[(round*16)     ])];
-  state[ 4]  = sbox[(state[ 4] ^ expanded_key[(round*16) +  4])];
-  state[ 8]  = sbox[(state[ 8] ^ expanded_key[(round*16) +  8])];
-  state[12]  = sbox[(state[12] ^ expanded_key[(round*16) + 12])];
-  // row 1
-  buf1 = state[1] ^ expanded_key[(round*16) + 1];
-  state[ 1]  = sbox[(state[ 5] ^ expanded_key[(round*16) +  5])];
-  state[ 5]  = sbox[(state[ 9] ^ expanded_key[(round*16) +  9])];
-  state[ 9]  = sbox[(state[13] ^ expanded_key[(round*16) + 13])];
-  state[13]  = sbox[buf1];
-  // row 2
-  buf1 = state[2] ^ expanded_key[(round*16) + 2];
-  buf2 = state[6] ^ expanded_key[(round*16) + 6];
-  state[ 2]  = sbox[(state[10] ^ expanded_key[(round*16) + 10])];
-  state[ 6]  = sbox[(state[14] ^ expanded_key[(round*16) + 14])];
-  state[10]  = sbox[buf1];
-  state[14]  = sbox[buf2];
-  // row 3
-  buf1 = state[15] ^ expanded_key[(round*16) + 15];
-  state[15]  = sbox[(state[11] ^ expanded_key[(round*16) + 11])];
-  state[11]  = sbox[(state[ 7] ^ expanded_key[(round*16) +  7])];
-  state[ 7]  = sbox[(state[ 3] ^ expanded_key[(round*16) +  3])];
-  state[ 3]  = sbox[buf1];
-  // last addroundkey
-  state[ 0]^=expanded_key[160];
-  state[ 1]^=expanded_key[161];
-  state[ 2]^=expanded_key[162];
-  state[ 3]^=expanded_key[163];
-  state[ 4]^=expanded_key[164];
-  state[ 5]^=expanded_key[165];
-  state[ 6]^=expanded_key[166];
-  state[ 7]^=expanded_key[167];
-  state[ 8]^=expanded_key[168];
-  state[ 9]^=expanded_key[169];
-  state[10]^=expanded_key[170];
-  state[11]^=expanded_key[171];
-  state[12]^=expanded_key[172];
-  state[13]^=expanded_key[173];
-  state[14]^=expanded_key[174];
-  state[15]^=expanded_key[175];
-}
-
-void cc3000_security::aes_decr(uint8_t *state, uint8_t *expanded_key) {
-  uint8_t buf1, buf2, buf3;
-  int8_t round;
-  round = 9;
-
-  // initial addroundkey
-  state[ 0]^=expanded_key[160];
-  state[ 1]^=expanded_key[161];
-  state[ 2]^=expanded_key[162];
-  state[ 3]^=expanded_key[163];
-  state[ 4]^=expanded_key[164];
-  state[ 5]^=expanded_key[165];
-  state[ 6]^=expanded_key[166];
-  state[ 7]^=expanded_key[167];
-  state[ 8]^=expanded_key[168];
-  state[ 9]^=expanded_key[169];
-  state[10]^=expanded_key[170];
-  state[11]^=expanded_key[171];
-  state[12]^=expanded_key[172];
-  state[13]^=expanded_key[173];
-  state[14]^=expanded_key[174];
-  state[15]^=expanded_key[175];
-
-  // 10th round without mixcols
-  state[ 0]  = rsbox[state[ 0]] ^ expanded_key[(round*16)     ];
-  state[ 4]  = rsbox[state[ 4]] ^ expanded_key[(round*16) +  4];
-  state[ 8]  = rsbox[state[ 8]] ^ expanded_key[(round*16) +  8];
-  state[12]  = rsbox[state[12]] ^ expanded_key[(round*16) + 12];
-  // row 1
-  buf1 =       rsbox[state[13]] ^ expanded_key[(round*16) +  1];
-  state[13]  = rsbox[state[ 9]] ^ expanded_key[(round*16) + 13];
-  state[ 9]  = rsbox[state[ 5]] ^ expanded_key[(round*16) +  9];
-  state[ 5]  = rsbox[state[ 1]] ^ expanded_key[(round*16) +  5];
-  state[ 1]  = buf1;
-  // row 2
-  buf1 =       rsbox[state[ 2]] ^ expanded_key[(round*16) + 10];
-  buf2 =       rsbox[state[ 6]] ^ expanded_key[(round*16) + 14];
-  state[ 2]  = rsbox[state[10]] ^ expanded_key[(round*16) +  2];
-  state[ 6]  = rsbox[state[14]] ^ expanded_key[(round*16) +  6];
-  state[10]  = buf1;
-  state[14]  = buf2;
-  // row 3
-  buf1 =       rsbox[state[ 3]] ^ expanded_key[(round*16) + 15];
-  state[ 3]  = rsbox[state[ 7]] ^ expanded_key[(round*16) +  3];
-  state[ 7]  = rsbox[state[11]] ^ expanded_key[(round*16) +  7];
-  state[11]  = rsbox[state[15]] ^ expanded_key[(round*16) + 11];
-  state[15]  = buf1;
-
-  for (round = 8; round >= 0; round--)
-  {
-    // barreto
-    //col1
-    buf1 = galois_mul2(galois_mul2(state[0]^state[2]));
-    buf2 = galois_mul2(galois_mul2(state[1]^state[3]));
-    state[0] ^= buf1;     state[1] ^= buf2;    state[2] ^= buf1;    state[3] ^= buf2;
-    //col2
-    buf1 = galois_mul2(galois_mul2(state[4]^state[6]));
-    buf2 = galois_mul2(galois_mul2(state[5]^state[7]));
-    state[4] ^= buf1;    state[5] ^= buf2;    state[6] ^= buf1;    state[7] ^= buf2;
-    //col3
-    buf1 = galois_mul2(galois_mul2(state[8]^state[10]));
-    buf2 = galois_mul2(galois_mul2(state[9]^state[11]));
-    state[8] ^= buf1;    state[9] ^= buf2;    state[10] ^= buf1;    state[11] ^= buf2;
-    //col4
-    buf1 = galois_mul2(galois_mul2(state[12]^state[14]));
-    buf2 = galois_mul2(galois_mul2(state[13]^state[15]));
-    state[12] ^= buf1;    state[13] ^= buf2;    state[14] ^= buf1;    state[15] ^= buf2;
-    // mixcolums //////////
-    // col1
-    buf1 = state[0] ^ state[1] ^ state[2] ^ state[3];
-    buf2 = state[0];
-    buf3 = state[0]^state[1]; buf3=galois_mul2(buf3); state[0] = state[0] ^ buf3 ^ buf1;
-    buf3 = state[1]^state[2]; buf3=galois_mul2(buf3); state[1] = state[1] ^ buf3 ^ buf1;
-    buf3 = state[2]^state[3]; buf3=galois_mul2(buf3); state[2] = state[2] ^ buf3 ^ buf1;
-    buf3 = state[3]^buf2;     buf3=galois_mul2(buf3); state[3] = state[3] ^ buf3 ^ buf1;
-    // col2
-    buf1 = state[4] ^ state[5] ^ state[6] ^ state[7];
-    buf2 = state[4];
-    buf3 = state[4]^state[5]; buf3=galois_mul2(buf3); state[4] = state[4] ^ buf3 ^ buf1;
-    buf3 = state[5]^state[6]; buf3=galois_mul2(buf3); state[5] = state[5] ^ buf3 ^ buf1;
-    buf3 = state[6]^state[7]; buf3=galois_mul2(buf3); state[6] = state[6] ^ buf3 ^ buf1;
-    buf3 = state[7]^buf2;     buf3=galois_mul2(buf3); state[7] = state[7] ^ buf3 ^ buf1;
-    // col3
-    buf1 = state[8] ^ state[9] ^ state[10] ^ state[11];
-    buf2 = state[8];
-    buf3 = state[8]^state[9];   buf3=galois_mul2(buf3); state[8] = state[8] ^ buf3 ^ buf1;
-    buf3 = state[9]^state[10];  buf3=galois_mul2(buf3); state[9] = state[9] ^ buf3 ^ buf1;
-    buf3 = state[10]^state[11]; buf3=galois_mul2(buf3); state[10] = state[10] ^ buf3 ^ buf1;
-    buf3 = state[11]^buf2;      buf3=galois_mul2(buf3); state[11] = state[11] ^ buf3 ^ buf1;
-    // col4
-    buf1 = state[12] ^ state[13] ^ state[14] ^ state[15];
-    buf2 = state[12];
-    buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;
-    buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;
-    buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;
-    buf3 = state[15]^buf2;      buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
-
-    // addroundkey, rsbox and shiftrows
-    // row 0
-    state[ 0]  = rsbox[state[ 0]] ^ expanded_key[(round*16)     ];
-    state[ 4]  = rsbox[state[ 4]] ^ expanded_key[(round*16) +  4];
-    state[ 8]  = rsbox[state[ 8]] ^ expanded_key[(round*16) +  8];
-    state[12]  = rsbox[state[12]] ^ expanded_key[(round*16) + 12];
-    // row 1
-    buf1 =       rsbox[state[13]] ^ expanded_key[(round*16) +  1];
-    state[13]  = rsbox[state[ 9]] ^ expanded_key[(round*16) + 13];
-    state[ 9]  = rsbox[state[ 5]] ^ expanded_key[(round*16) +  9];
-    state[ 5]  = rsbox[state[ 1]] ^ expanded_key[(round*16) +  5];
-    state[ 1]  = buf1;
-    // row 2
-    buf1 =       rsbox[state[ 2]] ^ expanded_key[(round*16) + 10];
-    buf2 =       rsbox[state[ 6]] ^ expanded_key[(round*16) + 14];
-    state[ 2]  = rsbox[state[10]] ^ expanded_key[(round*16) +  2];
-    state[ 6]  = rsbox[state[14]] ^ expanded_key[(round*16) +  6];
-    state[10]  = buf1;
-    state[14]  = buf2;
-    // row 3
-    buf1 =       rsbox[state[ 3]] ^ expanded_key[(round*16) + 15];
-    state[ 3]  = rsbox[state[ 7]] ^ expanded_key[(round*16) +  3];
-    state[ 7]  = rsbox[state[11]] ^ expanded_key[(round*16) +  7];
-    state[11]  = rsbox[state[15]] ^ expanded_key[(round*16) + 11];
-    state[15]  = buf1;
-  }
-}
-
-void cc3000_security::aes_encrypt(uint8_t *state, uint8_t *key) {
-    // expand the key into 176 bytes
-    expandKey(_expanded_key, key);
-    aes_encr(state, _expanded_key);
-}
-
-void cc3000_security::aes_decrypt(uint8_t *state, uint8_t *key) {
-    expandKey(_expanded_key, key);       // expand the key into 176 bytes
-    aes_decr(state, _expanded_key);
-}
-
-int32_t cc3000_security::aes_read_key(uint8_t *key) {
-    int32_t returnValue;
-
-    returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
-
-    return returnValue;
-}
-
-int32_t cc3000_security::aes_write_key(uint8_t *key) {
-    int32_t    returnValue;
-
-    returnValue = nvmem_write(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
-
-    return returnValue;
-}
-#endif
-
-} /* end of cc3000 namespace */
-
--- a/cc3000_hostdriver_mbedsocket/cc3000_simplelink.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_common.h"
-
-namespace mbed_cc3000 {
-
-cc3000_simple_link::cc3000_simple_link() {
-    _rx_buffer[CC3000_RX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER;
-    _tx_buffer[CC3000_TX_BUFFER_SIZE - 1] = CC3000_BUFFER_MAGIC_NUMBER;
-}
-
-cc3000_simple_link::~cc3000_simple_link() {
-}
-
-uint8_t cc3000_simple_link::get_data_received_flag() {
-    return _data_received_flag;
-}
-
-void *cc3000_simple_link::get_func_pointer(FunctionNumber function){
-    void *result;
-    /* casting to void *, will be casted back once used */
-    switch(function) {
-        case FW_PATCHES:
-            result = (void *)_fFWPatches;
-            break;
-        case DRIVER_PATCHES:
-            result = (void *)_fDriverPatches;
-            break;
-        case BOOTLOADER_PATCHES:
-            result = (void *)_fBootLoaderPatches;
-            break;
-        // case WLAN_CB:
-        //     result = (void *)_fWlanCB;
-        //     break;
-        default:
-            result = 0;
-         }
-         return result;
-}
-
-uint8_t *cc3000_simple_link::get_transmit_buffer() {
-    return _tx_buffer;
-}
-
-uint8_t *cc3000_simple_link::get_received_buffer() {
-    return _rx_buffer;
-}
-
-void cc3000_simple_link::set_op_code(uint16_t code) {
-    _rx_event_opcode = code;
-}
-
-void cc3000_simple_link::set_pending_data(uint16_t value) {
-    _rx_data_pending = value;
-}
-
-uint16_t cc3000_simple_link::get_pending_data() {
-    return _rx_data_pending;
-}
-
-void cc3000_simple_link::set_number_free_buffers(uint16_t value) {
-    _free_buffers = value;
-}
-
-void cc3000_simple_link::set_number_of_released_packets(uint16_t value) {
-    _released_packets = value;
-}
-
-
-void cc3000_simple_link::set_tx_complete_signal(bool value) {
-    _tx_complete_signal = value;
-}
-
-bool cc3000_simple_link::get_tx_complete_signal() {
-    return _tx_complete_signal;
-}
-
-void cc3000_simple_link::set_data_received_flag(uint8_t value) {
-    _data_received_flag = value;
-}
-
-uint16_t cc3000_simple_link::get_number_free_buffers() {
-    return _free_buffers;
-}
-
-uint16_t cc3000_simple_link::get_buffer_length() {
-    return _buffer_length;
-}
-
-void cc3000_simple_link::set_buffer_length(uint16_t value) {
-    _buffer_length = value;
-}
-
-uint16_t cc3000_simple_link::get_op_code() {
-    return _rx_event_opcode;
-}
-
-uint16_t cc3000_simple_link::get_released_packets() {
-    return _released_packets;
-}
-
-uint16_t cc3000_simple_link::get_sent_packets() {
-    return _sent_packets;
-}
-
-void cc3000_simple_link::set_sent_packets(uint16_t value) {
-    _sent_packets = value;
-}
-
-void cc3000_simple_link::set_transmit_error(int32_t value){
-    _transmit_data_error = value;
-}
-
-int32_t cc3000_simple_link::get_transmit_error(){
-    return _transmit_data_error;
-}
-
-void cc3000_simple_link::set_buffer_size(uint16_t value) {
-    _buffer_size = value;
-}
-
-uint16_t cc3000_simple_link::get_buffer_size(void) {
-    return _buffer_size;
-}
-
-uint8_t *cc3000_simple_link::get_received_data(void) {
-    return _received_data;
-}
-
-void cc3000_simple_link::set_received_data(uint8_t *pointer) {
-    _received_data = pointer;
-}
-
-//void cc3000_simple_link::set_wlan_cb(tWlanCB fpointer) {
-//    _fWlanCB = fpointer;
-//}
-
-}
--- a/cc3000_hostdriver_mbedsocket/cc3000_simplelink.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_SIMPLELINK_H
-#define CC3000_SIMPLELINK_H
-
-typedef uint8_t *(*tFWPatches)(uint32_t *usLength);
-typedef uint8_t *(*tDriverPatches)(uint32_t *usLength);
-typedef uint8_t *(*tBootLoaderPatches)(uint32_t *usLength);
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_socket.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,638 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_socket.h"
-#include "cc3000_event.h" //TODO - remove this
-#include "cc3000_common.h"
-
-namespace mbed_cc3000 {
-
-cc3000_socket::cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event)
-    : _simple_link(simplelink), _hci(hci), _event(event)
-{
-
-}
-
-cc3000_socket::~cc3000_socket()
-{
-
-}
-
-int32_t cc3000_socket::HostFlowControlConsumeBuff(int32_t sd) {
-#ifndef SEND_NON_BLOCKING
-    /* wait in busy loop */
-    do
-    {
-        // When the last transmission failed, return the last failure reason.
-        // Note that the buffer will not be allocated in this case
-        if (_simple_link.get_transmit_error() != 0)
-        {
-            errno = _simple_link.get_transmit_error();
-            _simple_link.set_transmit_error(0);
-            return errno;
-        }
-
-        if(SOCKET_STATUS_ACTIVE != _event.get_socket_active_status(sd))
-            return -1;
-    } while(0 == _simple_link.get_number_free_buffers());
-
-    uint16_t free_buffer = _simple_link.get_number_free_buffers();
-    free_buffer--;
-    _simple_link.set_number_free_buffers(free_buffer);
-
-    return 0;
-#else
-
-    // When the last transmission failed, return the last failure reason.
-    // Note that the buffer will not be allocated in this case
-    if (_simple_link.get_transmit_error() != 0)
-    {
-        errno = _simple_link.get_transmit_error();
-        _simple_link.set_transmit_error(0);
-        return errno;
-    }
-    if(SOCKET_STATUS_ACTIVE != _event.get_socket_active_status(sd))
-        return -1;
-
-    // If there are no available buffers, return -2. It is recommended to use
-    // select or receive to see if there is any buffer occupied with received data
-    // If so, call receive() to release the buffer.
-    if(0 == _simple_link.get_number_free_buffers())
-    {
-        return -2;
-    }
-    else
-    {
-        uint16_t free_buffer = _simple_link.get_number_free_buffers();
-        free_buffer--;
-        _simple_link.set_number_free_buffers(free_buffer);
-        return 0;
-    }
-#endif
-}
-
-int32_t cc3000_socket::socket(int32_t domain, int32_t type, int32_t protocol) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, domain);
-    args = UINT32_TO_STREAM(args, type);
-    args = UINT32_TO_STREAM(args, protocol);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_SOCKET, ptr, SOCKET_OPEN_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_SOCKET, &ret);
-
-    // Process the event
-    errno = ret;
-
-    _event.set_socket_active_status(ret, SOCKET_STATUS_ACTIVE);
-
-    return(ret);
-}
-
-int32_t cc3000_socket::closesocket(int32_t sd) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-
-    while(_simple_link.get_number_free_buffers() != SOCKET_MAX_FREE_BUFFERS);
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, sd);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_CLOSE_SOCKET, ptr, SOCKET_CLOSE_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_CLOSE_SOCKET, &ret);
-    errno = ret;
-
-    // since 'close' call may result in either OK (and then it closed) or error, mark this socket as invalid
-    _event.set_socket_active_status(sd, SOCKET_STATUS_INACTIVE);
-
-    return(ret);
-}
-
-int32_t cc3000_socket::accept(int32_t sd, sockaddr *addr, socklen_t *addrlen) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-    tBsdReturnParams tAcceptReturnArguments;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_ACCEPT, ptr, SOCKET_ACCEPT_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_ACCEPT, &tAcceptReturnArguments);
-
-
-    // need specify return parameters!!!
-    memcpy(addr, &tAcceptReturnArguments.tSocketAddress, ASIC_ADDR_LEN);
-    *addrlen = ASIC_ADDR_LEN;
-    errno = tAcceptReturnArguments.iStatus;
-    ret = errno;
-
-    // if succeeded, iStatus = new socket descriptor. otherwise - error number
-    if(M_IS_VALID_SD(ret))
-    {
-        _event.set_socket_active_status(ret, SOCKET_STATUS_ACTIVE);
-    }
-    else
-    {
-        _event.set_socket_active_status(sd, SOCKET_STATUS_INACTIVE);
-    }
-
-    return(ret);
-}
-
-int32_t cc3000_socket::bind(int32_t sd, const sockaddr *addr, int32_t addrlen) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    addrlen = ASIC_ADDR_LEN;
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, 0x00000008);
-    args = UINT32_TO_STREAM(args, addrlen);
-    ARRAY_TO_STREAM(args, ((uint8_t *)addr), addrlen);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_BIND, ptr, SOCKET_BIND_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_BIND, &ret);
-
-    errno = ret;
-
-    return(ret);
-}
-
-int32_t cc3000_socket::listen(int32_t sd, int32_t backlog) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, backlog);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_LISTEN, ptr, SOCKET_LISTEN_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_LISTEN, &ret);
-    errno = ret;
-
-    return(ret);
-}
-
-int32_t cc3000_socket::connect(int32_t sd, const sockaddr *addr, int32_t addrlen) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE);
-    addrlen = 8;
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, 0x00000008);
-    args = UINT32_TO_STREAM(args, addrlen);
-    ARRAY_TO_STREAM(args, ((uint8_t *)addr), addrlen);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_CONNECT, ptr, SOCKET_CONNECT_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_CONNECT, &ret);
-
-    errno = ret;
-
-    return((int32_t)ret);
-}
-
-int32_t cc3000_socket::select(int32_t nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout) {
-    uint8_t *ptr, *args;
-    tBsdSelectRecvParams tParams;
-    uint32_t is_blocking;
-
-    if( timeout == NULL)
-    {
-        is_blocking = 1; /* blocking , infinity timeout */
-    }
-    else
-    {
-        is_blocking = 0; /* no blocking, timeout */
-    }
-
-    // Fill in HCI packet structure
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, nfds);
-    args = UINT32_TO_STREAM(args, 0x00000014);
-    args = UINT32_TO_STREAM(args, 0x00000014);
-    args = UINT32_TO_STREAM(args, 0x00000014);
-    args = UINT32_TO_STREAM(args, 0x00000014);
-    args = UINT32_TO_STREAM(args, is_blocking);
-    args = UINT32_TO_STREAM(args, ((readsds) ? *(uint32_t*)readsds : 0));
-    args = UINT32_TO_STREAM(args, ((writesds) ? *(uint32_t*)writesds : 0));
-    args = UINT32_TO_STREAM(args, ((exceptsds) ? *(uint32_t*)exceptsds : 0));
-
-    if (timeout)
-    {
-        if ( 0 == timeout->tv_sec && timeout->tv_usec < SELECT_TIMEOUT_MIN_MICRO_SECONDS)
-        {
-            timeout->tv_usec = SELECT_TIMEOUT_MIN_MICRO_SECONDS;
-        }
-        args = UINT32_TO_STREAM(args, timeout->tv_sec);
-        args = UINT32_TO_STREAM(args, timeout->tv_usec);
-    }
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_BSD_SELECT, ptr, SOCKET_SELECT_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_EVNT_SELECT, &tParams);
-
-    // Update actually read FD
-    if (tParams.iStatus >= 0)
-    {
-        if (readsds)
-        {
-            memcpy(readsds, &tParams.uiRdfd, sizeof(tParams.uiRdfd));
-        }
-
-        if (writesds)
-        {
-            memcpy(writesds, &tParams.uiWrfd, sizeof(tParams.uiWrfd));
-        }
-
-        if (exceptsds)
-        {
-            memcpy(exceptsds, &tParams.uiExfd, sizeof(tParams.uiExfd));
-        }
-
-        return(tParams.iStatus);
-
-    }
-    else
-    {
-        errno = tParams.iStatus;
-        return(-1);
-    }
-}
-
-int32_t cc3000_socket::getsockopt (int32_t sd, int32_t level, int32_t optname, void *optval, socklen_t *optlen) {
-    uint8_t *ptr, *args;
-    tBsdGetSockOptReturnParams  tRetParams;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, level);
-    args = UINT32_TO_STREAM(args, optname);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_GETSOCKOPT, ptr, SOCKET_GET_SOCK_OPT_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_GETSOCKOPT, &tRetParams);
-
-    if (((int8_t)tRetParams.iStatus) >= 0)
-    {
-        *optlen = 4;
-        memcpy(optval, tRetParams.ucOptValue, 4);
-        return (0);
-    }
-    else
-    {
-        errno = tRetParams.iStatus;
-        return errno;
-    }
-}
-
-int32_t cc3000_socket::simple_link_recv(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen, int32_t opcode) {
-    uint8_t *ptr, *args;
-    tBsdReadReturnParams tSocketReadEvent;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, len);
-    args = UINT32_TO_STREAM(args, flags);
-
-    // Generate the read command, and wait for the
-    _hci.command_send(opcode,  ptr, SOCKET_RECV_FROM_PARAMS_LEN);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(opcode, &tSocketReadEvent);
-
-    // In case the number of bytes is more then zero - read data
-    if (tSocketReadEvent.iNumberOfBytes > 0)
-    {
-        // Wait for the data in a synchronous way. Here we assume that the bug is
-        // big enough to store also parameters of receive from too....
-        _event.simplelink_wait_data((uint8_t *)buf, (uint8_t *)from, (uint8_t *)fromlen);
-    }
-
-    errno = tSocketReadEvent.iNumberOfBytes;
-
-    return(tSocketReadEvent.iNumberOfBytes);
-}
-
-int32_t cc3000_socket::recv(int32_t sd, void *buf, int32_t len, int32_t flags) {
-    return(simple_link_recv(sd, buf, len, flags, NULL, NULL, HCI_CMND_RECV));
-}
-
-int32_t cc3000_socket::recvfrom(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen) {
-    return(simple_link_recv(sd, buf, len, flags, from, fromlen, HCI_CMND_RECVFROM));
-}
-
-int32_t cc3000_socket::simple_link_send(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, int32_t tolen, int32_t opcode) {
-    uint8_t uArgSize = 0x00,  addrlen = 0x00;
-    uint8_t *ptr, *pDataPtr = NULL, *args;
-    uint32_t addr_offset = 0x00;
-    int32_t res;
-    tBsdReadReturnParams tSocketSendEvent;
-
-    // Check the bsd_arguments
-    if (0 != (res = HostFlowControlConsumeBuff(sd)))
-    {
-        return res;
-    }
-
-    //Update the number of sent packets
-    uint16_t sent_packets = _simple_link.get_sent_packets();
-    sent_packets++;
-    _simple_link.set_sent_packets(sent_packets);
-
-    // Allocate a buffer and construct a packet and send it over spi
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_DATA);
-
-    // Update the offset of data and parameters according to the command
-    switch(opcode)
-    {
-    case HCI_CMND_SENDTO:
-        {
-            addr_offset = len + sizeof(len) + sizeof(len);
-            addrlen = 8;
-            uArgSize = SOCKET_SENDTO_PARAMS_LEN;
-            pDataPtr = ptr + HEADERS_SIZE_DATA + SOCKET_SENDTO_PARAMS_LEN;
-            break;
-        }
-
-    case HCI_CMND_SEND:
-        {
-            tolen = 0;
-            to = NULL;
-            uArgSize = HCI_CMND_SEND_ARG_LENGTH;
-            pDataPtr = ptr + HEADERS_SIZE_DATA + HCI_CMND_SEND_ARG_LENGTH;
-            break;
-        }
-
-    default:
-        {
-            break;
-        }
-    }
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, uArgSize - sizeof(sd));
-    args = UINT32_TO_STREAM(args, len);
-    args = UINT32_TO_STREAM(args, flags);
-
-    if (opcode == HCI_CMND_SENDTO)
-    {
-        args = UINT32_TO_STREAM(args, addr_offset);
-        args = UINT32_TO_STREAM(args, addrlen);
-    }
-
-    // Copy the data received from user into the TX Buffer
-    ARRAY_TO_STREAM(pDataPtr, ((uint8_t *)buf), len);
-
-    // In case we are using SendTo, copy the to parameters
-    if (opcode == HCI_CMND_SENDTO)
-    {
-        ARRAY_TO_STREAM(pDataPtr, ((uint8_t *)to), tolen);
-    }
-
-    // Initiate a HCI command
-    _hci.data_send(opcode, ptr, uArgSize, len,(uint8_t*)to, tolen);
-    if (opcode == HCI_CMND_SENDTO)
-       _event.simplelink_wait_event(HCI_EVNT_SENDTO, &tSocketSendEvent);
-    else
-       _event.simplelink_wait_event(HCI_EVNT_SEND, &tSocketSendEvent);
-
-    return (len);
-}
-
-int32_t cc3000_socket::send(int32_t sd, const void *buf, int32_t len, int32_t flags) {
-    return(simple_link_send(sd, buf, len, flags, NULL, 0, HCI_CMND_SEND));
-}
-
-int32_t cc3000_socket::sendto(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, socklen_t tolen) {
-    return(simple_link_send(sd, buf, len, flags, to, tolen, HCI_CMND_SENDTO));
-}
-
-int32_t cc3000_socket::mdns_advertiser(uint16_t mdns_enabled, uint8_t *device_service_name, uint16_t device_service_name_length) {
-    int32_t ret;
-     uint8_t *pTxBuffer, *pArgs;
-
-    if (device_service_name_length > MDNS_DEVICE_SERVICE_MAX_LENGTH)
-    {
-        return EFAIL;
-    }
-
-    pTxBuffer = _simple_link.get_transmit_buffer();
-    pArgs = (pTxBuffer + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE);
-
-    // Fill in HCI packet structure
-    pArgs = UINT32_TO_STREAM(pArgs, mdns_enabled);
-    pArgs = UINT32_TO_STREAM(pArgs, 8);
-    pArgs = UINT32_TO_STREAM(pArgs, device_service_name_length);
-    ARRAY_TO_STREAM(pArgs, device_service_name, device_service_name_length);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_MDNS_ADVERTISE, pTxBuffer, SOCKET_MDNS_ADVERTISE_PARAMS_LEN + device_service_name_length);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_EVNT_MDNS_ADVERTISE, &ret);
-
-    return ret;
-}
-
-
-#ifndef CC3000_TINY_DRIVER
-int32_t cc3000_socket::gethostbyname(uint8_t *hostname, uint16_t name_length, uint32_t *out_ip_addr) {
-    tBsdGethostbynameParams ret;
-    uint8_t *ptr, *args;
-
-    errno = EFAIL;
-
-    if (name_length > HOSTNAME_MAX_LENGTH)
-    {
-        return errno;
-    }
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, 8);
-    args = UINT32_TO_STREAM(args, name_length);
-    ARRAY_TO_STREAM(args, hostname, name_length);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_GETHOSTNAME, ptr, SOCKET_GET_HOST_BY_NAME_PARAMS_LEN + name_length - 1);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_EVNT_BSD_GETHOSTBYNAME, &ret);
-
-    errno = ret.retVal;
-
-    (*((int32_t*)out_ip_addr)) = ret.outputAddress;
-
-    return (errno);
-}
-
-int32_t cc3000_socket::setsockopt(int32_t sd, int32_t level, int32_t optname, const void *optval, socklen_t optlen) {
-    int32_t ret;
-    uint8_t *ptr, *args;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, sd);
-    args = UINT32_TO_STREAM(args, level);
-    args = UINT32_TO_STREAM(args, optname);
-    args = UINT32_TO_STREAM(args, 0x00000008);
-    args = UINT32_TO_STREAM(args, optlen);
-    ARRAY_TO_STREAM(args, ((uint8_t *)optval), optlen);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_SETSOCKOPT, ptr, SOCKET_SET_SOCK_OPT_PARAMS_LEN  + optlen);
-
-    // Since we are in blocking state - wait for event complete
-    _event.simplelink_wait_event(HCI_CMND_SETSOCKOPT, &ret);
-
-    if (ret >= 0)
-    {
-        return (0);
-    }
-    else
-    {
-        errno = ret;
-        return ret;
-    }
-}
-
-#endif
-
-char * cc3000_socket::inet_ntoa_r(uint32_t s_addr, char *buf, int buflen)
-{
-  char inv[3];
-  char *rp;
-  uint8_t *ap;
-  uint8_t rem;
-  uint8_t n;
-  uint8_t i;
-  int len = 0;
-
-  rp = buf;
-  ap = (uint8_t *)&s_addr;
-  for(n = 0; n < 4; n++) {
-    i = 0;
-    do {
-      rem = *ap % (uint8_t)10;
-      *ap /= (uint8_t)10;
-      inv[i++] = '0' + rem;
-    } while(*ap);
-    while(i--) {
-      if (len++ >= buflen) {
-        return NULL;
-      }
-      *rp++ = inv[i];
-    }
-    if (len++ >= buflen) {
-      return NULL;
-    }
-    *rp++ = '.';
-    ap++;
-  }
-  *--rp = 0;
-  return buf;
-}
-
-} /* end of cc3000 namespace */
--- a/cc3000_hostdriver_mbedsocket/cc3000_socket.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_SOCKET_H
-#define CC3000_SOCKET_H
-
-#define SOCKET_MAX_FREE_BUFFERS    6
-
-#define SOCKET_STATUS_ACTIVE       0
-#define SOCKET_STATUS_INACTIVE     1
-
-#define SOCKET_STATUS_INIT_VAL  0xFFFF
-#define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7))
-#define M_IS_VALID_STATUS(status) (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
-
-#ifdef _API_USE_BSD_CLOSE
-    #define close(sd) closesocket(sd)
-#endif
-
-//Enable this flag if and only if you must comply with BSD socket read() and
-//write() functions
-#ifdef _API_USE_BSD_READ_WRITE
-    #define read(sd, buf, len, flags) recv(sd, buf, len, flags)
-    #define write(sd, buf, len, flags) send(sd, buf, len, flags)
-#endif
-
-#define SOCKET_OPEN_PARAMS_LEN                 (12)
-#define SOCKET_CLOSE_PARAMS_LEN                (4)
-#define SOCKET_ACCEPT_PARAMS_LEN               (4)
-#define SOCKET_BIND_PARAMS_LEN                 (20)
-#define SOCKET_LISTEN_PARAMS_LEN               (8)
-#define SOCKET_GET_HOST_BY_NAME_PARAMS_LEN     (9)
-#define SOCKET_CONNECT_PARAMS_LEN              (20)
-#define SOCKET_SELECT_PARAMS_LEN               (44)
-#define SOCKET_SET_SOCK_OPT_PARAMS_LEN         (20)
-#define SOCKET_GET_SOCK_OPT_PARAMS_LEN         (12)
-#define SOCKET_RECV_FROM_PARAMS_LEN            (12)
-#define SOCKET_SENDTO_PARAMS_LEN               (24)
-#define SOCKET_MDNS_ADVERTISE_PARAMS_LEN       (12)
-
-//#define NULL 0
-
-// The legnth of arguments for the SEND command: sd + buff_offset + len + flags,
-// while size of each parameter is 32 bit - so the total length is 16 bytes;
-
-#define HCI_CMND_SEND_ARG_LENGTH                    (16)
-#define SELECT_TIMEOUT_MIN_MICRO_SECONDS            5000
-#define HEADERS_SIZE_DATA                           (SPI_HEADER_SIZE + 5)
-#define SIMPLE_LINK_HCI_CMND_TRANSPORT_HEADER_SIZE  (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE)
-#define MDNS_DEVICE_SERVICE_MAX_LENGTH              (32)
-
-
-#define HOSTNAME_MAX_LENGTH (230)  // 230 bytes + header shouldn't exceed 8 bit value
-
-//--------- Address Families --------
-
-#define  AF_INET                2
-#define  AF_INET6               23
-
-//------------ Socket Types ------------
-
-#define  SOCK_STREAM            1
-#define  SOCK_DGRAM             2
-#define  SOCK_RAW               3           // Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends the raw datagram not including link level headers
-#define  SOCK_RDM               4
-#define  SOCK_SEQPACKET         5
-
-//----------- Socket Protocol ----------
-
-#define IPPROTO_IP              0           // dummy for IP
-#define IPPROTO_ICMP            1           // control message protocol
-#define IPPROTO_IPV4            IPPROTO_IP  // IP inside IP
-#define IPPROTO_TCP             6           // tcp
-#define IPPROTO_UDP             17          // user datagram protocol
-#define IPPROTO_IPV6            41          // IPv6 in IPv6
-#define IPPROTO_NONE            59          // No next header
-#define IPPROTO_RAW             255         // raw IP packet
-#define IPPROTO_MAX             256
-
-//----------- Socket retunr codes  -----------
-
-#define SOC_ERROR                (-1)        // error
-#define SOC_IN_PROGRESS          (-2)        // socket in progress
-
-//----------- Socket Options -----------
-#define  SOL_SOCKET             0xffff       //  socket level
-#define  SOCKOPT_RECV_TIMEOUT   1            //  optname to configure recv and recvfromtimeout
-#define  SOCKOPT_NONBLOCK       2            // accept non block mode set SOCK_ON or SOCK_OFF (default block mode )
-#define  SOCK_ON                0            // socket non-blocking mode    is enabled
-#define  SOCK_OFF               1            // socket blocking mode is enabled
-
-#define  TCP_NODELAY            0x0001
-#define  TCP_BSDURGENT          0x7000
-
-#define  MAX_PACKET_SIZE        1500
-#define  MAX_LISTEN_QUEUE       4
-
-#define  IOCTL_SOCKET_EVENTMASK
-
-#define __FD_SETSIZE            32
-
-#define  ASIC_ADDR_LEN          8
-
-#define NO_QUERY_RECIVED        -3
-
-
-typedef struct _in_addr_t
-{
-    uint32_t s_addr;                   // load with inet_aton()
-} in_addr;
-
-/*typedef struct _sockaddr_t
-{
-    unsigned short int  sa_family;
-    unsigned char       sa_data[14];
-} sockaddr;*/
-
-typedef struct _sockaddr_in_t
-{
-    int16_t  sin_family;            // e.g. AF_INET
-    uint16_t sin_port;              // e.g. htons(3490)
-    in_addr  sin_addr;              // see struct in_addr, below
-    uint8_t  sin_zero[8];           // zero this if you want to
-} sockaddr_in;
-
-typedef uint32_t socklen_t;
-
-// The fd_set member is required to be an array of longs.
-typedef int32_t __fd_mask;
-
-// It's easier to assume 8-bit bytes than to get CHAR_BIT.
-#define __NFDBITS               (8 * sizeof (__fd_mask))
-#define __FDELT(d)              ((d) / __NFDBITS)
-#define __FDMASK(d)             ((__fd_mask) 1 << ((d) % __NFDBITS))
-
-#ifndef FD_SET
-//not used in the current code
-#define ENOBUFS                 55          // No buffer space available
-
-// Access macros for 'fd_set'.
-#define FD_SET(fd, fdsetp)      __FD_SET (fd, fdsetp)
-#define FD_CLR(fd, fdsetp)      __FD_CLR (fd, fdsetp)
-#define FD_ISSET(fd, fdsetp)    __FD_ISSET (fd, fdsetp)
-#define FD_ZERO(fdsetp)         __FD_ZERO (fdsetp)
-
-// fd_set for select and pselect.
-typedef struct
-{
-    __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
-#define __FDS_BITS(set)        ((set)->fds_bits)
-} fd_set;
-
-#endif /* FD_SET */
-
-// We don't use `memset' because this would require a prototype and
-//   the array isn't too big.
-#define __FD_ZERO(set)                               \
-  do {                                                \
-    uint32_t __i;                                 \
-    fd_set *__arr = (set);                            \
-    for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
-      __FDS_BITS (__arr)[__i] = 0;                    \
-  } while (0)
-#define __FD_SET(d, set)       (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
-#define __FD_CLR(d, set)       (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
-#define __FD_ISSET(d, set)     (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
-
-//Use in case of Big Endian only
-
-#define htonl(A)    ((((uint32_t)(A) & 0xff000000) >> 24) | \
-                     (((uint32_t)(A) & 0x00ff0000) >> 8) | \
-                     (((uint32_t)(A) & 0x0000ff00) << 8) | \
-                     (((uint32_t)(A) & 0x000000ff) << 24))
-
-#define ntohl                   htonl
-
-//Use in case of Big Endian only
-#define htons(A)     ((((uint32_t)(A) & 0xff00) >> 8) | \
-                      (((uint32_t)(A) & 0x00ff) << 8))
-
-
-#define ntohs                   htons
-
-// mDNS port - 5353    mDNS multicast address - 224.0.0.251
-#define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \
-                               sockaddr.sa_data[1] = 0xe9; \
-                               sockaddr.sa_data[2] = 0xe0; \
-                               sockaddr.sa_data[3] = 0x0;  \
-                               sockaddr.sa_data[4] = 0x0;  \
-                               sockaddr.sa_data[5] = 0xfb;
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_spi.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,285 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-#include "cc3000_spi.h"
-
-volatile bool ProcessWlanInterrupt;
-
-namespace mbed_cc3000 {
-
-cc3000_spi::cc3000_spi(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port, cc3000_event &event, cc3000_simple_link &simple_link)
-  : _wlan_irq(cc3000_irq), _wlan_en(cc3000_en), _wlan_cs(cc3000_cs), _wlan_spi(cc3000_spi), _irq_port(irq_port),
-    _event(event), _simple_link(simple_link) {
-    /* TODO = clear pending interrupts for PORTS. This is dependent on the used chip */
-
-    _wlan_spi.format(8,1);
-    _wlan_spi.frequency(12000000);
-    _function_pointer =  _wlan_irq.fall(this, &cc3000_spi::WLAN_IRQHandler);
-
-    _wlan_en = 0;
-    _wlan_cs = 1;
-}
-
-cc3000_spi::~cc3000_spi() {
-
-}
-
-void cc3000_spi::wlan_irq_enable()
-{
-ProcessWlanInterrupt = 1;
-//    NVIC_EnableIRQ(_irq_port);
-
-    if(wlan_irq_read() == 0) {
-        WLAN_IRQHandler();
-    }
-}
-
-void cc3000_spi::wlan_irq_disable() {
-ProcessWlanInterrupt = 0;
-//    NVIC_DisableIRQ(_irq_port);
-}
-
-uint32_t cc3000_spi::wlan_irq_read() {
-    return _wlan_irq.read();
-}
-
-void cc3000_spi::close() {
-    wlan_irq_disable();
-}
-
-void cc3000_spi::open() {
-   _spi_info.spi_state = eSPI_STATE_POWERUP;
-   _spi_info.tx_packet_length = 0;
-   _spi_info.rx_packet_length = 0;
-    wlan_irq_enable();
-}
-
-uint32_t cc3000_spi::first_write(uint8_t *buffer, uint16_t length) {
-    _wlan_cs = 0;
-    wait_us(50);
-
-    /* first 4 bytes of the data */
-    write_synchronous(buffer, 4);
-    wait_us(50);
-    write_synchronous(buffer + 4, length - 4);
-    _spi_info.spi_state = eSPI_STATE_IDLE;
-    _wlan_cs = 1;
-
-    return 0;
-}
-
-
-uint32_t cc3000_spi::write(uint8_t *buffer, uint16_t length) {
-    uint8_t pad = 0;
- // check the total length of the packet in order to figure out if padding is necessary
-   if(!(length & 0x0001))
-   {
-      pad++;
-   }
-   buffer[0] = WRITE;
-   buffer[1] = HI(length + pad);
-   buffer[2] = LO(length + pad);
-   buffer[3] = 0;
-   buffer[4] = 0;
-
-   length += (SPI_HEADER_SIZE + pad);
-
-   // The magic number resides at the end of the TX/RX buffer (1 byte after the allocated size)
-   // If the magic number is overwitten - buffer overrun occurred - we will be stuck here forever!
-   uint8_t * transmit_buffer = _simple_link.get_transmit_buffer();
-   if (transmit_buffer[CC3000_TX_BUFFER_SIZE - 1] != CC3000_BUFFER_MAGIC_NUMBER)
-   {
-      while (1);
-   }
-
-   if (_spi_info.spi_state == eSPI_STATE_POWERUP)
-   {
-      while (_spi_info.spi_state != eSPI_STATE_INITIALIZED);
-   }
-
-   if (_spi_info.spi_state == eSPI_STATE_INITIALIZED)
-   {
-      // TX/RX transaction over SPI after powerup: IRQ is low - send read buffer size command
-      first_write(buffer, length);
-   }
-   else
-   {
-      // Prevent occurence of a race condition when 2 back to back packets are sent to the
-      // device, so the state will move to IDLE and once again to not IDLE due to IRQ
-      wlan_irq_disable();
-
-      while (_spi_info.spi_state != eSPI_STATE_IDLE);
-
-      _spi_info.spi_state = eSPI_STATE_WRITE_IRQ;
-      //_spi_info.pTxPacket = buffer;
-      _spi_info.tx_packet_length = length;
-
-      // Assert the CS line and wait until the IRQ line is active, then initialize the write operation
-      _wlan_cs = 0;
-
-      wlan_irq_enable();
-   }
-
-   // Wait until the transaction ends
-   while (_spi_info.spi_state != eSPI_STATE_IDLE);
-
-   return 0;
-}
-
-void cc3000_spi::write_synchronous(uint8_t *data, uint16_t size) {
-   while(size)
-   {
-        _wlan_spi.write(*data++);
-        size--;
-   }
-}
-
-void cc3000_spi::read_synchronous(uint8_t *data, uint16_t size) {
-   for (uint32_t i = 0; i < size; i++)
-   {
-        data[i] = _wlan_spi.write(0x03);;
-   }
-}
-
-uint32_t cc3000_spi::read_data_cont() {
-   long data_to_recv;
-   unsigned char *evnt_buff, type;
-
-   //determine the packet type
-   evnt_buff = _simple_link.get_received_buffer();
-   data_to_recv = 0;
-   STREAM_TO_UINT8((uint8_t *)(evnt_buff + SPI_HEADER_SIZE), HCI_PACKET_TYPE_OFFSET, type);
-
-    switch(type)
-    {
-        case HCI_TYPE_DATA:
-        {
-         // Read the remaining data..
-         STREAM_TO_UINT16((uint8_t *)(evnt_buff + SPI_HEADER_SIZE), HCI_DATA_LENGTH_OFFSET, data_to_recv);
-         if (!((HEADERS_SIZE_EVNT + data_to_recv) & 1))
-         {
-              data_to_recv++;
-         }
-
-         if (data_to_recv)
-         {
-               read_synchronous(evnt_buff + 10, data_to_recv);
-         }
-            break;
-        }
-        case HCI_TYPE_EVNT:
-        {
-         // Calculate the rest length of the data
-            STREAM_TO_UINT8((char *)(evnt_buff + SPI_HEADER_SIZE), HCI_EVENT_LENGTH_OFFSET, data_to_recv);
-         data_to_recv -= 1;
-         // Add padding byte if needed
-         if ((HEADERS_SIZE_EVNT + data_to_recv) & 1)
-         {
-               data_to_recv++;
-         }
-
-         if (data_to_recv)
-         {
-               read_synchronous(evnt_buff + 10, data_to_recv);
-         }
-
-         _spi_info.spi_state = eSPI_STATE_READ_EOT;
-            break;
-        }
-    }
-    return (0);
-}
-
-void cc3000_spi::set_wlan_en(uint8_t value) {
-    if (value) {
-        _wlan_en = 1;
-    } else {
-        _wlan_en = 0;
-    }
-}
-
-void cc3000_spi::WLAN_IRQHandler() {
-if(ProcessWlanInterrupt)
-{
-
-   if (_spi_info.spi_state == eSPI_STATE_POWERUP)
-   {
-      // Inform HCI Layer that IRQ occured after powerup
-      _spi_info.spi_state = eSPI_STATE_INITIALIZED;
-   }
-   else if (_spi_info.spi_state == eSPI_STATE_IDLE)
-   {
-      _spi_info.spi_state = eSPI_STATE_READ_IRQ;
-      /* IRQ line goes low - acknowledge it */
-       _wlan_cs = 0;
-      read_synchronous(_simple_link.get_received_buffer(), 10);
-      _spi_info.spi_state = eSPI_STATE_READ_EOT;
-
-
-      // The header was read - continue with the payload read
-      if (!read_data_cont())
-      {
-          // All the data was read - finalize handling by switching to the task
-          // Trigger Rx processing
-          wlan_irq_disable();
-          _wlan_cs = 1;
-          // The magic number resides at the end of the TX/RX buffer (1 byte after the allocated size)
-          // If the magic number is overwitten - buffer overrun occurred - we will be stuck here forever!
-          uint8_t *received_buffer = _simple_link.get_received_buffer();
-          if (received_buffer[CC3000_RX_BUFFER_SIZE - 1] != CC3000_BUFFER_MAGIC_NUMBER)
-              {
-                  while (1);
-              }
-              _spi_info.spi_state = eSPI_STATE_IDLE;
-              _event.received_handler(received_buffer + SPI_HEADER_SIZE);
-      }
-   }
-   else if (_spi_info.spi_state == eSPI_STATE_WRITE_IRQ)
-   {
-      write_synchronous(_simple_link.get_transmit_buffer(), _spi_info.tx_packet_length);
-      _spi_info.spi_state = eSPI_STATE_IDLE;
-      _wlan_cs = 1;
-   }
-}
-}
-
-}
-
--- a/cc3000_hostdriver_mbedsocket/cc3000_spi.h	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#ifndef CC3000_SPI_H
-#define CC3000_SPI_H
-
-typedef struct
-{
-   uint16_t tx_packet_length;
-   uint16_t rx_packet_length;
-   uint32_t spi_state;
-} tSpiInfo;
-
-
-/* ===========================================================================================
-                                              SPI
-   =========================================================================================== */
-#define READ                    3
-#define WRITE                   1
-
-#define HI(value)               (((value) & 0xFF00) >> 8)
-#define LO(value)               ((value) & 0x00FF)
-
-#define HEADERS_SIZE_EVNT    (SPI_HEADER_SIZE + 5)
-
-#define SPI_HEADER_SIZE      (5)
-
-#define  eSPI_STATE_POWERUP             (0)
-#define  eSPI_STATE_INITIALIZED         (1)
-#define  eSPI_STATE_IDLE                (2)
-#define  eSPI_STATE_WRITE_IRQ           (3)
-#define  eSPI_STATE_WRITE_FIRST_PORTION (4)
-#define  eSPI_STATE_WRITE_EOT           (5)
-#define  eSPI_STATE_READ_IRQ            (6)
-#define  eSPI_STATE_READ_FIRST_PORTION  (7)
-#define  eSPI_STATE_READ_EOT            (8)
-
-// The magic number that resides at the end of the TX/RX buffer (1 byte after the allocated size)
-// for the purpose of detection of the overrun. The location of the memory where the magic number
-// resides shall never be written. In case it is written - overrun occured and either recevie function
-// or send function will be stuck forever.
-#define CC3000_BUFFER_MAGIC_NUMBER (0xDE)
-
-/* ===========================================================================================
-                                              HCI
-   =========================================================================================== */
-
-#define SL_PATCH_PORTION_SIZE                        (1000)
-
-#define SPI_HEADER_SIZE                              (5)
-#define SIMPLE_LINK_HCI_CMND_HEADER_SIZE             (4)
-#define HEADERS_SIZE_CMD                             (SPI_HEADER_SIZE + SIMPLE_LINK_HCI_CMND_HEADER_SIZE)
-#define SIMPLE_LINK_HCI_DATA_CMND_HEADER_SIZE        (5)
-#define SIMPLE_LINK_HCI_DATA_HEADER_SIZE             (5)
-#define SIMPLE_LINK_HCI_PATCH_HEADER_SIZE            (2)
-
-// Values that can be used as HCI Commands and HCI Packet header defines
-#define  HCI_TYPE_CMND          0x1
-#define  HCI_TYPE_DATA          0x2
-#define  HCI_TYPE_PATCH         0x3
-#define  HCI_TYPE_EVNT          0x4
-
-
-#define HCI_EVENT_PATCHES_DRV_REQ             (1)
-#define HCI_EVENT_PATCHES_FW_REQ              (2)
-#define HCI_EVENT_PATCHES_BOOTLOAD_REQ        (3)
-
-
-#define  HCI_CMND_WLAN_BASE                              (0x0000)
-#define  HCI_CMND_WLAN_CONNECT                            0x0001
-#define  HCI_CMND_WLAN_DISCONNECT                         0x0002
-#define  HCI_CMND_WLAN_IOCTL_SET_SCANPARAM                0x0003
-#define  HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY        0x0004
-#define  HCI_CMND_WLAN_IOCTL_ADD_PROFILE                  0x0005
-#define  HCI_CMND_WLAN_IOCTL_DEL_PROFILE                  0x0006
-#define  HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS             0x0007
-#define  HCI_CMND_EVENT_MASK                              0x0008
-#define  HCI_CMND_WLAN_IOCTL_STATUSGET                    0x0009
-#define  HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START          0x000A
-#define  HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP           0x000B
-#define  HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX     0x000C
-#define  HCI_CMND_WLAN_CONFIGURE_PATCH                    0x000D
-
-
-#define  HCI_CMND_SOCKET_BASE          0x1000
-#define  HCI_CMND_SOCKET               0x1001
-#define  HCI_CMND_BIND                 0x1002
-#define  HCI_CMND_RECV                 0x1004
-#define  HCI_CMND_ACCEPT               0x1005
-#define  HCI_CMND_LISTEN               0x1006
-#define  HCI_CMND_CONNECT              0x1007
-#define  HCI_CMND_BSD_SELECT           0x1008
-#define  HCI_CMND_SETSOCKOPT           0x1009
-#define  HCI_CMND_GETSOCKOPT           0x100A
-#define  HCI_CMND_CLOSE_SOCKET         0x100B
-#define  HCI_CMND_RECVFROM             0x100D
-#define  HCI_CMND_GETHOSTNAME          0x1010
-#define  HCI_CMND_MDNS_ADVERTISE       0x1011
-
-
-#define HCI_DATA_BASE                                0x80
-
-#define HCI_CMND_SEND                               (0x01 + HCI_DATA_BASE)
-#define HCI_CMND_SENDTO                             (0x03 + HCI_DATA_BASE)
-#define HCI_DATA_BSD_RECVFROM                       (0x04 + HCI_DATA_BASE)
-#define HCI_DATA_BSD_RECV                           (0x05 + HCI_DATA_BASE)
-
-
-#define HCI_CMND_NVMEM_CBASE        (0x0200)
-
-
-#define HCI_CMND_NVMEM_CREATE_ENTRY (0x0203)
-#define HCI_CMND_NVMEM_SWAP_ENTRY   (0x0205)
-#define HCI_CMND_NVMEM_READ         (0x0201)
-#define HCI_CMND_NVMEM_WRITE        (0x0090)
-#define HCI_CMND_NVMEM_WRITE_PATCH  (0x0204)
-#define HCI_CMND_READ_SP_VERSION    (0x0207)
-
-#define  HCI_CMND_READ_BUFFER_SIZE  0x400B
-#define  HCI_CMND_SIMPLE_LINK_START 0x4000
-
-#define HCI_CMND_NETAPP_BASE        0x2000
-
-#define HCI_NETAPP_DHCP                    (0x0001 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_PING_SEND               (0x0002 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_PING_REPORT             (0x0003 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_PING_STOP               (0x0004 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_IPCONFIG                (0x0005 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_ARP_FLUSH               (0x0006 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_SET_DEBUG_LEVEL         (0x0008 + HCI_CMND_NETAPP_BASE)
-#define HCI_NETAPP_SET_TIMERS              (0x0009 + HCI_CMND_NETAPP_BASE)
-
-// Values that can be used as HCI Events defines
-#define  HCI_EVNT_WLAN_BASE     0x0000
-#define  HCI_EVNT_WLAN_CONNECT  0x0001
-#define  HCI_EVNT_WLAN_DISCONNECT \
-                                0x0002
-#define  HCI_EVNT_WLAN_IOCTL_ADD_PROFILE  \
-                                0x0005
-
-
-#define  HCI_EVNT_SOCKET              HCI_CMND_SOCKET
-#define  HCI_EVNT_BIND                HCI_CMND_BIND
-#define  HCI_EVNT_RECV                HCI_CMND_RECV
-#define  HCI_EVNT_ACCEPT              HCI_CMND_ACCEPT
-#define  HCI_EVNT_LISTEN              HCI_CMND_LISTEN
-#define  HCI_EVNT_CONNECT             HCI_CMND_CONNECT
-#define  HCI_EVNT_SELECT              HCI_CMND_BSD_SELECT
-#define  HCI_EVNT_CLOSE_SOCKET        HCI_CMND_CLOSE_SOCKET
-#define  HCI_EVNT_RECVFROM            HCI_CMND_RECVFROM
-#define  HCI_EVNT_SETSOCKOPT          HCI_CMND_SETSOCKOPT
-#define  HCI_EVNT_GETSOCKOPT          HCI_CMND_GETSOCKOPT
-#define  HCI_EVNT_BSD_GETHOSTBYNAME   HCI_CMND_GETHOSTNAME
-#define  HCI_EVNT_MDNS_ADVERTISE      HCI_CMND_MDNS_ADVERTISE
-
-#define  HCI_EVNT_SEND                0x1003
-#define  HCI_EVNT_WRITE               0x100E
-#define  HCI_EVNT_SENDTO              0x100F
-
-#define HCI_EVNT_PATCHES_REQ          0x1000
-
-#define HCI_EVNT_UNSOL_BASE           0x4000
-
-#define HCI_EVNT_WLAN_UNSOL_BASE     (0x8000)
-
-#define HCI_EVNT_WLAN_UNSOL_CONNECT             (0x0001 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_UNSOL_DISCONNECT          (0x0002 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_UNSOL_INIT                (0x0004 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_TX_COMPLETE               (0x0008 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_UNSOL_DHCP                (0x0010 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_ASYNC_PING_REPORT         (0x0040 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE  (0x0080 + HCI_EVNT_WLAN_UNSOL_BASE)
-#define HCI_EVNT_WLAN_KEEPALIVE                 (0x0200  + HCI_EVNT_WLAN_UNSOL_BASE)
-#define    HCI_EVNT_BSD_TCP_CLOSE_WAIT          (0x0800 + HCI_EVNT_WLAN_UNSOL_BASE)
-
-#define HCI_EVNT_DATA_UNSOL_FREE_BUFF \
-                                0x4100
-
-#define HCI_EVNT_NVMEM_CREATE_ENTRY \
-                                HCI_CMND_NVMEM_CREATE_ENTRY
-#define HCI_EVNT_NVMEM_SWAP_ENTRY HCI_CMND_NVMEM_SWAP_ENTRY
-
-#define HCI_EVNT_NVMEM_READ     HCI_CMND_NVMEM_READ
-#define HCI_EVNT_NVMEM_WRITE    (0x0202)
-
-#define HCI_EVNT_READ_SP_VERSION      \
-                HCI_CMND_READ_SP_VERSION
-
-#define  HCI_EVNT_INPROGRESS    0xFFFF
-
-
-#define HCI_DATA_RECVFROM       0x84
-#define HCI_DATA_RECV           0x85
-#define HCI_DATA_NVMEM          0x91
-
-#define HCI_EVENT_CC3000_CAN_SHUT_DOWN 0x99
-
-// Prototypes for the structures for HCI APIs.
-#define HCI_DATA_HEADER_SIZE        (5)
-#define HCI_EVENT_HEADER_SIZE       (5)
-#define HCI_DATA_CMD_HEADER_SIZE    (5)
-#define HCI_PATCH_HEADER_SIZE       (6)
-
-#define HCI_PACKET_TYPE_OFFSET      (0)
-#define HCI_PACKET_ARGSIZE_OFFSET   (2)
-#define HCI_PACKET_LENGTH_OFFSET    (3)
-
-
-#define HCI_EVENT_OPCODE_OFFSET     (1)
-#define HCI_EVENT_LENGTH_OFFSET     (3)
-#define HCI_EVENT_STATUS_OFFSET     (4)
-#define HCI_DATA_LENGTH_OFFSET      (3)
-
-#endif
--- a/cc3000_hostdriver_mbedsocket/cc3000_wlan.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,693 +0,0 @@
-/*****************************************************************************
-*
-*  C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
-*  Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
-*  provided help.
-*
-*  This version of "host driver" uses CC3000 Host Driver Implementation. Thus
-*  read the following copyright:
-*
-*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
-*
-*  Redistribution and use in source and binary forms, with or without
-*  modification, are permitted provided that the following conditions
-*  are met:
-*
-*    Redistributions of source code must retain the above copyright
-*    notice, this list of conditions and the following disclaimer.
-*
-*    Redistributions in binary form must reproduce the above copyright
-*    notice, this list of conditions and the following disclaimer in the
-*    documentation and/or other materials provided with the
-*    distribution.
-*
-*    Neither the name of Texas Instruments Incorporated nor the names of
-*    its contributors may be used to endorse or promote products derived
-*    from this software without specific prior written permission.
-*
-*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*****************************************************************************/
-#include "cc3000.h"
-
-namespace mbed_cc3000 {
-
-cc3000_wlan::cc3000_wlan(cc3000_simple_link &simple_link, cc3000_event &event, cc3000_spi &spi, cc3000_hci &hci) :
-    _simple_link(simple_link), _event(event), _spi(spi), _hci(hci) {
-
-}
-
-cc3000_wlan::~cc3000_wlan() {
-
-}
-
-void cc3000_wlan::simpleLink_init_start(uint16_t patches_available_host) {
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);
-
-    UINT8_TO_STREAM(args, ((patches_available_host) ? SL_PATCHES_REQUEST_FORCE_HOST : SL_PATCHES_REQUEST_DEFAULT));
-
-    // IRQ Line asserted - send HCI_CMND_SIMPLE_LINK_START to CC3000
-    _hci.command_send(HCI_CMND_SIMPLE_LINK_START, ptr, WLAN_SL_INIT_START_PARAMS_LEN);
-    _event.simplelink_wait_event(HCI_CMND_SIMPLE_LINK_START, 0);
-}
-
-void cc3000_wlan::start(uint16_t patches_available_host) {
-    uint32_t spi_irq_state;
-
-    _simple_link.set_sent_packets(0);
-    _simple_link.set_number_of_released_packets(0);
-    _simple_link.set_op_code(0);
-    _simple_link.set_number_free_buffers(0);
-    _simple_link.set_buffer_length(0);
-    _simple_link.set_buffer_size(0);
-    _simple_link.set_pending_data(0);
-    _simple_link.set_transmit_error(0);
-    _simple_link.set_data_received_flag(0);
-    _simple_link.set_buffer_size(0);
-
-    // init spi
-    _spi.open();
-    // Check the IRQ line
-    spi_irq_state = _spi.wlan_irq_read();
-    // ASIC 1273 chip enable: toggle WLAN EN line
-    _spi.set_wlan_en(WLAN_ENABLE);
-
-    if (spi_irq_state)
-    {
-        // wait till the IRQ line goes low
-        while(_spi.wlan_irq_read() != 0)
-        {
-        }
-    }
-    else
-    {
-        // wait till the IRQ line goes high and then low
-        while(_spi.wlan_irq_read() == 0)
-        {
-        }
-        while(_spi.wlan_irq_read() != 0)
-        {
-        }
-    }
-    simpleLink_init_start(patches_available_host);
-
-    // Read Buffer's size and finish
-    _hci.command_send(HCI_CMND_READ_BUFFER_SIZE, _simple_link.get_transmit_buffer(), 0);
-    _event.simplelink_wait_event(HCI_CMND_READ_BUFFER_SIZE, 0);
-}
-
-
-void cc3000_wlan::stop() {
-    // ASIC 1273 chip disable
-    _spi.set_wlan_en( WLAN_DISABLE );
-
-    // Wait till IRQ line goes high...
-    while(_spi.wlan_irq_read() == 0)
-    {
-    }
-
-    _spi.close();
-}
-
-
-int32_t cc3000_wlan::disconnect() {
-    int32_t ret;
-    uint8_t *ptr;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-
-    _hci.command_send(HCI_CMND_WLAN_DISCONNECT, ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_DISCONNECT, &ret);
-    errno = ret;
-
-    return(ret);
-}
-
-
-int32_t cc3000_wlan::ioctl_set_connection_policy(uint32_t should_connect_to_open_ap,
-                                      uint32_t use_fast_connect,
-                                      uint32_t use_profiles) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, should_connect_to_open_ap);
-    args = UINT32_TO_STREAM(args, use_fast_connect);
-    args = UINT32_TO_STREAM(args, use_profiles);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, ptr, WLAN_SET_CONNECTION_POLICY_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, &ret);
-
-    return(ret);
-}
-
-
-int32_t cc3000_wlan::ioctl_del_profile(uint32_t index) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, index);
-    ret = EFAIL;
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, ptr, WLAN_DEL_PROFILE_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, &ret);
-
-    return(ret);
-}
-
-int32_t cc3000_wlan::set_event_mask(uint32_t mask) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-
-
-    if ((mask & HCI_EVNT_WLAN_TX_COMPLETE) == HCI_EVNT_WLAN_TX_COMPLETE)
-    {
-        _simple_link.set_tx_complete_signal(0);
-
-        // Since an event is a virtual event - i.e. it is not coming from CC3000
-        // there is no need to send anything to the device if it was an only event
-        if (mask == HCI_EVNT_WLAN_TX_COMPLETE)
-        {
-            return 0;
-        }
-
-        mask &= ~HCI_EVNT_WLAN_TX_COMPLETE;
-        mask |= HCI_EVNT_WLAN_UNSOL_BASE;
-    }
-    else
-    {
-        _simple_link.set_tx_complete_signal(1);
-    }
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, mask);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_EVENT_MASK, ptr, WLAN_SET_MASK_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_EVENT_MASK, &ret);
-
-    return(ret);
-}
-
-
-int32_t cc3000_wlan::smart_config_start(uint32_t encrypted_flag) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);
-
-    // Fill in HCI packet structure
-    args = UINT32_TO_STREAM(args, encrypted_flag);
-    ret = EFAIL;
-
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, ptr, WLAN_SMART_CONFIG_START_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, &ret);
-
-    return(ret);
-}
-
-
-int32_t cc3000_wlan::smart_config_stop(void) {
-    int32_t ret;
-    uint8_t *ptr;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, &ret);
-
-    return(ret);
-}
-
-int32_t cc3000_wlan::smart_config_set_prefix(uint8_t *new_prefix) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    if (new_prefix == NULL)
-        return ret;
-    else    // with the new Smart Config, prefix must be TTT
-    {
-        *new_prefix = 'T';
-        *(new_prefix + 1) = 'T';
-        *(new_prefix + 2) = 'T';
-    }
-
-    ARRAY_TO_STREAM(args, new_prefix, SL_SIMPLE_CONFIG_PREFIX_LENGTH);
-
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, ptr, SL_SIMPLE_CONFIG_PREFIX_LENGTH);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, &ret);
-
-    return(ret);
-}
-
-#ifndef CC3000_TINY_DRIVER
-int32_t cc3000_wlan::connect(uint32_t sec_type, const uint8_t *ssid, int32_t ssid_len, uint8_t *bssid,
-              uint8_t *key, int32_t key_len) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-    uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0};
-
-    ret      = EFAIL;
-    ptr      = _simple_link.get_transmit_buffer();
-    args     = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in command buffer
-    args = UINT32_TO_STREAM(args, 0x0000001c);
-    args = UINT32_TO_STREAM(args, ssid_len);
-    args = UINT32_TO_STREAM(args, sec_type);
-    args = UINT32_TO_STREAM(args, 0x00000010 + ssid_len);
-    args = UINT32_TO_STREAM(args, key_len);
-    args = UINT16_TO_STREAM(args, 0);
-
-    // padding shall be zeroed
-    if(bssid)
-    {
-        ARRAY_TO_STREAM(args, bssid, ETH_ALEN);
-    }
-    else
-    {
-        ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
-    }
-
-    ARRAY_TO_STREAM(args, ssid, ssid_len);
-
-    if(key_len && key)
-    {
-        ARRAY_TO_STREAM(args, key, key_len);
-    }
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_CONNECT, ptr, WLAN_CONNECT_PARAM_LEN + ssid_len + key_len - 1);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_CONNECT, &ret);
-    errno = ret;
-
-    return(ret);
-}
-
-int32_t cc3000_wlan::add_profile(uint32_t sec_type,
-                      uint8_t* ssid,
-                      uint32_t ssid_length,
-                      uint8_t *b_ssid,
-                      uint32_t priority,
-                      uint32_t pairwise_cipher_or_tx_key_len,
-                      uint32_t group_cipher_tx_key_index,
-                      uint32_t key_mgmt,
-                      uint8_t* pf_or_key,
-                      uint32_t pass_phrase_len) {
-    uint16_t arg_len = 0x00;
-    int32_t ret;
-    uint8_t *ptr;
-    int32_t i = 0;
-    uint8_t *args;
-    uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0};
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    args = UINT32_TO_STREAM(args, sec_type);
-
-    // Setup arguments in accordance with the security type
-    switch (sec_type)
-    {
-        //OPEN
-    case WLAN_SEC_UNSEC:
-        {
-            args = UINT32_TO_STREAM(args, 0x00000014);
-            args = UINT32_TO_STREAM(args, ssid_length);
-            args = UINT16_TO_STREAM(args, 0);
-            if(b_ssid)
-            {
-                ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
-            }
-            else
-            {
-                ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
-            }
-            args = UINT32_TO_STREAM(args, priority);
-            ARRAY_TO_STREAM(args, ssid, ssid_length);
-
-            arg_len = WLAN_ADD_PROFILE_NOSEC_PARAM_LEN + ssid_length;
-        }
-        break;
-
-        //WEP
-    case WLAN_SEC_WEP:
-        {
-            args = UINT32_TO_STREAM(args, 0x00000020);
-            args = UINT32_TO_STREAM(args, ssid_length);
-            args = UINT16_TO_STREAM(args, 0);
-            if(b_ssid)
-            {
-                ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
-            }
-            else
-            {
-                ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
-            }
-            args = UINT32_TO_STREAM(args, priority);
-            args = UINT32_TO_STREAM(args, 0x0000000C + ssid_length);
-            args = UINT32_TO_STREAM(args, pairwise_cipher_or_tx_key_len);
-            args = UINT32_TO_STREAM(args, group_cipher_tx_key_index);
-            ARRAY_TO_STREAM(args, ssid, ssid_length);
-
-            for(i = 0; i < 4; i++)
-            {
-                uint8_t *p = &pf_or_key[i * pairwise_cipher_or_tx_key_len];
-
-                ARRAY_TO_STREAM(args, p, pairwise_cipher_or_tx_key_len);
-            }
-
-            arg_len = WLAN_ADD_PROFILE_WEP_PARAM_LEN + ssid_length +
-                pairwise_cipher_or_tx_key_len * 4;
-
-        }
-        break;
-
-        //WPA
-        //WPA2
-    case WLAN_SEC_WPA:
-    case WLAN_SEC_WPA2:
-        {
-            args = UINT32_TO_STREAM(args, 0x00000028);
-            args = UINT32_TO_STREAM(args, ssid_length);
-            args = UINT16_TO_STREAM(args, 0);
-            if(b_ssid)
-            {
-                ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
-            }
-            else
-            {
-                ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
-            }
-            args = UINT32_TO_STREAM(args, priority);
-            args = UINT32_TO_STREAM(args, pairwise_cipher_or_tx_key_len);
-            args = UINT32_TO_STREAM(args, group_cipher_tx_key_index);
-            args = UINT32_TO_STREAM(args, key_mgmt);
-            args = UINT32_TO_STREAM(args, 0x00000008 + ssid_length);
-            args = UINT32_TO_STREAM(args, pass_phrase_len);
-            ARRAY_TO_STREAM(args, ssid, ssid_length);
-            ARRAY_TO_STREAM(args, pf_or_key, pass_phrase_len);
-
-            arg_len = WLAN_ADD_PROFILE_WPA_PARAM_LEN + ssid_length + pass_phrase_len;
-        }
-
-        break;
-    }
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_ADD_PROFILE, ptr, arg_len);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_ADD_PROFILE, &ret);
-
-    return(ret);
-}
-
-int32_t cc3000_wlan::ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results) {
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, scan_timeout);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, ptr, WLAN_GET_SCAN_RESULTS_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, results);
-
-    return(0);
-}
-
-int32_t cc3000_wlan::ioctl_set_scan_params(uint32_t enable,
-                                uint32_t min_dwell_time,
-                                uint32_t max_dwell_time,
-                                uint32_t num_probe_requests,
-                                uint32_t channel_mask,
-                                int32_t rssi_threshold,
-                                uint32_t snr_threshold,
-                                uint32_t default_tx_power,
-                                uint32_t *interval_list) {
-    uint32_t  uiRes;
-    uint8_t *ptr;
-    uint8_t *args;
-
-    ptr = _simple_link.get_transmit_buffer();
-    args = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in temporary command buffer
-    args = UINT32_TO_STREAM(args, 36);
-    args = UINT32_TO_STREAM(args, enable);
-    args = UINT32_TO_STREAM(args, min_dwell_time);
-    args = UINT32_TO_STREAM(args, max_dwell_time);
-    args = UINT32_TO_STREAM(args, num_probe_requests);
-    args = UINT32_TO_STREAM(args, channel_mask);
-    args = UINT32_TO_STREAM(args, rssi_threshold);
-    args = UINT32_TO_STREAM(args, snr_threshold);
-    args = UINT32_TO_STREAM(args, default_tx_power);
-    ARRAY_TO_STREAM(args, interval_list, sizeof(uint32_t) * SL_SET_SCAN_PARAMS_INTERVAL_LIST_SIZE);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_SET_SCANPARAM, ptr, WLAN_SET_SCAN_PARAMS_LEN);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SET_SCANPARAM, &uiRes);
-
-    return(uiRes);
-}
-
-int32_t cc3000_wlan::ioctl_statusget(void) {
-    int32_t ret;
-    uint8_t *ptr;
-
-    ret = EFAIL;
-    ptr = _simple_link.get_transmit_buffer();
-
-    _hci.command_send(HCI_CMND_WLAN_IOCTL_STATUSGET,ptr, 0);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_STATUSGET, &ret);
-
-    return(ret);
-}
-
-#else
-int32_t cc3000_wlan::wlan_add_profile(uint32_t sec_type,
-                      uint8_t *ssid,
-                      uint32_t ssid_length,
-                      uint8_t *b_ssid,
-                      uint32_t priority,
-                      uint32_t pairwise_cipher_or_tx_key_len,
-                      uint32_t group_cipher_tx_key_index,
-                      uint32_t key_mgmt,
-                      uint8_t* pf_or_key,
-                      uint32_t pass_phrase_length)
-{
-    return -1;
-}
-
-int32_t cc3000_wlan::connect(const uint8_t *ssid, int32_t ssid_len) {
-    int32_t ret;
-    uint8_t *ptr;
-    uint8_t *args;
-    uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0};
-
-    ret      = EFAIL;
-    ptr      = _simple_link.get_transmit_buffer();
-    args     = (ptr + HEADERS_SIZE_CMD);
-
-    // Fill in command buffer
-    args = UINT32_TO_STREAM(args, 0x0000001c);
-    args = UINT32_TO_STREAM(args, ssid_len);
-    args = UINT32_TO_STREAM(args, 0);
-    args = UINT32_TO_STREAM(args, 0x00000010 + ssid_len);
-    args = UINT32_TO_STREAM(args, 0);
-    args = UINT16_TO_STREAM(args, 0);
-
-    // padding shall be zeroed
-    ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
-    ARRAY_TO_STREAM(args, ssid, ssid_len);
-
-    // Initiate a HCI command
-    _hci.command_send(HCI_CMND_WLAN_CONNECT, ptr, WLAN_CONNECT_PARAM_LEN + ssid_len  - 1);
-
-    // Wait for command complete event
-    _event.simplelink_wait_event(HCI_CMND_WLAN_CONNECT, &ret);
-    errno = ret;
-
-    return(ret);
-}
-#endif
-
-
-
-#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
-int32_t cc3000_wlan::smart_config_process(void) {
-    int32_t  returnValue;
-    uint32_t ssidLen, keyLen;
-    uint8_t *decKeyPtr;
-    uint8_t *ssidPtr;
-
-    // read the key from EEPROM - fileID 12
-    returnValue = aes_read_key(key);
-
-    if (returnValue != 0)
-        return returnValue;
-
-    // read the received data from fileID #13 and parse it according to the followings:
-    // 1) SSID LEN - not encrypted
-    // 2) SSID - not encrypted
-    // 3) KEY LEN - not encrypted. always 32 bytes long
-    // 4) Security type - not encrypted
-    // 5) KEY - encrypted together with true key length as the first byte in KEY
-    //     to elaborate, there are two corner cases:
-    //        1) the KEY is 32 bytes long. In this case, the first byte does not represent KEY length
-    //        2) the KEY is 31 bytes long. In this case, the first byte represent KEY length and equals 31
-    returnValue = nvmem_read(NVMEM_SHARED_MEM_FILEID, SMART_CONFIG_PROFILE_SIZE, 0, profileArray);
-
-    if (returnValue != 0)
-        return returnValue;
-
-    ssidPtr = &profileArray[1];
-
-    ssidLen = profileArray[0];
-
-    decKeyPtr = &profileArray[profileArray[0] + 3];
-
-    aes_decrypt(decKeyPtr, key);
-    if (profileArray[profileArray[0] + 1] > 16)
-        aes_decrypt((uint8_t *)(decKeyPtr + 16), key);
-
-    if (*(uint8_t *)(decKeyPtr +31) != 0)
-    {
-        if (*decKeyPtr == 31)
-        {
-            keyLen = 31;
-            decKeyPtr++;
-        }
-        else
-        {
-            keyLen = 32;
-        }
-    }
-    else
-    {
-        keyLen = *decKeyPtr;
-        decKeyPtr++;
-    }
-
-    // add a profile
-    switch (profileArray[profileArray[0] + 2])
-    {
-    case WLAN_SEC_UNSEC://None
-         {
-            returnValue = wlan_add_profile(profileArray[profileArray[0] + 2],     // security type
-                                           ssidPtr,                               // SSID
-                                           ssidLen,                               // SSID length
-                                           NULL,                                  // BSSID
-                                           1,                                     // Priority
-                                           0, 0, 0, 0, 0);
-
-            break;
-         }
-
-    case WLAN_SEC_WEP://WEP
-        {
-            returnValue = wlan_add_profile(profileArray[profileArray[0] + 2],     // security type
-                                           ssidPtr,                               // SSID
-                                           ssidLen,                               // SSID length
-                                           NULL,                                  // BSSID
-                                           1,                                     // Priority
-                                           keyLen,                                // KEY length
-                                           0,                                     // KEY index
-                                           0,
-                                           decKeyPtr,                             // KEY
-                                           0);
-
-            break;
-        }
-
-    case WLAN_SEC_WPA:  //WPA
-    case WLAN_SEC_WPA2: //WPA2
-        {
-            returnValue = wlan_add_profile(WLAN_SEC_WPA2,     // security type
-                                           ssidPtr,
-                                           ssidLen,
-                                           NULL,              // BSSID
-                                           1,                 // Priority
-                                           0x18,              // PairwiseCipher
-                                           0x1e,              // GroupCipher
-                                           2,                 // KEY management
-                                           decKeyPtr,         // KEY
-                                           keyLen);           // KEY length
-
-            break;
-        }
-    }
-
-    return returnValue;
-}
-#endif
-
-}
--- a/init.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ b/init.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -1,65 +1,66 @@
-/* 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.
- */
-#include "main.h"
-#include "mbed.h"
-
-#if (MY_BOARD == WIGO)
-
-#include "NVIC_set_all_priorities.h"
-
-/**
- *  \brief Wi-Go initialization
- *  \param none
- *  \return none
- */
-void init() {
-
-    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
+/* 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.
+ */
+#include "main.h"
+#include "mbed.h"
+
+#if (MY_BOARD == WIGO)
+
+#include "NVIC_set_all_priorities.h"
+
+/**
+ *  \brief Wi-Go initialization
+ *  \param none
+ *  \return none
+ */
+void init() {
 
+    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
+
+
--- a/main.cpp	Fri Oct 25 08:49:08 2013 +0000
+++ b/main.cpp	Sun Dec 01 15:06:46 2013 +0000
@@ -16,6 +16,8 @@
 #include "mbed.h"
 #include "cc3000.h"
 #include "main.h"
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
 
 using namespace mbed_cc3000;
 
@@ -24,6 +26,7 @@
 /* cc3000 module declaration specific for user's board. Check also init() */
 #if (MY_BOARD == WIGO)
 
+#include "I2C_busreset.h"
 #include "defLED.h"
 #include "TSISensor.h"
 #include "TEMT6200.h"
@@ -33,7 +36,8 @@
 #include "MPL3115A2.h"
 #include "Wi-Go_eCompass_Lib_V3.h"
 #include "demo.h"
-//#include "run_exosite.h"
+#include "doTCPIP.h"
+#include "run_exosite.h"
 
 #define FCOUNTSPERG  4096.0F // sensor specific: MMA8451 provide 4096 counts / g in 2g mode
 #define FCOUNTSPERUT   10.0F // sensor specific: MAG3110 provide 10 counts / uT
@@ -48,7 +52,9 @@
 DigitalOut led2 (PTB9);
 DigitalOut led3 (PTB10);
 
-cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), PORTA_IRQn);
+cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), "", "", NONE, true);
+TCPSocketConnection socket;
+
 Serial pc(USBTX, USBRX);
 
 // Slide sensor
@@ -68,7 +74,8 @@
 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
 
 // Magnetometer
-MAG3110 mag(PTE0, PTE1);
+#define MAG3110_I2C_ADDRESS (0x0e<<1)
+MAG3110 mag(PTE0, PTE1, MAG3110_I2C_ADDRESS);
 
 // altimeter-Pressure-Temperature (apt)
 #define MPL3115A2_I2C_ADDRESS (0x60<<1)
@@ -117,9 +124,15 @@
     signed short resultx, resulty, resultz;
     if(acc.isDataAvailable())
     {
-        acc.getAccRawX(&resultx);
-        acc.getAccRawY(&resulty);
-        acc.getAccRawZ(&resultz);
+        resultx = acc.readReg(0x01)<<8;
+        resultx |= acc.readReg(0x02);
+        resultx = resultx >> 2;
+        resulty = acc.readReg(0x03)<<8;
+        resulty |= acc.readReg(0x04);
+        resulty = resulty >> 2;
+        resultz = acc.readReg(0x05)<<8;
+        resultz |= acc.readReg(0x06);
+        resultz = resultz >> 2;
         if(compass_type == NED_COMPASS)
         {
             axis6.acc_x = resultx;
@@ -149,43 +162,63 @@
 
 void readTempAlt(void) // We don't use the fractional data
 {
-    unsigned char raw_data[5];
-    if(apt.getAllDataRaw(&raw_data[0]))
-    {
-        axis6.temp = raw_data[3];
+    unsigned char raw_data[2];
+    if(apt.getAltimeterRaw(&raw_data[0]))
         axis6.alt = ((raw_data[0] << 8) | raw_data[1]);
-
-    }
+    if(apt.getTemperatureRaw(&raw_data[0]))
+        axis6.temp = raw_data[0];
 }
 
 void readCompass( void )
 {
-    if(compass_type == NED_COMPASS)
+    if(mag.isDataAvailable())
     {
-        axis6.mag_y = mag.readVal(MAG_OUT_X_MSB);      // x & y swapped to compenste for PCB layout
-        axis6.mag_x = mag.readVal(MAG_OUT_Y_MSB);      // 
-        axis6.mag_z = mag.readVal(MAG_OUT_Z_MSB);      //
-    }
-    if(compass_type == ANDROID_COMPASS)
-    {
-        axis6.mag_x = mag.readVal(MAG_OUT_X_MSB);      //
-        axis6.mag_y = mag.readVal(MAG_OUT_Y_MSB);      // 
-        axis6.mag_z = -1 * mag.readVal(MAG_OUT_Z_MSB); // negate to reverse axis of Z to conform to Android coordinate system
+        uint8_t  mx_msb, my_msb, mz_msb;
+        uint8_t  mx_lsb, my_lsb, mz_lsb;
+
+        mx_msb = mag.readReg(0x01);
+        mx_lsb = mag.readReg(0x02);
+        my_msb = mag.readReg(0x03);
+        my_lsb = mag.readReg(0x04);
+        mz_msb = mag.readReg(0x05);
+        mz_lsb = mag.readReg(0x06);
+
+        if(compass_type == NED_COMPASS)
+        {
+            axis6.mag_y = (((mx_msb << 8) | mx_lsb));      // x & y swapped to compensate for PCB layout
+            axis6.mag_x = (((my_msb << 8) | my_lsb));
+            axis6.mag_z = (((mz_msb << 8) | mz_lsb));
+        }
+        if(compass_type == ANDROID_COMPASS)
+        {
+            axis6.mag_x = (((mx_msb << 8) | mx_lsb));
+            axis6.mag_y = (((my_msb << 8) | my_lsb));
+            axis6.mag_z = -1 * (((mz_msb << 8) | mz_lsb)); // negate to reverse axis of Z to conform to Android coordinate system
+        }
+        if(compass_type == WINDOWS_COMPASS)
+        {
+            axis6.mag_x = (((mx_msb << 8) | mx_lsb));
+            axis6.mag_y = (((my_msb << 8) | my_lsb));
+            axis6.mag_z = -1 * (((mz_msb << 8) | mz_lsb));
+        }
+        axis6.fmx = axis6.mag_x;
+        axis6.fmy = axis6.mag_y;
+        axis6.fmz = axis6.mag_z;
+        axis6.fUTmx = axis6.fmx * fcountperut;
+        axis6.fUTmy = axis6.fmy * fcountperut;
+        axis6.fUTmz = axis6.fmz * fcountperut;
     }
-    if(compass_type == WINDOWS_COMPASS)
-    {
-        axis6.mag_x = mag.readVal(MAG_OUT_X_MSB);      //
-        axis6.mag_y = mag.readVal(MAG_OUT_Y_MSB);      // 
-        axis6.mag_z = -1 * mag.readVal(MAG_OUT_Z_MSB); //
-    }
-    axis6.fmx = axis6.mag_x;
-    axis6.fmy = axis6.mag_y;
-    axis6.fmz = axis6.mag_z;
-    axis6.fUTmx = axis6.fmx * fcountperut;
-    axis6.fUTmy = axis6.fmy * fcountperut;
-    axis6.fUTmz = axis6.fmz * fcountperut;
 }   
 
+void axis6Print(void)
+{
+    char *compass_points[9] = {"North", "N-East", "East", "S-East", "South", "S-West", "West", "N-West", "North"};
+    signed short compass_bearing = (axis6.compass + 23) / 45;
+    printf("Compass : Roll=%-d  Pitch=%-d  Yaw=%-d [%s]\r\n", axis6.roll, axis6.pitch, axis6.yaw, compass_points[compass_bearing]);
+    printf("Accel   : X= %1.2f, Y= %1.2f, Z= %1.2f\r\n", axis6.fGax, axis6.fGay, axis6.fGaz);
+    printf("Magneto : X= %3.1f, Y= %3.1f, Z= %3.1f\r\n\r\n", axis6.fUTmx, axis6.fUTmy, axis6.fUTmz);
+}
+
 void set_dir_LED(void)
 {
     RED_OFF; GREEN_OFF; BLUE_OFF;
@@ -234,7 +267,7 @@
         axis6.timestamp++;
         if(!server_running) set_dir_LED(); // Set the LEDs based on direction when nothing else is usng them
     }
-    if(ttt == 20)//100)
+    if(ttt == 100)//systick = 0.005 : 100 - systick = 0.025 : 20
     {
         LED_D1_ON;
         if(seconds && (seconds < 15)) calibrate_eCompass();
@@ -242,7 +275,7 @@
         axis6.light = ambi.readRaw(); // Light Sensor    
         HsecondFlag = 1; // A general purpose flag for things that need to happen every 500ms   
     }
-    if(ttt >= 40)//200)
+    if(ttt >= 200)//systick = 0.005 : 200 - systick = 0.025 : 40
     {
         LED_D1_OFF;
         ttt = 1;  
@@ -253,7 +286,7 @@
         secondFlag = 1; // A general purpose flag for things that need to happen once a second
         HsecondFlag = 1;
         seconds++;
-        if(!(seconds & 0x1F)) do_mDNS = 1;          
+        if(!(seconds & 0x1F)) do_mDNS = 1;
     } else ttt++;
 }
 
@@ -277,7 +310,9 @@
  */
 void print_cc3000_info() {
     uint8_t myMAC[8];
-
+    uint8_t spVER[5];
+    wifi._nvmem.read_sp_version(spVER);
+    printf("SP Version (TI) : %d %d %d %d %d\r\n", spVER[0], spVER[1], spVER[2], spVER[3], spVER[4]);
     printf("MAC address + cc3000 info \r\n");
     wifi.get_user_file_info((uint8_t *)&user_info, sizeof(user_info));
     wifi.get_mac_address(myMAC);
@@ -371,39 +406,42 @@
     HsecondFlag = 0;
     GREEN_ON;
 
+    // Unlock I2C bus if blocked by a device
+    I2C_busreset();
+
     pc.baud(115200);
 
     // set current to 500mA since we're turning on the Wi-Fi
     Batt.init(CHRG_500MA);
 
-    // Set MPL3115 to altimeter mode - oversample rate = 128
-    apt.Oversample_Ratio(OVERSAMPLE_RATIO_128);
-    apt.Altimeter_Mode();
-
     //Init LEDs
     initLEDs();
-
     // Read the Magnetometer a couple of times to initalize
     for(loop=0 ; loop < 5 ; loop++)
     {
-        while(!(mag.readReg(MAG_DR_STATUS) && 0x08));
-        readCompass();
+        temp = mag.readReg(0x01);
+        temp = mag.readReg(0x02);
+        temp = mag.readReg(0x03);
+        temp = mag.readReg(0x04);
+        temp = mag.readReg(0x05);
+        temp = mag.readReg(0x06);
+        wait_ms(50);
     }
 
     init_eCompass();
 
-    // Start 5ms Ticker
-    systick.attach(&SysTick_Handler, 0.025);
-
+    // Start Ticker
+    systick.attach(&SysTick_Handler, 0.005);
     // Trigger a WLAN device
-    wifi.start(0);
+    wifi.init();
+    //wifi.start(0);
     printf("CC3000 Wi-Go IOT demo.\r\n");
     print_cc3000_info();
     server_running = 1;
     newData = 0;    
     GREEN_ON;
 
-    if(!user_info.FTC && USE_SMART_CONFIG)
+    if(!user_info.FTC)
     {
         do_FTC(); // Call First Time Configuration if SmartConfig has not been run
         printf("Please restart your board. \r\n");
@@ -495,30 +533,11 @@
     RED_OFF; GREEN_OFF; BLUE_OFF; 
 
     printf("\r\nAttempting SSID Connection. \r\n");
-#if (USE_SMART_CONFIG == 1)
-        wifi._wlan.ioctl_set_connection_policy(0, 1, 1);
-#else
-    wifi._wlan.ioctl_set_connection_policy(0, 0, 0);
-    #ifndef CC3000_TINY_DRIVER
-        #ifdef AP_KEY
-            connect_to_ssid(SSID, AP_KEY, AP_SECURITY);
-        #else
-            connect_to_ssid(SSID);
-        #endif
-    #else
-        connect_to_ssid(SSID);
-    #endif
-#endif
-
-    printf("DHCP request \r\n");
-    while (wifi.is_dhcp_configured() == false)
-    {
-         wait_ms(500);
-         printf("  Waiting for dhcp to be set. \r\n");
+    if (wifi.connect() == -1) {
+        printf("Failed to connect. Please verify connection details and try again. \r\n");
+    } else {
+        printf("Connected - IP address: %s \r\n",wifi.getIPAddress());
     }
-    tNetappIpconfigRetArgs ipinfo2;
-    wifi.get_ip_config(&ipinfo2); // data is returned in the ipinfo2 structure
-    printf("DHCP assigned IP Address = %d.%d.%d.%d \r\n", ipinfo2.aucIP[3], ipinfo2.aucIP[2], ipinfo2.aucIP[1], ipinfo2.aucIP[0]);
     LED_D3_ON;
 
     server_running = 0;
@@ -536,12 +555,12 @@
         compass_type = NED_COMPASS;
         init_eCompass();
         seconds = 0;
-//        run_exosite();
+        run_exosite(&socket);
     }
     init_eCompass();
     seconds = 0;
     // Run TCP/IP Connection to host - Sensor Fusion App
-//    runTCPIPserver();
+    runTCPIPserver();
 
 }
 
--- a/main.h	Fri Oct 25 08:49:08 2013 +0000
+++ b/main.h	Sun Dec 01 15:06:46 2013 +0000
@@ -22,22 +22,11 @@
 
 #define MY_BOARD WIGO
 
-// 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 1
-
  // Default SSID Settings
 #define AP_KEY       "test"
 #define AP_SECURITY  WPA2            // WPA2 must be enabled for use with iPhone or Android phone hotspot!
 #define SSID         "test"
 
-
-
 void init();
 
 #endif
--- a/mbed.bld	Fri Oct 25 08:49:08 2013 +0000
+++ b/mbed.bld	Sun Dec 01 15:06:46 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/5798e58a58b1
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/673126e12c73
\ No newline at end of file