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