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