cc3000 hostdriver with the mbed socket interface. Hacked TCP Classes for better control of non-blocking sockets.
Fork of cc3000_hostdriver_mbedsocket by
cc3000.cpp@47:86bb5f431c50, 2014-10-27 (annotated)
- Committer:
- mfurseman
- Date:
- Mon Oct 27 18:45:11 2014 +0000
- Revision:
- 47:86bb5f431c50
- Parent:
- 46:ca8c234997c0
- Child:
- 48:1e6068103f0b
Driver Debugging
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 | #include "cc3000.h" |
Kojto | 20:30b6ed7bf8fd | 42 | #include "cc3000_event.h" |
Kojto | 20:30b6ed7bf8fd | 43 | |
mfurseman | 47:86bb5f431c50 | 44 | /* DEBUG */ |
mfurseman | 47:86bb5f431c50 | 45 | //#include "USBSerial.h" |
mfurseman | 47:86bb5f431c50 | 46 | //extern USBSerial serial; |
mfurseman | 47:86bb5f431c50 | 47 | |
Kojto | 20:30b6ed7bf8fd | 48 | namespace mbed_cc3000 { |
Kojto | 20:30b6ed7bf8fd | 49 | |
Kojto | 20:30b6ed7bf8fd | 50 | /* TODO this prefix remove? verify */ |
Kojto | 20:30b6ed7bf8fd | 51 | static uint8_t cc3000_prefix[] = {'T', 'T', 'T'}; |
Kojto | 20:30b6ed7bf8fd | 52 | cc3000 *cc3000::_inst; |
Kojto | 20:30b6ed7bf8fd | 53 | |
Kojto | 45:50ab13d8f2dc | 54 | cc3000::cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi) |
Kojto | 45:50ab13d8f2dc | 55 | : _event(_simple_link, _hci, _spi, *this), _socket(_simple_link, _hci, _event), |
Kojto | 45:50ab13d8f2dc | 56 | _spi(cc3000_irq, cc3000_en, cc3000_cs, cc3000_spi, _event, _simple_link), _hci(_spi), |
Kojto | 45:50ab13d8f2dc | 57 | _nvmem(_hci, _event, _simple_link), _netapp(_simple_link, _nvmem, _hci, _event), |
Kojto | 45:50ab13d8f2dc | 58 | _wlan(_simple_link, _event, _spi, _hci) { |
Kojto | 20:30b6ed7bf8fd | 59 | _simple_link.set_tx_complete_signal(1); |
Kojto | 45:50ab13d8f2dc | 60 | memset(&_status, 0, sizeof(_status)); |
Kojto | 20:30b6ed7bf8fd | 61 | _inst = this; |
Kojto | 20:30b6ed7bf8fd | 62 | } |
Kojto | 20:30b6ed7bf8fd | 63 | |
Kojto | 20:30b6ed7bf8fd | 64 | cc3000::~cc3000() { |
Kojto | 20:30b6ed7bf8fd | 65 | } |
Kojto | 20:30b6ed7bf8fd | 66 | |
Kojto | 44:960b73df5981 | 67 | #if (CC3000_ETH_COMPAT == 1) |
Kojto | 45:50ab13d8f2dc | 68 | cc3000::cc3000(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, const char *ssid, |
Kojto | 45:50ab13d8f2dc | 69 | const char *phrase, Security sec, bool smart_config) |
Kojto | 45:50ab13d8f2dc | 70 | : _event(_simple_link, _hci, _spi, *this), _socket(_simple_link, _hci, _event), |
Kojto | 45:50ab13d8f2dc | 71 | _spi(cc3000_irq, cc3000_en, cc3000_cs, cc3000_spi, _event, _simple_link), _hci(_spi), |
Kojto | 45:50ab13d8f2dc | 72 | _nvmem(_hci, _event, _simple_link), _netapp(_simple_link, _nvmem, _hci, _event), |
Kojto | 45:50ab13d8f2dc | 73 | _wlan(_simple_link, _event, _spi, _hci), _sec(sec), _smart_config(smart_config) { |
Kojto | 45:50ab13d8f2dc | 74 | _simple_link.set_tx_complete_signal(1); |
Kojto | 45:50ab13d8f2dc | 75 | memset(&_status, 0, sizeof(_status)); |
Kojto | 45:50ab13d8f2dc | 76 | strcpy((char *)_ssid, ssid); |
Kojto | 45:50ab13d8f2dc | 77 | strcpy((char *)_phrase, phrase); |
Kojto | 45:50ab13d8f2dc | 78 | _inst = this; |
Kojto | 45:50ab13d8f2dc | 79 | } |
Kojto | 45:50ab13d8f2dc | 80 | |
SolderSplashLabs | 39:03ac37ab34eb | 81 | // Ethernet library compatible, functions return strings |
SolderSplashLabs | 39:03ac37ab34eb | 82 | // Caches the ipconfig from the usync callback |
Kojto | 45:50ab13d8f2dc | 83 | static char mac_addr[19]= "\0"; |
SolderSplashLabs | 39:03ac37ab34eb | 84 | static char ip_addr[17] = "\0"; |
SolderSplashLabs | 39:03ac37ab34eb | 85 | static char gateway[17] = "\0"; |
SolderSplashLabs | 39:03ac37ab34eb | 86 | static char networkmask[17] = "\0"; |
SolderSplashLabs | 39:03ac37ab34eb | 87 | |
Kojto | 45:50ab13d8f2dc | 88 | void cc3000::init() { |
Kojto | 45:50ab13d8f2dc | 89 | _wlan.start(0); |
Kojto | 45:50ab13d8f2dc | 90 | |
Kojto | 45:50ab13d8f2dc | 91 | uint32_t subnet[4] = {0}; |
Kojto | 45:50ab13d8f2dc | 92 | uint32_t ip[4] = {0}; |
Kojto | 45:50ab13d8f2dc | 93 | uint32_t getway[4] = {0}; |
Kojto | 45:50ab13d8f2dc | 94 | uint32_t dns[4] = {0}; |
Kojto | 45:50ab13d8f2dc | 95 | |
Kojto | 45:50ab13d8f2dc | 96 | _netapp.dhcp(ip, subnet, getway, dns); |
Kojto | 45:50ab13d8f2dc | 97 | _wlan.stop(); |
Kojto | 45:50ab13d8f2dc | 98 | wait(1); |
Kojto | 45:50ab13d8f2dc | 99 | _wlan.start(0); |
Kojto | 45:50ab13d8f2dc | 100 | |
Kojto | 45:50ab13d8f2dc | 101 | _status.enabled = 1; |
Kojto | 46:ca8c234997c0 | 102 | _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE); |
Kojto | 45:50ab13d8f2dc | 103 | } |
Kojto | 45:50ab13d8f2dc | 104 | |
Kojto | 45:50ab13d8f2dc | 105 | void cc3000::init(const char *ip, const char *mask, const char *gateway) { |
Kojto | 45:50ab13d8f2dc | 106 | _netapp.dhcp((uint32_t *)ip, (uint32_t *)mask, (uint32_t *)gateway, (uint32_t *)ip); //dns = ip |
Kojto | 45:50ab13d8f2dc | 107 | _wlan.stop(); |
Kojto | 45:50ab13d8f2dc | 108 | wait(1); |
Kojto | 45:50ab13d8f2dc | 109 | _wlan.start(0); |
Kojto | 45:50ab13d8f2dc | 110 | |
Kojto | 45:50ab13d8f2dc | 111 | _status.enabled = 1; |
Kojto | 46:ca8c234997c0 | 112 | _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE); |
Kojto | 45:50ab13d8f2dc | 113 | } |
Kojto | 45:50ab13d8f2dc | 114 | |
Kojto | 45:50ab13d8f2dc | 115 | int cc3000::connect(unsigned int timeout_ms) { |
Kojto | 45:50ab13d8f2dc | 116 | Timer t; |
Kojto | 45:50ab13d8f2dc | 117 | int ret = 0; |
Kojto | 45:50ab13d8f2dc | 118 | |
Kojto | 45:50ab13d8f2dc | 119 | if (_smart_config == false) { |
Kojto | 45:50ab13d8f2dc | 120 | _wlan.ioctl_set_connection_policy(0, 0, 0); |
Kojto | 45:50ab13d8f2dc | 121 | } else { |
Kojto | 45:50ab13d8f2dc | 122 | tUserFS user_info; |
Kojto | 45:50ab13d8f2dc | 123 | get_user_file_info((uint8_t *)&user_info, sizeof(user_info)); |
Kojto | 45:50ab13d8f2dc | 124 | if (user_info.FTC == 1) { |
Kojto | 45:50ab13d8f2dc | 125 | _wlan.ioctl_set_connection_policy(0, 1, 1); |
Kojto | 45:50ab13d8f2dc | 126 | } else { |
Kojto | 45:50ab13d8f2dc | 127 | DBG_CC("Smart config is not set. Please run the first time configuration."); |
Kojto | 45:50ab13d8f2dc | 128 | return -1; |
Kojto | 45:50ab13d8f2dc | 129 | } |
Kojto | 45:50ab13d8f2dc | 130 | } |
Kojto | 45:50ab13d8f2dc | 131 | |
Kojto | 45:50ab13d8f2dc | 132 | t.start(); |
Kojto | 45:50ab13d8f2dc | 133 | while (is_connected() == false) { |
Kojto | 45:50ab13d8f2dc | 134 | if (strlen((const char *)_phrase) < 8) { |
Kojto | 45:50ab13d8f2dc | 135 | if (connect_open(_ssid)) { |
Kojto | 45:50ab13d8f2dc | 136 | break; |
Kojto | 45:50ab13d8f2dc | 137 | } |
Kojto | 45:50ab13d8f2dc | 138 | } else { |
Kojto | 45:50ab13d8f2dc | 139 | #ifndef CC3000_TINY_DRIVER |
Kojto | 45:50ab13d8f2dc | 140 | if (connect_secure(_ssid,_phrase, _sec)) { |
Kojto | 45:50ab13d8f2dc | 141 | break; |
Kojto | 45:50ab13d8f2dc | 142 | } |
Kojto | 45:50ab13d8f2dc | 143 | #else |
Kojto | 45:50ab13d8f2dc | 144 | return -1; /* secure connection not supported with TINY_DRIVER */ |
Kojto | 45:50ab13d8f2dc | 145 | #endif |
Kojto | 45:50ab13d8f2dc | 146 | } |
Kojto | 45:50ab13d8f2dc | 147 | |
Kojto | 45:50ab13d8f2dc | 148 | if (t.read_ms() > timeout_ms) { |
Kojto | 45:50ab13d8f2dc | 149 | ret = -1; |
Kojto | 45:50ab13d8f2dc | 150 | DBG_CC("Connection to AP failed"); |
Kojto | 45:50ab13d8f2dc | 151 | break; |
Kojto | 45:50ab13d8f2dc | 152 | } |
Kojto | 45:50ab13d8f2dc | 153 | } |
Kojto | 45:50ab13d8f2dc | 154 | |
Kojto | 45:50ab13d8f2dc | 155 | while (is_dhcp_configured() == false) |
Kojto | 45:50ab13d8f2dc | 156 | { |
Kojto | 45:50ab13d8f2dc | 157 | if (t.read_ms() > timeout_ms) { |
Kojto | 45:50ab13d8f2dc | 158 | ret = -1; |
Kojto | 45:50ab13d8f2dc | 159 | DBG_CC("Connection to AP failed"); |
Kojto | 45:50ab13d8f2dc | 160 | break; |
Kojto | 45:50ab13d8f2dc | 161 | } |
Kojto | 45:50ab13d8f2dc | 162 | } |
Kojto | 45:50ab13d8f2dc | 163 | |
Kojto | 45:50ab13d8f2dc | 164 | return ret; |
Kojto | 45:50ab13d8f2dc | 165 | } |
Kojto | 45:50ab13d8f2dc | 166 | |
SolderSplashLabs | 39:03ac37ab34eb | 167 | char* cc3000::getMACAddress() { |
SolderSplashLabs | 39:03ac37ab34eb | 168 | return mac_addr; |
SolderSplashLabs | 39:03ac37ab34eb | 169 | } |
SolderSplashLabs | 39:03ac37ab34eb | 170 | |
SolderSplashLabs | 39:03ac37ab34eb | 171 | char* cc3000::getIPAddress() { |
SolderSplashLabs | 39:03ac37ab34eb | 172 | return ip_addr; |
SolderSplashLabs | 39:03ac37ab34eb | 173 | } |
SolderSplashLabs | 39:03ac37ab34eb | 174 | |
SolderSplashLabs | 39:03ac37ab34eb | 175 | char* cc3000::getGateway() { |
SolderSplashLabs | 39:03ac37ab34eb | 176 | return gateway; |
SolderSplashLabs | 39:03ac37ab34eb | 177 | } |
SolderSplashLabs | 39:03ac37ab34eb | 178 | |
SolderSplashLabs | 39:03ac37ab34eb | 179 | char* cc3000::getNetworkMask() { |
SolderSplashLabs | 39:03ac37ab34eb | 180 | return networkmask; |
SolderSplashLabs | 39:03ac37ab34eb | 181 | } |
Kojto | 45:50ab13d8f2dc | 182 | |
Kojto | 45:50ab13d8f2dc | 183 | int cc3000::disconnect(void){ |
Kojto | 45:50ab13d8f2dc | 184 | if (_wlan.disconnect()) { |
Kojto | 45:50ab13d8f2dc | 185 | return -1; |
Kojto | 45:50ab13d8f2dc | 186 | } else { |
Kojto | 45:50ab13d8f2dc | 187 | return 0; |
Kojto | 45:50ab13d8f2dc | 188 | } |
Kojto | 45:50ab13d8f2dc | 189 | } |
Kojto | 45:50ab13d8f2dc | 190 | |
SolderSplashLabs | 39:03ac37ab34eb | 191 | #endif |
SolderSplashLabs | 39:03ac37ab34eb | 192 | |
Kojto | 44:960b73df5981 | 193 | void cc3000::usync_callback(int32_t event_type, uint8_t *data, uint8_t length) { |
Kojto | 45:50ab13d8f2dc | 194 | if (event_type == HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE) { |
SolderSplashLabs | 41:eb1999bd50fb | 195 | DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE"); |
Kojto | 20:30b6ed7bf8fd | 196 | _status.smart_config_complete = 1; |
Kojto | 20:30b6ed7bf8fd | 197 | _status.stop_smart_config = 1; |
Kojto | 20:30b6ed7bf8fd | 198 | } |
Kojto | 20:30b6ed7bf8fd | 199 | |
Kojto | 45:50ab13d8f2dc | 200 | if (event_type == HCI_EVNT_WLAN_UNSOL_CONNECT) { |
SolderSplashLabs | 41:eb1999bd50fb | 201 | DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_CONNECT"); |
Kojto | 20:30b6ed7bf8fd | 202 | _status.connected = 1; |
SolderSplashLabs | 39:03ac37ab34eb | 203 | // Connect message is always followed by a DHCP message, connection is not useable until then |
SolderSplashLabs | 39:03ac37ab34eb | 204 | _status.dhcp = 0; |
Kojto | 20:30b6ed7bf8fd | 205 | } |
Kojto | 20:30b6ed7bf8fd | 206 | |
Kojto | 45:50ab13d8f2dc | 207 | if (event_type == HCI_EVNT_WLAN_UNSOL_DISCONNECT) { |
SolderSplashLabs | 41:eb1999bd50fb | 208 | DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DISCONNECT"); |
Kojto | 20:30b6ed7bf8fd | 209 | _status.connected = 0; |
Kojto | 20:30b6ed7bf8fd | 210 | _status.dhcp = 0; |
Kojto | 20:30b6ed7bf8fd | 211 | _status.dhcp_configured = 0; |
Kojto | 20:30b6ed7bf8fd | 212 | } |
Kojto | 20:30b6ed7bf8fd | 213 | |
Kojto | 45:50ab13d8f2dc | 214 | if (event_type == HCI_EVNT_WLAN_UNSOL_DHCP) { |
Kojto | 44:960b73df5981 | 215 | #if (CC3000_ETH_COMPAT == 1) |
SolderSplashLabs | 42:bd2c631a031a | 216 | _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_IP_OFFSET]))), ip_addr, 17); |
SolderSplashLabs | 42:bd2c631a031a | 217 | _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_GW_OFFSET]))), gateway, 17); |
SolderSplashLabs | 42:bd2c631a031a | 218 | _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_SUBNET_OFFSET]))), networkmask, 17); |
SolderSplashLabs | 42:bd2c631a031a | 219 | _socket.inet_ntoa_r( htonl(*((uint32_t *)(&data[NETAPP_IPCONFIG_MAC_OFFSET]))), mac_addr, 19); |
Kojto | 44:960b73df5981 | 220 | #endif |
Kojto | 44:960b73df5981 | 221 | if (*(data + NETAPP_IPCONFIG_MAC_OFFSET) == 0) { |
SolderSplashLabs | 41:eb1999bd50fb | 222 | _status.dhcp = 1; |
SolderSplashLabs | 41:eb1999bd50fb | 223 | DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP %i.%i.%i.%i", data[3], data[2], data[1], data[0]); |
SolderSplashLabs | 41:eb1999bd50fb | 224 | } else { |
SolderSplashLabs | 42:bd2c631a031a | 225 | DBG_CC("Callback : HCI_EVNT_WLAN_UNSOL_DHCP - Disconnecting"); |
SolderSplashLabs | 41:eb1999bd50fb | 226 | _status.dhcp = 0; |
SolderSplashLabs | 41:eb1999bd50fb | 227 | } |
Kojto | 20:30b6ed7bf8fd | 228 | } |
Kojto | 20:30b6ed7bf8fd | 229 | |
Kojto | 45:50ab13d8f2dc | 230 | if (event_type == HCI_EVENT_CC3000_CAN_SHUT_DOWN) { |
Kojto | 44:960b73df5981 | 231 | // Note this means the modules is idle, so it could be shutdown.. |
SolderSplashLabs | 41:eb1999bd50fb | 232 | //DBG_CC("Callback : HCI_EVENT_CC3000_CAN_SHUT_DOWN"); |
Kojto | 20:30b6ed7bf8fd | 233 | _status.ok_to_shut_down = 1; |
Kojto | 20:30b6ed7bf8fd | 234 | } |
Kojto | 20:30b6ed7bf8fd | 235 | |
Kojto | 45:50ab13d8f2dc | 236 | if (event_type == HCI_EVNT_WLAN_ASYNC_PING_REPORT) { |
SolderSplashLabs | 41:eb1999bd50fb | 237 | DBG_CC("Callback : HCI_EVNT_WLAN_ASYNC_PING_REPORT"); |
Kojto | 20:30b6ed7bf8fd | 238 | memcpy(&_ping_report, data, length); |
Kojto | 20:30b6ed7bf8fd | 239 | } |
Kojto | 20:30b6ed7bf8fd | 240 | |
Kojto | 20:30b6ed7bf8fd | 241 | if (event_type == HCI_EVNT_BSD_TCP_CLOSE_WAIT) { |
Kojto | 45:50ab13d8f2dc | 242 | uint8_t socketnum = data[0]; |
mfurseman | 47:86bb5f431c50 | 243 | // serial.printf("Socket closure reported: %d\r\n", socketnum); |
SolderSplashLabs | 41:eb1999bd50fb | 244 | DBG_CC("Callback : HCI_EVNT_BSD_TCP_CLOSE_WAIT - Socket : %d", socketnum); |
Kojto | 20:30b6ed7bf8fd | 245 | if (socketnum < MAX_SOCKETS) { |
Kojto | 20:30b6ed7bf8fd | 246 | _closed_sockets[socketnum] = true; /* clients socket is closed */ |
Kojto | 20:30b6ed7bf8fd | 247 | } |
Kojto | 20:30b6ed7bf8fd | 248 | } |
Kojto | 20:30b6ed7bf8fd | 249 | } |
Kojto | 20:30b6ed7bf8fd | 250 | |
Kojto | 20:30b6ed7bf8fd | 251 | void cc3000::start_smart_config(const uint8_t *smart_config_key) { |
SolderSplashLabs | 39:03ac37ab34eb | 252 | _status.smart_config_complete = 0; |
Kojto | 20:30b6ed7bf8fd | 253 | _wlan.ioctl_set_connection_policy(0, 0, 0); |
Kojto | 44:960b73df5981 | 254 | |
Kojto | 45:50ab13d8f2dc | 255 | if (_status.connected == 1) { |
SolderSplashLabs | 42:bd2c631a031a | 256 | disconnect(); |
SolderSplashLabs | 42:bd2c631a031a | 257 | } |
Kojto | 20:30b6ed7bf8fd | 258 | |
Kojto | 20:30b6ed7bf8fd | 259 | //Wait until CC3000 is disconected |
Kojto | 45:50ab13d8f2dc | 260 | while (_status.connected == 1) { |
Kojto | 20:30b6ed7bf8fd | 261 | wait_us(5); |
Kojto | 20:30b6ed7bf8fd | 262 | _event.hci_unsolicited_event_handler(); |
Kojto | 20:30b6ed7bf8fd | 263 | } |
Kojto | 20:30b6ed7bf8fd | 264 | |
Kojto | 20:30b6ed7bf8fd | 265 | // Trigger the Smart Config process |
Kojto | 20:30b6ed7bf8fd | 266 | _wlan.smart_config_set_prefix(cc3000_prefix); |
Kojto | 20:30b6ed7bf8fd | 267 | // Start the Smart Config process with AES disabled |
Kojto | 20:30b6ed7bf8fd | 268 | _wlan.smart_config_start(0); |
Kojto | 20:30b6ed7bf8fd | 269 | |
Kojto | 20:30b6ed7bf8fd | 270 | DBG_CC("Waiting for smartconfig to be completed"); |
Kojto | 20:30b6ed7bf8fd | 271 | |
Kojto | 20:30b6ed7bf8fd | 272 | // Wait for Smart config finished |
Kojto | 45:50ab13d8f2dc | 273 | while (_status.smart_config_complete == 0) { |
Kojto | 20:30b6ed7bf8fd | 274 | wait_ms(100); |
Kojto | 20:30b6ed7bf8fd | 275 | } |
Kojto | 20:30b6ed7bf8fd | 276 | |
Kojto | 20:30b6ed7bf8fd | 277 | DBG_CC("Smartconfig finished"); |
Kojto | 20:30b6ed7bf8fd | 278 | |
Kojto | 20:30b6ed7bf8fd | 279 | #ifndef CC3000_UNENCRYPTED_SMART_CONFIG |
Kojto | 20:30b6ed7bf8fd | 280 | // create new entry for AES encryption key |
Kojto | 20:30b6ed7bf8fd | 281 | _nvmem.create_entry(NVMEM_AES128_KEY_FILEID, 16); |
Kojto | 20:30b6ed7bf8fd | 282 | // write AES key to NVMEM |
Kojto | 20:30b6ed7bf8fd | 283 | _security.aes_write_key((uint8_t *)(&smart_config_key[0])); |
Kojto | 20:30b6ed7bf8fd | 284 | // Decrypt configuration information and add profile |
Kojto | 20:30b6ed7bf8fd | 285 | _wlan.smart_config_process(); |
Kojto | 20:30b6ed7bf8fd | 286 | #endif |
Kojto | 20:30b6ed7bf8fd | 287 | |
Kojto | 20:30b6ed7bf8fd | 288 | // Configure to connect automatically to the AP retrieved in the |
Kojto | 20:30b6ed7bf8fd | 289 | // Smart config process |
SolderSplashLabs | 39:03ac37ab34eb | 290 | _wlan.ioctl_set_connection_policy(0, 0, 1); |
Kojto | 20:30b6ed7bf8fd | 291 | |
Kojto | 20:30b6ed7bf8fd | 292 | // reset the CC3000 |
Kojto | 20:30b6ed7bf8fd | 293 | _wlan.stop(); |
SolderSplashLabs | 39:03ac37ab34eb | 294 | _status.enabled = 0; |
SolderSplashLabs | 39:03ac37ab34eb | 295 | wait(5); |
Kojto | 20:30b6ed7bf8fd | 296 | _wlan.start(0); |
SolderSplashLabs | 39:03ac37ab34eb | 297 | _status.enabled = 1; |
Kojto | 20:30b6ed7bf8fd | 298 | |
Kojto | 20:30b6ed7bf8fd | 299 | // Mask out all non-required events |
Kojto | 46:ca8c234997c0 | 300 | _wlan.set_event_mask(HCI_EVNT_WLAN_KEEPALIVE | HCI_EVNT_WLAN_UNSOL_INIT); |
Kojto | 20:30b6ed7bf8fd | 301 | } |
Kojto | 20:30b6ed7bf8fd | 302 | |
Kojto | 20:30b6ed7bf8fd | 303 | bool cc3000::connect_secure(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) { |
Kojto | 45:50ab13d8f2dc | 304 | #ifdef CC3000_TINY_DRIVER |
Kojto | 45:50ab13d8f2dc | 305 | return false; /* not supported*/ |
Kojto | 45:50ab13d8f2dc | 306 | #else |
Kojto | 20:30b6ed7bf8fd | 307 | uint32_t ret; |
Kojto | 20:30b6ed7bf8fd | 308 | |
SolderSplashLabs | 42:bd2c631a031a | 309 | //_wlan.disconnect(); |
Kojto | 20:30b6ed7bf8fd | 310 | wait_ms(3); |
Kojto | 20:30b6ed7bf8fd | 311 | ret = _wlan.connect(security_mode, ssid, strlen((const char *)ssid), 0, (uint8_t *)key, strlen((const char *)key)); |
Kojto | 20:30b6ed7bf8fd | 312 | if (ret == 0) { /* TODO static internal cc3000 state 0 to TRUE */ |
Kojto | 20:30b6ed7bf8fd | 313 | ret = true; |
Kojto | 20:30b6ed7bf8fd | 314 | } else { |
Kojto | 20:30b6ed7bf8fd | 315 | ret = false; |
Kojto | 20:30b6ed7bf8fd | 316 | } |
Kojto | 20:30b6ed7bf8fd | 317 | return ret; |
Kojto | 45:50ab13d8f2dc | 318 | #endif |
Kojto | 20:30b6ed7bf8fd | 319 | } |
Kojto | 20:30b6ed7bf8fd | 320 | |
Kojto | 44:960b73df5981 | 321 | bool cc3000::connect_non_blocking(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) |
SolderSplashLabs | 39:03ac37ab34eb | 322 | { |
Kojto | 45:50ab13d8f2dc | 323 | bool ret = false; |
SolderSplashLabs | 39:03ac37ab34eb | 324 | |
Kojto | 45:50ab13d8f2dc | 325 | if (key == 0) { |
Kojto | 45:50ab13d8f2dc | 326 | if (connect_open(ssid)) { |
SolderSplashLabs | 39:03ac37ab34eb | 327 | ret = true; |
SolderSplashLabs | 39:03ac37ab34eb | 328 | } |
Kojto | 45:50ab13d8f2dc | 329 | } else { |
SolderSplashLabs | 39:03ac37ab34eb | 330 | #ifndef CC3000_TINY_DRIVER |
Kojto | 45:50ab13d8f2dc | 331 | if (connect_secure(ssid,key,security_mode)) { |
SolderSplashLabs | 39:03ac37ab34eb | 332 | ret = true; |
SolderSplashLabs | 39:03ac37ab34eb | 333 | } |
SolderSplashLabs | 39:03ac37ab34eb | 334 | #else |
SolderSplashLabs | 39:03ac37ab34eb | 335 | /* secure connection not supported with TINY_DRIVER */ |
SolderSplashLabs | 39:03ac37ab34eb | 336 | #endif |
SolderSplashLabs | 39:03ac37ab34eb | 337 | } |
Kojto | 44:960b73df5981 | 338 | |
SolderSplashLabs | 39:03ac37ab34eb | 339 | return ret; |
SolderSplashLabs | 39:03ac37ab34eb | 340 | } |
SolderSplashLabs | 39:03ac37ab34eb | 341 | |
Kojto | 20:30b6ed7bf8fd | 342 | bool cc3000::connect_to_AP(const uint8_t *ssid, const uint8_t *key, int32_t security_mode) { |
Kojto | 45:50ab13d8f2dc | 343 | Timer t; |
Kojto | 20:30b6ed7bf8fd | 344 | bool ret = true; |
Kojto | 20:30b6ed7bf8fd | 345 | |
Kojto | 20:30b6ed7bf8fd | 346 | t.start(); |
Kojto | 20:30b6ed7bf8fd | 347 | while (is_connected() == false) { |
Kojto | 20:30b6ed7bf8fd | 348 | if (key == 0) { |
Kojto | 20:30b6ed7bf8fd | 349 | if (connect_open(ssid)) { |
Kojto | 20:30b6ed7bf8fd | 350 | break; |
Kojto | 20:30b6ed7bf8fd | 351 | } |
Kojto | 20:30b6ed7bf8fd | 352 | } else { |
Kojto | 20:30b6ed7bf8fd | 353 | #ifndef CC3000_TINY_DRIVER |
Kojto | 20:30b6ed7bf8fd | 354 | if (connect_secure(ssid,key,security_mode)) { |
Kojto | 20:30b6ed7bf8fd | 355 | break; |
Kojto | 20:30b6ed7bf8fd | 356 | } |
Kojto | 20:30b6ed7bf8fd | 357 | #else |
Kojto | 20:30b6ed7bf8fd | 358 | return false; /* secure connection not supported with TINY_DRIVER */ |
Kojto | 20:30b6ed7bf8fd | 359 | #endif |
Kojto | 20:30b6ed7bf8fd | 360 | } |
Kojto | 20:30b6ed7bf8fd | 361 | |
Kojto | 20:30b6ed7bf8fd | 362 | /* timeout 10 seconds */ |
Kojto | 45:50ab13d8f2dc | 363 | if (t.read_ms() > 10000) { |
Kojto | 20:30b6ed7bf8fd | 364 | ret = false; |
Kojto | 20:30b6ed7bf8fd | 365 | DBG_CC("Connection to AP failed"); |
Kojto | 20:30b6ed7bf8fd | 366 | break; |
Kojto | 20:30b6ed7bf8fd | 367 | } |
Kojto | 20:30b6ed7bf8fd | 368 | } |
Kojto | 20:30b6ed7bf8fd | 369 | |
Kojto | 20:30b6ed7bf8fd | 370 | return ret; |
Kojto | 20:30b6ed7bf8fd | 371 | } |
Kojto | 20:30b6ed7bf8fd | 372 | |
Kojto | 20:30b6ed7bf8fd | 373 | void cc3000::start(uint8_t patch) { |
Kojto | 20:30b6ed7bf8fd | 374 | _wlan.start(patch); |
SolderSplashLabs | 39:03ac37ab34eb | 375 | _status.enabled = 1; |
Kojto | 46:ca8c234997c0 | 376 | _wlan.set_event_mask(HCI_EVNT_WLAN_UNSOL_INIT | HCI_EVNT_WLAN_KEEPALIVE); |
Kojto | 20:30b6ed7bf8fd | 377 | } |
Kojto | 20:30b6ed7bf8fd | 378 | |
Kojto | 20:30b6ed7bf8fd | 379 | void cc3000::stop(void) { |
Kojto | 20:30b6ed7bf8fd | 380 | _wlan.stop(); |
SolderSplashLabs | 39:03ac37ab34eb | 381 | _status.enabled = 0; |
Kojto | 20:30b6ed7bf8fd | 382 | } |
Kojto | 20:30b6ed7bf8fd | 383 | |
Kojto | 20:30b6ed7bf8fd | 384 | void cc3000::restart(uint8_t patch) { |
Kojto | 20:30b6ed7bf8fd | 385 | _wlan.stop(); |
SolderSplashLabs | 39:03ac37ab34eb | 386 | _status.enabled = 0; |
Kojto | 20:30b6ed7bf8fd | 387 | wait_ms(500); |
Kojto | 20:30b6ed7bf8fd | 388 | _wlan.start(patch); |
SolderSplashLabs | 39:03ac37ab34eb | 389 | _status.enabled = 1; |
Kojto | 20:30b6ed7bf8fd | 390 | } |
Kojto | 20:30b6ed7bf8fd | 391 | |
Kojto | 20:30b6ed7bf8fd | 392 | bool cc3000::connect_open(const uint8_t *ssid) { |
Kojto | 20:30b6ed7bf8fd | 393 | _wlan.disconnect(); |
Kojto | 20:30b6ed7bf8fd | 394 | wait_ms(3); |
Kojto | 45:50ab13d8f2dc | 395 | uint32_t ret; |
Kojto | 20:30b6ed7bf8fd | 396 | #ifndef CC3000_TINY_DRIVER |
Kojto | 20:30b6ed7bf8fd | 397 | ret = _wlan.connect(0,ssid, strlen((const char *)ssid), 0, 0, 0); |
Kojto | 20:30b6ed7bf8fd | 398 | #else |
Kojto | 20:30b6ed7bf8fd | 399 | ret = _wlan.connect(ssid, strlen((const char *)ssid)); |
Kojto | 20:30b6ed7bf8fd | 400 | #endif |
Kojto | 20:30b6ed7bf8fd | 401 | if (ret == 0) { |
Kojto | 20:30b6ed7bf8fd | 402 | ret = true; |
Kojto | 20:30b6ed7bf8fd | 403 | } else { |
Kojto | 20:30b6ed7bf8fd | 404 | ret = false; |
Kojto | 20:30b6ed7bf8fd | 405 | } |
Kojto | 20:30b6ed7bf8fd | 406 | return ret; |
Kojto | 20:30b6ed7bf8fd | 407 | } |
Kojto | 20:30b6ed7bf8fd | 408 | |
SolderSplashLabs | 39:03ac37ab34eb | 409 | bool cc3000::is_enabled() |
SolderSplashLabs | 39:03ac37ab34eb | 410 | { |
SolderSplashLabs | 39:03ac37ab34eb | 411 | return _status.enabled; |
SolderSplashLabs | 39:03ac37ab34eb | 412 | } |
SolderSplashLabs | 39:03ac37ab34eb | 413 | |
Kojto | 20:30b6ed7bf8fd | 414 | bool cc3000::is_connected() { |
Kojto | 45:50ab13d8f2dc | 415 | if (( _status.connected ) && ( _status.dhcp )) { |
Kojto | 45:50ab13d8f2dc | 416 | return 1; |
Kojto | 45:50ab13d8f2dc | 417 | } else { |
Kojto | 45:50ab13d8f2dc | 418 | return 0; |
SolderSplashLabs | 42:bd2c631a031a | 419 | } |
Kojto | 20:30b6ed7bf8fd | 420 | } |
Kojto | 20:30b6ed7bf8fd | 421 | |
Kojto | 20:30b6ed7bf8fd | 422 | bool cc3000::is_dhcp_configured() { |
Kojto | 20:30b6ed7bf8fd | 423 | return _status.dhcp; |
Kojto | 20:30b6ed7bf8fd | 424 | } |
Kojto | 20:30b6ed7bf8fd | 425 | |
Kojto | 20:30b6ed7bf8fd | 426 | bool cc3000::is_smart_confing_completed() { |
Kojto | 20:30b6ed7bf8fd | 427 | return _status.smart_config_complete; |
Kojto | 20:30b6ed7bf8fd | 428 | } |
Kojto | 20:30b6ed7bf8fd | 429 | |
Kojto | 20:30b6ed7bf8fd | 430 | uint8_t cc3000::get_mac_address(uint8_t address[6]) { |
Kojto | 20:30b6ed7bf8fd | 431 | return _nvmem.get_mac_address(address); |
Kojto | 20:30b6ed7bf8fd | 432 | } |
Kojto | 20:30b6ed7bf8fd | 433 | |
Kojto | 20:30b6ed7bf8fd | 434 | uint8_t cc3000::set_mac_address(uint8_t address[6]) { |
Kojto | 20:30b6ed7bf8fd | 435 | return _nvmem.set_mac_address(address); |
Kojto | 20:30b6ed7bf8fd | 436 | } |
Kojto | 20:30b6ed7bf8fd | 437 | |
Kojto | 20:30b6ed7bf8fd | 438 | void cc3000::get_user_file_info(uint8_t *info_file, size_t size) { |
Kojto | 20:30b6ed7bf8fd | 439 | _nvmem.read( NVMEM_USER_FILE_1_FILEID, size, 0, info_file); |
Kojto | 20:30b6ed7bf8fd | 440 | } |
Kojto | 20:30b6ed7bf8fd | 441 | |
Kojto | 20:30b6ed7bf8fd | 442 | #ifndef CC3000_TINY_DRIVER |
Kojto | 20:30b6ed7bf8fd | 443 | bool cc3000::get_ip_config(tNetappIpconfigRetArgs *ip_config) { |
Kojto | 20:30b6ed7bf8fd | 444 | if ((_status.dhcp == false) || (_status.connected == false)) { |
Kojto | 20:30b6ed7bf8fd | 445 | return false; |
Kojto | 20:30b6ed7bf8fd | 446 | } |
Kojto | 20:30b6ed7bf8fd | 447 | |
Kojto | 20:30b6ed7bf8fd | 448 | _netapp.ipconfig(ip_config); |
Kojto | 20:30b6ed7bf8fd | 449 | return true; |
Kojto | 20:30b6ed7bf8fd | 450 | } |
Kojto | 20:30b6ed7bf8fd | 451 | #endif |
Kojto | 20:30b6ed7bf8fd | 452 | |
Kojto | 20:30b6ed7bf8fd | 453 | void cc3000::delete_profiles(void) { |
Kojto | 20:30b6ed7bf8fd | 454 | _wlan.ioctl_set_connection_policy(0, 0, 0); |
Kojto | 20:30b6ed7bf8fd | 455 | _wlan.ioctl_del_profile(255); |
Kojto | 20:30b6ed7bf8fd | 456 | |
Kojto | 45:50ab13d8f2dc | 457 | tUserFS user_info; |
Kojto | 20:30b6ed7bf8fd | 458 | get_user_file_info((uint8_t *)&user_info, sizeof(user_info)); |
Kojto | 20:30b6ed7bf8fd | 459 | user_info.FTC = 0; |
Kojto | 20:30b6ed7bf8fd | 460 | set_user_file_info((uint8_t *)&user_info, sizeof(user_info)); |
Kojto | 20:30b6ed7bf8fd | 461 | } |
Kojto | 20:30b6ed7bf8fd | 462 | |
Kojto | 20:30b6ed7bf8fd | 463 | void cc3000::set_user_file_info(uint8_t *info_file, size_t size) { |
Kojto | 20:30b6ed7bf8fd | 464 | _nvmem.write( NVMEM_USER_FILE_1_FILEID, size, 0, info_file); |
Kojto | 20:30b6ed7bf8fd | 465 | } |
Kojto | 20:30b6ed7bf8fd | 466 | |
Kojto | 20:30b6ed7bf8fd | 467 | uint32_t cc3000::ping(uint32_t ip, uint8_t attempts, uint16_t timeout, uint8_t size) { |
Kojto | 45:50ab13d8f2dc | 468 | #ifndef CC3000_TINY_DRIVER |
Kojto | 37:3332f57b7f1e | 469 | uint32_t reversed_ip = (ip >> 24) | ((ip >> 8) & 0xFF00) | ((ip << 8) & 0xFF0000) | (ip << 24); |
Kojto | 20:30b6ed7bf8fd | 470 | |
Kojto | 20:30b6ed7bf8fd | 471 | _ping_report.packets_received = 0; |
Kojto | 20:30b6ed7bf8fd | 472 | if (_netapp.ping_send(&reversed_ip, attempts, size, timeout) == -1) { |
Kojto | 20:30b6ed7bf8fd | 473 | DBG_CC("Failed to send ping"); |
Kojto | 20:30b6ed7bf8fd | 474 | return 0; |
Kojto | 20:30b6ed7bf8fd | 475 | } |
Kojto | 20:30b6ed7bf8fd | 476 | wait_ms(timeout*attempts*2); |
Kojto | 20:30b6ed7bf8fd | 477 | |
Kojto | 20:30b6ed7bf8fd | 478 | /* known issue of cc3000 - sent number is send + received */ |
Kojto | 20:30b6ed7bf8fd | 479 | // TODO : Remove the Sent/recv'd counts until ti fix the firmware issue? |
Kojto | 20:30b6ed7bf8fd | 480 | DBG_CC("Sent: %d",_ping_report.packets_sent); |
Kojto | 20:30b6ed7bf8fd | 481 | DBG_CC("Received: %d",_ping_report.packets_received); |
Kojto | 20:30b6ed7bf8fd | 482 | DBG_CC("Min time: %d",_ping_report.min_round_time); |
Kojto | 20:30b6ed7bf8fd | 483 | DBG_CC("Max time: %d",_ping_report.max_round_time); |
Kojto | 20:30b6ed7bf8fd | 484 | DBG_CC("Avg time: %d",_ping_report.avg_round_time); |
Kojto | 20:30b6ed7bf8fd | 485 | |
Kojto | 20:30b6ed7bf8fd | 486 | return _ping_report.packets_received; |
Kojto | 45:50ab13d8f2dc | 487 | #else |
Kojto | 45:50ab13d8f2dc | 488 | return 0; |
Kojto | 45:50ab13d8f2dc | 489 | #endif |
Kojto | 20:30b6ed7bf8fd | 490 | } |
Kojto | 20:30b6ed7bf8fd | 491 | |
Kojto | 20:30b6ed7bf8fd | 492 | /* Conversion between uint types and C strings */ |
Kojto | 20:30b6ed7bf8fd | 493 | uint8_t* UINT32_TO_STREAM_f (uint8_t *p, uint32_t u32) |
Kojto | 20:30b6ed7bf8fd | 494 | { |
Kojto | 20:30b6ed7bf8fd | 495 | *(p)++ = (uint8_t)(u32); |
Kojto | 20:30b6ed7bf8fd | 496 | *(p)++ = (uint8_t)((u32) >> 8); |
Kojto | 20:30b6ed7bf8fd | 497 | *(p)++ = (uint8_t)((u32) >> 16); |
Kojto | 20:30b6ed7bf8fd | 498 | *(p)++ = (uint8_t)((u32) >> 24); |
Kojto | 20:30b6ed7bf8fd | 499 | return p; |
Kojto | 20:30b6ed7bf8fd | 500 | } |
Kojto | 20:30b6ed7bf8fd | 501 | |
Kojto | 20:30b6ed7bf8fd | 502 | |
Kojto | 20:30b6ed7bf8fd | 503 | uint8_t* UINT16_TO_STREAM_f (uint8_t *p, uint16_t u16) |
Kojto | 20:30b6ed7bf8fd | 504 | { |
Kojto | 20:30b6ed7bf8fd | 505 | *(p)++ = (uint8_t)(u16); |
Kojto | 20:30b6ed7bf8fd | 506 | *(p)++ = (uint8_t)((u16) >> 8); |
Kojto | 20:30b6ed7bf8fd | 507 | return p; |
Kojto | 20:30b6ed7bf8fd | 508 | } |
Kojto | 20:30b6ed7bf8fd | 509 | |
Kojto | 20:30b6ed7bf8fd | 510 | |
Kojto | 20:30b6ed7bf8fd | 511 | uint16_t STREAM_TO_UINT16_f(uint8_t *p, uint16_t offset) |
Kojto | 20:30b6ed7bf8fd | 512 | { |
Kojto | 20:30b6ed7bf8fd | 513 | return (uint16_t)((uint16_t)((uint16_t) |
Kojto | 20:30b6ed7bf8fd | 514 | (*(p + offset + 1)) << 8) + (uint16_t)(*(p + offset))); |
Kojto | 20:30b6ed7bf8fd | 515 | } |
Kojto | 20:30b6ed7bf8fd | 516 | |
Kojto | 20:30b6ed7bf8fd | 517 | |
Kojto | 20:30b6ed7bf8fd | 518 | uint32_t STREAM_TO_UINT32_f(uint8_t *p, uint16_t offset) |
Kojto | 20:30b6ed7bf8fd | 519 | { |
Kojto | 20:30b6ed7bf8fd | 520 | return (uint32_t)((uint32_t)((uint32_t) |
Kojto | 20:30b6ed7bf8fd | 521 | (*(p + offset + 3)) << 24) + (uint32_t)((uint32_t) |
Kojto | 20:30b6ed7bf8fd | 522 | (*(p + offset + 2)) << 16) + (uint32_t)((uint32_t) |
Kojto | 20:30b6ed7bf8fd | 523 | (*(p + offset + 1)) << 8) + (uint32_t)(*(p + offset))); |
Kojto | 20:30b6ed7bf8fd | 524 | } |
Kojto | 20:30b6ed7bf8fd | 525 | |
Kojto | 45:50ab13d8f2dc | 526 | } // mbed_cc3000 namespace |
Kojto | 20:30b6ed7bf8fd | 527 |