None
Fork of cc3000_hostdriver_mbedsocket by
cc3000.h@33:9e23b24fb4f3, 2013-10-08 (annotated)
- Committer:
- Kojto
- Date:
- Tue Oct 08 07:04:07 2013 +0200
- Revision:
- 33:9e23b24fb4f3
- Parent:
- 31:7b6e85b68b01
- Child:
- 34:1ad18123bf11
Removed code (set buffers) - non-sense, doxygen comments for simple link class
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 | 20:30b6ed7bf8fd | 53 | |
SolderSplashLabs | 22:d23c59fec0dc | 54 | /** Enable debug messages, comment out the ones you don't want |
Kojto | 20:30b6ed7bf8fd | 55 | */ |
SolderSplashLabs | 26:456f73ed2a75 | 56 | |
SolderSplashLabs | 24:ba3fa29197ac | 57 | // Debug - Socket interface messages |
SolderSplashLabs | 22:d23c59fec0dc | 58 | #define CC3000_DEBUG_SOCKET |
SolderSplashLabs | 26:456f73ed2a75 | 59 | |
SolderSplashLabs | 24:ba3fa29197ac | 60 | // Debug - HCI TX messages |
SolderSplashLabs | 22:d23c59fec0dc | 61 | #define CC3000_DEBUG_HCI_TX |
SolderSplashLabs | 26:456f73ed2a75 | 62 | |
SolderSplashLabs | 24:ba3fa29197ac | 63 | // Debug - HCI Rx messages |
SolderSplashLabs | 22:d23c59fec0dc | 64 | #define CC3000_DEBUG_HCI_RX |
SolderSplashLabs | 26:456f73ed2a75 | 65 | |
SolderSplashLabs | 24:ba3fa29197ac | 66 | // Debug - General Debug |
SolderSplashLabs | 22:d23c59fec0dc | 67 | #define CC3000_DEBUG |
Kojto | 20:30b6ed7bf8fd | 68 | |
SolderSplashLabs | 26:456f73ed2a75 | 69 | // Add colour to the debug messages, requires a VT100 terminal like putty, comment out to remove |
SolderSplashLabs | 22:d23c59fec0dc | 70 | #define VT100_COLOUR |
SolderSplashLabs | 22:d23c59fec0dc | 71 | |
SolderSplashLabs | 22:d23c59fec0dc | 72 | #ifdef CC3000_DEBUG_SOCKET |
Kojto | 20:30b6ed7bf8fd | 73 | |
SolderSplashLabs | 22:d23c59fec0dc | 74 | #ifdef VT100_COLOUR |
SolderSplashLabs | 22:d23c59fec0dc | 75 | #define DBG_SOCKET(x, ...) std::printf("\x1b[2;32;40m[CC3000 : SOCKET] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__); |
SolderSplashLabs | 22:d23c59fec0dc | 76 | #else |
SolderSplashLabs | 22:d23c59fec0dc | 77 | #define DBG_SOCKET(x, ...) std::printf("[CC3000 : SOCKET] "x"\r\n", ##__VA_ARGS__); |
SolderSplashLabs | 22:d23c59fec0dc | 78 | #endif |
Kojto | 29:c40918cd9b6d | 79 | |
Kojto | 20:30b6ed7bf8fd | 80 | #else |
Kojto | 20:30b6ed7bf8fd | 81 | #define DBG_SOCKET(x, ...) |
SolderSplashLabs | 22:d23c59fec0dc | 82 | #endif |
SolderSplashLabs | 22:d23c59fec0dc | 83 | |
SolderSplashLabs | 22:d23c59fec0dc | 84 | #ifdef CC3000_DEBUG_HCI_TX |
SolderSplashLabs | 22:d23c59fec0dc | 85 | |
SolderSplashLabs | 22:d23c59fec0dc | 86 | #ifdef VT100_COLOUR |
SolderSplashLabs | 22:d23c59fec0dc | 87 | #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 | 88 | #else |
SolderSplashLabs | 22:d23c59fec0dc | 89 | #define DBG_HCI(x, ...) std::printf("[CC3000 : HCI RX] "x"\r\n", ##__VA_ARGS__); |
SolderSplashLabs | 22:d23c59fec0dc | 90 | #endif |
Kojto | 29:c40918cd9b6d | 91 | |
SolderSplashLabs | 22:d23c59fec0dc | 92 | #else |
Kojto | 20:30b6ed7bf8fd | 93 | #define DBG_HCI(x, ...) |
SolderSplashLabs | 22:d23c59fec0dc | 94 | #endif |
SolderSplashLabs | 22:d23c59fec0dc | 95 | |
SolderSplashLabs | 22:d23c59fec0dc | 96 | #ifdef CC3000_DEBUG_HCI_RX |
SolderSplashLabs | 22:d23c59fec0dc | 97 | |
SolderSplashLabs | 22:d23c59fec0dc | 98 | #ifdef VT100_COLOUR |
SolderSplashLabs | 22:d23c59fec0dc | 99 | #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 | 100 | #else |
SolderSplashLabs | 22:d23c59fec0dc | 101 | #define DBG_HCI_CMD(x, ...) std::printf("[CC3000 : HCI TX] "x"\r\n", ##__VA_ARGS__); |
SolderSplashLabs | 22:d23c59fec0dc | 102 | #endif |
Kojto | 29:c40918cd9b6d | 103 | |
SolderSplashLabs | 22:d23c59fec0dc | 104 | #else |
SolderSplashLabs | 22:d23c59fec0dc | 105 | #define DBG_HCI_CMD(x, ...) |
SolderSplashLabs | 22:d23c59fec0dc | 106 | #endif |
SolderSplashLabs | 22:d23c59fec0dc | 107 | |
SolderSplashLabs | 22:d23c59fec0dc | 108 | |
SolderSplashLabs | 22:d23c59fec0dc | 109 | #ifdef CC3000_DEBUG |
SolderSplashLabs | 22:d23c59fec0dc | 110 | |
SolderSplashLabs | 22:d23c59fec0dc | 111 | #ifdef VT100_COLOUR |
SolderSplashLabs | 22:d23c59fec0dc | 112 | #define DBG_CC(x, ...) std::printf("\x1b[2;32;40m[CC3000] "x"\x1b[0;37;40m\r\n", ##__VA_ARGS__); |
SolderSplashLabs | 22:d23c59fec0dc | 113 | #else |
SolderSplashLabs | 22:d23c59fec0dc | 114 | #define DBG_CC(x, ...) std::printf("[CC3000] "x"\r\n", ##__VA_ARGS__); |
SolderSplashLabs | 22:d23c59fec0dc | 115 | #endif |
Kojto | 29:c40918cd9b6d | 116 | |
SolderSplashLabs | 22:d23c59fec0dc | 117 | #else |
SolderSplashLabs | 24:ba3fa29197ac | 118 | #define DBG_CC(x, ...) |
Kojto | 20:30b6ed7bf8fd | 119 | #endif |
Kojto | 20:30b6ed7bf8fd | 120 | |
Kojto | 20:30b6ed7bf8fd | 121 | namespace mbed_cc3000 { |
Kojto | 20:30b6ed7bf8fd | 122 | |
Kojto | 20:30b6ed7bf8fd | 123 | /** User info structure |
Kojto | 20:30b6ed7bf8fd | 124 | */ |
Kojto | 20:30b6ed7bf8fd | 125 | typedef struct { |
Kojto | 20:30b6ed7bf8fd | 126 | uint8_t FTC; // First time config performed |
Kojto | 20:30b6ed7bf8fd | 127 | uint8_t PP_version[2]; // Patch Programmer version |
Kojto | 20:30b6ed7bf8fd | 128 | uint8_t SERV_PACK[2]; // Service Pack Version |
Kojto | 20:30b6ed7bf8fd | 129 | uint8_t DRV_VER[3]; // Driver Version |
Kojto | 20:30b6ed7bf8fd | 130 | uint8_t FW_VER[3]; // Firmware Version |
Kojto | 20:30b6ed7bf8fd | 131 | uint8_t validCIK; // CIK[] is valid (Client Interface Key) |
Kojto | 20:30b6ed7bf8fd | 132 | uint8_t CIK[40]; |
Kojto | 20:30b6ed7bf8fd | 133 | } tUserFS; |
Kojto | 20:30b6ed7bf8fd | 134 | |
Kojto | 20:30b6ed7bf8fd | 135 | /** Function pointers which are not yet implemented |
Kojto | 20:30b6ed7bf8fd | 136 | */ |
Kojto | 20:30b6ed7bf8fd | 137 | enum FunctionNumber { |
Kojto | 20:30b6ed7bf8fd | 138 | FW_PATCHES = 0, |
Kojto | 20:30b6ed7bf8fd | 139 | DRIVER_PATCHES = 1, |
Kojto | 20:30b6ed7bf8fd | 140 | BOOTLOADER_PATCHES = 2, |
Kojto | 20:30b6ed7bf8fd | 141 | }; |
Kojto | 20:30b6ed7bf8fd | 142 | |
Kojto | 20:30b6ed7bf8fd | 143 | /** CC3000 Simple Link class which contains status of cc3000. |
Kojto | 20:30b6ed7bf8fd | 144 | */ |
Kojto | 20:30b6ed7bf8fd | 145 | class cc3000_simple_link { |
Kojto | 20:30b6ed7bf8fd | 146 | public: |
Kojto | 33:9e23b24fb4f3 | 147 | /** |
Kojto | 33:9e23b24fb4f3 | 148 | * \brief ctor - sets magic number in the buffers (overflow mark). |
Kojto | 33:9e23b24fb4f3 | 149 | * \param none |
Kojto | 33:9e23b24fb4f3 | 150 | * \return none |
Kojto | 20:30b6ed7bf8fd | 151 | */ |
Kojto | 20:30b6ed7bf8fd | 152 | cc3000_simple_link(); |
Kojto | 33:9e23b24fb4f3 | 153 | /** |
Kojto | 33:9e23b24fb4f3 | 154 | * \brief dtor |
Kojto | 33:9e23b24fb4f3 | 155 | * \param none |
Kojto | 33:9e23b24fb4f3 | 156 | * \return none |
Kojto | 20:30b6ed7bf8fd | 157 | */ |
Kojto | 20:30b6ed7bf8fd | 158 | ~cc3000_simple_link(); |
Kojto | 33:9e23b24fb4f3 | 159 | /** |
Kojto | 33:9e23b24fb4f3 | 160 | * \brief Returns data received flag. |
Kojto | 33:9e23b24fb4f3 | 161 | * \return Data received flag. |
Kojto | 20:30b6ed7bf8fd | 162 | */ |
Kojto | 20:30b6ed7bf8fd | 163 | uint8_t get_data_received_flag(); |
Kojto | 33:9e23b24fb4f3 | 164 | /** |
Kojto | 33:9e23b24fb4f3 | 165 | * \brief Set data received flag. |
Kojto | 20:30b6ed7bf8fd | 166 | * \param value The value to be set. |
Kojto | 20:30b6ed7bf8fd | 167 | */ |
Kojto | 20:30b6ed7bf8fd | 168 | void set_data_received_flag(uint8_t value); |
Kojto | 20:30b6ed7bf8fd | 169 | /** Returns if tx was completed. |
Kojto | 20:30b6ed7bf8fd | 170 | * \return |
Kojto | 20:30b6ed7bf8fd | 171 | * true if tx was completed, |
Kojto | 20:30b6ed7bf8fd | 172 | * false otherwise. |
Kojto | 20:30b6ed7bf8fd | 173 | */ |
Kojto | 20:30b6ed7bf8fd | 174 | bool get_tx_complete_signal(); |
Kojto | 20:30b6ed7bf8fd | 175 | /** |
Kojto | 33:9e23b24fb4f3 | 176 | * \brief Sets flag that tx was completed. |
Kojto | 33:9e23b24fb4f3 | 177 | * \param value Value to be set |
Kojto | 33:9e23b24fb4f3 | 178 | * \return none |
Kojto | 20:30b6ed7bf8fd | 179 | */ |
Kojto | 20:30b6ed7bf8fd | 180 | void set_tx_complete_signal(bool value); |
Kojto | 20:30b6ed7bf8fd | 181 | /** |
Kojto | 33:9e23b24fb4f3 | 182 | * \brief Get receive buffer. |
Kojto | 33:9e23b24fb4f3 | 183 | * \param none |
Kojto | 33:9e23b24fb4f3 | 184 | * \return Pointer to the receive buffer. |
Kojto | 20:30b6ed7bf8fd | 185 | */ |
Kojto | 20:30b6ed7bf8fd | 186 | uint8_t *get_received_buffer(); |
Kojto | 20:30b6ed7bf8fd | 187 | /** |
Kojto | 33:9e23b24fb4f3 | 188 | * \brief Get transmit buffer. |
Kojto | 33:9e23b24fb4f3 | 189 | * \param none |
Kojto | 33:9e23b24fb4f3 | 190 | * \return Pointer to the transmit buffer. |
Kojto | 20:30b6ed7bf8fd | 191 | */ |
Kojto | 20:30b6ed7bf8fd | 192 | uint8_t *get_transmit_buffer(); |
Kojto | 20:30b6ed7bf8fd | 193 | /** |
Kojto | 33:9e23b24fb4f3 | 194 | * \brief Get number of free buffers. |
Kojto | 33:9e23b24fb4f3 | 195 | * \param none |
Kojto | 29:c40918cd9b6d | 196 | * \return |
Kojto | 33:9e23b24fb4f3 | 197 | * Number of free buffers. |
Kojto | 20:30b6ed7bf8fd | 198 | */ |
Kojto | 20:30b6ed7bf8fd | 199 | uint16_t get_number_free_buffers(); |
Kojto | 20:30b6ed7bf8fd | 200 | /** |
Kojto | 33:9e23b24fb4f3 | 201 | * \brief Set number of free buffers. |
Kojto | 33:9e23b24fb4f3 | 202 | * \param value Number of free buffers. |
Kojto | 33:9e23b24fb4f3 | 203 | * \return none |
Kojto | 20:30b6ed7bf8fd | 204 | */ |
Kojto | 20:30b6ed7bf8fd | 205 | void set_number_free_buffers(uint16_t value); |
Kojto | 20:30b6ed7bf8fd | 206 | /** |
Kojto | 33:9e23b24fb4f3 | 207 | * \brief Retrieve buffer length. |
Kojto | 33:9e23b24fb4f3 | 208 | * \param none |
Kojto | 33:9e23b24fb4f3 | 209 | * \return Buffer length |
Kojto | 20:30b6ed7bf8fd | 210 | */ |
Kojto | 20:30b6ed7bf8fd | 211 | uint16_t get_buffer_length(); |
Kojto | 20:30b6ed7bf8fd | 212 | /** |
Kojto | 33:9e23b24fb4f3 | 213 | * \brief Set buffer length |
Kojto | 33:9e23b24fb4f3 | 214 | * \param value The length |
Kojto | 33:9e23b24fb4f3 | 215 | * \return none |
Kojto | 20:30b6ed7bf8fd | 216 | */ |
Kojto | 20:30b6ed7bf8fd | 217 | void set_buffer_length(uint16_t value); |
Kojto | 20:30b6ed7bf8fd | 218 | /** |
Kojto | 33:9e23b24fb4f3 | 219 | * \brief Retrieve pending data flag. |
Kojto | 33:9e23b24fb4f3 | 220 | * \param none |
Kojto | 33:9e23b24fb4f3 | 221 | * \return Pending data flag |
Kojto | 20:30b6ed7bf8fd | 222 | */ |
Kojto | 20:30b6ed7bf8fd | 223 | uint16_t get_pending_data(); |
Kojto | 20:30b6ed7bf8fd | 224 | /** |
Kojto | 33:9e23b24fb4f3 | 225 | * \brief Set pending data flag. |
Kojto | 33:9e23b24fb4f3 | 226 | * \param value Pending data value. |
Kojto | 33:9e23b24fb4f3 | 227 | * \return none |
Kojto | 20:30b6ed7bf8fd | 228 | */ |
Kojto | 20:30b6ed7bf8fd | 229 | void set_pending_data(uint16_t value); |
Kojto | 20:30b6ed7bf8fd | 230 | /** |
Kojto | 33:9e23b24fb4f3 | 231 | * \brief Retreive op code. |
Kojto | 33:9e23b24fb4f3 | 232 | * \param none |
Kojto | 33:9e23b24fb4f3 | 233 | * \return Op code |
Kojto | 20:30b6ed7bf8fd | 234 | */ |
Kojto | 20:30b6ed7bf8fd | 235 | uint16_t get_op_code(); |
Kojto | 20:30b6ed7bf8fd | 236 | /** |
Kojto | 33:9e23b24fb4f3 | 237 | * \brief Set op code. |
Kojto | 33:9e23b24fb4f3 | 238 | * \param code op code. |
Kojto | 33:9e23b24fb4f3 | 239 | * \return none |
Kojto | 20:30b6ed7bf8fd | 240 | */ |
Kojto | 20:30b6ed7bf8fd | 241 | void set_op_code(uint16_t code); |
Kojto | 20:30b6ed7bf8fd | 242 | /** |
Kojto | 33:9e23b24fb4f3 | 243 | * \brief Get number of released packets. |
Kojto | 33:9e23b24fb4f3 | 244 | * \param none |
Kojto | 33:9e23b24fb4f3 | 245 | * \return Number of released packets. |
Kojto | 20:30b6ed7bf8fd | 246 | */ |
Kojto | 20:30b6ed7bf8fd | 247 | uint16_t get_released_packets(); |
Kojto | 20:30b6ed7bf8fd | 248 | /** |
Kojto | 33:9e23b24fb4f3 | 249 | * \brief Set number of released packets. |
Kojto | 33:9e23b24fb4f3 | 250 | * \param value Number of released packets. |
Kojto | 33:9e23b24fb4f3 | 251 | * \return none |
Kojto | 20:30b6ed7bf8fd | 252 | */ |
Kojto | 20:30b6ed7bf8fd | 253 | void set_number_of_released_packets(uint16_t value); |
Kojto | 20:30b6ed7bf8fd | 254 | /** |
Kojto | 33:9e23b24fb4f3 | 255 | * \brief Get number of sent packats |
Kojto | 33:9e23b24fb4f3 | 256 | * \param none |
Kojto | 33:9e23b24fb4f3 | 257 | * \return Number of sent packets. |
Kojto | 20:30b6ed7bf8fd | 258 | */ |
Kojto | 20:30b6ed7bf8fd | 259 | uint16_t get_sent_packets(); |
Kojto | 20:30b6ed7bf8fd | 260 | /** |
Kojto | 33:9e23b24fb4f3 | 261 | * \brief Set number of sent packets |
Kojto | 33:9e23b24fb4f3 | 262 | * \param value Number of sent packets. |
Kojto | 33:9e23b24fb4f3 | 263 | * \return none |
Kojto | 20:30b6ed7bf8fd | 264 | */ |
Kojto | 20:30b6ed7bf8fd | 265 | void set_sent_packets(uint16_t value); |
Kojto | 29:c40918cd9b6d | 266 | /** |
Kojto | 33:9e23b24fb4f3 | 267 | * \brief Retrieve transmit error |
Kojto | 33:9e23b24fb4f3 | 268 | * \param none |
Kojto | 33:9e23b24fb4f3 | 269 | * \return Transmit error |
Kojto | 29:c40918cd9b6d | 270 | */ |
Kojto | 20:30b6ed7bf8fd | 271 | int32_t get_transmit_error(); |
Kojto | 29:c40918cd9b6d | 272 | /** |
Kojto | 33:9e23b24fb4f3 | 273 | * \brief Set transmit error. |
Kojto | 33:9e23b24fb4f3 | 274 | * \param value Error to be set. |
Kojto | 33:9e23b24fb4f3 | 275 | * \return none |
Kojto | 29:c40918cd9b6d | 276 | */ |
Kojto | 20:30b6ed7bf8fd | 277 | void set_transmit_error(int32_t value); |
Kojto | 29:c40918cd9b6d | 278 | /** |
Kojto | 33:9e23b24fb4f3 | 279 | * \brief Get buffer size. |
Kojto | 33:9e23b24fb4f3 | 280 | * \param none |
Kojto | 33:9e23b24fb4f3 | 281 | * \return Size of buffer. |
Kojto | 29:c40918cd9b6d | 282 | */ |
Kojto | 33:9e23b24fb4f3 | 283 | uint16_t get_buffer_size(); |
Kojto | 29:c40918cd9b6d | 284 | /** |
Kojto | 33:9e23b24fb4f3 | 285 | * \brief Set buffer size. |
Kojto | 33:9e23b24fb4f3 | 286 | * \param value Buffer size. |
Kojto | 33:9e23b24fb4f3 | 287 | * \return none |
Kojto | 29:c40918cd9b6d | 288 | */ |
Kojto | 20:30b6ed7bf8fd | 289 | void set_buffer_size(uint16_t value); |
Kojto | 29:c40918cd9b6d | 290 | /** |
Kojto | 33:9e23b24fb4f3 | 291 | * \brief Not used currently. |
Kojto | 33:9e23b24fb4f3 | 292 | * \param function Number of desired function. |
Kojto | 33:9e23b24fb4f3 | 293 | * \return void pointer to the function (need to recast). |
Kojto | 29:c40918cd9b6d | 294 | */ |
Kojto | 20:30b6ed7bf8fd | 295 | void *get_func_pointer(FunctionNumber function); |
Kojto | 29:c40918cd9b6d | 296 | /** |
Kojto | 33:9e23b24fb4f3 | 297 | * \brief Retreive pointer to the received data. |
Kojto | 33:9e23b24fb4f3 | 298 | * \param none |
Kojto | 33:9e23b24fb4f3 | 299 | * \return Pointer to the received data buffer. |
Kojto | 29:c40918cd9b6d | 300 | */ |
Kojto | 33:9e23b24fb4f3 | 301 | uint8_t *get_received_data(); |
Kojto | 29:c40918cd9b6d | 302 | /** |
Kojto | 33:9e23b24fb4f3 | 303 | * \brief Set received data pointer. |
Kojto | 33:9e23b24fb4f3 | 304 | * \param pointer Pointer to the buffer. |
Kojto | 33:9e23b24fb4f3 | 305 | * \return none |
Kojto | 29:c40918cd9b6d | 306 | */ |
Kojto | 20:30b6ed7bf8fd | 307 | void set_received_data(uint8_t *pointer); |
Kojto | 20:30b6ed7bf8fd | 308 | private: |
Kojto | 20:30b6ed7bf8fd | 309 | uint8_t _data_received_flag; |
Kojto | 20:30b6ed7bf8fd | 310 | bool _tx_complete_signal; |
Kojto | 20:30b6ed7bf8fd | 311 | uint16_t _rx_event_opcode; |
Kojto | 20:30b6ed7bf8fd | 312 | uint16_t _free_buffers; |
Kojto | 20:30b6ed7bf8fd | 313 | uint16_t _buffer_length; |
Kojto | 20:30b6ed7bf8fd | 314 | uint16_t _buffer_size; |
Kojto | 20:30b6ed7bf8fd | 315 | uint16_t _rx_data_pending; |
Kojto | 20:30b6ed7bf8fd | 316 | uint16_t _sent_packets; |
Kojto | 20:30b6ed7bf8fd | 317 | uint16_t _released_packets; |
Kojto | 20:30b6ed7bf8fd | 318 | int32_t _transmit_data_error; |
Kojto | 20:30b6ed7bf8fd | 319 | uint8_t *_received_data; |
Kojto | 20:30b6ed7bf8fd | 320 | uint8_t _rx_buffer[CC3000_RX_BUFFER_SIZE]; |
Kojto | 20:30b6ed7bf8fd | 321 | uint8_t _tx_buffer[CC3000_TX_BUFFER_SIZE]; |
Kojto | 20:30b6ed7bf8fd | 322 | private: |
Kojto | 33:9e23b24fb4f3 | 323 | /* Not used currently */ |
Kojto | 20:30b6ed7bf8fd | 324 | int8_t *(* _fFWPatches)(uint32_t *length); |
Kojto | 20:30b6ed7bf8fd | 325 | int8_t *(* _fDriverPatches)(uint32_t *length); |
Kojto | 20:30b6ed7bf8fd | 326 | int8_t *(* _fBootLoaderPatches)(uint32_t *length); |
Kojto | 20:30b6ed7bf8fd | 327 | }; |
Kojto | 20:30b6ed7bf8fd | 328 | |
Kojto | 20:30b6ed7bf8fd | 329 | /** Forward declaration classes |
Kojto | 20:30b6ed7bf8fd | 330 | */ |
Kojto | 20:30b6ed7bf8fd | 331 | class cc3000_hci; |
Kojto | 20:30b6ed7bf8fd | 332 | class cc3000_nvmem; |
Kojto | 20:30b6ed7bf8fd | 333 | class cc3000_spi; |
Kojto | 20:30b6ed7bf8fd | 334 | class cc3000; |
Kojto | 20:30b6ed7bf8fd | 335 | |
Kojto | 31:7b6e85b68b01 | 336 | /** Event layer |
Kojto | 20:30b6ed7bf8fd | 337 | */ |
Kojto | 20:30b6ed7bf8fd | 338 | class cc3000_event { |
Kojto | 20:30b6ed7bf8fd | 339 | public: |
Kojto | 29:c40918cd9b6d | 340 | /** |
Kojto | 29:c40918cd9b6d | 341 | * \brief |
Kojto | 29:c40918cd9b6d | 342 | * \param |
Kojto | 29:c40918cd9b6d | 343 | * \return |
Kojto | 29:c40918cd9b6d | 344 | */ |
Kojto | 20:30b6ed7bf8fd | 345 | cc3000_event(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_spi &spi, cc3000 &cc3000); |
Kojto | 29:c40918cd9b6d | 346 | /** |
Kojto | 29:c40918cd9b6d | 347 | * \brief |
Kojto | 29:c40918cd9b6d | 348 | * \param |
Kojto | 29:c40918cd9b6d | 349 | * \return |
Kojto | 29:c40918cd9b6d | 350 | */ |
Kojto | 29:c40918cd9b6d | 351 | ~cc3000_event(); |
Kojto | 29:c40918cd9b6d | 352 | /** |
Kojto | 29:c40918cd9b6d | 353 | * \brief |
Kojto | 29:c40918cd9b6d | 354 | * \param |
Kojto | 29:c40918cd9b6d | 355 | * \return |
Kojto | 29:c40918cd9b6d | 356 | */ |
Kojto | 20:30b6ed7bf8fd | 357 | void hci_unsol_handle_patch_request(uint8_t *event_hdr); |
Kojto | 29:c40918cd9b6d | 358 | /** |
Kojto | 29:c40918cd9b6d | 359 | * \brief |
Kojto | 29:c40918cd9b6d | 360 | * \param |
Kojto | 29:c40918cd9b6d | 361 | * \return |
Kojto | 29:c40918cd9b6d | 362 | */ |
Kojto | 20:30b6ed7bf8fd | 363 | uint8_t *hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen); |
Kojto | 29:c40918cd9b6d | 364 | /** |
Kojto | 29:c40918cd9b6d | 365 | * \brief |
Kojto | 29:c40918cd9b6d | 366 | * \param |
Kojto | 29:c40918cd9b6d | 367 | * \return |
Kojto | 29:c40918cd9b6d | 368 | */ |
Kojto | 20:30b6ed7bf8fd | 369 | int32_t hci_unsol_event_handler(uint8_t *event_hdr); |
Kojto | 29:c40918cd9b6d | 370 | /** |
Kojto | 29:c40918cd9b6d | 371 | * \brief |
Kojto | 29:c40918cd9b6d | 372 | * \param |
Kojto | 29:c40918cd9b6d | 373 | * \return |
Kojto | 29:c40918cd9b6d | 374 | */ |
Kojto | 20:30b6ed7bf8fd | 375 | int32_t hci_unsolicited_event_handler(void); |
Kojto | 29:c40918cd9b6d | 376 | /** |
Kojto | 29:c40918cd9b6d | 377 | * \brief |
Kojto | 29:c40918cd9b6d | 378 | * \param |
Kojto | 29:c40918cd9b6d | 379 | * \return |
Kojto | 29:c40918cd9b6d | 380 | */ |
Kojto | 20:30b6ed7bf8fd | 381 | int32_t get_socket_active_status(int32_t sd); |
Kojto | 29:c40918cd9b6d | 382 | /** |
Kojto | 29:c40918cd9b6d | 383 | * \brief |
Kojto | 29:c40918cd9b6d | 384 | * \param |
Kojto | 29:c40918cd9b6d | 385 | * \return |
Kojto | 29:c40918cd9b6d | 386 | */ |
Kojto | 20:30b6ed7bf8fd | 387 | void set_socket_active_status(int32_t sd, int32_t status); |
Kojto | 29:c40918cd9b6d | 388 | /** |
Kojto | 29:c40918cd9b6d | 389 | * \brief |
Kojto | 29:c40918cd9b6d | 390 | * \param |
Kojto | 29:c40918cd9b6d | 391 | * \return |
Kojto | 29:c40918cd9b6d | 392 | */ |
Kojto | 20:30b6ed7bf8fd | 393 | int32_t hci_event_unsol_flowcontrol_handler(uint8_t *event); |
Kojto | 29:c40918cd9b6d | 394 | /** |
Kojto | 29:c40918cd9b6d | 395 | * \brief |
Kojto | 29:c40918cd9b6d | 396 | * \param |
Kojto | 29:c40918cd9b6d | 397 | * \return |
Kojto | 29:c40918cd9b6d | 398 | */ |
Kojto | 20:30b6ed7bf8fd | 399 | void update_socket_active_status(uint8_t *resp_params); |
Kojto | 29:c40918cd9b6d | 400 | /** |
Kojto | 29:c40918cd9b6d | 401 | * \brief |
Kojto | 29:c40918cd9b6d | 402 | * \param |
Kojto | 29:c40918cd9b6d | 403 | * \return |
Kojto | 29:c40918cd9b6d | 404 | */ |
Kojto | 20:30b6ed7bf8fd | 405 | void simplelink_wait_event(uint16_t op_code, void *ret_param); |
Kojto | 29:c40918cd9b6d | 406 | /** |
Kojto | 29:c40918cd9b6d | 407 | * \brief |
Kojto | 29:c40918cd9b6d | 408 | * \param |
Kojto | 29:c40918cd9b6d | 409 | * \return |
Kojto | 29:c40918cd9b6d | 410 | */ |
Kojto | 20:30b6ed7bf8fd | 411 | void simplelink_wait_data(uint8_t *buffer, uint8_t *from, uint8_t *fromlen); |
Kojto | 29:c40918cd9b6d | 412 | /** |
Kojto | 29:c40918cd9b6d | 413 | * \brief |
Kojto | 29:c40918cd9b6d | 414 | * \param |
Kojto | 29:c40918cd9b6d | 415 | * \return |
Kojto | 29:c40918cd9b6d | 416 | */ |
Kojto | 20:30b6ed7bf8fd | 417 | void received_handler(uint8_t *buffer); |
Kojto | 20:30b6ed7bf8fd | 418 | private: |
Kojto | 20:30b6ed7bf8fd | 419 | uint32_t socket_active_status; |
Kojto | 20:30b6ed7bf8fd | 420 | cc3000_simple_link &_simple_link; |
Kojto | 20:30b6ed7bf8fd | 421 | cc3000_hci &_hci; |
Kojto | 20:30b6ed7bf8fd | 422 | cc3000_spi &_spi; |
Kojto | 20:30b6ed7bf8fd | 423 | cc3000 &_cc3000; |
Kojto | 20:30b6ed7bf8fd | 424 | }; |
Kojto | 20:30b6ed7bf8fd | 425 | |
Kojto | 31:7b6e85b68b01 | 426 | /** Netapp layer |
Kojto | 31:7b6e85b68b01 | 427 | */ |
Kojto | 20:30b6ed7bf8fd | 428 | class cc3000_netapp { |
Kojto | 20:30b6ed7bf8fd | 429 | public: |
Kojto | 29:c40918cd9b6d | 430 | /** |
Kojto | 29:c40918cd9b6d | 431 | * \brief |
Kojto | 29:c40918cd9b6d | 432 | * \param |
Kojto | 29:c40918cd9b6d | 433 | * \return |
Kojto | 29:c40918cd9b6d | 434 | */ |
Kojto | 20:30b6ed7bf8fd | 435 | cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci, cc3000_event &event); |
Kojto | 29:c40918cd9b6d | 436 | /** |
Kojto | 29:c40918cd9b6d | 437 | * \brief |
Kojto | 29:c40918cd9b6d | 438 | * \param |
Kojto | 29:c40918cd9b6d | 439 | * \return |
Kojto | 29:c40918cd9b6d | 440 | */ |
Kojto | 20:30b6ed7bf8fd | 441 | ~cc3000_netapp(); |
Kojto | 29:c40918cd9b6d | 442 | /** |
Kojto | 29:c40918cd9b6d | 443 | * \brief |
Kojto | 29:c40918cd9b6d | 444 | * \param |
Kojto | 29:c40918cd9b6d | 445 | * \return |
Kojto | 29:c40918cd9b6d | 446 | */ |
Kojto | 20:30b6ed7bf8fd | 447 | int32_t config_mac_adrress(uint8_t *mac); |
Kojto | 29:c40918cd9b6d | 448 | /** |
Kojto | 29:c40918cd9b6d | 449 | * \brief |
Kojto | 29:c40918cd9b6d | 450 | * \param |
Kojto | 29:c40918cd9b6d | 451 | * \return |
Kojto | 29:c40918cd9b6d | 452 | */ |
Kojto | 20:30b6ed7bf8fd | 453 | int32_t dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server); |
Kojto | 20:30b6ed7bf8fd | 454 | #ifndef CC3000_TINY_DRIVER |
Kojto | 29:c40918cd9b6d | 455 | /** |
Kojto | 29:c40918cd9b6d | 456 | * \brief |
Kojto | 29:c40918cd9b6d | 457 | * \param |
Kojto | 29:c40918cd9b6d | 458 | * \return |
Kojto | 29:c40918cd9b6d | 459 | */ |
Kojto | 20:30b6ed7bf8fd | 460 | void ipconfig(tNetappIpconfigRetArgs *ipconfig); |
Kojto | 29:c40918cd9b6d | 461 | /** |
Kojto | 29:c40918cd9b6d | 462 | * \brief |
Kojto | 29:c40918cd9b6d | 463 | * \param |
Kojto | 29:c40918cd9b6d | 464 | * \return |
Kojto | 29:c40918cd9b6d | 465 | */ |
Kojto | 20:30b6ed7bf8fd | 466 | int32_t timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity); |
Kojto | 29:c40918cd9b6d | 467 | /** |
Kojto | 29:c40918cd9b6d | 468 | * \brief |
Kojto | 29:c40918cd9b6d | 469 | * \param |
Kojto | 29:c40918cd9b6d | 470 | * \return |
Kojto | 29:c40918cd9b6d | 471 | */ |
Kojto | 20:30b6ed7bf8fd | 472 | int32_t ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout); |
Kojto | 29:c40918cd9b6d | 473 | /** |
Kojto | 29:c40918cd9b6d | 474 | * \brief |
Kojto | 29:c40918cd9b6d | 475 | * \param |
Kojto | 29:c40918cd9b6d | 476 | * \return |
Kojto | 29:c40918cd9b6d | 477 | */ |
Kojto | 20:30b6ed7bf8fd | 478 | void ping_report(); |
Kojto | 29:c40918cd9b6d | 479 | /** |
Kojto | 29:c40918cd9b6d | 480 | * \brief |
Kojto | 29:c40918cd9b6d | 481 | * \param |
Kojto | 29:c40918cd9b6d | 482 | * \return |
Kojto | 29:c40918cd9b6d | 483 | */ |
Kojto | 20:30b6ed7bf8fd | 484 | int32_t ping_stop(); |
Kojto | 29:c40918cd9b6d | 485 | /** |
Kojto | 29:c40918cd9b6d | 486 | * \brief |
Kojto | 29:c40918cd9b6d | 487 | * \param |
Kojto | 29:c40918cd9b6d | 488 | * \return |
Kojto | 29:c40918cd9b6d | 489 | */ |
Kojto | 20:30b6ed7bf8fd | 490 | int32_t arp_flush(); |
Kojto | 20:30b6ed7bf8fd | 491 | #endif |
Kojto | 20:30b6ed7bf8fd | 492 | private: |
Kojto | 20:30b6ed7bf8fd | 493 | cc3000_simple_link &_simple_link; |
Kojto | 20:30b6ed7bf8fd | 494 | cc3000_nvmem &_nvmem; |
Kojto | 20:30b6ed7bf8fd | 495 | cc3000_hci &_hci; |
Kojto | 20:30b6ed7bf8fd | 496 | cc3000_event &_event; |
Kojto | 20:30b6ed7bf8fd | 497 | }; |
Kojto | 20:30b6ed7bf8fd | 498 | |
Kojto | 20:30b6ed7bf8fd | 499 | #ifndef CC3000_UNENCRYPTED_SMART_CONFIG |
Kojto | 31:7b6e85b68b01 | 500 | /** Security class used only if encrypted smart config is set |
Kojto | 31:7b6e85b68b01 | 501 | */ |
Kojto | 20:30b6ed7bf8fd | 502 | class cc3000_security { |
Kojto | 20:30b6ed7bf8fd | 503 | public: |
Kojto | 29:c40918cd9b6d | 504 | /** |
Kojto | 29:c40918cd9b6d | 505 | * \brief |
Kojto | 29:c40918cd9b6d | 506 | * \param |
Kojto | 29:c40918cd9b6d | 507 | * \return |
Kojto | 29:c40918cd9b6d | 508 | */ |
Kojto | 20:30b6ed7bf8fd | 509 | void expandKey(uint8_t *expanded_key, uint8_t *key); |
Kojto | 29:c40918cd9b6d | 510 | /** |
Kojto | 29:c40918cd9b6d | 511 | * \brief |
Kojto | 29:c40918cd9b6d | 512 | * \param |
Kojto | 29:c40918cd9b6d | 513 | * \return |
Kojto | 29:c40918cd9b6d | 514 | */ |
Kojto | 20:30b6ed7bf8fd | 515 | uint8_t galois_mul2(uint8_t value); |
Kojto | 29:c40918cd9b6d | 516 | /** |
Kojto | 29:c40918cd9b6d | 517 | * \brief |
Kojto | 29:c40918cd9b6d | 518 | * \param |
Kojto | 29:c40918cd9b6d | 519 | * \return |
Kojto | 29:c40918cd9b6d | 520 | */ |
Kojto | 20:30b6ed7bf8fd | 521 | void aes_encr(uint8_t *state, uint8_t *expanded_key); |
Kojto | 29:c40918cd9b6d | 522 | /** |
Kojto | 29:c40918cd9b6d | 523 | * \brief |
Kojto | 29:c40918cd9b6d | 524 | * \param |
Kojto | 29:c40918cd9b6d | 525 | * \return |
Kojto | 29:c40918cd9b6d | 526 | */ |
Kojto | 20:30b6ed7bf8fd | 527 | void aes_decr(uint8_t *state, uint8_t *expanded_key); |
Kojto | 29:c40918cd9b6d | 528 | /** |
Kojto | 29:c40918cd9b6d | 529 | * \brief |
Kojto | 29:c40918cd9b6d | 530 | * \param |
Kojto | 29:c40918cd9b6d | 531 | * \return |
Kojto | 29:c40918cd9b6d | 532 | */ |
Kojto | 20:30b6ed7bf8fd | 533 | void aes_encrypt(uint8_t *state, uint8_t *key); |
Kojto | 29:c40918cd9b6d | 534 | /** |
Kojto | 29:c40918cd9b6d | 535 | * \brief |
Kojto | 29:c40918cd9b6d | 536 | * \param |
Kojto | 29:c40918cd9b6d | 537 | * \return |
Kojto | 29:c40918cd9b6d | 538 | */ |
Kojto | 20:30b6ed7bf8fd | 539 | void aes_decrypt(uint8_t *state, uint8_t *key); |
Kojto | 29:c40918cd9b6d | 540 | /** |
Kojto | 29:c40918cd9b6d | 541 | * \brief |
Kojto | 29:c40918cd9b6d | 542 | * \param |
Kojto | 29:c40918cd9b6d | 543 | * \return |
Kojto | 29:c40918cd9b6d | 544 | */ |
Kojto | 20:30b6ed7bf8fd | 545 | int32_t aes_read_key(uint8_t *key); |
Kojto | 29:c40918cd9b6d | 546 | /** |
Kojto | 29:c40918cd9b6d | 547 | * \brief |
Kojto | 29:c40918cd9b6d | 548 | * \param |
Kojto | 29:c40918cd9b6d | 549 | * \return |
Kojto | 29:c40918cd9b6d | 550 | */ |
Kojto | 20:30b6ed7bf8fd | 551 | int32_t aes_write_key(uint8_t *key); |
Kojto | 20:30b6ed7bf8fd | 552 | private: |
Kojto | 20:30b6ed7bf8fd | 553 | uint8_t _expanded_key[176]; |
Kojto | 20:30b6ed7bf8fd | 554 | }; |
Kojto | 20:30b6ed7bf8fd | 555 | #endif |
Kojto | 20:30b6ed7bf8fd | 556 | |
Kojto | 31:7b6e85b68b01 | 557 | /** Socket layer |
Kojto | 31:7b6e85b68b01 | 558 | */ |
Kojto | 20:30b6ed7bf8fd | 559 | class cc3000_socket { |
Kojto | 20:30b6ed7bf8fd | 560 | public: |
Kojto | 29:c40918cd9b6d | 561 | /** |
Kojto | 29:c40918cd9b6d | 562 | * \brief |
Kojto | 29:c40918cd9b6d | 563 | * \param |
Kojto | 29:c40918cd9b6d | 564 | * \return |
Kojto | 29:c40918cd9b6d | 565 | */ |
Kojto | 20:30b6ed7bf8fd | 566 | cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event); |
Kojto | 29:c40918cd9b6d | 567 | /** |
Kojto | 29:c40918cd9b6d | 568 | * \brief |
Kojto | 29:c40918cd9b6d | 569 | * \param |
Kojto | 29:c40918cd9b6d | 570 | * \return |
Kojto | 29:c40918cd9b6d | 571 | */ |
Kojto | 20:30b6ed7bf8fd | 572 | ~cc3000_socket(); |
Kojto | 29:c40918cd9b6d | 573 | /** |
Kojto | 29:c40918cd9b6d | 574 | * \brief |
Kojto | 29:c40918cd9b6d | 575 | * \param |
Kojto | 29:c40918cd9b6d | 576 | * \return |
Kojto | 29:c40918cd9b6d | 577 | */ |
Kojto | 20:30b6ed7bf8fd | 578 | int32_t socket(int32_t domain, int32_t type, int32_t protocol); |
Kojto | 29:c40918cd9b6d | 579 | /** |
Kojto | 29:c40918cd9b6d | 580 | * \brief |
Kojto | 29:c40918cd9b6d | 581 | * \param |
Kojto | 29:c40918cd9b6d | 582 | * \return |
Kojto | 29:c40918cd9b6d | 583 | */ |
Kojto | 20:30b6ed7bf8fd | 584 | int32_t accept(int32_t sd, sockaddr *addr, socklen_t *addrlen); |
Kojto | 29:c40918cd9b6d | 585 | /** |
Kojto | 29:c40918cd9b6d | 586 | * \brief |
Kojto | 29:c40918cd9b6d | 587 | * \param |
Kojto | 29:c40918cd9b6d | 588 | * \return |
Kojto | 29:c40918cd9b6d | 589 | */ |
Kojto | 20:30b6ed7bf8fd | 590 | int32_t bind(int32_t sd, const sockaddr *addr, int32_t addrlen); |
Kojto | 29:c40918cd9b6d | 591 | /** |
Kojto | 29:c40918cd9b6d | 592 | * \brief |
Kojto | 29:c40918cd9b6d | 593 | * \param |
Kojto | 29:c40918cd9b6d | 594 | * \return |
Kojto | 29:c40918cd9b6d | 595 | */ |
Kojto | 20:30b6ed7bf8fd | 596 | int32_t HostFlowControlConsumeBuff(int32_t sd); |
Kojto | 29:c40918cd9b6d | 597 | /** |
Kojto | 29:c40918cd9b6d | 598 | * \brief |
Kojto | 29:c40918cd9b6d | 599 | * \param |
Kojto | 29:c40918cd9b6d | 600 | * \return |
Kojto | 29:c40918cd9b6d | 601 | */ |
Kojto | 20:30b6ed7bf8fd | 602 | int32_t closesocket(int32_t sd); |
Kojto | 29:c40918cd9b6d | 603 | /** |
Kojto | 29:c40918cd9b6d | 604 | * \brief |
Kojto | 29:c40918cd9b6d | 605 | * \param |
Kojto | 29:c40918cd9b6d | 606 | * \return |
Kojto | 29:c40918cd9b6d | 607 | */ |
Kojto | 20:30b6ed7bf8fd | 608 | int32_t listen(int32_t sd, int32_t backlog); |
Kojto | 29:c40918cd9b6d | 609 | /** |
Kojto | 29:c40918cd9b6d | 610 | * \brief |
Kojto | 29:c40918cd9b6d | 611 | * \param |
Kojto | 29:c40918cd9b6d | 612 | * \return |
Kojto | 29:c40918cd9b6d | 613 | */ |
Kojto | 20:30b6ed7bf8fd | 614 | int32_t connect(int32_t sd, const sockaddr *addr, int32_t addrlen); |
Kojto | 29:c40918cd9b6d | 615 | /** |
Kojto | 29:c40918cd9b6d | 616 | * \brief |
Kojto | 29:c40918cd9b6d | 617 | * \param |
Kojto | 29:c40918cd9b6d | 618 | * \return |
Kojto | 29:c40918cd9b6d | 619 | */ |
Kojto | 20:30b6ed7bf8fd | 620 | int32_t select(int32_t nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout); |
Kojto | 29:c40918cd9b6d | 621 | /** |
Kojto | 29:c40918cd9b6d | 622 | * \brief |
Kojto | 29:c40918cd9b6d | 623 | * \param |
Kojto | 29:c40918cd9b6d | 624 | * \return |
Kojto | 29:c40918cd9b6d | 625 | */ |
Kojto | 20:30b6ed7bf8fd | 626 | int32_t getsockopt (int32_t sd, int32_t level, int32_t optname, void *optval, socklen_t *optlen); |
Kojto | 29:c40918cd9b6d | 627 | /** |
Kojto | 29:c40918cd9b6d | 628 | * \brief |
Kojto | 29:c40918cd9b6d | 629 | * \param |
Kojto | 29:c40918cd9b6d | 630 | * \return |
Kojto | 29:c40918cd9b6d | 631 | */ |
Kojto | 20:30b6ed7bf8fd | 632 | 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 | 633 | /** |
Kojto | 29:c40918cd9b6d | 634 | * \brief |
Kojto | 29:c40918cd9b6d | 635 | * \param |
Kojto | 29:c40918cd9b6d | 636 | * \return |
Kojto | 29:c40918cd9b6d | 637 | */ |
Kojto | 20:30b6ed7bf8fd | 638 | 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 | 639 | /** |
Kojto | 29:c40918cd9b6d | 640 | * \brief |
Kojto | 29:c40918cd9b6d | 641 | * \param |
Kojto | 29:c40918cd9b6d | 642 | * \return |
Kojto | 29:c40918cd9b6d | 643 | */ |
Kojto | 20:30b6ed7bf8fd | 644 | int32_t recv(int32_t sd, void *buf, int32_t len, int32_t flags); |
Kojto | 29:c40918cd9b6d | 645 | /** |
Kojto | 29:c40918cd9b6d | 646 | * \brief |
Kojto | 29:c40918cd9b6d | 647 | * \param |
Kojto | 29:c40918cd9b6d | 648 | * \return |
Kojto | 29:c40918cd9b6d | 649 | */ |
Kojto | 20:30b6ed7bf8fd | 650 | int32_t recvfrom(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen); |
Kojto | 29:c40918cd9b6d | 651 | /** |
Kojto | 29:c40918cd9b6d | 652 | * \brief |
Kojto | 29:c40918cd9b6d | 653 | * \param |
Kojto | 29:c40918cd9b6d | 654 | * \return |
Kojto | 29:c40918cd9b6d | 655 | */ |
Kojto | 20:30b6ed7bf8fd | 656 | int32_t send(int32_t sd, const void *buf, int32_t len, int32_t flags); |
Kojto | 29:c40918cd9b6d | 657 | /** |
Kojto | 29:c40918cd9b6d | 658 | * \brief |
Kojto | 29:c40918cd9b6d | 659 | * \param |
Kojto | 29:c40918cd9b6d | 660 | * \return |
Kojto | 29:c40918cd9b6d | 661 | */ |
Kojto | 20:30b6ed7bf8fd | 662 | int32_t sendto(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, socklen_t tolen); |
Kojto | 29:c40918cd9b6d | 663 | /** |
Kojto | 29:c40918cd9b6d | 664 | * \brief |
Kojto | 29:c40918cd9b6d | 665 | * \param |
Kojto | 29:c40918cd9b6d | 666 | * \return |
Kojto | 29:c40918cd9b6d | 667 | */ |
Kojto | 20:30b6ed7bf8fd | 668 | int32_t mdns_advertiser(uint16_t mdns_enabled, uint8_t * device_service_name, uint16_t device_service_name_length); |
Kojto | 20:30b6ed7bf8fd | 669 | #ifndef CC3000_TINY_DRIVER |
Kojto | 33:9e23b24fb4f3 | 670 | /** |
Kojto | 33:9e23b24fb4f3 | 671 | * \brief |
Kojto | 33:9e23b24fb4f3 | 672 | * \param |
Kojto | 33:9e23b24fb4f3 | 673 | * \return |
Kojto | 33:9e23b24fb4f3 | 674 | */ |
Kojto | 20:30b6ed7bf8fd | 675 | int32_t gethostbyname(uint8_t *hostname, uint16_t name_length, uint32_t *out_ip_addr); |
Kojto | 29:c40918cd9b6d | 676 | /** |
Kojto | 29:c40918cd9b6d | 677 | * \brief |
Kojto | 29:c40918cd9b6d | 678 | * \param |
Kojto | 29:c40918cd9b6d | 679 | * \return |
Kojto | 29:c40918cd9b6d | 680 | */ |
Kojto | 20:30b6ed7bf8fd | 681 | int32_t setsockopt(int32_t sd, int32_t level, int32_t optname, const void *optval, socklen_t optlen); |
Kojto | 20:30b6ed7bf8fd | 682 | #endif |
Kojto | 20:30b6ed7bf8fd | 683 | private: |
Kojto | 20:30b6ed7bf8fd | 684 | cc3000_simple_link &_simple_link; |
Kojto | 20:30b6ed7bf8fd | 685 | cc3000_hci &_hci; |
Kojto | 20:30b6ed7bf8fd | 686 | cc3000_event &_event; |
Kojto | 20:30b6ed7bf8fd | 687 | }; |
Kojto | 20:30b6ed7bf8fd | 688 | |
Kojto | 31:7b6e85b68b01 | 689 | /** SPI communication layer |
Kojto | 20:30b6ed7bf8fd | 690 | */ |
Kojto | 20:30b6ed7bf8fd | 691 | class cc3000_spi { |
Kojto | 20:30b6ed7bf8fd | 692 | public: |
Kojto | 33:9e23b24fb4f3 | 693 | /** |
Kojto | 33:9e23b24fb4f3 | 694 | * \brief Ctor |
Kojto | 33:9e23b24fb4f3 | 695 | * \param none |
Kojto | 33:9e23b24fb4f3 | 696 | * \return none |
Kojto | 20:30b6ed7bf8fd | 697 | */ |
Kojto | 20:30b6ed7bf8fd | 698 | cc3000_spi(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port, cc3000_event &event, cc3000_simple_link &simple_link); |
Kojto | 33:9e23b24fb4f3 | 699 | /** |
Kojto | 33:9e23b24fb4f3 | 700 | * \brief Dtor |
Kojto | 33:9e23b24fb4f3 | 701 | * \param none |
Kojto | 33:9e23b24fb4f3 | 702 | * \return none |
Kojto | 20:30b6ed7bf8fd | 703 | */ |
Kojto | 20:30b6ed7bf8fd | 704 | ~cc3000_spi(); |
Kojto | 33:9e23b24fb4f3 | 705 | /** |
Kojto | 33:9e23b24fb4f3 | 706 | * \brief Close SPI - disables IRQ and set received buffer to 0 |
Kojto | 20:30b6ed7bf8fd | 707 | * \param none |
Kojto | 20:30b6ed7bf8fd | 708 | * \return none |
Kojto | 20:30b6ed7bf8fd | 709 | */ |
Kojto | 20:30b6ed7bf8fd | 710 | void close(); |
Kojto | 20:30b6ed7bf8fd | 711 | /** |
Kojto | 20:30b6ed7bf8fd | 712 | * \param none |
Kojto | 20:30b6ed7bf8fd | 713 | * \return none |
Kojto | 20:30b6ed7bf8fd | 714 | */ |
Kojto | 20:30b6ed7bf8fd | 715 | void open(); |
Kojto | 20:30b6ed7bf8fd | 716 | /** |
Kojto | 20:30b6ed7bf8fd | 717 | * \param buffer |
Kojto | 20:30b6ed7bf8fd | 718 | * \param length |
Kojto | 20:30b6ed7bf8fd | 719 | * \return none |
Kojto | 20:30b6ed7bf8fd | 720 | */ |
Kojto | 20:30b6ed7bf8fd | 721 | uint32_t first_write(uint8_t *buffer, uint16_t length); |
Kojto | 20:30b6ed7bf8fd | 722 | /** |
Kojto | 29:c40918cd9b6d | 723 | * \brief |
Kojto | 29:c40918cd9b6d | 724 | * \param |
Kojto | 29:c40918cd9b6d | 725 | * \return |
Kojto | 20:30b6ed7bf8fd | 726 | */ |
Kojto | 20:30b6ed7bf8fd | 727 | uint32_t write(uint8_t *buffer, uint16_t length); |
Kojto | 20:30b6ed7bf8fd | 728 | /** |
Kojto | 29:c40918cd9b6d | 729 | * \brief |
Kojto | 29:c40918cd9b6d | 730 | * \param |
Kojto | 29:c40918cd9b6d | 731 | * \return |
Kojto | 20:30b6ed7bf8fd | 732 | */ |
Kojto | 20:30b6ed7bf8fd | 733 | void write_synchronous(uint8_t *data, uint16_t size); |
Kojto | 20:30b6ed7bf8fd | 734 | /** |
Kojto | 29:c40918cd9b6d | 735 | * \brief |
Kojto | 29:c40918cd9b6d | 736 | * \param |
Kojto | 29:c40918cd9b6d | 737 | * \return |
Kojto | 20:30b6ed7bf8fd | 738 | */ |
Kojto | 20:30b6ed7bf8fd | 739 | void read_synchronous(uint8_t *data, uint16_t size); |
Kojto | 20:30b6ed7bf8fd | 740 | /** |
Kojto | 29:c40918cd9b6d | 741 | * \brief |
Kojto | 29:c40918cd9b6d | 742 | * \param |
Kojto | 29:c40918cd9b6d | 743 | * \return |
Kojto | 20:30b6ed7bf8fd | 744 | */ |
Kojto | 20:30b6ed7bf8fd | 745 | uint32_t read_data_cont(); |
Kojto | 20:30b6ed7bf8fd | 746 | /** |
Kojto | 29:c40918cd9b6d | 747 | * \brief |
Kojto | 29:c40918cd9b6d | 748 | * \param |
Kojto | 29:c40918cd9b6d | 749 | * \return |
Kojto | 20:30b6ed7bf8fd | 750 | */ |
Kojto | 20:30b6ed7bf8fd | 751 | void wlan_irq_enable(); |
Kojto | 20:30b6ed7bf8fd | 752 | /** |
Kojto | 29:c40918cd9b6d | 753 | * \brief |
Kojto | 29:c40918cd9b6d | 754 | * \param |
Kojto | 29:c40918cd9b6d | 755 | * \return |
Kojto | 20:30b6ed7bf8fd | 756 | */ |
Kojto | 20:30b6ed7bf8fd | 757 | void wlan_irq_disable(); |
Kojto | 20:30b6ed7bf8fd | 758 | /** |
Kojto | 29:c40918cd9b6d | 759 | * \brief |
Kojto | 29:c40918cd9b6d | 760 | * \param |
Kojto | 29:c40918cd9b6d | 761 | * \return |
Kojto | 20:30b6ed7bf8fd | 762 | */ |
Kojto | 20:30b6ed7bf8fd | 763 | void wlan_irq_set(uint8_t value); |
Kojto | 20:30b6ed7bf8fd | 764 | /** |
Kojto | 29:c40918cd9b6d | 765 | * \brief |
Kojto | 29:c40918cd9b6d | 766 | * \param |
Kojto | 29:c40918cd9b6d | 767 | * \return |
Kojto | 20:30b6ed7bf8fd | 768 | */ |
Kojto | 20:30b6ed7bf8fd | 769 | uint32_t wlan_irq_read(); |
Kojto | 20:30b6ed7bf8fd | 770 | /** |
Kojto | 29:c40918cd9b6d | 771 | * \brief |
Kojto | 29:c40918cd9b6d | 772 | * \param |
Kojto | 29:c40918cd9b6d | 773 | * \return |
Kojto | 20:30b6ed7bf8fd | 774 | */ |
Kojto | 20:30b6ed7bf8fd | 775 | void WLAN_IRQHandler(); |
Kojto | 20:30b6ed7bf8fd | 776 | /** |
Kojto | 29:c40918cd9b6d | 777 | * \brief |
Kojto | 29:c40918cd9b6d | 778 | * \param |
Kojto | 29:c40918cd9b6d | 779 | * \return |
Kojto | 20:30b6ed7bf8fd | 780 | */ |
Kojto | 20:30b6ed7bf8fd | 781 | void write_wlan_en(uint8_t value); |
Kojto | 20:30b6ed7bf8fd | 782 | private: |
Kojto | 20:30b6ed7bf8fd | 783 | tSpiInfo _spi_info; |
Kojto | 20:30b6ed7bf8fd | 784 | InterruptIn _wlan_irq; |
Kojto | 20:30b6ed7bf8fd | 785 | DigitalOut _wlan_en; |
Kojto | 20:30b6ed7bf8fd | 786 | DigitalOut _wlan_cs; |
Kojto | 20:30b6ed7bf8fd | 787 | SPI _wlan_spi; |
Kojto | 20:30b6ed7bf8fd | 788 | IRQn_Type _irq_port; |
Kojto | 20:30b6ed7bf8fd | 789 | pFunctionPointer_t _function_pointer; |
Kojto | 20:30b6ed7bf8fd | 790 | cc3000_event &_event; |
Kojto | 20:30b6ed7bf8fd | 791 | cc3000_simple_link &_simple_link; |
Kojto | 20:30b6ed7bf8fd | 792 | }; |
Kojto | 20:30b6ed7bf8fd | 793 | |
Kojto | 31:7b6e85b68b01 | 794 | /** HCI layer |
Kojto | 31:7b6e85b68b01 | 795 | */ |
Kojto | 20:30b6ed7bf8fd | 796 | class cc3000_hci { |
Kojto | 20:30b6ed7bf8fd | 797 | public: |
Kojto | 29:c40918cd9b6d | 798 | /** |
Kojto | 29:c40918cd9b6d | 799 | * \brief Ctor |
Kojto | 29:c40918cd9b6d | 800 | * \param spi Reference to spi object. |
Kojto | 29:c40918cd9b6d | 801 | * \return none |
Kojto | 29:c40918cd9b6d | 802 | */ |
Kojto | 20:30b6ed7bf8fd | 803 | cc3000_hci(cc3000_spi &spi); |
Kojto | 29:c40918cd9b6d | 804 | /** |
Kojto | 29:c40918cd9b6d | 805 | * \brief Dtor |
Kojto | 29:c40918cd9b6d | 806 | * \param none |
Kojto | 29:c40918cd9b6d | 807 | * \return none |
Kojto | 29:c40918cd9b6d | 808 | */ |
Kojto | 20:30b6ed7bf8fd | 809 | ~cc3000_hci(); |
Kojto | 29:c40918cd9b6d | 810 | /** |
Kojto | 29:c40918cd9b6d | 811 | * \brief Initiate an HCI command. |
Kojto | 29:c40918cd9b6d | 812 | * \param op_code command operation code |
Kojto | 29:c40918cd9b6d | 813 | * \param buffer pointer to the command's arguments buffer |
Kojto | 29:c40918cd9b6d | 814 | * \param length length of the arguments |
Kojto | 29:c40918cd9b6d | 815 | * \return ??? |
Kojto | 29:c40918cd9b6d | 816 | */ |
Kojto | 20:30b6ed7bf8fd | 817 | uint16_t command_send(uint16_t op_code, uint8_t *buffer, uint8_t length); |
Kojto | 29:c40918cd9b6d | 818 | /** |
Kojto | 29:c40918cd9b6d | 819 | * \brief Initiate an HCI data write operation |
Kojto | 29:c40918cd9b6d | 820 | * \param op_code command operation code |
Kojto | 29:c40918cd9b6d | 821 | * \param args pointer to the command's arguments buffer |
Kojto | 29:c40918cd9b6d | 822 | * \param arg_length length of the arguments |
Kojto | 29:c40918cd9b6d | 823 | * \param data_length length od data |
Kojto | 29:c40918cd9b6d | 824 | * \param tail pointer to the data buffer |
Kojto | 29:c40918cd9b6d | 825 | * \param tail_length buffer length |
Kojto | 29:c40918cd9b6d | 826 | * \return ??? |
Kojto | 29:c40918cd9b6d | 827 | */ |
Kojto | 20:30b6ed7bf8fd | 828 | uint32_t data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length, |
Kojto | 20:30b6ed7bf8fd | 829 | uint16_t data_length, const uint8_t *tail, uint16_t tail_length); |
Kojto | 29:c40918cd9b6d | 830 | /** |
Kojto | 29:c40918cd9b6d | 831 | * \brief Prepare HCI header and initiate an HCI data write operation. |
Kojto | 29:c40918cd9b6d | 832 | * \param op_code command operation code |
Kojto | 29:c40918cd9b6d | 833 | * \param buffer pointer to the data buffer |
Kojto | 29:c40918cd9b6d | 834 | * \param arg_length arguments length |
Kojto | 29:c40918cd9b6d | 835 | * \param data_length data length |
Kojto | 29:c40918cd9b6d | 836 | * \return none |
Kojto | 29:c40918cd9b6d | 837 | */ |
Kojto | 20:30b6ed7bf8fd | 838 | void data_command_send(uint16_t op_code, uint8_t *buffer, uint8_t arg_length, |
Kojto | 20:30b6ed7bf8fd | 839 | uint16_t data_length); |
Kojto | 29:c40918cd9b6d | 840 | /** |
Kojto | 29:c40918cd9b6d | 841 | * \brief Prepare HCI header and initiate an HCI patch write operation. |
Kojto | 29:c40918cd9b6d | 842 | * \param op_code command operation code |
Kojto | 29:c40918cd9b6d | 843 | * \param buffer pointer to the command's arguments buffer |
Kojto | 29:c40918cd9b6d | 844 | * \param patch pointer to patch content buffer |
Kojto | 29:c40918cd9b6d | 845 | * \param data_length data length |
Kojto | 29:c40918cd9b6d | 846 | * \return none |
Kojto | 29:c40918cd9b6d | 847 | */ |
Kojto | 20:30b6ed7bf8fd | 848 | void patch_send(uint8_t op_code, uint8_t *buffer, uint8_t *patch, uint16_t data_length); |
Kojto | 20:30b6ed7bf8fd | 849 | private: |
Kojto | 20:30b6ed7bf8fd | 850 | cc3000_spi &_spi; |
Kojto | 20:30b6ed7bf8fd | 851 | }; |
Kojto | 20:30b6ed7bf8fd | 852 | |
Kojto | 31:7b6e85b68b01 | 853 | /** NVMEM layer |
Kojto | 31:7b6e85b68b01 | 854 | */ |
Kojto | 20:30b6ed7bf8fd | 855 | class cc3000_nvmem { |
Kojto | 20:30b6ed7bf8fd | 856 | public: |
Kojto | 29:c40918cd9b6d | 857 | /** |
Kojto | 29:c40918cd9b6d | 858 | * \brief Ctor |
Kojto | 29:c40918cd9b6d | 859 | * \param hci Reference to hci object. |
Kojto | 29:c40918cd9b6d | 860 | * \param event Reference to event object. |
Kojto | 29:c40918cd9b6d | 861 | * \param simple_link Reference to simple link object. |
Kojto | 29:c40918cd9b6d | 862 | * \return none |
Kojto | 29:c40918cd9b6d | 863 | */ |
Kojto | 29:c40918cd9b6d | 864 | cc3000_nvmem(cc3000_hci &hci, cc3000_event &event, cc3000_simple_link &simple_link); |
Kojto | 29:c40918cd9b6d | 865 | /** |
Kojto | 29:c40918cd9b6d | 866 | * \brief Dtor |
Kojto | 29:c40918cd9b6d | 867 | * \param none |
Kojto | 29:c40918cd9b6d | 868 | * \return none |
Kojto | 29:c40918cd9b6d | 869 | */ |
Kojto | 20:30b6ed7bf8fd | 870 | ~cc3000_nvmem(); |
Kojto | 29:c40918cd9b6d | 871 | /** |
Kojto | 29:c40918cd9b6d | 872 | * \brief Reads data from the file referred by the file_id parameter. |
Kojto | 29:c40918cd9b6d | 873 | * Reads data from file offset till length. Err if the file can't be used, |
Kojto | 29:c40918cd9b6d | 874 | * is invalid, or if the read is out of bounds. |
Kojto | 29:c40918cd9b6d | 875 | * \param file_id nvmem file id. |
Kojto | 29:c40918cd9b6d | 876 | * \param length number of bytes to read. |
Kojto | 29:c40918cd9b6d | 877 | * \param offset offset in file from where to read. |
Kojto | 29:c40918cd9b6d | 878 | * \param buff output buffer pointer. |
Kojto | 29:c40918cd9b6d | 879 | * \return |
Kojto | 29:c40918cd9b6d | 880 | * Number of bytes read, otherwise error. |
Kojto | 29:c40918cd9b6d | 881 | */ |
Kojto | 20:30b6ed7bf8fd | 882 | int32_t read(uint32_t file_id, uint32_t length, uint32_t offset, uint8_t *buff); |
Kojto | 29:c40918cd9b6d | 883 | /** |
Kojto | 29:c40918cd9b6d | 884 | * \brief Write data to nvmem. |
Kojto | 29:c40918cd9b6d | 885 | * \param file_id Nvmem file id |
Kojto | 29:c40918cd9b6d | 886 | * \param length number of bytes to write |
Kojto | 29:c40918cd9b6d | 887 | * \param entry_offset offset in file to start write operation from |
Kojto | 29:c40918cd9b6d | 888 | * \param buff data to write |
Kojto | 29:c40918cd9b6d | 889 | * \return |
Kojto | 29:c40918cd9b6d | 890 | * On success 0, error otherwise. |
Kojto | 29:c40918cd9b6d | 891 | */ |
Kojto | 20:30b6ed7bf8fd | 892 | int32_t write(uint32_t file_id, uint32_t length, uint32_t entry_offset, uint8_t *buff); |
Kojto | 29:c40918cd9b6d | 893 | /** |
Kojto | 29:c40918cd9b6d | 894 | * \brief Write MAC address to EEPROM. |
Kojto | 29:c40918cd9b6d | 895 | * \param mac Mac address to be set |
Kojto | 29:c40918cd9b6d | 896 | * \return |
Kojto | 29:c40918cd9b6d | 897 | * On success 0, error otherwise. |
Kojto | 29:c40918cd9b6d | 898 | */ |
Kojto | 20:30b6ed7bf8fd | 899 | uint8_t set_mac_address(uint8_t *mac); |
Kojto | 29:c40918cd9b6d | 900 | /** |
Kojto | 29:c40918cd9b6d | 901 | * \brief Read MAC address from EEPROM. |
Kojto | 29:c40918cd9b6d | 902 | * \param mac Mac address |
Kojto | 29:c40918cd9b6d | 903 | * \return |
Kojto | 33:9e23b24fb4f3 | 904 | * On success 0, error otherwise. |
Kojto | 29:c40918cd9b6d | 905 | */ |
Kojto | 20:30b6ed7bf8fd | 906 | uint8_t get_mac_address(uint8_t *mac); |
Kojto | 29:c40918cd9b6d | 907 | /** |
Kojto | 29:c40918cd9b6d | 908 | * \brief Program a patch to a specific file ID. The SP data is assumed to be organized in 2-dimensional. |
Kojto | 29:c40918cd9b6d | 909 | * Each line is SP_PORTION_SIZE bytes long. |
Kojto | 29:c40918cd9b6d | 910 | * \param file_id nvmem file id/ |
Kojto | 29:c40918cd9b6d | 911 | * \param length number of bytes to write |
Kojto | 29:c40918cd9b6d | 912 | * \param data SP data to write |
Kojto | 29:c40918cd9b6d | 913 | * \return |
Kojto | 29:c40918cd9b6d | 914 | * On success 0, error otherwise. |
Kojto | 29:c40918cd9b6d | 915 | */ |
Kojto | 20:30b6ed7bf8fd | 916 | uint8_t write_patch(uint32_t file_id, uint32_t length, const uint8_t *data); |
Kojto | 29:c40918cd9b6d | 917 | /** |
Kojto | 29:c40918cd9b6d | 918 | * \brief Create new file entry and allocate space on the NVMEM. Applies only to user files. |
Kojto | 29:c40918cd9b6d | 919 | * \param file_id nvmem file Id |
Kojto | 29:c40918cd9b6d | 920 | * \param new_len entry ulLength |
Kojto | 29:c40918cd9b6d | 921 | * \return |
Kojto | 29:c40918cd9b6d | 922 | */ |
Kojto | 20:30b6ed7bf8fd | 923 | int32_t create_entry(uint32_t file_id, uint32_t new_len); |
Kojto | 20:30b6ed7bf8fd | 924 | #ifndef CC3000_TINY_DRIVER |
Kojto | 29:c40918cd9b6d | 925 | /** |
Kojto | 29:c40918cd9b6d | 926 | * \brief Read patch version. read package version (WiFi FW patch, river-supplicant-NS patch, |
Kojto | 29:c40918cd9b6d | 927 | * bootloader patch) |
Kojto | 29:c40918cd9b6d | 928 | * \param patch_ver First number indicates package ID and the second number indicates |
Kojto | 29:c40918cd9b6d | 929 | * package build number |
Kojto | 29:c40918cd9b6d | 930 | * \return |
Kojto | 29:c40918cd9b6d | 931 | * On success 0, error otherwise. |
Kojto | 29:c40918cd9b6d | 932 | */ |
Kojto | 20:30b6ed7bf8fd | 933 | uint8_t read_sp_version(uint8_t* patch_ver); |
Kojto | 20:30b6ed7bf8fd | 934 | #endif |
Kojto | 20:30b6ed7bf8fd | 935 | private: |
Kojto | 20:30b6ed7bf8fd | 936 | cc3000_hci &_hci; |
Kojto | 20:30b6ed7bf8fd | 937 | cc3000_event &_event; |
Kojto | 20:30b6ed7bf8fd | 938 | cc3000_simple_link &_simple_link; |
Kojto | 20:30b6ed7bf8fd | 939 | }; |
Kojto | 20:30b6ed7bf8fd | 940 | |
Kojto | 31:7b6e85b68b01 | 941 | /** WLAN layer |
Kojto | 31:7b6e85b68b01 | 942 | */ |
Kojto | 20:30b6ed7bf8fd | 943 | class cc3000_wlan { |
Kojto | 20:30b6ed7bf8fd | 944 | public: |
Kojto | 29:c40918cd9b6d | 945 | /** |
Kojto | 29:c40918cd9b6d | 946 | * \brief Ctor |
Kojto | 29:c40918cd9b6d | 947 | * \param simple_link Reference to simple link object. |
Kojto | 29:c40918cd9b6d | 948 | * \param event Reference to event object. |
Kojto | 29:c40918cd9b6d | 949 | * \param spi Reference to spi object. |
Kojto | 29:c40918cd9b6d | 950 | * \param hci Reference to hci object. |
Kojto | 29:c40918cd9b6d | 951 | * \return none |
Kojto | 29:c40918cd9b6d | 952 | */ |
Kojto | 20:30b6ed7bf8fd | 953 | cc3000_wlan(cc3000_simple_link &simple_link, cc3000_event &event, cc3000_spi &spi, cc3000_hci &hci); |
Kojto | 29:c40918cd9b6d | 954 | /** |
Kojto | 29:c40918cd9b6d | 955 | * \brief Dtor |
Kojto | 29:c40918cd9b6d | 956 | * \param none |
Kojto | 29:c40918cd9b6d | 957 | * \return none |
Kojto | 29:c40918cd9b6d | 958 | */ |
Kojto | 20:30b6ed7bf8fd | 959 | ~cc3000_wlan(); |
Kojto | 29:c40918cd9b6d | 960 | /** |
Kojto | 29:c40918cd9b6d | 961 | * \brief Send SIMPLE LINK START to cc3000. |
Kojto | 29:c40918cd9b6d | 962 | * \param patches_available_host Flag to indicate if patches are available. |
Kojto | 20:30b6ed7bf8fd | 963 | * \return none |
Kojto | 20:30b6ed7bf8fd | 964 | */ |
Kojto | 20:30b6ed7bf8fd | 965 | void simpleLink_init_start(uint16_t patches_available_host); |
Kojto | 29:c40918cd9b6d | 966 | /** |
Kojto | 29:c40918cd9b6d | 967 | * \brief Start wlan device. Blocking call until init is completed. |
Kojto | 29:c40918cd9b6d | 968 | * \param patches_available_host Flag to indicate if patches are available. |
Kojto | 20:30b6ed7bf8fd | 969 | * \return none |
Kojto | 20:30b6ed7bf8fd | 970 | */ |
Kojto | 20:30b6ed7bf8fd | 971 | void start(uint16_t patches_available_host); |
Kojto | 29:c40918cd9b6d | 972 | /** |
Kojto | 29:c40918cd9b6d | 973 | * \brief Stop wlan device |
Kojto | 20:30b6ed7bf8fd | 974 | * \param none |
Kojto | 20:30b6ed7bf8fd | 975 | * \return none |
Kojto | 20:30b6ed7bf8fd | 976 | */ |
Kojto | 20:30b6ed7bf8fd | 977 | void stop(void); |
Kojto | 20:30b6ed7bf8fd | 978 | #ifndef CC3000_TINY_DRIVER |
Kojto | 29:c40918cd9b6d | 979 | /** |
Kojto | 29:c40918cd9b6d | 980 | * \brief Connect to AP. |
Kojto | 29:c40918cd9b6d | 981 | * \param sec_type Security option. |
Kojto | 29:c40918cd9b6d | 982 | * \param ssid up to 32 bytes, ASCII SSID |
Kojto | 29:c40918cd9b6d | 983 | * \param ssid_length length of SSID |
Kojto | 29:c40918cd9b6d | 984 | * \param b_ssid 6 bytes specified the AP bssid |
Kojto | 29:c40918cd9b6d | 985 | * \param key up to 16 bytes specified the AP security key |
Kojto | 29:c40918cd9b6d | 986 | * \param key_len key length |
Kojto | 29:c40918cd9b6d | 987 | * \return |
Kojto | 29:c40918cd9b6d | 988 | * On success, zero is returned. On error, negative is returned. |
Kojto | 29:c40918cd9b6d | 989 | */ |
Kojto | 20:30b6ed7bf8fd | 990 | 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 | 991 | /** |
Kojto | 29:c40918cd9b6d | 992 | * \brief Add profile. Up to 7 profiles are supported. |
Kojto | 29:c40918cd9b6d | 993 | * \param sec_type Security option. |
Kojto | 29:c40918cd9b6d | 994 | * \param ssid Up to 32 bytes, ASCII SSID |
Kojto | 29:c40918cd9b6d | 995 | * \param ssid_length Length of SSID |
Kojto | 29:c40918cd9b6d | 996 | * \param b_ssid 6 bytes specified the AP bssid |
Kojto | 29:c40918cd9b6d | 997 | * \param priority Up to 16 bytes specified the AP security key |
Kojto | 29:c40918cd9b6d | 998 | * \param pairwise_cipher_or_tx_key_len Key length |
Kojto | 29:c40918cd9b6d | 999 | * \param group_cipher_tx_key_index Key length for WEP security |
Kojto | 29:c40918cd9b6d | 1000 | * \param key_mgmt KEY management |
Kojto | 29:c40918cd9b6d | 1001 | * \param pf_or_key Security key |
Kojto | 29:c40918cd9b6d | 1002 | * \param pass_phrase_length Security key length for WPA\WPA2 |
Kojto | 29:c40918cd9b6d | 1003 | * \return |
Kojto | 29:c40918cd9b6d | 1004 | * On success, zero is returned. On error, negative is returned. |
Kojto | 29:c40918cd9b6d | 1005 | */ |
Kojto | 20:30b6ed7bf8fd | 1006 | 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 | 1007 | uint32_t key_mgmt, uint8_t* pf_or_key, uint32_t pass_phrase_length); |
Kojto | 29:c40918cd9b6d | 1008 | /** |
Kojto | 29:c40918cd9b6d | 1009 | * \brief Gets entry from scan result table. The scan results are returned |
Kojto | 29:c40918cd9b6d | 1010 | * one by one, and each entry represents a single AP found in the area. |
Kojto | 29:c40918cd9b6d | 1011 | * \param scan_timeout Not supported yet |
Kojto | 29:c40918cd9b6d | 1012 | * \param results Scan result |
Kojto | 29:c40918cd9b6d | 1013 | * \return |
Kojto | 29:c40918cd9b6d | 1014 | * On success, zero is returned. On error, -1 is returned |
Kojto | 29:c40918cd9b6d | 1015 | */ |
Kojto | 20:30b6ed7bf8fd | 1016 | int32_t ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results); |
Kojto | 29:c40918cd9b6d | 1017 | /** |
Kojto | 29:c40918cd9b6d | 1018 | * \brief Start and stop scan procedure. Set scan parameters. |
Kojto | 29:c40918cd9b6d | 1019 | * \param enable Start/stop application scan |
Kojto | 29:c40918cd9b6d | 1020 | * \param min_dwell_time Minimum dwell time value to be used for each channel, in ms. (Default: 20) |
Kojto | 29:c40918cd9b6d | 1021 | * \param max_dwell_time Maximum dwell time value to be used for each channel, in ms. (Default: 30) |
Kojto | 29:c40918cd9b6d | 1022 | * \param num_probe_requests Max probe request between dwell time. (Default:2) |
Kojto | 29:c40918cd9b6d | 1023 | * \param channel_mask Bitwise, up to 13 channels (0x1fff). |
Kojto | 29:c40918cd9b6d | 1024 | * \param rssi_threshold RSSI threshold. Saved: yes (Default: -80) |
Kojto | 29:c40918cd9b6d | 1025 | * \param snr_threshold NSR threshold. Saved: yes (Default: 0) |
Kojto | 29:c40918cd9b6d | 1026 | * \param default_tx_power probe Tx power. Saved: yes (Default: 205) |
Kojto | 29:c40918cd9b6d | 1027 | * \param interval_list Pointer to array with 16 entries (16 channels) |
Kojto | 29:c40918cd9b6d | 1028 | * \return |
Kojto | 29:c40918cd9b6d | 1029 | * On success, zero is returned. On error, -1 is returned. |
Kojto | 29:c40918cd9b6d | 1030 | */ |
Kojto | 20:30b6ed7bf8fd | 1031 | 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 | 1032 | uint32_t channel_mask, int32_t rssi_threshold, uint32_t snr_threshold, uint32_t default_tx_power, uint32_t *interval_list); |
Kojto | 29:c40918cd9b6d | 1033 | /** |
Kojto | 29:c40918cd9b6d | 1034 | * \brief Get wlan status: disconnected, scanning, connecting or connected |
Kojto | 29:c40918cd9b6d | 1035 | * \param none |
Kojto | 29:c40918cd9b6d | 1036 | * \return |
Kojto | 29:c40918cd9b6d | 1037 | * WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, STATUS_CONNECTING or WLAN_STATUS_CONNECTED |
Kojto | 29:c40918cd9b6d | 1038 | */ |
Kojto | 20:30b6ed7bf8fd | 1039 | int32_t ioctl_statusget(void); |
Kojto | 20:30b6ed7bf8fd | 1040 | #else |
Kojto | 29:c40918cd9b6d | 1041 | /** |
Kojto | 29:c40918cd9b6d | 1042 | * \brief Connect to AP |
Kojto | 29:c40918cd9b6d | 1043 | * \param ssid Up to 32 bytes and is ASCII SSID of the AP |
Kojto | 29:c40918cd9b6d | 1044 | * \param ssid_length Length of the SSID |
Kojto | 29:c40918cd9b6d | 1045 | * \return |
Kojto | 29:c40918cd9b6d | 1046 | * On success, zero is returned. On error, negative is returned. |
Kojto | 29:c40918cd9b6d | 1047 | */ |
Kojto | 20:30b6ed7bf8fd | 1048 | int32_t connect(const uint8_t *ssid, int32_t ssid_length); |
Kojto | 29:c40918cd9b6d | 1049 | /** |
Kojto | 29:c40918cd9b6d | 1050 | * \brief When auto start is enabled, the device connects to station from the profiles table. |
Kojto | 29:c40918cd9b6d | 1051 | * If several profiles configured the device choose the highest priority profile. |
Kojto | 29:c40918cd9b6d | 1052 | * \param sec_type WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2 |
Kojto | 29:c40918cd9b6d | 1053 | * \param ssid SSID up to 32 bytes |
Kojto | 29:c40918cd9b6d | 1054 | * \param ssid_length SSID length |
Kojto | 29:c40918cd9b6d | 1055 | * \param b_ssid bssid 6 bytes |
Kojto | 29:c40918cd9b6d | 1056 | * \param priority Profile priority. Lowest priority:0. |
Kojto | 29:c40918cd9b6d | 1057 | * \param pairwise_cipher_or_tx_key_len Key length for WEP security |
Kojto | 29:c40918cd9b6d | 1058 | * \param group_cipher_tx_key_index Key index |
Kojto | 29:c40918cd9b6d | 1059 | * \param key_mgmt KEY management |
Kojto | 29:c40918cd9b6d | 1060 | * \param pf_or_key Security key |
Kojto | 29:c40918cd9b6d | 1061 | * \param pass_phrase_length Security key length for WPA\WPA2 |
Kojto | 29:c40918cd9b6d | 1062 | * \return |
Kojto | 29:c40918cd9b6d | 1063 | * On success, zero is returned. On error, -1 is returned |
Kojto | 29:c40918cd9b6d | 1064 | */ |
Kojto | 20:30b6ed7bf8fd | 1065 | 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 | 1066 | uint32_t pairwise_cipher_or_tx_key_len, uint32_t group_cipher_tx_key_index, uint32_t key_mgmt, |
Kojto | 20:30b6ed7bf8fd | 1067 | uint8_t* pf_or_key, uint32_t pass_phrase_length); |
Kojto | 20:30b6ed7bf8fd | 1068 | #endif |
Kojto | 20:30b6ed7bf8fd | 1069 | #ifndef CC3000_UNENCRYPTED_SMART_CONFIG |
Kojto | 29:c40918cd9b6d | 1070 | /** |
Kojto | 29:c40918cd9b6d | 1071 | * \brief Process the acquired data and store it as a profile. |
Kojto | 29:c40918cd9b6d | 1072 | * \param none |
Kojto | 29:c40918cd9b6d | 1073 | * \return |
Kojto | 29:c40918cd9b6d | 1074 | * On success, zero is returned. On error, -1 is returned. |
Kojto | 29:c40918cd9b6d | 1075 | */ |
Kojto | 20:30b6ed7bf8fd | 1076 | int32_t smart_config_process(void); |
Kojto | 20:30b6ed7bf8fd | 1077 | #endif |
Kojto | 29:c40918cd9b6d | 1078 | /** |
Kojto | 29:c40918cd9b6d | 1079 | * \brief Disconnect connection from AP. |
Kojto | 29:c40918cd9b6d | 1080 | * \param none |
Kojto | 29:c40918cd9b6d | 1081 | * \return |
Kojto | 29:c40918cd9b6d | 1082 | * 0 if disconnected done, other CC3000 already disconnected. |
Kojto | 29:c40918cd9b6d | 1083 | */ |
Kojto | 20:30b6ed7bf8fd | 1084 | int32_t disconnect(); |
Kojto | 29:c40918cd9b6d | 1085 | /** |
Kojto | 29:c40918cd9b6d | 1086 | * \brief When auto is enabled, the device tries to connect according the following policy: |
Kojto | 29:c40918cd9b6d | 1087 | * 1) If fast connect is enabled and last connection is valid, the device will try to |
Kojto | 29:c40918cd9b6d | 1088 | * connect to it without the scanning procedure (fast). The last connection will be |
Kojto | 29:c40918cd9b6d | 1089 | * marked as invalid, due to adding/removing profile. |
Kojto | 29:c40918cd9b6d | 1090 | * 2) If profile exists, the device will try to connect it (Up to seven profiles). |
Kojto | 29:c40918cd9b6d | 1091 | * 3) If fast and profiles are not found, and open mode is enabled, the device |
Kojto | 29:c40918cd9b6d | 1092 | * will try to connect to any AP. |
Kojto | 29:c40918cd9b6d | 1093 | * Note that the policy settings are stored in the CC3000 NVMEM. |
Kojto | 29:c40918cd9b6d | 1094 | * \param should_connect_to_open_ap Enable(1), disable(0) connect to any available AP. |
Kojto | 29:c40918cd9b6d | 1095 | * \param use_fast_connect Enable(1), disable(0). if enabled, tries to |
Kojto | 29:c40918cd9b6d | 1096 | * connect to the last connected AP. |
Kojto | 29:c40918cd9b6d | 1097 | * \param use_profiles Enable(1), disable(0) auto connect after reset. |
Kojto | 29:c40918cd9b6d | 1098 | * and periodically reconnect if needed. |
Kojto | 29:c40918cd9b6d | 1099 | * \return |
Kojto | 29:c40918cd9b6d | 1100 | * On success, zero is returned. On error, -1 is returned |
Kojto | 29:c40918cd9b6d | 1101 | */ |
Kojto | 20:30b6ed7bf8fd | 1102 | 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 | 1103 | /** |
Kojto | 29:c40918cd9b6d | 1104 | * \brief Delete WLAN profile |
Kojto | 29:c40918cd9b6d | 1105 | * \param index Number of profile to delete |
Kojto | 29:c40918cd9b6d | 1106 | * \return |
Kojto | 29:c40918cd9b6d | 1107 | * On success, zero is returned. On error, -1 is returned |
Kojto | 29:c40918cd9b6d | 1108 | */ |
Kojto | 20:30b6ed7bf8fd | 1109 | int32_t ioctl_del_profile(uint32_t index); |
Kojto | 29:c40918cd9b6d | 1110 | /** |
Kojto | 29:c40918cd9b6d | 1111 | * \brief Mask event according to bit mask. In case that event is |
Kojto | 29:c40918cd9b6d | 1112 | * masked (1), the device will not send the masked event to host. |
Kojto | 29:c40918cd9b6d | 1113 | * \param mask event mask |
Kojto | 29:c40918cd9b6d | 1114 | * \return |
Kojto | 29:c40918cd9b6d | 1115 | * On success, zero is returned. On error, -1 is returned |
Kojto | 29:c40918cd9b6d | 1116 | */ |
Kojto | 20:30b6ed7bf8fd | 1117 | int32_t set_event_mask(uint32_t mask); |
Kojto | 29:c40918cd9b6d | 1118 | /** |
Kojto | 29:c40918cd9b6d | 1119 | * \brief Start to acquire device profile. The device acquire its own |
Kojto | 29:c40918cd9b6d | 1120 | * profile, if profile message is found. |
Kojto | 29:c40918cd9b6d | 1121 | * \param encrypted_flag Indicates whether the information is encrypted |
Kojto | 29:c40918cd9b6d | 1122 | * \return |
Kojto | 29:c40918cd9b6d | 1123 | * On success, zero is returned. On error, -1 is returned. |
Kojto | 29:c40918cd9b6d | 1124 | */ |
Kojto | 20:30b6ed7bf8fd | 1125 | int32_t smart_config_start(uint32_t encrypted_flag); |
Kojto | 29:c40918cd9b6d | 1126 | /** |
Kojto | 29:c40918cd9b6d | 1127 | * \brief Stop the acquire profile procedure. |
Kojto | 29:c40918cd9b6d | 1128 | * \param none |
Kojto | 29:c40918cd9b6d | 1129 | * \return |
Kojto | 29:c40918cd9b6d | 1130 | * On success, zero is returned. On error, -1 is returned |
Kojto | 29:c40918cd9b6d | 1131 | */ |
Kojto | 20:30b6ed7bf8fd | 1132 | int32_t smart_config_stop(void); |
Kojto | 29:c40918cd9b6d | 1133 | /** |
Kojto | 29:c40918cd9b6d | 1134 | * \brief Configure station ssid prefix. |
Kojto | 29:c40918cd9b6d | 1135 | * \param new_prefix 3 bytes identify the SSID prefix for the Smart Config. |
Kojto | 29:c40918cd9b6d | 1136 | * \return |
Kojto | 29:c40918cd9b6d | 1137 | * On success, zero is returned. On error, -1 is returned. |
Kojto | 29:c40918cd9b6d | 1138 | */ |
Kojto | 20:30b6ed7bf8fd | 1139 | int32_t smart_config_set_prefix(uint8_t *new_prefix); |
Kojto | 20:30b6ed7bf8fd | 1140 | private: |
Kojto | 20:30b6ed7bf8fd | 1141 | cc3000_simple_link &_simple_link; |
Kojto | 20:30b6ed7bf8fd | 1142 | cc3000_event &_event; |
Kojto | 20:30b6ed7bf8fd | 1143 | cc3000_spi &_spi; |
Kojto | 20:30b6ed7bf8fd | 1144 | cc3000_hci &_hci; |
Kojto | 20:30b6ed7bf8fd | 1145 | }; |
Kojto | 20:30b6ed7bf8fd | 1146 | |
Kojto | 31:7b6e85b68b01 | 1147 | /** The main object of cc3000 implementation |
Kojto | 20:30b6ed7bf8fd | 1148 | */ |
Kojto | 20:30b6ed7bf8fd | 1149 | class cc3000 { |
Kojto | 20:30b6ed7bf8fd | 1150 | public: |
Kojto | 29:c40918cd9b6d | 1151 | /** status structure */ |
Kojto | 20:30b6ed7bf8fd | 1152 | typedef struct { |
Kojto | 29:c40918cd9b6d | 1153 | bool dhcp; |
Kojto | 29:c40918cd9b6d | 1154 | bool connected; |
Kojto | 20:30b6ed7bf8fd | 1155 | uint8_t socket; |
Kojto | 29:c40918cd9b6d | 1156 | bool smart_config_complete; |
Kojto | 29:c40918cd9b6d | 1157 | bool stop_smart_config; |
Kojto | 29:c40918cd9b6d | 1158 | bool dhcp_configured; |
Kojto | 29:c40918cd9b6d | 1159 | bool ok_to_shut_down; |
Kojto | 20:30b6ed7bf8fd | 1160 | } tStatus; |
Kojto | 29:c40918cd9b6d | 1161 | /** |
Kojto | 29:c40918cd9b6d | 1162 | * \brief Ctor. |
Kojto | 20:30b6ed7bf8fd | 1163 | * \param cc3000_irq IRQ pin |
Kojto | 20:30b6ed7bf8fd | 1164 | * \param cc3000_en Enable pin |
Kojto | 20:30b6ed7bf8fd | 1165 | * \param cc3000_cs Chip select pin |
Kojto | 20:30b6ed7bf8fd | 1166 | * \param cc3000_spi SPI interface |
Kojto | 20:30b6ed7bf8fd | 1167 | * \param irq_port IRQ pin's port |
Kojto | 20:30b6ed7bf8fd | 1168 | */ |
Kojto | 20:30b6ed7bf8fd | 1169 | cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port); |
Kojto | 29:c40918cd9b6d | 1170 | /** |
Kojto | 29:c40918cd9b6d | 1171 | * \brief Dtor. |
Kojto | 20:30b6ed7bf8fd | 1172 | */ |
Kojto | 20:30b6ed7bf8fd | 1173 | ~cc3000(); |
Kojto | 29:c40918cd9b6d | 1174 | /** |
Kojto | 29:c40918cd9b6d | 1175 | * \brief Initiate cc3000. It starts the wlan communication and deletes profiles. |
Kojto | 20:30b6ed7bf8fd | 1176 | * \param patch Patch |
Kojto | 20:30b6ed7bf8fd | 1177 | */ |
Kojto | 20:30b6ed7bf8fd | 1178 | void start(uint8_t patch); |
Kojto | 29:c40918cd9b6d | 1179 | /** |
Kojto | 29:c40918cd9b6d | 1180 | * \brief Stops the wlan communication. |
Kojto | 20:30b6ed7bf8fd | 1181 | */ |
Kojto | 20:30b6ed7bf8fd | 1182 | void stop(); |
Kojto | 29:c40918cd9b6d | 1183 | /** |
Kojto | 29:c40918cd9b6d | 1184 | * \brief Restarts the wlan communication. |
Kojto | 20:30b6ed7bf8fd | 1185 | */ |
Kojto | 20:30b6ed7bf8fd | 1186 | void restart(uint8_t patch); |
Kojto | 29:c40918cd9b6d | 1187 | /** |
Kojto | 29:c40918cd9b6d | 1188 | * \brief Disconnect wlan device |
Kojto | 20:30b6ed7bf8fd | 1189 | * |
Kojto | 20:30b6ed7bf8fd | 1190 | */ |
Kojto | 20:30b6ed7bf8fd | 1191 | bool disconnect(void); |
Kojto | 29:c40918cd9b6d | 1192 | /** |
Kojto | 29:c40918cd9b6d | 1193 | * \brief Callback which is called from the event class. This updates status of cc3000. |
Kojto | 20:30b6ed7bf8fd | 1194 | * \param event_type Type of the event |
Kojto | 20:30b6ed7bf8fd | 1195 | * \param data Pointer to data |
Kojto | 20:30b6ed7bf8fd | 1196 | * \param length Length of data |
Kojto | 20:30b6ed7bf8fd | 1197 | * \return none |
Kojto | 20:30b6ed7bf8fd | 1198 | */ |
Kojto | 20:30b6ed7bf8fd | 1199 | void usync_callback(int32_t event_type, uint8_t *data, uint8_t length); |
Kojto | 29:c40918cd9b6d | 1200 | /** |
Kojto | 29:c40918cd9b6d | 1201 | * \brief Connect to SSID (open/secured) with timeout (10ms). |
Kojto | 20:30b6ed7bf8fd | 1202 | * \param ssid SSID name |
Kojto | 20:30b6ed7bf8fd | 1203 | * \param key Security key (if key = 0, open connection) |
Kojto | 20:30b6ed7bf8fd | 1204 | * \param security_mode Security mode |
Kojto | 20:30b6ed7bf8fd | 1205 | * \return true if connection was established, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1206 | */ |
Kojto | 20:30b6ed7bf8fd | 1207 | bool connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode); |
Kojto | 29:c40918cd9b6d | 1208 | /** |
Kojto | 29:c40918cd9b6d | 1209 | * \brief Connect to SSID which is secured |
Kojto | 20:30b6ed7bf8fd | 1210 | * \param ssid SSID name |
Kojto | 20:30b6ed7bf8fd | 1211 | * \param key Security key |
Kojto | 20:30b6ed7bf8fd | 1212 | * \param security_mode Security mode |
Kojto | 20:30b6ed7bf8fd | 1213 | * \return true if connection was established, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1214 | */ |
Kojto | 20:30b6ed7bf8fd | 1215 | bool connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode); |
Kojto | 29:c40918cd9b6d | 1216 | /** |
Kojto | 29:c40918cd9b6d | 1217 | * \brief Connect to SSID which is open (no security) |
Kojto | 20:30b6ed7bf8fd | 1218 | * \param ssid SSID name |
Kojto | 20:30b6ed7bf8fd | 1219 | * \return true if connection was established, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1220 | */ |
Kojto | 20:30b6ed7bf8fd | 1221 | bool connect_open(const uint8_t *ssid); |
Kojto | 29:c40918cd9b6d | 1222 | /** |
Kojto | 29:c40918cd9b6d | 1223 | * \brief Status of the cc3000 connection. |
Kojto | 20:30b6ed7bf8fd | 1224 | * \return true if it's connected, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1225 | */ |
Kojto | 20:30b6ed7bf8fd | 1226 | bool is_connected(); |
Kojto | 29:c40918cd9b6d | 1227 | /** |
Kojto | 29:c40918cd9b6d | 1228 | * \brief Status of DHCP. |
Kojto | 20:30b6ed7bf8fd | 1229 | * \param none |
Kojto | 20:30b6ed7bf8fd | 1230 | * \return true if DCHP is configured, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1231 | */ |
Kojto | 20:30b6ed7bf8fd | 1232 | bool is_dhcp_configured(); |
Kojto | 29:c40918cd9b6d | 1233 | /** |
Kojto | 29:c40918cd9b6d | 1234 | * \brief Status of smart confing completation. |
Kojto | 20:30b6ed7bf8fd | 1235 | * \param none |
Kojto | 20:30b6ed7bf8fd | 1236 | * \return smart config was set, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1237 | */ |
Kojto | 20:30b6ed7bf8fd | 1238 | bool is_smart_confing_completed(); |
Kojto | 29:c40918cd9b6d | 1239 | /** |
Kojto | 29:c40918cd9b6d | 1240 | * \brief Return the cc3000's mac address. |
Kojto | 20:30b6ed7bf8fd | 1241 | * \param address Retreived mac address. |
Kojto | 20:30b6ed7bf8fd | 1242 | * \return |
Kojto | 20:30b6ed7bf8fd | 1243 | */ |
Kojto | 20:30b6ed7bf8fd | 1244 | uint8_t get_mac_address(uint8_t address[6]); |
Kojto | 29:c40918cd9b6d | 1245 | /** |
Kojto | 29:c40918cd9b6d | 1246 | * \brief Set the cc3000's mac address. |
Kojto | 29:c40918cd9b6d | 1247 | * \param address Mac address to be set. |
Kojto | 20:30b6ed7bf8fd | 1248 | * \return |
Kojto | 20:30b6ed7bf8fd | 1249 | */ |
Kojto | 20:30b6ed7bf8fd | 1250 | uint8_t set_mac_address(uint8_t address[6]); |
Kojto | 29:c40918cd9b6d | 1251 | /** |
Kojto | 29:c40918cd9b6d | 1252 | * \brief Get user file info. |
Kojto | 29:c40918cd9b6d | 1253 | * \param info_file Pointer where info will be stored. |
Kojto | 29:c40918cd9b6d | 1254 | * \param size Available size. |
Kojto | 20:30b6ed7bf8fd | 1255 | * \return none |
Kojto | 20:30b6ed7bf8fd | 1256 | */ |
Kojto | 20:30b6ed7bf8fd | 1257 | void get_user_file_info(uint8_t *info_file, size_t size); |
Kojto | 29:c40918cd9b6d | 1258 | /** |
Kojto | 29:c40918cd9b6d | 1259 | * \brief Set user filo info. |
Kojto | 29:c40918cd9b6d | 1260 | * \param info_file Pointer to user's info. |
Kojto | 20:30b6ed7bf8fd | 1261 | * \return none |
Kojto | 20:30b6ed7bf8fd | 1262 | */ |
Kojto | 20:30b6ed7bf8fd | 1263 | void set_user_file_info(uint8_t *info_file, size_t size); |
Kojto | 29:c40918cd9b6d | 1264 | /** |
Kojto | 29:c40918cd9b6d | 1265 | * \brief Start smart config. |
Kojto | 29:c40918cd9b6d | 1266 | * \param smart_config_key Pointer to smart config key. |
Kojto | 20:30b6ed7bf8fd | 1267 | * \return none |
Kojto | 20:30b6ed7bf8fd | 1268 | */ |
Kojto | 20:30b6ed7bf8fd | 1269 | void start_smart_config(const uint8_t *smart_config_key); /* TODO enable AES ? */ |
Kojto | 20:30b6ed7bf8fd | 1270 | #ifndef CC3000_TINY_DRIVER |
Kojto | 29:c40918cd9b6d | 1271 | /** |
Kojto | 29:c40918cd9b6d | 1272 | * \brief Return ip configuration. |
Kojto | 29:c40918cd9b6d | 1273 | * \param ip_config Pointer to ipconfig data. |
Kojto | 29:c40918cd9b6d | 1274 | * \return true if it's connected and info was retrieved, false otherwise. |
Kojto | 20:30b6ed7bf8fd | 1275 | */ |
Kojto | 20:30b6ed7bf8fd | 1276 | bool get_ip_config(tNetappIpconfigRetArgs *ip_config); |
Kojto | 20:30b6ed7bf8fd | 1277 | #endif |
Kojto | 29:c40918cd9b6d | 1278 | /** |
Kojto | 33:9e23b24fb4f3 | 1279 | * \brief Delete all stored profiles. |
Kojto | 29:c40918cd9b6d | 1280 | * \param none |
Kojto | 20:30b6ed7bf8fd | 1281 | * \return none |
Kojto | 20:30b6ed7bf8fd | 1282 | */ |
Kojto | 20:30b6ed7bf8fd | 1283 | void delete_profiles(void); |
Kojto | 20:30b6ed7bf8fd | 1284 | /** |
Kojto | 33:9e23b24fb4f3 | 1285 | * \brief Ping an ip address. |
Kojto | 29:c40918cd9b6d | 1286 | * \param ip Destination IP address |
Kojto | 29:c40918cd9b6d | 1287 | * \param attempts Number of attempts |
Kojto | 29:c40918cd9b6d | 1288 | * \param timeout Time to wait for a response,in milliseconds. |
Kojto | 29:c40918cd9b6d | 1289 | * \param size Send buffer size which may be up to 1400 bytes |
Kojto | 20:30b6ed7bf8fd | 1290 | */ |
Kojto | 20:30b6ed7bf8fd | 1291 | uint32_t ping(uint32_t ip, uint8_t attempts, uint16_t timeout, uint8_t size); |
Kojto | 29:c40918cd9b6d | 1292 | /** |
Kojto | 33:9e23b24fb4f3 | 1293 | * \brief Returns cc3000 instance. Used in Socket interface. |
Kojto | 29:c40918cd9b6d | 1294 | * \param none |
Kojto | 29:c40918cd9b6d | 1295 | * \return Pointer to cc3000 object |
Kojto | 29:c40918cd9b6d | 1296 | */ |
Kojto | 20:30b6ed7bf8fd | 1297 | static cc3000 *get_instance() { |
Kojto | 20:30b6ed7bf8fd | 1298 | return _inst; |
Kojto | 20:30b6ed7bf8fd | 1299 | } |
Kojto | 20:30b6ed7bf8fd | 1300 | public: |
Kojto | 20:30b6ed7bf8fd | 1301 | cc3000_simple_link _simple_link; |
Kojto | 20:30b6ed7bf8fd | 1302 | cc3000_event _event; |
Kojto | 20:30b6ed7bf8fd | 1303 | #ifndef CC3000_UNENCRYPTED_SMART_CONFIG |
Kojto | 20:30b6ed7bf8fd | 1304 | cc3000_security _security; |
Kojto | 20:30b6ed7bf8fd | 1305 | #endif |
Kojto | 20:30b6ed7bf8fd | 1306 | cc3000_socket _socket; |
Kojto | 20:30b6ed7bf8fd | 1307 | cc3000_spi _spi; |
Kojto | 20:30b6ed7bf8fd | 1308 | cc3000_hci _hci; |
Kojto | 20:30b6ed7bf8fd | 1309 | cc3000_nvmem _nvmem; |
Kojto | 20:30b6ed7bf8fd | 1310 | cc3000_netapp _netapp; |
Kojto | 20:30b6ed7bf8fd | 1311 | cc3000_wlan _wlan; |
Kojto | 20:30b6ed7bf8fd | 1312 | protected: |
Kojto | 20:30b6ed7bf8fd | 1313 | static cc3000 *_inst; |
Kojto | 20:30b6ed7bf8fd | 1314 | private: |
Kojto | 20:30b6ed7bf8fd | 1315 | tStatus _status; |
Kojto | 20:30b6ed7bf8fd | 1316 | netapp_pingreport_args_t _ping_report; |
Kojto | 20:30b6ed7bf8fd | 1317 | bool _closed_sockets[MAX_SOCKETS]; |
Kojto | 20:30b6ed7bf8fd | 1318 | }; |
Kojto | 20:30b6ed7bf8fd | 1319 | |
Kojto | 20:30b6ed7bf8fd | 1320 | /** |
Kojto | 29:c40918cd9b6d | 1321 | * Copy 32 bit to stream while converting to little endian format. |
Kojto | 29:c40918cd9b6d | 1322 | * @param p pointer to the new stream |
Kojto | 29:c40918cd9b6d | 1323 | * @param u32 pointer to the 32 bit |
Kojto | 29:c40918cd9b6d | 1324 | * @return pointer to the new stream |
Kojto | 29:c40918cd9b6d | 1325 | */ |
Kojto | 20:30b6ed7bf8fd | 1326 | uint8_t *UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32); |
Kojto | 20:30b6ed7bf8fd | 1327 | |
Kojto | 20:30b6ed7bf8fd | 1328 | /** |
Kojto | 29:c40918cd9b6d | 1329 | * Copy 16 bit to stream while converting to little endian format. |
Kojto | 29:c40918cd9b6d | 1330 | * @param p pointer to the new stream |
Kojto | 29:c40918cd9b6d | 1331 | * @param u32 pointer to the 16 bit |
Kojto | 29:c40918cd9b6d | 1332 | * @return pointer to the new stream |
Kojto | 29:c40918cd9b6d | 1333 | */ |
Kojto | 20:30b6ed7bf8fd | 1334 | uint8_t *UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16); |
Kojto | 20:30b6ed7bf8fd | 1335 | |
Kojto | 20:30b6ed7bf8fd | 1336 | /** |
Kojto | 29:c40918cd9b6d | 1337 | * Copy received stream to 16 bit in little endian format. |
Kojto | 29:c40918cd9b6d | 1338 | * @param p pointer to the stream |
Kojto | 29:c40918cd9b6d | 1339 | * @param offset offset in the stream |
Kojto | 29:c40918cd9b6d | 1340 | * @return pointer to the new 16 bit |
Kojto | 29:c40918cd9b6d | 1341 | */ |
Kojto | 20:30b6ed7bf8fd | 1342 | uint16_t STREAM_TO_UINT16_f(uint8_t* p, uint16_t offset); |
Kojto | 20:30b6ed7bf8fd | 1343 | |
Kojto | 20:30b6ed7bf8fd | 1344 | /** |
Kojto | 29:c40918cd9b6d | 1345 | * Copy received stream to 32 bit in little endian format. |
Kojto | 29:c40918cd9b6d | 1346 | * @param p pointer to the stream |
Kojto | 29:c40918cd9b6d | 1347 | * @param offset offset in the stream |
Kojto | 29:c40918cd9b6d | 1348 | * @return pointer to the new 32 bit |
Kojto | 29:c40918cd9b6d | 1349 | */ |
Kojto | 20:30b6ed7bf8fd | 1350 | uint32_t STREAM_TO_UINT32_f(uint8_t* p, uint16_t offset); |
Kojto | 20:30b6ed7bf8fd | 1351 | |
Kojto | 20:30b6ed7bf8fd | 1352 | } /* end of mbed_cc3000 namespace */ |
Kojto | 20:30b6ed7bf8fd | 1353 | |
Kojto | 20:30b6ed7bf8fd | 1354 | |
Kojto | 20:30b6ed7bf8fd | 1355 | #endif |