Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
G_functions/fPtr_func.cpp@4:5af740da0a59, 2015-02-23 (annotated)
- Committer:
- dflet
- Date:
- Mon Feb 23 21:10:13 2015 +0000
- Revision:
- 4:5af740da0a59
- Parent:
- 1:c73566c6788a
Added eye candy in some of the event handlers, made a few changes to SL_IPV4_BYTE to correct errors.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dflet | 0:e89ba455dbcf | 1 | /* |
| dflet | 0:e89ba455dbcf | 2 | * - CC31xx/CC32xx Host Driver Implementation |
| dflet | 0:e89ba455dbcf | 3 | * |
| dflet | 0:e89ba455dbcf | 4 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ |
| dflet | 0:e89ba455dbcf | 5 | * |
| dflet | 0:e89ba455dbcf | 6 | * |
| dflet | 0:e89ba455dbcf | 7 | * Redistribution and use in source and binary forms, with or without |
| dflet | 0:e89ba455dbcf | 8 | * modification, are permitted provided that the following conditions |
| dflet | 0:e89ba455dbcf | 9 | * are met: |
| dflet | 0:e89ba455dbcf | 10 | * |
| dflet | 0:e89ba455dbcf | 11 | * Redistributions of source code must retain the above copyright |
| dflet | 0:e89ba455dbcf | 12 | * notice, this list of conditions and the following disclaimer. |
| dflet | 0:e89ba455dbcf | 13 | * |
| dflet | 0:e89ba455dbcf | 14 | * Redistributions in binary form must reproduce the above copyright |
| dflet | 0:e89ba455dbcf | 15 | * notice, this list of conditions and the following disclaimer in the |
| dflet | 0:e89ba455dbcf | 16 | * documentation and/or other materials provided with the |
| dflet | 0:e89ba455dbcf | 17 | * distribution. |
| dflet | 0:e89ba455dbcf | 18 | * |
| dflet | 0:e89ba455dbcf | 19 | * Neither the name of Texas Instruments Incorporated nor the names of |
| dflet | 0:e89ba455dbcf | 20 | * its contributors may be used to endorse or promote products derived |
| dflet | 0:e89ba455dbcf | 21 | * from this software without specific prior written permission. |
| dflet | 0:e89ba455dbcf | 22 | * |
| dflet | 0:e89ba455dbcf | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| dflet | 0:e89ba455dbcf | 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| dflet | 0:e89ba455dbcf | 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| dflet | 0:e89ba455dbcf | 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| dflet | 0:e89ba455dbcf | 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| dflet | 0:e89ba455dbcf | 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| dflet | 0:e89ba455dbcf | 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| dflet | 0:e89ba455dbcf | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| dflet | 0:e89ba455dbcf | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| dflet | 0:e89ba455dbcf | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| dflet | 0:e89ba455dbcf | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| dflet | 0:e89ba455dbcf | 34 | * |
| dflet | 0:e89ba455dbcf | 35 | */ |
| dflet | 1:c73566c6788a | 36 | |
| dflet | 0:e89ba455dbcf | 37 | #include "cc3100_simplelink.h" |
| dflet | 0:e89ba455dbcf | 38 | |
| dflet | 0:e89ba455dbcf | 39 | #include "cc3100.h" |
| dflet | 0:e89ba455dbcf | 40 | #include "fPtr_func.h" |
| dflet | 0:e89ba455dbcf | 41 | |
| dflet | 0:e89ba455dbcf | 42 | |
| dflet | 0:e89ba455dbcf | 43 | using namespace mbed_cc3100; |
| dflet | 0:e89ba455dbcf | 44 | |
| dflet | 0:e89ba455dbcf | 45 | cc3100_driver *_driver; |
| dflet | 0:e89ba455dbcf | 46 | cc3100_nonos *_nonos; |
| dflet | 0:e89ba455dbcf | 47 | cc3100_netapp *_netapp; |
| dflet | 0:e89ba455dbcf | 48 | cc3100 *_cc3100_; |
| dflet | 0:e89ba455dbcf | 49 | |
| dflet | 0:e89ba455dbcf | 50 | #ifdef __cplusplus |
| dflet | 0:e89ba455dbcf | 51 | extern "C" { |
| dflet | 0:e89ba455dbcf | 52 | #endif |
| dflet | 0:e89ba455dbcf | 53 | |
| dflet | 0:e89ba455dbcf | 54 | /*! |
| dflet | 0:e89ba455dbcf | 55 | \brief This function handles ping report events |
| dflet | 0:e89ba455dbcf | 56 | |
| dflet | 0:e89ba455dbcf | 57 | \param[in] pPingReport holds the ping report statistics |
| dflet | 0:e89ba455dbcf | 58 | |
| dflet | 0:e89ba455dbcf | 59 | \return None |
| dflet | 0:e89ba455dbcf | 60 | |
| dflet | 0:e89ba455dbcf | 61 | \note |
| dflet | 0:e89ba455dbcf | 62 | |
| dflet | 0:e89ba455dbcf | 63 | \warning |
| dflet | 0:e89ba455dbcf | 64 | */ |
| dflet | 0:e89ba455dbcf | 65 | void SimpleLinkPingReport(SlPingReport_t *pPingReport) |
| dflet | 0:e89ba455dbcf | 66 | { |
| dflet | 0:e89ba455dbcf | 67 | _cc3100_->SET_STATUS_BIT(g_Status, STATUS_BIT_PING_DONE); |
| dflet | 0:e89ba455dbcf | 68 | |
| dflet | 0:e89ba455dbcf | 69 | if(pPingReport == NULL) |
| dflet | 0:e89ba455dbcf | 70 | printf(" [PING REPORT] NULL Pointer Error\r\n"); |
| dflet | 0:e89ba455dbcf | 71 | |
| dflet | 0:e89ba455dbcf | 72 | g_PingPacketsRecv = pPingReport->PacketsReceived; |
| dflet | 0:e89ba455dbcf | 73 | } |
| dflet | 0:e89ba455dbcf | 74 | |
| dflet | 0:e89ba455dbcf | 75 | |
| dflet | 0:e89ba455dbcf | 76 | /*******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 77 | /* _sl_HandleAsync_Accept */ |
| dflet | 0:e89ba455dbcf | 78 | /*******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 79 | void _sl_HandleAsync_Accept(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 80 | { |
| dflet | 0:e89ba455dbcf | 81 | _SocketAddrResponse_u *pMsgArgs = (_SocketAddrResponse_u *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 82 | |
| dflet | 0:e89ba455dbcf | 83 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER)); |
| dflet | 0:e89ba455dbcf | 84 | |
| dflet | 0:e89ba455dbcf | 85 | VERIFY_PROTOCOL(( pMsgArgs->IpV4.sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); |
| dflet | 0:e89ba455dbcf | 86 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
| dflet | 0:e89ba455dbcf | 87 | |
| dflet | 0:e89ba455dbcf | 88 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs,sizeof(_SocketAddrResponse_u)); |
| dflet | 0:e89ba455dbcf | 89 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 90 | |
| dflet | 0:e89ba455dbcf | 91 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 92 | return; |
| dflet | 0:e89ba455dbcf | 93 | } |
| dflet | 0:e89ba455dbcf | 94 | |
| dflet | 0:e89ba455dbcf | 95 | /*******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 96 | /* _sl_HandleAsync_Connect */ |
| dflet | 0:e89ba455dbcf | 97 | /*******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 98 | void _sl_HandleAsync_Connect(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 99 | { |
| dflet | 0:e89ba455dbcf | 100 | _SocketResponse_t *pMsgArgs = (_SocketResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 101 | |
| dflet | 0:e89ba455dbcf | 102 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER)); |
| dflet | 0:e89ba455dbcf | 103 | |
| dflet | 0:e89ba455dbcf | 104 | VERIFY_PROTOCOL((pMsgArgs->sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); |
| dflet | 0:e89ba455dbcf | 105 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
| dflet | 0:e89ba455dbcf | 106 | |
| dflet | 0:e89ba455dbcf | 107 | ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->sd = pMsgArgs->sd; |
| dflet | 0:e89ba455dbcf | 108 | ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->statusOrLen = pMsgArgs->statusOrLen; |
| dflet | 0:e89ba455dbcf | 109 | |
| dflet | 0:e89ba455dbcf | 110 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 111 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 112 | return; |
| dflet | 0:e89ba455dbcf | 113 | } |
| dflet | 0:e89ba455dbcf | 114 | |
| dflet | 0:e89ba455dbcf | 115 | /*******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 116 | /* _sl_HandleAsync_Select */ |
| dflet | 0:e89ba455dbcf | 117 | /*******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 118 | void _sl_HandleAsync_Select(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 119 | { |
| dflet | 0:e89ba455dbcf | 120 | _SelectAsyncResponse_t *pMsgArgs = (_SelectAsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 121 | |
| dflet | 0:e89ba455dbcf | 122 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER)); |
| dflet | 0:e89ba455dbcf | 123 | |
| dflet | 0:e89ba455dbcf | 124 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
| dflet | 0:e89ba455dbcf | 125 | |
| dflet | 0:e89ba455dbcf | 126 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_SelectAsyncResponse_t)); |
| dflet | 0:e89ba455dbcf | 127 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 128 | |
| dflet | 0:e89ba455dbcf | 129 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 130 | return; |
| dflet | 0:e89ba455dbcf | 131 | } |
| dflet | 0:e89ba455dbcf | 132 | |
| dflet | 0:e89ba455dbcf | 133 | /******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 134 | /* _sl_HandleAsync_DnsGetHostByName */ |
| dflet | 0:e89ba455dbcf | 135 | /******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 136 | void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 137 | { |
| dflet | 0:e89ba455dbcf | 138 | _GetHostByNameIPv4AsyncResponse_t *pMsgArgs = (_GetHostByNameIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 139 | |
| dflet | 0:e89ba455dbcf | 140 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER)); |
| dflet | 0:e89ba455dbcf | 141 | |
| dflet | 0:e89ba455dbcf | 142 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
| dflet | 0:e89ba455dbcf | 143 | |
| dflet | 0:e89ba455dbcf | 144 | /*IPv6 */ |
| dflet | 0:e89ba455dbcf | 145 | if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { |
| dflet | 0:e89ba455dbcf | 146 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv6AsyncResponse_t)); |
| dflet | 0:e89ba455dbcf | 147 | } |
| dflet | 0:e89ba455dbcf | 148 | /*IPv4 */ |
| dflet | 0:e89ba455dbcf | 149 | else { |
| dflet | 0:e89ba455dbcf | 150 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv4AsyncResponse_t)); |
| dflet | 0:e89ba455dbcf | 151 | } |
| dflet | 0:e89ba455dbcf | 152 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 153 | |
| dflet | 0:e89ba455dbcf | 154 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 155 | return; |
| dflet | 0:e89ba455dbcf | 156 | } |
| dflet | 0:e89ba455dbcf | 157 | |
| dflet | 0:e89ba455dbcf | 158 | /******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 159 | |
| dflet | 0:e89ba455dbcf | 160 | /****************************************************************************** |
| dflet | 0:e89ba455dbcf | 161 | _sl_HandleAsync_DnsGetHostByService |
| dflet | 0:e89ba455dbcf | 162 | |
| dflet | 0:e89ba455dbcf | 163 | CALLER NWP - Async event on sl_DnsGetHostByService with IPv4 Family |
| dflet | 0:e89ba455dbcf | 164 | |
| dflet | 0:e89ba455dbcf | 165 | |
| dflet | 0:e89ba455dbcf | 166 | DESCRIPTION: |
| dflet | 0:e89ba455dbcf | 167 | |
| dflet | 0:e89ba455dbcf | 168 | Async event on sl_DnsGetHostByService command with IPv4 Family. |
| dflet | 0:e89ba455dbcf | 169 | Return service attributes like IP address, port and text according to service name. |
| dflet | 0:e89ba455dbcf | 170 | The user sets a service name Full/Part (see example below), and should get the: |
| dflet | 0:e89ba455dbcf | 171 | 1. IP of the service |
| dflet | 0:e89ba455dbcf | 172 | 2. The port of service. |
| dflet | 0:e89ba455dbcf | 173 | 3. The text of service. |
| dflet | 0:e89ba455dbcf | 174 | |
| dflet | 0:e89ba455dbcf | 175 | Hence it can make a connection to the specific service and use it. |
| dflet | 0:e89ba455dbcf | 176 | It is similar to get host by name method. |
| dflet | 0:e89ba455dbcf | 177 | |
| dflet | 0:e89ba455dbcf | 178 | It is done by a single shot query with PTR type on the service name. |
| dflet | 0:e89ba455dbcf | 179 | |
| dflet | 0:e89ba455dbcf | 180 | |
| dflet | 0:e89ba455dbcf | 181 | |
| dflet | 0:e89ba455dbcf | 182 | Note: |
| dflet | 0:e89ba455dbcf | 183 | 1. The return's attributes are belonged to first service that is found. |
| dflet | 0:e89ba455dbcf | 184 | It can be other services with the same service name will response to |
| dflet | 0:e89ba455dbcf | 185 | the query. The results of these responses are saved in the peer cache of the NWP, and |
| dflet | 0:e89ba455dbcf | 186 | should be read by another API. |
| dflet | 0:e89ba455dbcf | 187 | |
| dflet | 0:e89ba455dbcf | 188 | |
| dflet | 0:e89ba455dbcf | 189 | PARAMETERS: |
| dflet | 0:e89ba455dbcf | 190 | |
| dflet | 0:e89ba455dbcf | 191 | pVoidBuf - is point to opcode of the event. |
| dflet | 0:e89ba455dbcf | 192 | it contains the outputs that are given to the user |
| dflet | 0:e89ba455dbcf | 193 | |
| dflet | 0:e89ba455dbcf | 194 | outputs description: |
| dflet | 0:e89ba455dbcf | 195 | |
| dflet | 0:e89ba455dbcf | 196 | 1.out_pAddr[] - output: Contain the IP address of the service. |
| dflet | 0:e89ba455dbcf | 197 | 2.out_pPort - output: Contain the port of the service. |
| dflet | 0:e89ba455dbcf | 198 | 3.inout_TextLen - Input: Contain the max length of the text that the user wants to get. |
| dflet | 0:e89ba455dbcf | 199 | it means that if the test of service is bigger that its value than |
| dflet | 0:e89ba455dbcf | 200 | the text is cut to inout_TextLen value. |
| dflet | 0:e89ba455dbcf | 201 | Output: Contain the length of the text that is returned. Can be full text or part |
| dflet | 0:e89ba455dbcf | 202 | of the text (see above). |
| dflet | 0:e89ba455dbcf | 203 | |
| dflet | 0:e89ba455dbcf | 204 | 4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description). |
| dflet | 0:e89ba455dbcf | 205 | |
| dflet | 0:e89ba455dbcf | 206 | * |
| dflet | 0:e89ba455dbcf | 207 | |
| dflet | 0:e89ba455dbcf | 208 | |
| dflet | 0:e89ba455dbcf | 209 | RETURNS: success or fail. |
| dflet | 0:e89ba455dbcf | 210 | |
| dflet | 0:e89ba455dbcf | 211 | ******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 212 | void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 213 | { |
| dflet | 0:e89ba455dbcf | 214 | _GetHostByServiceAsyncResponse_t* Res; |
| dflet | 0:e89ba455dbcf | 215 | uint16_t TextLen; |
| dflet | 0:e89ba455dbcf | 216 | uint16_t UserTextLen; |
| dflet | 0:e89ba455dbcf | 217 | |
| dflet | 0:e89ba455dbcf | 218 | /*pVoidBuf - is point to opcode of the event.*/ |
| dflet | 0:e89ba455dbcf | 219 | |
| dflet | 0:e89ba455dbcf | 220 | /*set pMsgArgs to point to the attribute of the event.*/ |
| dflet | 0:e89ba455dbcf | 221 | _GetHostByServiceIPv4AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 222 | |
| dflet | 0:e89ba455dbcf | 223 | VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); |
| dflet | 0:e89ba455dbcf | 224 | |
| dflet | 0:e89ba455dbcf | 225 | /*IPv6*/ |
| dflet | 0:e89ba455dbcf | 226 | if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { |
| dflet | 0:e89ba455dbcf | 227 | return; |
| dflet | 0:e89ba455dbcf | 228 | } |
| dflet | 0:e89ba455dbcf | 229 | /*IPv4*/ |
| dflet | 0:e89ba455dbcf | 230 | else { |
| dflet | 0:e89ba455dbcf | 231 | /************************************************************************************************* |
| dflet | 0:e89ba455dbcf | 232 | |
| dflet | 0:e89ba455dbcf | 233 | 1. Copy the attribute part of the evnt to the attribute part of the response |
| dflet | 0:e89ba455dbcf | 234 | memcpy(g_pCB->GetHostByServiceCB.pAsyncRsp, pMsgArgs, sizeof(_GetHostByServiceIPv4AsyncResponse_t)); |
| dflet | 0:e89ba455dbcf | 235 | |
| dflet | 0:e89ba455dbcf | 236 | set to TextLen the text length of the service.*/ |
| dflet | 0:e89ba455dbcf | 237 | TextLen = pMsgArgs->TextLen; |
| dflet | 0:e89ba455dbcf | 238 | |
| dflet | 0:e89ba455dbcf | 239 | /*Res pointed to mDNS global object struct */ |
| dflet | 0:e89ba455dbcf | 240 | Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs; |
| dflet | 0:e89ba455dbcf | 241 | |
| dflet | 0:e89ba455dbcf | 242 | |
| dflet | 0:e89ba455dbcf | 243 | |
| dflet | 0:e89ba455dbcf | 244 | /*It is 4 bytes so we avoid from memcpy*/ |
| dflet | 0:e89ba455dbcf | 245 | Res->out_pAddr[0] = pMsgArgs->Address; |
| dflet | 0:e89ba455dbcf | 246 | Res->out_pPort[0] = pMsgArgs->Port; |
| dflet | 0:e89ba455dbcf | 247 | Res->Status = pMsgArgs->Status; |
| dflet | 0:e89ba455dbcf | 248 | |
| dflet | 0:e89ba455dbcf | 249 | /*set to TextLen the text length of the user (input fromthe user).*/ |
| dflet | 0:e89ba455dbcf | 250 | UserTextLen = Res->inout_TextLen[0]; |
| dflet | 0:e89ba455dbcf | 251 | |
| dflet | 0:e89ba455dbcf | 252 | /*Cut the service text if the user requested for smaller text.*/ |
| dflet | 0:e89ba455dbcf | 253 | UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen; |
| dflet | 0:e89ba455dbcf | 254 | Res->inout_TextLen[0] = UserTextLen ; |
| dflet | 0:e89ba455dbcf | 255 | |
| dflet | 0:e89ba455dbcf | 256 | /************************************************************************************************** |
| dflet | 0:e89ba455dbcf | 257 | |
| dflet | 0:e89ba455dbcf | 258 | 2. Copy the payload part of the evnt (the text) to the payload part of the response |
| dflet | 0:e89ba455dbcf | 259 | the lenght of the copy is according to the text length in the attribute part. */ |
| dflet | 0:e89ba455dbcf | 260 | |
| dflet | 0:e89ba455dbcf | 261 | |
| dflet | 0:e89ba455dbcf | 262 | memcpy(Res->out_pText , |
| dflet | 0:e89ba455dbcf | 263 | (int8_t *)(& pMsgArgs[1]), /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/ |
| dflet | 0:e89ba455dbcf | 264 | UserTextLen); |
| dflet | 0:e89ba455dbcf | 265 | |
| dflet | 0:e89ba455dbcf | 266 | |
| dflet | 0:e89ba455dbcf | 267 | /**************************************************************************************************/ |
| dflet | 0:e89ba455dbcf | 268 | |
| dflet | 0:e89ba455dbcf | 269 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 270 | return; |
| dflet | 0:e89ba455dbcf | 271 | } |
| dflet | 0:e89ba455dbcf | 272 | } |
| dflet | 0:e89ba455dbcf | 273 | |
| dflet | 0:e89ba455dbcf | 274 | /*****************************************************************************/ |
| dflet | 0:e89ba455dbcf | 275 | /* _sl_HandleAsync_PingResponse */ |
| dflet | 0:e89ba455dbcf | 276 | /*****************************************************************************/ |
| dflet | 0:e89ba455dbcf | 277 | void _sl_HandleAsync_PingResponse(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 278 | { |
| dflet | 0:e89ba455dbcf | 279 | _PingReportResponse_t *pMsgArgs = (_PingReportResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 280 | SlPingReport_t pingReport; |
| dflet | 0:e89ba455dbcf | 281 | |
| dflet | 0:e89ba455dbcf | 282 | if(pPingCallBackFunc) { |
| dflet | 0:e89ba455dbcf | 283 | _netapp->CopyPingResultsToReport(pMsgArgs,&pingReport); |
| dflet | 0:e89ba455dbcf | 284 | pPingCallBackFunc(&pingReport); |
| dflet | 0:e89ba455dbcf | 285 | } else { |
| dflet | 0:e89ba455dbcf | 286 | |
| dflet | 0:e89ba455dbcf | 287 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE,NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER)); |
| dflet | 0:e89ba455dbcf | 288 | VERIFY_SOCKET_CB(NULL != g_pCB->PingCB.PingAsync.pAsyncRsp); |
| dflet | 0:e89ba455dbcf | 289 | |
| dflet | 0:e89ba455dbcf | 290 | if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs) { |
| dflet | 0:e89ba455dbcf | 291 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_PingReportResponse_t)); |
| dflet | 0:e89ba455dbcf | 292 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 293 | } |
| dflet | 0:e89ba455dbcf | 294 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 295 | } |
| dflet | 0:e89ba455dbcf | 296 | return; |
| dflet | 0:e89ba455dbcf | 297 | } |
| dflet | 0:e89ba455dbcf | 298 | |
| dflet | 0:e89ba455dbcf | 299 | /* ******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 300 | /* _SlDrvMsgReadSpawnCtx */ |
| dflet | 0:e89ba455dbcf | 301 | /* ******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 302 | _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) |
| dflet | 0:e89ba455dbcf | 303 | { |
| dflet | 0:e89ba455dbcf | 304 | |
| dflet | 0:e89ba455dbcf | 305 | #ifdef SL_POLLING_MODE_USED |
| dflet | 0:e89ba455dbcf | 306 | int16_t retCode = OSI_OK; |
| dflet | 0:e89ba455dbcf | 307 | /* for polling based systems */ |
| dflet | 0:e89ba455dbcf | 308 | do { |
| dflet | 0:e89ba455dbcf | 309 | retCode = sl_LockObjLock(&g_pCB->GlobalLockObj, 0); |
| dflet | 0:e89ba455dbcf | 310 | if ( OSI_OK != retCode ) { |
| dflet | 0:e89ba455dbcf | 311 | if (TRUE == g_pCB->IsCmdRespWaited) { |
| dflet | 0:e89ba455dbcf | 312 | OSI_RET_OK_CHECK( sl_SyncObjSignal(&g_pCB->CmdSyncObj) ); |
| dflet | 0:e89ba455dbcf | 313 | return SL_RET_CODE_OK; |
| dflet | 0:e89ba455dbcf | 314 | } |
| dflet | 0:e89ba455dbcf | 315 | } |
| dflet | 0:e89ba455dbcf | 316 | |
| dflet | 0:e89ba455dbcf | 317 | } while (OSI_OK != retCode); |
| dflet | 0:e89ba455dbcf | 318 | |
| dflet | 0:e89ba455dbcf | 319 | #else |
| dflet | 0:e89ba455dbcf | 320 | |
| dflet | 0:e89ba455dbcf | 321 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER) ); |
| dflet | 0:e89ba455dbcf | 322 | |
| dflet | 0:e89ba455dbcf | 323 | #endif |
| dflet | 0:e89ba455dbcf | 324 | |
| dflet | 0:e89ba455dbcf | 325 | g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL;/* buffer must be allocated by _SlDrvMsgRead */ |
| dflet | 0:e89ba455dbcf | 326 | g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler= NULL; |
| dflet | 0:e89ba455dbcf | 327 | g_pCB->FunctionParams.AsyncExt.RxMsgClass = CMD_RESP_CLASS;/* init to illegal value and verify it's overwritten with the valid one */ |
| dflet | 0:e89ba455dbcf | 328 | |
| dflet | 0:e89ba455dbcf | 329 | /* Messages might have been read by CmdResp context. Therefore after */ |
| dflet | 0:e89ba455dbcf | 330 | /* getting LockObj, check again where the Pending Rx Msg is still present. */ |
| dflet | 0:e89ba455dbcf | 331 | if(FALSE == (_driver->_SL_PENDING_RX_MSG(g_pCB))) { |
| dflet | 0:e89ba455dbcf | 332 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 333 | return SL_RET_CODE_OK; |
| dflet | 0:e89ba455dbcf | 334 | } |
| dflet | 0:e89ba455dbcf | 335 | |
| dflet | 0:e89ba455dbcf | 336 | VERIFY_RET_OK(_driver->_SlDrvMsgRead()); |
| dflet | 0:e89ba455dbcf | 337 | |
| dflet | 0:e89ba455dbcf | 338 | g_pCB->RxDoneCnt++; |
| dflet | 0:e89ba455dbcf | 339 | |
| dflet | 0:e89ba455dbcf | 340 | switch(g_pCB->FunctionParams.AsyncExt.RxMsgClass) { |
| dflet | 0:e89ba455dbcf | 341 | case ASYNC_EVT_CLASS: |
| dflet | 0:e89ba455dbcf | 342 | /* If got here and protected by LockObj a message is waiting */ |
| dflet | 0:e89ba455dbcf | 343 | /* to be read */ |
| dflet | 0:e89ba455dbcf | 344 | VERIFY_PROTOCOL(NULL != g_pCB->FunctionParams.AsyncExt.pAsyncBuf); |
| dflet | 0:e89ba455dbcf | 345 | |
| dflet | 0:e89ba455dbcf | 346 | _driver->_SlAsyncEventGenericHandler(); |
| dflet | 0:e89ba455dbcf | 347 | |
| dflet | 0:e89ba455dbcf | 348 | #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_STATIC) |
| dflet | 0:e89ba455dbcf | 349 | g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; |
| dflet | 0:e89ba455dbcf | 350 | #else |
| dflet | 0:e89ba455dbcf | 351 | free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); |
| dflet | 0:e89ba455dbcf | 352 | #endif |
| dflet | 0:e89ba455dbcf | 353 | break; |
| dflet | 0:e89ba455dbcf | 354 | case DUMMY_MSG_CLASS: |
| dflet | 0:e89ba455dbcf | 355 | case RECV_RESP_CLASS: |
| dflet | 0:e89ba455dbcf | 356 | /* These types are legal in this context. Do nothing */ |
| dflet | 0:e89ba455dbcf | 357 | break; |
| dflet | 0:e89ba455dbcf | 358 | case CMD_RESP_CLASS: |
| dflet | 0:e89ba455dbcf | 359 | /* Command response is illegal in this context. */ |
| dflet | 0:e89ba455dbcf | 360 | /* No 'break' here: Assert! */ |
| dflet | 0:e89ba455dbcf | 361 | default: |
| dflet | 0:e89ba455dbcf | 362 | VERIFY_PROTOCOL(0); |
| dflet | 0:e89ba455dbcf | 363 | } |
| dflet | 0:e89ba455dbcf | 364 | |
| dflet | 0:e89ba455dbcf | 365 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 366 | |
| dflet | 0:e89ba455dbcf | 367 | return(SL_RET_CODE_OK); |
| dflet | 1:c73566c6788a | 368 | |
| dflet | 0:e89ba455dbcf | 369 | } |
| dflet | 0:e89ba455dbcf | 370 | |
| dflet | 0:e89ba455dbcf | 371 | /*************************************************************************** |
| dflet | 0:e89ba455dbcf | 372 | _sl_HandleAsync_Stop - handles stop signalling to |
| dflet | 0:e89ba455dbcf | 373 | a waiting object |
| dflet | 0:e89ba455dbcf | 374 | ****************************************************************************/ |
| dflet | 0:e89ba455dbcf | 375 | void _sl_HandleAsync_Stop(void *pVoidBuf) |
| dflet | 0:e89ba455dbcf | 376 | { |
| dflet | 0:e89ba455dbcf | 377 | _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); |
| dflet | 0:e89ba455dbcf | 378 | |
| dflet | 0:e89ba455dbcf | 379 | VERIFY_SOCKET_CB(NULL != g_pCB->StopCB.pAsyncRsp); |
| dflet | 0:e89ba455dbcf | 380 | |
| dflet | 0:e89ba455dbcf | 381 | OSI_RET_OK_CHECK(_nonos->sl_LockObjLock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE,NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER)); |
| dflet | 0:e89ba455dbcf | 382 | |
| dflet | 0:e89ba455dbcf | 383 | memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_BasicResponse_t)); |
| dflet | 0:e89ba455dbcf | 384 | OSI_RET_OK_CHECK(_nonos->sl_SyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj, NON_OS_SYNC_OBJ_SIGNAL_VALUE)); |
| dflet | 0:e89ba455dbcf | 385 | OSI_RET_OK_CHECK(_nonos->sl_LockObjUnlock(&g_pCB->ProtectionLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); |
| dflet | 0:e89ba455dbcf | 386 | return; |
| dflet | 0:e89ba455dbcf | 387 | } |
| dflet | 0:e89ba455dbcf | 388 | |
| dflet | 0:e89ba455dbcf | 389 | /****************************************************************************** |
| dflet | 0:e89ba455dbcf | 390 | _SlDrvDeviceEventHandler - handles internally device async events |
| dflet | 0:e89ba455dbcf | 391 | ******************************************************************************/ |
| dflet | 0:e89ba455dbcf | 392 | void _SlDrvDeviceEventHandler(void *pArgs) |
| dflet | 0:e89ba455dbcf | 393 | { |
| dflet | 0:e89ba455dbcf | 394 | _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; |
| dflet | 1:c73566c6788a | 395 | |
| dflet | 0:e89ba455dbcf | 396 | switch(pHdr->GenHeader.Opcode) { |
| dflet | 0:e89ba455dbcf | 397 | case SL_OPCODE_DEVICE_INITCOMPLETE: |
| dflet | 0:e89ba455dbcf | 398 | _cc3100_->_sl_HandleAsync_InitComplete(pHdr); |
| dflet | 1:c73566c6788a | 399 | |
| dflet | 0:e89ba455dbcf | 400 | break; |
| dflet | 0:e89ba455dbcf | 401 | case SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE: |
| dflet | 0:e89ba455dbcf | 402 | _sl_HandleAsync_Stop(pHdr); |
| dflet | 1:c73566c6788a | 403 | |
| dflet | 0:e89ba455dbcf | 404 | break; |
| dflet | 0:e89ba455dbcf | 405 | case SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR: |
| dflet | 0:e89ba455dbcf | 406 | #ifdef sl_GeneralEvtHdlr |
| dflet | 0:e89ba455dbcf | 407 | { |
| dflet | 0:e89ba455dbcf | 408 | _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pHdr); |
| dflet | 0:e89ba455dbcf | 409 | SlDeviceEvent_t devHandler; |
| dflet | 0:e89ba455dbcf | 410 | devHandler.Event = SL_DEVICE_FATAL_ERROR_EVENT; |
| dflet | 0:e89ba455dbcf | 411 | devHandler.EventData.deviceEvent.status = pMsgArgs->status & 0xFF; |
| dflet | 0:e89ba455dbcf | 412 | devHandler.EventData.deviceEvent.sender = (SlErrorSender_e)((pMsgArgs->status >> 8) & 0xFF); |
| dflet | 0:e89ba455dbcf | 413 | SimpleLinkGeneralEventHandler(&devHandler); |
| dflet | 0:e89ba455dbcf | 414 | } |
| dflet | 0:e89ba455dbcf | 415 | #endif |
| dflet | 0:e89ba455dbcf | 416 | break; |
| dflet | 0:e89ba455dbcf | 417 | default: |
| dflet | 0:e89ba455dbcf | 418 | //SL_ERROR_TRACE2(MSG_306, "ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); |
| dflet | 0:e89ba455dbcf | 419 | printf("ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); |
| dflet | 0:e89ba455dbcf | 420 | VERIFY_PROTOCOL(0); |
| dflet | 0:e89ba455dbcf | 421 | } |
| dflet | 0:e89ba455dbcf | 422 | } |
| dflet | 0:e89ba455dbcf | 423 | |
| dflet | 0:e89ba455dbcf | 424 | /*****************************************************************************/ |
| dflet | 0:e89ba455dbcf | 425 | /* _SlDrvNetAppEventHandler */ |
| dflet | 0:e89ba455dbcf | 426 | /*****************************************************************************/ |
| dflet | 0:e89ba455dbcf | 427 | void _SlDrvNetAppEventHandler(void *pArgs) |
| dflet | 0:e89ba455dbcf | 428 | { |
| dflet | 0:e89ba455dbcf | 429 | _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; |
| dflet | 0:e89ba455dbcf | 430 | #ifdef sl_HttpServerCallback |
| dflet | 0:e89ba455dbcf | 431 | SlHttpServerEvent_t httpServerEvent; |
| dflet | 0:e89ba455dbcf | 432 | SlHttpServerResponse_t httpServerResponse; |
| dflet | 0:e89ba455dbcf | 433 | #endif |
| dflet | 0:e89ba455dbcf | 434 | switch(pHdr->GenHeader.Opcode) { |
| dflet | 0:e89ba455dbcf | 435 | case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE: |
| dflet | 0:e89ba455dbcf | 436 | case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6: |
| dflet | 0:e89ba455dbcf | 437 | _sl_HandleAsync_DnsGetHostByName(pArgs); |
| dflet | 0:e89ba455dbcf | 438 | break; |
| dflet | 0:e89ba455dbcf | 439 | case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE: |
| dflet | 0:e89ba455dbcf | 440 | case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6: |
| dflet | 0:e89ba455dbcf | 441 | _sl_HandleAsync_DnsGetHostByService(pArgs); |
| dflet | 0:e89ba455dbcf | 442 | break; |
| dflet | 0:e89ba455dbcf | 443 | case SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE: |
| dflet | 0:e89ba455dbcf | 444 | _sl_HandleAsync_PingResponse(pArgs); |
| dflet | 0:e89ba455dbcf | 445 | break; |
| dflet | 0:e89ba455dbcf | 446 | case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE: { |
| dflet | 0:e89ba455dbcf | 447 | #ifdef sl_HttpServerCallback |
| dflet | 0:e89ba455dbcf | 448 | uint8_t *pTokenName; |
| dflet | 0:e89ba455dbcf | 449 | slHttpServerData_t Token_value; |
| dflet | 0:e89ba455dbcf | 450 | sl_NetAppHttpServerGetToken_t *httpGetToken = (sl_NetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr); |
| dflet | 0:e89ba455dbcf | 451 | pTokenName = (uint8_t *)((sl_NetAppHttpServerGetToken_t *)httpGetToken + 1); |
| dflet | 0:e89ba455dbcf | 452 | |
| dflet | 0:e89ba455dbcf | 453 | httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE; |
| dflet | 0:e89ba455dbcf | 454 | httpServerResponse.ResponseData.token_value.len = MAX_TOKEN_VALUE_LEN; |
| dflet | 0:e89ba455dbcf | 455 | httpServerResponse.ResponseData.token_value.data = (uint8_t *)_SL_RESP_ARGS_START(pHdr) + MAX_TOKEN_NAME_LEN; //Reuse the async buffer for getting the token value response from the user |
| dflet | 0:e89ba455dbcf | 456 | |
| dflet | 0:e89ba455dbcf | 457 | httpServerEvent.Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT; |
| dflet | 0:e89ba455dbcf | 458 | httpServerEvent.EventData.httpTokenName.len = httpGetToken->token_name_len; |
| dflet | 0:e89ba455dbcf | 459 | httpServerEvent.EventData.httpTokenName.data = pTokenName; |
| dflet | 0:e89ba455dbcf | 460 | |
| dflet | 0:e89ba455dbcf | 461 | Token_value.token_name = pTokenName; |
| dflet | 0:e89ba455dbcf | 462 | |
| dflet | 0:e89ba455dbcf | 463 | SimpleLinkHttpServerCallback(&httpServerEvent, &httpServerResponse); |
| dflet | 0:e89ba455dbcf | 464 | |
| dflet | 0:e89ba455dbcf | 465 | Token_value.value_len = httpServerResponse.ResponseData.token_value.len; |
| dflet | 0:e89ba455dbcf | 466 | Token_value.name_len = httpServerEvent.EventData.httpTokenName.len; |
| dflet | 0:e89ba455dbcf | 467 | |
| dflet | 0:e89ba455dbcf | 468 | Token_value.token_value = httpServerResponse.ResponseData.token_value.data; |
| dflet | 0:e89ba455dbcf | 469 | |
| dflet | 0:e89ba455dbcf | 470 | |
| dflet | 0:e89ba455dbcf | 471 | _netapp->sl_NetAppSendTokenValue(&Token_value); |
| dflet | 0:e89ba455dbcf | 472 | #endif |
| dflet | 0:e89ba455dbcf | 473 | } |
| dflet | 0:e89ba455dbcf | 474 | break; |
| dflet | 0:e89ba455dbcf | 475 | |
| dflet | 0:e89ba455dbcf | 476 | case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE: { |
| dflet | 0:e89ba455dbcf | 477 | #ifdef sl_HttpServerCallback |
| dflet | 0:e89ba455dbcf | 478 | uint8_t *pPostParams; |
| dflet | 0:e89ba455dbcf | 479 | |
| dflet | 0:e89ba455dbcf | 480 | sl_NetAppHttpServerPostToken_t *httpPostTokenArgs = (sl_NetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr); |
| dflet | 0:e89ba455dbcf | 481 | pPostParams = (uint8_t *)((sl_NetAppHttpServerPostToken_t *)httpPostTokenArgs + 1); |
| dflet | 0:e89ba455dbcf | 482 | |
| dflet | 0:e89ba455dbcf | 483 | httpServerEvent.Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT; |
| dflet | 0:e89ba455dbcf | 484 | |
| dflet | 0:e89ba455dbcf | 485 | httpServerEvent.EventData.httpPostData.action.len = httpPostTokenArgs->post_action_len; |
| dflet | 0:e89ba455dbcf | 486 | httpServerEvent.EventData.httpPostData.action.data = pPostParams; |
| dflet | 0:e89ba455dbcf | 487 | pPostParams+=httpPostTokenArgs->post_action_len; |
| dflet | 0:e89ba455dbcf | 488 | |
| dflet | 0:e89ba455dbcf | 489 | httpServerEvent.EventData.httpPostData.token_name.len = httpPostTokenArgs->token_name_len; |
| dflet | 0:e89ba455dbcf | 490 | httpServerEvent.EventData.httpPostData.token_name.data = pPostParams; |
| dflet | 0:e89ba455dbcf | 491 | pPostParams+=httpPostTokenArgs->token_name_len; |
| dflet | 0:e89ba455dbcf | 492 | |
| dflet | 0:e89ba455dbcf | 493 | httpServerEvent.EventData.httpPostData.token_value.len = httpPostTokenArgs->token_value_len; |
| dflet | 0:e89ba455dbcf | 494 | httpServerEvent.EventData.httpPostData.token_value.data = pPostParams; |
| dflet | 0:e89ba455dbcf | 495 | |
| dflet | 0:e89ba455dbcf | 496 | httpServerResponse.Response = SL_NETAPP_RESPONSE_NONE; |
| dflet | 0:e89ba455dbcf | 497 | |
| dflet | 0:e89ba455dbcf | 498 | |
| dflet | 0:e89ba455dbcf | 499 | SimpleLinkHttpServerCallback(&httpServerEvent, &httpServerResponse); |
| dflet | 0:e89ba455dbcf | 500 | #endif |
| dflet | 0:e89ba455dbcf | 501 | } |
| dflet | 0:e89ba455dbcf | 502 | break; |
| dflet | 0:e89ba455dbcf | 503 | default: |
| dflet | 0:e89ba455dbcf | 504 | SL_ERROR_TRACE2(MSG_305, "ASSERT: _SlDrvNetAppEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); |
| dflet | 0:e89ba455dbcf | 505 | VERIFY_PROTOCOL(0); |
| dflet | 0:e89ba455dbcf | 506 | } |
| dflet | 0:e89ba455dbcf | 507 | } |
| dflet | 0:e89ba455dbcf | 508 | |
| dflet | 0:e89ba455dbcf | 509 | /* |
| dflet | 0:e89ba455dbcf | 510 | * ASYNCHRONOUS EVENT HANDLERS -- Start |
| dflet | 0:e89ba455dbcf | 511 | */ |
| dflet | 0:e89ba455dbcf | 512 | |
| dflet | 0:e89ba455dbcf | 513 | /*! |
| dflet | 0:e89ba455dbcf | 514 | \brief This function handles WLAN events |
| dflet | 0:e89ba455dbcf | 515 | |
| dflet | 0:e89ba455dbcf | 516 | \param[in] pWlanEvent is the event passed to the handler |
| dflet | 0:e89ba455dbcf | 517 | |
| dflet | 0:e89ba455dbcf | 518 | \return None |
| dflet | 0:e89ba455dbcf | 519 | |
| dflet | 0:e89ba455dbcf | 520 | \note |
| dflet | 0:e89ba455dbcf | 521 | |
| dflet | 0:e89ba455dbcf | 522 | \warning |
| dflet | 0:e89ba455dbcf | 523 | */ |
| dflet | 0:e89ba455dbcf | 524 | #if (defined(sl_WlanEvtHdlr)) |
| dflet | 0:e89ba455dbcf | 525 | void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent) |
| dflet | 0:e89ba455dbcf | 526 | { |
| dflet | 4:5af740da0a59 | 527 | unsigned char g_ucConnectionSSID[32+1]; //Connection SSID |
| dflet | 4:5af740da0a59 | 528 | unsigned char g_ucConnectionBSSID[6]; //Connection BSSID |
| dflet | 4:5af740da0a59 | 529 | |
| dflet | 0:e89ba455dbcf | 530 | if(pWlanEvent == NULL) |
| dflet | 0:e89ba455dbcf | 531 | printf(" [WLAN EVENT] NULL Pointer Error \n\r"); |
| dflet | 0:e89ba455dbcf | 532 | |
| dflet | 0:e89ba455dbcf | 533 | switch(pWlanEvent->Event) { |
| dflet | 0:e89ba455dbcf | 534 | case SL_WLAN_CONNECT_EVENT: { |
| dflet | 0:e89ba455dbcf | 535 | _cc3100_->SET_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION); |
| dflet | 4:5af740da0a59 | 536 | |
| dflet | 4:5af740da0a59 | 537 | // Copy new connection SSID and BSSID to global parameters |
| dflet | 4:5af740da0a59 | 538 | memcpy(g_ucConnectionSSID,pWlanEvent->EventData. |
| dflet | 4:5af740da0a59 | 539 | STAandP2PModeWlanConnected.ssid_name, |
| dflet | 4:5af740da0a59 | 540 | pWlanEvent->EventData.STAandP2PModeWlanConnected.ssid_len); |
| dflet | 4:5af740da0a59 | 541 | memcpy(g_ucConnectionBSSID, |
| dflet | 4:5af740da0a59 | 542 | pWlanEvent->EventData.STAandP2PModeWlanConnected.bssid, |
| dflet | 4:5af740da0a59 | 543 | SL_BSSID_LENGTH); |
| dflet | 4:5af740da0a59 | 544 | |
| dflet | 4:5af740da0a59 | 545 | printf("[WLAN EVENT] STA Connected to the AP: %s ," |
| dflet | 4:5af740da0a59 | 546 | "BSSID: %x:%x:%x:%x:%x:%x\n\r", |
| dflet | 4:5af740da0a59 | 547 | g_ucConnectionSSID,g_ucConnectionBSSID[0], |
| dflet | 4:5af740da0a59 | 548 | g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], |
| dflet | 4:5af740da0a59 | 549 | g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], |
| dflet | 4:5af740da0a59 | 550 | g_ucConnectionBSSID[5]); |
| dflet | 0:e89ba455dbcf | 551 | /* |
| dflet | 0:e89ba455dbcf | 552 | * Information about the connected AP (like name, MAC etc) will be |
| dflet | 0:e89ba455dbcf | 553 | * available in 'slWlanConnectAsyncResponse_t' - Applications |
| dflet | 0:e89ba455dbcf | 554 | * can use it if required |
| dflet | 0:e89ba455dbcf | 555 | * |
| dflet | 0:e89ba455dbcf | 556 | * slWlanConnectAsyncResponse_t *pEventData = NULL; |
| dflet | 0:e89ba455dbcf | 557 | * pEventData = &pWlanEvent->EventData.STAandP2PModeWlanConnected; |
| dflet | 0:e89ba455dbcf | 558 | * |
| dflet | 0:e89ba455dbcf | 559 | */ |
| dflet | 0:e89ba455dbcf | 560 | } |
| dflet | 0:e89ba455dbcf | 561 | break; |
| dflet | 0:e89ba455dbcf | 562 | |
| dflet | 0:e89ba455dbcf | 563 | case SL_WLAN_DISCONNECT_EVENT: { |
| dflet | 0:e89ba455dbcf | 564 | slWlanConnectAsyncResponse_t* pEventData = NULL; |
| dflet | 0:e89ba455dbcf | 565 | |
| dflet | 0:e89ba455dbcf | 566 | _cc3100_->CLR_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION); |
| dflet | 0:e89ba455dbcf | 567 | _cc3100_->CLR_STATUS_BIT(g_Status, STATUS_BIT_IP_ACQUIRED); |
| dflet | 0:e89ba455dbcf | 568 | |
| dflet | 0:e89ba455dbcf | 569 | pEventData = &pWlanEvent->EventData.STAandP2PModeDisconnected; |
| dflet | 0:e89ba455dbcf | 570 | |
| dflet | 0:e89ba455dbcf | 571 | /* If the user has initiated 'Disconnect' request, 'reason_code' is SL_USER_INITIATED_DISCONNECTION */ |
| dflet | 0:e89ba455dbcf | 572 | if(SL_USER_INITIATED_DISCONNECTION == pEventData->reason_code) { |
| dflet | 4:5af740da0a59 | 573 | printf("[WLAN EVENT]Device disconnected from the AP: %s," |
| dflet | 4:5af740da0a59 | 574 | "BSSID: %x:%x:%x:%x:%x:%x on application's request \n\r", |
| dflet | 4:5af740da0a59 | 575 | g_ucConnectionSSID,g_ucConnectionBSSID[0], |
| dflet | 4:5af740da0a59 | 576 | g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], |
| dflet | 4:5af740da0a59 | 577 | g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], |
| dflet | 4:5af740da0a59 | 578 | g_ucConnectionBSSID[5]); |
| dflet | 0:e89ba455dbcf | 579 | } else { |
| dflet | 4:5af740da0a59 | 580 | printf("[WLAN ERROR]Device disconnected from the AP AP: %s," |
| dflet | 4:5af740da0a59 | 581 | "BSSID: %x:%x:%x:%x:%x:%x on an ERROR..!! \n\r", |
| dflet | 4:5af740da0a59 | 582 | g_ucConnectionSSID,g_ucConnectionBSSID[0], |
| dflet | 4:5af740da0a59 | 583 | g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], |
| dflet | 4:5af740da0a59 | 584 | g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], |
| dflet | 4:5af740da0a59 | 585 | g_ucConnectionBSSID[5]); |
| dflet | 0:e89ba455dbcf | 586 | } |
| dflet | 4:5af740da0a59 | 587 | memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID)); |
| dflet | 4:5af740da0a59 | 588 | memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID)); |
| dflet | 0:e89ba455dbcf | 589 | } |
| dflet | 0:e89ba455dbcf | 590 | break; |
| dflet | 0:e89ba455dbcf | 591 | |
| dflet | 0:e89ba455dbcf | 592 | case SL_WLAN_STA_CONNECTED_EVENT: { |
| dflet | 0:e89ba455dbcf | 593 | _cc3100_->SET_STATUS_BIT(g_Status, STATUS_BIT_STA_CONNECTED); |
| dflet | 0:e89ba455dbcf | 594 | } |
| dflet | 0:e89ba455dbcf | 595 | break; |
| dflet | 0:e89ba455dbcf | 596 | |
| dflet | 0:e89ba455dbcf | 597 | case SL_WLAN_STA_DISCONNECTED_EVENT: { |
| dflet | 0:e89ba455dbcf | 598 | _cc3100_->CLR_STATUS_BIT(g_Status, STATUS_BIT_STA_CONNECTED); |
| dflet | 0:e89ba455dbcf | 599 | _cc3100_->CLR_STATUS_BIT(g_Status, STATUS_BIT_IP_LEASED); |
| dflet | 0:e89ba455dbcf | 600 | } |
| dflet | 0:e89ba455dbcf | 601 | break; |
| dflet | 0:e89ba455dbcf | 602 | |
| dflet | 0:e89ba455dbcf | 603 | default: { |
| dflet | 4:5af740da0a59 | 604 | printf("[WLAN EVENT] Unexpected event [0x%x]\n\r",pWlanEvent->Event); |
| dflet | 0:e89ba455dbcf | 605 | } |
| dflet | 0:e89ba455dbcf | 606 | break; |
| dflet | 0:e89ba455dbcf | 607 | } |
| dflet | 0:e89ba455dbcf | 608 | } |
| dflet | 0:e89ba455dbcf | 609 | #endif |
| dflet | 0:e89ba455dbcf | 610 | |
| dflet | 0:e89ba455dbcf | 611 | /*! |
| dflet | 0:e89ba455dbcf | 612 | \brief This function handles events for IP address acquisition via DHCP |
| dflet | 0:e89ba455dbcf | 613 | indication |
| dflet | 0:e89ba455dbcf | 614 | |
| dflet | 0:e89ba455dbcf | 615 | \param[in] pNetAppEvent is the event passed to the handler |
| dflet | 0:e89ba455dbcf | 616 | |
| dflet | 0:e89ba455dbcf | 617 | \return None |
| dflet | 0:e89ba455dbcf | 618 | |
| dflet | 0:e89ba455dbcf | 619 | \note |
| dflet | 0:e89ba455dbcf | 620 | |
| dflet | 0:e89ba455dbcf | 621 | \warning |
| dflet | 0:e89ba455dbcf | 622 | */ |
| dflet | 0:e89ba455dbcf | 623 | #if (defined(sl_NetAppEvtHdlr)) |
| dflet | 0:e89ba455dbcf | 624 | void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent) |
| dflet | 0:e89ba455dbcf | 625 | { |
| dflet | 0:e89ba455dbcf | 626 | |
| dflet | 0:e89ba455dbcf | 627 | if(pNetAppEvent == NULL){ |
| dflet | 0:e89ba455dbcf | 628 | printf(" [NETAPP EVENT] NULL Pointer Error \n\r"); |
| dflet | 0:e89ba455dbcf | 629 | } |
| dflet | 0:e89ba455dbcf | 630 | |
| dflet | 0:e89ba455dbcf | 631 | switch(pNetAppEvent->Event) { |
| dflet | 0:e89ba455dbcf | 632 | case SL_NETAPP_IPV4_IPACQUIRED_EVENT: { |
| dflet | 1:c73566c6788a | 633 | SlIpV4AcquiredAsync_t *pEventData = NULL; |
| dflet | 1:c73566c6788a | 634 | _cc3100_->SET_STATUS_BIT(g_Status, STATUS_BIT_IP_ACQUIRED); |
| dflet | 1:c73566c6788a | 635 | pEventData = &pNetAppEvent->EventData.ipAcquiredV4; |
| dflet | 1:c73566c6788a | 636 | g_GatewayIP = pEventData->gateway; |
| dflet | 0:e89ba455dbcf | 637 | |
| dflet | 4:5af740da0a59 | 638 | printf("[NETAPP EVENT] IP Acquired: IP=%d.%d.%d.%d , ""Gateway=%d.%d.%d.%d\n\r", |
| dflet | 4:5af740da0a59 | 639 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,3), |
| dflet | 4:5af740da0a59 | 640 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,2), |
| dflet | 4:5af740da0a59 | 641 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,1), |
| dflet | 4:5af740da0a59 | 642 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,0), |
| dflet | 4:5af740da0a59 | 643 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,3), |
| dflet | 4:5af740da0a59 | 644 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,2), |
| dflet | 4:5af740da0a59 | 645 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,1), |
| dflet | 4:5af740da0a59 | 646 | _cc3100_->_netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,0)); |
| dflet | 4:5af740da0a59 | 647 | |
| dflet | 0:e89ba455dbcf | 648 | } |
| dflet | 0:e89ba455dbcf | 649 | break; |
| dflet | 0:e89ba455dbcf | 650 | |
| dflet | 1:c73566c6788a | 651 | case SL_NETAPP_IP_LEASED_EVENT: { |
| dflet | 1:c73566c6788a | 652 | g_StationIP = pNetAppEvent->EventData.ipLeased.ip_address; |
| dflet | 0:e89ba455dbcf | 653 | _cc3100_->SET_STATUS_BIT(g_Status, STATUS_BIT_IP_LEASED); |
| dflet | 1:c73566c6788a | 654 | |
| dflet | 0:e89ba455dbcf | 655 | } |
| dflet | 0:e89ba455dbcf | 656 | break; |
| dflet | 0:e89ba455dbcf | 657 | |
| dflet | 0:e89ba455dbcf | 658 | default: { |
| dflet | 4:5af740da0a59 | 659 | printf("[NETAPP EVENT] Unexpected event [0x%x] \n\r",pNetAppEvent->Event); |
| dflet | 0:e89ba455dbcf | 660 | } |
| dflet | 0:e89ba455dbcf | 661 | break; |
| dflet | 0:e89ba455dbcf | 662 | } |
| dflet | 0:e89ba455dbcf | 663 | } |
| dflet | 0:e89ba455dbcf | 664 | #endif |
| dflet | 0:e89ba455dbcf | 665 | |
| dflet | 0:e89ba455dbcf | 666 | /*! |
| dflet | 0:e89ba455dbcf | 667 | \brief This function handles socket events indication |
| dflet | 0:e89ba455dbcf | 668 | |
| dflet | 0:e89ba455dbcf | 669 | \param[in] pSock is the event passed to the handler |
| dflet | 0:e89ba455dbcf | 670 | |
| dflet | 0:e89ba455dbcf | 671 | \return None |
| dflet | 0:e89ba455dbcf | 672 | */ |
| dflet | 0:e89ba455dbcf | 673 | #if (defined(sl_SockEvtHdlr)) |
| dflet | 0:e89ba455dbcf | 674 | void SimpleLinkSockEventHandler(SlSockEvent_t *pSock) |
| dflet | 0:e89ba455dbcf | 675 | { |
| dflet | 0:e89ba455dbcf | 676 | if(pSock == NULL) |
| dflet | 0:e89ba455dbcf | 677 | printf(" [SOCK EVENT] NULL Pointer Error \n\r"); |
| dflet | 0:e89ba455dbcf | 678 | |
| dflet | 0:e89ba455dbcf | 679 | switch( pSock->Event ) |
| dflet | 0:e89ba455dbcf | 680 | { |
| dflet | 0:e89ba455dbcf | 681 | case SL_SOCKET_TX_FAILED_EVENT: |
| dflet | 0:e89ba455dbcf | 682 | /* |
| dflet | 0:e89ba455dbcf | 683 | * TX Failed |
| dflet | 0:e89ba455dbcf | 684 | * |
| dflet | 0:e89ba455dbcf | 685 | * Information about the socket descriptor and status will be |
| dflet | 0:e89ba455dbcf | 686 | * available in 'SlSockEventData_t' - Applications can use it if |
| dflet | 0:e89ba455dbcf | 687 | * required |
| dflet | 0:e89ba455dbcf | 688 | * |
| dflet | 0:e89ba455dbcf | 689 | * SlSockEventData_t *pEventData = NULL; |
| dflet | 0:e89ba455dbcf | 690 | * pEventData = & pSock->EventData; |
| dflet | 0:e89ba455dbcf | 691 | */ |
| dflet | 0:e89ba455dbcf | 692 | switch( pSock->EventData.status ) |
| dflet | 0:e89ba455dbcf | 693 | { |
| dflet | 0:e89ba455dbcf | 694 | case SL_ECLOSE: |
| dflet | 0:e89ba455dbcf | 695 | printf(" [SOCK EVENT] Close socket operation, failed to transmit all queued packets\n\r"); |
| dflet | 0:e89ba455dbcf | 696 | break; |
| dflet | 0:e89ba455dbcf | 697 | default: |
| dflet | 4:5af740da0a59 | 698 | printf("[SOCK ERROR] - TX FAILED : socket %d , reason""(%d) \n\n", pSock->EventData.sd, pSock->EventData.status); |
| dflet | 0:e89ba455dbcf | 699 | break; |
| dflet | 0:e89ba455dbcf | 700 | } |
| dflet | 0:e89ba455dbcf | 701 | break; |
| dflet | 0:e89ba455dbcf | 702 | |
| dflet | 0:e89ba455dbcf | 703 | default: |
| dflet | 4:5af740da0a59 | 704 | printf("[SOCK EVENT] - Unexpected Event [%x0x]\n\n",pSock->Event); |
| dflet | 0:e89ba455dbcf | 705 | break; |
| dflet | 0:e89ba455dbcf | 706 | } |
| dflet | 0:e89ba455dbcf | 707 | } |
| dflet | 0:e89ba455dbcf | 708 | #endif |
| dflet | 0:e89ba455dbcf | 709 | |
| dflet | 0:e89ba455dbcf | 710 | /*! |
| dflet | 0:e89ba455dbcf | 711 | \brief This function handles callback for the HTTP server events |
| dflet | 0:e89ba455dbcf | 712 | |
| dflet | 0:e89ba455dbcf | 713 | \param[in] pHttpEvent - Contains the relevant event information |
| dflet | 0:e89ba455dbcf | 714 | \param[in] pHttpResponse - Should be filled by the user with the |
| dflet | 0:e89ba455dbcf | 715 | relevant response information |
| dflet | 0:e89ba455dbcf | 716 | |
| dflet | 0:e89ba455dbcf | 717 | \return None |
| dflet | 0:e89ba455dbcf | 718 | |
| dflet | 0:e89ba455dbcf | 719 | \note |
| dflet | 0:e89ba455dbcf | 720 | |
| dflet | 0:e89ba455dbcf | 721 | \warning |
| dflet | 0:e89ba455dbcf | 722 | */ |
| dflet | 0:e89ba455dbcf | 723 | #if (defined(sl_HttpServerCallback)) |
| dflet | 0:e89ba455dbcf | 724 | void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pHttpEvent, SlHttpServerResponse_t *pHttpResponse) |
| dflet | 0:e89ba455dbcf | 725 | { |
| dflet | 0:e89ba455dbcf | 726 | /* |
| dflet | 0:e89ba455dbcf | 727 | * This application doesn't work with HTTP server - Hence these |
| dflet | 0:e89ba455dbcf | 728 | * events are not handled here |
| dflet | 0:e89ba455dbcf | 729 | */ |
| dflet | 0:e89ba455dbcf | 730 | printf(" [HTTP EVENT] Unexpected event \n\r"); |
| dflet | 0:e89ba455dbcf | 731 | } |
| dflet | 0:e89ba455dbcf | 732 | #endif |
| dflet | 0:e89ba455dbcf | 733 | /*! |
| dflet | 0:e89ba455dbcf | 734 | \brief This function handles general error events indication |
| dflet | 0:e89ba455dbcf | 735 | |
| dflet | 0:e89ba455dbcf | 736 | \param[in] pDevEvent is the event passed to the handler |
| dflet | 0:e89ba455dbcf | 737 | |
| dflet | 0:e89ba455dbcf | 738 | \return None |
| dflet | 0:e89ba455dbcf | 739 | */ |
| dflet | 0:e89ba455dbcf | 740 | #if (defined(sl_GeneralEvtHdlr)) |
| dflet | 0:e89ba455dbcf | 741 | void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent) |
| dflet | 0:e89ba455dbcf | 742 | { |
| dflet | 0:e89ba455dbcf | 743 | /* |
| dflet | 0:e89ba455dbcf | 744 | * Most of the general errors are not FATAL are are to be handled |
| dflet | 0:e89ba455dbcf | 745 | * appropriately by the application |
| dflet | 0:e89ba455dbcf | 746 | */ |
| dflet | 4:5af740da0a59 | 747 | printf("[GENERAL EVENT] - ID=[%d] Sender=[%d]\n\n", pDevEvent->EventData.deviceEvent.status, pDevEvent->EventData.deviceEvent.sender); |
| dflet | 0:e89ba455dbcf | 748 | } |
| dflet | 0:e89ba455dbcf | 749 | #endif |
| dflet | 0:e89ba455dbcf | 750 | |
| dflet | 0:e89ba455dbcf | 751 | #ifdef __cplusplus |
| dflet | 0:e89ba455dbcf | 752 | } |
| dflet | 0:e89ba455dbcf | 753 | #endif /* __cplusplus */ |
| dflet | 0:e89ba455dbcf | 754 | |
| dflet | 0:e89ba455dbcf | 755 | //}//namespace |