TI's CC3100. A test demo with very little testing done!

Dependencies:   mbed

Fork of cc3100_Test_Demo2 by 高 杨

Committer:
gaoyang
Date:
Sun Jul 30 06:32:08 2017 +0000
Revision:
9:b8da46b97970
Parent:
5:d3b320ebd469
DAS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 5:d3b320ebd469 1 /*
dflet 5:d3b320ebd469 2 * - CC31xx/CC32xx Host Driver Implementation
dflet 5:d3b320ebd469 3 *
dflet 5:d3b320ebd469 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 5:d3b320ebd469 5 *
dflet 5:d3b320ebd469 6 *
dflet 5:d3b320ebd469 7 * Redistribution and use in source and binary forms, with or without
dflet 5:d3b320ebd469 8 * modification, are permitted provided that the following conditions
dflet 5:d3b320ebd469 9 * are met:
dflet 5:d3b320ebd469 10 *
dflet 5:d3b320ebd469 11 * Redistributions of source code must retain the above copyright
dflet 5:d3b320ebd469 12 * notice, this list of conditions and the following disclaimer.
dflet 5:d3b320ebd469 13 *
dflet 5:d3b320ebd469 14 * Redistributions in binary form must reproduce the above copyright
dflet 5:d3b320ebd469 15 * notice, this list of conditions and the following disclaimer in the
dflet 5:d3b320ebd469 16 * documentation and/or other materials provided with the
dflet 5:d3b320ebd469 17 * distribution.
dflet 5:d3b320ebd469 18 *
dflet 5:d3b320ebd469 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 5:d3b320ebd469 20 * its contributors may be used to endorse or promote products derived
dflet 5:d3b320ebd469 21 * from this software without specific prior written permission.
dflet 5:d3b320ebd469 22 *
dflet 5:d3b320ebd469 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 5:d3b320ebd469 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 5:d3b320ebd469 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 5:d3b320ebd469 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 5:d3b320ebd469 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 5:d3b320ebd469 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 5:d3b320ebd469 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 5:d3b320ebd469 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 5:d3b320ebd469 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 5:d3b320ebd469 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 5:d3b320ebd469 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 5:d3b320ebd469 34 *
dflet 5:d3b320ebd469 35 */
dflet 5:d3b320ebd469 36
dflet 5:d3b320ebd469 37 #ifndef fPtr_func_h
dflet 5:d3b320ebd469 38 #define fPtr_func_h
dflet 5:d3b320ebd469 39
dflet 5:d3b320ebd469 40 #include "cc3100_simplelink.h"
dflet 5:d3b320ebd469 41
dflet 5:d3b320ebd469 42
dflet 5:d3b320ebd469 43 /* Note. C function pointers point to the functions below. */
dflet 5:d3b320ebd469 44 /* C++ member function pointers not used ? */
dflet 5:d3b320ebd469 45
dflet 5:d3b320ebd469 46 namespace mbed_cc3100 {
dflet 5:d3b320ebd469 47
dflet 5:d3b320ebd469 48
dflet 5:d3b320ebd469 49 extern uint32_t g_PingPacketsRecv;
dflet 5:d3b320ebd469 50 extern uint32_t g_GatewayIP;
dflet 5:d3b320ebd469 51 extern uint32_t g_StationIP;
dflet 5:d3b320ebd469 52 extern uint32_t g_DestinationIP;
dflet 5:d3b320ebd469 53 extern uint32_t g_BytesReceived; // variable to store the file size
dflet 5:d3b320ebd469 54 extern uint32_t g_Status;
dflet 5:d3b320ebd469 55 extern uint8_t g_buff[MAX_BUFF_SIZE+1];
dflet 5:d3b320ebd469 56 extern int32_t g_SockID;
dflet 5:d3b320ebd469 57
dflet 5:d3b320ebd469 58 }//namespace mbed_cc3100
dflet 5:d3b320ebd469 59
dflet 5:d3b320ebd469 60 using namespace mbed_cc3100;
dflet 5:d3b320ebd469 61
dflet 5:d3b320ebd469 62 #ifdef __cplusplus
dflet 5:d3b320ebd469 63 extern "C" {
dflet 5:d3b320ebd469 64 #endif
dflet 5:d3b320ebd469 65
dflet 5:d3b320ebd469 66
dflet 5:d3b320ebd469 67 void SimpleLinkPingReport(SlPingReport_t *pPingReport);
dflet 5:d3b320ebd469 68
dflet 5:d3b320ebd469 69 /*!
dflet 5:d3b320ebd469 70 \brief WLAN Async event handler
dflet 5:d3b320ebd469 71
dflet 5:d3b320ebd469 72 \param[out] pSlWlanEvent pointer to SlWlanEvent_t data
dflet 5:d3b320ebd469 73
dflet 5:d3b320ebd469 74 \par
dflet 5:d3b320ebd469 75 Parameters:
dflet 5:d3b320ebd469 76
dflet 5:d3b320ebd469 77 - <b>pSlWlanEvent->Event = SL_WLAN_CONNECT_EVENT </b>, STA or P2P client connection indication event
dflet 5:d3b320ebd469 78 - pSlWlanEvent->EventData.STAandP2PModeWlanConnected main fields:
dflet 5:d3b320ebd469 79 - ssid_name
dflet 5:d3b320ebd469 80 - ssid_len
dflet 5:d3b320ebd469 81 - bssid
dflet 5:d3b320ebd469 82 - go_peer_device_name
dflet 5:d3b320ebd469 83 - go_peer_device_name_len
dflet 5:d3b320ebd469 84
dflet 5:d3b320ebd469 85 - <b>pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT </b>, STA or P2P client disconnection event
dflet 5:d3b320ebd469 86 - pSlWlanEvent->EventData.STAandP2PModeDisconnected main fields:
dflet 5:d3b320ebd469 87 - ssid_name
dflet 5:d3b320ebd469 88 - ssid_len
dflet 5:d3b320ebd469 89 - reason_code
dflet 5:d3b320ebd469 90
dflet 5:d3b320ebd469 91 - <b>pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT </b>, AP/P2P(Go) connected STA/P2P(Client)
dflet 5:d3b320ebd469 92 - pSlWlanEvent->EventData.APModeStaConnected fields:
dflet 5:d3b320ebd469 93 - go_peer_device_name
dflet 5:d3b320ebd469 94 - mac
dflet 5:d3b320ebd469 95 - go_peer_device_name_len
dflet 5:d3b320ebd469 96 - wps_dev_password_id
dflet 5:d3b320ebd469 97 - own_ssid: relevant for event sta-connected only
dflet 5:d3b320ebd469 98 - own_ssid_len: relevant for event sta-connected only
dflet 5:d3b320ebd469 99
dflet 5:d3b320ebd469 100 - <b>pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT </b>, AP/P2P(Go) disconnected STA/P2P(Client)
dflet 5:d3b320ebd469 101 - pSlWlanEvent->EventData.APModestaDisconnected fields:
dflet 5:d3b320ebd469 102 - go_peer_device_name
dflet 5:d3b320ebd469 103 - mac
dflet 5:d3b320ebd469 104 - go_peer_device_name_len
dflet 5:d3b320ebd469 105 - wps_dev_password_id
dflet 5:d3b320ebd469 106 - own_ssid: relevant for event sta-connected only
dflet 5:d3b320ebd469 107 - own_ssid_len: relevant for event sta-connected only
dflet 5:d3b320ebd469 108
dflet 5:d3b320ebd469 109 - <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT </b>
dflet 5:d3b320ebd469 110 - pSlWlanEvent->EventData.smartConfigStartResponse fields:
dflet 5:d3b320ebd469 111 - status
dflet 5:d3b320ebd469 112 - ssid_len
dflet 5:d3b320ebd469 113 - ssid
dflet 5:d3b320ebd469 114 - private_token_len
dflet 5:d3b320ebd469 115 - private_token
dflet 5:d3b320ebd469 116
dflet 5:d3b320ebd469 117 - <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT </b>
dflet 5:d3b320ebd469 118 - pSlWlanEvent->EventData.smartConfigStopResponse fields:
dflet 5:d3b320ebd469 119 - status
dflet 5:d3b320ebd469 120
dflet 5:d3b320ebd469 121 - <b>pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT </b>
dflet 5:d3b320ebd469 122 - pSlWlanEvent->EventData.P2PModeDevFound fields:
dflet 5:d3b320ebd469 123 - go_peer_device_name
dflet 5:d3b320ebd469 124 - mac
dflet 5:d3b320ebd469 125 - go_peer_device_name_len
dflet 5:d3b320ebd469 126 - wps_dev_password_id
dflet 5:d3b320ebd469 127 - own_ssid: relevant for event sta-connected only
dflet 5:d3b320ebd469 128 - own_ssid_len: relevant for event sta-connected only
dflet 5:d3b320ebd469 129
dflet 5:d3b320ebd469 130 - <b>pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT </b>
dflet 5:d3b320ebd469 131 - pSlWlanEvent->EventData.P2PModeNegReqReceived fields
dflet 5:d3b320ebd469 132 - go_peer_device_name
dflet 5:d3b320ebd469 133 - mac
dflet 5:d3b320ebd469 134 - go_peer_device_name_len
dflet 5:d3b320ebd469 135 - wps_dev_password_id
dflet 5:d3b320ebd469 136 - own_ssid: relevant for event sta-connected only
dflet 5:d3b320ebd469 137
dflet 5:d3b320ebd469 138 - <b>pSlWlanEvent->Event = SL_WLAN_CONNECTION_FAILED_EVENT </b>, P2P only
dflet 5:d3b320ebd469 139 - pSlWlanEvent->EventData.P2PModewlanConnectionFailure fields:
dflet 5:d3b320ebd469 140 - status
dflet 5:d3b320ebd469 141 */
dflet 5:d3b320ebd469 142 #if (defined(sl_WlanEvtHdlr))
dflet 5:d3b320ebd469 143 void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent);
dflet 5:d3b320ebd469 144 #endif
dflet 5:d3b320ebd469 145
dflet 5:d3b320ebd469 146 /*!
dflet 5:d3b320ebd469 147 \brief NETAPP Async event handler
dflet 5:d3b320ebd469 148
dflet 5:d3b320ebd469 149 \param[out] pSlNetApp pointer to SlNetAppEvent_t data
dflet 5:d3b320ebd469 150
dflet 5:d3b320ebd469 151 \par
dflet 5:d3b320ebd469 152 Parameters:
dflet 5:d3b320ebd469 153 - <b>pSlWlanEvent->Event = SL_NETAPP_IPV4_IPACQUIRED_EVENT</b>, IPV4 acquired event
dflet 5:d3b320ebd469 154 - pSlWlanEvent->EventData.ipAcquiredV4 fields:
dflet 5:d3b320ebd469 155 - ip
dflet 5:d3b320ebd469 156 - gateway
dflet 5:d3b320ebd469 157 - dns
dflet 5:d3b320ebd469 158
dflet 5:d3b320ebd469 159 - <b>pSlWlanEvent->Event = SL_NETAPP_IP_LEASED_EVENT</b>, AP or P2P go dhcp lease event
dflet 5:d3b320ebd469 160 - pSlWlanEvent->EventData.ipLeased fields:
dflet 5:d3b320ebd469 161 - ip_address
dflet 5:d3b320ebd469 162 - lease_time
dflet 5:d3b320ebd469 163 - mac
dflet 5:d3b320ebd469 164
dflet 5:d3b320ebd469 165 - <b>pSlWlanEvent->Event = SL_NETAPP_IP_RELEASED_EVENT</b>, AP or P2P go dhcp ip release event
dflet 5:d3b320ebd469 166 - pSlWlanEvent->EventData.ipReleased fields
dflet 5:d3b320ebd469 167 - ip_address
dflet 5:d3b320ebd469 168 - mac
dflet 5:d3b320ebd469 169 - reason
dflet 5:d3b320ebd469 170
dflet 5:d3b320ebd469 171 */
dflet 5:d3b320ebd469 172 #if (defined(sl_NetAppEvtHdlr))
dflet 5:d3b320ebd469 173 void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent);
dflet 5:d3b320ebd469 174 #endif
dflet 5:d3b320ebd469 175
dflet 5:d3b320ebd469 176 /*!
dflet 5:d3b320ebd469 177 \brief Socket Async event handler
dflet 5:d3b320ebd469 178
dflet 5:d3b320ebd469 179 \param[out] pSlSockEvent pointer to SlSockEvent_t data
dflet 5:d3b320ebd469 180
dflet 5:d3b320ebd469 181 \par
dflet 5:d3b320ebd469 182 Parameters:\n
dflet 5:d3b320ebd469 183 - <b>pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT</b>
dflet 5:d3b320ebd469 184 - pSlSockEvent->EventData fields:
dflet 5:d3b320ebd469 185 - sd
dflet 5:d3b320ebd469 186 - status
dflet 5:d3b320ebd469 187 - <b>pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT</b>
dflet 5:d3b320ebd469 188 - pSlSockEvent->EventData fields:
dflet 5:d3b320ebd469 189 - sd
dflet 5:d3b320ebd469 190 - type: SSL_ACCEPT or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED
dflet 5:d3b320ebd469 191 - val
dflet 5:d3b320ebd469 192
dflet 5:d3b320ebd469 193 */
dflet 5:d3b320ebd469 194 #if (defined(sl_SockEvtHdlr))
dflet 5:d3b320ebd469 195 void SimpleLinkSockEventHandler(SlSockEvent_t *pSock);
dflet 5:d3b320ebd469 196 #endif
dflet 5:d3b320ebd469 197
dflet 5:d3b320ebd469 198 void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent);
dflet 5:d3b320ebd469 199
dflet 5:d3b320ebd469 200 void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pHttpEvent, SlHttpServerResponse_t *pHttpResponse);
dflet 5:d3b320ebd469 201 #ifndef SL_TINY_EXT
dflet 5:d3b320ebd469 202 void _sl_HandleAsync_Accept(void *pVoidBuf);
dflet 5:d3b320ebd469 203
dflet 5:d3b320ebd469 204 void _sl_HandleAsync_Select(void *pVoidBuf);
dflet 5:d3b320ebd469 205
dflet 5:d3b320ebd469 206 void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf);
dflet 5:d3b320ebd469 207
dflet 5:d3b320ebd469 208 void _sl_HandleAsync_PingResponse(void *pVoidBuf);
dflet 5:d3b320ebd469 209 #endif
dflet 5:d3b320ebd469 210 void _sl_HandleAsync_Connect(void *pVoidBuf);
dflet 5:d3b320ebd469 211
dflet 5:d3b320ebd469 212 void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf);
dflet 5:d3b320ebd469 213
dflet 5:d3b320ebd469 214 void _sl_HandleAsync_Stop(void *pVoidBuf);
dflet 5:d3b320ebd469 215
dflet 5:d3b320ebd469 216 _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue);
dflet 5:d3b320ebd469 217
dflet 5:d3b320ebd469 218 void _SlDrvDeviceEventHandler(void *pArgs);
dflet 5:d3b320ebd469 219
dflet 5:d3b320ebd469 220 void _SlDrvNetAppEventHandler(void *pArgs);
dflet 5:d3b320ebd469 221
dflet 5:d3b320ebd469 222 void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse);
dflet 5:d3b320ebd469 223 void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent);
dflet 5:d3b320ebd469 224 void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent);
dflet 5:d3b320ebd469 225 void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent);
dflet 5:d3b320ebd469 226 void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent);
dflet 5:d3b320ebd469 227
dflet 5:d3b320ebd469 228 #ifdef __cplusplus
dflet 5:d3b320ebd469 229 }
dflet 5:d3b320ebd469 230 #endif /* __cplusplus */
dflet 5:d3b320ebd469 231
dflet 5:d3b320ebd469 232 //}//namespace mbed_cc3100
dflet 5:d3b320ebd469 233
dflet 5:d3b320ebd469 234 #endif//fPtr_func_h
dflet 5:d3b320ebd469 235
dflet 5:d3b320ebd469 236
dflet 5:d3b320ebd469 237
dflet 5:d3b320ebd469 238
dflet 5:d3b320ebd469 239
dflet 5:d3b320ebd469 240
dflet 5:d3b320ebd469 241