cc3000 hostdriver with the mbed socket interface

Dependents:   cc3000_hello_world_demo cc3000_simple_socket_demo cc3000_ntp_demo cc3000_ping_demo ... more

Files at this revision

API Documentation at this revision

Comitter:
Kojto
Date:
Wed Nov 06 17:56:25 2013 +0100
Parent:
44:960b73df5981
Child:
46:ca8c234997c0
Commit message:
complete Ethernet interface

- code clean-up
- IRQ - faster enable/disable, a flag to process an IRQ
- EthernetInterface
- TINY_DRIVER compilation errors correction

Changed in this revision

Socket/Endpoint.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/Socket.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000.h Show annotated file Show diff for this revision Revisions of this file
cc3000_event.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_hci.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_netapp.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_nvmem.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_security.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_simplelink.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_socket.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_spi.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_wlan.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Socket/Endpoint.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/Socket/Endpoint.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -23,7 +23,7 @@
  #include "cc3000.h"
 
 /* Copied from lwip */
-static char *inet_ntoa_r(const in_addr addr, char *buf, int buflen)
+static char *cc3000_inet_ntoa_r(const in_addr addr, char *buf, int buflen)
 {
   uint32_t s_addr;
   char inv[3];
@@ -78,7 +78,6 @@
 int Endpoint::set_address(const char* host, const int port) {
     reset_address();
 
-    int resolveRetCode;
     char address[5];
     char *p_address = address;
 
@@ -92,18 +91,23 @@
     std::memset(_ipAddress,0,sizeof(_ipAddress));
 
     if (result != 4) {
+ #ifndef CC3000_TINY_DRIVER
         //Resolve DNS address or populate hard-coded IP address
         uint32_t address_integer;
+        int resolveRetCode;
         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));
+            cc3000_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
+        return -1;
+#endif
     } else {
         std::memcpy((char*)&_remote_host.sin_addr.s_addr, p_address, 4);
     }
@@ -124,7 +128,7 @@
 
 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));
+            cc3000_inet_ntoa_r(_remote_host.sin_addr, _ipAddress, sizeof(_ipAddress));
     return _ipAddress;
 }
 
--- a/Socket/Socket.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/Socket/Socket.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -37,7 +37,7 @@
         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;
 
@@ -50,7 +50,11 @@
 }
 
 int Socket::set_option(int level, int optname, const void *optval, socklen_t optlen) {
+#ifndef CC3000_TINY_DRIVER
     return _cc3000_module->_socket.setsockopt(_sock_fd, level, optname, optval, optlen);
+#else
+    return -1;
+#endif
 }
 
 int Socket::get_option(int level, int optname, void *optval, socklen_t *optlen) {
@@ -70,9 +74,9 @@
     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)) {
--- a/cc3000.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -47,36 +47,119 @@
 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 ?? */
-
+cc3000::cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi)
+             : _event(_simple_link, _hci, _spi, *this), _socket(_simple_link, _hci, _event),
+               _spi(cc3000_irq, cc3000_en, cc3000_cs, cc3000_spi, _event, _simple_link), _hci(_spi),
+               _nvmem(_hci, _event, _simple_link), _netapp(_simple_link, _nvmem, _hci, _event),
+               _wlan(_simple_link, _event, _spi, _hci) {
     _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;
-
+    memset(&_status, 0, sizeof(_status));
     _inst = this;
 }
 
 cc3000::~cc3000() {
-
 }
 
 #if (CC3000_ETH_COMPAT == 1)
+cc3000::cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, const char *ssid,
+               const char *phrase, Security sec, bool smart_config)
+             : _event(_simple_link, _hci, _spi, *this), _socket(_simple_link, _hci, _event),
+               _spi(cc3000_irq, cc3000_en, cc3000_cs, cc3000_spi, _event, _simple_link), _hci(_spi),
+               _nvmem(_hci, _event, _simple_link), _netapp(_simple_link, _nvmem, _hci, _event),
+               _wlan(_simple_link, _event, _spi, _hci), _sec(sec), _smart_config(smart_config) {
+    _simple_link.set_tx_complete_signal(1);
+    memset(&_status, 0, sizeof(_status));
+    strcpy((char *)_ssid, ssid);
+    strcpy((char *)_phrase, phrase);
+    _inst = this;
+}
+
 // Ethernet library compatible, functions return strings
 // Caches the ipconfig from the usync callback
-static char mac_addr[19];
+static char mac_addr[19]= "\0";
 static char ip_addr[17] = "\0";
 static char gateway[17] = "\0";
 static char networkmask[17] = "\0";
 
+void cc3000::init() {
+    _wlan.start(0);
+
+    uint32_t subnet[4] = {0};
+    uint32_t ip[4] = {0};
+    uint32_t getway[4] = {0};
+    uint32_t dns[4] = {0};
+
+    _netapp.dhcp(ip, subnet, getway, dns);
+    _wlan.stop();
+    wait(1);
+    _wlan.start(0);
+
+    _status.enabled = 1;
+    _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE | HCI_EVNT_WLAN_ASYNC_PING_REPORT);
+}
+
+void cc3000::init(const char *ip, const char *mask, const char *gateway) {
+    _netapp.dhcp((uint32_t *)ip, (uint32_t *)mask, (uint32_t *)gateway, (uint32_t *)ip); //dns = ip
+    _wlan.stop();
+    wait(1);
+    _wlan.start(0);
+
+    _status.enabled = 1;
+    _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE | HCI_EVNT_WLAN_ASYNC_PING_REPORT);
+}
+
+int cc3000::connect(unsigned int timeout_ms) {
+    Timer t;
+    int ret = 0;
+
+    if (_smart_config == false) {
+        _wlan.ioctl_set_connection_policy(0, 0, 0);
+    } else {
+        tUserFS user_info;
+        get_user_file_info((uint8_t *)&user_info, sizeof(user_info));
+        if (user_info.FTC == 1) {
+            _wlan.ioctl_set_connection_policy(0, 1, 1);
+        } else {
+            DBG_CC("Smart config is not set. Please run the first time configuration.");
+            return -1;
+        }
+    }
+
+    t.start();
+    while (is_connected() == false) {
+        if (strlen((const char *)_phrase) < 8) {
+            if (connect_open(_ssid)) {
+                break;
+            }
+        } else {
+#ifndef CC3000_TINY_DRIVER
+            if (connect_secure(_ssid,_phrase, _sec)) {
+                break;
+            }
+#else
+            return -1; /* secure connection not supported with TINY_DRIVER */
+#endif
+        }
+
+        if (t.read_ms() > timeout_ms) {
+            ret = -1;
+            DBG_CC("Connection to AP failed");
+            break;
+        }
+    }
+
+    while (is_dhcp_configured() == false)
+    {
+        if (t.read_ms() > timeout_ms) {
+            ret = -1;
+            DBG_CC("Connection to AP failed");
+            break;
+        }
+    }
+
+    return ret;
+}
+
 char* cc3000::getMACAddress() {
     return mac_addr;
 }
@@ -92,34 +175,39 @@
 char* cc3000::getNetworkMask() {
     return networkmask;
 }
+
+int cc3000::disconnect(void){
+    if (_wlan.disconnect()) {
+        return -1;
+    } else {
+        return 0;
+    }
+}
+
 #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)
-    {
+    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)
-    {
+    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)
-    {
+    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 (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);
@@ -135,22 +223,19 @@
         }
     }
 
-    if (event_type == HCI_EVENT_CC3000_CAN_SHUT_DOWN)
-    {
+    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)
-    {
+    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];
+        uint8_t 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 */
@@ -162,14 +247,12 @@
     _status.smart_config_complete = 0;
     _wlan.ioctl_set_connection_policy(0, 0, 0);
 
-    if (_status.connected == 1)
-    {
+    if (_status.connected == 1) {
         disconnect();
     }
 
     //Wait until CC3000 is disconected
-    while (_status.connected == 1)
-    {
+    while (_status.connected == 1) {
         wait_us(5);
         _event.hci_unsolicited_event_handler();
     }
@@ -182,8 +265,7 @@
     DBG_CC("Waiting for smartconfig to be completed");
 
     // Wait for Smart config finished
-    while (_status.smart_config_complete == 0)
-    {
+    while (_status.smart_config_complete == 0) {
         wait_ms(100);
     }
 
@@ -214,6 +296,9 @@
 }
 
 bool cc3000::connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) {
+#ifdef CC3000_TINY_DRIVER
+    return false; /* not supported*/
+#else
     uint32_t ret;
 
     //_wlan.disconnect();
@@ -225,24 +310,20 @@
       ret = false;
     }
     return ret;
+#endif
 }
 
 bool cc3000::connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode)
 {
-bool ret = false;
+    bool ret = false;
 
-    if (key == 0)
-    {
-        if (connect_open(ssid))
-        {
+    if (key == 0) {
+        if (connect_open(ssid)) {
             ret = true;
         }
-    }
-    else
-    {
+    } else {
     #ifndef CC3000_TINY_DRIVER
-        if (connect_secure(ssid,key,security_mode))
-        {
+        if (connect_secure(ssid,key,security_mode)) {
             ret = true;
         }
     #else
@@ -254,7 +335,7 @@
 }
 
 bool cc3000::connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) {
-    Timer t;  /* TODO static? */
+    Timer t;
     bool ret = true;
 
     t.start();
@@ -274,11 +355,9 @@
         }
 
         /* timeout 10 seconds */
-        if (t.read_ms() > 10000){
+        if (t.read_ms() > 10000) {
             ret = false;
-
             DBG_CC("Connection to AP failed");
-
             break;
         }
     }
@@ -289,7 +368,7 @@
 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);
+    _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE | HCI_EVNT_WLAN_ASYNC_PING_REPORT);
 }
 
 void cc3000::stop(void) {
@@ -306,10 +385,9 @@
 }
 
 bool cc3000::connect_open(const uint8_t *ssid) {
-    uint32_t ret;
-
     _wlan.disconnect();
     wait_ms(3);
+    uint32_t ret;
 #ifndef CC3000_TINY_DRIVER
     ret = _wlan.connect(0,ssid, strlen((const char *)ssid), 0, 0, 0);
 #else
@@ -329,13 +407,10 @@
 }
 
 bool cc3000::is_connected() {
-    if (( _status.connected ) && ( _status.dhcp ))
-    {
-        return( 1 );
-    }
-    else
-    {
-        return( 0 );
+    if (( _status.connected ) && ( _status.dhcp )) {
+        return 1;
+    } else {
+        return 0;
     }
 }
 
@@ -371,11 +446,10 @@
 #endif
 
 void cc3000::delete_profiles(void) {
-    tUserFS user_info;
-
     _wlan.ioctl_set_connection_policy(0, 0, 0);
     _wlan.ioctl_del_profile(255);
 
+    tUserFS user_info;
     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));
@@ -385,15 +459,8 @@
     _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) {
+#ifndef CC3000_TINY_DRIVER
     uint32_t reversed_ip = (ip >> 24) | ((ip >> 8) & 0xFF00) | ((ip << 8) & 0xFF0000) | (ip << 24);
 
     _ping_report.packets_received = 0;
@@ -412,6 +479,9 @@
     DBG_CC("Avg time: %d",_ping_report.avg_round_time);
 
     return _ping_report.packets_received;
+#else
+    return 0;
+#endif
 }
 
 /* Conversion between uint types and C strings */
@@ -448,5 +518,5 @@
            (*(p + offset + 1)) << 8) + (uint32_t)(*(p + offset)));
 }
 
-} /* end of mbed_cc3000 namespace */
+} // mbed_cc3000 namespace
 
--- a/cc3000.h	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000.h	Wed Nov 06 17:56:25 2013 +0100
@@ -127,6 +127,15 @@
     BOOTLOADER_PATCHES  = 2,
 };
 
+/** AP security
+ */
+enum Security {
+    NONE = 0,
+    WEP  = 1,
+    WPA  = 2,
+    WPA2 = 3
+};
+
 /** CC3000 Simple Link class which contains status of cc3000.
  */
 class cc3000_simple_link {
@@ -325,7 +334,7 @@
 class cc3000_event {
 public:
     /**
-     *  \brief
+     *  \brief Ctor
      *  \param simplelink Reference to simple link object.
      *  \param hci        Reference to hci object.
      *  \param spi        Reference to spi object.
@@ -334,7 +343,7 @@
      */
     cc3000_event(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_spi &spi, cc3000 &cc3000);
     /**
-     *  \brief Ctor
+     *  \brief Dtor
      *  \param none
      *  \return none
      */
@@ -352,7 +361,7 @@
     *  \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);
+    uint8_t* hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen);
     /**
     *  \brief  Handle unsolicited events.
     *  \param  event_hdr Event header
@@ -1072,7 +1081,7 @@
      *  \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);
+     cc3000_spi(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, cc3000_event &event, cc3000_simple_link &simple_link);
     /**
      *  \brief Dtor
      *  \param none
@@ -1166,10 +1175,9 @@
     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;
+    bool                _process_irq;
 };
 
 /** HCI layer
@@ -1531,9 +1539,9 @@
 public:
     /** status structure */
     typedef struct {
+        uint8_t socket;
         bool    dhcp;
         bool    connected;
-        uint8_t socket;
         bool    smart_config_complete;
         bool    stop_smart_config;
         bool    dhcp_configured;
@@ -1546,15 +1554,14 @@
      *  \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);
+    cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi);
     /**
      *  \brief Dtor.
      */
     ~cc3000();
     /**
-     *  \brief Initiate cc3000. It starts the wlan communication and deletes profiles.
+     *  \brief Initiate cc3000. It starts the wlan communication.
      *  \param patch Patch
      */
     void start(uint8_t patch);
@@ -1567,11 +1574,6 @@
      */
     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
@@ -1689,18 +1691,55 @@
      *  \param none
      *  \return Pointer to cc3000 object
      */
-    static cc3000 *get_instance() {
+    static cc3000* get_instance() {
         return _inst;
     }
 #if (CC3000_ETH_COMPAT == 1)
     /**
+     *  \brief Ctor for EthernetInterface
+     *  \param cc3000_irq   IRQ pin
+     *  \param cc3000_en    Enable pin
+     *  \param cc3000_cs    Chip select pin
+     *  \param cc3000_spi   SPI interface
+     *  \param ssid         SSID
+     *  \param phrase       Password
+     *  \param sec          Security of the AP
+     *  \param smart_config Smart config selection
+     */
+    cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, const char *ssid, const char *phrase, Security sec, bool smart_config);
+    /**
+     *  \brief Disconnect wlan device.
+     *  \param none
+     *  \return 0 if successful, -1 otherwise.
+     */
+    int disconnect();
+    /**
+     *  \brief Initialize the interface with DHCP.
+     *  \param none
+     *  \return none
+     */
+    void init();
+    /**
+     *  \brief Initialize the interface with a static IP address.
+     *  \param ip      the IP address to use.
+     *  \param mask    the IP address mask
+     *  \param gateway the gateway to use
+     *  \return none
+     */
+    void init(const char *ip, const char *mask, const char *gateway);
+    /**
+     *  \brief Connect Bring the interface up.
+     *  \param timeout_ms timeout in ms
+     *  \return 0 if successful, -1 otherwise.
+     */
+    int connect(unsigned int timeout_ms = 20000);
+    /**
      *  \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
@@ -1708,7 +1747,6 @@
      *      Pointer to a string containing the IP address.
      */
     char* getIPAddress();
-
      /**
      *  \brief Get the Gateway address of your Ethernet interface
      *  \param none
@@ -1716,7 +1754,6 @@
      *      Pointer to a string containing the Gateway address
      */
     char* getGateway();
-
      /**
      *  \brief Get the Network mask of your Ethernet interface
      *  \param none
@@ -1728,21 +1765,27 @@
 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;
+#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
+    cc3000_security     _security;
+#endif
 protected:
     static cc3000       *_inst;
 private:
     tStatus                  _status;
     netapp_pingreport_args_t _ping_report;
     bool                     _closed_sockets[MAX_SOCKETS];
+#if (CC3000_ETH_COMPAT == 1)
+    uint8_t                  _phrase[30];
+    uint8_t                  _ssid[30];
+    Security                 _sec;
+    bool                     _smart_config;
+#endif
 };
 
 /**
--- a/cc3000_event.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_event.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -430,9 +430,6 @@
             }
 
             _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
@@ -485,15 +482,8 @@
             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);
+                 _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
@@ -517,11 +507,8 @@
                 // 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));
-                // }
+                _cc3000.usync_callback(event_type, (uint8_t  *)params, sizeof(params));
+
                 break;
             }
             case HCI_EVNT_WLAN_ASYNC_PING_REPORT:
@@ -534,20 +521,12 @@
                 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));
-                // }
+                _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);
-                // }
+                _cc3000.usync_callback(event_type, NULL, 0);
                 break;
             }
 
@@ -603,8 +582,7 @@
 }
 
 void cc3000_event::set_socket_active_status(int32_t sd, int32_t status) {
-    if (M_IS_VALID_SD(sd) && M_IS_VALID_STATUS(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 */
     }
@@ -633,7 +611,7 @@
 }
 
 int32_t cc3000_event::get_socket_active_status(int32_t sd) {
-    if(M_IS_VALID_SD(sd)) {
+    if (M_IS_VALID_SD(sd)) {
         return (socket_active_status & (1 << sd)) ? SOCKET_STATUS_INACTIVE : SOCKET_STATUS_ACTIVE;
     } else {
         return SOCKET_STATUS_INACTIVE;
@@ -646,7 +624,7 @@
     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) {
+    if (ERROR_SOCKET_INACTIVE == status) {
         set_socket_active_status(sd, SOCKET_STATUS_INACTIVE);
     }
 }
@@ -666,4 +644,4 @@
 }
 
 
-} /* end of cc3000 namespace */
+} // end of cc3000
--- a/cc3000_hci.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_hci.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -51,8 +51,8 @@
 }
 
 uint16_t  cc3000_hci::command_send(uint16_t op_code, uint8_t *buffer, uint8_t length) {
-    unsigned char *stream;
-    
+    uint8_t *stream;
+
     DBG_HCI_CMD("Command Sent : 0x%04X", op_code);
 
     stream = (buffer + SPI_HEADER_SIZE);
@@ -67,7 +67,7 @@
 
 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;
+    uint8_t *stream;
 
     stream = ((args) + SPI_HEADER_SIZE);
 
@@ -83,7 +83,7 @@
 }
 
 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_t *stream = (buffer + SPI_HEADER_SIZE);
 
     UINT8_TO_STREAM(stream, HCI_TYPE_DATA);
     UINT8_TO_STREAM(stream, op_code);
@@ -97,21 +97,18 @@
 }
 
 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);
+    uint16_t usTransLength;
+    uint8_t *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)
-    {
+    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
-    {
+    } 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);
@@ -124,21 +121,16 @@
         _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)
-            {
+        while (data_length) {
+            if (data_length <= SL_PATCH_PORTION_SIZE) {
                 usTransLength = data_length;
                 data_length = 0;
-
-            }
-            else
-            {
+            } else {
                 usTransLength = SL_PATCH_PORTION_SIZE;
                 data_length -= usTransLength;
             }
 
-            *(unsigned short *)stream = usTransLength;
+            *(uint16_t *)stream = usTransLength;
             memcpy(stream + SIMPLE_LINK_HCI_PATCH_HEADER_SIZE, patch, usTransLength);
             patch += usTransLength;
 
@@ -148,4 +140,4 @@
     }
 }
 
-}
+} // mbed_cc3000 namespace
--- a/cc3000_netapp.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_netapp.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -78,7 +78,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_NETAPP_DHCP, &scRet);
 
-    return(scRet);
+    return scRet;
 }
 
 #ifndef CC3000_TINY_DRIVER
@@ -122,7 +122,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_NETAPP_SET_TIMERS, &scRet);
 
-    return(scRet);
+    return scRet;
 }
 
 int32_t cc3000_netapp::ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout) {
@@ -145,7 +145,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_NETAPP_PING_SEND, &scRet);
 
-    return(scRet);
+    return scRet;
 }
 
 void cc3000_netapp::ping_report() {
@@ -176,7 +176,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_NETAPP_PING_STOP, &scRet);
 
-    return(scRet);
+    return scRet;
 }
 
 int32_t cc3000_netapp::arp_flush() {
@@ -192,8 +192,8 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_NETAPP_ARP_FLUSH, &scRet);
 
-    return(scRet);
+    return scRet;
 }
 #endif
 
-} /* end of cc3000 namespace */
+} // mbed_cc3000
--- a/cc3000_nvmem.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_nvmem.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -118,22 +118,19 @@
     uint16_t    offset = 0;
     uint8_t*      spDataPtr = (uint8_t*)data;
 
-    while ((status == 0) && (length >= SP_PORTION_SIZE))
-    {
+    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)
-    {
+    if (status !=0) {
         // NVMEM error occurred
         return status;
     }
 
-    if (length != 0)
-    {
+    if (length != 0) {
         // If length MOD 512 is nonzero, write the remaining bytes.
         status = write(file_id, length, offset, spDataPtr);
     }
@@ -162,7 +159,7 @@
 }
 
 #ifndef CC3000_TINY_DRIVER
-uint8_t  cc3000_nvmem::read_sp_version(uint8_t* patch_ver) {
+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];
@@ -180,7 +177,6 @@
 
     return(retBuf[0]);
 }
-
 #endif
 
-}
+} // mbed_cc3000 namespace
--- a/cc3000_security.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_security.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -377,5 +377,5 @@
 }
 #endif
 
-} /* end of cc3000 namespace */
+} // mbed_cc3000 namespace
 
--- a/cc3000_simplelink.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_simplelink.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -68,20 +68,17 @@
         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() {
+uint8_t* cc3000_simple_link::get_transmit_buffer() {
     return _tx_buffer;
 }
 
-uint8_t *cc3000_simple_link::get_received_buffer() {
+uint8_t* cc3000_simple_link::get_received_buffer() {
     return _rx_buffer;
 }
 
@@ -170,8 +167,4 @@
     _received_data = pointer;
 }
 
-//void cc3000_simple_link::set_wlan_cb(tWlanCB fpointer) {
-//    _fWlanCB = fpointer;
-//}
-
-}
+} // mbed_cc3000 namespace
--- a/cc3000_socket.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_socket.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -46,25 +46,21 @@
 namespace mbed_cc3000 {
 
 cc3000_socket::cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event)
-    : _simple_link(simplelink), _hci(hci), _event(event)
-{
+    : _simple_link(simplelink), _hci(hci), _event(event) {
 
 }
 
-cc3000_socket::~cc3000_socket()
-{
+cc3000_socket::~cc3000_socket() {
 
 }
 
 int32_t cc3000_socket::HostFlowControlConsumeBuff(int32_t sd) {
 #ifndef SEND_NON_BLOCKING
     /* wait in busy loop */
-    do
-    {
+    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)
-        {
+        if (_simple_link.get_transmit_error() != 0) {
             errno = _simple_link.get_transmit_error();
             _simple_link.set_transmit_error(0);
             return errno;
@@ -72,7 +68,7 @@
 
         if(SOCKET_STATUS_ACTIVE != _event.get_socket_active_status(sd))
             return -1;
-    } while(0 == _simple_link.get_number_free_buffers());
+    } while (0 == _simple_link.get_number_free_buffers());
 
     uint16_t free_buffer = _simple_link.get_number_free_buffers();
     free_buffer--;
@@ -83,24 +79,20 @@
 
     // 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)
-    {
+    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))
+    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())
-    {
+    if (0 == _simple_link.get_number_free_buffers()) {
         return -2;
-    }
-    else
-    {
+    } else {
         uint16_t free_buffer = _simple_link.get_number_free_buffers();
         free_buffer--;
         _simple_link.set_number_free_buffers(free_buffer);
@@ -133,14 +125,14 @@
 
     _event.set_socket_active_status(ret, SOCKET_STATUS_ACTIVE);
 
-    return(ret);
+    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);
+    while (_simple_link.get_number_free_buffers() != SOCKET_MAX_FREE_BUFFERS);
     ret = EFAIL;
     ptr = _simple_link.get_transmit_buffer();
     args = (ptr + HEADERS_SIZE_CMD);
@@ -158,7 +150,7 @@
     // 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);
+    return ret;
 }
 
 int32_t cc3000_socket::accept(int32_t sd, sockaddr *addr, socklen_t *addrlen) {
@@ -187,16 +179,13 @@
     ret = errno;
 
     // if succeeded, iStatus = new socket descriptor. otherwise - error number
-    if(M_IS_VALID_SD(ret))
-    {
+    if(M_IS_VALID_SD(ret)) {
         _event.set_socket_active_status(ret, SOCKET_STATUS_ACTIVE);
-    }
-    else
-    {
+    } else {
         _event.set_socket_active_status(sd, SOCKET_STATUS_INACTIVE);
     }
 
-    return(ret);
+    return ret;
 }
 
 int32_t cc3000_socket::bind(int32_t sd, const sockaddr *addr, int32_t addrlen) {
@@ -223,7 +212,7 @@
 
     errno = ret;
 
-    return(ret);
+    return ret;
 }
 
 int32_t cc3000_socket::listen(int32_t sd, int32_t backlog) {
@@ -279,12 +268,9 @@
     tBsdSelectRecvParams tParams;
     uint32_t is_blocking;
 
-    if( timeout == NULL)
-    {
+    if (timeout == NULL) {
         is_blocking = 1; /* blocking , infinity timeout */
-    }
-    else
-    {
+    } else {
         is_blocking = 0; /* no blocking, timeout */
     }
 
@@ -303,10 +289,8 @@
     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)
-        {
+    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);
@@ -320,30 +304,24 @@
     _event.simplelink_wait_event(HCI_EVNT_SELECT, &tParams);
 
     // Update actually read FD
-    if (tParams.iStatus >= 0)
-    {
-        if (readsds)
-        {
+    if (tParams.iStatus >= 0) {
+        if (readsds) {
             memcpy(readsds, &tParams.uiRdfd, sizeof(tParams.uiRdfd));
         }
 
-        if (writesds)
-        {
+        if (writesds) {
             memcpy(writesds, &tParams.uiWrfd, sizeof(tParams.uiWrfd));
         }
 
-        if (exceptsds)
-        {
+        if (exceptsds) {
             memcpy(exceptsds, &tParams.uiExfd, sizeof(tParams.uiExfd));
         }
 
         return(tParams.iStatus);
 
-    }
-    else
-    {
+    } else {
         errno = tParams.iStatus;
-        return(-1);
+        return -1;
     }
 }
 
@@ -365,14 +343,11 @@
     // Since we are in blocking state - wait for event complete
     _event.simplelink_wait_event(HCI_CMND_GETSOCKOPT, &tRetParams);
 
-    if (((int8_t)tRetParams.iStatus) >= 0)
-    {
+    if (((int8_t)tRetParams.iStatus) >= 0) {
         *optlen = 4;
         memcpy(optval, tRetParams.ucOptValue, 4);
         return (0);
-    }
-    else
-    {
+    } else {
         errno = tRetParams.iStatus;
         return errno;
     }
@@ -397,8 +372,7 @@
     _event.simplelink_wait_event(opcode, &tSocketReadEvent);
 
     // In case the number of bytes is more then zero - read data
-    if (tSocketReadEvent.iNumberOfBytes > 0)
-    {
+    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);
@@ -425,8 +399,7 @@
     tBsdReadReturnParams tSocketSendEvent;
 
     // Check the bsd_arguments
-    if (0 != (res = HostFlowControlConsumeBuff(sd)))
-    {
+    if (0 != (res = HostFlowControlConsumeBuff(sd))) {
         return res;
     }
 
@@ -442,7 +415,7 @@
     // Update the offset of data and parameters according to the command
     switch(opcode)
     {
-    case HCI_CMND_SENDTO:
+        case HCI_CMND_SENDTO:
         {
             addr_offset = len + sizeof(len) + sizeof(len);
             addrlen = 8;
@@ -451,7 +424,7 @@
             break;
         }
 
-    case HCI_CMND_SEND:
+        case HCI_CMND_SEND:
         {
             tolen = 0;
             to = NULL;
@@ -460,7 +433,7 @@
             break;
         }
 
-    default:
+        default:
         {
             break;
         }
@@ -472,8 +445,7 @@
     args = UINT32_TO_STREAM(args, len);
     args = UINT32_TO_STREAM(args, flags);
 
-    if (opcode == HCI_CMND_SENDTO)
-    {
+    if (opcode == HCI_CMND_SENDTO) {
         args = UINT32_TO_STREAM(args, addr_offset);
         args = UINT32_TO_STREAM(args, addrlen);
     }
@@ -482,8 +454,7 @@
     ARRAY_TO_STREAM(pDataPtr, ((uint8_t *)buf), len);
 
     // In case we are using SendTo, copy the to parameters
-    if (opcode == HCI_CMND_SENDTO)
-    {
+    if (opcode == HCI_CMND_SENDTO) {
         ARRAY_TO_STREAM(pDataPtr, ((uint8_t *)to), tolen);
     }
 
@@ -509,8 +480,7 @@
     int32_t ret;
      uint8_t *pTxBuffer, *pArgs;
 
-    if (device_service_name_length > MDNS_DEVICE_SERVICE_MAX_LENGTH)
-    {
+    if (device_service_name_length > MDNS_DEVICE_SERVICE_MAX_LENGTH) {
         return EFAIL;
     }
 
@@ -540,8 +510,7 @@
 
     errno = EFAIL;
 
-    if (name_length > HOSTNAME_MAX_LENGTH)
-    {
+    if (name_length > HOSTNAME_MAX_LENGTH) {
         return errno;
     }
 
@@ -587,12 +556,9 @@
     // Since we are in blocking state - wait for event complete
     _event.simplelink_wait_event(HCI_CMND_SETSOCKOPT, &ret);
 
-    if (ret >= 0)
-    {
+    if (ret >= 0) {
         return (0);
-    }
-    else
-    {
+    } else {
         errno = ret;
         return ret;
     }
@@ -600,39 +566,39 @@
 
 #endif
 
-char * cc3000_socket::inet_ntoa_r(uint32_t s_addr, char *buf, int buflen)
+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;
+    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];
+    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++;
     }
-    if (len++ >= buflen) {
-      return NULL;
-    }
-    *rp++ = '.';
-    ap++;
-  }
-  *--rp = 0;
-  return buf;
+    *--rp = 0;
+    return buf;
 }
 
-} /* end of cc3000 namespace */
+} // mbed_cc3000 namespace
--- a/cc3000_spi.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_spi.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -43,17 +43,16 @@
 
 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 */
+cc3000_spi::cc3000_spi(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, cc3000_event &event, cc3000_simple_link &simple_link)
+  : _wlan_irq(cc3000_irq), _wlan_en(cc3000_en), _wlan_cs(cc3000_cs), _wlan_spi(cc3000_spi), _event(event), _simple_link(simple_link) {
 
     _wlan_spi.format(8,1);
     _wlan_spi.frequency(12000000);
-    _function_pointer =  _wlan_irq.fall(this, &cc3000_spi::WLAN_IRQHandler);
+    _wlan_irq.fall(this, &cc3000_spi::WLAN_IRQHandler);
 
     _wlan_en = 0;
     _wlan_cs = 1;
+    wait_ms(50); /* mbed board delay */
 }
 
 cc3000_spi::~cc3000_spi() {
@@ -62,15 +61,17 @@
 
 void cc3000_spi::wlan_irq_enable()
 {
-    NVIC_EnableIRQ(_irq_port);
+    _process_irq = true;
+    //_wlan_irq.enable_irq();
 
-    if(wlan_irq_read() == 0) {
+    if (wlan_irq_read() == 0) {
         WLAN_IRQHandler();
     }
 }
 
 void cc3000_spi::wlan_irq_disable() {
-    NVIC_DisableIRQ(_irq_port);
+    _process_irq = false;
+    //_wlan_irq.disable_irq();
 }
 
 uint32_t cc3000_spi::wlan_irq_read() {
@@ -105,123 +106,106 @@
 
 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))
-   {
+    // 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);
+    }
+    buffer[0] = WRITE;
+    buffer[1] = HI(length + pad);
+    buffer[2] = LO(length + pad);
+    buffer[3] = 0;
+    buffer[4] = 0;
 
-   // 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);
-   }
+    length += (SPI_HEADER_SIZE + pad);
 
-   if (_spi_info.spi_state == eSPI_STATE_POWERUP)
-   {
-      while (_spi_info.spi_state != eSPI_STATE_INITIALIZED);
-   }
+    // 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();
+    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);
+        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;
+        _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;
+        // Assert the CS line and wait until the IRQ line is active, then initialize the write operation
+        _wlan_cs = 0;
 
-      wlan_irq_enable();
-   }
+        wlan_irq_enable();
+    }
 
-   // Wait until the transaction ends
-   while (_spi_info.spi_state != eSPI_STATE_IDLE);
+    // Wait until the transaction ends
+    while (_spi_info.spi_state != eSPI_STATE_IDLE);
 
-   return 0;
+    return 0;
 }
 
 void cc3000_spi::write_synchronous(uint8_t *data, uint16_t size) {
-   while(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);;
-   }
+    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;
+   int32_t data_to_recv;
+   uint8_t *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)
-    {
+    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++;
-         }
+            // 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)
-         {
+            if (data_to_recv) {
                read_synchronous(evnt_buff + 10, data_to_recv);
-         }
+            }
             break;
-        }
         case HCI_TYPE_EVNT:
-        {
-         // Calculate the rest length of the data
+            // 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++;
-         }
+            data_to_recv -= 1;
+            // Add padding byte if needed
+            if ((HEADERS_SIZE_EVNT + data_to_recv) & 1) {
+                 data_to_recv++;
+            }
 
-         if (data_to_recv)
-         {
+            if (data_to_recv) {
                read_synchronous(evnt_buff + 10, data_to_recv);
-         }
+            }
 
-         _spi_info.spi_state = eSPI_STATE_READ_EOT;
+            _spi_info.spi_state = eSPI_STATE_READ_EOT;
             break;
-        }
     }
-    return (0);
+    return 0;
 }
 
 void cc3000_spi::set_wlan_en(uint8_t value) {
@@ -233,44 +217,39 @@
 }
 
 void cc3000_spi::WLAN_IRQHandler() {
-   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;
-
+    if (_process_irq) {
+        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;
-   }
+            // 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;
+        }
+    }
 }
 
-}
+} // namespace mbed_cc3000
--- a/cc3000_wlan.cpp	Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_wlan.cpp	Wed Nov 06 17:56:25 2013 +0100
@@ -86,22 +86,13 @@
     // ASIC 1273 chip enable: toggle WLAN EN line
     _spi.set_wlan_en(WLAN_ENABLE);
 
-    if (spi_irq_state)
-    {
+    if (spi_irq_state) {
         // wait till the IRQ line goes low
-        while(_spi.wlan_irq_read() != 0)
-        {
-        }
-    }
-    else
-    {
+        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)
-        {
-        }
+        while(_spi.wlan_irq_read() == 0);
+        while(_spi.wlan_irq_read() != 0);
     }
     simpleLink_init_start(patches_available_host);
 
@@ -113,12 +104,10 @@
 
 void cc3000_wlan::stop() {
     // ASIC 1273 chip disable
-    _spi.set_wlan_en( WLAN_DISABLE );
+    _spi.set_wlan_en(WLAN_DISABLE);
 
-    // Wait till IRQ line goes high...
-    while(_spi.wlan_irq_read() == 0)
-    {
-    }
+    // Wait till IRQ line goes high
+    while(_spi.wlan_irq_read() == 0);
 
     _spi.close();
 }
@@ -137,7 +126,7 @@
     _event.simplelink_wait_event(HCI_CMND_WLAN_DISCONNECT, &ret);
     errno = ret;
 
-    return(ret);
+    return ret;
 }
 
 
@@ -163,7 +152,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, &ret);
 
-    return(ret);
+    return ret;
 }
 
 
@@ -185,7 +174,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, &ret);
 
-    return(ret);
+    return ret;
 }
 
 int32_t cc3000_wlan::set_event_mask(uint32_t mask) {
@@ -194,22 +183,18 @@
     uint8_t *args;
 
 
-    if ((mask & HCI_EVNT_WLAN_TX_COMPLETE) == HCI_EVNT_WLAN_TX_COMPLETE)
-    {
+    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)
-        {
+        if (mask == HCI_EVNT_WLAN_TX_COMPLETE) {
             return 0;
         }
 
         mask &= ~HCI_EVNT_WLAN_TX_COMPLETE;
         mask |= HCI_EVNT_WLAN_UNSOL_BASE;
-    }
-    else
-    {
+    } else {
         _simple_link.set_tx_complete_signal(1);
     }
 
@@ -226,7 +211,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_EVENT_MASK, &ret);
 
-    return(ret);
+    return ret;
 }
 
 
@@ -248,7 +233,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, &ret);
 
-    return(ret);
+    return ret;
 }
 
 
@@ -264,7 +249,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, &ret);
 
-    return(ret);
+    return ret;
 }
 
 int32_t cc3000_wlan::smart_config_set_prefix(uint8_t *new_prefix) {
@@ -276,10 +261,10 @@
     ptr = _simple_link.get_transmit_buffer();
     args = (ptr + HEADERS_SIZE_CMD);
 
-    if (new_prefix == NULL)
+    if (new_prefix == NULL) {
         return ret;
-    else    // with the new Smart Config, prefix must be TTT
-    {
+    } else {
+        // with the new Smart Config, prefix must be TTT
         *new_prefix = 'T';
         *(new_prefix + 1) = 'T';
         *(new_prefix + 2) = 'T';
@@ -292,7 +277,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, &ret);
 
-    return(ret);
+    return ret;
 }
 
 #ifndef CC3000_TINY_DRIVER
@@ -316,19 +301,15 @@
     args = UINT16_TO_STREAM(args, 0);
 
     // padding shall be zeroed
-    if(bssid)
-    {
+    if (bssid) {
         ARRAY_TO_STREAM(args, bssid, ETH_ALEN);
-    }
-    else
-    {
+    } else {
         ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
     }
 
     ARRAY_TO_STREAM(args, ssid, ssid_len);
 
-    if(key_len && key)
-    {
+    if (key_len && key) {
         ARRAY_TO_STREAM(args, key, key_len);
     }
 
@@ -339,7 +320,7 @@
     _event.simplelink_wait_event(HCI_CMND_WLAN_CONNECT, &ret);
     errno = ret;
 
-    return(ret);
+    return ret;
 }
 
 int32_t cc3000_wlan::add_profile(uint32_t sec_type,
@@ -368,17 +349,14 @@
     switch (sec_type)
     {
         //OPEN
-    case WLAN_SEC_UNSEC:
+        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)
-            {
+            if(b_ssid) {
                 ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
-            }
-            else
-            {
+            } else {
                 ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
             }
             args = UINT32_TO_STREAM(args, priority);
@@ -389,17 +367,14 @@
         break;
 
         //WEP
-    case WLAN_SEC_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)
-            {
+            if (b_ssid) {
                 ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
-            }
-            else
-            {
+            } else {
                 ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
             }
             args = UINT32_TO_STREAM(args, priority);
@@ -408,8 +383,7 @@
             args = UINT32_TO_STREAM(args, group_cipher_tx_key_index);
             ARRAY_TO_STREAM(args, ssid, ssid_length);
 
-            for(i = 0; i < 4; i++)
-            {
+            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);
@@ -423,18 +397,15 @@
 
         //WPA
         //WPA2
-    case WLAN_SEC_WPA:
-    case WLAN_SEC_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)
-            {
+            if (b_ssid) {
                 ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
-            }
-            else
-            {
+            } else {
                 ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
             }
             args = UINT32_TO_STREAM(args, priority);
@@ -458,7 +429,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_ADD_PROFILE, &ret);
 
-    return(ret);
+    return ret;
 }
 
 int32_t cc3000_wlan::ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results) {
@@ -477,7 +448,7 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, results);
 
-    return(0);
+    return 0;
 }
 
 int32_t cc3000_wlan::ioctl_set_scan_params(uint32_t enable,
@@ -529,11 +500,11 @@
     // Wait for command complete event
     _event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_STATUSGET, &ret);
 
-    return(ret);
+    return ret;
 }
 
 #else
-int32_t cc3000_wlan::wlan_add_profile(uint32_t sec_type,
+int32_t cc3000_wlan::add_profile(uint32_t sec_type,
                       uint8_t *ssid,
                       uint32_t ssid_length,
                       uint8_t *b_ssid,
@@ -576,7 +547,7 @@
     _event.simplelink_wait_event(HCI_CMND_WLAN_CONNECT, &ret);
     errno = ret;
 
-    return(ret);
+    return ret;
 }
 #endif
 
@@ -619,20 +590,14 @@
     if (profileArray[profileArray[0] + 1] > 16)
         aes_decrypt((uint8_t *)(decKeyPtr + 16), key);
 
-    if (*(uint8_t *)(decKeyPtr +31) != 0)
-    {
-        if (*decKeyPtr == 31)
-        {
+    if (*(uint8_t *)(decKeyPtr +31) != 0) {
+        if (*decKeyPtr == 31) {
             keyLen = 31;
             decKeyPtr++;
-        }
-        else
-        {
+        } else {
             keyLen = 32;
         }
-    }
-    else
-    {
+    } else {
         keyLen = *decKeyPtr;
         decKeyPtr++;
     }