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