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.
Fork of simplelink_V2 by
fPtr_func.cpp
00001 /* 00002 * - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 #include "simplelink_V2/cc3100_simplelink.h" 00038 00039 #include "simplelink_V2/cc3100.h" 00040 #include "simplelink_V2/cc3100_driver.h" 00041 #include "simplelink_V2/G_functions/fPtr_func.h" 00042 #include "simplelink_V2/cc3100_nonos.h" 00043 #include "cli_uart.h" 00044 00045 #include "cc3100_trace.h" 00046 00047 using namespace mbed_cc3100; 00048 00049 cc3100 _cc3100_(p16, p17, p9, p10, p8, SPI(p5, p6, p7));//LPC1768 irq, nHib, cs, mosi, miso, sck 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 00055 #define PRINT_BUF_LEN 128 00056 extern int8_t print_buf[PRINT_BUF_LEN]; 00057 00058 /* General Events handling*/ 00059 #if defined (EXT_LIB_REGISTERED_GENERAL_EVENTS) 00060 00061 typedef _SlEventPropogationStatus_e (*general_callback) (SlDeviceEvent_t *); 00062 00063 static const general_callback general_callbacks[] = 00064 { 00065 #ifdef SlExtLib1GeneralEventHandler 00066 SlExtLib1GeneralEventHandler, 00067 #endif 00068 00069 #ifdef SlExtLib2GeneralEventHandler 00070 SlExtLib2GeneralEventHandler, 00071 #endif 00072 00073 #ifdef SlExtLib3GeneralEventHandler 00074 SlExtLib3GeneralEventHandler, 00075 #endif 00076 00077 #ifdef SlExtLib4GeneralEventHandler 00078 SlExtLib4GeneralEventHandler, 00079 #endif 00080 00081 #ifdef SlExtLib5GeneralEventHandler 00082 SlExtLib5GeneralEventHandler, 00083 #endif 00084 }; 00085 00086 #undef _SlDrvHandleGeneralEvents 00087 00088 /******************************************************************** 00089 _SlDrvHandleGeneralEvents 00090 Iterates through all the general(device) event handlers which are 00091 registered by the external libs/user application. 00092 *********************************************************************/ 00093 void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent) 00094 { 00095 uint8_t i; 00096 00097 /* Iterate over all the extenal libs handlers */ 00098 for ( i = 0 ; i < sizeof(general_callbacks)/sizeof(general_callbacks[0]) ; i++ ) 00099 { 00100 if (EVENT_PROPAGATION_BLOCK == general_callbacks[i](slGeneralEvent) ) 00101 { 00102 /* exit immediately and do not call the user specific handler as well */ 00103 return; 00104 } 00105 } 00106 00107 /* At last call the Application specific handler if registered */ 00108 #ifdef sl_GeneralEvtHdlr 00109 sl_GeneralEvtHdlr(slGeneralEvent); 00110 #endif 00111 00112 } 00113 #endif 00114 00115 00116 00117 /* WLAN Events handling*/ 00118 00119 #if defined (EXT_LIB_REGISTERED_WLAN_EVENTS) 00120 00121 typedef _SlEventPropogationStatus_e (*wlan_callback) (SlWlanEvent_t *); 00122 00123 static wlan_callback wlan_callbacks[] = 00124 { 00125 #ifdef SlExtLib1WlanEventHandler 00126 SlExtLib1WlanEventHandler, 00127 #endif 00128 00129 #ifdef SlExtLib2WlanEventHandler 00130 SlExtLib2WlanEventHandler, 00131 #endif 00132 00133 #ifdef SlExtLib3WlanEventHandler 00134 SlExtLib3WlanEventHandler, 00135 #endif 00136 00137 #ifdef SlExtLib4WlanEventHandler 00138 SlExtLib4WlanEventHandler, 00139 #endif 00140 00141 #ifdef SlExtLib5WlanEventHandler 00142 SlExtLib5WlanEventHandler, 00143 #endif 00144 }; 00145 00146 #undef _SlDrvHandleWlanEvents 00147 00148 /*********************************************************** 00149 _SlDrvHandleWlanEvents 00150 Iterates through all the wlan event handlers which are 00151 registered by the external libs/user application. 00152 ************************************************************/ 00153 void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent) 00154 { 00155 uint8_t i; 00156 00157 /* Iterate over all the extenal libs handlers */ 00158 for ( i = 0 ; i < sizeof(wlan_callbacks)/sizeof(wlan_callbacks[0]) ; i++ ) 00159 { 00160 if ( EVENT_PROPAGATION_BLOCK == wlan_callbacks[i](slWlanEvent) ) 00161 { 00162 /* exit immediately and do not call the user specific handler as well */ 00163 return; 00164 } 00165 } 00166 00167 /* At last call the Application specific handler if registered */ 00168 #ifdef sl_WlanEvtHdlr 00169 sl_WlanEvtHdlr(slWlanEvent); 00170 #endif 00171 00172 } 00173 #endif 00174 00175 00176 /* NetApp Events handling */ 00177 #if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS) 00178 00179 typedef _SlEventPropogationStatus_e (*netApp_callback) (SlNetAppEvent_t *); 00180 00181 static const netApp_callback netApp_callbacks[] = 00182 { 00183 #ifdef SlExtLib1NetAppEventHandler 00184 SlExtLib1NetAppEventHandler, 00185 #endif 00186 00187 #ifdef SlExtLib2NetAppEventHandler 00188 SlExtLib2NetAppEventHandler, 00189 #endif 00190 00191 #ifdef SlExtLib3NetAppEventHandler 00192 SlExtLib3NetAppEventHandler, 00193 #endif 00194 00195 #ifdef SlExtLib4NetAppEventHandler 00196 SlExtLib4NetAppEventHandler, 00197 #endif 00198 00199 #ifdef SlExtLib5NetAppEventHandler 00200 SlExtLib5NetAppEventHandler, 00201 #endif 00202 }; 00203 00204 #undef _SlDrvHandleNetAppEvents 00205 00206 /************************************************************ 00207 _SlDrvHandleNetAppEvents 00208 Iterates through all the net app event handlers which are 00209 registered by the external libs/user application. 00210 ************************************************************/ 00211 void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent) 00212 { 00213 uint8_t i; 00214 00215 /* Iterate over all the extenal libs handlers */ 00216 for ( i = 0 ; i < sizeof(netApp_callbacks)/sizeof(netApp_callbacks[0]) ; i++ ) 00217 { 00218 if (EVENT_PROPAGATION_BLOCK == netApp_callbacks[i](slNetAppEvent) ) 00219 { 00220 /* exit immediately and do not call the user specific handler as well */ 00221 return; 00222 } 00223 } 00224 00225 /* At last call the Application specific handler if registered */ 00226 #ifdef sl_NetAppEvtHdlr 00227 sl_NetAppEvtHdlr(slNetAppEvent); 00228 #endif 00229 00230 } 00231 #endif 00232 00233 00234 /* Http Server Events handling */ 00235 #if defined (EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) 00236 00237 typedef _SlEventPropogationStatus_e (*httpServer_callback) (SlHttpServerEvent_t*, SlHttpServerResponse_t*); 00238 00239 static const httpServer_callback httpServer_callbacks[] = 00240 { 00241 #ifdef SlExtLib1HttpServerEventHandler 00242 SlExtLib1HttpServerEventHandler, 00243 #endif 00244 00245 #ifdef SlExtLib2HttpServerEventHandler 00246 SlExtLib2HttpServerEventHandler, 00247 #endif 00248 00249 #ifdef SlExtLib3HttpServerEventHandler 00250 SlExtLib3HttpServerEventHandler, 00251 #endif 00252 00253 #ifdef SlExtLib4HttpServerEventHandler 00254 SlExtLib4HttpServerEventHandler, 00255 #endif 00256 00257 #ifdef SlExtLib5HttpServerEventHandler 00258 SlExtLib5HttpServerEventHandler, 00259 #endif 00260 }; 00261 00262 #undef _SlDrvHandleHttpServerEvents 00263 00264 /******************************************************************* 00265 _SlDrvHandleHttpServerEvents 00266 Iterates through all the http server event handlers which are 00267 registered by the external libs/user application. 00268 ********************************************************************/ 00269 void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse) 00270 { 00271 _u8 i; 00272 00273 /* Iterate over all the external libs handlers */ 00274 for ( i = 0 ; i < sizeof(httpServer_callbacks)/sizeof(httpServer_callbacks[0]) ; i++ ) 00275 { 00276 if ( EVENT_PROPAGATION_BLOCK == httpServer_callbacks[i](slHttpServerEvent, slHttpServerResponse) ) 00277 { 00278 /* exit immediately and do not call the user specific handler as well */ 00279 return; 00280 } 00281 } 00282 00283 /* At last call the Application specific handler if registered */ 00284 #ifdef sl_HttpServerCallback 00285 sl_HttpServerCallback(slHttpServerEvent, slHttpServerResponse); 00286 #endif 00287 00288 } 00289 #endif 00290 00291 00292 /* Socket Events */ 00293 #if defined (EXT_LIB_REGISTERED_SOCK_EVENTS) 00294 00295 typedef _SlEventPropogationStatus_e (*sock_callback) (SlSockEvent_t *); 00296 00297 static const sock_callback sock_callbacks[] = 00298 { 00299 #ifdef SlExtLib1SockEventHandler 00300 SlExtLib1SockEventHandler, 00301 #endif 00302 00303 #ifdef SlExtLib2SockEventHandler 00304 SlExtLib2SockEventHandler, 00305 #endif 00306 00307 #ifdef SlExtLib3SockEventHandler 00308 SlExtLib3SockEventHandler, 00309 #endif 00310 00311 #ifdef SlExtLib4SockEventHandler 00312 SlExtLib4SockEventHandler, 00313 #endif 00314 00315 #ifdef SlExtLib5SockEventHandler 00316 SlExtLib5SockEventHandler, 00317 #endif 00318 }; 00319 00320 /************************************************************* 00321 _SlDrvHandleSockEvents 00322 Iterates through all the socket event handlers which are 00323 registered by the external libs/user application. 00324 **************************************************************/ 00325 void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent) 00326 { 00327 uint8_t i; 00328 00329 /* Iterate over all the external libs handlers */ 00330 for ( i = 0 ; i < sizeof(sock_callbacks)/sizeof(sock_callbacks[0]) ; i++ ) 00331 { 00332 if ( EVENT_PROPAGATION_BLOCK == sock_callbacks[i](slSockEvent) ) 00333 { 00334 /* exit immediately and do not call the user specific handler as well */ 00335 return; 00336 } 00337 } 00338 00339 /* At last call the Application specific handler if registered */ 00340 #ifdef sl_SockEvtHdlr 00341 sl_SockEvtHdlr(slSockEvent); 00342 #endif 00343 00344 } 00345 00346 #endif 00347 00348 /*! 00349 \brief This function handles ping report events 00350 00351 \param[in] pPingReport holds the ping report statistics 00352 00353 \return None 00354 00355 \note 00356 00357 \warning 00358 */ 00359 void SimpleLinkPingReport(SlPingReport_t *pPingReport) 00360 { 00361 _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_PING_DONE); 00362 00363 if(pPingReport == NULL) 00364 Uart_Write((uint8_t*)" [PING REPORT] NULL Pointer Error\r\n"); 00365 00366 g_PingPacketsRecv = pPingReport->PacketsReceived; 00367 } 00368 00369 00370 /*******************************************************************************/ 00371 /* _sl_HandleAsync_Accept */ 00372 /*******************************************************************************/ 00373 #ifndef SL_TINY_EXT 00374 void _sl_HandleAsync_Accept(void *pVoidBuf) 00375 { 00376 _SocketAddrResponse_u *pMsgArgs = (_SocketAddrResponse_u *)_SL_RESP_ARGS_START(pVoidBuf); 00377 00378 _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); 00379 00380 VERIFY_PROTOCOL(( pMsgArgs->IpV4.sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); 00381 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); 00382 00383 memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs,sizeof(_SocketAddrResponse_u)); 00384 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00385 00386 _cc3100_._driver._SlDrvProtectionObjUnLock(); 00387 return; 00388 } 00389 00390 /*******************************************************************************/ 00391 /* _sl_HandleAsync_Connect */ 00392 /*******************************************************************************/ 00393 void _sl_HandleAsync_Connect(void *pVoidBuf) 00394 { 00395 _SocketResponse_t *pMsgArgs = (_SocketResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); 00396 00397 _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); 00398 00399 VERIFY_PROTOCOL((pMsgArgs->sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); 00400 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); 00401 00402 ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->sd = pMsgArgs->sd; 00403 ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->statusOrLen = pMsgArgs->statusOrLen; 00404 00405 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00406 _cc3100_._driver._SlDrvProtectionObjUnLock(); 00407 return; 00408 } 00409 00410 /*******************************************************************************/ 00411 /* _sl_HandleAsync_Select */ 00412 /*******************************************************************************/ 00413 void _sl_HandleAsync_Select(void *pVoidBuf) 00414 { 00415 _SelectAsyncResponse_t *pMsgArgs = (_SelectAsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); 00416 00417 _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); 00418 00419 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); 00420 00421 memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_SelectAsyncResponse_t)); 00422 00423 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00424 _cc3100_._driver._SlDrvProtectionObjUnLock(); 00425 00426 return; 00427 } 00428 00429 #endif 00430 00431 /******************************************************************************/ 00432 /* _sl_HandleAsync_DnsGetHostByName */ 00433 /******************************************************************************/ 00434 void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf) 00435 { 00436 _GetHostByNameIPv4AsyncResponse_t *pMsgArgs = (_GetHostByNameIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); 00437 00438 _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); 00439 00440 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); 00441 00442 /*IPv6 */ 00443 if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { 00444 memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv6AsyncResponse_t)); 00445 } 00446 /*IPv4 */ 00447 else 00448 { 00449 memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv4AsyncResponse_t)); 00450 } 00451 00452 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00453 _cc3100_._driver._SlDrvProtectionObjUnLock(); 00454 00455 return; 00456 } 00457 00458 /******************************************************************************/ 00459 00460 /****************************************************************************** 00461 _sl_HandleAsync_DnsGetHostByService 00462 00463 CALLER NWP - Async event on sl_DnsGetHostByService with IPv4 Family 00464 00465 00466 DESCRIPTION: 00467 00468 Async event on sl_DnsGetHostByService command with IPv4 Family. 00469 Return service attributes like IP address, port and text according to service name. 00470 The user sets a service name Full/Part (see example below), and should get the: 00471 1. IP of the service 00472 2. The port of service. 00473 3. The text of service. 00474 00475 Hence it can make a connection to the specific service and use it. 00476 It is similar to get host by name method. 00477 00478 It is done by a single shot query with PTR type on the service name. 00479 00480 00481 00482 Note: 00483 1. The return's attributes are belonged to first service that is found. 00484 It can be other services with the same service name will response to 00485 the query. The results of these responses are saved in the peer cache of the NWP, and 00486 should be read by another API. 00487 00488 00489 PARAMETERS: 00490 00491 pVoidBuf - is point to opcode of the event. 00492 it contains the outputs that are given to the user 00493 00494 outputs description: 00495 00496 1.out_pAddr[] - output: Contain the IP address of the service. 00497 2.out_pPort - output: Contain the port of the service. 00498 3.inout_TextLen - Input: Contain the max length of the text that the user wants to get. 00499 it means that if the test of service is bigger that its value than 00500 the text is cut to inout_TextLen value. 00501 Output: Contain the length of the text that is returned. Can be full text or part 00502 of the text (see above). 00503 00504 4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description). 00505 00506 * 00507 00508 00509 RETURNS: success or fail. 00510 00511 ******************************************************************************/ 00512 #ifndef SL_TINY_EXT 00513 void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf) 00514 { 00515 _GetHostByServiceAsyncResponse_t* Res; 00516 uint16_t TextLen; 00517 uint16_t UserTextLen; 00518 00519 /*pVoidBuf - is point to opcode of the event.*/ 00520 00521 /*set pMsgArgs to point to the attribute of the event.*/ 00522 _GetHostByServiceIPv4AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); 00523 00524 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); 00525 00526 /*IPv6*/ 00527 if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) { 00528 return; 00529 } 00530 /*IPv4*/ 00531 else { 00532 /************************************************************************************************* 00533 00534 1. Copy the attribute part of the evnt to the attribute part of the response 00535 memcpy(g_pCB->GetHostByServiceCB.pAsyncRsp, pMsgArgs, sizeof(_GetHostByServiceIPv4AsyncResponse_t)); 00536 00537 set to TextLen the text length of the service.*/ 00538 TextLen = pMsgArgs->TextLen; 00539 00540 /*Res pointed to mDNS global object struct */ 00541 Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs; 00542 00543 00544 00545 /*It is 4 bytes so we avoid from memcpy*/ 00546 Res->out_pAddr[0] = pMsgArgs->Address; 00547 Res->out_pPort[0] = pMsgArgs->Port; 00548 Res->Status = pMsgArgs->Status; 00549 00550 /*set to TextLen the text length of the user (input fromthe user).*/ 00551 UserTextLen = Res->inout_TextLen[0]; 00552 00553 /*Cut the service text if the user requested for smaller text.*/ 00554 UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen; 00555 Res->inout_TextLen[0] = UserTextLen ; 00556 00557 /************************************************************************************************** 00558 00559 2. Copy the payload part of the evnt (the text) to the payload part of the response 00560 the lenght of the copy is according to the text length in the attribute part. */ 00561 00562 00563 memcpy(Res->out_pText, 00564 (int8_t *)(& pMsgArgs[1]), /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/ 00565 UserTextLen); 00566 00567 00568 /**************************************************************************************************/ 00569 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00570 return; 00571 } 00572 } 00573 #endif 00574 00575 /*****************************************************************************/ 00576 /* _sl_HandleAsync_PingResponse */ 00577 /*****************************************************************************/ 00578 #ifndef SL_TINY_EXT 00579 void _sl_HandleAsync_PingResponse(void *pVoidBuf) 00580 { 00581 _PingReportResponse_t *pMsgArgs = (_PingReportResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); 00582 SlPingReport_t pingReport; 00583 00584 if(pPingCallBackFunc) { 00585 _cc3100_._netapp.CopyPingResultsToReport(pMsgArgs,&pingReport); 00586 pPingCallBackFunc(&pingReport); 00587 } else { 00588 00589 _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); 00590 VERIFY_SOCKET_CB(NULL != g_pCB->PingCB.PingAsync.pAsyncRsp); 00591 00592 if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs) { 00593 memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_PingReportResponse_t)); 00594 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00595 } 00596 _cc3100_._driver._SlDrvProtectionObjUnLock(); 00597 } 00598 return; 00599 } 00600 #endif 00601 00602 /* ******************************************************************************/ 00603 /* _SlDrvMsgReadSpawnCtx */ 00604 /* ******************************************************************************/ 00605 00606 _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) 00607 { 00608 // Uart_Write((uint8_t*)"\n\r _SlDrvMsgReadSpawnCtx \n\r"); 00609 #ifdef SL_POLLING_MODE_USED 00610 int16_t retCode = OSI_OK; 00611 // for polling based systems 00612 do { 00613 retCode = _cc3100_->_nonos.sl_LockObjLock(&g_pCB->GlobalLockObj, 0); 00614 if ( OSI_OK != retCode ) { 00615 if (TRUE == g_pCB->IsCmdRespWaited) { 00616 OSI_RET_OK_CHECK( _cc3100_->_nonos.sl_SyncObjSignal(&g_pCB->CmdSyncObj) ); 00617 return SL_RET_CODE_OK; 00618 } 00619 } 00620 00621 } while (OSI_OK != retCode); 00622 00623 #else 00624 00625 // OSI_RET_OK_CHECK(_cc3100_->_nonos.sl_LockObjLock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE, NON_OS_LOCK_OBJ_LOCK_VALUE, SL_OS_WAIT_FOREVER) ); 00626 _cc3100_._driver._SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); 00627 00628 #endif 00629 00630 g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL;// buffer must be allocated by _SlDrvMsgRead 00631 g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler= NULL; 00632 g_pCB->FunctionParams.AsyncExt.RxMsgClass = CMD_RESP_CLASS;// init to illegal value and verify it's overwritten with the valid one 00633 00634 // Messages might have been read by CmdResp context. Therefore after 00635 // getting LockObj, check again where the Pending Rx Msg is still present. 00636 if(FALSE == (_cc3100_._driver._SL_PENDING_RX_MSG(g_pCB))) { 00637 _cc3100_._driver._SlDrvObjUnLock(&g_pCB->GlobalLockObj); 00638 // OSI_RET_OK_CHECK(_cc3100_->_nonos.sl_LockObjUnlock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); 00639 return SL_RET_CODE_OK; 00640 } 00641 00642 VERIFY_RET_OK(_cc3100_._driver._SlDrvMsgRead()); 00643 00644 g_pCB->RxDoneCnt++; 00645 00646 switch(g_pCB->FunctionParams.AsyncExt.RxMsgClass) { 00647 case ASYNC_EVT_CLASS: 00648 // If got here and protected by LockObj a message is waiting 00649 // to be read 00650 VERIFY_PROTOCOL(NULL != g_pCB->FunctionParams.AsyncExt.pAsyncBuf); 00651 00652 _cc3100_._driver._SlAsyncEventGenericHandler(); 00653 00654 #if (SL_MEMORY_MGMT == SL_MEMORY_MGMT_STATIC) 00655 g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; 00656 #else 00657 free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); 00658 #endif 00659 break; 00660 case DUMMY_MSG_CLASS: 00661 case RECV_RESP_CLASS: 00662 // These types are legal in this context. Do nothing 00663 break; 00664 case CMD_RESP_CLASS: 00665 // Command response is illegal in this context. 00666 // No 'break' here: Assert! 00667 default: 00668 VERIFY_PROTOCOL(0); 00669 } 00670 00671 _cc3100_._driver._SlDrvObjUnLock(&g_pCB->GlobalLockObj); 00672 // OSI_RET_OK_CHECK(_cc3100_->_nonos.sl_LockObjUnlock(&g_pCB->GlobalLockObj, NON_OS_LOCK_OBJ_UNLOCK_VALUE)); 00673 00674 return(SL_RET_CODE_OK); 00675 00676 } 00677 00678 /*************************************************************************** 00679 _sl_HandleAsync_Stop - handles stop signalling to 00680 a waiting object 00681 ****************************************************************************/ 00682 void _sl_HandleAsync_Stop(void *pVoidBuf) 00683 { 00684 _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); 00685 00686 VERIFY_SOCKET_CB(NULL != g_pCB->StopCB.pAsyncRsp); 00687 00688 _cc3100_._driver._SlDrvProtectionObjLockWaitForever(); 00689 00690 memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_BasicResponse_t)); 00691 _cc3100_._driver._SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); 00692 _cc3100_._driver._SlDrvProtectionObjUnLock(); 00693 return; 00694 } 00695 00696 /****************************************************************************** 00697 _SlDrvDeviceEventHandler - handles internally device async events 00698 ******************************************************************************/ 00699 void _SlDrvDeviceEventHandler(void *pArgs) 00700 { 00701 _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; 00702 00703 switch(pHdr->GenHeader.Opcode) { 00704 case SL_OPCODE_DEVICE_INITCOMPLETE: 00705 _cc3100_._sl_HandleAsync_InitComplete(pHdr); 00706 00707 break; 00708 case SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE: 00709 _sl_HandleAsync_Stop(pHdr); 00710 00711 break; 00712 00713 00714 case SL_OPCODE_DEVICE_ABORT: 00715 { 00716 #if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS) 00717 SlDeviceEvent_t devHandler; 00718 devHandler.Event = SL_DEVICE_ABORT_ERROR_EVENT; 00719 devHandler.EventData.deviceReport.AbortType = *((uint32_t*)pArgs + 2); 00720 devHandler.EventData.deviceReport.AbortData = *((uint32_t*)pArgs + 3); 00721 _SlDrvHandleGeneralEvents(&devHandler); 00722 #endif 00723 } 00724 break; 00725 case SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR: 00726 #if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS) 00727 { 00728 _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pHdr); 00729 SlDeviceEvent_t devHandler; 00730 devHandler.Event = SL_DEVICE_FATAL_ERROR_EVENT; 00731 devHandler.EventData.deviceEvent.status = pMsgArgs->status & 0xFF; 00732 devHandler.EventData.deviceEvent.sender = (SlErrorSender_e)((pMsgArgs->status >> 8) & 0xFF); 00733 _SlDrvHandleGeneralEvents(&devHandler); 00734 } 00735 #endif 00736 break; 00737 default: 00738 SL_ERROR_TRACE2(MSG_306, "ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); 00739 //printf("ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); 00740 00741 } 00742 } 00743 00744 /*****************************************************************************/ 00745 /* _SlDrvNetAppEventHandler */ 00746 /*****************************************************************************/ 00747 void _SlDrvNetAppEventHandler(void *pArgs) 00748 { 00749 _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; 00750 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) 00751 SlHttpServerEvent_t httpServerEvent; 00752 SlHttpServerResponse_t httpServerResponse; 00753 #endif 00754 switch(pHdr->GenHeader.Opcode) { 00755 case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE: 00756 case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6: 00757 _sl_HandleAsync_DnsGetHostByName(pArgs); 00758 break; 00759 #ifndef SL_TINY_EXT 00760 case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE: 00761 case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6: 00762 _sl_HandleAsync_DnsGetHostByService(pArgs); 00763 break; 00764 case SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE: 00765 _sl_HandleAsync_PingResponse(pArgs); 00766 break; 00767 #endif 00768 00769 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) 00770 case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE: { 00771 00772 uint8_t *pTokenName; 00773 slHttpServerData_t Token_value; 00774 sl_NetAppHttpServerGetToken_t *httpGetToken = (sl_NetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr); 00775 pTokenName = (uint8_t *)((sl_NetAppHttpServerGetToken_t *)httpGetToken + 1); 00776 00777 httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE; 00778 httpServerResponse.ResponseData.token_value.len = MAX_TOKEN_VALUE_LEN; 00779 00780 /* Reuse the async buffer for getting the token value response from the user */ 00781 httpServerResponse.ResponseData.token_value.data = (uint8_t *)_SL_RESP_ARGS_START(pHdr) + MAX_TOKEN_NAME_LEN; 00782 httpServerEvent.Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT; 00783 00784 httpServerEvent.EventData.httpTokenName.len = httpGetToken->token_name_len; 00785 httpServerEvent.EventData.httpTokenName.data = pTokenName; 00786 00787 Token_value.token_name = pTokenName; 00788 00789 _SlDrvHandleHttpServerEvents (&httpServerEvent, &httpServerResponse); 00790 00791 Token_value.value_len = httpServerResponse.ResponseData.token_value.len; 00792 Token_value.name_len = httpServerEvent.EventData.httpTokenName.len; 00793 00794 Token_value.token_value = httpServerResponse.ResponseData.token_value.data; 00795 00796 00797 _cc3100_._netapp.sl_NetAppSendTokenValue(&Token_value); 00798 #endif 00799 } 00800 break; 00801 00802 case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE: { 00803 #ifdef sl_HttpServerCallback 00804 uint8_t *pPostParams; 00805 00806 sl_NetAppHttpServerPostToken_t *httpPostTokenArgs = (sl_NetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr); 00807 pPostParams = (uint8_t *)((sl_NetAppHttpServerPostToken_t *)httpPostTokenArgs + 1); 00808 00809 httpServerEvent.Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT; 00810 00811 httpServerEvent.EventData.httpPostData.action.len = httpPostTokenArgs->post_action_len; 00812 httpServerEvent.EventData.httpPostData.action.data = pPostParams; 00813 pPostParams+=httpPostTokenArgs->post_action_len; 00814 00815 httpServerEvent.EventData.httpPostData.token_name.len = httpPostTokenArgs->token_name_len; 00816 httpServerEvent.EventData.httpPostData.token_name.data = pPostParams; 00817 pPostParams+=httpPostTokenArgs->token_name_len; 00818 00819 httpServerEvent.EventData.httpPostData.token_value.len = httpPostTokenArgs->token_value_len; 00820 httpServerEvent.EventData.httpPostData.token_value.data = pPostParams; 00821 00822 httpServerResponse.Response = SL_NETAPP_RESPONSE_NONE; 00823 00824 00825 _SlDrvHandleHttpServerEvents (&httpServerEvent, &httpServerResponse); 00826 } 00827 break; 00828 #endif 00829 default: 00830 SL_ERROR_TRACE2(MSG_305, "ASSERT: _SlDrvNetAppEventHandler : invalid opcode = 0x%x = %i", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); 00831 VERIFY_PROTOCOL(0); 00832 } 00833 } 00834 00835 /* 00836 * ASYNCHRONOUS EVENT HANDLERS -- Start 00837 */ 00838 00839 /*! 00840 \brief This function handles WLAN events 00841 00842 \param[in] pWlanEvent is the event passed to the handler 00843 00844 \return None 00845 00846 \note 00847 00848 \warning 00849 */ 00850 #if (defined(sl_WlanEvtHdlr)) 00851 void SimpleLinkWlanEventHandler(SlWlanEvent_t *pWlanEvent) 00852 { 00853 unsigned char g_ucConnectionSSID[32+1]; //Connection SSID 00854 unsigned char g_ucConnectionBSSID[6]; //Connection BSSID 00855 00856 if(pWlanEvent == NULL) 00857 Uart_Write((uint8_t*)" [WLAN EVENT] NULL Pointer Error \n\r"); 00858 00859 switch(pWlanEvent->Event) { 00860 case SL_WLAN_CONNECT_EVENT: { 00861 _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION); 00862 00863 // Copy new connection SSID and BSSID to global parameters 00864 memcpy(g_ucConnectionSSID,pWlanEvent->EventData. 00865 STAandP2PModeWlanConnected.ssid_name, 00866 pWlanEvent->EventData.STAandP2PModeWlanConnected.ssid_len); 00867 memcpy(g_ucConnectionBSSID, 00868 pWlanEvent->EventData.STAandP2PModeWlanConnected.bssid, 00869 SL_BSSID_LENGTH); 00870 00871 memset(print_buf, 0x00, PRINT_BUF_LEN); 00872 sprintf((char*) print_buf, "[WLAN EVENT] STA Connected to the AP: %s ,""BSSID: %x:%x:%x:%x:%x:%x\n\r", 00873 g_ucConnectionSSID,g_ucConnectionBSSID[0], 00874 g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], 00875 g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], 00876 g_ucConnectionBSSID[5]); 00877 Uart_Write((uint8_t *) print_buf); 00878 /* 00879 * Information about the connected AP (like name, MAC etc) will be 00880 * available in 'slWlanConnectAsyncResponse_t' - Applications 00881 * can use it if required 00882 * 00883 * slWlanConnectAsyncResponse_t *pEventData = NULL; 00884 * pEventData = &pWlanEvent->EventData.STAandP2PModeWlanConnected; 00885 * 00886 */ 00887 } 00888 break; 00889 00890 case SL_WLAN_DISCONNECT_EVENT: { 00891 slWlanConnectAsyncResponse_t* pEventData = NULL; 00892 00893 _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_CONNECTION); 00894 _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_IP_ACQUIRED); 00895 00896 pEventData = &pWlanEvent->EventData.STAandP2PModeDisconnected; 00897 00898 /* If the user has initiated 'Disconnect' request, 'reason_code' is SL_USER_INITIATED_DISCONNECTION */ 00899 if(SL_USER_INITIATED_DISCONNECTION == pEventData->reason_code) { 00900 memset(print_buf, 0x00, PRINT_BUF_LEN); 00901 sprintf((char*) print_buf, "[WLAN EVENT]Device disconnected from the AP: %s," 00902 "BSSID: %x:%x:%x:%x:%x:%x on application's request \n\r", 00903 g_ucConnectionSSID,g_ucConnectionBSSID[0], 00904 g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], 00905 g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], 00906 g_ucConnectionBSSID[5]); 00907 Uart_Write((uint8_t *) print_buf); 00908 } else { 00909 memset(print_buf, 0x00, PRINT_BUF_LEN); 00910 sprintf((char*) print_buf, "[WLAN ERROR]Device disconnected from the AP AP: %s," 00911 "BSSID: %x:%x:%x:%x:%x:%x on an ERROR..!! \n\r", 00912 g_ucConnectionSSID,g_ucConnectionBSSID[0], 00913 g_ucConnectionBSSID[1],g_ucConnectionBSSID[2], 00914 g_ucConnectionBSSID[3],g_ucConnectionBSSID[4], 00915 g_ucConnectionBSSID[5]); 00916 Uart_Write((uint8_t *) print_buf); 00917 } 00918 memset(g_ucConnectionSSID,0,sizeof(g_ucConnectionSSID)); 00919 memset(g_ucConnectionBSSID,0,sizeof(g_ucConnectionBSSID)); 00920 } 00921 break; 00922 00923 case SL_WLAN_STA_CONNECTED_EVENT: { 00924 _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_STA_CONNECTED); 00925 } 00926 break; 00927 00928 case SL_WLAN_STA_DISCONNECTED_EVENT: { 00929 _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_STA_CONNECTED); 00930 _cc3100_.CLR_STATUS_BIT(g_Status, STATUS_BIT_IP_LEASED); 00931 } 00932 break; 00933 00934 default: { 00935 memset(print_buf, 0x00, PRINT_BUF_LEN); 00936 sprintf((char*) print_buf, "[WLAN EVENT] Unexpected event [0x%x]\n\r",pWlanEvent->Event); 00937 Uart_Write((uint8_t *) print_buf); 00938 } 00939 break; 00940 } 00941 } 00942 #endif 00943 00944 /*! 00945 \brief This function handles events for IP address acquisition via DHCP 00946 indication 00947 00948 \param[in] pNetAppEvent is the event passed to the handler 00949 00950 \return None 00951 00952 \note 00953 00954 \warning 00955 */ 00956 #if (defined(sl_NetAppEvtHdlr)) 00957 void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent) 00958 { 00959 00960 if(pNetAppEvent == NULL){ 00961 Uart_Write((uint8_t *)" [NETAPP EVENT] NULL Pointer Error \n\r"); 00962 } 00963 00964 switch(pNetAppEvent->Event) { 00965 case SL_NETAPP_IPV4_IPACQUIRED_EVENT: { 00966 SlIpV4AcquiredAsync_t *pEventData = NULL; 00967 _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_IP_ACQUIRED); 00968 pEventData = &pNetAppEvent->EventData.ipAcquiredV4; 00969 g_GatewayIP = pEventData->gateway; 00970 00971 memset(print_buf, 0x00, PRINT_BUF_LEN); 00972 sprintf((char*) print_buf, "[NETAPP EVENT] IP Acquired: IP=%d.%d.%d.%d , ""Gateway=%d.%d.%d.%d\n\r", 00973 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,3), 00974 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,2), 00975 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,1), 00976 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip,0), 00977 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,3), 00978 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,2), 00979 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,1), 00980 _cc3100_._netcfg.SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway,0)); 00981 Uart_Write((uint8_t *) print_buf); 00982 00983 } 00984 break; 00985 00986 case SL_NETAPP_IP_LEASED_EVENT: { 00987 g_StationIP = pNetAppEvent->EventData.ipLeased.ip_address; 00988 _cc3100_.SET_STATUS_BIT(g_Status, STATUS_BIT_IP_LEASED); 00989 00990 } 00991 break; 00992 00993 default: { 00994 memset(print_buf, 0x00, PRINT_BUF_LEN); 00995 sprintf((char*) print_buf, "[NETAPP EVENT] Unexpected event [0x%x] \n\r",pNetAppEvent->Event); 00996 Uart_Write((uint8_t *) print_buf); 00997 } 00998 break; 00999 } 01000 } 01001 #endif 01002 01003 /*! 01004 \brief This function handles socket events indication 01005 01006 \param[in] pSock is the event passed to the handler 01007 01008 \return None 01009 */ 01010 #if (defined(sl_SockEvtHdlr)) 01011 void SimpleLinkSockEventHandler(SlSockEvent_t *pSock) 01012 { 01013 if(pSock == NULL) 01014 Uart_Write((uint8_t *)" [SOCK EVENT] NULL Pointer Error \n\r"); 01015 01016 switch( pSock->Event ) 01017 { 01018 case SL_SOCKET_TX_FAILED_EVENT: 01019 /* 01020 * TX Failed 01021 * 01022 * Information about the socket descriptor and status will be 01023 * available in 'SlSockEventData_t' - Applications can use it if 01024 * required 01025 * 01026 * SlSockEventData_t *pEventData = NULL; 01027 * pEventData = & pSock->EventData; 01028 */ 01029 01030 switch( pSock->socketAsyncEvent.SockTxFailData.status ) 01031 { 01032 case SL_ECLOSE: 01033 Uart_Write((uint8_t *)" [SOCK EVENT] Close socket operation, failed to transmit all queued packets\n\r"); 01034 break; 01035 default: 01036 memset(print_buf, 0x00, PRINT_BUF_LEN); 01037 sprintf((char*) print_buf, "[SOCK ERROR] - TX FAILED : socket %d , reason""(%d) \n\n", pSock->socketAsyncEvent.SockTxFailData.sd, pSock->socketAsyncEvent.SockTxFailData.status); 01038 Uart_Write((uint8_t *) print_buf); 01039 break; 01040 } 01041 break; 01042 01043 default: 01044 memset(print_buf, 0x00, PRINT_BUF_LEN); 01045 sprintf((char*) print_buf, "[SOCK EVENT] - Unexpected Event [%x0x]\n\n",pSock->Event); 01046 Uart_Write((uint8_t *) print_buf); 01047 break; 01048 } 01049 } 01050 #endif 01051 01052 /*! 01053 \brief This function handles callback for the HTTP server events 01054 01055 \param[in] pHttpEvent - Contains the relevant event information 01056 \param[in] pHttpResponse - Should be filled by the user with the 01057 relevant response information 01058 01059 \return None 01060 01061 \note 01062 01063 \warning 01064 */ 01065 #if (defined(sl_HttpServerCallback)) 01066 void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *pHttpEvent, SlHttpServerResponse_t *pHttpResponse) 01067 { 01068 /* 01069 * This application doesn't work with HTTP server - Hence these 01070 * events are not handled here 01071 */ 01072 Uart_Write((uint8_t *)" [HTTP EVENT] Unexpected event \n\r"); 01073 } 01074 #endif 01075 /*! 01076 \brief This function handles general error events indication 01077 01078 \param[in] pDevEvent is the event passed to the handler 01079 01080 \return None 01081 */ 01082 #if (defined(sl_GeneralEvtHdlr)) 01083 void SimpleLinkGeneralEventHandler(SlDeviceEvent_t *pDevEvent) 01084 { 01085 /* 01086 * Most of the general errors are not FATAL are are to be handled 01087 * appropriately by the application 01088 */ 01089 memset(print_buf, 0x00, PRINT_BUF_LEN); 01090 sprintf((char*) print_buf, "[GENERAL EVENT] - ID=[%d] Sender=[%d]\n\n", pDevEvent->EventData.deviceEvent.status, pDevEvent->EventData.deviceEvent.sender); 01091 Uart_Write((uint8_t *) print_buf); 01092 } 01093 #endif 01094 01095 #ifdef __cplusplus 01096 } 01097 #endif /* __cplusplus */ 01098 01099 //}//namespace
Generated on Tue Jul 12 2022 18:08:23 by
1.7.2
