cc3000 hostdriver with the mbed socket interface

Fork of cc3000_hostdriver_mbedsocket by Martin Kojtal

Committer:
Kojto
Date:
Sun Oct 06 17:22:49 2013 +0200
Revision:
30:251a0a7d88de
Parent:
29:c40918cd9b6d
Child:
31:7b6e85b68b01
TCP/UDP client/server removal (my own versions)

- Socket interface replaced those

Who changed what in which revision?

UserRevisionLine numberNew 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 20:30b6ed7bf8fd 339 /**
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 20:30b6ed7bf8fd 429 class cc3000_netapp {
Kojto 20:30b6ed7bf8fd 430 public:
Kojto 29:c40918cd9b6d 431 /**
Kojto 29:c40918cd9b6d 432 * \brief
Kojto 29:c40918cd9b6d 433 * \param
Kojto 29:c40918cd9b6d 434 * \return
Kojto 29:c40918cd9b6d 435 */
Kojto 20:30b6ed7bf8fd 436 cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci, cc3000_event &event);
Kojto 29:c40918cd9b6d 437 /**
Kojto 29:c40918cd9b6d 438 * \brief
Kojto 29:c40918cd9b6d 439 * \param
Kojto 29:c40918cd9b6d 440 * \return
Kojto 29:c40918cd9b6d 441 */
Kojto 20:30b6ed7bf8fd 442 ~cc3000_netapp();
Kojto 29:c40918cd9b6d 443 /**
Kojto 29:c40918cd9b6d 444 * \brief
Kojto 29:c40918cd9b6d 445 * \param
Kojto 29:c40918cd9b6d 446 * \return
Kojto 29:c40918cd9b6d 447 */
Kojto 20:30b6ed7bf8fd 448 int32_t config_mac_adrress(uint8_t *mac);
Kojto 29:c40918cd9b6d 449 /**
Kojto 29:c40918cd9b6d 450 * \brief
Kojto 29:c40918cd9b6d 451 * \param
Kojto 29:c40918cd9b6d 452 * \return
Kojto 29:c40918cd9b6d 453 */
Kojto 20:30b6ed7bf8fd 454 int32_t dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server);
Kojto 20:30b6ed7bf8fd 455 #ifndef CC3000_TINY_DRIVER
Kojto 29:c40918cd9b6d 456 /**
Kojto 29:c40918cd9b6d 457 * \brief
Kojto 29:c40918cd9b6d 458 * \param
Kojto 29:c40918cd9b6d 459 * \return
Kojto 29:c40918cd9b6d 460 */
Kojto 20:30b6ed7bf8fd 461 void ipconfig(tNetappIpconfigRetArgs *ipconfig);
Kojto 29:c40918cd9b6d 462 /**
Kojto 29:c40918cd9b6d 463 * \brief
Kojto 29:c40918cd9b6d 464 * \param
Kojto 29:c40918cd9b6d 465 * \return
Kojto 29:c40918cd9b6d 466 */
Kojto 20:30b6ed7bf8fd 467 int32_t timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity);
Kojto 29:c40918cd9b6d 468 /**
Kojto 29:c40918cd9b6d 469 * \brief
Kojto 29:c40918cd9b6d 470 * \param
Kojto 29:c40918cd9b6d 471 * \return
Kojto 29:c40918cd9b6d 472 */
Kojto 20:30b6ed7bf8fd 473 int32_t ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout);
Kojto 29:c40918cd9b6d 474 /**
Kojto 29:c40918cd9b6d 475 * \brief
Kojto 29:c40918cd9b6d 476 * \param
Kojto 29:c40918cd9b6d 477 * \return
Kojto 29:c40918cd9b6d 478 */
Kojto 20:30b6ed7bf8fd 479 void ping_report();
Kojto 29:c40918cd9b6d 480 /**
Kojto 29:c40918cd9b6d 481 * \brief
Kojto 29:c40918cd9b6d 482 * \param
Kojto 29:c40918cd9b6d 483 * \return
Kojto 29:c40918cd9b6d 484 */
Kojto 20:30b6ed7bf8fd 485 int32_t ping_stop();
Kojto 29:c40918cd9b6d 486 /**
Kojto 29:c40918cd9b6d 487 * \brief
Kojto 29:c40918cd9b6d 488 * \param
Kojto 29:c40918cd9b6d 489 * \return
Kojto 29:c40918cd9b6d 490 */
Kojto 20:30b6ed7bf8fd 491 int32_t arp_flush();
Kojto 20:30b6ed7bf8fd 492 #endif
Kojto 20:30b6ed7bf8fd 493 private:
Kojto 20:30b6ed7bf8fd 494 cc3000_simple_link &_simple_link;
Kojto 20:30b6ed7bf8fd 495 cc3000_nvmem &_nvmem;
Kojto 20:30b6ed7bf8fd 496 cc3000_hci &_hci;
Kojto 20:30b6ed7bf8fd 497 cc3000_event &_event;
Kojto 20:30b6ed7bf8fd 498 };
Kojto 20:30b6ed7bf8fd 499
Kojto 20:30b6ed7bf8fd 500 #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
Kojto 20:30b6ed7bf8fd 501 class cc3000_security {
Kojto 20:30b6ed7bf8fd 502 public:
Kojto 29:c40918cd9b6d 503 /**
Kojto 29:c40918cd9b6d 504 * \brief
Kojto 29:c40918cd9b6d 505 * \param
Kojto 29:c40918cd9b6d 506 * \return
Kojto 29:c40918cd9b6d 507 */
Kojto 20:30b6ed7bf8fd 508 void expandKey(uint8_t *expanded_key, uint8_t *key);
Kojto 29:c40918cd9b6d 509 /**
Kojto 29:c40918cd9b6d 510 * \brief
Kojto 29:c40918cd9b6d 511 * \param
Kojto 29:c40918cd9b6d 512 * \return
Kojto 29:c40918cd9b6d 513 */
Kojto 20:30b6ed7bf8fd 514 uint8_t galois_mul2(uint8_t value);
Kojto 29:c40918cd9b6d 515 /**
Kojto 29:c40918cd9b6d 516 * \brief
Kojto 29:c40918cd9b6d 517 * \param
Kojto 29:c40918cd9b6d 518 * \return
Kojto 29:c40918cd9b6d 519 */
Kojto 20:30b6ed7bf8fd 520 void aes_encr(uint8_t *state, uint8_t *expanded_key);
Kojto 29:c40918cd9b6d 521 /**
Kojto 29:c40918cd9b6d 522 * \brief
Kojto 29:c40918cd9b6d 523 * \param
Kojto 29:c40918cd9b6d 524 * \return
Kojto 29:c40918cd9b6d 525 */
Kojto 20:30b6ed7bf8fd 526 void aes_decr(uint8_t *state, uint8_t *expanded_key);
Kojto 29:c40918cd9b6d 527 /**
Kojto 29:c40918cd9b6d 528 * \brief
Kojto 29:c40918cd9b6d 529 * \param
Kojto 29:c40918cd9b6d 530 * \return
Kojto 29:c40918cd9b6d 531 */
Kojto 20:30b6ed7bf8fd 532 void aes_encrypt(uint8_t *state, uint8_t *key);
Kojto 29:c40918cd9b6d 533 /**
Kojto 29:c40918cd9b6d 534 * \brief
Kojto 29:c40918cd9b6d 535 * \param
Kojto 29:c40918cd9b6d 536 * \return
Kojto 29:c40918cd9b6d 537 */
Kojto 20:30b6ed7bf8fd 538 void aes_decrypt(uint8_t *state, uint8_t *key);
Kojto 29:c40918cd9b6d 539 /**
Kojto 29:c40918cd9b6d 540 * \brief
Kojto 29:c40918cd9b6d 541 * \param
Kojto 29:c40918cd9b6d 542 * \return
Kojto 29:c40918cd9b6d 543 */
Kojto 20:30b6ed7bf8fd 544 int32_t aes_read_key(uint8_t *key);
Kojto 29:c40918cd9b6d 545 /**
Kojto 29:c40918cd9b6d 546 * \brief
Kojto 29:c40918cd9b6d 547 * \param
Kojto 29:c40918cd9b6d 548 * \return
Kojto 29:c40918cd9b6d 549 */
Kojto 20:30b6ed7bf8fd 550 int32_t aes_write_key(uint8_t *key);
Kojto 20:30b6ed7bf8fd 551 private:
Kojto 20:30b6ed7bf8fd 552 uint8_t _expanded_key[176];
Kojto 20:30b6ed7bf8fd 553 };
Kojto 20:30b6ed7bf8fd 554 #endif
Kojto 20:30b6ed7bf8fd 555
Kojto 20:30b6ed7bf8fd 556 class cc3000_socket {
Kojto 20:30b6ed7bf8fd 557 public:
Kojto 29:c40918cd9b6d 558 /**
Kojto 29:c40918cd9b6d 559 * \brief
Kojto 29:c40918cd9b6d 560 * \param
Kojto 29:c40918cd9b6d 561 * \return
Kojto 29:c40918cd9b6d 562 */
Kojto 20:30b6ed7bf8fd 563 cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event);
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();
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 int32_t socket(int32_t domain, int32_t type, int32_t protocol);
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 accept(int32_t sd, sockaddr *addr, socklen_t *addrlen);
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 bind(int32_t sd, const sockaddr *addr, int32_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 HostFlowControlConsumeBuff(int32_t sd);
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 closesocket(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 listen(int32_t sd, int32_t backlog);
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 connect(int32_t sd, const sockaddr *addr, int32_t addrlen);
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 select(int32_t nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout);
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 getsockopt (int32_t sd, int32_t level, int32_t optname, void *optval, socklen_t *optlen);
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 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 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_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 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 recv(int32_t sd, void *buf, int32_t len, int32_t flags);
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 recvfrom(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen);
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 send(int32_t sd, const void *buf, int32_t len, int32_t flags);
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 sendto(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, socklen_t tolen);
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 mdns_advertiser(uint16_t mdns_enabled, uint8_t * device_service_name, uint16_t device_service_name_length);
Kojto 20:30b6ed7bf8fd 666 #ifndef CC3000_TINY_DRIVER
Kojto 20:30b6ed7bf8fd 667 int32_t gethostbyname(uint8_t *hostname, uint16_t name_length, uint32_t *out_ip_addr);
Kojto 29:c40918cd9b6d 668 /**
Kojto 29:c40918cd9b6d 669 * \brief
Kojto 29:c40918cd9b6d 670 * \param
Kojto 29:c40918cd9b6d 671 * \return
Kojto 29:c40918cd9b6d 672 */
Kojto 20:30b6ed7bf8fd 673 int32_t setsockopt(int32_t sd, int32_t level, int32_t optname, const void *optval, socklen_t optlen);
Kojto 20:30b6ed7bf8fd 674 #endif
Kojto 20:30b6ed7bf8fd 675 private:
Kojto 20:30b6ed7bf8fd 676 cc3000_simple_link &_simple_link;
Kojto 20:30b6ed7bf8fd 677 cc3000_hci &_hci;
Kojto 20:30b6ed7bf8fd 678 cc3000_event &_event;
Kojto 20:30b6ed7bf8fd 679 };
Kojto 20:30b6ed7bf8fd 680
Kojto 20:30b6ed7bf8fd 681 /** SPI communication class
Kojto 20:30b6ed7bf8fd 682 */
Kojto 20:30b6ed7bf8fd 683 class cc3000_spi {
Kojto 20:30b6ed7bf8fd 684 public:
Kojto 20:30b6ed7bf8fd 685 /** ctor
Kojto 20:30b6ed7bf8fd 686 */
Kojto 20:30b6ed7bf8fd 687 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 688 /** dtor
Kojto 20:30b6ed7bf8fd 689 */
Kojto 20:30b6ed7bf8fd 690 ~cc3000_spi();
Kojto 20:30b6ed7bf8fd 691 /** Close SPI - disables IRQ and set received buffer to 0
Kojto 20:30b6ed7bf8fd 692 * \param none
Kojto 20:30b6ed7bf8fd 693 * \return none
Kojto 20:30b6ed7bf8fd 694 */
Kojto 20:30b6ed7bf8fd 695 void close();
Kojto 20:30b6ed7bf8fd 696 /**
Kojto 20:30b6ed7bf8fd 697 * \param none
Kojto 20:30b6ed7bf8fd 698 * \return none
Kojto 20:30b6ed7bf8fd 699 */
Kojto 20:30b6ed7bf8fd 700 void open();
Kojto 20:30b6ed7bf8fd 701 /**
Kojto 20:30b6ed7bf8fd 702 * \param buffer
Kojto 20:30b6ed7bf8fd 703 * \param length
Kojto 20:30b6ed7bf8fd 704 * \return none
Kojto 20:30b6ed7bf8fd 705 */
Kojto 20:30b6ed7bf8fd 706 uint32_t first_write(uint8_t *buffer, uint16_t length);
Kojto 20:30b6ed7bf8fd 707 /**
Kojto 29:c40918cd9b6d 708 * \brief
Kojto 29:c40918cd9b6d 709 * \param
Kojto 29:c40918cd9b6d 710 * \return
Kojto 20:30b6ed7bf8fd 711 */
Kojto 20:30b6ed7bf8fd 712 uint32_t 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 void write_synchronous(uint8_t *data, uint16_t size);
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 read_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 uint32_t read_data_cont();
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 void wlan_irq_enable();
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_disable();
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_set(uint8_t value);
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 uint32_t wlan_irq_read();
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 void WLAN_IRQHandler();
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 write_wlan_en(uint8_t value);
Kojto 20:30b6ed7bf8fd 767 private:
Kojto 20:30b6ed7bf8fd 768 tSpiInfo _spi_info;
Kojto 20:30b6ed7bf8fd 769 InterruptIn _wlan_irq;
Kojto 20:30b6ed7bf8fd 770 DigitalOut _wlan_en;
Kojto 20:30b6ed7bf8fd 771 DigitalOut _wlan_cs;
Kojto 20:30b6ed7bf8fd 772 SPI _wlan_spi;
Kojto 20:30b6ed7bf8fd 773 IRQn_Type _irq_port;
Kojto 20:30b6ed7bf8fd 774 pFunctionPointer_t _function_pointer;
Kojto 20:30b6ed7bf8fd 775 cc3000_event &_event;
Kojto 20:30b6ed7bf8fd 776 cc3000_simple_link &_simple_link;
Kojto 20:30b6ed7bf8fd 777 };
Kojto 20:30b6ed7bf8fd 778
Kojto 20:30b6ed7bf8fd 779 class cc3000_hci {
Kojto 20:30b6ed7bf8fd 780 public:
Kojto 29:c40918cd9b6d 781 /**
Kojto 29:c40918cd9b6d 782 * \brief Ctor
Kojto 29:c40918cd9b6d 783 * \param spi Reference to spi object.
Kojto 29:c40918cd9b6d 784 * \return none
Kojto 29:c40918cd9b6d 785 */
Kojto 20:30b6ed7bf8fd 786 cc3000_hci(cc3000_spi &spi);
Kojto 29:c40918cd9b6d 787 /**
Kojto 29:c40918cd9b6d 788 * \brief Dtor
Kojto 29:c40918cd9b6d 789 * \param none
Kojto 29:c40918cd9b6d 790 * \return none
Kojto 29:c40918cd9b6d 791 */
Kojto 20:30b6ed7bf8fd 792 ~cc3000_hci();
Kojto 29:c40918cd9b6d 793 /**
Kojto 29:c40918cd9b6d 794 * \brief Initiate an HCI command.
Kojto 29:c40918cd9b6d 795 * \param op_code command operation code
Kojto 29:c40918cd9b6d 796 * \param buffer pointer to the command's arguments buffer
Kojto 29:c40918cd9b6d 797 * \param length length of the arguments
Kojto 29:c40918cd9b6d 798 * \return ???
Kojto 29:c40918cd9b6d 799 */
Kojto 20:30b6ed7bf8fd 800 uint16_t command_send(uint16_t op_code, uint8_t *buffer, uint8_t length);
Kojto 29:c40918cd9b6d 801 /**
Kojto 29:c40918cd9b6d 802 * \brief Initiate an HCI data write operation
Kojto 29:c40918cd9b6d 803 * \param op_code command operation code
Kojto 29:c40918cd9b6d 804 * \param args pointer to the command's arguments buffer
Kojto 29:c40918cd9b6d 805 * \param arg_length length of the arguments
Kojto 29:c40918cd9b6d 806 * \param data_length length od data
Kojto 29:c40918cd9b6d 807 * \param tail pointer to the data buffer
Kojto 29:c40918cd9b6d 808 * \param tail_length buffer length
Kojto 29:c40918cd9b6d 809 * \return ???
Kojto 29:c40918cd9b6d 810 */
Kojto 20:30b6ed7bf8fd 811 uint32_t data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length,
Kojto 20:30b6ed7bf8fd 812 uint16_t data_length, const uint8_t *tail, uint16_t tail_length);
Kojto 29:c40918cd9b6d 813 /**
Kojto 29:c40918cd9b6d 814 * \brief Prepare HCI header and initiate an HCI data write operation.
Kojto 29:c40918cd9b6d 815 * \param op_code command operation code
Kojto 29:c40918cd9b6d 816 * \param buffer pointer to the data buffer
Kojto 29:c40918cd9b6d 817 * \param arg_length arguments length
Kojto 29:c40918cd9b6d 818 * \param data_length data length
Kojto 29:c40918cd9b6d 819 * \return none
Kojto 29:c40918cd9b6d 820 */
Kojto 20:30b6ed7bf8fd 821 void data_command_send(uint16_t op_code, uint8_t *buffer, uint8_t arg_length,
Kojto 20:30b6ed7bf8fd 822 uint16_t data_length);
Kojto 29:c40918cd9b6d 823 /**
Kojto 29:c40918cd9b6d 824 * \brief Prepare HCI header and initiate an HCI patch write operation.
Kojto 29:c40918cd9b6d 825 * \param op_code command operation code
Kojto 29:c40918cd9b6d 826 * \param buffer pointer to the command's arguments buffer
Kojto 29:c40918cd9b6d 827 * \param patch pointer to patch content buffer
Kojto 29:c40918cd9b6d 828 * \param data_length data length
Kojto 29:c40918cd9b6d 829 * \return none
Kojto 29:c40918cd9b6d 830 */
Kojto 20:30b6ed7bf8fd 831 void patch_send(uint8_t op_code, uint8_t *buffer, uint8_t *patch, uint16_t data_length);
Kojto 20:30b6ed7bf8fd 832 private:
Kojto 20:30b6ed7bf8fd 833 cc3000_spi &_spi;
Kojto 20:30b6ed7bf8fd 834 };
Kojto 20:30b6ed7bf8fd 835
Kojto 20:30b6ed7bf8fd 836 class cc3000_nvmem {
Kojto 20:30b6ed7bf8fd 837 public:
Kojto 29:c40918cd9b6d 838 /**
Kojto 29:c40918cd9b6d 839 * \brief Ctor
Kojto 29:c40918cd9b6d 840 * \param hci Reference to hci object.
Kojto 29:c40918cd9b6d 841 * \param event Reference to event object.
Kojto 29:c40918cd9b6d 842 * \param simple_link Reference to simple link object.
Kojto 29:c40918cd9b6d 843 * \return none
Kojto 29:c40918cd9b6d 844 */
Kojto 29:c40918cd9b6d 845 cc3000_nvmem(cc3000_hci &hci, cc3000_event &event, cc3000_simple_link &simple_link);
Kojto 29:c40918cd9b6d 846 /**
Kojto 29:c40918cd9b6d 847 * \brief Dtor
Kojto 29:c40918cd9b6d 848 * \param none
Kojto 29:c40918cd9b6d 849 * \return none
Kojto 29:c40918cd9b6d 850 */
Kojto 20:30b6ed7bf8fd 851 ~cc3000_nvmem();
Kojto 29:c40918cd9b6d 852 /**
Kojto 29:c40918cd9b6d 853 * \brief Reads data from the file referred by the file_id parameter.
Kojto 29:c40918cd9b6d 854 * Reads data from file offset till length. Err if the file can't be used,
Kojto 29:c40918cd9b6d 855 * is invalid, or if the read is out of bounds.
Kojto 29:c40918cd9b6d 856 * \param file_id nvmem file id.
Kojto 29:c40918cd9b6d 857 * \param length number of bytes to read.
Kojto 29:c40918cd9b6d 858 * \param offset offset in file from where to read.
Kojto 29:c40918cd9b6d 859 * \param buff output buffer pointer.
Kojto 29:c40918cd9b6d 860 * \return
Kojto 29:c40918cd9b6d 861 * Number of bytes read, otherwise error.
Kojto 29:c40918cd9b6d 862 */
Kojto 20:30b6ed7bf8fd 863 int32_t read(uint32_t file_id, uint32_t length, uint32_t offset, uint8_t *buff);
Kojto 29:c40918cd9b6d 864 /**
Kojto 29:c40918cd9b6d 865 * \brief Write data to nvmem.
Kojto 29:c40918cd9b6d 866 * \param file_id Nvmem file id
Kojto 29:c40918cd9b6d 867 * \param length number of bytes to write
Kojto 29:c40918cd9b6d 868 * \param entry_offset offset in file to start write operation from
Kojto 29:c40918cd9b6d 869 * \param buff data to write
Kojto 29:c40918cd9b6d 870 * \return
Kojto 29:c40918cd9b6d 871 * On success 0, error otherwise.
Kojto 29:c40918cd9b6d 872 */
Kojto 20:30b6ed7bf8fd 873 int32_t write(uint32_t file_id, uint32_t length, uint32_t entry_offset, uint8_t *buff);
Kojto 29:c40918cd9b6d 874 /**
Kojto 29:c40918cd9b6d 875 * \brief Write MAC address to EEPROM.
Kojto 29:c40918cd9b6d 876 * \param mac Mac address to be set
Kojto 29:c40918cd9b6d 877 * \return
Kojto 29:c40918cd9b6d 878 * On success 0, error otherwise.
Kojto 29:c40918cd9b6d 879 */
Kojto 20:30b6ed7bf8fd 880 uint8_t set_mac_address(uint8_t *mac);
Kojto 29:c40918cd9b6d 881 /**
Kojto 29:c40918cd9b6d 882 * \brief Read MAC address from EEPROM.
Kojto 29:c40918cd9b6d 883 * \param mac Mac address
Kojto 29:c40918cd9b6d 884 * \return
Kojto 29:c40918cd9b6d 885 * on success 0, error otherwise.
Kojto 29:c40918cd9b6d 886 */
Kojto 20:30b6ed7bf8fd 887 uint8_t get_mac_address(uint8_t *mac);
Kojto 29:c40918cd9b6d 888 /**
Kojto 29:c40918cd9b6d 889 * \brief Program a patch to a specific file ID. The SP data is assumed to be organized in 2-dimensional.
Kojto 29:c40918cd9b6d 890 * Each line is SP_PORTION_SIZE bytes long.
Kojto 29:c40918cd9b6d 891 * \param file_id nvmem file id/
Kojto 29:c40918cd9b6d 892 * \param length number of bytes to write
Kojto 29:c40918cd9b6d 893 * \param data SP data to write
Kojto 29:c40918cd9b6d 894 * \return
Kojto 29:c40918cd9b6d 895 * On success 0, error otherwise.
Kojto 29:c40918cd9b6d 896 */
Kojto 20:30b6ed7bf8fd 897 uint8_t write_patch(uint32_t file_id, uint32_t length, const uint8_t *data);
Kojto 29:c40918cd9b6d 898 /**
Kojto 29:c40918cd9b6d 899 * \brief Create new file entry and allocate space on the NVMEM. Applies only to user files.
Kojto 29:c40918cd9b6d 900 * \param file_id nvmem file Id
Kojto 29:c40918cd9b6d 901 * \param new_len entry ulLength
Kojto 29:c40918cd9b6d 902 * \return
Kojto 29:c40918cd9b6d 903 */
Kojto 20:30b6ed7bf8fd 904 int32_t create_entry(uint32_t file_id, uint32_t new_len);
Kojto 20:30b6ed7bf8fd 905 #ifndef CC3000_TINY_DRIVER
Kojto 29:c40918cd9b6d 906 /**
Kojto 29:c40918cd9b6d 907 * \brief Read patch version. read package version (WiFi FW patch, river-supplicant-NS patch,
Kojto 29:c40918cd9b6d 908 * bootloader patch)
Kojto 29:c40918cd9b6d 909 * \param patch_ver First number indicates package ID and the second number indicates
Kojto 29:c40918cd9b6d 910 * package build number
Kojto 29:c40918cd9b6d 911 * \return
Kojto 29:c40918cd9b6d 912 * On success 0, error otherwise.
Kojto 29:c40918cd9b6d 913 */
Kojto 20:30b6ed7bf8fd 914 uint8_t read_sp_version(uint8_t* patch_ver);
Kojto 20:30b6ed7bf8fd 915 #endif
Kojto 20:30b6ed7bf8fd 916 private:
Kojto 20:30b6ed7bf8fd 917 cc3000_hci &_hci;
Kojto 20:30b6ed7bf8fd 918 cc3000_event &_event;
Kojto 20:30b6ed7bf8fd 919 cc3000_simple_link &_simple_link;
Kojto 20:30b6ed7bf8fd 920 };
Kojto 20:30b6ed7bf8fd 921
Kojto 20:30b6ed7bf8fd 922 class cc3000_wlan {
Kojto 20:30b6ed7bf8fd 923 public:
Kojto 29:c40918cd9b6d 924 /**
Kojto 29:c40918cd9b6d 925 * \brief Ctor
Kojto 29:c40918cd9b6d 926 * \param simple_link Reference to simple link object.
Kojto 29:c40918cd9b6d 927 * \param event Reference to event object.
Kojto 29:c40918cd9b6d 928 * \param spi Reference to spi object.
Kojto 29:c40918cd9b6d 929 * \param hci Reference to hci object.
Kojto 29:c40918cd9b6d 930 * \return none
Kojto 29:c40918cd9b6d 931 */
Kojto 20:30b6ed7bf8fd 932 cc3000_wlan(cc3000_simple_link &simple_link, cc3000_event &event, cc3000_spi &spi, cc3000_hci &hci);
Kojto 29:c40918cd9b6d 933 /**
Kojto 29:c40918cd9b6d 934 * \brief Dtor
Kojto 29:c40918cd9b6d 935 * \param none
Kojto 29:c40918cd9b6d 936 * \return none
Kojto 29:c40918cd9b6d 937 */
Kojto 20:30b6ed7bf8fd 938 ~cc3000_wlan();
Kojto 29:c40918cd9b6d 939 /**
Kojto 29:c40918cd9b6d 940 * \brief Send SIMPLE LINK START to cc3000.
Kojto 29:c40918cd9b6d 941 * \param patches_available_host Flag to indicate if patches are available.
Kojto 20:30b6ed7bf8fd 942 * \return none
Kojto 20:30b6ed7bf8fd 943 */
Kojto 20:30b6ed7bf8fd 944 void simpleLink_init_start(uint16_t patches_available_host);
Kojto 29:c40918cd9b6d 945 /**
Kojto 29:c40918cd9b6d 946 * \brief Start wlan device. Blocking call until init is completed.
Kojto 29:c40918cd9b6d 947 * \param patches_available_host Flag to indicate if patches are available.
Kojto 20:30b6ed7bf8fd 948 * \return none
Kojto 20:30b6ed7bf8fd 949 */
Kojto 20:30b6ed7bf8fd 950 void start(uint16_t patches_available_host);
Kojto 29:c40918cd9b6d 951 /**
Kojto 29:c40918cd9b6d 952 * \brief Stop wlan device
Kojto 20:30b6ed7bf8fd 953 * \param none
Kojto 20:30b6ed7bf8fd 954 * \return none
Kojto 20:30b6ed7bf8fd 955 */
Kojto 20:30b6ed7bf8fd 956 void stop(void);
Kojto 20:30b6ed7bf8fd 957 #ifndef CC3000_TINY_DRIVER
Kojto 29:c40918cd9b6d 958 /**
Kojto 29:c40918cd9b6d 959 * \brief Connect to AP.
Kojto 29:c40918cd9b6d 960 * \param sec_type Security option.
Kojto 29:c40918cd9b6d 961 * \param ssid up to 32 bytes, ASCII SSID
Kojto 29:c40918cd9b6d 962 * \param ssid_length length of SSID
Kojto 29:c40918cd9b6d 963 * \param b_ssid 6 bytes specified the AP bssid
Kojto 29:c40918cd9b6d 964 * \param key up to 16 bytes specified the AP security key
Kojto 29:c40918cd9b6d 965 * \param key_len key length
Kojto 29:c40918cd9b6d 966 * \return
Kojto 29:c40918cd9b6d 967 * On success, zero is returned. On error, negative is returned.
Kojto 29:c40918cd9b6d 968 */
Kojto 20:30b6ed7bf8fd 969 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 970 /**
Kojto 29:c40918cd9b6d 971 * \brief Add profile. Up to 7 profiles are supported.
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 priority Up to 16 bytes specified the AP security key
Kojto 29:c40918cd9b6d 977 * \param pairwise_cipher_or_tx_key_len Key length
Kojto 29:c40918cd9b6d 978 * \param group_cipher_tx_key_index Key length for WEP security
Kojto 29:c40918cd9b6d 979 * \param key_mgmt KEY management
Kojto 29:c40918cd9b6d 980 * \param pf_or_key Security key
Kojto 29:c40918cd9b6d 981 * \param pass_phrase_length Security key length for WPA\WPA2
Kojto 29:c40918cd9b6d 982 * \return
Kojto 29:c40918cd9b6d 983 * On success, zero is returned. On error, negative is returned.
Kojto 29:c40918cd9b6d 984 */
Kojto 20:30b6ed7bf8fd 985 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 986 uint32_t key_mgmt, uint8_t* pf_or_key, uint32_t pass_phrase_length);
Kojto 29:c40918cd9b6d 987 /**
Kojto 29:c40918cd9b6d 988 * \brief Gets entry from scan result table. The scan results are returned
Kojto 29:c40918cd9b6d 989 * one by one, and each entry represents a single AP found in the area.
Kojto 29:c40918cd9b6d 990 * \param scan_timeout Not supported yet
Kojto 29:c40918cd9b6d 991 * \param results Scan result
Kojto 29:c40918cd9b6d 992 * \return
Kojto 29:c40918cd9b6d 993 * On success, zero is returned. On error, -1 is returned
Kojto 29:c40918cd9b6d 994 */
Kojto 20:30b6ed7bf8fd 995 int32_t ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results);
Kojto 29:c40918cd9b6d 996 /**
Kojto 29:c40918cd9b6d 997 * \brief Start and stop scan procedure. Set scan parameters.
Kojto 29:c40918cd9b6d 998 * \param enable Start/stop application scan
Kojto 29:c40918cd9b6d 999 * \param min_dwell_time Minimum dwell time value to be used for each channel, in ms. (Default: 20)
Kojto 29:c40918cd9b6d 1000 * \param max_dwell_time Maximum dwell time value to be used for each channel, in ms. (Default: 30)
Kojto 29:c40918cd9b6d 1001 * \param num_probe_requests Max probe request between dwell time. (Default:2)
Kojto 29:c40918cd9b6d 1002 * \param channel_mask Bitwise, up to 13 channels (0x1fff).
Kojto 29:c40918cd9b6d 1003 * \param rssi_threshold RSSI threshold. Saved: yes (Default: -80)
Kojto 29:c40918cd9b6d 1004 * \param snr_threshold NSR threshold. Saved: yes (Default: 0)
Kojto 29:c40918cd9b6d 1005 * \param default_tx_power probe Tx power. Saved: yes (Default: 205)
Kojto 29:c40918cd9b6d 1006 * \param interval_list Pointer to array with 16 entries (16 channels)
Kojto 29:c40918cd9b6d 1007 * \return
Kojto 29:c40918cd9b6d 1008 * On success, zero is returned. On error, -1 is returned.
Kojto 29:c40918cd9b6d 1009 */
Kojto 20:30b6ed7bf8fd 1010 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 1011 uint32_t channel_mask, int32_t rssi_threshold, uint32_t snr_threshold, uint32_t default_tx_power, uint32_t *interval_list);
Kojto 29:c40918cd9b6d 1012 /**
Kojto 29:c40918cd9b6d 1013 * \brief Get wlan status: disconnected, scanning, connecting or connected
Kojto 29:c40918cd9b6d 1014 * \param none
Kojto 29:c40918cd9b6d 1015 * \return
Kojto 29:c40918cd9b6d 1016 * WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING, STATUS_CONNECTING or WLAN_STATUS_CONNECTED
Kojto 29:c40918cd9b6d 1017 */
Kojto 20:30b6ed7bf8fd 1018 int32_t ioctl_statusget(void);
Kojto 20:30b6ed7bf8fd 1019 #else
Kojto 29:c40918cd9b6d 1020 /**
Kojto 29:c40918cd9b6d 1021 * \brief Connect to AP
Kojto 29:c40918cd9b6d 1022 * \param ssid Up to 32 bytes and is ASCII SSID of the AP
Kojto 29:c40918cd9b6d 1023 * \param ssid_length Length of the SSID
Kojto 29:c40918cd9b6d 1024 * \return
Kojto 29:c40918cd9b6d 1025 * On success, zero is returned. On error, negative is returned.
Kojto 29:c40918cd9b6d 1026 */
Kojto 20:30b6ed7bf8fd 1027 int32_t connect(const uint8_t *ssid, int32_t ssid_length);
Kojto 29:c40918cd9b6d 1028 /**
Kojto 29:c40918cd9b6d 1029 * \brief When auto start is enabled, the device connects to station from the profiles table.
Kojto 29:c40918cd9b6d 1030 * If several profiles configured the device choose the highest priority profile.
Kojto 29:c40918cd9b6d 1031 * \param sec_type WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2
Kojto 29:c40918cd9b6d 1032 * \param ssid SSID up to 32 bytes
Kojto 29:c40918cd9b6d 1033 * \param ssid_length SSID length
Kojto 29:c40918cd9b6d 1034 * \param b_ssid bssid 6 bytes
Kojto 29:c40918cd9b6d 1035 * \param priority Profile priority. Lowest priority:0.
Kojto 29:c40918cd9b6d 1036 * \param pairwise_cipher_or_tx_key_len Key length for WEP security
Kojto 29:c40918cd9b6d 1037 * \param group_cipher_tx_key_index Key index
Kojto 29:c40918cd9b6d 1038 * \param key_mgmt KEY management
Kojto 29:c40918cd9b6d 1039 * \param pf_or_key Security key
Kojto 29:c40918cd9b6d 1040 * \param pass_phrase_length Security key length for WPA\WPA2
Kojto 29:c40918cd9b6d 1041 * \return
Kojto 29:c40918cd9b6d 1042 * On success, zero is returned. On error, -1 is returned
Kojto 29:c40918cd9b6d 1043 */
Kojto 20:30b6ed7bf8fd 1044 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 1045 uint32_t pairwise_cipher_or_tx_key_len, uint32_t group_cipher_tx_key_index, uint32_t key_mgmt,
Kojto 20:30b6ed7bf8fd 1046 uint8_t* pf_or_key, uint32_t pass_phrase_length);
Kojto 20:30b6ed7bf8fd 1047 #endif
Kojto 20:30b6ed7bf8fd 1048 #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
Kojto 29:c40918cd9b6d 1049 /**
Kojto 29:c40918cd9b6d 1050 * \brief Process the acquired data and store it as a profile.
Kojto 29:c40918cd9b6d 1051 * \param none
Kojto 29:c40918cd9b6d 1052 * \return
Kojto 29:c40918cd9b6d 1053 * On success, zero is returned. On error, -1 is returned.
Kojto 29:c40918cd9b6d 1054 */
Kojto 20:30b6ed7bf8fd 1055 int32_t smart_config_process(void);
Kojto 20:30b6ed7bf8fd 1056 #endif
Kojto 29:c40918cd9b6d 1057 /**
Kojto 29:c40918cd9b6d 1058 * \brief Disconnect connection from AP.
Kojto 29:c40918cd9b6d 1059 * \param none
Kojto 29:c40918cd9b6d 1060 * \return
Kojto 29:c40918cd9b6d 1061 * 0 if disconnected done, other CC3000 already disconnected.
Kojto 29:c40918cd9b6d 1062 */
Kojto 20:30b6ed7bf8fd 1063 int32_t disconnect();
Kojto 29:c40918cd9b6d 1064 /**
Kojto 29:c40918cd9b6d 1065 * \brief When auto is enabled, the device tries to connect according the following policy:
Kojto 29:c40918cd9b6d 1066 * 1) If fast connect is enabled and last connection is valid, the device will try to
Kojto 29:c40918cd9b6d 1067 * connect to it without the scanning procedure (fast). The last connection will be
Kojto 29:c40918cd9b6d 1068 * marked as invalid, due to adding/removing profile.
Kojto 29:c40918cd9b6d 1069 * 2) If profile exists, the device will try to connect it (Up to seven profiles).
Kojto 29:c40918cd9b6d 1070 * 3) If fast and profiles are not found, and open mode is enabled, the device
Kojto 29:c40918cd9b6d 1071 * will try to connect to any AP.
Kojto 29:c40918cd9b6d 1072 * Note that the policy settings are stored in the CC3000 NVMEM.
Kojto 29:c40918cd9b6d 1073 * \param should_connect_to_open_ap Enable(1), disable(0) connect to any available AP.
Kojto 29:c40918cd9b6d 1074 * \param use_fast_connect Enable(1), disable(0). if enabled, tries to
Kojto 29:c40918cd9b6d 1075 * connect to the last connected AP.
Kojto 29:c40918cd9b6d 1076 * \param use_profiles Enable(1), disable(0) auto connect after reset.
Kojto 29:c40918cd9b6d 1077 * and periodically reconnect if needed.
Kojto 29:c40918cd9b6d 1078 * \return
Kojto 29:c40918cd9b6d 1079 * On success, zero is returned. On error, -1 is returned
Kojto 29:c40918cd9b6d 1080 */
Kojto 20:30b6ed7bf8fd 1081 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 1082 /**
Kojto 29:c40918cd9b6d 1083 * \brief Delete WLAN profile
Kojto 29:c40918cd9b6d 1084 * \param index Number of profile to delete
Kojto 29:c40918cd9b6d 1085 * \return
Kojto 29:c40918cd9b6d 1086 * On success, zero is returned. On error, -1 is returned
Kojto 29:c40918cd9b6d 1087 */
Kojto 20:30b6ed7bf8fd 1088 int32_t ioctl_del_profile(uint32_t index);
Kojto 29:c40918cd9b6d 1089 /**
Kojto 29:c40918cd9b6d 1090 * \brief Mask event according to bit mask. In case that event is
Kojto 29:c40918cd9b6d 1091 * masked (1), the device will not send the masked event to host.
Kojto 29:c40918cd9b6d 1092 * \param mask event mask
Kojto 29:c40918cd9b6d 1093 * \return
Kojto 29:c40918cd9b6d 1094 * On success, zero is returned. On error, -1 is returned
Kojto 29:c40918cd9b6d 1095 */
Kojto 20:30b6ed7bf8fd 1096 int32_t set_event_mask(uint32_t mask);
Kojto 29:c40918cd9b6d 1097 /**
Kojto 29:c40918cd9b6d 1098 * \brief Start to acquire device profile. The device acquire its own
Kojto 29:c40918cd9b6d 1099 * profile, if profile message is found.
Kojto 29:c40918cd9b6d 1100 * \param encrypted_flag Indicates whether the information is encrypted
Kojto 29:c40918cd9b6d 1101 * \return
Kojto 29:c40918cd9b6d 1102 * On success, zero is returned. On error, -1 is returned.
Kojto 29:c40918cd9b6d 1103 */
Kojto 20:30b6ed7bf8fd 1104 int32_t smart_config_start(uint32_t encrypted_flag);
Kojto 29:c40918cd9b6d 1105 /**
Kojto 29:c40918cd9b6d 1106 * \brief Stop the acquire profile procedure.
Kojto 29:c40918cd9b6d 1107 * \param none
Kojto 29:c40918cd9b6d 1108 * \return
Kojto 29:c40918cd9b6d 1109 * On success, zero is returned. On error, -1 is returned
Kojto 29:c40918cd9b6d 1110 */
Kojto 20:30b6ed7bf8fd 1111 int32_t smart_config_stop(void);
Kojto 29:c40918cd9b6d 1112 /**
Kojto 29:c40918cd9b6d 1113 * \brief Configure station ssid prefix.
Kojto 29:c40918cd9b6d 1114 * \param new_prefix 3 bytes identify the SSID prefix for the Smart Config.
Kojto 29:c40918cd9b6d 1115 * \return
Kojto 29:c40918cd9b6d 1116 * On success, zero is returned. On error, -1 is returned.
Kojto 29:c40918cd9b6d 1117 */
Kojto 20:30b6ed7bf8fd 1118 int32_t smart_config_set_prefix(uint8_t *new_prefix);
Kojto 20:30b6ed7bf8fd 1119 private:
Kojto 20:30b6ed7bf8fd 1120 cc3000_simple_link &_simple_link;
Kojto 20:30b6ed7bf8fd 1121 cc3000_event &_event;
Kojto 20:30b6ed7bf8fd 1122 cc3000_spi &_spi;
Kojto 20:30b6ed7bf8fd 1123 cc3000_hci &_hci;
Kojto 20:30b6ed7bf8fd 1124 };
Kojto 20:30b6ed7bf8fd 1125
Kojto 20:30b6ed7bf8fd 1126 /** The main class of entire cc3000 implementation
Kojto 20:30b6ed7bf8fd 1127 */
Kojto 20:30b6ed7bf8fd 1128 class cc3000 {
Kojto 20:30b6ed7bf8fd 1129 public:
Kojto 29:c40918cd9b6d 1130 /** status structure */
Kojto 20:30b6ed7bf8fd 1131 typedef struct {
Kojto 29:c40918cd9b6d 1132 bool dhcp;
Kojto 29:c40918cd9b6d 1133 bool connected;
Kojto 20:30b6ed7bf8fd 1134 uint8_t socket;
Kojto 29:c40918cd9b6d 1135 bool smart_config_complete;
Kojto 29:c40918cd9b6d 1136 bool stop_smart_config;
Kojto 29:c40918cd9b6d 1137 bool dhcp_configured;
Kojto 29:c40918cd9b6d 1138 bool ok_to_shut_down;
Kojto 20:30b6ed7bf8fd 1139 } tStatus;
Kojto 29:c40918cd9b6d 1140 /**
Kojto 29:c40918cd9b6d 1141 * \brief Ctor.
Kojto 20:30b6ed7bf8fd 1142 * \param cc3000_irq IRQ pin
Kojto 20:30b6ed7bf8fd 1143 * \param cc3000_en Enable pin
Kojto 20:30b6ed7bf8fd 1144 * \param cc3000_cs Chip select pin
Kojto 20:30b6ed7bf8fd 1145 * \param cc3000_spi SPI interface
Kojto 20:30b6ed7bf8fd 1146 * \param irq_port IRQ pin's port
Kojto 20:30b6ed7bf8fd 1147 */
Kojto 20:30b6ed7bf8fd 1148 cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port);
Kojto 29:c40918cd9b6d 1149 /**
Kojto 29:c40918cd9b6d 1150 * \brief Dtor.
Kojto 20:30b6ed7bf8fd 1151 */
Kojto 20:30b6ed7bf8fd 1152 ~cc3000();
Kojto 29:c40918cd9b6d 1153 /**
Kojto 29:c40918cd9b6d 1154 * \brief Initiate cc3000. It starts the wlan communication and deletes profiles.
Kojto 20:30b6ed7bf8fd 1155 * \param patch Patch
Kojto 20:30b6ed7bf8fd 1156 */
Kojto 20:30b6ed7bf8fd 1157 void start(uint8_t patch);
Kojto 29:c40918cd9b6d 1158 /**
Kojto 29:c40918cd9b6d 1159 * \brief Stops the wlan communication.
Kojto 20:30b6ed7bf8fd 1160 */
Kojto 20:30b6ed7bf8fd 1161 void stop();
Kojto 29:c40918cd9b6d 1162 /**
Kojto 29:c40918cd9b6d 1163 * \brief Restarts the wlan communication.
Kojto 20:30b6ed7bf8fd 1164 */
Kojto 20:30b6ed7bf8fd 1165 void restart(uint8_t patch);
Kojto 29:c40918cd9b6d 1166 /**
Kojto 29:c40918cd9b6d 1167 * \brief Disconnect wlan device
Kojto 20:30b6ed7bf8fd 1168 *
Kojto 20:30b6ed7bf8fd 1169 */
Kojto 20:30b6ed7bf8fd 1170 bool disconnect(void);
Kojto 29:c40918cd9b6d 1171 /**
Kojto 29:c40918cd9b6d 1172 * \brief Callback which is called from the event class. This updates status of cc3000.
Kojto 20:30b6ed7bf8fd 1173 * \param event_type Type of the event
Kojto 20:30b6ed7bf8fd 1174 * \param data Pointer to data
Kojto 20:30b6ed7bf8fd 1175 * \param length Length of data
Kojto 20:30b6ed7bf8fd 1176 * \return none
Kojto 20:30b6ed7bf8fd 1177 */
Kojto 20:30b6ed7bf8fd 1178 void usync_callback(int32_t event_type, uint8_t *data, uint8_t length);
Kojto 29:c40918cd9b6d 1179 /**
Kojto 29:c40918cd9b6d 1180 * \brief Connect to SSID (open/secured) with timeout (10ms).
Kojto 20:30b6ed7bf8fd 1181 * \param ssid SSID name
Kojto 20:30b6ed7bf8fd 1182 * \param key Security key (if key = 0, open connection)
Kojto 20:30b6ed7bf8fd 1183 * \param security_mode Security mode
Kojto 20:30b6ed7bf8fd 1184 * \return true if connection was established, false otherwise.
Kojto 20:30b6ed7bf8fd 1185 */
Kojto 20:30b6ed7bf8fd 1186 bool connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
Kojto 29:c40918cd9b6d 1187 /**
Kojto 29:c40918cd9b6d 1188 * \brief Connect to SSID which is secured
Kojto 20:30b6ed7bf8fd 1189 * \param ssid SSID name
Kojto 20:30b6ed7bf8fd 1190 * \param key Security key
Kojto 20:30b6ed7bf8fd 1191 * \param security_mode Security mode
Kojto 20:30b6ed7bf8fd 1192 * \return true if connection was established, false otherwise.
Kojto 20:30b6ed7bf8fd 1193 */
Kojto 20:30b6ed7bf8fd 1194 bool connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode);
Kojto 29:c40918cd9b6d 1195 /**
Kojto 29:c40918cd9b6d 1196 * \brief Connect to SSID which is open (no security)
Kojto 20:30b6ed7bf8fd 1197 * \param ssid SSID name
Kojto 20:30b6ed7bf8fd 1198 * \return true if connection was established, false otherwise.
Kojto 20:30b6ed7bf8fd 1199 */
Kojto 20:30b6ed7bf8fd 1200 bool connect_open(const uint8_t *ssid);
Kojto 29:c40918cd9b6d 1201 /**
Kojto 29:c40918cd9b6d 1202 * \brief Status of the cc3000 connection.
Kojto 20:30b6ed7bf8fd 1203 * \return true if it's connected, false otherwise.
Kojto 20:30b6ed7bf8fd 1204 */
Kojto 20:30b6ed7bf8fd 1205 bool is_connected();
Kojto 29:c40918cd9b6d 1206 /**
Kojto 29:c40918cd9b6d 1207 * \brief Status of DHCP.
Kojto 20:30b6ed7bf8fd 1208 * \param none
Kojto 20:30b6ed7bf8fd 1209 * \return true if DCHP is configured, false otherwise.
Kojto 20:30b6ed7bf8fd 1210 */
Kojto 20:30b6ed7bf8fd 1211 bool is_dhcp_configured();
Kojto 29:c40918cd9b6d 1212 /**
Kojto 29:c40918cd9b6d 1213 * \brief Status of smart confing completation.
Kojto 20:30b6ed7bf8fd 1214 * \param none
Kojto 20:30b6ed7bf8fd 1215 * \return smart config was set, false otherwise.
Kojto 20:30b6ed7bf8fd 1216 */
Kojto 20:30b6ed7bf8fd 1217 bool is_smart_confing_completed();
Kojto 29:c40918cd9b6d 1218 /**
Kojto 29:c40918cd9b6d 1219 * \brief Return the cc3000's mac address.
Kojto 20:30b6ed7bf8fd 1220 * \param address Retreived mac address.
Kojto 20:30b6ed7bf8fd 1221 * \return
Kojto 20:30b6ed7bf8fd 1222 */
Kojto 20:30b6ed7bf8fd 1223 uint8_t get_mac_address(uint8_t address[6]);
Kojto 29:c40918cd9b6d 1224 /**
Kojto 29:c40918cd9b6d 1225 * \brief Set the cc3000's mac address.
Kojto 29:c40918cd9b6d 1226 * \param address Mac address to be set.
Kojto 20:30b6ed7bf8fd 1227 * \return
Kojto 20:30b6ed7bf8fd 1228 */
Kojto 20:30b6ed7bf8fd 1229 uint8_t set_mac_address(uint8_t address[6]);
Kojto 29:c40918cd9b6d 1230 /**
Kojto 29:c40918cd9b6d 1231 * \brief Get user file info.
Kojto 29:c40918cd9b6d 1232 * \param info_file Pointer where info will be stored.
Kojto 29:c40918cd9b6d 1233 * \param size Available size.
Kojto 20:30b6ed7bf8fd 1234 * \return none
Kojto 20:30b6ed7bf8fd 1235 */
Kojto 20:30b6ed7bf8fd 1236 void get_user_file_info(uint8_t *info_file, size_t size);
Kojto 29:c40918cd9b6d 1237 /**
Kojto 29:c40918cd9b6d 1238 * \brief Set user filo info.
Kojto 29:c40918cd9b6d 1239 * \param info_file Pointer to user's info.
Kojto 20:30b6ed7bf8fd 1240 * \return none
Kojto 20:30b6ed7bf8fd 1241 */
Kojto 20:30b6ed7bf8fd 1242 void set_user_file_info(uint8_t *info_file, size_t size);
Kojto 29:c40918cd9b6d 1243 /**
Kojto 29:c40918cd9b6d 1244 * \brief Start smart config.
Kojto 29:c40918cd9b6d 1245 * \param smart_config_key Pointer to smart config key.
Kojto 20:30b6ed7bf8fd 1246 * \return none
Kojto 20:30b6ed7bf8fd 1247 */
Kojto 20:30b6ed7bf8fd 1248 void start_smart_config(const uint8_t *smart_config_key); /* TODO enable AES ? */
Kojto 20:30b6ed7bf8fd 1249 #ifndef CC3000_TINY_DRIVER
Kojto 29:c40918cd9b6d 1250 /**
Kojto 29:c40918cd9b6d 1251 * \brief Return ip configuration.
Kojto 29:c40918cd9b6d 1252 * \param ip_config Pointer to ipconfig data.
Kojto 29:c40918cd9b6d 1253 * \return true if it's connected and info was retrieved, false otherwise.
Kojto 20:30b6ed7bf8fd 1254 */
Kojto 20:30b6ed7bf8fd 1255 bool get_ip_config(tNetappIpconfigRetArgs *ip_config);
Kojto 20:30b6ed7bf8fd 1256 #endif
Kojto 29:c40918cd9b6d 1257 /**
Kojto 29:c40918cd9b6d 1258 * \brief Delete all stored profiles
Kojto 29:c40918cd9b6d 1259 * \param none
Kojto 20:30b6ed7bf8fd 1260 * \return none
Kojto 20:30b6ed7bf8fd 1261 */
Kojto 20:30b6ed7bf8fd 1262 void delete_profiles(void);
Kojto 20:30b6ed7bf8fd 1263 /**
Kojto 29:c40918cd9b6d 1264 * \brief Ping an ip address
Kojto 29:c40918cd9b6d 1265 * \param ip Destination IP address
Kojto 29:c40918cd9b6d 1266 * \param attempts Number of attempts
Kojto 29:c40918cd9b6d 1267 * \param timeout Time to wait for a response,in milliseconds.
Kojto 29:c40918cd9b6d 1268 * \param size Send buffer size which may be up to 1400 bytes
Kojto 20:30b6ed7bf8fd 1269 */
Kojto 20:30b6ed7bf8fd 1270 uint32_t ping(uint32_t ip, uint8_t attempts, uint16_t timeout, uint8_t size);
Kojto 29:c40918cd9b6d 1271 /**
Kojto 29:c40918cd9b6d 1272 * \brief Returns cc3000 instance
Kojto 29:c40918cd9b6d 1273 * \param none
Kojto 29:c40918cd9b6d 1274 * \return Pointer to cc3000 object
Kojto 29:c40918cd9b6d 1275 */
Kojto 20:30b6ed7bf8fd 1276 static cc3000 *get_instance() {
Kojto 20:30b6ed7bf8fd 1277 return _inst;
Kojto 20:30b6ed7bf8fd 1278 }
Kojto 20:30b6ed7bf8fd 1279 public:
Kojto 20:30b6ed7bf8fd 1280 cc3000_simple_link _simple_link;
Kojto 20:30b6ed7bf8fd 1281 cc3000_event _event;
Kojto 20:30b6ed7bf8fd 1282 #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
Kojto 20:30b6ed7bf8fd 1283 cc3000_security _security;
Kojto 20:30b6ed7bf8fd 1284 #endif
Kojto 20:30b6ed7bf8fd 1285 cc3000_socket _socket;
Kojto 20:30b6ed7bf8fd 1286 cc3000_spi _spi;
Kojto 20:30b6ed7bf8fd 1287 cc3000_hci _hci;
Kojto 20:30b6ed7bf8fd 1288 cc3000_nvmem _nvmem;
Kojto 20:30b6ed7bf8fd 1289 cc3000_netapp _netapp;
Kojto 20:30b6ed7bf8fd 1290 cc3000_wlan _wlan;
Kojto 20:30b6ed7bf8fd 1291 protected:
Kojto 20:30b6ed7bf8fd 1292 static cc3000 *_inst;
Kojto 20:30b6ed7bf8fd 1293 private:
Kojto 20:30b6ed7bf8fd 1294 tStatus _status;
Kojto 20:30b6ed7bf8fd 1295 netapp_pingreport_args_t _ping_report;
Kojto 20:30b6ed7bf8fd 1296 bool _closed_sockets[MAX_SOCKETS];
Kojto 20:30b6ed7bf8fd 1297 };
Kojto 20:30b6ed7bf8fd 1298
Kojto 20:30b6ed7bf8fd 1299 /**
Kojto 29:c40918cd9b6d 1300 * Copy 32 bit to stream while converting to little endian format.
Kojto 29:c40918cd9b6d 1301 * @param p pointer to the new stream
Kojto 29:c40918cd9b6d 1302 * @param u32 pointer to the 32 bit
Kojto 29:c40918cd9b6d 1303 * @return pointer to the new stream
Kojto 29:c40918cd9b6d 1304 */
Kojto 20:30b6ed7bf8fd 1305 uint8_t *UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32);
Kojto 20:30b6ed7bf8fd 1306
Kojto 20:30b6ed7bf8fd 1307 /**
Kojto 29:c40918cd9b6d 1308 * Copy 16 bit to stream while converting to little endian format.
Kojto 29:c40918cd9b6d 1309 * @param p pointer to the new stream
Kojto 29:c40918cd9b6d 1310 * @param u32 pointer to the 16 bit
Kojto 29:c40918cd9b6d 1311 * @return pointer to the new stream
Kojto 29:c40918cd9b6d 1312 */
Kojto 20:30b6ed7bf8fd 1313 uint8_t *UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16);
Kojto 20:30b6ed7bf8fd 1314
Kojto 20:30b6ed7bf8fd 1315 /**
Kojto 29:c40918cd9b6d 1316 * Copy received stream to 16 bit in little endian format.
Kojto 29:c40918cd9b6d 1317 * @param p pointer to the stream
Kojto 29:c40918cd9b6d 1318 * @param offset offset in the stream
Kojto 29:c40918cd9b6d 1319 * @return pointer to the new 16 bit
Kojto 29:c40918cd9b6d 1320 */
Kojto 20:30b6ed7bf8fd 1321 uint16_t STREAM_TO_UINT16_f(uint8_t* p, uint16_t offset);
Kojto 20:30b6ed7bf8fd 1322
Kojto 20:30b6ed7bf8fd 1323 /**
Kojto 29:c40918cd9b6d 1324 * Copy received stream to 32 bit in little endian format.
Kojto 29:c40918cd9b6d 1325 * @param p pointer to the stream
Kojto 29:c40918cd9b6d 1326 * @param offset offset in the stream
Kojto 29:c40918cd9b6d 1327 * @return pointer to the new 32 bit
Kojto 29:c40918cd9b6d 1328 */
Kojto 20:30b6ed7bf8fd 1329 uint32_t STREAM_TO_UINT32_f(uint8_t* p, uint16_t offset);
Kojto 20:30b6ed7bf8fd 1330
Kojto 20:30b6ed7bf8fd 1331 } /* end of mbed_cc3000 namespace */
Kojto 20:30b6ed7bf8fd 1332
Kojto 20:30b6ed7bf8fd 1333
Kojto 20:30b6ed7bf8fd 1334 #endif