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.
Committer:
frankvnk
Date:
Wed Oct 23 12:01:30 2013 +0000
Revision:
1:99bfc8d68fd3
Webserver functional using ProcessWlanInterrupt flag instead of NVIC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frankvnk 1:99bfc8d68fd3 1 /*****************************************************************************
frankvnk 1:99bfc8d68fd3 2 *
frankvnk 1:99bfc8d68fd3 3 * C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to
frankvnk 1:99bfc8d68fd3 4 * Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and
frankvnk 1:99bfc8d68fd3 5 * provided help.
frankvnk 1:99bfc8d68fd3 6 *
frankvnk 1:99bfc8d68fd3 7 * This version of "host driver" uses CC3000 Host Driver Implementation. Thus
frankvnk 1:99bfc8d68fd3 8 * read the following copyright:
frankvnk 1:99bfc8d68fd3 9 *
frankvnk 1:99bfc8d68fd3 10 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
frankvnk 1:99bfc8d68fd3 11 *
frankvnk 1:99bfc8d68fd3 12 * Redistribution and use in source and binary forms, with or without
frankvnk 1:99bfc8d68fd3 13 * modification, are permitted provided that the following conditions
frankvnk 1:99bfc8d68fd3 14 * are met:
frankvnk 1:99bfc8d68fd3 15 *
frankvnk 1:99bfc8d68fd3 16 * Redistributions of source code must retain the above copyright
frankvnk 1:99bfc8d68fd3 17 * notice, this list of conditions and the following disclaimer.
frankvnk 1:99bfc8d68fd3 18 *
frankvnk 1:99bfc8d68fd3 19 * Redistributions in binary form must reproduce the above copyright
frankvnk 1:99bfc8d68fd3 20 * notice, this list of conditions and the following disclaimer in the
frankvnk 1:99bfc8d68fd3 21 * documentation and/or other materials provided with the
frankvnk 1:99bfc8d68fd3 22 * distribution.
frankvnk 1:99bfc8d68fd3 23 *
frankvnk 1:99bfc8d68fd3 24 * Neither the name of Texas Instruments Incorporated nor the names of
frankvnk 1:99bfc8d68fd3 25 * its contributors may be used to endorse or promote products derived
frankvnk 1:99bfc8d68fd3 26 * from this software without specific prior written permission.
frankvnk 1:99bfc8d68fd3 27 *
frankvnk 1:99bfc8d68fd3 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
frankvnk 1:99bfc8d68fd3 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
frankvnk 1:99bfc8d68fd3 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
frankvnk 1:99bfc8d68fd3 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
frankvnk 1:99bfc8d68fd3 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
frankvnk 1:99bfc8d68fd3 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
frankvnk 1:99bfc8d68fd3 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
frankvnk 1:99bfc8d68fd3 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
frankvnk 1:99bfc8d68fd3 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
frankvnk 1:99bfc8d68fd3 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
frankvnk 1:99bfc8d68fd3 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
frankvnk 1:99bfc8d68fd3 39 *
frankvnk 1:99bfc8d68fd3 40 *****************************************************************************/
frankvnk 1:99bfc8d68fd3 41 #ifndef CC3000_H
frankvnk 1:99bfc8d68fd3 42 #define CC3000_H
frankvnk 1:99bfc8d68fd3 43
frankvnk 1:99bfc8d68fd3 44 #include "mbed.h"
frankvnk 1:99bfc8d68fd3 45 #include "cc3000_common.h"
frankvnk 1:99bfc8d68fd3 46 #include "cc3000_spi.h"
frankvnk 1:99bfc8d68fd3 47 #include "cc3000_simplelink.h"
frankvnk 1:99bfc8d68fd3 48 #include "cc3000_netapp.h"
frankvnk 1:99bfc8d68fd3 49 #include "cc3000_nvmem.h"
frankvnk 1:99bfc8d68fd3 50 #include "cc3000_socket.h"
frankvnk 1:99bfc8d68fd3 51
frankvnk 1:99bfc8d68fd3 52 #define MAX_SOCKETS 4
frankvnk 1:99bfc8d68fd3 53 // cc3000 Ethernet Interface - enabled by default
frankvnk 1:99bfc8d68fd3 54 #define CC3000_ETH_COMPAT 1
frankvnk 1:99bfc8d68fd3 55
frankvnk 1:99bfc8d68fd3 56 /** Enable debug messages - set 1 */
frankvnk 1:99bfc8d68fd3 57 // Debug - Socket interface messages
frankvnk 1:99bfc8d68fd3 58 #define CC3000_DEBUG_SOCKET 0
frankvnk 1:99bfc8d68fd3 59 // Debug - HCI TX messages
frankvnk 1:99bfc8d68fd3 60 #define CC3000_DEBUG_HCI_TX 0
frankvnk 1:99bfc8d68fd3 61 // Debug - HCI Rx messages
frankvnk 1:99bfc8d68fd3 62 #define CC3000_DEBUG_HCI_RX 0
frankvnk 1:99bfc8d68fd3 63 // Debug - General Debug
frankvnk 1:99bfc8d68fd3 64 #define CC3000_DEBUG 0
frankvnk 1:99bfc8d68fd3 65 // Add colour to the debug messages, requires a VT100 terminal like putty, comment out to remove
frankvnk 1:99bfc8d68fd3 66 #define VT100_COLOUR 0
frankvnk 1:99bfc8d68fd3 67
frankvnk 1:99bfc8d68fd3 68 #if (CC3000_DEBUG_SOCKET == 1)
frankvnk 1:99bfc8d68fd3 69 #if (VT100_COLOUR == 1)
frankvnk 1:99bfc8d68fd3 70 #define DBG_SOCKET(x, ...) std::printf("\x1b[2;32;40m[CC3000 : SOCKET] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 71 #else
frankvnk 1:99bfc8d68fd3 72 #define DBG_SOCKET(x, ...) std::printf("[CC3000 : SOCKET] "x"\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 73 #endif
frankvnk 1:99bfc8d68fd3 74 #else
frankvnk 1:99bfc8d68fd3 75 #define DBG_SOCKET(x, ...)
frankvnk 1:99bfc8d68fd3 76 #endif
frankvnk 1:99bfc8d68fd3 77
frankvnk 1:99bfc8d68fd3 78 #if (CC3000_DEBUG_HCI_TX == 1)
frankvnk 1:99bfc8d68fd3 79 #if (VT100_COLOUR == 1)
frankvnk 1:99bfc8d68fd3 80 #define DBG_HCI(x, ...) std::printf("\x1b[2;35;40m[CC3000 : HCI RX] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 81 #else
frankvnk 1:99bfc8d68fd3 82 #define DBG_HCI(x, ...) std::printf("[CC3000 : HCI RX] "x"\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 83 #endif
frankvnk 1:99bfc8d68fd3 84 #else
frankvnk 1:99bfc8d68fd3 85 #define DBG_HCI(x, ...)
frankvnk 1:99bfc8d68fd3 86 #endif
frankvnk 1:99bfc8d68fd3 87
frankvnk 1:99bfc8d68fd3 88 #if (CC3000_DEBUG_HCI_RX == 1)
frankvnk 1:99bfc8d68fd3 89 #if (VT100_COLOUR == 1)
frankvnk 1:99bfc8d68fd3 90 #define DBG_HCI_CMD(x, ...) std::printf("\x1b[2;36;40m[CC3000 : HCI TX] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 91 #else
frankvnk 1:99bfc8d68fd3 92 #define DBG_HCI_CMD(x, ...) std::printf("[CC3000 : HCI TX] "x"\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 93 #endif
frankvnk 1:99bfc8d68fd3 94 #else
frankvnk 1:99bfc8d68fd3 95 #define DBG_HCI_CMD(x, ...)
frankvnk 1:99bfc8d68fd3 96 #endif
frankvnk 1:99bfc8d68fd3 97
frankvnk 1:99bfc8d68fd3 98 #if (CC3000_DEBUG == 1)
frankvnk 1:99bfc8d68fd3 99 #if (VT100_COLOUR == 1)
frankvnk 1:99bfc8d68fd3 100 #define DBG_CC(x, ...) std::printf("\x1b[2;32;40m[CC3000] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 101 #else
frankvnk 1:99bfc8d68fd3 102 #define DBG_CC(x, ...) std::printf("[CC3000] "x"\r\n", ##__VA_ARGS__);
frankvnk 1:99bfc8d68fd3 103 #endif
frankvnk 1:99bfc8d68fd3 104 #else
frankvnk 1:99bfc8d68fd3 105 #define DBG_CC(x, ...)
frankvnk 1:99bfc8d68fd3 106 #endif
frankvnk 1:99bfc8d68fd3 107
frankvnk 1:99bfc8d68fd3 108 namespace mbed_cc3000 {
frankvnk 1:99bfc8d68fd3 109
frankvnk 1:99bfc8d68fd3 110 /** User info structure
frankvnk 1:99bfc8d68fd3 111 */
frankvnk 1:99bfc8d68fd3 112 typedef struct {
frankvnk 1:99bfc8d68fd3 113 uint8_t FTC; // First time config performed
frankvnk 1:99bfc8d68fd3 114 uint8_t PP_version[2]; // Patch Programmer version
frankvnk 1:99bfc8d68fd3 115 uint8_t SERV_PACK[2]; // Service Pack Version
frankvnk 1:99bfc8d68fd3 116 uint8_t DRV_VER[3]; // Driver Version
frankvnk 1:99bfc8d68fd3 117 uint8_t FW_VER[3]; // Firmware Version
frankvnk 1:99bfc8d68fd3 118 uint8_t validCIK; // CIK[] is valid (Client Interface Key)
frankvnk 1:99bfc8d68fd3 119 uint8_t CIK[40];
frankvnk 1:99bfc8d68fd3 120 } tUserFS;
frankvnk 1:99bfc8d68fd3 121
frankvnk 1:99bfc8d68fd3 122 /** Function pointers which are not yet implemented
frankvnk 1:99bfc8d68fd3 123 */
frankvnk 1:99bfc8d68fd3 124 enum FunctionNumber {
frankvnk 1:99bfc8d68fd3 125 FW_PATCHES = 0,
frankvnk 1:99bfc8d68fd3 126 DRIVER_PATCHES = 1,
frankvnk 1:99bfc8d68fd3 127 BOOTLOADER_PATCHES = 2,
frankvnk 1:99bfc8d68fd3 128 };
frankvnk 1:99bfc8d68fd3 129
frankvnk 1:99bfc8d68fd3 130 /** CC3000 Simple Link class which contains status of cc3000.
frankvnk 1:99bfc8d68fd3 131 */
frankvnk 1:99bfc8d68fd3 132 class cc3000_simple_link {
frankvnk 1:99bfc8d68fd3 133 public:
frankvnk 1:99bfc8d68fd3 134 /**
frankvnk 1:99bfc8d68fd3 135 * \brief ctor - sets magic number in the buffers (overflow mark).
frankvnk 1:99bfc8d68fd3 136 * \param none
frankvnk 1:99bfc8d68fd3 137 * \return none
frankvnk 1:99bfc8d68fd3 138 */
frankvnk 1:99bfc8d68fd3 139 cc3000_simple_link();
frankvnk 1:99bfc8d68fd3 140 /**
frankvnk 1:99bfc8d68fd3 141 * \brief dtor
frankvnk 1:99bfc8d68fd3 142 * \param none
frankvnk 1:99bfc8d68fd3 143 * \return none
frankvnk 1:99bfc8d68fd3 144 */
frankvnk 1:99bfc8d68fd3 145 ~cc3000_simple_link();
frankvnk 1:99bfc8d68fd3 146 /**
frankvnk 1:99bfc8d68fd3 147 * \brief Returns data received flag.
frankvnk 1:99bfc8d68fd3 148 * \return Data received flag.
frankvnk 1:99bfc8d68fd3 149 */
frankvnk 1:99bfc8d68fd3 150 uint8_t get_data_received_flag();
frankvnk 1:99bfc8d68fd3 151 /**
frankvnk 1:99bfc8d68fd3 152 * \brief Set data received flag.
frankvnk 1:99bfc8d68fd3 153 * \param value The value to be set.
frankvnk 1:99bfc8d68fd3 154 */
frankvnk 1:99bfc8d68fd3 155 void set_data_received_flag(uint8_t value);
frankvnk 1:99bfc8d68fd3 156 /** Returns if tx was completed.
frankvnk 1:99bfc8d68fd3 157 * \return
frankvnk 1:99bfc8d68fd3 158 * true if tx was completed,
frankvnk 1:99bfc8d68fd3 159 * false otherwise.
frankvnk 1:99bfc8d68fd3 160 */
frankvnk 1:99bfc8d68fd3 161 bool get_tx_complete_signal();
frankvnk 1:99bfc8d68fd3 162 /**
frankvnk 1:99bfc8d68fd3 163 * \brief Sets flag that tx was completed.
frankvnk 1:99bfc8d68fd3 164 * \param value Value to be set
frankvnk 1:99bfc8d68fd3 165 * \return none
frankvnk 1:99bfc8d68fd3 166 */
frankvnk 1:99bfc8d68fd3 167 void set_tx_complete_signal(bool value);
frankvnk 1:99bfc8d68fd3 168 /**
frankvnk 1:99bfc8d68fd3 169 * \brief Get receive buffer.
frankvnk 1:99bfc8d68fd3 170 * \param none
frankvnk 1:99bfc8d68fd3 171 * \return Pointer to the receive buffer.
frankvnk 1:99bfc8d68fd3 172 */
frankvnk 1:99bfc8d68fd3 173 uint8_t *get_received_buffer();
frankvnk 1:99bfc8d68fd3 174 /**
frankvnk 1:99bfc8d68fd3 175 * \brief Get transmit buffer.
frankvnk 1:99bfc8d68fd3 176 * \param none
frankvnk 1:99bfc8d68fd3 177 * \return Pointer to the transmit buffer.
frankvnk 1:99bfc8d68fd3 178 */
frankvnk 1:99bfc8d68fd3 179 uint8_t *get_transmit_buffer();
frankvnk 1:99bfc8d68fd3 180 /**
frankvnk 1:99bfc8d68fd3 181 * \brief Get number of free buffers.
frankvnk 1:99bfc8d68fd3 182 * \param none
frankvnk 1:99bfc8d68fd3 183 * \return
frankvnk 1:99bfc8d68fd3 184 * Number of free buffers.
frankvnk 1:99bfc8d68fd3 185 */
frankvnk 1:99bfc8d68fd3 186 uint16_t get_number_free_buffers();
frankvnk 1:99bfc8d68fd3 187 /**
frankvnk 1:99bfc8d68fd3 188 * \brief Set number of free buffers.
frankvnk 1:99bfc8d68fd3 189 * \param value Number of free buffers.
frankvnk 1:99bfc8d68fd3 190 * \return none
frankvnk 1:99bfc8d68fd3 191 */
frankvnk 1:99bfc8d68fd3 192 void set_number_free_buffers(uint16_t value);
frankvnk 1:99bfc8d68fd3 193 /**
frankvnk 1:99bfc8d68fd3 194 * \brief Retrieve buffer length.
frankvnk 1:99bfc8d68fd3 195 * \param none
frankvnk 1:99bfc8d68fd3 196 * \return Buffer length
frankvnk 1:99bfc8d68fd3 197 */
frankvnk 1:99bfc8d68fd3 198 uint16_t get_buffer_length();
frankvnk 1:99bfc8d68fd3 199 /**
frankvnk 1:99bfc8d68fd3 200 * \brief Set buffer length
frankvnk 1:99bfc8d68fd3 201 * \param value The length
frankvnk 1:99bfc8d68fd3 202 * \return none
frankvnk 1:99bfc8d68fd3 203 */
frankvnk 1:99bfc8d68fd3 204 void set_buffer_length(uint16_t value);
frankvnk 1:99bfc8d68fd3 205 /**
frankvnk 1:99bfc8d68fd3 206 * \brief Retrieve pending data flag.
frankvnk 1:99bfc8d68fd3 207 * \param none
frankvnk 1:99bfc8d68fd3 208 * \return Pending data flag
frankvnk 1:99bfc8d68fd3 209 */
frankvnk 1:99bfc8d68fd3 210 uint16_t get_pending_data();
frankvnk 1:99bfc8d68fd3 211 /**
frankvnk 1:99bfc8d68fd3 212 * \brief Set pending data flag.
frankvnk 1:99bfc8d68fd3 213 * \param value Pending data value.
frankvnk 1:99bfc8d68fd3 214 * \return none
frankvnk 1:99bfc8d68fd3 215 */
frankvnk 1:99bfc8d68fd3 216 void set_pending_data(uint16_t value);
frankvnk 1:99bfc8d68fd3 217 /**
frankvnk 1:99bfc8d68fd3 218 * \brief Retreive op code.
frankvnk 1:99bfc8d68fd3 219 * \param none
frankvnk 1:99bfc8d68fd3 220 * \return Op code
frankvnk 1:99bfc8d68fd3 221 */
frankvnk 1:99bfc8d68fd3 222 uint16_t get_op_code();
frankvnk 1:99bfc8d68fd3 223 /**
frankvnk 1:99bfc8d68fd3 224 * \brief Set op code.
frankvnk 1:99bfc8d68fd3 225 * \param code op code.
frankvnk 1:99bfc8d68fd3 226 * \return none
frankvnk 1:99bfc8d68fd3 227 */
frankvnk 1:99bfc8d68fd3 228 void set_op_code(uint16_t code);
frankvnk 1:99bfc8d68fd3 229 /**
frankvnk 1:99bfc8d68fd3 230 * \brief Get number of released packets.
frankvnk 1:99bfc8d68fd3 231 * \param none
frankvnk 1:99bfc8d68fd3 232 * \return Number of released packets.
frankvnk 1:99bfc8d68fd3 233 */
frankvnk 1:99bfc8d68fd3 234 uint16_t get_released_packets();
frankvnk 1:99bfc8d68fd3 235 /**
frankvnk 1:99bfc8d68fd3 236 * \brief Set number of released packets.
frankvnk 1:99bfc8d68fd3 237 * \param value Number of released packets.
frankvnk 1:99bfc8d68fd3 238 * \return none
frankvnk 1:99bfc8d68fd3 239 */
frankvnk 1:99bfc8d68fd3 240 void set_number_of_released_packets(uint16_t value);
frankvnk 1:99bfc8d68fd3 241 /**
frankvnk 1:99bfc8d68fd3 242 * \brief Get number of sent packats
frankvnk 1:99bfc8d68fd3 243 * \param none
frankvnk 1:99bfc8d68fd3 244 * \return Number of sent packets.
frankvnk 1:99bfc8d68fd3 245 */
frankvnk 1:99bfc8d68fd3 246 uint16_t get_sent_packets();
frankvnk 1:99bfc8d68fd3 247 /**
frankvnk 1:99bfc8d68fd3 248 * \brief Set number of sent packets
frankvnk 1:99bfc8d68fd3 249 * \param value Number of sent packets.
frankvnk 1:99bfc8d68fd3 250 * \return none
frankvnk 1:99bfc8d68fd3 251 */
frankvnk 1:99bfc8d68fd3 252 void set_sent_packets(uint16_t value);
frankvnk 1:99bfc8d68fd3 253 /**
frankvnk 1:99bfc8d68fd3 254 * \brief Retrieve transmit error
frankvnk 1:99bfc8d68fd3 255 * \param none
frankvnk 1:99bfc8d68fd3 256 * \return Transmit error
frankvnk 1:99bfc8d68fd3 257 */
frankvnk 1:99bfc8d68fd3 258 int32_t get_transmit_error();
frankvnk 1:99bfc8d68fd3 259 /**
frankvnk 1:99bfc8d68fd3 260 * \brief Set transmit error.
frankvnk 1:99bfc8d68fd3 261 * \param value Error to be set.
frankvnk 1:99bfc8d68fd3 262 * \return none
frankvnk 1:99bfc8d68fd3 263 */
frankvnk 1:99bfc8d68fd3 264 void set_transmit_error(int32_t value);
frankvnk 1:99bfc8d68fd3 265 /**
frankvnk 1:99bfc8d68fd3 266 * \brief Get buffer size.
frankvnk 1:99bfc8d68fd3 267 * \param none
frankvnk 1:99bfc8d68fd3 268 * \return Size of buffer.
frankvnk 1:99bfc8d68fd3 269 */
frankvnk 1:99bfc8d68fd3 270 uint16_t get_buffer_size();
frankvnk 1:99bfc8d68fd3 271 /**
frankvnk 1:99bfc8d68fd3 272 * \brief Set buffer size.
frankvnk 1:99bfc8d68fd3 273 * \param value Buffer size.
frankvnk 1:99bfc8d68fd3 274 * \return none
frankvnk 1:99bfc8d68fd3 275 */
frankvnk 1:99bfc8d68fd3 276 void set_buffer_size(uint16_t value);
frankvnk 1:99bfc8d68fd3 277 /**
frankvnk 1:99bfc8d68fd3 278 * \brief Not used currently.
frankvnk 1:99bfc8d68fd3 279 * \param function Number of desired function.
frankvnk 1:99bfc8d68fd3 280 * \return void pointer to the function (need to recast).
frankvnk 1:99bfc8d68fd3 281 */
frankvnk 1:99bfc8d68fd3 282 void *get_func_pointer(FunctionNumber function);
frankvnk 1:99bfc8d68fd3 283 /**
frankvnk 1:99bfc8d68fd3 284 * \brief Retreive pointer to the received data.
frankvnk 1:99bfc8d68fd3 285 * \param none
frankvnk 1:99bfc8d68fd3 286 * \return Pointer to the received data buffer.
frankvnk 1:99bfc8d68fd3 287 */
frankvnk 1:99bfc8d68fd3 288 uint8_t *get_received_data();
frankvnk 1:99bfc8d68fd3 289 /**
frankvnk 1:99bfc8d68fd3 290 * \brief Set received data pointer.
frankvnk 1:99bfc8d68fd3 291 * \param pointer Pointer to the buffer.
frankvnk 1:99bfc8d68fd3 292 * \return none
frankvnk 1:99bfc8d68fd3 293 */
frankvnk 1:99bfc8d68fd3 294 void set_received_data(uint8_t *pointer);
frankvnk 1:99bfc8d68fd3 295 private:
frankvnk 1:99bfc8d68fd3 296 uint8_t _data_received_flag;
frankvnk 1:99bfc8d68fd3 297 bool _tx_complete_signal;
frankvnk 1:99bfc8d68fd3 298 uint16_t _rx_event_opcode;
frankvnk 1:99bfc8d68fd3 299 uint16_t _free_buffers;
frankvnk 1:99bfc8d68fd3 300 uint16_t _buffer_length;
frankvnk 1:99bfc8d68fd3 301 uint16_t _buffer_size;
frankvnk 1:99bfc8d68fd3 302 uint16_t _rx_data_pending;
frankvnk 1:99bfc8d68fd3 303 uint16_t _sent_packets;
frankvnk 1:99bfc8d68fd3 304 uint16_t _released_packets;
frankvnk 1:99bfc8d68fd3 305 int32_t _transmit_data_error;
frankvnk 1:99bfc8d68fd3 306 uint8_t *_received_data;
frankvnk 1:99bfc8d68fd3 307 uint8_t _rx_buffer[CC3000_RX_BUFFER_SIZE];
frankvnk 1:99bfc8d68fd3 308 uint8_t _tx_buffer[CC3000_TX_BUFFER_SIZE];
frankvnk 1:99bfc8d68fd3 309 private:
frankvnk 1:99bfc8d68fd3 310 /* Not used currently */
frankvnk 1:99bfc8d68fd3 311 int8_t *(* _fFWPatches)(uint32_t *length);
frankvnk 1:99bfc8d68fd3 312 int8_t *(* _fDriverPatches)(uint32_t *length);
frankvnk 1:99bfc8d68fd3 313 int8_t *(* _fBootLoaderPatches)(uint32_t *length);
frankvnk 1:99bfc8d68fd3 314 };
frankvnk 1:99bfc8d68fd3 315
frankvnk 1:99bfc8d68fd3 316 /** Forward declaration classes
frankvnk 1:99bfc8d68fd3 317 */
frankvnk 1:99bfc8d68fd3 318 class cc3000_hci;
frankvnk 1:99bfc8d68fd3 319 class cc3000_nvmem;
frankvnk 1:99bfc8d68fd3 320 class cc3000_spi;
frankvnk 1:99bfc8d68fd3 321 class cc3000;
frankvnk 1:99bfc8d68fd3 322
frankvnk 1:99bfc8d68fd3 323 /** Event layer
frankvnk 1:99bfc8d68fd3 324 */
frankvnk 1:99bfc8d68fd3 325 class cc3000_event {
frankvnk 1:99bfc8d68fd3 326 public:
frankvnk 1:99bfc8d68fd3 327 /**
frankvnk 1:99bfc8d68fd3 328 * \brief
frankvnk 1:99bfc8d68fd3 329 * \param simplelink Reference to simple link object.
frankvnk 1:99bfc8d68fd3 330 * \param hci Reference to hci object.
frankvnk 1:99bfc8d68fd3 331 * \param spi Reference to spi object.
frankvnk 1:99bfc8d68fd3 332 * \param cc3000 Reference to cc3000 object.
frankvnk 1:99bfc8d68fd3 333 * \return none
frankvnk 1:99bfc8d68fd3 334 */
frankvnk 1:99bfc8d68fd3 335 cc3000_event(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_spi &spi, cc3000 &cc3000);
frankvnk 1:99bfc8d68fd3 336 /**
frankvnk 1:99bfc8d68fd3 337 * \brief Ctor
frankvnk 1:99bfc8d68fd3 338 * \param none
frankvnk 1:99bfc8d68fd3 339 * \return none
frankvnk 1:99bfc8d68fd3 340 */
frankvnk 1:99bfc8d68fd3 341 ~cc3000_event();
frankvnk 1:99bfc8d68fd3 342 /**
frankvnk 1:99bfc8d68fd3 343 * \brief Handle unsolicited event from type patch request.
frankvnk 1:99bfc8d68fd3 344 * \param event_hdr event header
frankvnk 1:99bfc8d68fd3 345 * \return none
frankvnk 1:99bfc8d68fd3 346 */
frankvnk 1:99bfc8d68fd3 347 void hci_unsol_handle_patch_request(uint8_t *event_hdr);
frankvnk 1:99bfc8d68fd3 348 /**
frankvnk 1:99bfc8d68fd3 349 * \brief Parse the incoming event packets and issue corresponding event handler from global array of handlers pointers.
frankvnk 1:99bfc8d68fd3 350 * \param ret_param incoming data buffer
frankvnk 1:99bfc8d68fd3 351 * \param from from information (in case of data received)
frankvnk 1:99bfc8d68fd3 352 * \param fromlen from information length (in case of data received)
frankvnk 1:99bfc8d68fd3 353 * \return none
frankvnk 1:99bfc8d68fd3 354 */
frankvnk 1:99bfc8d68fd3 355 uint8_t *hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen);
frankvnk 1:99bfc8d68fd3 356 /**
frankvnk 1:99bfc8d68fd3 357 * \brief Handle unsolicited events.
frankvnk 1:99bfc8d68fd3 358 * \param event_hdr Event header
frankvnk 1:99bfc8d68fd3 359 * \return 1 if event supported and handled
frankvnk 1:99bfc8d68fd3 360 * \return 0 if event is not supported
frankvnk 1:99bfc8d68fd3 361 */
frankvnk 1:99bfc8d68fd3 362 int32_t hci_unsol_event_handler(uint8_t *event_hdr);
frankvnk 1:99bfc8d68fd3 363 /**
frankvnk 1:99bfc8d68fd3 364 * \brief Parse the incoming unsolicited event packets and start corresponding event handler.
frankvnk 1:99bfc8d68fd3 365 * \param None
frankvnk 1:99bfc8d68fd3 366 * \return ESUCCESS if successful, EFAIL if an error occurred.
frankvnk 1:99bfc8d68fd3 367 */
frankvnk 1:99bfc8d68fd3 368 int32_t hci_unsolicited_event_handler(void);
frankvnk 1:99bfc8d68fd3 369 /**
frankvnk 1:99bfc8d68fd3 370 * \brief Get the socket status.
frankvnk 1:99bfc8d68fd3 371 * \param Sd Socket IS
frankvnk 1:99bfc8d68fd3 372 * \return Current status of the socket.
frankvnk 1:99bfc8d68fd3 373 */
frankvnk 1:99bfc8d68fd3 374 int32_t get_socket_active_status(int32_t sd);
frankvnk 1:99bfc8d68fd3 375 /**
frankvnk 1:99bfc8d68fd3 376 * \brief Check if the socket ID and status are valid and set the global socket status accordingly.
frankvnk 1:99bfc8d68fd3 377 * \param Sd Sock descr
frankvnk 1:99bfc8d68fd3 378 * \param Status status to be set
frankvnk 1:99bfc8d68fd3 379 * \return none
frankvnk 1:99bfc8d68fd3 380 */
frankvnk 1:99bfc8d68fd3 381 void set_socket_active_status(int32_t sd, int32_t status);
frankvnk 1:99bfc8d68fd3 382 /**
frankvnk 1:99bfc8d68fd3 383 * \brief Keep track on the number of packets transmitted and update the number of free buffer in the SL device.
frankvnk 1:99bfc8d68fd3 384 * \brief Called when unsolicited event = HCI_EVNT_DATA_UNSOL_FREE_BUFF has received.
frankvnk 1:99bfc8d68fd3 385 * \param event pointer to the string contains parameters for IPERF.
frankvnk 1:99bfc8d68fd3 386 * \return ESUCCESS if successful, EFAIL if an error occurred.
frankvnk 1:99bfc8d68fd3 387 */
frankvnk 1:99bfc8d68fd3 388 int32_t hci_event_unsol_flowcontrol_handler(uint8_t *event);
frankvnk 1:99bfc8d68fd3 389 /**
frankvnk 1:99bfc8d68fd3 390 * \brief Update the socket status.
frankvnk 1:99bfc8d68fd3 391 * \param resp_params Socket IS
frankvnk 1:99bfc8d68fd3 392 * \return Current status of the socket.
frankvnk 1:99bfc8d68fd3 393 */
frankvnk 1:99bfc8d68fd3 394 void update_socket_active_status(uint8_t *resp_params);
frankvnk 1:99bfc8d68fd3 395 /**
frankvnk 1:99bfc8d68fd3 396 * \brief Wait for event, pass it to the hci_event_handler and update the event opcode in a global variable.
frankvnk 1:99bfc8d68fd3 397 * \param op_code Command operation code
frankvnk 1:99bfc8d68fd3 398 * \param ret_param Command return parameters
frankvnk 1:99bfc8d68fd3 399 * \return none
frankvnk 1:99bfc8d68fd3 400 */
frankvnk 1:99bfc8d68fd3 401 void simplelink_wait_event(uint16_t op_code, void *ret_param);
frankvnk 1:99bfc8d68fd3 402 /**
frankvnk 1:99bfc8d68fd3 403 * \brief Wait for data, pass it to the hci_event_handler and set the data available flag.
frankvnk 1:99bfc8d68fd3 404 * \param buffer Data buffer
frankvnk 1:99bfc8d68fd3 405 * \param from From information
frankvnk 1:99bfc8d68fd3 406 * \param fromlen From information length
frankvnk 1:99bfc8d68fd3 407 * \return none
frankvnk 1:99bfc8d68fd3 408 */
frankvnk 1:99bfc8d68fd3 409 void simplelink_wait_data(uint8_t *buffer, uint8_t *from, uint8_t *fromlen);
frankvnk 1:99bfc8d68fd3 410 /**
frankvnk 1:99bfc8d68fd3 411 * \brief Trigger Received event/data processing - called from the SPI library to receive the data
frankvnk 1:99bfc8d68fd3 412 * \param buffer pointer to the received data buffer\n
frankvnk 1:99bfc8d68fd3 413 * The function triggers Received event/data processing\n
frankvnk 1:99bfc8d68fd3 414 * \return none
frankvnk 1:99bfc8d68fd3 415 */
frankvnk 1:99bfc8d68fd3 416 void received_handler(uint8_t *buffer);
frankvnk 1:99bfc8d68fd3 417 private:
frankvnk 1:99bfc8d68fd3 418 uint32_t socket_active_status;
frankvnk 1:99bfc8d68fd3 419 cc3000_simple_link &_simple_link;
frankvnk 1:99bfc8d68fd3 420 cc3000_hci &_hci;
frankvnk 1:99bfc8d68fd3 421 cc3000_spi &_spi;
frankvnk 1:99bfc8d68fd3 422 cc3000 &_cc3000;
frankvnk 1:99bfc8d68fd3 423 };
frankvnk 1:99bfc8d68fd3 424
frankvnk 1:99bfc8d68fd3 425 /** Netapp layer
frankvnk 1:99bfc8d68fd3 426 */
frankvnk 1:99bfc8d68fd3 427 class cc3000_netapp {
frankvnk 1:99bfc8d68fd3 428 public:
frankvnk 1:99bfc8d68fd3 429 /**
frankvnk 1:99bfc8d68fd3 430 * \brief Ctor
frankvnk 1:99bfc8d68fd3 431 * \param simple_link Reference to the simple link object.
frankvnk 1:99bfc8d68fd3 432 * \param nvmem Reference to the nvmem object.
frankvnk 1:99bfc8d68fd3 433 * \param hci Reference to the hci object.
frankvnk 1:99bfc8d68fd3 434 * \param event Reference to the event object.
frankvnk 1:99bfc8d68fd3 435 * \return none
frankvnk 1:99bfc8d68fd3 436 */
frankvnk 1:99bfc8d68fd3 437 cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci, cc3000_event &event);
frankvnk 1:99bfc8d68fd3 438 /**
frankvnk 1:99bfc8d68fd3 439 * \brief Dtor
frankvnk 1:99bfc8d68fd3 440 * \param none
frankvnk 1:99bfc8d68fd3 441 * \return none
frankvnk 1:99bfc8d68fd3 442 */
frankvnk 1:99bfc8d68fd3 443 ~cc3000_netapp();
frankvnk 1:99bfc8d68fd3 444 /**
frankvnk 1:99bfc8d68fd3 445 * \brief Configure device MAC address and store it in NVMEM.
frankvnk 1:99bfc8d68fd3 446 * The value of the MAC address configured through the API will be\n
frankvnk 1:99bfc8d68fd3 447 * stored in CC3000 non volatile memory, thus preserved over resets.\n
frankvnk 1:99bfc8d68fd3 448 * \param mac device mac address, 6 bytes. Saved: yes
frankvnk 1:99bfc8d68fd3 449 * \return return on success 0, otherwise error.
frankvnk 1:99bfc8d68fd3 450 */
frankvnk 1:99bfc8d68fd3 451 int32_t config_mac_adrress(uint8_t *mac);
frankvnk 1:99bfc8d68fd3 452 /**
frankvnk 1:99bfc8d68fd3 453 * \brief Configure the network interface, static or dynamic (DHCP).
frankvnk 1:99bfc8d68fd3 454 * In order to activate DHCP mode, ip, subnet_mask, default_gateway must be 0.\n
frankvnk 1:99bfc8d68fd3 455 * The default mode of CC3000 is DHCP mode. The configuration is saved in non volatile memory\n
frankvnk 1:99bfc8d68fd3 456 * and thus preserved over resets.\n
frankvnk 1:99bfc8d68fd3 457 * \param ip device mac address, 6 bytes. Saved: yes
frankvnk 1:99bfc8d68fd3 458 * \param subnet_mask device mac address, 6 bytes. Saved: yes
frankvnk 1:99bfc8d68fd3 459 * \param default_gateway device mac address, 6 bytes. Saved: yes
frankvnk 1:99bfc8d68fd3 460 * \param dns_server device mac address, 6 bytes. Saved: yes
frankvnk 1:99bfc8d68fd3 461 * \return 0 on success, otherwise error.
frankvnk 1:99bfc8d68fd3 462 * \note If the mode is altered, a reset of CC3000 device is required to apply the changes.\n
frankvnk 1:99bfc8d68fd3 463 * Also note that an asynchronous event of type 'DHCP_EVENT' is generated only when\n
frankvnk 1:99bfc8d68fd3 464 * a connection to the AP was established. This event is generated when an IP address\n
frankvnk 1:99bfc8d68fd3 465 * is allocated either by the DHCP server or by static allocation.\n
frankvnk 1:99bfc8d68fd3 466 */
frankvnk 1:99bfc8d68fd3 467 int32_t dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server);
frankvnk 1:99bfc8d68fd3 468 #ifndef CC3000_TINY_DRIVER
frankvnk 1:99bfc8d68fd3 469 /**
frankvnk 1:99bfc8d68fd3 470 * \brief Get the CC3000 Network interface information.
frankvnk 1:99bfc8d68fd3 471 * This information is only available after establishing a WLAN connection.\n
frankvnk 1:99bfc8d68fd3 472 * Undefined values are returned when this function is called before association.\n
frankvnk 1:99bfc8d68fd3 473 * \param ipconfig pointer to a tNetappIpconfigRetArgs structure for storing the network interface configuration.\n
frankvnk 1:99bfc8d68fd3 474 * tNetappIpconfigRetArgs: aucIP - ip address,\n
frankvnk 1:99bfc8d68fd3 475 * aucSubnetMask - mask
frankvnk 1:99bfc8d68fd3 476 * aucDefaultGateway - default gateway address\n
frankvnk 1:99bfc8d68fd3 477 * aucDHCPServer - dhcp server address\n
frankvnk 1:99bfc8d68fd3 478 * aucDNSServer - dns server address\n
frankvnk 1:99bfc8d68fd3 479 * uaMacAddr - mac address\n
frankvnk 1:99bfc8d68fd3 480 * uaSSID - connected AP ssid\n
frankvnk 1:99bfc8d68fd3 481 * \return none
frankvnk 1:99bfc8d68fd3 482 * \note This function is useful for figuring out the IP Configuration of\n
frankvnk 1:99bfc8d68fd3 483 * the device when DHCP is used and for figuring out the SSID of\n
frankvnk 1:99bfc8d68fd3 484 * the Wireless network the device is associated with.\n
frankvnk 1:99bfc8d68fd3 485 */
frankvnk 1:99bfc8d68fd3 486 void ipconfig(tNetappIpconfigRetArgs *ipconfig);
frankvnk 1:99bfc8d68fd3 487 /**
frankvnk 1:99bfc8d68fd3 488 * \brief Set new timeout values for DHCP lease timeout, ARP refresh timeout, keepalive event timeout and socket inactivity timeout
frankvnk 1:99bfc8d68fd3 489 * \param dhcp DHCP lease time request, also impact\n
frankvnk 1:99bfc8d68fd3 490 * the DHCP renew timeout.\n
frankvnk 1:99bfc8d68fd3 491 * Range: [0-0xffffffff] seconds,\n
frankvnk 1:99bfc8d68fd3 492 * 0 or 0xffffffff = infinite lease timeout.\n
frankvnk 1:99bfc8d68fd3 493 * Resolution: 10 seconds.\n
frankvnk 1:99bfc8d68fd3 494 * Influence: only after reconnecting to the AP. \n
frankvnk 1:99bfc8d68fd3 495 * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.\n
frankvnk 1:99bfc8d68fd3 496 * The parameter is saved into the CC3000 NVMEM.\n
frankvnk 1:99bfc8d68fd3 497 * The default value on CC3000 is 14400 seconds.\n
frankvnk 1:99bfc8d68fd3 498 *
frankvnk 1:99bfc8d68fd3 499 * \param arp ARP refresh timeout, if ARP entry is not updated by\n
frankvnk 1:99bfc8d68fd3 500 * incoming packet, the ARP entry will be deleted by\n
frankvnk 1:99bfc8d68fd3 501 * the end of the timeout. \n
frankvnk 1:99bfc8d68fd3 502 * Range: [0-0xffffffff] seconds, 0 = infinite ARP timeout\n
frankvnk 1:99bfc8d68fd3 503 * Resolution: 10 seconds.\n
frankvnk 1:99bfc8d68fd3 504 * Influence: at runtime.\n
frankvnk 1:99bfc8d68fd3 505 * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds\n
frankvnk 1:99bfc8d68fd3 506 * The parameter is saved into the CC3000 NVMEM.\n
frankvnk 1:99bfc8d68fd3 507 * The default value on CC3000 is 3600 seconds.\n
frankvnk 1:99bfc8d68fd3 508 *
frankvnk 1:99bfc8d68fd3 509 * \param keep_alive Keepalive event sent by the end of keepalive timeout\n
frankvnk 1:99bfc8d68fd3 510 * Range: [0-0xffffffff] seconds, 0 == infinite timeout\n
frankvnk 1:99bfc8d68fd3 511 * Resolution: 10 seconds.\n
frankvnk 1:99bfc8d68fd3 512 * Influence: at runtime.\n
frankvnk 1:99bfc8d68fd3 513 * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec\n
frankvnk 1:99bfc8d68fd3 514 * The parameter is saved into the CC3000 NVMEM. \n
frankvnk 1:99bfc8d68fd3 515 * The default value on CC3000 is 10 seconds.\n
frankvnk 1:99bfc8d68fd3 516 *
frankvnk 1:99bfc8d68fd3 517 * \param inactivity Socket inactivity timeout, socket timeout is\n
frankvnk 1:99bfc8d68fd3 518 * refreshed by incoming or outgoing packet, by the\n
frankvnk 1:99bfc8d68fd3 519 * end of the socket timeout the socket will be closed\n
frankvnk 1:99bfc8d68fd3 520 * Range: [0-0xffffffff] sec, 0 == infinite timeout.\n
frankvnk 1:99bfc8d68fd3 521 * Resolution: 10 seconds.\n
frankvnk 1:99bfc8d68fd3 522 * Influence: at runtime.\n
frankvnk 1:99bfc8d68fd3 523 * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec\n
frankvnk 1:99bfc8d68fd3 524 * The parameter is saved into the CC3000 NVMEM.\n
frankvnk 1:99bfc8d68fd3 525 * The default value on CC3000 is 60 seconds.\n
frankvnk 1:99bfc8d68fd3 526 *
frankvnk 1:99bfc8d68fd3 527 * \return 0 on success,otherwise error.
frankvnk 1:99bfc8d68fd3 528 *
frankvnk 1:99bfc8d68fd3 529 * \note A parameter set to a non zero value less than 20s automatically changes to 20s.
frankvnk 1:99bfc8d68fd3 530 */
frankvnk 1:99bfc8d68fd3 531 int32_t timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity);
frankvnk 1:99bfc8d68fd3 532 /**
frankvnk 1:99bfc8d68fd3 533 * \brief send ICMP ECHO_REQUEST to network hosts
frankvnk 1:99bfc8d68fd3 534 * \param ip destination IP address
frankvnk 1:99bfc8d68fd3 535 * \param ping_attempts number of echo requests to send
frankvnk 1:99bfc8d68fd3 536 * \param ping_size send buffer size which may be up to 1400 bytes
frankvnk 1:99bfc8d68fd3 537 * \param ping_timeout Time to wait for a response,in milliseconds.
frankvnk 1:99bfc8d68fd3 538 * \return 0 on success, otherwise error.
frankvnk 1:99bfc8d68fd3 539 *
frankvnk 1:99bfc8d68fd3 540 * \note A succesful operation will generate an asynchronous ping report event.\n
frankvnk 1:99bfc8d68fd3 541 * The report structure is defined by structure netapp_pingreport_args_t.\n
frankvnk 1:99bfc8d68fd3 542 * \warning Calling this function while a Ping Request is in progress will kill the ping request in progress.
frankvnk 1:99bfc8d68fd3 543 */
frankvnk 1:99bfc8d68fd3 544 int32_t ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout);
frankvnk 1:99bfc8d68fd3 545 /**
frankvnk 1:99bfc8d68fd3 546 * \brief Ping status request.
frankvnk 1:99bfc8d68fd3 547 * This API triggers the CC3000 to send asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT.\n
frankvnk 1:99bfc8d68fd3 548 * This event will create the report structure in netapp_pingreport_args_t.\n
frankvnk 1:99bfc8d68fd3 549 * This structure is filled with ping results until the API is triggered.\n
frankvnk 1:99bfc8d68fd3 550 * netapp_pingreport_args_t: packets_sent - echo sent\n
frankvnk 1:99bfc8d68fd3 551 * packets_received - echo reply\n
frankvnk 1:99bfc8d68fd3 552 * min_round_time - minimum round time\n
frankvnk 1:99bfc8d68fd3 553 * max_round_time - max round time\n
frankvnk 1:99bfc8d68fd3 554 * avg_round_time - average round time\n
frankvnk 1:99bfc8d68fd3 555 *
frankvnk 1:99bfc8d68fd3 556 * \param none
frankvnk 1:99bfc8d68fd3 557 * \return none
frankvnk 1:99bfc8d68fd3 558 * \note When a ping operation is not active, the returned structure fields are 0.
frankvnk 1:99bfc8d68fd3 559 */
frankvnk 1:99bfc8d68fd3 560 void ping_report();
frankvnk 1:99bfc8d68fd3 561 /**
frankvnk 1:99bfc8d68fd3 562 * \brief Stop any ping request.
frankvnk 1:99bfc8d68fd3 563 * \param none
frankvnk 1:99bfc8d68fd3 564 * \return 0 on success
frankvnk 1:99bfc8d68fd3 565 * -1 on error
frankvnk 1:99bfc8d68fd3 566 */
frankvnk 1:99bfc8d68fd3 567 int32_t ping_stop();
frankvnk 1:99bfc8d68fd3 568 /**
frankvnk 1:99bfc8d68fd3 569 * \brief Flush ARP table
frankvnk 1:99bfc8d68fd3 570 * \param none
frankvnk 1:99bfc8d68fd3 571 * \return none
frankvnk 1:99bfc8d68fd3 572 */
frankvnk 1:99bfc8d68fd3 573 int32_t arp_flush();
frankvnk 1:99bfc8d68fd3 574 #endif
frankvnk 1:99bfc8d68fd3 575 private:
frankvnk 1:99bfc8d68fd3 576 cc3000_simple_link &_simple_link;
frankvnk 1:99bfc8d68fd3 577 cc3000_nvmem &_nvmem;
frankvnk 1:99bfc8d68fd3 578 cc3000_hci &_hci;
frankvnk 1:99bfc8d68fd3 579 cc3000_event &_event;
frankvnk 1:99bfc8d68fd3 580 };
frankvnk 1:99bfc8d68fd3 581
frankvnk 1:99bfc8d68fd3 582 #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
frankvnk 1:99bfc8d68fd3 583 /** Security class used only if encrypted smart config is set
frankvnk 1:99bfc8d68fd3 584 */
frankvnk 1:99bfc8d68fd3 585 class cc3000_security {
frankvnk 1:99bfc8d68fd3 586 public:
frankvnk 1:99bfc8d68fd3 587 /**
frankvnk 1:99bfc8d68fd3 588 * \brief Expand a 16 bytes key for AES128 implementation.
frankvnk 1:99bfc8d68fd3 589 * \param expanded_key expanded AES128 key
frankvnk 1:99bfc8d68fd3 590 * \param key AES128 key - 16 bytes
frankvnk 1:99bfc8d68fd3 591 * \return none
frankvnk 1:99bfc8d68fd3 592 */
frankvnk 1:99bfc8d68fd3 593 void expandKey(uint8_t *expanded_key, uint8_t *key);
frankvnk 1:99bfc8d68fd3 594 /**
frankvnk 1:99bfc8d68fd3 595 * \brief multiply by 2 in the galois field.
frankvnk 1:99bfc8d68fd3 596 * \param value Argument to multiply
frankvnk 1:99bfc8d68fd3 597 * \return multiplied argument
frankvnk 1:99bfc8d68fd3 598 */
frankvnk 1:99bfc8d68fd3 599 uint8_t galois_mul2(uint8_t value);
frankvnk 1:99bfc8d68fd3 600 /**
frankvnk 1:99bfc8d68fd3 601 * \brief internal implementation of AES128 encryption.
frankvnk 1:99bfc8d68fd3 602 * straight forward aes encryption implementation\n
frankvnk 1:99bfc8d68fd3 603 * first the group of operations
frankvnk 1:99bfc8d68fd3 604 * - addRoundKey
frankvnk 1:99bfc8d68fd3 605 * - subbytes
frankvnk 1:99bfc8d68fd3 606 * - shiftrows
frankvnk 1:99bfc8d68fd3 607 * - mixcolums\n
frankvnk 1:99bfc8d68fd3 608 *
frankvnk 1:99bfc8d68fd3 609 * is executed 9 times, after this addroundkey to finish the 9th\n
frankvnk 1:99bfc8d68fd3 610 * round, after that the 10th round without mixcolums\n
frankvnk 1:99bfc8d68fd3 611 * no further subfunctions to save cycles for function calls\n
frankvnk 1:99bfc8d68fd3 612 * no structuring with "for (....)" to save cycles.\n
frankvnk 1:99bfc8d68fd3 613 * \param[in] expanded_key expanded AES128 key
frankvnk 1:99bfc8d68fd3 614 * \param[in/out] state 16 bytes of plain text and cipher text
frankvnk 1:99bfc8d68fd3 615 * \return none
frankvnk 1:99bfc8d68fd3 616 */
frankvnk 1:99bfc8d68fd3 617 void aes_encr(uint8_t *state, uint8_t *expanded_key);
frankvnk 1:99bfc8d68fd3 618 /**
frankvnk 1:99bfc8d68fd3 619 * \brief internal implementation of AES128 decryption.
frankvnk 1:99bfc8d68fd3 620 * straightforward aes decryption implementation\n
frankvnk 1:99bfc8d68fd3 621 * the order of substeps is the exact reverse of decryption\n
frankvnk 1:99bfc8d68fd3 622 * inverse functions:
frankvnk 1:99bfc8d68fd3 623 * - addRoundKey is its own inverse
frankvnk 1:99bfc8d68fd3 624 * - rsbox is inverse of sbox
frankvnk 1:99bfc8d68fd3 625 * - rightshift instead of leftshift
frankvnk 1:99bfc8d68fd3 626 * - invMixColumns = barreto + mixColumns\n
frankvnk 1:99bfc8d68fd3 627 *
frankvnk 1:99bfc8d68fd3 628 * no further subfunctions to save cycles for function calls\n
frankvnk 1:99bfc8d68fd3 629 * no structuring with "for (....)" to save cycles\n
frankvnk 1:99bfc8d68fd3 630 * \param[in] expanded_key expanded AES128 key
frankvnk 1:99bfc8d68fd3 631 * \param[in\out] state 16 bytes of cipher text and plain text
frankvnk 1:99bfc8d68fd3 632 * \return none
frankvnk 1:99bfc8d68fd3 633 */
frankvnk 1:99bfc8d68fd3 634 void aes_decr(uint8_t *state, uint8_t *expanded_key);
frankvnk 1:99bfc8d68fd3 635 /**
frankvnk 1:99bfc8d68fd3 636 * \brief AES128 encryption.
frankvnk 1:99bfc8d68fd3 637 * Given AES128 key and 16 bytes plain text, cipher text of 16 bytes is computed.\n
frankvnk 1:99bfc8d68fd3 638 * The AES implementation is in mode ECB (Electronic Code Book).\n
frankvnk 1:99bfc8d68fd3 639 * \param[in] key AES128 key of size 16 bytes
frankvnk 1:99bfc8d68fd3 640 * \param[in\out] state 16 bytes of plain text and cipher text
frankvnk 1:99bfc8d68fd3 641 * \return none
frankvnk 1:99bfc8d68fd3 642 */
frankvnk 1:99bfc8d68fd3 643 void aes_encrypt(uint8_t *state, uint8_t *key);
frankvnk 1:99bfc8d68fd3 644 /**
frankvnk 1:99bfc8d68fd3 645 * \brief AES128 decryption.
frankvnk 1:99bfc8d68fd3 646 * Given AES128 key and 16 bytes cipher text, plain text of 16 bytes is computed.\n
frankvnk 1:99bfc8d68fd3 647 * The AES implementation is in mode ECB (Electronic Code Book).\n
frankvnk 1:99bfc8d68fd3 648 * \param[in] key AES128 key of size 16 bytes
frankvnk 1:99bfc8d68fd3 649 * \param[in\out] state 16 bytes of cipher text and plain text
frankvnk 1:99bfc8d68fd3 650 * \return none
frankvnk 1:99bfc8d68fd3 651 */
frankvnk 1:99bfc8d68fd3 652 void aes_decrypt(uint8_t *state, uint8_t *key);
frankvnk 1:99bfc8d68fd3 653 /**
frankvnk 1:99bfc8d68fd3 654 * \brief Read the AES128 key from fileID #12 in EEPROM.
frankvnk 1:99bfc8d68fd3 655 * \param[out] key AES128 key of size 16 bytes
frankvnk 1:99bfc8d68fd3 656 * \return 0 on success, error otherwise.
frankvnk 1:99bfc8d68fd3 657 */
frankvnk 1:99bfc8d68fd3 658 int32_t aes_read_key(uint8_t *key);
frankvnk 1:99bfc8d68fd3 659 /**
frankvnk 1:99bfc8d68fd3 660 * \brief Write the AES128 key to fileID #12 in EEPROM.
frankvnk 1:99bfc8d68fd3 661 * \param[out] key AES128 key of size 16 bytes
frankvnk 1:99bfc8d68fd3 662 * \return on success 0, error otherwise.
frankvnk 1:99bfc8d68fd3 663 */
frankvnk 1:99bfc8d68fd3 664 int32_t aes_write_key(uint8_t *key);
frankvnk 1:99bfc8d68fd3 665 private:
frankvnk 1:99bfc8d68fd3 666 uint8_t _expanded_key[176];
frankvnk 1:99bfc8d68fd3 667 };
frankvnk 1:99bfc8d68fd3 668 #endif
frankvnk 1:99bfc8d68fd3 669
frankvnk 1:99bfc8d68fd3 670 /** Socket layer
frankvnk 1:99bfc8d68fd3 671 */
frankvnk 1:99bfc8d68fd3 672 class cc3000_socket {
frankvnk 1:99bfc8d68fd3 673 public:
frankvnk 1:99bfc8d68fd3 674 /**
frankvnk 1:99bfc8d68fd3 675 * \brief Ctor
frankvnk 1:99bfc8d68fd3 676 * \param simplelink Reference to simple link object.
frankvnk 1:99bfc8d68fd3 677 * \param hci Reference to hci object.
frankvnk 1:99bfc8d68fd3 678 * \param event Reference to event object.
frankvnk 1:99bfc8d68fd3 679 * \return none
frankvnk 1:99bfc8d68fd3 680 */
frankvnk 1:99bfc8d68fd3 681 cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event);
frankvnk 1:99bfc8d68fd3 682 /**
frankvnk 1:99bfc8d68fd3 683 * \brief Dtor
frankvnk 1:99bfc8d68fd3 684 * \param
frankvnk 1:99bfc8d68fd3 685 * \return none
frankvnk 1:99bfc8d68fd3 686 */
frankvnk 1:99bfc8d68fd3 687 ~cc3000_socket();
frankvnk 1:99bfc8d68fd3 688 /**
frankvnk 1:99bfc8d68fd3 689 * \brief create an endpoint for communication.
frankvnk 1:99bfc8d68fd3 690 * The socket function creates a socket that is bound to a specific transport service provider.\n
frankvnk 1:99bfc8d68fd3 691 * This function is called by the application layer to obtain a socket handle.\n
frankvnk 1:99bfc8d68fd3 692 *
frankvnk 1:99bfc8d68fd3 693 * \param domain selects the protocol family which will be used for\n
frankvnk 1:99bfc8d68fd3 694 * communication. On this version only AF_INET is supported\n
frankvnk 1:99bfc8d68fd3 695 * \param type specifies the communication semantics. On this version\n
frankvnk 1:99bfc8d68fd3 696 * only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported\n
frankvnk 1:99bfc8d68fd3 697 * \param protocol specifies a particular protocol to be used with the\n
frankvnk 1:99bfc8d68fd3 698 * socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are supported.\n
frankvnk 1:99bfc8d68fd3 699 * \return On success, socket handle that is used for consequent socket operations\n
frankvnk 1:99bfc8d68fd3 700 * On error, -1 is returned.\n
frankvnk 1:99bfc8d68fd3 701 */
frankvnk 1:99bfc8d68fd3 702 int32_t socket(int32_t domain, int32_t type, int32_t protocol);
frankvnk 1:99bfc8d68fd3 703 /**
frankvnk 1:99bfc8d68fd3 704 * \brief accept a connection on a socket.
frankvnk 1:99bfc8d68fd3 705 * This function is used with connection-based socket types\n
frankvnk 1:99bfc8d68fd3 706 * (SOCK_STREAM). It extracts the first connection request on the\n
frankvnk 1:99bfc8d68fd3 707 * queue of pending connections, creates a new connected socket, and\n
frankvnk 1:99bfc8d68fd3 708 * returns a new file descriptor referring to that socket.\n
frankvnk 1:99bfc8d68fd3 709 * The newly created socket is not in the listening state.\n
frankvnk 1:99bfc8d68fd3 710 * The original socket sd is unaffected by this call.\n
frankvnk 1:99bfc8d68fd3 711 * The argument sd is a socket that has been created with socket(),\n
frankvnk 1:99bfc8d68fd3 712 * bound to a local address with bind(), and is listening for \n
frankvnk 1:99bfc8d68fd3 713 * connections after a listen(). The argument addr is a pointer \n
frankvnk 1:99bfc8d68fd3 714 * to a sockaddr structure. This structure is filled in with the \n
frankvnk 1:99bfc8d68fd3 715 * address of the peer socket, as known to the communications layer.\n
frankvnk 1:99bfc8d68fd3 716 * The exact format of the address returned addr is determined by the \n
frankvnk 1:99bfc8d68fd3 717 * socket's address family. The addrlen argument is a value-result\n
frankvnk 1:99bfc8d68fd3 718 * argument: it should initially contain the size of the structure\n
frankvnk 1:99bfc8d68fd3 719 * pointed to by addr, on return it will contain the actual\n
frankvnk 1:99bfc8d68fd3 720 * length (in bytes) of the address returned.\n
frankvnk 1:99bfc8d68fd3 721 *
frankvnk 1:99bfc8d68fd3 722 * \param[in] sd socket descriptor (handle)\n
frankvnk 1:99bfc8d68fd3 723 * \param[out] addr the argument addr is a pointer to a sockaddr structure\n
frankvnk 1:99bfc8d68fd3 724 * This structure is filled in with the address of the \n
frankvnk 1:99bfc8d68fd3 725 * peer socket, as known to the communications layer. \n
frankvnk 1:99bfc8d68fd3 726 * determined. The exact format of the address returned \n
frankvnk 1:99bfc8d68fd3 727 * addr is by the socket's address sockaddr. \n
frankvnk 1:99bfc8d68fd3 728 * On this version only AF_INET is supported.\n
frankvnk 1:99bfc8d68fd3 729 * This argument returns in network order.\n
frankvnk 1:99bfc8d68fd3 730 * \param[out] addrlen the addrlen argument is a value-result argument: \n
frankvnk 1:99bfc8d68fd3 731 * it should initially contain the size of the structure\n
frankvnk 1:99bfc8d68fd3 732 * pointed to by addr.\n
frankvnk 1:99bfc8d68fd3 733 * \return For socket in blocking mode:\n
frankvnk 1:99bfc8d68fd3 734 * - On success, socket handle. on failure negative\n
frankvnk 1:99bfc8d68fd3 735 * For socket in non-blocking mode:\n
frankvnk 1:99bfc8d68fd3 736 * - On connection establishment, socket handle\n
frankvnk 1:99bfc8d68fd3 737 * - On connection pending, SOC_IN_PROGRESS (-2)\n
frankvnk 1:99bfc8d68fd3 738 * - On failure, SOC_ERROR (-1)\n
frankvnk 1:99bfc8d68fd3 739 * \sa socket ; bind ; listen
frankvnk 1:99bfc8d68fd3 740 */
frankvnk 1:99bfc8d68fd3 741 int32_t accept(int32_t sd, sockaddr *addr, socklen_t *addrlen);
frankvnk 1:99bfc8d68fd3 742 /**
frankvnk 1:99bfc8d68fd3 743 * \brief assign a name to a socket.
frankvnk 1:99bfc8d68fd3 744 * This function gives the socket the local address addr.\n
frankvnk 1:99bfc8d68fd3 745 * addr is addrlen bytes long. Traditionally, this is called when a \n
frankvnk 1:99bfc8d68fd3 746 * socket is created with socket, it exists in a name space (address \n
frankvnk 1:99bfc8d68fd3 747 * family) but has no name assigned.\n
frankvnk 1:99bfc8d68fd3 748 * It is necessary to assign a local address before a SOCK_STREAM\n
frankvnk 1:99bfc8d68fd3 749 * socket may receive connections.\n
frankvnk 1:99bfc8d68fd3 750 *
frankvnk 1:99bfc8d68fd3 751 * \param[in] sd socket descriptor (handle)
frankvnk 1:99bfc8d68fd3 752 * \param[out] addr specifies the destination address. On this version\n
frankvnk 1:99bfc8d68fd3 753 * only AF_INET is supported.\n
frankvnk 1:99bfc8d68fd3 754 * \param[out] addrlen contains the size of the structure pointed to by addr.\n
frankvnk 1:99bfc8d68fd3 755 * \return On success, zero is returned.\n
frankvnk 1:99bfc8d68fd3 756 * On error, -1 is returned.\n
frankvnk 1:99bfc8d68fd3 757 * \sa socket ; accept ; listen
frankvnk 1:99bfc8d68fd3 758 */
frankvnk 1:99bfc8d68fd3 759 int32_t bind(int32_t sd, const sockaddr *addr, int32_t addrlen);
frankvnk 1:99bfc8d68fd3 760 /**
frankvnk 1:99bfc8d68fd3 761 * \brief HostFlowControlConsumeBuff.
frankvnk 1:99bfc8d68fd3 762 * if SEND_NON_BLOCKING is not defined - block until a free buffer is available,\n
frankvnk 1:99bfc8d68fd3 763 * otherwise return the status of the available buffers.\n
frankvnk 1:99bfc8d68fd3 764 *
frankvnk 1:99bfc8d68fd3 765 * \param sd socket descriptor
frankvnk 1:99bfc8d68fd3 766 * \return 0 in case there are buffers available, \n
frankvnk 1:99bfc8d68fd3 767 * -1 in case of bad socket\n
frankvnk 1:99bfc8d68fd3 768 * -2 if there are no free buffers present (only when SEND_NON_BLOCKING is enabled)\n
frankvnk 1:99bfc8d68fd3 769 */
frankvnk 1:99bfc8d68fd3 770 int32_t HostFlowControlConsumeBuff(int32_t sd);
frankvnk 1:99bfc8d68fd3 771 /**
frankvnk 1:99bfc8d68fd3 772 * \brief The socket function closes a created socket.
frankvnk 1:99bfc8d68fd3 773 * \param sd socket handle.
frankvnk 1:99bfc8d68fd3 774 * \return On success, zero is returned. On error, -1 is returned.
frankvnk 1:99bfc8d68fd3 775 */
frankvnk 1:99bfc8d68fd3 776 int32_t closesocket(int32_t sd);
frankvnk 1:99bfc8d68fd3 777 /**
frankvnk 1:99bfc8d68fd3 778 * \brief listen for connections on a socket.
frankvnk 1:99bfc8d68fd3 779 * The willingness to accept incoming connections and a queue\n
frankvnk 1:99bfc8d68fd3 780 * limit for incoming connections are specified with listen(),\n
frankvnk 1:99bfc8d68fd3 781 * and then the connections are accepted with accept.\n
frankvnk 1:99bfc8d68fd3 782 * The listen() call applies only to sockets of type SOCK_STREAM\n
frankvnk 1:99bfc8d68fd3 783 * The backlog parameter defines the maximum length the queue of\n
frankvnk 1:99bfc8d68fd3 784 * pending connections may grow to. \n
frankvnk 1:99bfc8d68fd3 785 *
frankvnk 1:99bfc8d68fd3 786 * \param[in] sd socket descriptor (handle)
frankvnk 1:99bfc8d68fd3 787 * \param[in] backlog specifies the listen queue depth. On this version\n
frankvnk 1:99bfc8d68fd3 788 * backlog is not supported.\n
frankvnk 1:99bfc8d68fd3 789 * \return On success, zero is returned.\n
frankvnk 1:99bfc8d68fd3 790 * On error, -1 is returned.\n
frankvnk 1:99bfc8d68fd3 791 * \sa socket ; accept ; bind
frankvnk 1:99bfc8d68fd3 792 * \note On this version, backlog is not supported
frankvnk 1:99bfc8d68fd3 793 */
frankvnk 1:99bfc8d68fd3 794 int32_t listen(int32_t sd, int32_t backlog);
frankvnk 1:99bfc8d68fd3 795 /**
frankvnk 1:99bfc8d68fd3 796 * \brief initiate a connection on a socket.
frankvnk 1:99bfc8d68fd3 797 * Function connects the socket referred to by the socket descriptor\n
frankvnk 1:99bfc8d68fd3 798 * sd, to the address specified by addr. The addrlen argument \n
frankvnk 1:99bfc8d68fd3 799 * specifies the size of addr. The format of the address in addr is \n
frankvnk 1:99bfc8d68fd3 800 * determined by the address space of the socket. If it is of type \n
frankvnk 1:99bfc8d68fd3 801 * SOCK_DGRAM, this call specifies the peer with which the socket is \n
frankvnk 1:99bfc8d68fd3 802 * to be associated; this address is that to which datagrams are to be\n
frankvnk 1:99bfc8d68fd3 803 * sent, and the only address from which datagrams are to be received. \n
frankvnk 1:99bfc8d68fd3 804 * If the socket is of type SOCK_STREAM, this call attempts to make a \n
frankvnk 1:99bfc8d68fd3 805 * connection to another socket. The other socket is specified by \n
frankvnk 1:99bfc8d68fd3 806 * address, which is an address in the communications space of the\n
frankvnk 1:99bfc8d68fd3 807 * socket. Note that the function implements only blocking behavior \n
frankvnk 1:99bfc8d68fd3 808 * thus the caller will be waiting either for the connection \n
frankvnk 1:99bfc8d68fd3 809 * establishment or for the connection establishment failure.\n
frankvnk 1:99bfc8d68fd3 810 *
frankvnk 1:99bfc8d68fd3 811 * \param[in] sd socket descriptor (handle)
frankvnk 1:99bfc8d68fd3 812 * \param[in] addr specifies the destination addr. On this version\n
frankvnk 1:99bfc8d68fd3 813 * only AF_INET is supported.\n
frankvnk 1:99bfc8d68fd3 814 * \param[out] addrlen contains the size of the structure pointed to by addr
frankvnk 1:99bfc8d68fd3 815 * \return On success, zero is returned.\n
frankvnk 1:99bfc8d68fd3 816 On error, -1 is returned\n
frankvnk 1:99bfc8d68fd3 817 * \sa socket
frankvnk 1:99bfc8d68fd3 818 */
frankvnk 1:99bfc8d68fd3 819 int32_t connect(int32_t sd, const sockaddr *addr, int32_t addrlen);
frankvnk 1:99bfc8d68fd3 820 /**
frankvnk 1:99bfc8d68fd3 821 * \brief Monitor socket activity.
frankvnk 1:99bfc8d68fd3 822 * Select allow a program to monitor multiple file descriptors,\n
frankvnk 1:99bfc8d68fd3 823 * waiting until one or more of the file descriptors become \n
frankvnk 1:99bfc8d68fd3 824 * "ready" for some class of I/O operation \n
frankvnk 1:99bfc8d68fd3 825 *
frankvnk 1:99bfc8d68fd3 826 * \param[in] nfds the highest-numbered file descriptor in any of the\n
frankvnk 1:99bfc8d68fd3 827 * three sets, plus 1. \n
frankvnk 1:99bfc8d68fd3 828 * \param[out] readsds socket descriptors list for read monitoring\n
frankvnk 1:99bfc8d68fd3 829 * \param[out] writesds socket descriptors list for write monitoring\n
frankvnk 1:99bfc8d68fd3 830 * \param[out] exceptsds socket descriptors list for exception monitoring\n
frankvnk 1:99bfc8d68fd3 831 * \param[in] timeout is an upper bound on the amount of time elapsed\n
frankvnk 1:99bfc8d68fd3 832 * before select() returns. Null means infinity \n
frankvnk 1:99bfc8d68fd3 833 * timeout. The minimum timeout is 5 milliseconds,\n
frankvnk 1:99bfc8d68fd3 834 * less than 5 milliseconds will be set\n
frankvnk 1:99bfc8d68fd3 835 * automatically to 5 milliseconds.\n
frankvnk 1:99bfc8d68fd3 836 * \return On success, select() returns the number of file descriptors\n
frankvnk 1:99bfc8d68fd3 837 * contained in the three returned descriptor sets (that is, the\n
frankvnk 1:99bfc8d68fd3 838 * total number of bits that are set in readfds, writefds,\n
frankvnk 1:99bfc8d68fd3 839 * exceptfds) which may be zero if the timeout expires before\n
frankvnk 1:99bfc8d68fd3 840 * anything interesting happens.\n
frankvnk 1:99bfc8d68fd3 841 * On error, -1 is returned.\n
frankvnk 1:99bfc8d68fd3 842 * *readsds - return the sockets on which Read request will\n
frankvnk 1:99bfc8d68fd3 843 * return without delay with valid data.\n
frankvnk 1:99bfc8d68fd3 844 * *writesds - return the sockets on which Write request \n
frankvnk 1:99bfc8d68fd3 845 * will return without delay.\n
frankvnk 1:99bfc8d68fd3 846 * *exceptsds - return the sockets which closed recently.\n
frankvnk 1:99bfc8d68fd3 847 * \Note If the timeout value set to less than 5ms it will automatically\n
frankvnk 1:99bfc8d68fd3 848 * change to 5ms to prevent overload of the system\n
frankvnk 1:99bfc8d68fd3 849 * \sa socket
frankvnk 1:99bfc8d68fd3 850 */
frankvnk 1:99bfc8d68fd3 851 int32_t select(int32_t nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout);
frankvnk 1:99bfc8d68fd3 852 /**
frankvnk 1:99bfc8d68fd3 853 * \brief get socket options.
frankvnk 1:99bfc8d68fd3 854 * This function manipulate the options associated with a socket.\n
frankvnk 1:99bfc8d68fd3 855 * Options may exist at multiple protocol levels; they are always\n
frankvnk 1:99bfc8d68fd3 856 * present at the uppermost socket level.\n
frankvnk 1:99bfc8d68fd3 857 * When manipulating socket options the level at which the option \n
frankvnk 1:99bfc8d68fd3 858 * resides and the name of the option must be specified. \n
frankvnk 1:99bfc8d68fd3 859 * To manipulate options at the socket level, level is specified as \n
frankvnk 1:99bfc8d68fd3 860 * SOL_SOCKET. To manipulate options at any other level the protocol \n
frankvnk 1:99bfc8d68fd3 861 * number of the appropriate protocol controlling the option is \n
frankvnk 1:99bfc8d68fd3 862 * supplied. For example, to indicate that an option is to be \n
frankvnk 1:99bfc8d68fd3 863 * interpreted by the TCP protocol, level should be set to the \n
frankvnk 1:99bfc8d68fd3 864 * protocol number of TCP; \n
frankvnk 1:99bfc8d68fd3 865 * The parameters optval and optlen are used to access optval -\n
frankvnk 1:99bfc8d68fd3 866 * use for setsockopt(). For getsockopt() they identify a buffer\n
frankvnk 1:99bfc8d68fd3 867 * in which the value for the requested option(s) are to \n
frankvnk 1:99bfc8d68fd3 868 * be returned. For getsockopt(), optlen is a value-result \n
frankvnk 1:99bfc8d68fd3 869 * parameter, initially containing the size of the buffer \n
frankvnk 1:99bfc8d68fd3 870 * pointed to by option_value, and modified on return to \n
frankvnk 1:99bfc8d68fd3 871 * indicate the actual size of the value returned. If no option \n
frankvnk 1:99bfc8d68fd3 872 * value is to be supplied or returned, option_value may be NULL.\n
frankvnk 1:99bfc8d68fd3 873 *
frankvnk 1:99bfc8d68fd3 874 * \param[in] sd socket handle
frankvnk 1:99bfc8d68fd3 875 * \param[in] level defines the protocol level for this option
frankvnk 1:99bfc8d68fd3 876 * \param[in] optname defines the option name to Interrogate
frankvnk 1:99bfc8d68fd3 877 * \param[out] optval specifies a value for the option
frankvnk 1:99bfc8d68fd3 878 * \param[out] optlen specifies the length of the option value
frankvnk 1:99bfc8d68fd3 879 * \return On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 880 *
frankvnk 1:99bfc8d68fd3 881 * \Note On this version the following two socket options are enabled:\n
frankvnk 1:99bfc8d68fd3 882 * The only protocol level supported in this version is SOL_SOCKET (level).\n
frankvnk 1:99bfc8d68fd3 883 * 1. SOCKOPT_RECV_TIMEOUT (optname)\n
frankvnk 1:99bfc8d68fd3 884 * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout in milliseconds.\n
frankvnk 1:99bfc8d68fd3 885 * In that case optval should be pointer to unsigned long.\n
frankvnk 1:99bfc8d68fd3 886 * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on or off.\n
frankvnk 1:99bfc8d68fd3 887 * In that case optval should be SOCK_ON or SOCK_OFF (optval).\n
frankvnk 1:99bfc8d68fd3 888 * \sa setsockopt
frankvnk 1:99bfc8d68fd3 889 */
frankvnk 1:99bfc8d68fd3 890 int32_t getsockopt (int32_t sd, int32_t level, int32_t optname, void *optval, socklen_t *optlen);
frankvnk 1:99bfc8d68fd3 891 /**
frankvnk 1:99bfc8d68fd3 892 * \brief Read data from socket (simple_link_recv).
frankvnk 1:99bfc8d68fd3 893 * Return the length of the message on successful completion.\n
frankvnk 1:99bfc8d68fd3 894 * If a message is too long to fit in the supplied buffer, excess bytes may\n
frankvnk 1:99bfc8d68fd3 895 * be discarded depending on the type of socket the message is received from.\n
frankvnk 1:99bfc8d68fd3 896 *
frankvnk 1:99bfc8d68fd3 897 * \param sd socket handle
frankvnk 1:99bfc8d68fd3 898 * \param buf read buffer
frankvnk 1:99bfc8d68fd3 899 * \param len buffer length
frankvnk 1:99bfc8d68fd3 900 * \param flags indicates blocking or non-blocking operation
frankvnk 1:99bfc8d68fd3 901 * \param from pointer to an address structure indicating source address
frankvnk 1:99bfc8d68fd3 902 * \param fromlen source address structure size
frankvnk 1:99bfc8d68fd3 903 * \return Return the number of bytes received, or -1 if an error occurred
frankvnk 1:99bfc8d68fd3 904 */
frankvnk 1:99bfc8d68fd3 905 int32_t simple_link_recv(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen, int32_t opcode);
frankvnk 1:99bfc8d68fd3 906 /**
frankvnk 1:99bfc8d68fd3 907 * \brief Transmit a message to another socket (simple_link_send).
frankvnk 1:99bfc8d68fd3 908 * \param sd socket handle
frankvnk 1:99bfc8d68fd3 909 * \param buf write buffer
frankvnk 1:99bfc8d68fd3 910 * \param len buffer length
frankvnk 1:99bfc8d68fd3 911 * \param flags On this version, this parameter is not supported
frankvnk 1:99bfc8d68fd3 912 * \param to pointer to an address structure indicating destination address
frankvnk 1:99bfc8d68fd3 913 * \param tolen destination address structure size
frankvnk 1:99bfc8d68fd3 914 * \return Return the number of bytes transmitted, or -1 if an error\n
frankvnk 1:99bfc8d68fd3 915 * occurred, or -2 in case there are no free buffers available\n
frankvnk 1:99bfc8d68fd3 916 * (only when SEND_NON_BLOCKING is enabled)\n
frankvnk 1:99bfc8d68fd3 917 */
frankvnk 1:99bfc8d68fd3 918 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);
frankvnk 1:99bfc8d68fd3 919 /**
frankvnk 1:99bfc8d68fd3 920 * \brief Receive a message from a connection-mode socket.
frankvnk 1:99bfc8d68fd3 921 * \param[in] sd socket handle
frankvnk 1:99bfc8d68fd3 922 * \param[out] buf Points to the buffer where the message should be stored
frankvnk 1:99bfc8d68fd3 923 * \param[in] len Specifies the length in bytes of the buffer pointed to \n
frankvnk 1:99bfc8d68fd3 924 * by the buffer argument.\n
frankvnk 1:99bfc8d68fd3 925 * \param[in] flags Specifies the type of message reception. \n
frankvnk 1:99bfc8d68fd3 926 * On this version, this parameter is not supported.\n
frankvnk 1:99bfc8d68fd3 927 * \return Return the number of bytes received, or -1 if an error occurred
frankvnk 1:99bfc8d68fd3 928 * \sa recvfrom
frankvnk 1:99bfc8d68fd3 929 * \Note On this version, only blocking mode is supported.
frankvnk 1:99bfc8d68fd3 930 */
frankvnk 1:99bfc8d68fd3 931 int32_t recv(int32_t sd, void *buf, int32_t len, int32_t flags);
frankvnk 1:99bfc8d68fd3 932 /**
frankvnk 1:99bfc8d68fd3 933 * \brief read data from socket (recvfrom).
frankvnk 1:99bfc8d68fd3 934 * Receives a message from a connection-mode or connectionless-mode socket.\n
frankvnk 1:99bfc8d68fd3 935 * Note that raw sockets are not supported.\n
frankvnk 1:99bfc8d68fd3 936 *
frankvnk 1:99bfc8d68fd3 937 * \param[in] sd socket handle
frankvnk 1:99bfc8d68fd3 938 * \param[out] buf Points to the buffer where the message should be stored
frankvnk 1:99bfc8d68fd3 939 * \param[in] len Specifies the length in bytes of the buffer pointed to \n
frankvnk 1:99bfc8d68fd3 940 * by the buffer argument.\n
frankvnk 1:99bfc8d68fd3 941 * \param[in] flags Specifies the type of message reception.\n
frankvnk 1:99bfc8d68fd3 942 * On this version, this parameter is not supported.\n
frankvnk 1:99bfc8d68fd3 943 * \param[in] from pointer to an address structure indicating the source\n
frankvnk 1:99bfc8d68fd3 944 * address: sockaddr. On this version only AF_INET is\n
frankvnk 1:99bfc8d68fd3 945 * supported.\n
frankvnk 1:99bfc8d68fd3 946 * \param[in] fromlen source address structure size
frankvnk 1:99bfc8d68fd3 947 * \return Return the number of bytes received, or -1 if an error occurred
frankvnk 1:99bfc8d68fd3 948 * \sa recv
frankvnk 1:99bfc8d68fd3 949 * \Note On this version, only blocking mode is supported.
frankvnk 1:99bfc8d68fd3 950 */
frankvnk 1:99bfc8d68fd3 951 int32_t recvfrom(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen);
frankvnk 1:99bfc8d68fd3 952 /**
frankvnk 1:99bfc8d68fd3 953 * \brief Transmit a message to another socket (send).
frankvnk 1:99bfc8d68fd3 954 * \param sd socket handle
frankvnk 1:99bfc8d68fd3 955 * \param buf Points to a buffer containing the message to be sent
frankvnk 1:99bfc8d68fd3 956 * \param len message size in bytes
frankvnk 1:99bfc8d68fd3 957 * \param flags On this version, this parameter is not supported
frankvnk 1:99bfc8d68fd3 958 * \return Return the number of bytes transmitted, or -1 if an\n
frankvnk 1:99bfc8d68fd3 959 * error occurred\n
frankvnk 1:99bfc8d68fd3 960 * \Note On this version, only blocking mode is supported.
frankvnk 1:99bfc8d68fd3 961 * \sa sendto
frankvnk 1:99bfc8d68fd3 962 */
frankvnk 1:99bfc8d68fd3 963 int32_t send(int32_t sd, const void *buf, int32_t len, int32_t flags);
frankvnk 1:99bfc8d68fd3 964 /**
frankvnk 1:99bfc8d68fd3 965 * \brief Transmit a message to another socket (sendto).
frankvnk 1:99bfc8d68fd3 966 * \param sd socket handle
frankvnk 1:99bfc8d68fd3 967 * \param buf Points to a buffer containing the message to be sent
frankvnk 1:99bfc8d68fd3 968 * \param len message size in bytes
frankvnk 1:99bfc8d68fd3 969 * \param flags On this version, this parameter is not supported
frankvnk 1:99bfc8d68fd3 970 * \param to pointer to an address structure indicating the destination\n
frankvnk 1:99bfc8d68fd3 971 * address: sockaddr. On this version only AF_INET is\n
frankvnk 1:99bfc8d68fd3 972 * supported.\n
frankvnk 1:99bfc8d68fd3 973 * \param tolen destination address structure size
frankvnk 1:99bfc8d68fd3 974 * \return Return the number of bytes transmitted, or -1 if an error occurred
frankvnk 1:99bfc8d68fd3 975 * \Note On this version, only blocking mode is supported.
frankvnk 1:99bfc8d68fd3 976 * \sa send
frankvnk 1:99bfc8d68fd3 977 */
frankvnk 1:99bfc8d68fd3 978 int32_t sendto(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, socklen_t tolen);
frankvnk 1:99bfc8d68fd3 979 /**
frankvnk 1:99bfc8d68fd3 980 * \brief Set CC3000 in mDNS advertiser mode in order to advertise itself.
frankvnk 1:99bfc8d68fd3 981 * \param[in] mdns_enabled flag to enable/disable the mDNS feature
frankvnk 1:99bfc8d68fd3 982 * \param[in] device_service_name Service name as part of the published\n
frankvnk 1:99bfc8d68fd3 983 * canonical domain name\n
frankvnk 1:99bfc8d68fd3 984 * \param[in] device_service_name_length Length of the service name
frankvnk 1:99bfc8d68fd3 985 * \return On success, zero is returned,\n
frankvnk 1:99bfc8d68fd3 986 * return SOC_ERROR if socket was not opened successfully, or if an error occurred.\n
frankvnk 1:99bfc8d68fd3 987 */
frankvnk 1:99bfc8d68fd3 988 int32_t mdns_advertiser(uint16_t mdns_enabled, uint8_t * device_service_name, uint16_t device_service_name_length);
frankvnk 1:99bfc8d68fd3 989 /**
frankvnk 1:99bfc8d68fd3 990 * \brief
frankvnk 1:99bfc8d68fd3 991 * \param[in] s_addr in host format ( little endian )
frankvnk 1:99bfc8d68fd3 992 * \param[in] *buf buffer to write too
frankvnk 1:99bfc8d68fd3 993 * \param[in] buflen length of supplied buffer
frankvnk 1:99bfc8d68fd3 994 * \return pointer to buf \n
frankvnk 1:99bfc8d68fd3 995 */
frankvnk 1:99bfc8d68fd3 996 char * inet_ntoa_r(uint32_t s_addr, char *buf, int buflen);
frankvnk 1:99bfc8d68fd3 997 #ifndef CC3000_TINY_DRIVER
frankvnk 1:99bfc8d68fd3 998 /**
frankvnk 1:99bfc8d68fd3 999 * \brief Get host IP by name.\n
frankvnk 1:99bfc8d68fd3 1000 * Obtain the IP Address of machine on network\n
frankvnk 1:99bfc8d68fd3 1001 *
frankvnk 1:99bfc8d68fd3 1002 * \param[in] hostname host name
frankvnk 1:99bfc8d68fd3 1003 * \param[in] name_length name length
frankvnk 1:99bfc8d68fd3 1004 * \param[out] out_ip_addr This parameter is filled in with host IP address.\n
frankvnk 1:99bfc8d68fd3 1005 * In case that host name is not resolved, \n
frankvnk 1:99bfc8d68fd3 1006 * out_ip_addr is zero.\n
frankvnk 1:99bfc8d68fd3 1007 * \return On success, positive is returned.\n
frankvnk 1:99bfc8d68fd3 1008 * On error, negative is returned by its name.\n
frankvnk 1:99bfc8d68fd3 1009 * \note On this version, only blocking mode is supported. Also note that\n
frankvnk 1:99bfc8d68fd3 1010 * The function requires DNS server to be configured prior to its usage.\n
frankvnk 1:99bfc8d68fd3 1011 */
frankvnk 1:99bfc8d68fd3 1012 int32_t gethostbyname(uint8_t *hostname, uint16_t name_length, uint32_t *out_ip_addr);
frankvnk 1:99bfc8d68fd3 1013 /**
frankvnk 1:99bfc8d68fd3 1014 * \brief set socket options.
frankvnk 1:99bfc8d68fd3 1015 * This function manipulate the options associated with a socket.\n
frankvnk 1:99bfc8d68fd3 1016 * Options may exist at multiple protocol levels; they are always\n
frankvnk 1:99bfc8d68fd3 1017 * present at the uppermost socket level.\n
frankvnk 1:99bfc8d68fd3 1018 * When manipulating socket options the level at which the option \n
frankvnk 1:99bfc8d68fd3 1019 * resides and the name of the option must be specified.\n
frankvnk 1:99bfc8d68fd3 1020 * To manipulate options at the socket level, level is specified as\n
frankvnk 1:99bfc8d68fd3 1021 * SOL_SOCKET. To manipulate options at any other level the protocol \n
frankvnk 1:99bfc8d68fd3 1022 * number of the appropriate protocol controlling the option is \n
frankvnk 1:99bfc8d68fd3 1023 * supplied. For example, to indicate that an option is to be \n
frankvnk 1:99bfc8d68fd3 1024 * interpreted by the TCP protocol, level should be set to the \n
frankvnk 1:99bfc8d68fd3 1025 * protocol number of TCP; \n
frankvnk 1:99bfc8d68fd3 1026 * The parameters optval and optlen are used to access optval - \n
frankvnk 1:99bfc8d68fd3 1027 * use for setsockopt(). For getsockopt() they identify a buffer\n
frankvnk 1:99bfc8d68fd3 1028 * in which the value for the requested option(s) are to \n
frankvnk 1:99bfc8d68fd3 1029 * be returned. For getsockopt(), optlen is a value-result \n
frankvnk 1:99bfc8d68fd3 1030 * parameter, initially containing the size of the buffer \n
frankvnk 1:99bfc8d68fd3 1031 * pointed to by option_value, and modified on return to \n
frankvnk 1:99bfc8d68fd3 1032 * indicate the actual size of the value returned. If no option \n
frankvnk 1:99bfc8d68fd3 1033 * value is to be supplied or returned, option_value may be NULL.\n
frankvnk 1:99bfc8d68fd3 1034 *
frankvnk 1:99bfc8d68fd3 1035 * \param[in] sd socket handle
frankvnk 1:99bfc8d68fd3 1036 * \param[in] level defines the protocol level for this option
frankvnk 1:99bfc8d68fd3 1037 * \param[in] optname defines the option name to Interrogate
frankvnk 1:99bfc8d68fd3 1038 * \param[in] optval specifies a value for the option
frankvnk 1:99bfc8d68fd3 1039 * \param[in] optlen specifies the length of the option value
frankvnk 1:99bfc8d68fd3 1040 * \return On success, zero is returned.\n
frankvnk 1:99bfc8d68fd3 1041 * On error, -1 is returned\n
frankvnk 1:99bfc8d68fd3 1042 *
frankvnk 1:99bfc8d68fd3 1043 * \Note On this version the following two socket options are enabled:\n
frankvnk 1:99bfc8d68fd3 1044 * The only protocol level supported in this version is SOL_SOCKET (level).\n
frankvnk 1:99bfc8d68fd3 1045 * 1. SOCKOPT_RECV_TIMEOUT (optname)\n
frankvnk 1:99bfc8d68fd3 1046 * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout in milliseconds.\n
frankvnk 1:99bfc8d68fd3 1047 * In that case optval should be pointer to unsigned long.\n
frankvnk 1:99bfc8d68fd3 1048 * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on or off.\n
frankvnk 1:99bfc8d68fd3 1049 * In that case optval should be SOCK_ON or SOCK_OFF (optval).\n
frankvnk 1:99bfc8d68fd3 1050 * \sa getsockopt
frankvnk 1:99bfc8d68fd3 1051 */
frankvnk 1:99bfc8d68fd3 1052 int32_t setsockopt(int32_t sd, int32_t level, int32_t optname, const void *optval, socklen_t optlen);
frankvnk 1:99bfc8d68fd3 1053 #endif
frankvnk 1:99bfc8d68fd3 1054 private:
frankvnk 1:99bfc8d68fd3 1055 cc3000_simple_link &_simple_link;
frankvnk 1:99bfc8d68fd3 1056 cc3000_hci &_hci;
frankvnk 1:99bfc8d68fd3 1057 cc3000_event &_event;
frankvnk 1:99bfc8d68fd3 1058 };
frankvnk 1:99bfc8d68fd3 1059
frankvnk 1:99bfc8d68fd3 1060 /** SPI communication layer
frankvnk 1:99bfc8d68fd3 1061 */
frankvnk 1:99bfc8d68fd3 1062 class cc3000_spi {
frankvnk 1:99bfc8d68fd3 1063 public:
frankvnk 1:99bfc8d68fd3 1064 /**
frankvnk 1:99bfc8d68fd3 1065 * \brief Ctor
frankvnk 1:99bfc8d68fd3 1066 * \param irq IRQ pin
frankvnk 1:99bfc8d68fd3 1067 * \param cc3000_en Enable pin
frankvnk 1:99bfc8d68fd3 1068 * \param cc3000_cs Chip select pin
frankvnk 1:99bfc8d68fd3 1069 * \param cc3000_spi SPI object
frankvnk 1:99bfc8d68fd3 1070 * \param irq_port Port for IRQ pin (needed for enable/disable interrupts)
frankvnk 1:99bfc8d68fd3 1071 * \param event Reference to the event object.
frankvnk 1:99bfc8d68fd3 1072 * \param simple_link Reference to the simple link object.
frankvnk 1:99bfc8d68fd3 1073 * \return none
frankvnk 1:99bfc8d68fd3 1074 */
frankvnk 1:99bfc8d68fd3 1075 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);
frankvnk 1:99bfc8d68fd3 1076 /**
frankvnk 1:99bfc8d68fd3 1077 * \brief Dtor
frankvnk 1:99bfc8d68fd3 1078 * \param none
frankvnk 1:99bfc8d68fd3 1079 * \return none
frankvnk 1:99bfc8d68fd3 1080 */
frankvnk 1:99bfc8d68fd3 1081 ~cc3000_spi();
frankvnk 1:99bfc8d68fd3 1082 /**
frankvnk 1:99bfc8d68fd3 1083 * \brief Close SPI - disables IRQ and set received buffer to 0
frankvnk 1:99bfc8d68fd3 1084 * \param none
frankvnk 1:99bfc8d68fd3 1085 * \return none
frankvnk 1:99bfc8d68fd3 1086 */
frankvnk 1:99bfc8d68fd3 1087 void close();
frankvnk 1:99bfc8d68fd3 1088 /**
frankvnk 1:99bfc8d68fd3 1089 * \brief Open the SPI interface
frankvnk 1:99bfc8d68fd3 1090 * \param none
frankvnk 1:99bfc8d68fd3 1091 * \return none
frankvnk 1:99bfc8d68fd3 1092 */
frankvnk 1:99bfc8d68fd3 1093 void open();
frankvnk 1:99bfc8d68fd3 1094 /**
frankvnk 1:99bfc8d68fd3 1095 * \brief First SPI write after powerup (delay needed between SPI header and body)
frankvnk 1:99bfc8d68fd3 1096 * \param buffer pointer to write buffer
frankvnk 1:99bfc8d68fd3 1097 * \param length buffer length
frankvnk 1:99bfc8d68fd3 1098 * \return 0
frankvnk 1:99bfc8d68fd3 1099 */
frankvnk 1:99bfc8d68fd3 1100 uint32_t first_write(uint8_t *buffer, uint16_t length);
frankvnk 1:99bfc8d68fd3 1101 /**
frankvnk 1:99bfc8d68fd3 1102 * \brief SPI Write function
frankvnk 1:99bfc8d68fd3 1103 * \param buffer pointer to write buffer
frankvnk 1:99bfc8d68fd3 1104 * \param length buffer length
frankvnk 1:99bfc8d68fd3 1105 * \return 0
frankvnk 1:99bfc8d68fd3 1106 */
frankvnk 1:99bfc8d68fd3 1107 uint32_t write(uint8_t *buffer, uint16_t length);
frankvnk 1:99bfc8d68fd3 1108 /**
frankvnk 1:99bfc8d68fd3 1109 * \brief Low level SPI write
frankvnk 1:99bfc8d68fd3 1110 * \param data pointer to data buffer
frankvnk 1:99bfc8d68fd3 1111 * \param size number of bytes
frankvnk 1:99bfc8d68fd3 1112 * \return none
frankvnk 1:99bfc8d68fd3 1113 */
frankvnk 1:99bfc8d68fd3 1114 void write_synchronous(uint8_t *data, uint16_t size);
frankvnk 1:99bfc8d68fd3 1115 /**
frankvnk 1:99bfc8d68fd3 1116 * \brief Low level SPI read
frankvnk 1:99bfc8d68fd3 1117 * \param data pointer to data buffer
frankvnk 1:99bfc8d68fd3 1118 * \param size number of bytes
frankvnk 1:99bfc8d68fd3 1119 * \return none
frankvnk 1:99bfc8d68fd3 1120 */
frankvnk 1:99bfc8d68fd3 1121 void read_synchronous(uint8_t *data, uint16_t size);
frankvnk 1:99bfc8d68fd3 1122 /**
frankvnk 1:99bfc8d68fd3 1123 * \brief Process the received SPI Header and in accordance with it - continue reading the packet
frankvnk 1:99bfc8d68fd3 1124 * \param None
frankvnk 1:99bfc8d68fd3 1125 * \return 0
frankvnk 1:99bfc8d68fd3 1126 */
frankvnk 1:99bfc8d68fd3 1127 uint32_t read_data_cont();
frankvnk 1:99bfc8d68fd3 1128 /**
frankvnk 1:99bfc8d68fd3 1129 * \brief Enable WLAN interrutp
frankvnk 1:99bfc8d68fd3 1130 * \param None
frankvnk 1:99bfc8d68fd3 1131 * \return None
frankvnk 1:99bfc8d68fd3 1132 */
frankvnk 1:99bfc8d68fd3 1133 void wlan_irq_enable();
frankvnk 1:99bfc8d68fd3 1134 /**
frankvnk 1:99bfc8d68fd3 1135 * \brief Disable WLAN interrutp
frankvnk 1:99bfc8d68fd3 1136 * \param None
frankvnk 1:99bfc8d68fd3 1137 * \return None
frankvnk 1:99bfc8d68fd3 1138 */
frankvnk 1:99bfc8d68fd3 1139 void wlan_irq_disable();
frankvnk 1:99bfc8d68fd3 1140 /**
frankvnk 1:99bfc8d68fd3 1141 * \brief Get WLAN interrupt status
frankvnk 1:99bfc8d68fd3 1142 * \param None
frankvnk 1:99bfc8d68fd3 1143 * \return 0 : No interrupt occured
frankvnk 1:99bfc8d68fd3 1144 * 1 : Interrupt occured
frankvnk 1:99bfc8d68fd3 1145 */
frankvnk 1:99bfc8d68fd3 1146 uint32_t wlan_irq_read();
frankvnk 1:99bfc8d68fd3 1147 /**
frankvnk 1:99bfc8d68fd3 1148 * \brief SPI interrupt Handler.
frankvnk 1:99bfc8d68fd3 1149 * The external WLAN device asserts the IRQ line when data is ready.\n
frankvnk 1:99bfc8d68fd3 1150 * The host CPU needs to acknowledges the IRQ by asserting CS.\n
frankvnk 1:99bfc8d68fd3 1151 *
frankvnk 1:99bfc8d68fd3 1152 * \param none
frankvnk 1:99bfc8d68fd3 1153 * \return none
frankvnk 1:99bfc8d68fd3 1154 */
frankvnk 1:99bfc8d68fd3 1155 void WLAN_IRQHandler();
frankvnk 1:99bfc8d68fd3 1156 /**
frankvnk 1:99bfc8d68fd3 1157 * \brief Enable/Disable the WLAN module
frankvnk 1:99bfc8d68fd3 1158 * \param value 1 : Enable
frankvnk 1:99bfc8d68fd3 1159 * 0 : Disable
frankvnk 1:99bfc8d68fd3 1160 * \return None
frankvnk 1:99bfc8d68fd3 1161 */
frankvnk 1:99bfc8d68fd3 1162 void set_wlan_en(uint8_t value);
frankvnk 1:99bfc8d68fd3 1163 private:
frankvnk 1:99bfc8d68fd3 1164 tSpiInfo _spi_info;
frankvnk 1:99bfc8d68fd3 1165 InterruptIn _wlan_irq;
frankvnk 1:99bfc8d68fd3 1166 DigitalOut _wlan_en;
frankvnk 1:99bfc8d68fd3 1167 DigitalOut _wlan_cs;
frankvnk 1:99bfc8d68fd3 1168 SPI _wlan_spi;
frankvnk 1:99bfc8d68fd3 1169 IRQn_Type _irq_port;
frankvnk 1:99bfc8d68fd3 1170 pFunctionPointer_t _function_pointer;
frankvnk 1:99bfc8d68fd3 1171 cc3000_event &_event;
frankvnk 1:99bfc8d68fd3 1172 cc3000_simple_link &_simple_link;
frankvnk 1:99bfc8d68fd3 1173 };
frankvnk 1:99bfc8d68fd3 1174
frankvnk 1:99bfc8d68fd3 1175 /** HCI layer
frankvnk 1:99bfc8d68fd3 1176 */
frankvnk 1:99bfc8d68fd3 1177 class cc3000_hci {
frankvnk 1:99bfc8d68fd3 1178 public:
frankvnk 1:99bfc8d68fd3 1179 /**
frankvnk 1:99bfc8d68fd3 1180 * \brief Ctor
frankvnk 1:99bfc8d68fd3 1181 * \param spi Reference to the spi object.
frankvnk 1:99bfc8d68fd3 1182 * \return none
frankvnk 1:99bfc8d68fd3 1183 */
frankvnk 1:99bfc8d68fd3 1184 cc3000_hci(cc3000_spi &spi);
frankvnk 1:99bfc8d68fd3 1185 /**
frankvnk 1:99bfc8d68fd3 1186 * \brief Dtor
frankvnk 1:99bfc8d68fd3 1187 * \param none
frankvnk 1:99bfc8d68fd3 1188 * \return none
frankvnk 1:99bfc8d68fd3 1189 */
frankvnk 1:99bfc8d68fd3 1190 ~cc3000_hci();
frankvnk 1:99bfc8d68fd3 1191 /**
frankvnk 1:99bfc8d68fd3 1192 * \brief Initiate an HCI command.
frankvnk 1:99bfc8d68fd3 1193 * \param op_code command operation code
frankvnk 1:99bfc8d68fd3 1194 * \param buffer pointer to the command's arguments buffer
frankvnk 1:99bfc8d68fd3 1195 * \param length length of the arguments
frankvnk 1:99bfc8d68fd3 1196 * \return 0
frankvnk 1:99bfc8d68fd3 1197 */
frankvnk 1:99bfc8d68fd3 1198 uint16_t command_send(uint16_t op_code, uint8_t *buffer, uint8_t length);
frankvnk 1:99bfc8d68fd3 1199 /**
frankvnk 1:99bfc8d68fd3 1200 * \brief Initiate an HCI data write operation
frankvnk 1:99bfc8d68fd3 1201 * \param op_code command operation code
frankvnk 1:99bfc8d68fd3 1202 * \param args pointer to the command's arguments buffer
frankvnk 1:99bfc8d68fd3 1203 * \param arg_length length of the arguments
frankvnk 1:99bfc8d68fd3 1204 * \param data_length length od data
frankvnk 1:99bfc8d68fd3 1205 * \param tail pointer to the data buffer
frankvnk 1:99bfc8d68fd3 1206 * \param tail_length buffer length
frankvnk 1:99bfc8d68fd3 1207 * \return ESUCCESS
frankvnk 1:99bfc8d68fd3 1208 */
frankvnk 1:99bfc8d68fd3 1209 uint32_t data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length,
frankvnk 1:99bfc8d68fd3 1210 uint16_t data_length, const uint8_t *tail, uint16_t tail_length);
frankvnk 1:99bfc8d68fd3 1211 /**
frankvnk 1:99bfc8d68fd3 1212 * \brief Prepare HCI header and initiate an HCI data write operation.
frankvnk 1:99bfc8d68fd3 1213 * \param op_code command operation code
frankvnk 1:99bfc8d68fd3 1214 * \param buffer pointer to the data buffer
frankvnk 1:99bfc8d68fd3 1215 * \param arg_length arguments length
frankvnk 1:99bfc8d68fd3 1216 * \param data_length data length
frankvnk 1:99bfc8d68fd3 1217 * \return none
frankvnk 1:99bfc8d68fd3 1218 */
frankvnk 1:99bfc8d68fd3 1219 void data_command_send(uint16_t op_code, uint8_t *buffer, uint8_t arg_length,
frankvnk 1:99bfc8d68fd3 1220 uint16_t data_length);
frankvnk 1:99bfc8d68fd3 1221 /**
frankvnk 1:99bfc8d68fd3 1222 * \brief Prepare HCI header and initiate an HCI patch write operation.
frankvnk 1:99bfc8d68fd3 1223 * \param op_code command operation code
frankvnk 1:99bfc8d68fd3 1224 * \param buffer pointer to the command's arguments buffer
frankvnk 1:99bfc8d68fd3 1225 * \param patch pointer to patch content buffer
frankvnk 1:99bfc8d68fd3 1226 * \param data_length data length
frankvnk 1:99bfc8d68fd3 1227 * \return none
frankvnk 1:99bfc8d68fd3 1228 */
frankvnk 1:99bfc8d68fd3 1229 void patch_send(uint8_t op_code, uint8_t *buffer, uint8_t *patch, uint16_t data_length);
frankvnk 1:99bfc8d68fd3 1230 private:
frankvnk 1:99bfc8d68fd3 1231 cc3000_spi &_spi;
frankvnk 1:99bfc8d68fd3 1232 };
frankvnk 1:99bfc8d68fd3 1233
frankvnk 1:99bfc8d68fd3 1234 /** NVMEM layer
frankvnk 1:99bfc8d68fd3 1235 */
frankvnk 1:99bfc8d68fd3 1236 class cc3000_nvmem {
frankvnk 1:99bfc8d68fd3 1237 public:
frankvnk 1:99bfc8d68fd3 1238 /**
frankvnk 1:99bfc8d68fd3 1239 * \brief Ctor
frankvnk 1:99bfc8d68fd3 1240 * \param hci Reference to the hci object.
frankvnk 1:99bfc8d68fd3 1241 * \param event Reference to the event object.
frankvnk 1:99bfc8d68fd3 1242 * \param simple_link Reference to the simple link object.
frankvnk 1:99bfc8d68fd3 1243 * \return none
frankvnk 1:99bfc8d68fd3 1244 */
frankvnk 1:99bfc8d68fd3 1245 cc3000_nvmem(cc3000_hci &hci, cc3000_event &event, cc3000_simple_link &simple_link);
frankvnk 1:99bfc8d68fd3 1246 /**
frankvnk 1:99bfc8d68fd3 1247 * \brief Dtor
frankvnk 1:99bfc8d68fd3 1248 * \param none
frankvnk 1:99bfc8d68fd3 1249 * \return none
frankvnk 1:99bfc8d68fd3 1250 */
frankvnk 1:99bfc8d68fd3 1251 ~cc3000_nvmem();
frankvnk 1:99bfc8d68fd3 1252 /**
frankvnk 1:99bfc8d68fd3 1253 * \brief Reads data from the file referred by the file_id parameter.
frankvnk 1:99bfc8d68fd3 1254 * Reads data from file offset till length. Err if the file can't be used,
frankvnk 1:99bfc8d68fd3 1255 * is invalid, or if the read is out of bounds.
frankvnk 1:99bfc8d68fd3 1256 * \param file_id nvmem file id.
frankvnk 1:99bfc8d68fd3 1257 * \param length number of bytes to read.
frankvnk 1:99bfc8d68fd3 1258 * \param offset offset in file from where to read.
frankvnk 1:99bfc8d68fd3 1259 * \param buff output buffer pointer.
frankvnk 1:99bfc8d68fd3 1260 * \return
frankvnk 1:99bfc8d68fd3 1261 * Number of bytes read, otherwise error.
frankvnk 1:99bfc8d68fd3 1262 */
frankvnk 1:99bfc8d68fd3 1263 int32_t read(uint32_t file_id, uint32_t length, uint32_t offset, uint8_t *buff);
frankvnk 1:99bfc8d68fd3 1264 /**
frankvnk 1:99bfc8d68fd3 1265 * \brief Write data to nvmem.
frankvnk 1:99bfc8d68fd3 1266 * \param file_id Nvmem file id
frankvnk 1:99bfc8d68fd3 1267 * \param length number of bytes to write
frankvnk 1:99bfc8d68fd3 1268 * \param entry_offset offset in file to start write operation from
frankvnk 1:99bfc8d68fd3 1269 * \param buff data to write
frankvnk 1:99bfc8d68fd3 1270 * \return
frankvnk 1:99bfc8d68fd3 1271 * On success 0, error otherwise.
frankvnk 1:99bfc8d68fd3 1272 */
frankvnk 1:99bfc8d68fd3 1273 int32_t write(uint32_t file_id, uint32_t length, uint32_t entry_offset, uint8_t *buff);
frankvnk 1:99bfc8d68fd3 1274 /**
frankvnk 1:99bfc8d68fd3 1275 * \brief Write MAC address to EEPROM.
frankvnk 1:99bfc8d68fd3 1276 * \param mac Mac address to be set
frankvnk 1:99bfc8d68fd3 1277 * \return
frankvnk 1:99bfc8d68fd3 1278 * On success 0, error otherwise.
frankvnk 1:99bfc8d68fd3 1279 */
frankvnk 1:99bfc8d68fd3 1280 uint8_t set_mac_address(uint8_t *mac);
frankvnk 1:99bfc8d68fd3 1281 /**
frankvnk 1:99bfc8d68fd3 1282 * \brief Read MAC address from EEPROM.
frankvnk 1:99bfc8d68fd3 1283 * \param mac Mac address
frankvnk 1:99bfc8d68fd3 1284 * \return
frankvnk 1:99bfc8d68fd3 1285 * On success 0, error otherwise.
frankvnk 1:99bfc8d68fd3 1286 */
frankvnk 1:99bfc8d68fd3 1287 uint8_t get_mac_address(uint8_t *mac);
frankvnk 1:99bfc8d68fd3 1288 /**
frankvnk 1:99bfc8d68fd3 1289 * \brief Program a patch to a specific file ID. The SP data is assumed to be organized in 2-dimensional.
frankvnk 1:99bfc8d68fd3 1290 * Each line is SP_PORTION_SIZE bytes long.
frankvnk 1:99bfc8d68fd3 1291 * \param file_id nvmem file id/
frankvnk 1:99bfc8d68fd3 1292 * \param length number of bytes to write
frankvnk 1:99bfc8d68fd3 1293 * \param data SP data to write
frankvnk 1:99bfc8d68fd3 1294 * \return
frankvnk 1:99bfc8d68fd3 1295 * On success 0, error otherwise.
frankvnk 1:99bfc8d68fd3 1296 */
frankvnk 1:99bfc8d68fd3 1297 uint8_t write_patch(uint32_t file_id, uint32_t length, const uint8_t *data);
frankvnk 1:99bfc8d68fd3 1298 /**
frankvnk 1:99bfc8d68fd3 1299 * \brief Create new file entry and allocate space on the NVMEM. Applies only to user files.
frankvnk 1:99bfc8d68fd3 1300 * \param file_id nvmem file Id
frankvnk 1:99bfc8d68fd3 1301 * \param new_len entry ulLength
frankvnk 1:99bfc8d68fd3 1302 * \return
frankvnk 1:99bfc8d68fd3 1303 */
frankvnk 1:99bfc8d68fd3 1304 int32_t create_entry(uint32_t file_id, uint32_t new_len);
frankvnk 1:99bfc8d68fd3 1305 #ifndef CC3000_TINY_DRIVER
frankvnk 1:99bfc8d68fd3 1306 /**
frankvnk 1:99bfc8d68fd3 1307 * \brief Read patch version. read package version (WiFi FW patch, river-supplicant-NS patch,
frankvnk 1:99bfc8d68fd3 1308 * bootloader patch)
frankvnk 1:99bfc8d68fd3 1309 * \param patch_ver First number indicates package ID and the second number indicates
frankvnk 1:99bfc8d68fd3 1310 * package build number
frankvnk 1:99bfc8d68fd3 1311 * \return
frankvnk 1:99bfc8d68fd3 1312 * On success 0, error otherwise.
frankvnk 1:99bfc8d68fd3 1313 */
frankvnk 1:99bfc8d68fd3 1314 uint8_t read_sp_version(uint8_t* patch_ver);
frankvnk 1:99bfc8d68fd3 1315 #endif
frankvnk 1:99bfc8d68fd3 1316 private:
frankvnk 1:99bfc8d68fd3 1317 cc3000_hci &_hci;
frankvnk 1:99bfc8d68fd3 1318 cc3000_event &_event;
frankvnk 1:99bfc8d68fd3 1319 cc3000_simple_link &_simple_link;
frankvnk 1:99bfc8d68fd3 1320 };
frankvnk 1:99bfc8d68fd3 1321
frankvnk 1:99bfc8d68fd3 1322 /** WLAN layer
frankvnk 1:99bfc8d68fd3 1323 */
frankvnk 1:99bfc8d68fd3 1324 class cc3000_wlan {
frankvnk 1:99bfc8d68fd3 1325 public:
frankvnk 1:99bfc8d68fd3 1326 /**
frankvnk 1:99bfc8d68fd3 1327 * \brief Ctor
frankvnk 1:99bfc8d68fd3 1328 * \param simple_link Reference to the simple link object.
frankvnk 1:99bfc8d68fd3 1329 * \param event Reference to the event object.
frankvnk 1:99bfc8d68fd3 1330 * \param spi Reference to the spi object.
frankvnk 1:99bfc8d68fd3 1331 * \param hci Reference to the hci object.
frankvnk 1:99bfc8d68fd3 1332 * \return none
frankvnk 1:99bfc8d68fd3 1333 */
frankvnk 1:99bfc8d68fd3 1334 cc3000_wlan(cc3000_simple_link &simple_link, cc3000_event &event, cc3000_spi &spi, cc3000_hci &hci);
frankvnk 1:99bfc8d68fd3 1335 /**
frankvnk 1:99bfc8d68fd3 1336 * \brief Dtor
frankvnk 1:99bfc8d68fd3 1337 * \param none
frankvnk 1:99bfc8d68fd3 1338 * \return none
frankvnk 1:99bfc8d68fd3 1339 */
frankvnk 1:99bfc8d68fd3 1340 ~cc3000_wlan();
frankvnk 1:99bfc8d68fd3 1341 /**
frankvnk 1:99bfc8d68fd3 1342 * \brief Send SIMPLE LINK START to cc3000.
frankvnk 1:99bfc8d68fd3 1343 * \param patches_available_host Flag to indicate if patches are available.
frankvnk 1:99bfc8d68fd3 1344 * \return none
frankvnk 1:99bfc8d68fd3 1345 */
frankvnk 1:99bfc8d68fd3 1346 void simpleLink_init_start(uint16_t patches_available_host);
frankvnk 1:99bfc8d68fd3 1347 /**
frankvnk 1:99bfc8d68fd3 1348 * \brief Start wlan device. Blocking call until init is completed.
frankvnk 1:99bfc8d68fd3 1349 * \param patches_available_host Flag to indicate if patches are available.
frankvnk 1:99bfc8d68fd3 1350 * \return none
frankvnk 1:99bfc8d68fd3 1351 */
frankvnk 1:99bfc8d68fd3 1352 void start(uint16_t patches_available_host);
frankvnk 1:99bfc8d68fd3 1353 /**
frankvnk 1:99bfc8d68fd3 1354 * \brief Stop wlan device
frankvnk 1:99bfc8d68fd3 1355 * \param none
frankvnk 1:99bfc8d68fd3 1356 * \return none
frankvnk 1:99bfc8d68fd3 1357 */
frankvnk 1:99bfc8d68fd3 1358 void stop(void);
frankvnk 1:99bfc8d68fd3 1359 #ifndef CC3000_TINY_DRIVER
frankvnk 1:99bfc8d68fd3 1360 /**
frankvnk 1:99bfc8d68fd3 1361 * \brief Connect to AP.
frankvnk 1:99bfc8d68fd3 1362 * \param sec_type Security option.
frankvnk 1:99bfc8d68fd3 1363 * \param ssid up to 32 bytes, ASCII SSID
frankvnk 1:99bfc8d68fd3 1364 * \param ssid_length length of SSID
frankvnk 1:99bfc8d68fd3 1365 * \param b_ssid 6 bytes specified the AP bssid
frankvnk 1:99bfc8d68fd3 1366 * \param key up to 16 bytes specified the AP security key
frankvnk 1:99bfc8d68fd3 1367 * \param key_len key length
frankvnk 1:99bfc8d68fd3 1368 * \return
frankvnk 1:99bfc8d68fd3 1369 * On success, zero is returned. On error, negative is returned.
frankvnk 1:99bfc8d68fd3 1370 */
frankvnk 1:99bfc8d68fd3 1371 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);
frankvnk 1:99bfc8d68fd3 1372 /**
frankvnk 1:99bfc8d68fd3 1373 * \brief Add profile. Up to 7 profiles are supported.
frankvnk 1:99bfc8d68fd3 1374 * \param sec_type Security option.
frankvnk 1:99bfc8d68fd3 1375 * \param ssid Up to 32 bytes, ASCII SSID
frankvnk 1:99bfc8d68fd3 1376 * \param ssid_length Length of SSID
frankvnk 1:99bfc8d68fd3 1377 * \param b_ssid 6 bytes specified the AP bssid
frankvnk 1:99bfc8d68fd3 1378 * \param priority Up to 16 bytes specified the AP security key
frankvnk 1:99bfc8d68fd3 1379 * \param pairwise_cipher_or_tx_key_len Key length
frankvnk 1:99bfc8d68fd3 1380 * \param group_cipher_tx_key_index Key length for WEP security
frankvnk 1:99bfc8d68fd3 1381 * \param key_mgmt KEY management
frankvnk 1:99bfc8d68fd3 1382 * \param pf_or_key Security key
frankvnk 1:99bfc8d68fd3 1383 * \param pass_phrase_length Security key length for WPA\WPA2
frankvnk 1:99bfc8d68fd3 1384 * \return
frankvnk 1:99bfc8d68fd3 1385 * On success, zero is returned. On error, negative is returned.
frankvnk 1:99bfc8d68fd3 1386 */
frankvnk 1:99bfc8d68fd3 1387 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,
frankvnk 1:99bfc8d68fd3 1388 uint32_t key_mgmt, uint8_t* pf_or_key, uint32_t pass_phrase_length);
frankvnk 1:99bfc8d68fd3 1389 /**
frankvnk 1:99bfc8d68fd3 1390 * \brief Gets entry from scan result table. The scan results are returned
frankvnk 1:99bfc8d68fd3 1391 * one by one, and each entry represents a single AP found in the area.
frankvnk 1:99bfc8d68fd3 1392 * \param scan_timeout Not supported yet
frankvnk 1:99bfc8d68fd3 1393 * \param results Scan result
frankvnk 1:99bfc8d68fd3 1394 * \return
frankvnk 1:99bfc8d68fd3 1395 * On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 1396 */
frankvnk 1:99bfc8d68fd3 1397 int32_t ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results);
frankvnk 1:99bfc8d68fd3 1398 /**
frankvnk 1:99bfc8d68fd3 1399 * \brief Start and stop scan procedure. Set scan parameters.
frankvnk 1:99bfc8d68fd3 1400 * \param enable Start/stop application scan
frankvnk 1:99bfc8d68fd3 1401 * \param min_dwell_time Minimum dwell time value to be used for each channel, in ms. (Default: 20)
frankvnk 1:99bfc8d68fd3 1402 * \param max_dwell_time Maximum dwell time value to be used for each channel, in ms. (Default: 30)
frankvnk 1:99bfc8d68fd3 1403 * \param num_probe_requests Max probe request between dwell time. (Default:2)
frankvnk 1:99bfc8d68fd3 1404 * \param channel_mask Bitwise, up to 13 channels (0x1fff).
frankvnk 1:99bfc8d68fd3 1405 * \param rssi_threshold RSSI threshold. Saved: yes (Default: -80)
frankvnk 1:99bfc8d68fd3 1406 * \param snr_threshold NSR threshold. Saved: yes (Default: 0)
frankvnk 1:99bfc8d68fd3 1407 * \param default_tx_power probe Tx power. Saved: yes (Default: 205)
frankvnk 1:99bfc8d68fd3 1408 * \param interval_list Pointer to array with 16 entries (16 channels)
frankvnk 1:99bfc8d68fd3 1409 * \return
frankvnk 1:99bfc8d68fd3 1410 * On success, zero is returned. On error, -1 is returned.
frankvnk 1:99bfc8d68fd3 1411 */
frankvnk 1:99bfc8d68fd3 1412 int32_t ioctl_set_scan_params(uint32_t enable, uint32_t min_dwell_time, uint32_t max_dwell_time, uint32_t num_probe_requests,
frankvnk 1:99bfc8d68fd3 1413 uint32_t channel_mask, int32_t rssi_threshold, uint32_t snr_threshold, uint32_t default_tx_power, uint32_t *interval_list);
frankvnk 1:99bfc8d68fd3 1414 /**
frankvnk 1:99bfc8d68fd3 1415 * \brief Get wlan status: disconnected, scanning, connecting or connected
frankvnk 1:99bfc8d68fd3 1416 * \param none
frankvnk 1:99bfc8d68fd3 1417 * \return
frankvnk 1:99bfc8d68fd3 1418 * WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, STATUS_CONNECTING or WLAN_STATUS_CONNECTED
frankvnk 1:99bfc8d68fd3 1419 */
frankvnk 1:99bfc8d68fd3 1420 int32_t ioctl_statusget(void);
frankvnk 1:99bfc8d68fd3 1421 #else
frankvnk 1:99bfc8d68fd3 1422 /**
frankvnk 1:99bfc8d68fd3 1423 * \brief Connect to AP
frankvnk 1:99bfc8d68fd3 1424 * \param ssid Up to 32 bytes and is ASCII SSID of the AP
frankvnk 1:99bfc8d68fd3 1425 * \param ssid_length Length of the SSID
frankvnk 1:99bfc8d68fd3 1426 * \return
frankvnk 1:99bfc8d68fd3 1427 * On success, zero is returned. On error, negative is returned.
frankvnk 1:99bfc8d68fd3 1428 */
frankvnk 1:99bfc8d68fd3 1429 int32_t connect(const uint8_t *ssid, int32_t ssid_length);
frankvnk 1:99bfc8d68fd3 1430 /**
frankvnk 1:99bfc8d68fd3 1431 * \brief When auto start is enabled, the device connects to station from the profiles table.
frankvnk 1:99bfc8d68fd3 1432 * If several profiles configured the device choose the highest priority profile.
frankvnk 1:99bfc8d68fd3 1433 * \param sec_type WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2
frankvnk 1:99bfc8d68fd3 1434 * \param ssid SSID up to 32 bytes
frankvnk 1:99bfc8d68fd3 1435 * \param ssid_length SSID length
frankvnk 1:99bfc8d68fd3 1436 * \param b_ssid bssid 6 bytes
frankvnk 1:99bfc8d68fd3 1437 * \param priority Profile priority. Lowest priority:0.
frankvnk 1:99bfc8d68fd3 1438 * \param pairwise_cipher_or_tx_key_len Key length for WEP security
frankvnk 1:99bfc8d68fd3 1439 * \param group_cipher_tx_key_index Key index
frankvnk 1:99bfc8d68fd3 1440 * \param key_mgmt KEY management
frankvnk 1:99bfc8d68fd3 1441 * \param pf_or_key Security key
frankvnk 1:99bfc8d68fd3 1442 * \param pass_phrase_length Security key length for WPA\WPA2
frankvnk 1:99bfc8d68fd3 1443 * \return
frankvnk 1:99bfc8d68fd3 1444 * On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 1445 */
frankvnk 1:99bfc8d68fd3 1446 int32_t add_profile(uint32_t sec_type, uint8_t *ssid, uint32_t ssid_length, uint8_t *b_ssid, uint32_t priority,
frankvnk 1:99bfc8d68fd3 1447 uint32_t pairwise_cipher_or_tx_key_len, uint32_t group_cipher_tx_key_index, uint32_t key_mgmt,
frankvnk 1:99bfc8d68fd3 1448 uint8_t* pf_or_key, uint32_t pass_phrase_length);
frankvnk 1:99bfc8d68fd3 1449 #endif
frankvnk 1:99bfc8d68fd3 1450 #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
frankvnk 1:99bfc8d68fd3 1451 /**
frankvnk 1:99bfc8d68fd3 1452 * \brief Process the acquired data and store it as a profile.
frankvnk 1:99bfc8d68fd3 1453 * \param none
frankvnk 1:99bfc8d68fd3 1454 * \return
frankvnk 1:99bfc8d68fd3 1455 * On success, zero is returned. On error, -1 is returned.
frankvnk 1:99bfc8d68fd3 1456 */
frankvnk 1:99bfc8d68fd3 1457 int32_t smart_config_process(void);
frankvnk 1:99bfc8d68fd3 1458 #endif
frankvnk 1:99bfc8d68fd3 1459 /**
frankvnk 1:99bfc8d68fd3 1460 * \brief Disconnect connection from AP.
frankvnk 1:99bfc8d68fd3 1461 * \param none
frankvnk 1:99bfc8d68fd3 1462 * \return
frankvnk 1:99bfc8d68fd3 1463 * 0 if disconnected done, other CC3000 already disconnected.
frankvnk 1:99bfc8d68fd3 1464 */
frankvnk 1:99bfc8d68fd3 1465 int32_t disconnect();
frankvnk 1:99bfc8d68fd3 1466 /**
frankvnk 1:99bfc8d68fd3 1467 * \brief When auto is enabled, the device tries to connect according the following policy:
frankvnk 1:99bfc8d68fd3 1468 * 1) If fast connect is enabled and last connection is valid, the device will try to
frankvnk 1:99bfc8d68fd3 1469 * connect to it without the scanning procedure (fast). The last connection will be
frankvnk 1:99bfc8d68fd3 1470 * marked as invalid, due to adding/removing profile.
frankvnk 1:99bfc8d68fd3 1471 * 2) If profile exists, the device will try to connect it (Up to seven profiles).
frankvnk 1:99bfc8d68fd3 1472 * 3) If fast and profiles are not found, and open mode is enabled, the device
frankvnk 1:99bfc8d68fd3 1473 * will try to connect to any AP.
frankvnk 1:99bfc8d68fd3 1474 * Note that the policy settings are stored in the CC3000 NVMEM.
frankvnk 1:99bfc8d68fd3 1475 * \param should_connect_to_open_ap Enable(1), disable(0) connect to any available AP.
frankvnk 1:99bfc8d68fd3 1476 * \param use_fast_connect Enable(1), disable(0). if enabled, tries to
frankvnk 1:99bfc8d68fd3 1477 * connect to the last connected AP.
frankvnk 1:99bfc8d68fd3 1478 * \param use_profiles Enable(1), disable(0) auto connect after reset.
frankvnk 1:99bfc8d68fd3 1479 * and periodically reconnect if needed.
frankvnk 1:99bfc8d68fd3 1480 * \return
frankvnk 1:99bfc8d68fd3 1481 * On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 1482 */
frankvnk 1:99bfc8d68fd3 1483 int32_t ioctl_set_connection_policy(uint32_t should_connect_to_open_ap, uint32_t use_fast_connect, uint32_t use_profiles);
frankvnk 1:99bfc8d68fd3 1484 /**
frankvnk 1:99bfc8d68fd3 1485 * \brief Delete WLAN profile
frankvnk 1:99bfc8d68fd3 1486 * \param index Number of profile to delete
frankvnk 1:99bfc8d68fd3 1487 * \return
frankvnk 1:99bfc8d68fd3 1488 * On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 1489 */
frankvnk 1:99bfc8d68fd3 1490 int32_t ioctl_del_profile(uint32_t index);
frankvnk 1:99bfc8d68fd3 1491 /**
frankvnk 1:99bfc8d68fd3 1492 * \brief Mask event according to bit mask. In case that event is
frankvnk 1:99bfc8d68fd3 1493 * masked (1), the device will not send the masked event to host.
frankvnk 1:99bfc8d68fd3 1494 * \param mask event mask
frankvnk 1:99bfc8d68fd3 1495 * \return
frankvnk 1:99bfc8d68fd3 1496 * On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 1497 */
frankvnk 1:99bfc8d68fd3 1498 int32_t set_event_mask(uint32_t mask);
frankvnk 1:99bfc8d68fd3 1499 /**
frankvnk 1:99bfc8d68fd3 1500 * \brief Start to acquire device profile. The device acquire its own
frankvnk 1:99bfc8d68fd3 1501 * profile, if profile message is found.
frankvnk 1:99bfc8d68fd3 1502 * \param encrypted_flag Indicates whether the information is encrypted
frankvnk 1:99bfc8d68fd3 1503 * \return
frankvnk 1:99bfc8d68fd3 1504 * On success, zero is returned. On error, -1 is returned.
frankvnk 1:99bfc8d68fd3 1505 */
frankvnk 1:99bfc8d68fd3 1506 int32_t smart_config_start(uint32_t encrypted_flag);
frankvnk 1:99bfc8d68fd3 1507 /**
frankvnk 1:99bfc8d68fd3 1508 * \brief Stop the acquire profile procedure.
frankvnk 1:99bfc8d68fd3 1509 * \param none
frankvnk 1:99bfc8d68fd3 1510 * \return
frankvnk 1:99bfc8d68fd3 1511 * On success, zero is returned. On error, -1 is returned
frankvnk 1:99bfc8d68fd3 1512 */
frankvnk 1:99bfc8d68fd3 1513 int32_t smart_config_stop(void);
frankvnk 1:99bfc8d68fd3 1514 /**
frankvnk 1:99bfc8d68fd3 1515 * \brief Configure station ssid prefix.
frankvnk 1:99bfc8d68fd3 1516 * \param new_prefix 3 bytes identify the SSID prefix for the Smart Config.
frankvnk 1:99bfc8d68fd3 1517 * \return
frankvnk 1:99bfc8d68fd3 1518 * On success, zero is returned. On error, -1 is returned.
frankvnk 1:99bfc8d68fd3 1519 */
frankvnk 1:99bfc8d68fd3 1520 int32_t smart_config_set_prefix(uint8_t *new_prefix);
frankvnk 1:99bfc8d68fd3 1521 private:
frankvnk 1:99bfc8d68fd3 1522 cc3000_simple_link &_simple_link;
frankvnk 1:99bfc8d68fd3 1523 cc3000_event &_event;
frankvnk 1:99bfc8d68fd3 1524 cc3000_spi &_spi;
frankvnk 1:99bfc8d68fd3 1525 cc3000_hci &_hci;
frankvnk 1:99bfc8d68fd3 1526 };
frankvnk 1:99bfc8d68fd3 1527
frankvnk 1:99bfc8d68fd3 1528 /** The main object of cc3000 implementation
frankvnk 1:99bfc8d68fd3 1529 */
frankvnk 1:99bfc8d68fd3 1530 class cc3000 {
frankvnk 1:99bfc8d68fd3 1531 public:
frankvnk 1:99bfc8d68fd3 1532 /** status structure */
frankvnk 1:99bfc8d68fd3 1533 typedef struct {
frankvnk 1:99bfc8d68fd3 1534 bool dhcp;
frankvnk 1:99bfc8d68fd3 1535 bool connected;
frankvnk 1:99bfc8d68fd3 1536 uint8_t socket;
frankvnk 1:99bfc8d68fd3 1537 bool smart_config_complete;
frankvnk 1:99bfc8d68fd3 1538 bool stop_smart_config;
frankvnk 1:99bfc8d68fd3 1539 bool dhcp_configured;
frankvnk 1:99bfc8d68fd3 1540 bool ok_to_shut_down;
frankvnk 1:99bfc8d68fd3 1541 bool enabled;
frankvnk 1:99bfc8d68fd3 1542 } tStatus;
frankvnk 1:99bfc8d68fd3 1543 /**
frankvnk 1:99bfc8d68fd3 1544 * \brief Ctor.
frankvnk 1:99bfc8d68fd3 1545 * \param cc3000_irq IRQ pin
frankvnk 1:99bfc8d68fd3 1546 * \param cc3000_en Enable pin
frankvnk 1:99bfc8d68fd3 1547 * \param cc3000_cs Chip select pin
frankvnk 1:99bfc8d68fd3 1548 * \param cc3000_spi SPI interface
frankvnk 1:99bfc8d68fd3 1549 * \param irq_port IRQ pin's port
frankvnk 1:99bfc8d68fd3 1550 */
frankvnk 1:99bfc8d68fd3 1551 cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port);
frankvnk 1:99bfc8d68fd3 1552 /**
frankvnk 1:99bfc8d68fd3 1553 * \brief Dtor.
frankvnk 1:99bfc8d68fd3 1554 */
frankvnk 1:99bfc8d68fd3 1555 ~cc3000();
frankvnk 1:99bfc8d68fd3 1556 /**
frankvnk 1:99bfc8d68fd3 1557 * \brief Initiate cc3000. It starts the wlan communication and deletes profiles.
frankvnk 1:99bfc8d68fd3 1558 * \param patch Patch
frankvnk 1:99bfc8d68fd3 1559 */
frankvnk 1:99bfc8d68fd3 1560 void start(uint8_t patch);
frankvnk 1:99bfc8d68fd3 1561 /**
frankvnk 1:99bfc8d68fd3 1562 * \brief Stops the wlan communication.
frankvnk 1:99bfc8d68fd3 1563 */
frankvnk 1:99bfc8d68fd3 1564 void stop();
frankvnk 1:99bfc8d68fd3 1565 /**
frankvnk 1:99bfc8d68fd3 1566 * \brief Restarts the wlan communication.
frankvnk 1:99bfc8d68fd3 1567 */
frankvnk 1:99bfc8d68fd3 1568 void restart(uint8_t patch);
frankvnk 1:99bfc8d68fd3 1569 /**
frankvnk 1:99bfc8d68fd3 1570 * \brief Disconnect wlan device
frankvnk 1:99bfc8d68fd3 1571 *
frankvnk 1:99bfc8d68fd3 1572 */
frankvnk 1:99bfc8d68fd3 1573 bool disconnect(void);
frankvnk 1:99bfc8d68fd3 1574 /**
frankvnk 1:99bfc8d68fd3 1575 * \brief Callback which is called from the event class. This updates status of cc3000.
frankvnk 1:99bfc8d68fd3 1576 * \param event_type Type of the event
frankvnk 1:99bfc8d68fd3 1577 * \param data Pointer to data
frankvnk 1:99bfc8d68fd3 1578 * \param length Length of data
frankvnk 1:99bfc8d68fd3 1579 * \return none
frankvnk 1:99bfc8d68fd3 1580 */
frankvnk 1:99bfc8d68fd3 1581 void usync_callback(int32_t event_type, uint8_t *data, uint8_t length);
frankvnk 1:99bfc8d68fd3 1582 /**
frankvnk 1:99bfc8d68fd3 1583 * \brief Start connection to SSID (open/secured) non-blocking
frankvnk 1:99bfc8d68fd3 1584 * \param ssid SSID name
frankvnk 1:99bfc8d68fd3 1585 * \param key Security key (if key = 0, open connection)
frankvnk 1:99bfc8d68fd3 1586 * \param security_mode Security mode
frankvnk 1:99bfc8d68fd3 1587 * \return true if connection was established, false otherwise.
frankvnk 1:99bfc8d68fd3 1588 */
frankvnk 1:99bfc8d68fd3 1589 bool connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
frankvnk 1:99bfc8d68fd3 1590 /**
frankvnk 1:99bfc8d68fd3 1591 * \brief Connect to SSID (open/secured) with timeout (10s).
frankvnk 1:99bfc8d68fd3 1592 * \param ssid SSID name
frankvnk 1:99bfc8d68fd3 1593 * \param key Security key (if key = 0, open connection)
frankvnk 1:99bfc8d68fd3 1594 * \param security_mode Security mode
frankvnk 1:99bfc8d68fd3 1595 * \return true if connection was established, false otherwise.
frankvnk 1:99bfc8d68fd3 1596 */
frankvnk 1:99bfc8d68fd3 1597 bool connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
frankvnk 1:99bfc8d68fd3 1598 /**
frankvnk 1:99bfc8d68fd3 1599 * \brief Connect to SSID which is secured
frankvnk 1:99bfc8d68fd3 1600 * \param ssid SSID name
frankvnk 1:99bfc8d68fd3 1601 * \param key Security key
frankvnk 1:99bfc8d68fd3 1602 * \param security_mode Security mode
frankvnk 1:99bfc8d68fd3 1603 * \return true if connection was established, false otherwise.
frankvnk 1:99bfc8d68fd3 1604 */
frankvnk 1:99bfc8d68fd3 1605 bool connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
frankvnk 1:99bfc8d68fd3 1606 /**
frankvnk 1:99bfc8d68fd3 1607 * \brief Connect to SSID which is open (no security)
frankvnk 1:99bfc8d68fd3 1608 * \param ssid SSID name
frankvnk 1:99bfc8d68fd3 1609 * \return true if connection was established, false otherwise.
frankvnk 1:99bfc8d68fd3 1610 */
frankvnk 1:99bfc8d68fd3 1611 bool connect_open(const uint8_t *ssid);
frankvnk 1:99bfc8d68fd3 1612 /**
frankvnk 1:99bfc8d68fd3 1613 * \brief Status of the cc3000 module.
frankvnk 1:99bfc8d68fd3 1614 * \return true if it's enabled, false otherwise.
frankvnk 1:99bfc8d68fd3 1615 */
frankvnk 1:99bfc8d68fd3 1616 bool is_enabled();
frankvnk 1:99bfc8d68fd3 1617 /**
frankvnk 1:99bfc8d68fd3 1618 * \brief Status of the cc3000 connection.
frankvnk 1:99bfc8d68fd3 1619 * \return true if it's connected, false otherwise.
frankvnk 1:99bfc8d68fd3 1620 */
frankvnk 1:99bfc8d68fd3 1621 bool is_connected();
frankvnk 1:99bfc8d68fd3 1622 /**
frankvnk 1:99bfc8d68fd3 1623 * \brief Status of DHCP.
frankvnk 1:99bfc8d68fd3 1624 * \param none
frankvnk 1:99bfc8d68fd3 1625 * \return true if DCHP is configured, false otherwise.
frankvnk 1:99bfc8d68fd3 1626 */
frankvnk 1:99bfc8d68fd3 1627 bool is_dhcp_configured();
frankvnk 1:99bfc8d68fd3 1628 /**
frankvnk 1:99bfc8d68fd3 1629 * \brief Status of smart confing completation.
frankvnk 1:99bfc8d68fd3 1630 * \param none
frankvnk 1:99bfc8d68fd3 1631 * \return smart config was set, false otherwise.
frankvnk 1:99bfc8d68fd3 1632 */
frankvnk 1:99bfc8d68fd3 1633 bool is_smart_confing_completed();
frankvnk 1:99bfc8d68fd3 1634 /**
frankvnk 1:99bfc8d68fd3 1635 * \brief Return the cc3000's mac address.
frankvnk 1:99bfc8d68fd3 1636 * \param address Retreived mac address.
frankvnk 1:99bfc8d68fd3 1637 * \return
frankvnk 1:99bfc8d68fd3 1638 */
frankvnk 1:99bfc8d68fd3 1639 uint8_t get_mac_address(uint8_t address[6]);
frankvnk 1:99bfc8d68fd3 1640 /**
frankvnk 1:99bfc8d68fd3 1641 * \brief Set the cc3000's mac address.
frankvnk 1:99bfc8d68fd3 1642 * \param address Mac address to be set.
frankvnk 1:99bfc8d68fd3 1643 * \return
frankvnk 1:99bfc8d68fd3 1644 */
frankvnk 1:99bfc8d68fd3 1645 uint8_t set_mac_address(uint8_t address[6]);
frankvnk 1:99bfc8d68fd3 1646 /**
frankvnk 1:99bfc8d68fd3 1647 * \brief Get user file info.
frankvnk 1:99bfc8d68fd3 1648 * \param info_file Pointer where info will be stored.
frankvnk 1:99bfc8d68fd3 1649 * \param size Available size.
frankvnk 1:99bfc8d68fd3 1650 * \return none
frankvnk 1:99bfc8d68fd3 1651 */
frankvnk 1:99bfc8d68fd3 1652 void get_user_file_info(uint8_t *info_file, size_t size);
frankvnk 1:99bfc8d68fd3 1653 /**
frankvnk 1:99bfc8d68fd3 1654 * \brief Set user filo info.
frankvnk 1:99bfc8d68fd3 1655 * \param info_file Pointer to user's info.
frankvnk 1:99bfc8d68fd3 1656 * \return none
frankvnk 1:99bfc8d68fd3 1657 */
frankvnk 1:99bfc8d68fd3 1658 void set_user_file_info(uint8_t *info_file, size_t size);
frankvnk 1:99bfc8d68fd3 1659 /**
frankvnk 1:99bfc8d68fd3 1660 * \brief Start smart config.
frankvnk 1:99bfc8d68fd3 1661 * \param smart_config_key Pointer to smart config key.
frankvnk 1:99bfc8d68fd3 1662 * \return none
frankvnk 1:99bfc8d68fd3 1663 */
frankvnk 1:99bfc8d68fd3 1664 void start_smart_config(const uint8_t *smart_config_key); /* TODO enable AES ? */
frankvnk 1:99bfc8d68fd3 1665 #ifndef CC3000_TINY_DRIVER
frankvnk 1:99bfc8d68fd3 1666 /**
frankvnk 1:99bfc8d68fd3 1667 * \brief Return ip configuration.
frankvnk 1:99bfc8d68fd3 1668 * \param ip_config Pointer to ipconfig data.
frankvnk 1:99bfc8d68fd3 1669 * \return true if it's connected and info was retrieved, false otherwise.
frankvnk 1:99bfc8d68fd3 1670 */
frankvnk 1:99bfc8d68fd3 1671 bool get_ip_config(tNetappIpconfigRetArgs *ip_config);
frankvnk 1:99bfc8d68fd3 1672 #endif
frankvnk 1:99bfc8d68fd3 1673 /**
frankvnk 1:99bfc8d68fd3 1674 * \brief Delete all stored profiles.
frankvnk 1:99bfc8d68fd3 1675 * \param none
frankvnk 1:99bfc8d68fd3 1676 * \return none
frankvnk 1:99bfc8d68fd3 1677 */
frankvnk 1:99bfc8d68fd3 1678 void delete_profiles(void);
frankvnk 1:99bfc8d68fd3 1679 /**
frankvnk 1:99bfc8d68fd3 1680 * \brief Ping an ip address.
frankvnk 1:99bfc8d68fd3 1681 * \param ip Destination IP address
frankvnk 1:99bfc8d68fd3 1682 * \param attempts Number of attempts
frankvnk 1:99bfc8d68fd3 1683 * \param timeout Time to wait for a response,in milliseconds.
frankvnk 1:99bfc8d68fd3 1684 * \param size Send buffer size which may be up to 1400 bytes
frankvnk 1:99bfc8d68fd3 1685 */
frankvnk 1:99bfc8d68fd3 1686 uint32_t ping(uint32_t ip, uint8_t attempts, uint16_t timeout, uint8_t size);
frankvnk 1:99bfc8d68fd3 1687 /**
frankvnk 1:99bfc8d68fd3 1688 * \brief Returns cc3000 instance. Used in Socket interface.
frankvnk 1:99bfc8d68fd3 1689 * \param none
frankvnk 1:99bfc8d68fd3 1690 * \return Pointer to cc3000 object
frankvnk 1:99bfc8d68fd3 1691 */
frankvnk 1:99bfc8d68fd3 1692 static cc3000 *get_instance() {
frankvnk 1:99bfc8d68fd3 1693 return _inst;
frankvnk 1:99bfc8d68fd3 1694 }
frankvnk 1:99bfc8d68fd3 1695 #if (CC3000_ETH_COMPAT == 1)
frankvnk 1:99bfc8d68fd3 1696 /**
frankvnk 1:99bfc8d68fd3 1697 * \brief Get the MAC address of your Ethernet interface.
frankvnk 1:99bfc8d68fd3 1698 * \param none
frankvnk 1:99bfc8d68fd3 1699 * \return
frankvnk 1:99bfc8d68fd3 1700 * Pointer to a string containing the MAC address.
frankvnk 1:99bfc8d68fd3 1701 */
frankvnk 1:99bfc8d68fd3 1702 char* getMACAddress();
frankvnk 1:99bfc8d68fd3 1703
frankvnk 1:99bfc8d68fd3 1704 /**
frankvnk 1:99bfc8d68fd3 1705 * \brief Get the IP address of your Ethernet interface.
frankvnk 1:99bfc8d68fd3 1706 * \param none
frankvnk 1:99bfc8d68fd3 1707 * \return
frankvnk 1:99bfc8d68fd3 1708 * Pointer to a string containing the IP address.
frankvnk 1:99bfc8d68fd3 1709 */
frankvnk 1:99bfc8d68fd3 1710 char* getIPAddress();
frankvnk 1:99bfc8d68fd3 1711
frankvnk 1:99bfc8d68fd3 1712 /**
frankvnk 1:99bfc8d68fd3 1713 * \brief Get the Gateway address of your Ethernet interface
frankvnk 1:99bfc8d68fd3 1714 * \param none
frankvnk 1:99bfc8d68fd3 1715 * \return
frankvnk 1:99bfc8d68fd3 1716 * Pointer to a string containing the Gateway address
frankvnk 1:99bfc8d68fd3 1717 */
frankvnk 1:99bfc8d68fd3 1718 char* getGateway();
frankvnk 1:99bfc8d68fd3 1719
frankvnk 1:99bfc8d68fd3 1720 /**
frankvnk 1:99bfc8d68fd3 1721 * \brief Get the Network mask of your Ethernet interface
frankvnk 1:99bfc8d68fd3 1722 * \param none
frankvnk 1:99bfc8d68fd3 1723 * \return
frankvnk 1:99bfc8d68fd3 1724 * Pointer to a string containing the Network mask
frankvnk 1:99bfc8d68fd3 1725 */
frankvnk 1:99bfc8d68fd3 1726 char* getNetworkMask();
frankvnk 1:99bfc8d68fd3 1727 #endif
frankvnk 1:99bfc8d68fd3 1728 public:
frankvnk 1:99bfc8d68fd3 1729 cc3000_simple_link _simple_link;
frankvnk 1:99bfc8d68fd3 1730 cc3000_event _event;
frankvnk 1:99bfc8d68fd3 1731 #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
frankvnk 1:99bfc8d68fd3 1732 cc3000_security _security;
frankvnk 1:99bfc8d68fd3 1733 #endif
frankvnk 1:99bfc8d68fd3 1734 cc3000_socket _socket;
frankvnk 1:99bfc8d68fd3 1735 cc3000_spi _spi;
frankvnk 1:99bfc8d68fd3 1736 cc3000_hci _hci;
frankvnk 1:99bfc8d68fd3 1737 cc3000_nvmem _nvmem;
frankvnk 1:99bfc8d68fd3 1738 cc3000_netapp _netapp;
frankvnk 1:99bfc8d68fd3 1739 cc3000_wlan _wlan;
frankvnk 1:99bfc8d68fd3 1740 protected:
frankvnk 1:99bfc8d68fd3 1741 static cc3000 *_inst;
frankvnk 1:99bfc8d68fd3 1742 private:
frankvnk 1:99bfc8d68fd3 1743 tStatus _status;
frankvnk 1:99bfc8d68fd3 1744 netapp_pingreport_args_t _ping_report;
frankvnk 1:99bfc8d68fd3 1745 bool _closed_sockets[MAX_SOCKETS];
frankvnk 1:99bfc8d68fd3 1746 };
frankvnk 1:99bfc8d68fd3 1747
frankvnk 1:99bfc8d68fd3 1748 /**
frankvnk 1:99bfc8d68fd3 1749 * Copy 32 bit to stream while converting to little endian format.
frankvnk 1:99bfc8d68fd3 1750 * @param p pointer to the new stream
frankvnk 1:99bfc8d68fd3 1751 * @param u32 pointer to the 32 bit
frankvnk 1:99bfc8d68fd3 1752 * @return pointer to the new stream
frankvnk 1:99bfc8d68fd3 1753 */
frankvnk 1:99bfc8d68fd3 1754 uint8_t *UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32);
frankvnk 1:99bfc8d68fd3 1755
frankvnk 1:99bfc8d68fd3 1756 /**
frankvnk 1:99bfc8d68fd3 1757 * Copy 16 bit to stream while converting to little endian format.
frankvnk 1:99bfc8d68fd3 1758 * @param p pointer to the new stream
frankvnk 1:99bfc8d68fd3 1759 * @param u32 pointer to the 16 bit
frankvnk 1:99bfc8d68fd3 1760 * @return pointer to the new stream
frankvnk 1:99bfc8d68fd3 1761 */
frankvnk 1:99bfc8d68fd3 1762 uint8_t *UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16);
frankvnk 1:99bfc8d68fd3 1763
frankvnk 1:99bfc8d68fd3 1764 /**
frankvnk 1:99bfc8d68fd3 1765 * Copy received stream to 16 bit in little endian format.
frankvnk 1:99bfc8d68fd3 1766 * @param p pointer to the stream
frankvnk 1:99bfc8d68fd3 1767 * @param offset offset in the stream
frankvnk 1:99bfc8d68fd3 1768 * @return pointer to the new 16 bit
frankvnk 1:99bfc8d68fd3 1769 */
frankvnk 1:99bfc8d68fd3 1770 uint16_t STREAM_TO_UINT16_f(uint8_t* p, uint16_t offset);
frankvnk 1:99bfc8d68fd3 1771
frankvnk 1:99bfc8d68fd3 1772 /**
frankvnk 1:99bfc8d68fd3 1773 * Copy received stream to 32 bit in little endian format.
frankvnk 1:99bfc8d68fd3 1774 * @param p pointer to the stream
frankvnk 1:99bfc8d68fd3 1775 * @param offset offset in the stream
frankvnk 1:99bfc8d68fd3 1776 * @return pointer to the new 32 bit
frankvnk 1:99bfc8d68fd3 1777 */
frankvnk 1:99bfc8d68fd3 1778 uint32_t STREAM_TO_UINT32_f(uint8_t* p, uint16_t offset);
frankvnk 1:99bfc8d68fd3 1779
frankvnk 1:99bfc8d68fd3 1780 } /* end of mbed_cc3000 namespace */
frankvnk 1:99bfc8d68fd3 1781
frankvnk 1:99bfc8d68fd3 1782
frankvnk 1:99bfc8d68fd3 1783 #endif