From 992735ed2786060d39f1e1513373a8c942fb2cb2 Mon Sep 17 00:00:00 2001 From: PhilLaFayette Date: Fri, 27 May 2016 18:31:25 -0500 Subject: [PATCH] Updated Energia SLDriver to 1.0.1.6 --- .../WiFi/utility/SimpleLinkForEnergia.cpp | 23 +- .../WiFi/utility/SimpleLinkForEnergia.h | 5 +- hardware/lm4f/libraries/WiFi/utility/device.c | 314 +++-- hardware/lm4f/libraries/WiFi/utility/device.h | 336 ++--- hardware/lm4f/libraries/WiFi/utility/driver.c | 1142 +++++++++++------ hardware/lm4f/libraries/WiFi/utility/driver.h | 264 ++-- .../lm4f/libraries/WiFi/utility/flowcont.c | 30 +- .../lm4f/libraries/WiFi/utility/flowcont.h | 32 +- hardware/lm4f/libraries/WiFi/utility/fs.c | 214 +-- hardware/lm4f/libraries/WiFi/utility/fs.h | 134 +- hardware/lm4f/libraries/WiFi/utility/netapp.c | 1088 ++++++++-------- hardware/lm4f/libraries/WiFi/utility/netapp.h | 208 +-- hardware/lm4f/libraries/WiFi/utility/netcfg.c | 95 +- hardware/lm4f/libraries/WiFi/utility/netcfg.h | 216 +++- hardware/lm4f/libraries/WiFi/utility/nonos.c | 212 +-- hardware/lm4f/libraries/WiFi/utility/nonos.h | 121 +- .../libraries/WiFi/utility/objInclusion.h | 76 +- .../lm4f/libraries/WiFi/utility/protocol.h | 595 ++++----- .../lm4f/libraries/WiFi/utility/simplelink.h | 571 +++++---- hardware/lm4f/libraries/WiFi/utility/socket.c | 571 +++++---- hardware/lm4f/libraries/WiFi/utility/socket.h | 704 +++++----- hardware/lm4f/libraries/WiFi/utility/spawn.c | 95 +- hardware/lm4f/libraries/WiFi/utility/spawn.h | 36 +- hardware/lm4f/libraries/WiFi/utility/trace.h | 76 +- hardware/lm4f/libraries/WiFi/utility/user.h | 2 +- hardware/lm4f/libraries/WiFi/utility/wlan.c | 346 +++-- hardware/lm4f/libraries/WiFi/utility/wlan.h | 591 +++++---- .../libraries/WiFi/utility/wlan_rx_filters.h | 50 +- 28 files changed, 4611 insertions(+), 3536 deletions(-) diff --git a/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.cpp b/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.cpp index 59431d636c7..f7353c71a26 100644 --- a/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.cpp +++ b/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.cpp @@ -3,6 +3,9 @@ * * Copyright (C) 2014 Noah Luskey | LuskeyNoah@gmail.com * + * Contributors: + * Phil LaFayette (MH Electric Motor & Control Corp.) - Upgraded CC31xx/CC32xx Host Driver to v1.0.1.6, May 27, 2016 + * */ #include "SimpleLinkForEnergia.h" @@ -42,7 +45,7 @@ void CC3100_disable() // digitalWrite(WiFiClass::pin_nhib, LOW); } - + // //open the SPI interface (none of the inputs actually matter) // @@ -57,14 +60,14 @@ int spi_Open(char* pIfName , unsigned long flags) pinMode(WiFiClass::pin_irq, INPUT); pinMode(WiFiClass::pin_nhib, OUTPUT); digitalWrite(WiFiClass::pin_nhib, LOW); - + // //set the spi port up using Energia functions // SPI.begin(); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE0); - + // //return a success // @@ -91,7 +94,7 @@ int spi_Close(int Fd) int spi_Read(int Fd , char* pBuff , int Len)\ { digitalWrite(WiFiClass::pin_cs, LOW); - + DEBUG_TRACE("SPI_READ"); // //read bytes into the buffer by transmitting NULL over and over @@ -100,7 +103,7 @@ int spi_Read(int Fd , char* pBuff , int Len)\ pBuff[i] = SPI.transfer(0); DEBUG_TRACE(pBuff[i]); } - + digitalWrite(WiFiClass::pin_cs, HIGH); return Len; } @@ -111,7 +114,7 @@ int spi_Read(int Fd , char* pBuff , int Len)\ int spi_Write(int Fd , char* pBuff , int Len) { digitalWrite(WiFiClass::pin_cs, LOW); - + DEBUG_TRACE("SPI_WRITE"); // //transfer all the bytes from the buffer @@ -120,7 +123,7 @@ int spi_Write(int Fd , char* pBuff , int Len) SPI.transfer(pBuff[i]); DEBUG_TRACE(pBuff[i]); } - + digitalWrite(WiFiClass::pin_cs, HIGH); return Len; } @@ -130,7 +133,7 @@ int registerInterruptHandler(void* InterruptHdl , void* pValue) { delay(100); DEBUG_TRACE("INTERRUPT REGISTER"); - + // //the IRQ line may already be high //in this case, manually call the interrupt first @@ -139,7 +142,7 @@ int registerInterruptHandler(void* InterruptHdl , void* pValue) void (*interruptFunction)(void) = (void (*)())InterruptHdl; interruptFunction(); } - + if (InterruptHdl == NULL) { // //according to documentation, a NULL pointer means remove the interrupt @@ -151,7 +154,7 @@ int registerInterruptHandler(void* InterruptHdl , void* pValue) // attachInterrupt(WiFiClass::pin_irq, (void (*)())InterruptHdl, RISING); } - + delay(100); return 0; } diff --git a/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.h b/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.h index f7f43fd3d0d..5cd0a471a0a 100644 --- a/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.h +++ b/hardware/lm4f/libraries/WiFi/utility/SimpleLinkForEnergia.h @@ -3,6 +3,9 @@ * * Copyright (C) 2014 Noah Luskey | LuskeyNoah@gmail.com * + * Contributors: + * Phil LaFayette (MH Electric Motor & Control Corp.) - Upgraded CC31xx/CC32xx Host Driver to v1.0.1.6, May 27, 2016 + * */ @@ -28,4 +31,4 @@ int registerInterruptHandler(void* InterruptHdl , void* pValue); } #endif /* extern "C" */ -#endif /* inclusion guard end */ \ No newline at end of file +#endif /* inclusion guard end */ diff --git a/hardware/lm4f/libraries/WiFi/utility/device.c b/hardware/lm4f/libraries/WiFi/utility/device.c index b58df11a96c..e578594d359 100644 --- a/hardware/lm4f/libraries/WiFi/utility/device.c +++ b/hardware/lm4f/libraries/WiFi/utility/device.c @@ -1,37 +1,37 @@ /* -* device.c - CC31xx/CC32xx Host Driver Implementation -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the -* distribution. -* -* Neither the name of Texas Instruments Incorporated nor the names of -* its contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* + * device.c - CC31xx/CC32xx Host Driver Implementation + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * */ @@ -43,31 +43,35 @@ #include "protocol.h" #include "flowcont.h" #include "driver.h" +#include "wlan.h" /*****************************************************************************/ /* Internal functions */ /*****************************************************************************/ -const _i8 StartResponseLUT[8] = +static SlWlanMode_e _sl_GetStartResponseConvert(_i32 Status); + + +static const SlWlanMode_e StartResponseLUT[8] = { - ROLE_UNKNOWN_ERR, + ROLE_UNKNOWN, ROLE_STA, ROLE_STA_ERR, ROLE_AP, ROLE_AP_ERR, ROLE_P2P, ROLE_P2P_ERR, - ROLE_UNKNOWN_ERR + INIT_CALIB_FAIL }; - -_i16 _sl_GetStartResponseConvert(_u32 Status) +static SlWlanMode_e _sl_GetStartResponseConvert(_i32 Status) { - return (_i16)StartResponseLUT[Status & 0x7]; + return StartResponseLUT[Status & 0x7]; } + /*****************************************************************************/ /* API Functions */ /*****************************************************************************/ @@ -81,7 +85,7 @@ _i16 _sl_GetStartResponseConvert(_u32 Status) void sl_Task(void) { #ifdef _SlTaskEntry - _SlTaskEntry(); + (void)_SlTaskEntry(); #endif } #endif @@ -92,14 +96,19 @@ void sl_Task(void) #if _SL_INCLUDE_FUNC(sl_Start) _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack) { - _i16 ObjIdx = MAX_CONCURRENT_ACTIONS; + _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; InitComplete_t AsyncRsp; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); /* Perform any preprocessing before enable networking services */ - //sl_DeviceEnablePreamble(); +#ifdef sl_DeviceEnablePreamble + sl_DeviceEnablePreamble(); +#endif /* ControlBlock init */ - _SlDrvDriverCBInit(); + (void)_SlDrvDriverCBInit(); /* open the interface: usually SPI or UART */ if (NULL == pIfHdl) @@ -110,7 +119,7 @@ _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCal { g_pCB->FD = (_SlFd_t)pIfHdl; } - + ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS); if (MAX_CONCURRENT_ACTIONS == ObjIdx) @@ -125,15 +134,28 @@ _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCal sl_IfRegIntHdlr((SL_P_EVENT_HANDLER)_SlDrvRxIrqHandler, NULL); g_pCB->pInitCallback = pInitCallBack; + sl_DeviceEnable(); - + if (NULL == pInitCallBack) { +#ifdef SL_TINY_EXT _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); +#else + _SlReturnVal_t retVal; + retVal = _SlDrvSyncObjWaitTimeout(&g_pCB->ObjPool[ObjIdx].SyncObj, + INIT_COMPLETE_TIMEOUT, + SL_DRIVER_API_DEVICE_SL_START); + if (retVal) + { + return SL_API_ABORTED; + } +#endif + /* release Pool Object */ _SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex); - return _sl_GetStartResponseConvert(AsyncRsp.Status); + return _sl_GetStartResponseConvert(AsyncRsp.Status); } else { @@ -145,14 +167,14 @@ _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCal #endif /*************************************************************************** -_sl_HandleAsync_InitComplete - handles init complete signalling to +_sl_HandleAsync_InitComplete - handles init complete signalling to a waiting object ****************************************************************************/ -void _sl_HandleAsync_InitComplete(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_InitComplete(void *pVoidBuf) { InitComplete_t *pMsgArgs = (InitComplete_t *)_SL_RESP_ARGS_START(pVoidBuf); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); if(g_pCB->pInitCallback) { @@ -161,20 +183,22 @@ void _sl_HandleAsync_InitComplete(void *pVoidBuf) else { sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(InitComplete_t)); - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); } - - _SlDrvProtectionObjUnLock(); - + + SL_DRV_PROTECTION_OBJ_UNLOCK(); + if(g_pCB->pInitCallback) { _SlDrvReleasePoolObj(g_pCB->FunctionParams.AsyncExt.ActionIndex); } + + return SL_RET_CODE_OK; } /*************************************************************************** -_sl_HandleAsync_Stop - handles stop signalling to +_sl_HandleAsync_Stop - handles stop signalling to a waiting object ****************************************************************************/ void _sl_HandleAsync_Stop(void *pVoidBuf) @@ -183,13 +207,13 @@ void _sl_HandleAsync_Stop(void *pVoidBuf) VERIFY_SOCKET_CB(NULL != g_pCB->StopCB.pAsyncRsp); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_BasicResponse_t)); - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - _SlDrvProtectionObjUnLock(); - + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + SL_DRV_PROTECTION_OBJ_UNLOCK(); + return; } @@ -200,14 +224,14 @@ sl_stop typedef union { _DevStopCommand_t Cmd; - _BasicResponse_t Rsp; + _BasicResponse_t Rsp; }_SlStopMsg_u; -const _SlCmdCtrl_t _SlStopCmdCtrl = +static const _SlCmdCtrl_t _SlStopCmdCtrl = { SL_OPCODE_DEVICE_STOP_COMMAND, - sizeof(_DevStopCommand_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_DevStopCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; #if _SL_INCLUDE_FUNC(sl_Stop) @@ -216,41 +240,56 @@ _i16 sl_Stop(const _u16 timeout) _i16 RetVal=0; _SlStopMsg_u Msg; _BasicResponse_t AsyncRsp; - _i8 ObjIdx = MAX_CONCURRENT_ACTIONS; - /* if timeout is 0 the shutdown is forced immediately */ - if( 0 == timeout ) - { - sl_IfRegIntHdlr(NULL, NULL); - sl_DeviceDisable(); - RetVal = sl_IfClose(g_pCB->FD); - - } - else + _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + + /* If we are in the middle of assert handling then ignore stopping + * the device with timeout and force immediate shutdown as we would like + * to avoid any additional commands to the NWP */ + if( (timeout != 0) +#ifndef SL_TINY_EXT + && ((_u8)FALSE == g_bDeviceRestartIsRequired) +#endif + ) { /* let the device make the shutdown using the defined timeout */ Msg.Cmd.Timeout = timeout; - ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS); - if (MAX_CONCURRENT_ACTIONS == ObjIdx) - { + ObjIdx = _SlDrvProtectAsyncRespSetting((_u8 *)&AsyncRsp, START_STOP_ID, SL_MAX_SOCKETS); + if (MAX_CONCURRENT_ACTIONS == ObjIdx) + { return SL_POOL_IS_EMPTY; - } + } + + VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlStopCmdCtrl, &Msg, NULL)); - VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlStopCmdCtrl, &Msg, NULL)); + if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status) + { - if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status) - { +#ifdef SL_TINY_EXT _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); + /* Wait for sync object to be signaled */ +#else + SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj, + STOP_DEVICE_TIMEOUT, + SL_DRIVER_API_DEVICE_SL_STOP); +#endif + Msg.Rsp.status = AsyncRsp.status; RetVal = Msg.Rsp.status; - } - - _SlDrvReleasePoolObj(ObjIdx); - sl_IfRegIntHdlr(NULL, NULL); - sl_DeviceDisable(); - sl_IfClose(g_pCB->FD); + } + _SlDrvReleasePoolObj(ObjIdx); } - _SlDrvDriverCBDeinit(); + + sl_IfRegIntHdlr(NULL, NULL); + sl_DeviceDisable(); + RetVal = sl_IfClose(g_pCB->FD); + + (void)_SlDrvDriverCBDeinit(); + +#ifndef SL_TINY_EXT + /* Clear the restart device flag */ + g_bDeviceRestartIsRequired = FALSE; +#endif return RetVal; } @@ -262,8 +301,8 @@ sl_EventMaskSet *****************************************************************************/ typedef union { - _DevMaskEventSetCommand_t Cmd; - _BasicResponse_t Rsp; + _DevMaskEventSetCommand_t Cmd; + _BasicResponse_t Rsp; }_SlEventMaskSetMsg_u; @@ -271,11 +310,11 @@ typedef union #if _SL_INCLUDE_FUNC(sl_EventMaskSet) -const _SlCmdCtrl_t _SlEventMaskSetCmdCtrl = +static const _SlCmdCtrl_t _SlEventMaskSetCmdCtrl = { SL_OPCODE_DEVICE_EVENTMASKSET, - sizeof(_DevMaskEventSetCommand_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_DevMaskEventSetCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; @@ -283,6 +322,10 @@ _i16 sl_EventMaskSet(const _u8 EventClass ,const _u32 Mask) { _SlEventMaskSetMsg_u Msg; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.group = EventClass; Msg.Cmd.mask = Mask; @@ -297,7 +340,7 @@ sl_EventMaskGet ******************************************************************************/ typedef union { - _DevMaskEventGetCommand_t Cmd; + _DevMaskEventGetCommand_t Cmd; _DevMaskEventGetResponse_t Rsp; }_SlEventMaskGetMsg_u; @@ -305,11 +348,11 @@ typedef union #if _SL_INCLUDE_FUNC(sl_EventMaskGet) -const _SlCmdCtrl_t _SlEventMaskGetCmdCtrl = +static const _SlCmdCtrl_t _SlEventMaskGetCmdCtrl = { SL_OPCODE_DEVICE_EVENTMASKGET, - sizeof(_DevMaskEventGetCommand_t), - sizeof(_DevMaskEventGetResponse_t) + (_SlArgSize_t)sizeof(_DevMaskEventGetCommand_t), + (_SlArgSize_t)sizeof(_DevMaskEventGetResponse_t) }; @@ -317,6 +360,9 @@ _i16 sl_EventMaskGet(const _u8 EventClass,_u32 *pMask) { _SlEventMaskGetMsg_u Msg; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); Msg.Cmd.group = EventClass; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlEventMaskGetCmdCtrl, &Msg, NULL)); @@ -334,25 +380,28 @@ sl_DevGet typedef union { - _DeviceSetGet_t Cmd; - _DeviceSetGet_t Rsp; + _DeviceSetGet_t Cmd; + _DeviceSetGet_t Rsp; }_SlDeviceMsgGet_u; #if _SL_INCLUDE_FUNC(sl_DevGet) -const _SlCmdCtrl_t _SlDeviceGetCmdCtrl = +static const _SlCmdCtrl_t _SlDeviceGetCmdCtrl = { SL_OPCODE_DEVICE_DEVICEGET, - sizeof(_DeviceSetGet_t), - sizeof(_DeviceSetGet_t) + (_SlArgSize_t)sizeof(_DeviceSetGet_t), + (_SlArgSize_t)sizeof(_DeviceSetGet_t) }; _i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues) { _SlDeviceMsgGet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); if (*pConfigLen == 0) { @@ -362,8 +411,8 @@ _i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues) if( pOption ) { - _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = *pConfigLen; + _SlDrvResetCmdExt(&CmdExt); + CmdExt.RxPayloadLen = (_i16)*pConfigLen; CmdExt.pRxPayload = (_u8 *)pValues; Msg.Cmd.DeviceSetId = DeviceGetId; @@ -377,7 +426,7 @@ _i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues) *pOption = (_u8)Msg.Rsp.Option; } - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { *pConfigLen = (_u8)CmdExt.RxPayloadLen; return SL_ESMALLBUF; @@ -409,11 +458,11 @@ typedef union #if _SL_INCLUDE_FUNC(sl_DevSet) -const _SlCmdCtrl_t _SlDeviceSetCmdCtrl = +static const _SlCmdCtrl_t _SlDeviceSetCmdCtrl = { SL_OPCODE_DEVICE_DEVICESET, - sizeof(_DeviceSetGet_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_DeviceSetGet_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const _u8 *pValues) @@ -421,6 +470,9 @@ _i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const _SlDeviceMsgSet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); @@ -441,9 +493,11 @@ _i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const /****************************************************************************** _SlDrvDeviceEventHandler - handles internally device async events ******************************************************************************/ -void _SlDrvDeviceEventHandler(void* pArgs) +_SlReturnVal_t _SlDrvDeviceEventHandler(void* pEventInfo) { - _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; + DeviceEventInfo_t* pInfo = (DeviceEventInfo_t*)pEventInfo; + _SlResponseHeader_t* pHdr = (_SlResponseHeader_t *)pInfo->pAsyncMsgBuff; + _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pHdr); switch(pHdr->GenHeader.Opcode) { @@ -455,43 +509,47 @@ void _SlDrvDeviceEventHandler(void* pArgs) break; - case SL_OPCODE_DEVICE_ABORT: - { -#if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS) - SlDeviceEvent_t devHandler; - devHandler.Event = SL_DEVICE_ABORT_ERROR_EVENT; - devHandler.EventData.deviceReport.AbortType = *((_u32*)pArgs + 2); - devHandler.EventData.deviceReport.AbortData = *((_u32*)pArgs + 3); - _SlDrvHandleGeneralEvents(&devHandler); -#endif - } + case SL_OPCODE_DEVICE_ABORT: + { + /* release global lock of cmd context */ + if (pInfo->bInCmdContext == TRUE) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + } + +#ifndef SL_TINY_EXT + _SlDriverHandleError(SL_DEVICE_ABORT_ERROR_EVENT, + *((_u32*)pMsgArgs), /* Abort type */ + *((_u32*)pMsgArgs + 1)); /* Abort data */ +#endif + } break; - case SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR: -#if defined (sl_GeneralEvtHdlr) || defined(EXT_LIB_REGISTERED_GENERAL_EVENTS) + case SL_OPCODE_DEVICE_ASYNC_GENERAL_ERROR: { - _BasicResponse_t *pMsgArgs = (_BasicResponse_t *)_SL_RESP_ARGS_START(pHdr); SlDeviceEvent_t devHandler; - devHandler.Event = SL_DEVICE_FATAL_ERROR_EVENT; + devHandler.Event = SL_DEVICE_GENERAL_ERROR_EVENT; devHandler.EventData.deviceEvent.status = pMsgArgs->status & 0xFF; devHandler.EventData.deviceEvent.sender = (SlErrorSender_e)((pMsgArgs->status >> 8) & 0xFF); _SlDrvHandleGeneralEvents(&devHandler); } -#endif + break; default: SL_ERROR_TRACE2(MSG_306, "ASSERT: _SlDrvDeviceEventHandler : invalid opcode = 0x%x = %1", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); } + + return SL_OS_RET_CODE_OK; } /****************************************************************************** -sl_UartSetMode +sl_UartSetMode ******************************************************************************/ #ifdef SL_IF_TYPE_UART typedef union { - _DevUartSetModeCommand_t Cmd; + _DevUartSetModeCommand_t Cmd; _DevUartSetModeResponse_t Rsp; }_SlUartSetModeMsg_u; @@ -502,14 +560,14 @@ typedef union const _SlCmdCtrl_t _SlUartSetModeCmdCtrl = { SL_OPCODE_DEVICE_SETUARTMODECOMMAND, - sizeof(_DevUartSetModeCommand_t), - sizeof(_DevUartSetModeResponse_t) + (_SlArgSize_t)sizeof(_DevUartSetModeCommand_t), + (_SlArgSize_t)sizeof(_DevUartSetModeResponse_t) }; _i16 sl_UartSetMode(const SlUartIfParams_t* pUartParams) { _SlUartSetModeMsg_u Msg; - _u32 magicCode = 0xFFFFFFFF; + _u32 magicCode = (_u32)0xFFFFFFFF; Msg.Cmd.BaudRate = pUartParams->BaudRate; Msg.Cmd.FlowControlEnable = pUartParams->FlowControlEnable; diff --git a/hardware/lm4f/libraries/WiFi/utility/device.h b/hardware/lm4f/libraries/WiFi/utility/device.h index ad123a313ad..5aca3a02358 100644 --- a/hardware/lm4f/libraries/WiFi/utility/device.h +++ b/hardware/lm4f/libraries/WiFi/utility/device.h @@ -1,35 +1,35 @@ /* * device.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -60,17 +60,17 @@ extern "C" { /*****************************************************************************/ /* Macro declarations */ /*****************************************************************************/ - - + + /* SL internal Error codes */ - + /* Receive this error in case there are no resources to issue the command If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase) If not, try again later */ #define SL_POOL_IS_EMPTY (-2000) - -/* Receive this error in case a given length for RX buffer was too small. - Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size + +/* Receive this error in case a given length for RX buffer was too small. + Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size Recommend to increase buffer size */ #define SL_ESMALLBUF (-2001) @@ -85,6 +85,9 @@ extern "C" { /* Failed to open interface */ #define SL_BAD_INTERFACE (-2004) +/* API has been aborted due to an error detected by host driver */ +#define SL_API_ABORTED (-100) + /* End of SL internal Error codes */ @@ -111,7 +114,21 @@ typedef enum SL_ERR_SENDER_DHCP_CLIENT, SL_ERR_DISPATCHER, SL_ERR_NUM_SENDER_LAST=0xFF -}SlErrorSender_e; +}SlErrorSender_e; + + +typedef enum +{ + SL_DRIVER_API_DEVICE_SL_START = 0, + SL_DRIVER_API_DEVICE_SL_STOP, + SL_DRIVER_API_NETAPP_PING_START, + SL_DRIVER_API_SOCKET_CONNECT, + SL_DRIVER_API_SOCKET_ACCEPT, + SL_DRIVER_API_SOCKET_SELECT, + SL_DRIVER_API_SOCKET_RECV, + SL_DRIVER_API_SOCKET_RECVFROM + +} SlDriverAPIWithTimeout_e; /* Error codes */ @@ -133,17 +150,17 @@ typedef enum #define SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED (-94) /* supplicant error */ #define SL_ERROR_DHCP_CLIENT_RENEW_FAILED (-100) /* DHCP client error */ /* WLAN Connection management status */ -#define SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED (-102) -#define SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT (-103) -#define SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT (-104) -#define SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE (-105) -#define SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE (-106) -#define SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE (-107) -#define SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER (-108) -#define SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT (-109) -#define SL_ERROR_CON_MGMT_STATUS_SG_RESELECT (-110) -#define SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE (-111) -#define SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE (-112) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_UNSPECIFIED (-102) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_AUTH_REJECT (-103) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT (-104) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE (-105) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE (-106) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE (-107) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER (-108) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT (-109) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_SG_RESELECT (-110) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_ROC_FAILURE (-111) +#define SL_GENERAL_ERROR_CON_MGMT_STATUS_MIC_FAILURE (-112) /* end of WLAN connection management error statuses */ #define SL_ERROR_WAKELOCK_ERROR_PREFIX (-115) /* Wake lock expired */ #define SL_ERROR_LENGTH_ERROR_PREFIX (-116) /* Uart header length error */ @@ -159,11 +176,10 @@ typedef enum /* Declare the different event group classifications - The SimpleLink device send asynchronous events. Each event has a group + The SimpleLink device send asynchronous events. Each event has a group classification according to its nature. */ -#if 1 /* SL_EVENT_CLASS_WLAN connection user events */ #define SL_WLAN_CONNECT_EVENT (1) #define SL_WLAN_DISCONNECT_EVENT (2) @@ -177,14 +193,23 @@ typedef enum #define SL_WLAN_P2P_DEV_FOUND_EVENT (7) #define SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT (8) #define SL_WLAN_CONNECTION_FAILED_EVENT (9) -/* SL_EVENT_CLASS_DEVICE user events */ -#define SL_DEVICE_FATAL_ERROR_EVENT (1) -#define SL_DEVICE_ABORT_ERROR_EVENT (2) -/* SL_EVENT_CLASS_BSD user events */ -#define SL_SOCKET_TX_FAILED_EVENT (1) +typedef enum +{ + SL_DEVICE_GENERAL_ERROR_EVENT = 1, + SL_DEVICE_ABORT_ERROR_EVENT, + SL_DEVICE_DRIVER_ASSERT_ERROR_EVENT, + SL_DEVICE_DRIVER_TIMEOUT_CMD_COMPLETE, + SL_DEVICE_DRIVER_TIMEOUT_SYNC_PATTERN, + SL_DEVICE_DRIVER_TIMEOUT_ASYNC_EVENT, + SL_DEVICE_ERROR_MAX +} +SlDeviceDriverError_e; + +/* SL_EVENT_CLASS_BSD user events */ +#define SL_SOCKET_TX_FAILED_EVENT (1) #define SL_SOCKET_ASYNC_EVENT (2) -/* SL_EVENT_CLASS_NETAPP user events */ +/* SL_EVENT_CLASS_NETAPP user events */ #define SL_NETAPP_IPV4_IPACQUIRED_EVENT (1) #define SL_NETAPP_IPV6_IPACQUIRED_EVENT (2) #define SL_NETAPP_IP_LEASED_EVENT (3) @@ -193,7 +218,6 @@ typedef enum /* Server Events */ #define SL_NETAPP_HTTPGETTOKENVALUE_EVENT (1) #define SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT (2) -#endif /* @@ -210,39 +234,56 @@ typedef enum #define SL_EVENT_CLASS_NETCFG (5) #define SL_EVENT_CLASS_FS (6) - + /****************** DEVICE CLASS status ****************/ #define EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L) #define STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L) - + /****************** WLAN CLASS status ****************/ #define EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L) #define EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L) #define EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L) #define EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L) #define STATUS_WLAN_STA_CONNECTED (0x80000000L) - + /****************** NETAPP CLASS status ****************/ #define EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L) #define EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L) #define EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L) #define EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L) - + /****************** BSD CLASS status ****************/ #define EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L) - + /****************** FS CLASS ****************/ - + + + + +/******************************************** +For backward compatability (version 1.0.0.10) +*********************************************/ +#define SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED SL_GENERAL_ERROR_CON_MGMT_STATUS_UNSPECIFIED +#define SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT SL_GENERAL_ERROR_CON_MGMT_STATUS_AUTH_REJECT +#define SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT SL_GENERAL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT +#define SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE SL_GENERAL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE +#define SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE +#define SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE +#define SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER SL_GENERAL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER +#define SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT SL_GENERAL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT +#define SL_ERROR_CON_MGMT_STATUS_SG_RESELECT SL_GENERAL_ERROR_CON_MGMT_STATUS_SG_RESELECT +#define SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE SL_GENERAL_ERROR_CON_MGMT_STATUS_ROC_FAILURE +#define SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE SL_GENERAL_ERROR_CON_MGMT_STATUS_MIC_FAILURE +#define SL_DEVICE_FATAL_ERROR_EVENT SL_DEVICE_GENERAL_ERROR_EVENT /*****************************************************************************/ /* Structure/Enum declarations */ /*****************************************************************************/ -#define ROLE_UNKNOWN_ERR (-1) #ifdef SL_IF_TYPE_UART -typedef struct +typedef struct { _u32 BaudRate; _u8 FlowControlEnable; @@ -265,11 +306,10 @@ typedef struct _u16 Padding; }SlVersionFull; - typedef struct { - _u32 AbortType; - _u32 AbortData; + _u32 AbortType; + _u32 AbortData; }sl_DeviceReportAbort; @@ -279,19 +319,24 @@ typedef struct SlErrorSender_e sender; }sl_DeviceReport; +typedef struct +{ + _u32 info; +}sl_DeviceDriverErrorReport; typedef union { - sl_DeviceReport deviceEvent; - sl_DeviceReportAbort deviceReport; -} _SlDeviceEventData_u; + sl_DeviceReport deviceEvent; + sl_DeviceReportAbort deviceReport; + sl_DeviceDriverErrorReport deviceDriverReport; +} SlDeviceEventData_u; typedef struct { - _u32 Event; - _SlDeviceEventData_u EventData; + SlDeviceDriverError_e Event; + SlDeviceEventData_u EventData; } SlDeviceEvent_t; -typedef struct +typedef struct { /* time */ _u32 sl_tm_sec; @@ -302,11 +347,10 @@ typedef struct _u32 sl_tm_mon; /* 1-12 */ _u32 sl_tm_year; /* YYYY 4 digits */ _u32 sl_tm_week_day; /* not required */ - _u32 sl_tm_year_day; /* not required */ - _u32 reserved[3]; + _u32 sl_tm_year_day; /* not required */ + _u32 reserved[3]; }SlDateTime_t; - /******************************************************************************/ /* Type declarations */ /******************************************************************************/ @@ -318,50 +362,50 @@ typedef void (*P_INIT_CALLBACK)(_u32 Status); /*! \brief Start the SimpleLink device - - This function initialize the communication interface, set the enable pin + + This function initialize the communication interface, set the enable pin of the device, and call to the init complete callback. - \param[in] pIfHdl Opened Interface Object. In case the interface + \param[in] pIfHdl Opened Interface Object. In case the interface must be opened outside the SimpleLink Driver, the user might give the handler to be used in \n - any access of the communication interface with the + any access of the communication interface with the device (UART/SPI). \n The SimpleLink driver will open an interface port only if this parameter is null! \n - \param[in] pDevName The name of the device to open. Could be used when - the pIfHdl is null, to transfer information to the + \param[in] pDevName The name of the device to open. Could be used when + the pIfHdl is null, to transfer information to the open interface function \n This pointer could be used to pass additional information to sl_IfOpen in case it is required (e.g. UART com port name) \param[in] pInitCallBack Pointer to function that would be called on completion of the initialization process.\n - If this parameter is NULL the function is - blocked until the device initialization - is completed, otherwise the function returns + If this parameter is NULL the function is + blocked until the device initialization + is completed, otherwise the function returns immediately. \return Returns the current active role (STA/AP/P2P) or an error code: - - ROLE_STA, ROLE_AP, ROLE_P2P in case of success, + - ROLE_STA, ROLE_AP, ROLE_P2P in case of success, otherwise in failure one of the following is return: - ROLE_STA_ERR (Failure to load MAC/PHY in STA role) - ROLE_AP_ERR (Failure to load MAC/PHY in AP role) - ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role) - + \sa sl_Stop \note belongs to \ref basic_api \warning This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device \par Example: - \code + \code An example for open interface without callback routine. The interface name and handler are - handled by the sl_IfOpen routine: + handled by the sl_IfOpen routine: if( sl_Start(NULL, NULL, NULL) < 0 ) { - LOG("Error opening interface to device\n"); + LOG("Error opening interface to device\n"); } \endcode */ @@ -373,21 +417,21 @@ _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCal \brief Stop the SimpleLink device This function clears the enable pin of the device, closes the communication \n - interface and invokes the stop complete callback + interface and invokes the stop complete callback - \param[in] timeout Stop timeout in msec. Should be used to give the device time to finish \n + \param[in] timeout Stop timeout in msec. Should be used to give the device time to finish \n any transmission/reception that is not completed when the function was called. \n Additional options: - 0 Enter to hibernate immediately \n - 0xFFFF Host waits for device's response before \n - hibernating, without timeout protection \n + hibernating, without timeout protection \n - 0 < Timeout[msec] < 0xFFFF Host waits for device's response before \n hibernating, with a defined timeout protection \n This timeout defines the max time to wait. The NWP \n response can be sent earlier than this timeout. - \return On success, zero is returned. On error, -1 is returned - + \return On success, zero is returned. On error, -1 is returned + \sa sl_Start \note This API will shutdown the device and invoke the "i/f close" function regardless \n @@ -395,7 +439,7 @@ _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCal It is up to the platform interface library to properly handle interface close \n routine \n belongs to \ref basic_api \n - \warning + \warning */ #if _SL_INCLUDE_FUNC(sl_Stop) _i16 sl_Stop(const _u16 timeout); @@ -405,25 +449,25 @@ _i16 sl_Stop(const _u16 timeout); /*! \brief Internal function for setting device configurations - \return On success, zero is returned. On error, -1 is + \return On success, zero is returned. On error, -1 is returned - + \param[in] DeviceSetId configuration id \param[in] Option configurations option \param[in] ConfigLen configurations len \param[in] pValues configurations values - \sa - \note - \warning + \sa + \note + \warning \par Examples: \code Setting device time and date example: SlDateTime_t dateTime= {0}; dateTime.sl_tm_day = (_u32)23; // Day of month (DD format) range 1-31 - dateTime.sl_tm_mon = (_u32)6; // Month (MM format) in the range of 1-12 - dateTime.sl_tm_year = (_u32)2014; // Year (YYYY format) + dateTime.sl_tm_mon = (_u32)6; // Month (MM format) in the range of 1-12 + dateTime.sl_tm_year = (_u32)2014; // Year (YYYY format) dateTime.sl_tm_hour = (_u32)17; // Hours in the range of 0-23 dateTime.sl_tm_min = (_u32)55; // Minutes in the range of 0-59 dateTime.sl_tm_sec = (_u32)22; // Seconds in the range of 0-59 @@ -440,27 +484,27 @@ _i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const /*! \brief Internal function for getting device configurations - \return On success, zero is returned. On error, -1 is + \return On success, zero is returned. On error, -1 is returned \param[in] DeviceGetId configuration id - example SL_DEVICE_STATUS \param[out] pOption Get configurations option, example for get status options - SL_EVENT_CLASS_GLOBAL - SL_EVENT_CLASS_DEVICE - - SL_EVENT_CLASS_WLAN - - SL_EVENT_CLASS_BSD + - SL_EVENT_CLASS_WLAN + - SL_EVENT_CLASS_BSD - SL_EVENT_CLASS_NETAPP - SL_EVENT_CLASS_NETCFG - - SL_EVENT_CLASS_FS + - SL_EVENT_CLASS_FS \param[out] pConfigLen The length of the allocated memory as input, when the function complete, the value of this parameter would be - the len that actually read from the device.\n - If the device return length that is longer from the input + the len that actually read from the device.\n + If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return SL_ESMALLBUF \param[out] pValues Get configurations values - \sa - \note - \warning + \sa + \note + \warning \par Examples: \code Example for getting WLAN class status: @@ -488,12 +532,12 @@ _i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const \endcode \code Getting Device time and date example: - - SlDateTime_t dateTime = {0}; - _i8 configLen = sizeof(SlDateTime_t); + + SlDateTime_t dateTime = {0}; + _i8 configLen = sizeof(SlDateTime_t); _i8 configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME; - sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(_u8 *)(&dateTime)); - + sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(_u8 *)(&dateTime)); + printf("Day %d,Mon %d,Year %d,Hour %,Min %d,Sec %d\n",dateTime.sl_tm_day,dateTime.sl_tm_mon,dateTime.sl_tm_year dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec); \endcode @@ -505,49 +549,49 @@ _i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues) /*! \brief Set asynchronous event mask - + Mask asynchronous events from the device. Masked events do not - generate asynchronous messages from the device. + generate asynchronous messages from the device. By default - all events are active - - \param[in] EventClass The classification groups that the + + \param[in] EventClass The classification groups that the mask is referred to. Need to be one of the following: - SL_EVENT_CLASS_GLOBAL - SL_EVENT_CLASS_DEVICE - - SL_EVENT_CLASS_WLAN - - SL_EVENT_CLASS_BSD + - SL_EVENT_CLASS_WLAN + - SL_EVENT_CLASS_BSD - SL_EVENT_CLASS_NETAPP - SL_EVENT_CLASS_NETCFG - - SL_EVENT_CLASS_FS + - SL_EVENT_CLASS_FS \param[in] Mask Event Mask bitmap. Valid mask are (per group): - SL_EVENT_CLASS_WLAN user events - - SL_WLAN_CONNECT_EVENT + - SL_WLAN_CONNECT_EVENT - SL_WLAN_DISCONNECT_EVENT - SL_EVENT_CLASS_DEVICE user events - - SL_DEVICE_FATAL_ERROR_EVENT + - SL_DEVICE_GENERAL_ERROR_EVENT - SL_EVENT_CLASS_BSD user events - - SL_SOCKET_TX_FAILED_EVENT - - SL_SOCKET_ASYNC_EVENT + - SL_SOCKET_TX_FAILED_EVENT + - SL_SOCKET_ASYNC_EVENT - SL_EVENT_CLASS_NETAPP user events - - SL_NETAPP_IPV4_IPACQUIRED_EVENT + - SL_NETAPP_IPV4_IPACQUIRED_EVENT - SL_NETAPP_IPV6_IPACQUIRED_EVENT - - \return On success, zero is returned. On error, -1 is returned + + \return On success, zero is returned. On error, -1 is returned \sa sl_EventMaskGet \note belongs to \ref ext_api - - \warning + + \warning \par Example: - \code + \code An example of masking connection/disconnection async events from WLAN class: sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) ); - + \endcode */ #if _SL_INCLUDE_FUNC(sl_EventMaskSet) @@ -556,33 +600,33 @@ _i16 sl_EventMaskSet(const _u8 EventClass ,const _u32 Mask); /*! \brief Get current event mask of the device - - return the events bit mask from the device. In case that event is - masked, the device is not sending this event. - - \param[in] EventClass The classification groups that the + + return the events bit mask from the device. In case that event is + masked, the device is not sending this event. + + \param[in] EventClass The classification groups that the mask is referred to. Need to be one of the following: - SL_EVENT_CLASS_GLOBAL - SL_EVENT_CLASS_DEVICE - - SL_EVENT_CLASS_WLAN - - SL_EVENT_CLASS_BSD + - SL_EVENT_CLASS_WLAN + - SL_EVENT_CLASS_BSD - SL_EVENT_CLASS_NETAPP - SL_EVENT_CLASS_NETCFG - - SL_EVENT_CLASS_FS + - SL_EVENT_CLASS_FS - \param[out] pMask Pointer to Mask bitmap where the + \param[out] pMask Pointer to Mask bitmap where the value should be stored. Bitmasks are the same as in \ref sl_EventMaskSet - - \return On success, zero is returned. On error, -1 is returned - - \sa sl_EventMaskSet + + \return On success, zero is returned. On error, -1 is returned + + \sa sl_EventMaskSet \note belongs to \ref ext_api - \warning + \warning \par Example: - \code + \code An example of getting an event mask for WLAN class _u32 maskWlan; @@ -602,17 +646,17 @@ _i16 sl_EventMaskGet(const _u8 EventClass,_u32 *pMask); This function must be called from the main loop or from dedicated thread in the following cases: - Non-Os Platform - should be called from the mail loop - - Multi Threaded Platform when the user does not implement the external spawn functions - + - Multi Threaded Platform when the user does not implement the external spawn functions - should be called from dedicated thread allocated to the simplelink driver. In this mode the function never return. - + \return None - + \sa sl_Stop \note belongs to \ref basic_api - \warning This function must be called from a thread that is start running before + \warning This function must be called from a thread that is start running before any call to other simple link API */ #if _SL_INCLUDE_FUNC(sl_Task) @@ -621,15 +665,15 @@ void sl_Task(void); /*! - \brief Setting the internal uart mode + \brief Setting the internal uart mode - \param[in] pUartParams Pointer to the uart configuration parameter set: + \param[in] pUartParams Pointer to the uart configuration parameter set: baudrate - up to 711 Kbps - flow control - enable/disable + flow control - enable/disable comm port - the comm port number - - \return On success zero is returned, otherwise - Failed. - + + \return On success zero is returned, otherwise - Failed. + \sa sl_Stop \note belongs to \ref basic_api diff --git a/hardware/lm4f/libraries/WiFi/utility/driver.c b/hardware/lm4f/libraries/WiFi/utility/driver.c index 268df2f49da..244e903b204 100644 --- a/hardware/lm4f/libraries/WiFi/utility/driver.c +++ b/hardware/lm4f/libraries/WiFi/utility/driver.c @@ -1,37 +1,37 @@ /* -* driver.c - CC31xx/CC32xx Host Driver Implementation -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the -* distribution. -* -* Neither the name of Texas Instruments Incorporated nor the names of -* its contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* + * driver.c - CC31xx/CC32xx Host Driver Implementation + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * */ /*****************************************************************************/ @@ -48,7 +48,7 @@ #define _SL_PENDING_RX_MSG(pDriverCB) (RxIrqCnt != (pDriverCB)->RxDoneCnt) -/* 2 LSB of the N2H_SYNC_PATTERN are for sequence number +/* 2 LSB of the N2H_SYNC_PATTERN are for sequence number only in SPI interface support backward sync pattern */ #define N2H_SYNC_PATTERN_SEQ_NUM_BITS ((_u32)0x00000003) /* Bits 0..1 - use the 2 LBS for seq num */ @@ -57,24 +57,24 @@ support backward sync pattern */ #define N2H_SYNC_SPI_BUGS_MASK ((_u32)0x7FFF7F7F) /* Bits 7,15,31 - ignore the SPI (8,16,32 bites bus) error bits */ #define BUF_SYNC_SPIM(pBuf) ((*(_u32 *)(pBuf)) & N2H_SYNC_SPI_BUGS_MASK) -_u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID); #define N2H_SYNC_SPIM (N2H_SYNC_PATTERN & N2H_SYNC_SPI_BUGS_MASK) #define N2H_SYNC_SPIM_WITH_SEQ(TxSeqNum) ((N2H_SYNC_SPIM & N2H_SYNC_PATTERN_MASK) | N2H_SYNC_PATTERN_SEQ_NUM_EXISTS | ((TxSeqNum) & (N2H_SYNC_PATTERN_SEQ_NUM_BITS))) #define MATCH_WOUT_SEQ_NUM(pBuf) ( BUF_SYNC_SPIM(pBuf) == N2H_SYNC_SPIM ) #define MATCH_WITH_SEQ_NUM(pBuf, TxSeqNum) ( BUF_SYNC_SPIM(pBuf) == (N2H_SYNC_SPIM_WITH_SEQ(TxSeqNum)) ) #define N2H_SYNC_PATTERN_MATCH(pBuf, TxSeqNum) \ ( \ - ( (*((_u32 *)pBuf) & N2H_SYNC_PATTERN_SEQ_NUM_EXISTS) && ( MATCH_WITH_SEQ_NUM(pBuf, TxSeqNum) ) ) || \ - ( !(*((_u32 *)pBuf) & N2H_SYNC_PATTERN_SEQ_NUM_EXISTS) && ( MATCH_WOUT_SEQ_NUM(pBuf ) ) ) \ + ( (*((_u32 *)pBuf) & N2H_SYNC_PATTERN_SEQ_NUM_EXISTS) && ( MATCH_WITH_SEQ_NUM(pBuf, TxSeqNum) ) ) || \ + ( !(*((_u32 *)pBuf) & N2H_SYNC_PATTERN_SEQ_NUM_EXISTS) && ( MATCH_WOUT_SEQ_NUM(pBuf ) ) ) \ ) -#define OPCODE(_ptr) (((_SlResponseHeader_t *)(_ptr))->GenHeader.Opcode) -#define RSP_PAYLOAD_LEN(_ptr) (((_SlResponseHeader_t *)(_ptr))->GenHeader.Len - _SL_RESP_SPEC_HDR_SIZE) +#define OPCODE(_ptr) (((_SlResponseHeader_t *)(_ptr))->GenHeader.Opcode) +#define RSP_PAYLOAD_LEN(_ptr) (((_SlResponseHeader_t *)(_ptr))->GenHeader.Len - _SL_RESP_SPEC_HDR_SIZE) #define SD(_ptr) (((_SocketAddrResponse_u *)(_ptr))->IpV4.sd) /* Actual size of Recv/Recvfrom response data */ #define ACT_DATA_SIZE(_ptr) (((_SocketAddrResponse_u *)(_ptr))->IpV4.statusOrLen) +/* Internal function prototype declaration */ /* General Events handling*/ @@ -85,23 +85,23 @@ typedef _SlEventPropogationStatus_e (*general_callback) (SlDeviceEvent_t *); static const general_callback general_callbacks[] = { #ifdef SlExtLib1GeneralEventHandler - SlExtLib1GeneralEventHandler, + SlExtLib1GeneralEventHandler, #endif #ifdef SlExtLib2GeneralEventHandler - SlExtLib2GeneralEventHandler, + SlExtLib2GeneralEventHandler, #endif #ifdef SlExtLib3GeneralEventHandler - SlExtLib3GeneralEventHandler, + SlExtLib3GeneralEventHandler, #endif #ifdef SlExtLib4GeneralEventHandler - SlExtLib4GeneralEventHandler, + SlExtLib4GeneralEventHandler, #endif #ifdef SlExtLib5GeneralEventHandler - SlExtLib5GeneralEventHandler, + SlExtLib5GeneralEventHandler, #endif }; @@ -120,10 +120,10 @@ void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent) for ( i = 0 ; i < sizeof(general_callbacks)/sizeof(general_callbacks[0]) ; i++ ) { if (EVENT_PROPAGATION_BLOCK == general_callbacks[i](slGeneralEvent) ) - { - /* exit immediately and do not call the user specific handler as well */ + { + /* exit immediately and do not call the user specific handler as well */ return; - } + } } /* At last call the Application specific handler if registered */ @@ -145,23 +145,23 @@ typedef _SlEventPropogationStatus_e (*wlan_callback) (SlWlanEvent_t *); static wlan_callback wlan_callbacks[] = { #ifdef SlExtLib1WlanEventHandler - SlExtLib1WlanEventHandler, + SlExtLib1WlanEventHandler, #endif #ifdef SlExtLib2WlanEventHandler - SlExtLib2WlanEventHandler, + SlExtLib2WlanEventHandler, #endif #ifdef SlExtLib3WlanEventHandler - SlExtLib3WlanEventHandler, + SlExtLib3WlanEventHandler, #endif #ifdef SlExtLib4WlanEventHandler - SlExtLib4WlanEventHandler, + SlExtLib4WlanEventHandler, #endif #ifdef SlExtLib5WlanEventHandler - SlExtLib5WlanEventHandler, + SlExtLib5WlanEventHandler, #endif }; @@ -180,10 +180,10 @@ void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent) for ( i = 0 ; i < sizeof(wlan_callbacks)/sizeof(wlan_callbacks[0]) ; i++ ) { if ( EVENT_PROPAGATION_BLOCK == wlan_callbacks[i](slWlanEvent) ) - { - /* exit immediately and do not call the user specific handler as well */ + { + /* exit immediately and do not call the user specific handler as well */ return; - } + } } /* At last call the Application specific handler if registered */ @@ -203,23 +203,23 @@ typedef _SlEventPropogationStatus_e (*netApp_callback) (SlNetAppEvent_t *); static const netApp_callback netApp_callbacks[] = { #ifdef SlExtLib1NetAppEventHandler - SlExtLib1NetAppEventHandler, + SlExtLib1NetAppEventHandler, #endif #ifdef SlExtLib2NetAppEventHandler - SlExtLib2NetAppEventHandler, + SlExtLib2NetAppEventHandler, #endif #ifdef SlExtLib3NetAppEventHandler - SlExtLib3NetAppEventHandler, + SlExtLib3NetAppEventHandler, #endif #ifdef SlExtLib4NetAppEventHandler - SlExtLib4NetAppEventHandler, + SlExtLib4NetAppEventHandler, #endif #ifdef SlExtLib5NetAppEventHandler - SlExtLib5NetAppEventHandler, + SlExtLib5NetAppEventHandler, #endif }; @@ -238,10 +238,10 @@ void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent) for ( i = 0 ; i < sizeof(netApp_callbacks)/sizeof(netApp_callbacks[0]) ; i++ ) { if (EVENT_PROPAGATION_BLOCK == netApp_callbacks[i](slNetAppEvent) ) - { - /* exit immediately and do not call the user specific handler as well */ + { + /* exit immediately and do not call the user specific handler as well */ return; - } + } } /* At last call the Application specific handler if registered */ @@ -261,23 +261,23 @@ typedef _SlEventPropogationStatus_e (*httpServer_callback) (SlHttpServerEvent_t* static const httpServer_callback httpServer_callbacks[] = { #ifdef SlExtLib1HttpServerEventHandler - SlExtLib1HttpServerEventHandler, + SlExtLib1HttpServerEventHandler, #endif #ifdef SlExtLib2HttpServerEventHandler - SlExtLib2HttpServerEventHandler, + SlExtLib2HttpServerEventHandler, #endif #ifdef SlExtLib3HttpServerEventHandler - SlExtLib3HttpServerEventHandler, + SlExtLib3HttpServerEventHandler, #endif #ifdef SlExtLib4HttpServerEventHandler - SlExtLib4HttpServerEventHandler, + SlExtLib4HttpServerEventHandler, #endif #ifdef SlExtLib5HttpServerEventHandler - SlExtLib5HttpServerEventHandler, + SlExtLib5HttpServerEventHandler, #endif }; @@ -296,10 +296,10 @@ void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttp for ( i = 0 ; i < sizeof(httpServer_callbacks)/sizeof(httpServer_callbacks[0]) ; i++ ) { if ( EVENT_PROPAGATION_BLOCK == httpServer_callbacks[i](slHttpServerEvent, slHttpServerResponse) ) - { - /* exit immediately and do not call the user specific handler as well */ + { + /* exit immediately and do not call the user specific handler as well */ return; - } + } } /* At last call the Application specific handler if registered */ @@ -319,23 +319,23 @@ typedef _SlEventPropogationStatus_e (*sock_callback) (SlSockEvent_t *); static const sock_callback sock_callbacks[] = { #ifdef SlExtLib1SockEventHandler - SlExtLib1SockEventHandler, + SlExtLib1SockEventHandler, #endif #ifdef SlExtLib2SockEventHandler - SlExtLib2SockEventHandler, + SlExtLib2SockEventHandler, #endif #ifdef SlExtLib3SockEventHandler - SlExtLib3SockEventHandler, + SlExtLib3SockEventHandler, #endif #ifdef SlExtLib4SockEventHandler - SlExtLib4SockEventHandler, + SlExtLib4SockEventHandler, #endif #ifdef SlExtLib5SockEventHandler - SlExtLib5SockEventHandler, + SlExtLib5SockEventHandler, #endif }; @@ -352,10 +352,10 @@ void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent) for ( i = 0 ; i < sizeof(sock_callbacks)/sizeof(sock_callbacks[0]) ; i++ ) { if ( EVENT_PROPAGATION_BLOCK == sock_callbacks[i](slSockEvent) ) - { - /* exit immediately and do not call the user specific handler as well */ + { + /* exit immediately and do not call the user specific handler as well */ return; - } + } } /* At last call the Application specific handler if registered */ @@ -376,22 +376,22 @@ typedef struct _u8 AsyncRespBuf[SL_ASYNC_MAX_MSG_LEN]; }_SlStatMem_t; -_SlStatMem_t g_StatMem; +static _SlStatMem_t g_StatMem; #endif -_u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID) +_u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _SlActionID_e ActionID, _u8 SocketID) { _u8 ObjIdx; /* Use Obj to issue the command, if not available try later */ - ObjIdx = _SlDrvWaitForPoolObj(ActionID, SocketID); + ObjIdx = (_u8)_SlDrvWaitForPoolObj(ActionID, SocketID); if (MAX_CONCURRENT_ACTIONS != ObjIdx) { - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); g_pCB->ObjPool[ObjIdx].pRespArgs = pAsyncRsp; - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); } return ObjIdx; @@ -401,26 +401,34 @@ _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID) /*****************************************************************************/ /* Variables */ /*****************************************************************************/ -const _SlSyncPattern_t g_H2NSyncPattern = H2N_SYNC_PATTERN; -const _SlSyncPattern_t g_H2NCnysPattern = H2N_CNYS_PATTERN; +static const _SlSyncPattern_t g_H2NSyncPattern = H2N_SYNC_PATTERN; + +#ifndef SL_IF_TYPE_UART +static const _SlSyncPattern_t g_H2NCnysPattern = H2N_CNYS_PATTERN; +#endif + + _volatile _u8 RxIrqCnt; #ifndef SL_TINY_EXT -const _SlActionLookup_t _SlActionLookupTable[] = + +_volatile _u8 g_bDeviceRestartIsRequired; + +const _SlActionLookup_t _SlActionLookupTable[] = { {ACCEPT_ID, SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE, (_SlSpawnEntryFunc_t)_sl_HandleAsync_Accept}, {CONNECT_ID, SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Connect}, {SELECT_ID, SL_OPCODE_SOCKET_SELECTASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Select}, {GETHOSYBYNAME_ID, SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByName}, - {GETHOSYBYSERVICE_ID, SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByService}, + {GETHOSYBYSERVICE_ID, SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByService}, {PING_ID, SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE, (_SlSpawnEntryFunc_t)_sl_HandleAsync_PingResponse}, {START_STOP_ID, SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Stop} }; #else -const _SlActionLookup_t _SlActionLookupTable[] = +const _SlActionLookup_t _SlActionLookupTable[] = { {CONNECT_ID, SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Connect}, - {GETHOSYBYNAME_ID, SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByName}, + {GETHOSYBYNAME_ID, SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_DnsGetHostByName}, {START_STOP_ID, SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE,(_SlSpawnEntryFunc_t)_sl_HandleAsync_Stop} }; #endif @@ -434,13 +442,13 @@ typedef struct } OpcodeKeyVal_t; /* The table translates opcode to user's event type */ -const OpcodeKeyVal_t OpcodeTranslateTable[] = +const OpcodeKeyVal_t OpcodeTranslateTable[] = { {SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE, SL_WLAN_SMART_CONFIG_COMPLETE_EVENT}, {SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE,SL_WLAN_SMART_CONFIG_STOP_EVENT}, {SL_OPCODE_WLAN_STA_CONNECTED, SL_WLAN_STA_CONNECTED_EVENT}, {SL_OPCODE_WLAN_STA_DISCONNECTED,SL_WLAN_STA_DISCONNECTED_EVENT}, -{SL_OPCODE_WLAN_P2P_DEV_FOUND,SL_WLAN_P2P_DEV_FOUND_EVENT}, +{SL_OPCODE_WLAN_P2P_DEV_FOUND,SL_WLAN_P2P_DEV_FOUND_EVENT}, {SL_OPCODE_WLAN_P2P_NEG_REQ_RECEIVED, SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT}, {SL_OPCODE_WLAN_CONNECTION_FAILED, SL_WLAN_CONNECTION_FAILED_EVENT}, {SL_OPCODE_WLAN_WLANASYNCCONNECTEDRESPONSE, SL_WLAN_CONNECT_EVENT}, @@ -457,25 +465,23 @@ const OpcodeKeyVal_t OpcodeTranslateTable[] = _SlDriverCb_t* g_pCB = NULL; P_SL_DEV_PING_CALLBACK pPingCallBackFunc = NULL; -_u8 gFirstCmdMode = 0; + +#ifndef SL_IF_TYPE_UART +static _u8 gFirstCmdMode = 0; +#endif /*****************************************************************************/ /* Function prototypes */ /*****************************************************************************/ -_SlReturnVal_t _SlDrvMsgRead(void); -_SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 *pTxRxDescBuff); -_SlReturnVal_t _SlDrvMsgReadCmdCtx(void); -_SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue); -void _SlDrvClassifyRxMsg(_SlOpcode_t Opcode ); -_SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize); -void _SlDrvShiftDWord(_u8 *pBuf); -void _SlDrvDriverCBInit(void); -void _SlAsyncEventGenericHandler(void); -_u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID); -void _SlDrvReleasePoolObj(_u8 pObj); -void _SlRemoveFromList(_u8* ListIndex, _u8 ItemIndex); -_SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd); - +static _SlReturnVal_t _SlDrvMsgRead(void); +static _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 *pTxRxDescBuff); +static _SlReturnVal_t _SlDrvMsgReadCmdCtx(_u16 cmdOpcode); +static _SlReturnVal_t _SlDrvClassifyRxMsg(_SlOpcode_t Opcode ); +static _SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize); +static void _SlAsyncEventGenericHandler(_u8 bInCmdContext); +static void _SlRemoveFromList(_u8* ListIndex, _u8 ItemIndex); +static _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd); +static _SlReturnVal_t _SlDrvObjGlobalLockWaitForever(void); /*****************************************************************************/ /* Internal functions */ @@ -486,28 +492,34 @@ _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd); _SlDrvDriverCBInit - init Driver Control Block *****************************************************************************/ -void _SlDrvDriverCBInit(void) +_SlReturnVal_t _SlDrvDriverCBInit(void) { _u8 Idx =0; #ifdef SL_MEMORY_MGMT_DYNAMIC - g_pCB = sl_Malloc(sizeof(_SlDriverCb_t)); + g_pCB = (_SlDriverCb_t*)sl_Malloc(sizeof(_SlDriverCb_t)); #else g_pCB = &(g_StatMem.DriverCB); #endif MALLOC_OK_CHECK(g_pCB); - - _SlDrvMemZero(g_pCB, sizeof(_SlDriverCb_t)); +#ifndef SL_PLATFORM_MULTI_THREADED + { + extern _SlNonOsCB_t g__SlNonOsCB; + sl_Memset(&g__SlNonOsCB, 0, sizeof(g__SlNonOsCB)); + } +#endif + + _SlDrvMemZero(g_pCB, (_u16)sizeof(_SlDriverCb_t)); RxIrqCnt = 0; OSI_RET_OK_CHECK( sl_SyncObjCreate(&g_pCB->CmdSyncObj, "CmdSyncObj") ); - sl_SyncObjClear(&g_pCB->CmdSyncObj); + SL_DRV_SYNC_OBJ_CLEAR(&g_pCB->CmdSyncObj); OSI_RET_OK_CHECK( sl_LockObjCreate(&g_pCB->GlobalLockObj, "GlobalLockObj") ); OSI_RET_OK_CHECK( sl_LockObjCreate(&g_pCB->ProtectionLockObj, "ProtectionLockObj") ); /* Init Drv object */ - _SlDrvMemZero(&g_pCB->ObjPool[0], MAX_CONCURRENT_ACTIONS*sizeof(_SlPoolObj_t)); + _SlDrvMemZero(&g_pCB->ObjPool[0], (_u16)(MAX_CONCURRENT_ACTIONS*sizeof(_SlPoolObj_t))); /* place all Obj in the free list*/ g_pCB->FreePoolIdx = 0; @@ -518,7 +530,7 @@ void _SlDrvDriverCBInit(void) g_pCB->ObjPool[Idx].AdditionalData = SL_MAX_SOCKETS; OSI_RET_OK_CHECK( sl_SyncObjCreate(&g_pCB->ObjPool[Idx].SyncObj, "SyncObj")); - sl_SyncObjClear(&g_pCB->ObjPool[Idx].SyncObj); + SL_DRV_SYNC_OBJ_CLEAR(&g_pCB->ObjPool[Idx].SyncObj); } g_pCB->ActivePoolIdx = MAX_CONCURRENT_ACTIONS; @@ -528,15 +540,18 @@ void _SlDrvDriverCBInit(void) g_pCB->FlowContCB.TxPoolCnt = FLOW_CONT_MIN; OSI_RET_OK_CHECK(sl_LockObjCreate(&g_pCB->FlowContCB.TxLockObj, "TxLockObj")); OSI_RET_OK_CHECK(sl_SyncObjCreate(&g_pCB->FlowContCB.TxSyncObj, "TxSyncObj")); - - gFirstCmdMode = 0; +#ifndef SL_IF_TYPE_UART + gFirstCmdMode = 0; +#endif + + return SL_OS_RET_CODE_OK; } /***************************************************************************** _SlDrvDriverCBDeinit - De init Driver Control Block *****************************************************************************/ -void _SlDrvDriverCBDeinit() +_SlReturnVal_t _SlDrvDriverCBDeinit(void) { _u8 Idx =0; @@ -544,16 +559,23 @@ void _SlDrvDriverCBDeinit() g_pCB->FlowContCB.TxPoolCnt = 0; OSI_RET_OK_CHECK(sl_LockObjDelete(&g_pCB->FlowContCB.TxLockObj)); OSI_RET_OK_CHECK(sl_SyncObjDelete(&g_pCB->FlowContCB.TxSyncObj)); - + OSI_RET_OK_CHECK( sl_SyncObjDelete(&g_pCB->CmdSyncObj) ); - OSI_RET_OK_CHECK( sl_LockObjDelete(&g_pCB->GlobalLockObj) ); + +#ifndef SL_TINY_EXT + if (g_bDeviceRestartIsRequired == 0) +#endif + { + OSI_RET_OK_CHECK( sl_LockObjDelete(&g_pCB->GlobalLockObj) ); + } + OSI_RET_OK_CHECK( sl_LockObjDelete(&g_pCB->ProtectionLockObj) ); - + #ifndef SL_TINY_EXT for (Idx = 0; Idx < MAX_CONCURRENT_ACTIONS; Idx++) #endif { - OSI_RET_OK_CHECK( sl_SyncObjDelete(&g_pCB->ObjPool[Idx].SyncObj) ); + OSI_RET_OK_CHECK( sl_SyncObjDelete(&g_pCB->ObjPool[Idx].SyncObj) ); } g_pCB->FreePoolIdx = 0; @@ -568,13 +590,16 @@ void _SlDrvDriverCBDeinit() g_pCB = NULL; + return SL_OS_RET_CODE_OK; } /***************************************************************************** -_SlDrvRxIrqHandler - Interrupt handler +_SlDrvRxIrqHandler - Interrupt handler *****************************************************************************/ -void _SlDrvRxIrqHandler(void *pValue) +_SlReturnVal_t _SlDrvRxIrqHandler(void *pValue) { + (void)pValue; + sl_IfMaskIntHdlr(); RxIrqCnt++; @@ -585,8 +610,9 @@ void _SlDrvRxIrqHandler(void *pValue) } else { - sl_Spawn((_SlSpawnEntryFunc_t)_SlDrvMsgReadSpawnCtx, NULL, 0); + (void)sl_Spawn((_SlSpawnEntryFunc_t)_SlDrvMsgReadSpawnCtx, NULL, SL_SPAWN_FLAG_FROM_SL_IRQ_HANDLER); } + return SL_OS_RET_CODE_OK; } /***************************************************************************** @@ -599,9 +625,18 @@ _SlReturnVal_t _SlDrvCmdOp( { _SlReturnVal_t RetVal; - - _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); - + SL_DRV_LOCK_GLOBAL_LOCK_FOREVER(); + +#ifndef SL_TINY_EXT + /* In case the global was succesffully taken but error in progress + it means it has been released as part of an error handling and we should abort immediately */ + if (TRUE == g_bDeviceRestartIsRequired) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + return SL_API_ABORTED; + } +#endif + g_pCB->IsCmdRespWaited = TRUE; SL_TRACE0(DBG_MSG, MSG_312, "_SlDrvCmdOp: call _SlDrvMsgWrite"); @@ -613,7 +648,7 @@ _SlReturnVal_t _SlDrvCmdOp( if(SL_OS_RET_CODE_OK == RetVal) { -#ifndef SL_IF_TYPE_UART +#ifndef SL_IF_TYPE_UART /* Waiting for SPI to stabilize after first command */ if( 0 == gFirstCmdMode ) { @@ -621,17 +656,17 @@ _SlReturnVal_t _SlDrvCmdOp( gFirstCmdMode = 1; CountVal = CPU_FREQ_IN_MHZ*USEC_DELAY; while( CountVal-- ); - } -#endif + } +#endif /* wait for respond */ - RetVal = _SlDrvMsgReadCmdCtx(); /* will free global lock */ + RetVal = _SlDrvMsgReadCmdCtx(pCmdCtrl->Opcode); /* will free global lock */ SL_TRACE0(DBG_MSG, MSG_314, "_SlDrvCmdOp: exited _SlDrvMsgReadCmdCtx"); } else { - _SlDrvObjUnLock(&g_pCB->GlobalLockObj); + SL_DRV_LOCK_GLOBAL_UNLOCK(); } - + return RetVal; } @@ -671,51 +706,76 @@ _SlReturnVal_t _SlDrvDataReadOp( return SL_POOL_IS_EMPTY; } - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); pArgsData.pData = pCmdExt->pRxPayload; pArgsData.pArgs = (_u8 *)pTxRxDescBuff; g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&pArgsData; - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); /* Do Flow Control check/update for DataWrite operation */ - _SlDrvObjLockWaitForever(&g_pCB->FlowContCB.TxLockObj); + SL_DRV_OBJ_LOCK_FOREVER(&g_pCB->FlowContCB.TxLockObj); /* Clear SyncObj for the case it was signalled before TxPoolCnt */ /* dropped below '1' (last Data buffer was taken) */ /* OSI_RET_OK_CHECK( sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj) ); */ - sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj); + SL_DRV_SYNC_OBJ_CLEAR(&g_pCB->FlowContCB.TxSyncObj); if(g_pCB->FlowContCB.TxPoolCnt <= FLOW_CONT_MIN) { /* If TxPoolCnt was increased by other thread at this moment, TxSyncObj won't wait here */ - _SlDrvSyncObjWaitForever(&g_pCB->FlowContCB.TxSyncObj); - + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->FlowContCB.TxSyncObj); + } - _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); - + SL_DRV_LOCK_GLOBAL_LOCK_FOREVER(); + +#ifndef SL_TINY_EXT + /* In case the global was succesffully taken but error in progress + it means it has been released as part of an error handling and we should abort immediately */ + if (TRUE == g_bDeviceRestartIsRequired) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + return SL_API_ABORTED; + } +#endif VERIFY_PROTOCOL(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN); g_pCB->FlowContCB.TxPoolCnt--; - _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); + SL_DRV_OBJ_UNLOCK(&g_pCB->FlowContCB.TxLockObj); /* send the message */ RetVal = _SlDrvMsgWrite(pCmdCtrl, pCmdExt, (_u8 *)pTxRxDescBuff); - _SlDrvObjUnLock(&g_pCB->GlobalLockObj); - + SL_DRV_LOCK_GLOBAL_UNLOCK(); + if(SL_OS_RET_CODE_OK == RetVal) { - /* Wait for response message. Will be signaled by _SlDrvMsgRead. */ - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); +#ifndef SL_TINY_EXT + /* in case socket is non-blocking one, the async event should be received immediately */ + if( g_pCB->SocketNonBlocking & (1<<(Sd & BSD_SOCKET_ID_MASK) )) + { + SlDriverAPIWithTimeout_e api = (pCmdCtrl->Opcode == SL_OPCODE_SOCKET_RECV) ? SL_DRIVER_API_SOCKET_RECV : SL_DRIVER_API_SOCKET_RECVFROM; + + SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj, + SL_DRIVER_TIMEOUT_SHORT, + api + ); + } + else +#endif + { + /* Wait for response message. Will be signaled by _SlDrvMsgRead. */ + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj); + } + } _SlDrvReleasePoolObj(ObjIdx); @@ -735,31 +795,32 @@ _SlReturnVal_t _SlDrvDataWriteOp( while( 1 ) { /* Do Flow Control check/update for DataWrite operation */ - _SlDrvObjLockWaitForever(&g_pCB->FlowContCB.TxLockObj); + SL_DRV_OBJ_LOCK_FOREVER(&g_pCB->FlowContCB.TxLockObj); /* Clear SyncObj for the case it was signalled before TxPoolCnt */ /* dropped below '1' (last Data buffer was taken) */ /* OSI_RET_OK_CHECK( sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj) ); */ - sl_SyncObjClear(&g_pCB->FlowContCB.TxSyncObj); + SL_DRV_SYNC_OBJ_CLEAR(&g_pCB->FlowContCB.TxSyncObj); /* we have indication that the last send has failed - socket is no longer valid for operations */ if(g_pCB->SocketTXFailure & (1<<(Sd & BSD_SOCKET_ID_MASK))) { - _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); + SL_DRV_OBJ_UNLOCK(&g_pCB->FlowContCB.TxLockObj); return SL_SOC_ERROR; } if(g_pCB->FlowContCB.TxPoolCnt <= FLOW_CONT_MIN + 1) { /* we have indication that this socket is set as blocking and we try to */ /* unblock it - return an error */ - if( g_pCB->SocketNonBlocking & (1<< (Sd & BSD_SOCKET_ID_MASK))) + if( g_pCB->SocketNonBlocking & (1<<(Sd & BSD_SOCKET_ID_MASK) )) { - _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); + SL_DRV_OBJ_UNLOCK(&g_pCB->FlowContCB.TxLockObj); return RetVal; } /* If TxPoolCnt was increased by other thread at this moment, */ /* TxSyncObj won't wait here */ - _SlDrvSyncObjWaitForever(&g_pCB->FlowContCB.TxSyncObj); + + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->FlowContCB.TxSyncObj); } if(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN + 1 ) { @@ -767,22 +828,32 @@ _SlReturnVal_t _SlDrvDataWriteOp( } else { - _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); + SL_DRV_OBJ_UNLOCK(&g_pCB->FlowContCB.TxLockObj); } } - _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); - + SL_DRV_LOCK_GLOBAL_LOCK_FOREVER(); + +#ifndef SL_TINY_EXT + /* In case the global was succesffully taken but error in progress + it means it has been released as part of an error handling and we should abort immediately */ + if (TRUE == g_bDeviceRestartIsRequired) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + return SL_API_ABORTED; + } +#endif + VERIFY_PROTOCOL(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN + 1 ); g_pCB->FlowContCB.TxPoolCnt--; - _SlDrvObjUnLock(&g_pCB->FlowContCB.TxLockObj); - + SL_DRV_OBJ_UNLOCK(&g_pCB->FlowContCB.TxLockObj); + /* send the message */ RetVal = _SlDrvMsgWrite(pCmdCtrl, pCmdExt, pTxRxDescBuff); - _SlDrvObjUnLock(&g_pCB->GlobalLockObj); + SL_DRV_LOCK_GLOBAL_UNLOCK(); return RetVal; } @@ -790,7 +861,7 @@ _SlReturnVal_t _SlDrvDataWriteOp( /* ******************************************************************************/ /* _SlDrvMsgWrite */ /* ******************************************************************************/ -_SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 *pTxRxDescBuff) +static _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 *pTxRxDescBuff) { _u8 sendRxPayload = FALSE; VERIFY_PROTOCOL(NULL != pCmdCtrl); @@ -798,11 +869,11 @@ _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 g_pCB->FunctionParams.pCmdCtrl = pCmdCtrl; g_pCB->FunctionParams.pTxRxDescBuff = pTxRxDescBuff; g_pCB->FunctionParams.pCmdExt = pCmdExt; - + g_pCB->TempProtocolHeader.Opcode = pCmdCtrl->Opcode; - g_pCB->TempProtocolHeader.Len = _SL_PROTOCOL_CALC_LEN(pCmdCtrl, pCmdExt); + g_pCB->TempProtocolHeader.Len = (_u16)(_SL_PROTOCOL_CALC_LEN(pCmdCtrl, pCmdExt)); - if (pCmdExt && pCmdExt->RxPayloadLen < 0 && pCmdExt->TxPayloadLen) + if (pCmdExt && pCmdExt->RxPayloadLen < 0 ) { pCmdExt->RxPayloadLen = pCmdExt->RxPayloadLen * (-1); /* change sign */ sendRxPayload = TRUE; @@ -827,7 +898,7 @@ _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 /* Descriptors */ if (pTxRxDescBuff && pCmdCtrl->TxDescLen > 0) { - NWP_IF_WRITE_CHECK(g_pCB->FD, pTxRxDescBuff, + NWP_IF_WRITE_CHECK(g_pCB->FD, pTxRxDescBuff, _SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen)); } @@ -836,7 +907,7 @@ _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 /* transceiver mode */ if (sendRxPayload == TRUE ) { - NWP_IF_WRITE_CHECK(g_pCB->FD, pCmdExt->pRxPayload, + NWP_IF_WRITE_CHECK(g_pCB->FD, pCmdExt->pRxPayload, _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->RxPayloadLen)); } @@ -847,7 +918,7 @@ _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 /* Otherwise the aligning of arguments will create a gap between arguments and payload. */ VERIFY_PROTOCOL(_SL_IS_PROTOCOL_ALIGNED_SIZE(pCmdCtrl->TxDescLen)); - NWP_IF_WRITE_CHECK(g_pCB->FD, pCmdExt->pTxPayload, + NWP_IF_WRITE_CHECK(g_pCB->FD, pCmdExt->pTxPayload, _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->TxPayloadLen)); } @@ -864,11 +935,11 @@ _SlReturnVal_t _SlDrvMsgWrite(_SlCmdCtrl_t *pCmdCtrl,_SlCmdExt_t *pCmdExt, _u8 /* ******************************************************************************/ /* _SlDrvMsgRead */ /* ******************************************************************************/ -_SlReturnVal_t _SlDrvMsgRead(void) +static _SlReturnVal_t _SlDrvMsgRead(void) { /* alignment for small memory models */ union - { + { _u8 TempBuf[_SL_RESP_HDR_SIZE]; _u32 DummyBuf[2]; } uBuf; @@ -881,17 +952,25 @@ _SlReturnVal_t _SlDrvMsgRead(void) _u16 RespPayloadLen; _u8 sd = SL_MAX_SOCKETS; _SlRxMsgClass_e RxMsgClass; - + /* save params in global CB */ g_pCB->FunctionParams.AsyncExt.pAsyncBuf = NULL; g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler= NULL; - +#ifdef SL_TINY_EXT VERIFY_RET_OK(_SlDrvRxHdrRead((_u8*)(uBuf.TempBuf), &AlignSize)); +#else + if (_SlDrvRxHdrRead((_u8*)(uBuf.TempBuf), &AlignSize) == SL_API_ABORTED) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + _SlDriverHandleError(SL_DEVICE_DRIVER_TIMEOUT_SYNC_PATTERN, 0, 0); + return SL_API_ABORTED; + } +#endif OpCode = OPCODE(uBuf.TempBuf); - RespPayloadLen = RSP_PAYLOAD_LEN(uBuf.TempBuf); + RespPayloadLen = (_u16)(RSP_PAYLOAD_LEN(uBuf.TempBuf)); /* 'Init Compelete' message bears no valid FlowControl info */ @@ -903,13 +982,13 @@ _SlReturnVal_t _SlDrvMsgRead(void) if(g_pCB->FlowContCB.TxPoolCnt > FLOW_CONT_MIN) { - _SlDrvSyncObjSignal(&g_pCB->FlowContCB.TxSyncObj); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->FlowContCB.TxSyncObj); } } /* Find the RX messaage class and set its async event handler */ _SlDrvClassifyRxMsg(OpCode); - + RxMsgClass = g_pCB->FunctionParams.AsyncExt.RxMsgClass; @@ -920,7 +999,7 @@ _SlReturnVal_t _SlDrvMsgRead(void) VERIFY_PROTOCOL(NULL == pAsyncBuf); #ifdef SL_MEMORY_MGMT_DYNAMIC - g_pCB->FunctionParams.AsyncExt.pAsyncBuf = sl_Malloc(SL_ASYNC_MAX_MSG_LEN); + g_pCB->FunctionParams.AsyncExt.pAsyncBuf = (_u8*)sl_Malloc(SL_ASYNC_MAX_MSG_LEN); #else g_pCB->FunctionParams.AsyncExt.pAsyncBuf = g_StatMem.AsyncRespBuf; #endif @@ -928,19 +1007,19 @@ _SlReturnVal_t _SlDrvMsgRead(void) pAsyncBuf = g_pCB->FunctionParams.AsyncExt.pAsyncBuf; /* clear the async buffer */ - _SlDrvMemZero(pAsyncBuf, SL_ASYNC_MAX_MSG_LEN); - + _SlDrvMemZero(pAsyncBuf, (_u16)SL_ASYNC_MAX_MSG_LEN); + MALLOC_OK_CHECK(pAsyncBuf); sl_Memcpy(pAsyncBuf, uBuf.TempBuf, _SL_RESP_HDR_SIZE); - if (_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) <= SL_ASYNC_MAX_PAYLOAD_LEN) - { - AlignedLengthRecv = _SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen); - } - else - { - AlignedLengthRecv = _SL_PROTOCOL_ALIGN_SIZE(SL_ASYNC_MAX_PAYLOAD_LEN); - } + if (_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) <= SL_ASYNC_MAX_PAYLOAD_LEN) + { + AlignedLengthRecv = (_u16)_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen); + } + else + { + AlignedLengthRecv = (_u16)_SL_PROTOCOL_ALIGN_SIZE(SL_ASYNC_MAX_PAYLOAD_LEN); + } if (RespPayloadLen > 0) { NWP_IF_READ_CHECK(g_pCB->FD, @@ -948,32 +1027,33 @@ _SlReturnVal_t _SlDrvMsgRead(void) AlignedLengthRecv); } /* In case ASYNC RX buffer length is smaller then the received data length, dump the rest */ - if ((_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) > SL_ASYNC_MAX_PAYLOAD_LEN)) + if ((_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) > SL_ASYNC_MAX_PAYLOAD_LEN)) { - AlignedLengthRecv = _SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) - SL_ASYNC_MAX_PAYLOAD_LEN; + AlignedLengthRecv = (_u16)(_SL_PROTOCOL_ALIGN_SIZE(RespPayloadLen) - SL_ASYNC_MAX_PAYLOAD_LEN); while (AlignedLengthRecv > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer,4); AlignedLengthRecv = AlignedLengthRecv - 4; } } - - _SlDrvProtectionObjLockWaitForever(); - - if ( -#ifndef SL_TINY_EXT - (SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE == OpCode) || - (SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE_V6 == OpCode) || -#endif + + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); + + if ( +#ifndef SL_TINY_EXT + (SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE == OpCode) || + (SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE_V6 == OpCode) || +#endif (SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE == OpCode) ) - { - /* go over the active list if exist to find obj waiting for this Async event */ - sd = ((((_SocketResponse_t *)(pAsyncBuf + _SL_RESP_HDR_SIZE))->sd) & BSD_SOCKET_ID_MASK); - } - _SlFindAndSetActiveObj(OpCode, sd); + { + /* go over the active list if exist to find obj waiting for this Async event */ + sd = ((((_SocketResponse_t *)(pAsyncBuf + _SL_RESP_HDR_SIZE))->sd) & BSD_SOCKET_ID_MASK); + } + + (void)_SlFindAndSetActiveObj(OpCode, sd); - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); break; case RECV_RESP_CLASS: @@ -983,17 +1063,17 @@ _SlReturnVal_t _SlDrvMsgRead(void) switch(OpCode) { case SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE: - ExpArgSize = RECVFROM_IPV4_ARGS_SIZE; + ExpArgSize = (_u8)RECVFROM_IPV4_ARGS_SIZE; break; -#ifndef SL_TINY_EXT +#ifndef SL_TINY_EXT case SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6: - ExpArgSize = RECVFROM_IPV6_ARGS_SIZE; + ExpArgSize = (_u8)RECVFROM_IPV6_ARGS_SIZE; break; -#endif +#endif default: /* SL_OPCODE_SOCKET_RECVASYNCRESPONSE: */ - ExpArgSize = RECV_ARGS_SIZE; - } + ExpArgSize = (_u8)RECV_ARGS_SIZE; + } /* Read first 4 bytes of Recv/Recvfrom response to get SocketId and actual */ /* response data length */ @@ -1002,17 +1082,17 @@ _SlReturnVal_t _SlDrvMsgRead(void) /* Validate Socket ID and Received Length value. */ VERIFY_PROTOCOL((SD(&uBuf.TempBuf[4])& BSD_SOCKET_ID_MASK) < SL_MAX_SOCKETS); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); /* go over the active list if exist to find obj waiting for this Async event */ - VERIFY_RET_OK(_SlFindAndSetActiveObj(OpCode,SD(&uBuf.TempBuf[4]) & BSD_SOCKET_ID_MASK)); + VERIFY_RET_OK(_SlFindAndSetActiveObj(OpCode,SD(&uBuf.TempBuf[4]) & BSD_SOCKET_ID_MASK)); /* Verify data is waited on this socket. The pArgs should have been set by _SlDrvDataReadOp(). */ - VERIFY_SOCKET_CB(NULL != ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pData))->pArgs); + VERIFY_SOCKET_CB(NULL != ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pData))->pArgs); sl_Memcpy( ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pArgs, &uBuf.TempBuf[4], RECV_ARGS_SIZE); - if(ExpArgSize > RECV_ARGS_SIZE) + if(ExpArgSize > (_u8)RECV_ARGS_SIZE) { NWP_IF_READ_CHECK(g_pCB->FD, ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pArgs + RECV_ARGS_SIZE, @@ -1023,29 +1103,29 @@ _SlReturnVal_t _SlDrvMsgRead(void) /* Overwrite requested DataSize with actual one. */ /* If error is received, this information will be read from arguments. */ if(ACT_DATA_SIZE(&uBuf.TempBuf[4]) > 0) - { + { VERIFY_SOCKET_CB(NULL != ((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData); /* Read 4 bytes aligned from interface */ /* therefore check the requested length and read only */ /* 4 bytes aligned data. The rest unaligned (if any) will be read */ /* and copied to a TailBuffer */ - LengthToCopy = ACT_DATA_SIZE(&uBuf.TempBuf[4]) & (3); - AlignedLengthRecv = ACT_DATA_SIZE(&uBuf.TempBuf[4]) & (~3); + LengthToCopy = (_u16)(ACT_DATA_SIZE(&uBuf.TempBuf[4]) & (3)); + AlignedLengthRecv = (_u16)(ACT_DATA_SIZE(&uBuf.TempBuf[4]) & (~3)); if( AlignedLengthRecv >= 4) { - NWP_IF_READ_CHECK(g_pCB->FD,((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData,AlignedLengthRecv ); + NWP_IF_READ_CHECK(g_pCB->FD,((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData,AlignedLengthRecv ); } /* copy the unaligned part, if any */ - if( LengthToCopy > 0) + if( LengthToCopy > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer,4); /* copy TailBuffer unaligned part (1/2/3 bytes) */ - sl_Memcpy(((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData + AlignedLengthRecv,TailBuffer,LengthToCopy); - } + sl_Memcpy(((_SlArgsData_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->pData + AlignedLengthRecv,TailBuffer,LengthToCopy); + } } - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - _SlDrvProtectionObjUnLock(); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + SL_DRV_PROTECTION_OBJ_UNLOCK(); } break; @@ -1064,7 +1144,7 @@ _SlReturnVal_t _SlDrvMsgRead(void) if((NULL != g_pCB->FunctionParams.pCmdExt) && (0 != g_pCB->FunctionParams.pCmdExt->RxPayloadLen)) { /* Actual size of command's response payload: - */ - _i16 ActDataSize = RSP_PAYLOAD_LEN(uBuf.TempBuf) - g_pCB->FunctionParams.pCmdCtrl->RxDescLen; + _i16 ActDataSize = (_i16)(RSP_PAYLOAD_LEN(uBuf.TempBuf) - g_pCB->FunctionParams.pCmdCtrl->RxDescLen); g_pCB->FunctionParams.pCmdExt->ActualRxPayloadLen = ActDataSize; @@ -1078,13 +1158,13 @@ _SlReturnVal_t _SlDrvMsgRead(void) /* In case the user supplied Rx buffer length which is smaller then the received data length, copy according to user length */ if (ActDataSize > g_pCB->FunctionParams.pCmdExt->RxPayloadLen) { - LengthToCopy = g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (3); - AlignedLengthRecv = g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (~3); + LengthToCopy = (_u16)(g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (3)); + AlignedLengthRecv = (_u16)(g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (~3)); } else { - LengthToCopy = ActDataSize & (3); - AlignedLengthRecv = ActDataSize & (~3); + LengthToCopy = (_u16)(ActDataSize & (3)); + AlignedLengthRecv = (_u16)(ActDataSize & (~3)); } /* Read 4 bytes aligned from interface */ /* therefore check the requested length and read only */ @@ -1099,7 +1179,7 @@ _SlReturnVal_t _SlDrvMsgRead(void) } /* copy the unaligned part, if any */ - if( LengthToCopy > 0) + if( LengthToCopy > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer,4); /* copy TailBuffer unaligned part (1/2/3 bytes) */ @@ -1112,7 +1192,7 @@ _SlReturnVal_t _SlDrvMsgRead(void) if (ActDataSize > g_pCB->FunctionParams.pCmdExt->RxPayloadLen) { /* calculate the rest of the data size to dump */ - AlignedLengthRecv = ActDataSize - (g_pCB->FunctionParams.pCmdExt->RxPayloadLen & (~3)); + AlignedLengthRecv = (_u16)( (ActDataSize + 3 - g_pCB->FunctionParams.pCmdExt->RxPayloadLen) & (~3) ); while( AlignedLengthRecv > 0) { NWP_IF_READ_CHECK(g_pCB->FD,TailBuffer, 4 ); @@ -1145,12 +1225,12 @@ _SlReturnVal_t _SlDrvMsgRead(void) /* ******************************************************************************/ /* _SlAsyncEventGenericHandler */ /* ******************************************************************************/ -void _SlAsyncEventGenericHandler(void) +static void _SlAsyncEventGenericHandler(_u8 bInCmdContext) { _u32 SlAsyncEvent = 0; - _u8 OpcodeFound = FALSE; + _u8 OpcodeFound = FALSE; _u8 i; - + _u32* pEventLocation = NULL; /* This pointer will override the async buffer with the translated event type */ _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)g_pCB->FunctionParams.AsyncExt.pAsyncBuf; @@ -1160,7 +1240,7 @@ void _SlAsyncEventGenericHandler(void) return; /* Iterate through all the opcode in the table */ - for (i=0; i< (sizeof(OpcodeTranslateTable) / sizeof(OpcodeKeyVal_t)); i++) + for (i=0; i< (_u8)(sizeof(OpcodeTranslateTable) / sizeof(OpcodeKeyVal_t)); i++) { if (OpcodeTranslateTable[i].opcode == pHdr->GenHeader.Opcode) { @@ -1173,9 +1253,21 @@ void _SlAsyncEventGenericHandler(void) /* No Async event found in the table */ if (OpcodeFound == FALSE) { + if ((pHdr->GenHeader.Opcode & SL_OPCODE_SILO_MASK) == SL_OPCODE_SILO_DEVICE) + { + DeviceEventInfo_t deviceEvent; + + deviceEvent.pAsyncMsgBuff = g_pCB->FunctionParams.AsyncExt.pAsyncBuf; + deviceEvent.bInCmdContext = bInCmdContext; + + g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler(&deviceEvent); + } + else + { /* This case handles all the async events handlers of the DEVICE & SOCK Silos which are handled internally. For these cases we send the async even buffer as is */ g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); + } } else { @@ -1190,15 +1282,21 @@ void _SlAsyncEventGenericHandler(void) g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler(pEventLocation); } - + } /* ******************************************************************************/ /* _SlDrvMsgReadCmdCtx */ /* ******************************************************************************/ -_SlReturnVal_t _SlDrvMsgReadCmdCtx(void) +static _SlReturnVal_t _SlDrvMsgReadCmdCtx(_u16 cmdOpcode) { +#ifndef SL_TINY_EXT + _u16 CmdCmpltTimeout; + + /* For any FS command, the timeout will be the long one as the commnad response holds the full response data */ + CmdCmpltTimeout = (SL_OPCODE_SILO_NVMEM & cmdOpcode)? (_u16)(SL_DRIVER_TIMEOUT_LONG) : (_u16)SL_DRIVER_TIMEOUT_SHORT; +#endif /* after command response is received and isCmdRespWaited */ /* flag is set FALSE, it is necessary to read out all */ @@ -1210,7 +1308,15 @@ _SlReturnVal_t _SlDrvMsgReadCmdCtx(void) { if(_SL_PENDING_RX_MSG(g_pCB)) { +#ifdef SL_TINY_EXT VERIFY_RET_OK(_SlDrvMsgRead()); +#else + if (_SlDrvMsgRead() != SL_OS_RET_CODE_OK) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + return SL_API_ABORTED; + } +#endif g_pCB->RxDoneCnt++; if (CMD_RESP_CLASS == g_pCB->FunctionParams.AsyncExt.RxMsgClass) @@ -1219,7 +1325,7 @@ _SlReturnVal_t _SlDrvMsgReadCmdCtx(void) /* In case CmdResp has been read without waiting on CmdSyncObj - that */ /* Sync object. That to prevent old signal to be processed. */ - sl_SyncObjClear(&g_pCB->CmdSyncObj); + SL_DRV_SYNC_OBJ_CLEAR(&g_pCB->CmdSyncObj); } else if (ASYNC_EVT_CLASS == g_pCB->FunctionParams.AsyncExt.RxMsgClass) { @@ -1229,9 +1335,9 @@ _SlReturnVal_t _SlDrvMsgReadCmdCtx(void) /* This way there will be no "dry shots" from CmdResp context to */ /* temporary context, i.e less waste of CPU and faster buffer */ /* release. */ - _SlAsyncEventGenericHandler(); - - + _SlAsyncEventGenericHandler(TRUE); + + #ifdef SL_MEMORY_MGMT_DYNAMIC sl_Free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); #else @@ -1241,8 +1347,19 @@ _SlReturnVal_t _SlDrvMsgReadCmdCtx(void) } else { +#ifdef SL_TINY_EXT /* CmdSyncObj will be signaled by IRQ */ _SlDrvSyncObjWaitForever(&g_pCB->CmdSyncObj); +#else + + + if (sl_SyncObjWait(&g_pCB->CmdSyncObj, CmdCmpltTimeout)) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + _SlDriverHandleError(SL_DEVICE_DRIVER_TIMEOUT_CMD_COMPLETE, cmdOpcode, CmdCmpltTimeout); + return SL_API_ABORTED; + } +#endif } } @@ -1252,11 +1369,11 @@ _SlReturnVal_t _SlDrvMsgReadCmdCtx(void) /* Temporary context. */ /* sl_Spawn is activated, using a different context */ - _SlDrvObjUnLock(&g_pCB->GlobalLockObj); - + SL_DRV_LOCK_GLOBAL_UNLOCK(); + if(_SL_PENDING_RX_MSG(g_pCB)) { - sl_Spawn((_SlSpawnEntryFunc_t)_SlDrvMsgReadSpawnCtx, NULL, 0); + (void)sl_Spawn((_SlSpawnEntryFunc_t)_SlDrvMsgReadSpawnCtx, NULL, 0); } return SL_OS_RET_CODE_OK; @@ -1277,7 +1394,7 @@ _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) { if (TRUE == g_pCB->IsCmdRespWaited) { - _SlDrvSyncObjSignal(&g_pCB->CmdSyncObj); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->CmdSyncObj); return SL_RET_CODE_OK; } } @@ -1286,20 +1403,30 @@ _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) while (OSI_OK != retCode); #else - _SlDrvObjLockWaitForever(&g_pCB->GlobalLockObj); + SL_DRV_LOCK_GLOBAL_LOCK_FOREVER(); #endif + /* pValue paramater is currently not in use */ + (void)pValue; /* Messages might have been read by CmdResp context. Therefore after */ /* getting LockObj, check again where the Pending Rx Msg is still present. */ if(FALSE == (_SL_PENDING_RX_MSG(g_pCB))) { - _SlDrvObjUnLock(&g_pCB->GlobalLockObj); - + SL_DRV_LOCK_GLOBAL_UNLOCK(); + return SL_RET_CODE_OK; } +#ifdef SL_TINY_EXT VERIFY_RET_OK(_SlDrvMsgRead()); +#else + if (_SlDrvMsgRead() != SL_OS_RET_CODE_OK) + { + SL_DRV_LOCK_GLOBAL_UNLOCK(); + return SL_API_ABORTED; + } +#endif g_pCB->RxDoneCnt++; @@ -1309,9 +1436,9 @@ _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) /* If got here and protected by LockObj a message is waiting */ /* to be read */ VERIFY_PROTOCOL(NULL != g_pCB->FunctionParams.AsyncExt.pAsyncBuf); - - _SlAsyncEventGenericHandler(); - + + _SlAsyncEventGenericHandler(FALSE); + #ifdef SL_MEMORY_MGMT_DYNAMIC sl_Free(g_pCB->FunctionParams.AsyncExt.pAsyncBuf); #else @@ -1329,7 +1456,7 @@ _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) VERIFY_PROTOCOL(0); } - _SlDrvObjUnLock(&g_pCB->GlobalLockObj); + SL_DRV_LOCK_GLOBAL_UNLOCK(); return(SL_RET_CODE_OK); } @@ -1350,7 +1477,7 @@ _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue) /* The Lookup table below holds the event handlers to be called according to the incoming RX message SILO type */ -const _SlSpawnEntryFunc_t RxMsgClassLUT[] = { +static const _SlSpawnEntryFunc_t RxMsgClassLUT[] = { (_SlSpawnEntryFunc_t)_SlDrvDeviceEventHandler, /* SL_OPCODE_SILO_DEVICE */ #if defined(sl_WlanEvtHdlr) || defined(EXT_LIB_REGISTERED_WLAN_EVENTS) (_SlSpawnEntryFunc_t)_SlDrvHandleWlanEvents, /* SL_OPCODE_SILO_WLAN */ @@ -1366,7 +1493,7 @@ const _SlSpawnEntryFunc_t RxMsgClassLUT[] = { #if defined(sl_NetAppEvtHdlr) || defined(EXT_LIB_REGISTERED_NETAPP_EVENTS) (_SlSpawnEntryFunc_t)_SlDrvHandleNetAppEvents, /* SL_OPCODE_SILO_NETAPP */ #else - NULL, + NULL, #endif NULL, /* SL_OPCODE_SILO_NVMEM */ NULL, /* SL_OPCODE_SILO_NETCFG */ @@ -1378,114 +1505,161 @@ const _SlSpawnEntryFunc_t RxMsgClassLUT[] = { /* ******************************************************************************/ /* _SlDrvClassifyRxMsg */ /* ******************************************************************************/ -void _SlDrvClassifyRxMsg( +static _SlReturnVal_t _SlDrvClassifyRxMsg( _SlOpcode_t Opcode) { _SlSpawnEntryFunc_t AsyncEvtHandler = NULL; _SlRxMsgClass_e RxMsgClass = CMD_RESP_CLASS; _u8 Silo; - - - if (0 == (SL_OPCODE_SYNC & Opcode)) - { /* Async event has received */ - - if (SL_OPCODE_DEVICE_DEVICEASYNCDUMMY == Opcode) - { - RxMsgClass = DUMMY_MSG_CLASS; - } - else if ( (SL_OPCODE_SOCKET_RECVASYNCRESPONSE == Opcode) || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE == Opcode) -#ifndef SL_TINY_EXT - || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 == Opcode) -#endif - ) - { - RxMsgClass = RECV_RESP_CLASS; - } - else - { + + + if (0 == (SL_OPCODE_SYNC & Opcode)) + { /* Async event has received */ + + if (SL_OPCODE_DEVICE_DEVICEASYNCDUMMY == Opcode) + { + RxMsgClass = DUMMY_MSG_CLASS; + } + else if ( (SL_OPCODE_SOCKET_RECVASYNCRESPONSE == Opcode) || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE == Opcode) +#ifndef SL_TINY_EXT + || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 == Opcode) +#endif + ) + { + RxMsgClass = RECV_RESP_CLASS; + } + else + { /* This is Async Event class message */ RxMsgClass = ASYNC_EVT_CLASS; - - /* Despite the fact that 4 bits are allocated in the SILO field, we actually have only 6 SILOs - So we can use the 8 options of SILO in look up table */ - Silo = ((Opcode >> SL_OPCODE_SILO_OFFSET) & 0x7); - VERIFY_PROTOCOL(Silo < (sizeof(RxMsgClassLUT)/sizeof(_SlSpawnEntryFunc_t))); + /* Despite the fact that 4 bits are allocated in the SILO field, we actually have only 6 SILOs + So we can use the 8 options of SILO in look up table */ + Silo = (_u8)((Opcode >> SL_OPCODE_SILO_OFFSET) & 0x7); + + VERIFY_PROTOCOL(Silo < (_u8)(sizeof(RxMsgClassLUT)/sizeof(_SlSpawnEntryFunc_t))); /* Set the async event hander according to the LUT */ AsyncEvtHandler = RxMsgClassLUT[Silo]; - + if ((SL_OPCODE_NETAPP_HTTPGETTOKENVALUE == Opcode) || (SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE == Opcode)) { AsyncEvtHandler = _SlDrvNetAppEventHandler; } -#ifndef SL_TINY_EXT +#ifndef SL_TINY_EXT else if (SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE == Opcode) { AsyncEvtHandler = (_SlSpawnEntryFunc_t)_sl_HandleAsync_PingResponse; } #endif - } - } + } + } - g_pCB->FunctionParams.AsyncExt.RxMsgClass = RxMsgClass; + g_pCB->FunctionParams.AsyncExt.RxMsgClass = RxMsgClass; g_pCB->FunctionParams.AsyncExt.AsyncEvtHandler = AsyncEvtHandler; - + + + return SL_RET_CODE_OK; } /* ******************************************************************************/ /* _SlDrvRxHdrRead */ /* ******************************************************************************/ -_SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize) +static _SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize) { _u32 SyncCnt = 0; - _u8 ShiftIdx; + _u8 ShiftIdx; + _u8 TimeoutState = TIMEOUT_STATE_INIT_VAL; + _u8 SearchSync = TRUE; + + +#if (!defined (SL_TINY_EXT)) && (defined(sl_GetTimestamp)) + _SlTimeoutParams_t TimeoutInfo={0}; +#endif #ifndef SL_IF_TYPE_UART /* 1. Write CNYS pattern to NWP when working in SPI mode only */ NWP_IF_WRITE_CHECK(g_pCB->FD, (_u8 *)&g_H2NCnysPattern.Short, SYNC_PATTERN_LEN); #endif - /* 2. Read 4 bytes (protocol aligned) */ - NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[0], 4); +#if (!defined (SL_TINY)) && (defined(sl_GetTimestamp)) + _SlDrvStartMeasureTimeout(&TimeoutInfo, SYNC_PATTERN_TIMEOUT_IN_MSEC); +#endif + + /* 2. Read 8 bytes (protocol aligned) - expected to be the sync pattern */ + NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[0], 8); _SL_DBG_SYNC_LOG(SyncCnt,pBuf); - /* Wait for SYNC_PATTERN_LEN from the device */ - while ( ! N2H_SYNC_PATTERN_MATCH(pBuf, g_pCB->TxSeqNum) ) + /* read while first 4 bytes are different than last 4 bytes */ + while ( *(_u32 *)&pBuf[0] == *(_u32 *)&pBuf[4]) { - /* 3. Debug limit of scan */ - VERIFY_PROTOCOL(SyncCnt < SL_SYNC_SCAN_THRESHOLD); + NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[4], 4); + } - /* 4. Read next 4 bytes to Low 4 bytes of buffer */ - if(0 == (SyncCnt % (_u32)SYNC_PATTERN_LEN)) + + /* scan for the sync pattern till found or timeout elapsed (if configured) */ + while (SearchSync && TimeoutState) + { + /* scan till we get the real sync pattern */ + for (ShiftIdx =0; ShiftIdx <=4 ; ShiftIdx++) { - NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[4], 4); - _SL_DBG_SYNC_LOG(SyncCnt,pBuf); + /* sync pattern found so complete the read to 4 bytes aligned */ + if (N2H_SYNC_PATTERN_MATCH(&pBuf[ShiftIdx], g_pCB->TxSeqNum)) + { + /* copy the bytes following the sync pattern to the buffer start */ + *(_u32 *)&pBuf[0] = *(_u32 *)&pBuf[ShiftIdx + SYNC_PATTERN_LEN]; + + /* read the rest of the byte */ + NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[SYNC_PATTERN_LEN - ShiftIdx], ShiftIdx); + + /* here we except to get the opcode + length or false doubled sync..*/ + SearchSync = FALSE; + break; + } + } - /* 5. Shift Buffer Up for checking if the sync is shifted */ - for(ShiftIdx = 0; ShiftIdx< 7; ShiftIdx++) + if (SearchSync == TRUE) { - pBuf[ShiftIdx] = pBuf[ShiftIdx+1]; - } - pBuf[7] = 0; + /* sync not found move top 4 bytes to bottom */ + *(_u32 *)&pBuf[0] = *(_u32 *)&pBuf[4]; - SyncCnt++; - } + /* read 4 more bytes to the buffer top */ + NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[4], 4); + } - /* 5. Sync pattern found. If needed, complete number of read bytes to multiple of 4 (protocol align) */ - SyncCnt %= SYNC_PATTERN_LEN; - if(SyncCnt > 0) - { - *(_u32 *)&pBuf[0] = *(_u32 *)&pBuf[4]; - NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[SYNC_PATTERN_LEN - SyncCnt], (_u16)SyncCnt); - } - else +#if (defined (sl_GetTimestamp)) && (!defined (SL_TINY)) + + /* if we got here after first timeout detection, it means that we gave + one more chance, and we can now exit the loop with timeout expiry */ + if (TIMEOUT_ONE_MORE_SHOT == TimeoutState) + { + TimeoutState = TIMEOUT_STATE_EXPIRY; + break; + } + + /* Timeout occured. do not break now as we want to give one more chance in case + the timeout occured due to some external context switch */ + if (_SlDrvIsTimeoutExpired(&TimeoutInfo)) + { + TimeoutState = TIMEOUT_ONE_MORE_SHOT; + } + +#endif + + } /* end of while*/ + + +#if (defined (sl_GetTimestamp)) && (!defined (SL_TINY)) + if (TIMEOUT_STATE_EXPIRY == TimeoutState) { - NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[0], 4); + return SL_API_ABORTED; } +#endif + + /* 6. Scan for Double pattern. */ while ( N2H_SYNC_PATTERN_MATCH(pBuf, g_pCB->TxSeqNum) ) @@ -1495,7 +1669,8 @@ _SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize) } g_pCB->TxSeqNum++; - /* 7. Here we've read Generic Header (4 bytes). Read the Resp Specific header (4 more bytes). */ + /* 7. Here we've read Generic Header (4 bytes opcode+length). + * Now Read the Resp Specific header (4 more bytes). */ NWP_IF_READ_CHECK(g_pCB->FD, &pBuf[SYNC_PATTERN_LEN], _SL_RESP_SPEC_HDR_SIZE); /* 8. Here we've read the entire Resp Header. */ @@ -1510,19 +1685,21 @@ _SlReturnVal_t _SlDrvRxHdrRead(_u8 *pBuf, _u8 *pAlignSize) /* ***************************************************************************** */ typedef union { - _BasicResponse_t Rsp; + _BasicResponse_t Rsp; }_SlBasicCmdMsg_u; #ifndef SL_TINY_EXT _i16 _SlDrvBasicCmd(_SlOpcode_t Opcode) { - _SlBasicCmdMsg_u Msg = {0}; + _SlBasicCmdMsg_u Msg; _SlCmdCtrl_t CmdCtrl; + _SlDrvMemZero(&Msg, (_u16)sizeof(_SlBasicCmdMsg_u)); + CmdCtrl.Opcode = Opcode; CmdCtrl.TxDescLen = 0; - CmdCtrl.RxDescLen = sizeof(_BasicResponse_t); + CmdCtrl.RxDescLen = (_SlArgSize_t)sizeof(_BasicResponse_t); VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, &Msg, NULL)); @@ -1531,9 +1708,9 @@ _i16 _SlDrvBasicCmd(_SlOpcode_t Opcode) } /***************************************************************************** - _SlDrvCmdSend - Send SL command without waiting for command response - This function is unprotected and the caller should make + _SlDrvCmdSend + Send SL command without waiting for command response + This function is unprotected and the caller should make sure global lock is active *****************************************************************************/ _SlReturnVal_t _SlDrvCmdSend( @@ -1544,16 +1721,16 @@ _SlReturnVal_t _SlDrvCmdSend( _SlReturnVal_t RetVal; _u8 IsCmdRespWaitedOriginalVal; - _SlFunctionParams_t originalFuncParms; + _SlFunctionParams_t originalFuncParms; /* save the current RespWait flag before clearing it */ IsCmdRespWaitedOriginalVal = g_pCB->IsCmdRespWaited; - /* save the current command parameters */ + /* save the current command paramaters */ sl_Memcpy(&originalFuncParms, &g_pCB->FunctionParams, sizeof(_SlFunctionParams_t)); g_pCB->IsCmdRespWaited = FALSE; - + SL_TRACE0(DBG_MSG, MSG_312, "_SlDrvCmdSend: call _SlDrvMsgWrite"); /* send the message */ @@ -1562,7 +1739,7 @@ _SlReturnVal_t _SlDrvCmdSend( /* restore the original RespWait flag */ g_pCB->IsCmdRespWaited = IsCmdRespWaitedOriginalVal; - /* restore the original command parameters */ + /* restore the original command paramaters */ sl_Memcpy(&g_pCB->FunctionParams, &originalFuncParms, sizeof(_SlFunctionParams_t)); return RetVal; @@ -1579,7 +1756,8 @@ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) _u8 CurrObjIndex = MAX_CONCURRENT_ACTIONS; /* Get free object */ - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); + if (MAX_CONCURRENT_ACTIONS > g_pCB->FreePoolIdx) { /* save the current obj index */ @@ -1591,7 +1769,7 @@ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) g_pCB->FreePoolIdx = g_pCB->ObjPool[CurrObjIndex].NextIndex; } else -#endif +#endif { /* No further free actions available */ g_pCB->FreePoolIdx = MAX_CONCURRENT_ACTIONS; @@ -1599,7 +1777,7 @@ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) } else { - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); return CurrObjIndex; } g_pCB->ObjPool[CurrObjIndex].ActionID = (_u8)ActionID; @@ -1610,19 +1788,19 @@ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) #ifndef SL_TINY_EXT /*In case this action is socket related, SocketID bit will be on In case SocketID is set to SL_MAX_SOCKETS, the socket is not relevant to the action. In that case ActionID bit will be on */ - while ( ( (SL_MAX_SOCKETS > SocketID) && (g_pCB->ActiveActionsBitmap & (1< SocketID) && (g_pCB->ActiveActionsBitmap & (1<ActiveActionsBitmap & (1<ObjPool[CurrObjIndex].NextIndex = g_pCB->PendingPoolIdx; g_pCB->PendingPoolIdx = CurrObjIndex; - _SlDrvProtectionObjUnLock(); - + SL_DRV_PROTECTION_OBJ_UNLOCK(); + /* wait for action to be free */ - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[CurrObjIndex].SyncObj); - + (void)_SlDrvSyncObjWaitForever(&g_pCB->ObjPool[CurrObjIndex].SyncObj); + /* set params and move to active (remove from pending list at _SlDrvReleasePoolObj) */ - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); } #endif /* mark as active. Set socket as active if action is on socket, otherwise mark action as active */ @@ -1636,9 +1814,9 @@ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) } /* move to active list */ g_pCB->ObjPool[CurrObjIndex].NextIndex = g_pCB->ActivePoolIdx; - g_pCB->ActivePoolIdx = CurrObjIndex; + g_pCB->ActivePoolIdx = CurrObjIndex; /* unlock */ - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); return CurrObjIndex; } @@ -1647,43 +1825,43 @@ _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID) /* ******************************************************************************/ void _SlDrvReleasePoolObj(_u8 ObjIdx) { -#ifndef SL_TINY_EXT +#ifndef SL_TINY_EXT _u8 PendingIndex; #endif - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); /* In Tiny mode, there is only one object pool so no pending actions are available */ #ifndef SL_TINY_EXT /* go over the pending list and release other pending action if needed */ - PendingIndex = g_pCB->PendingPoolIdx; - - while(MAX_CONCURRENT_ACTIONS > PendingIndex) - { - /* In case this action is socket related, SocketID is in use, otherwise will be set to SL_MAX_SOCKETS */ - if ( (g_pCB->ObjPool[PendingIndex].ActionID == g_pCB->ObjPool[ObjIdx].ActionID) && - ( (SL_MAX_SOCKETS == (g_pCB->ObjPool[PendingIndex].AdditionalData & BSD_SOCKET_ID_MASK)) || - ((SL_MAX_SOCKETS > (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)) && ( (g_pCB->ObjPool[PendingIndex].AdditionalData & BSD_SOCKET_ID_MASK) == (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK) ))) ) - { - /* remove from pending list */ - _SlRemoveFromList(&g_pCB->PendingPoolIdx, PendingIndex); - _SlDrvSyncObjSignal(&g_pCB->ObjPool[PendingIndex].SyncObj); - break; - } - PendingIndex = g_pCB->ObjPool[PendingIndex].NextIndex; - } -#endif - - if (SL_MAX_SOCKETS > (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)) - { - /* unset socketID */ - g_pCB->ActiveActionsBitmap &= ~(1<<(g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)); - } - else - { - /* unset actionID */ - g_pCB->ActiveActionsBitmap &= ~(1<ObjPool[ObjIdx].ActionID); - } + PendingIndex = g_pCB->PendingPoolIdx; + + while(MAX_CONCURRENT_ACTIONS > PendingIndex) + { + /* In case this action is socket related, SocketID is in use, otherwise will be set to SL_MAX_SOCKETS */ + if ( (g_pCB->ObjPool[PendingIndex].ActionID == g_pCB->ObjPool[ObjIdx].ActionID) && + ( (SL_MAX_SOCKETS == (g_pCB->ObjPool[PendingIndex].AdditionalData & BSD_SOCKET_ID_MASK)) || + ((SL_MAX_SOCKETS > (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)) && ( (g_pCB->ObjPool[PendingIndex].AdditionalData & BSD_SOCKET_ID_MASK) == (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK) ))) ) + { + /* remove from pending list */ + _SlRemoveFromList(&g_pCB->PendingPoolIdx, PendingIndex); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[PendingIndex].SyncObj); + break; + } + PendingIndex = g_pCB->ObjPool[PendingIndex].NextIndex; + } +#endif + + if (SL_MAX_SOCKETS > (g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)) + { + /* unset socketID */ + g_pCB->ActiveActionsBitmap &= ~(1<<(g_pCB->ObjPool[ObjIdx].AdditionalData & BSD_SOCKET_ID_MASK)); + } + else + { + /* unset actionID */ + g_pCB->ActiveActionsBitmap &= ~(1<ObjPool[ObjIdx].ActionID); + } /* delete old data */ g_pCB->ObjPool[ObjIdx].pRespArgs = NULL; @@ -1695,34 +1873,34 @@ void _SlDrvReleasePoolObj(_u8 ObjIdx) /* move to free list */ g_pCB->ObjPool[ObjIdx].NextIndex = g_pCB->FreePoolIdx; g_pCB->FreePoolIdx = ObjIdx; - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); } /* ******************************************************************************/ /* _SlRemoveFromList */ /* ******************************************************************************/ -void _SlRemoveFromList(_u8 *ListIndex, _u8 ItemIndex) +static void _SlRemoveFromList(_u8 *ListIndex, _u8 ItemIndex) { -#ifndef SL_TINY_EXT - _u8 Idx; -#endif - +#ifndef SL_TINY_EXT + _u8 Idx; +#endif + if (MAX_CONCURRENT_ACTIONS == g_pCB->ObjPool[*ListIndex].NextIndex) { *ListIndex = MAX_CONCURRENT_ACTIONS; } /* As MAX_CONCURRENT_ACTIONS is equal to 1 in Tiny mode */ #ifndef SL_TINY_EXT - /* need to remove the first item in the list and therefore update the global which holds this index */ - else if (*ListIndex == ItemIndex) - { - *ListIndex = g_pCB->ObjPool[ItemIndex].NextIndex; - } - else - { + /* need to remove the first item in the list and therefore update the global which holds this index */ + else if (*ListIndex == ItemIndex) + { + *ListIndex = g_pCB->ObjPool[ItemIndex].NextIndex; + } + else + { Idx = *ListIndex; - + while(MAX_CONCURRENT_ACTIONS > Idx) { /* remove from list */ @@ -1734,22 +1912,22 @@ void _SlRemoveFromList(_u8 *ListIndex, _u8 ItemIndex) Idx = g_pCB->ObjPool[Idx].NextIndex; } - } -#endif + } +#endif } /* ******************************************************************************/ /* _SlFindAndSetActiveObj */ /* ******************************************************************************/ -_SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd) +static _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd) { _u8 ActiveIndex; ActiveIndex = g_pCB->ActivePoolIdx; /* go over the active list if exist to find obj waiting for this Async event */ -#ifndef SL_TINY_EXT - while (MAX_CONCURRENT_ACTIONS > ActiveIndex) +#ifndef SL_TINY_EXT + while (MAX_CONCURRENT_ACTIONS > ActiveIndex) #else /* Only one Active action is availabe in tiny mode, so we can replace the loop with if condition */ if (MAX_CONCURRENT_ACTIONS > ActiveIndex) @@ -1761,12 +1939,12 @@ _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd) Opcode &= ~SL_OPCODE_IPV6; } - if ((g_pCB->ObjPool[ActiveIndex].ActionID == RECV_ID) && (Sd == g_pCB->ObjPool[ActiveIndex].AdditionalData) && - ( (SL_OPCODE_SOCKET_RECVASYNCRESPONSE == Opcode) || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE == Opcode) + if ((g_pCB->ObjPool[ActiveIndex].ActionID == RECV_ID) && (Sd == g_pCB->ObjPool[ActiveIndex].AdditionalData) && + ( (SL_OPCODE_SOCKET_RECVASYNCRESPONSE == Opcode) || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE == Opcode) #ifndef SL_TINY_EXT - || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 == Opcode) + || (SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 == Opcode) #endif - ) + ) ) { @@ -1774,7 +1952,7 @@ _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd) return SL_RET_CODE_OK; } /* In case this action is socket related, SocketID is in use, otherwise will be set to SL_MAX_SOCKETS */ - if ( (_SlActionLookupTable[ g_pCB->ObjPool[ActiveIndex].ActionID - MAX_SOCKET_ENUM_IDX].ActionAsyncOpcode == Opcode) && + if ( (_SlActionLookupTable[ g_pCB->ObjPool[ActiveIndex].ActionID - MAX_SOCKET_ENUM_IDX].ActionAsyncOpcode == Opcode) && ( ((Sd == (g_pCB->ObjPool[ActiveIndex].AdditionalData & BSD_SOCKET_ID_MASK) ) && (SL_MAX_SOCKETS > Sd)) || (SL_MAX_SOCKETS == (g_pCB->ObjPool[ActiveIndex].AdditionalData & BSD_SOCKET_ID_MASK)) ) ) { /* set handler */ @@ -1787,45 +1965,69 @@ _SlReturnVal_t _SlFindAndSetActiveObj(_SlOpcode_t Opcode, _u8 Sd) return SL_RET_CODE_SELF_ERROR; - +} + +#if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) +void _SlDrvDispatchHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse) +{ + _SlDrvHandleHttpServerEvents (slHttpServerEvent, slHttpServerResponse); } +#endif /* Wrappers for the object functions */ -void _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj) -{ - OSI_RET_OK_CHECK(sl_SyncObjWait(pSyncObj, SL_OS_WAIT_FOREVER)); -} -void _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj) +_SlReturnVal_t _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj) { OSI_RET_OK_CHECK(sl_SyncObjSignal(pSyncObj)); + return SL_OS_RET_CODE_OK; } -void _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj) +_SlReturnVal_t _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj) { OSI_RET_OK_CHECK(sl_LockObjLock(pLockObj, SL_OS_WAIT_FOREVER)); + return SL_OS_RET_CODE_OK; } -void _SlDrvProtectionObjLockWaitForever() +_SlReturnVal_t _SlDrvProtectionObjLockWaitForever(void) { OSI_RET_OK_CHECK(sl_LockObjLock(&g_pCB->ProtectionLockObj, SL_OS_WAIT_FOREVER)); + return SL_OS_RET_CODE_OK; } -void _SlDrvObjUnLock(_SlLockObj_t *pLockObj) +_SlReturnVal_t _SlDrvObjUnLock(_SlLockObj_t *pLockObj) { OSI_RET_OK_CHECK(sl_LockObjUnlock(pLockObj)); + return SL_OS_RET_CODE_OK; } -void _SlDrvProtectionObjUnLock() +_SlReturnVal_t _SlDrvProtectionObjUnLock(void) { OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->ProtectionLockObj)); + return SL_OS_RET_CODE_OK; +} + +static _SlReturnVal_t _SlDrvObjGlobalLockWaitForever(void) +{ +#ifndef SL_TINY_EXT + if (g_bDeviceRestartIsRequired == TRUE) + { + return SL_API_ABORTED; + } +#endif + return sl_LockObjLock(&g_pCB->GlobalLockObj, SL_OS_WAIT_FOREVER); } +_SlReturnVal_t _SlDrvGlobalObjUnLock(void) +{ + OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->GlobalLockObj)); + + return SL_OS_RET_CODE_OK; +} void _SlDrvMemZero(void* Addr, _u16 size) { @@ -1835,9 +2037,161 @@ void _SlDrvMemZero(void* Addr, _u16 size) void _SlDrvResetCmdExt(_SlCmdExt_t* pCmdExt) { - _SlDrvMemZero(pCmdExt, sizeof (_SlCmdExt_t)); + _SlDrvMemZero(pCmdExt, (_u16)sizeof (_SlCmdExt_t)); +} + + +#ifdef SL_TINY_EXT + +_SlReturnVal_t _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj) +{ + return sl_SyncObjWait(pSyncObj, SL_OS_WAIT_FOREVER); +} + +#else +_SlReturnVal_t _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj) +{ + (void)sl_SyncObjWait(pSyncObj, SL_OS_WAIT_FOREVER); + + /* if the wait is finished and we detect that restart is required (we in the middle of error handling), + than we should abort immediately from the current API command execution + */ + if (g_bDeviceRestartIsRequired == TRUE) + { + return SL_API_ABORTED; + } + + return SL_RET_CODE_OK; +} + +#endif + + +#ifndef SL_TINY_EXT + + +_SlReturnVal_t _SlDrvSyncObjWaitTimeout(_SlSyncObj_t *pSyncObj, _u32 timeoutVal, SlDriverAPIWithTimeout_e apiIdx) +{ + _SlReturnVal_t ret = sl_SyncObjWait(pSyncObj, timeoutVal); + + /* if timeout occured...*/ + if (ret) + { + _SlDriverHandleError(SL_DEVICE_DRIVER_TIMEOUT_ASYNC_EVENT, apiIdx, timeoutVal); + } + else if (g_bDeviceRestartIsRequired == TRUE) + { + return SL_API_ABORTED; + } + + return SL_RET_CODE_OK; +} + + +void _SlDriverHandleError(SlDeviceDriverError_e eError, _u32 info1, _u32 info2) +{ + _u8 i; + SlDeviceEvent_t devHandler; + + if (TRUE == g_bDeviceRestartIsRequired) + { + return; + } + + /* set the restart flag */ + g_bDeviceRestartIsRequired = TRUE; + + /* Upon the deletion of the mutex, all thread waiting on this + mutex will return immediately with an error (i.e. MUTEX_DELETED status) */ + (void)sl_LockObjDelete(&g_pCB->GlobalLockObj); + + /* signal all waiting sync objects */ + for (i=0; i< MAX_CONCURRENT_ACTIONS; i++) + { + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[i].SyncObj); + } + + /* prepare the event and notify the user app/ext libraries */ + devHandler.Event = eError; + + switch (eError) + { + case SL_DEVICE_ABORT_ERROR_EVENT: + { + devHandler.EventData.deviceReport.AbortType = (_u32)info1; + devHandler.EventData.deviceReport.AbortData = (_u32)info2; + } + break; + + /* For asyn event timeout type error: + * Info1 - Holds the SL API index (2 bytes) + */ + case SL_DEVICE_DRIVER_TIMEOUT_ASYNC_EVENT: + + /* For cmd complete timeout type error: + * Info1 - Holds the cmd opcode (2 bytes) + */ + case SL_DEVICE_DRIVER_TIMEOUT_CMD_COMPLETE: + { + devHandler.EventData.deviceDriverReport.info = info1; + } + break; + + default: + devHandler.EventData.deviceDriverReport.info = info1; + break; + } + + /* call the registered handlers */ + _SlDrvHandleGeneralEvents(&devHandler); + +} + + +#if (defined(sl_GetTimestamp)) + +void _SlDrvStartMeasureTimeout(_SlTimeoutParams_t *pTimeoutInfo, _u32 TimeoutInMsec) +{ + pTimeoutInfo->Total10MSecUnits = TimeoutInMsec / 10; + pTimeoutInfo->TSPrev = sl_GetTimestamp(); } +_u8 _SlDrvIsTimeoutExpired(_SlTimeoutParams_t *pTimeoutInfo) +{ + _u32 TSCount; + + pTimeoutInfo->TSCurr = sl_GetTimestamp(); + if (pTimeoutInfo->TSCurr >= pTimeoutInfo->TSPrev) + { + pTimeoutInfo->DeltaTicks = pTimeoutInfo->TSCurr - pTimeoutInfo->TSPrev; + } + else + { + pTimeoutInfo->DeltaTicks = (SL_TIMESTAMP_MAX_VALUE - pTimeoutInfo->TSPrev) + pTimeoutInfo->TSCurr; + } + + TSCount = pTimeoutInfo->DeltaTicksReminder + pTimeoutInfo->DeltaTicks; + + + if (TSCount > SL_TIMESTAMP_TICKS_IN_10_MILLISECONDS) + { + pTimeoutInfo->Total10MSecUnits -= (TSCount / SL_TIMESTAMP_TICKS_IN_10_MILLISECONDS); + pTimeoutInfo->DeltaTicksReminder = TSCount % SL_TIMESTAMP_TICKS_IN_10_MILLISECONDS; + + if (pTimeoutInfo->Total10MSecUnits > 0) + { + pTimeoutInfo->TSPrev = pTimeoutInfo->TSCurr; + } + else + { + return TRUE; + } + } + return FALSE; +} +#endif + +#endif diff --git a/hardware/lm4f/libraries/WiFi/utility/driver.h b/hardware/lm4f/libraries/WiFi/utility/driver.h index 157427619f3..8bfea9e9be4 100644 --- a/hardware/lm4f/libraries/WiFi/utility/driver.h +++ b/hardware/lm4f/libraries/WiFi/utility/driver.h @@ -1,43 +1,60 @@ /* * driver.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + #ifndef __DRIVER_INT_H__ #define __DRIVER_INT_H__ +#define TIMEOUT_STATE_EXPIRY (0) +#define TIMEOUT_ONE_MORE_SHOT (1) +#define TIMEOUT_STATE_INIT_VAL (2) + +/* Timeouts for the sync objects */ +#ifndef SL_DRIVER_TIMEOUT_SHORT +#define SL_DRIVER_TIMEOUT_SHORT (1000) /* msec units */ +#endif +#ifndef SL_DRIVER_TIMEOUT_LONG +#define SL_DRIVER_TIMEOUT_LONG (65535) /* msec units */ +#endif + +#define INIT_COMPLETE_TIMEOUT SL_DRIVER_TIMEOUT_LONG +#define STOP_DEVICE_TIMEOUT SL_DRIVER_TIMEOUT_LONG +#ifndef SYNC_PATTERN_TIMEOUT_IN_MSEC +#define SYNC_PATTERN_TIMEOUT_IN_MSEC (50) /* the sync patttern timeout in milliseconds units */ +#endif /*****************************************************************************/ /* Macro declarations */ /*****************************************************************************/ @@ -47,10 +64,73 @@ #endif #define USEC_DELAY (50) +#define SL_DRV_PROTECTION_OBJ_UNLOCK() (void)_SlDrvProtectionObjUnLock(); +#define SL_DRV_PROTECTION_OBJ_LOCK_FOREVER() (void)_SlDrvProtectionObjLockWaitForever(); +#define SL_DRV_OBJ_UNLOCK(pObj) (void)_SlDrvObjUnLock(pObj); +#define SL_DRV_OBJ_LOCK_FOREVER(pObj) (void)_SlDrvObjLockWaitForever(pObj); +#define SL_DRV_SYNC_OBJ_SIGNAL(pObj) (void)_SlDrvSyncObjSignal(pObj); +#define SL_DRV_SYNC_OBJ_CLEAR(pObj) (void)sl_SyncObjWait(pObj,SL_OS_NO_WAIT); + + +#ifdef SL_TINY_EXT +#define SL_DRV_SYNC_OBJ_WAIT_FOREVER(SyncObj) (void)_SlDrvSyncObjWaitForever(SyncObj); +#define SL_DRV_LOCK_GLOBAL_LOCK_FOREVER() (void)_SlDrvObjGlobalLockWaitForever(); +#define SL_DRV_LOCK_GLOBAL_UNLOCK() (void)_SlDrvGlobalObjUnLock(); +#else +#define SL_DRV_SYNC_OBJ_WAIT_FOREVER(SyncObj) { \ +if (SL_API_ABORTED == _SlDrvSyncObjWaitForever(SyncObj)) \ +{ \ + return SL_API_ABORTED; \ +} \ +} + +#define SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(SyncObj, timeoutVal, apiIdx) { \ +if (SL_API_ABORTED == _SlDrvSyncObjWaitTimeout(SyncObj, timeoutVal, apiIdx)) \ +{ \ + return SL_API_ABORTED; \ +} \ +} +#define SL_DRV_LOCK_GLOBAL_LOCK_FOREVER() { \ +_SlReturnVal_t retVal; \ + \ +retVal = _SlDrvObjGlobalLockWaitForever(); \ +if (retVal) \ +{ \ + return retVal; \ +} \ +} + +#define SL_DRV_LOCK_GLOBAL_UNLOCK() { \ +_SlReturnVal_t retVal; \ + \ +retVal = _SlDrvGlobalObjUnLock(); \ +if (retVal) \ +{ \ + return retVal; \ +} \ +} +#endif + + /*****************************************************************************/ /* Structure/Enum declarations */ /*****************************************************************************/ +typedef struct +{ + _u32 TSPrev; + _u32 TSCurr; + _u32 DeltaTicks; + _u32 DeltaTicksReminder; + _i32 Total10MSecUnits; +} _SlTimeoutParams_t; + +typedef struct +{ + _u8 *pAsyncMsgBuff; + _u8 bInCmdContext; +} DeviceEventInfo_t; + typedef struct { _SlOpcode_t Opcode; @@ -62,7 +142,7 @@ typedef struct { _u16 TxPayloadLen; _i16 RxPayloadLen; - _i16 ActualRxPayloadLen; + _i16 ActualRxPayloadLen; _u8 *pTxPayload; _u8 *pRxPayload; }_SlCmdExt_t; @@ -70,56 +150,56 @@ typedef struct typedef struct _SlArgsData_t { - _u8 *pArgs; - _u8 *pData; + _u8 *pArgs; + _u8 *pData; } _SlArgsData_t; typedef struct _SlPoolObj_t { - _SlSyncObj_t SyncObj; - _u8 *pRespArgs; - _u8 ActionID; - _u8 AdditionalData; /* use for socketID and one bit which indicate supprt IPV6 or not (1=support, 0 otherwise) */ - _u8 NextIndex; + _SlSyncObj_t SyncObj; + _u8 *pRespArgs; + _u8 ActionID; + _u8 AdditionalData; /* use for socketID and one bit which indicate supprt IPV6 or not (1=support, 0 otherwise) */ + _u8 NextIndex; } _SlPoolObj_t; typedef enum { - SOCKET_0, - SOCKET_1, - SOCKET_2, - SOCKET_3, - SOCKET_4, - SOCKET_5, - SOCKET_6, - SOCKET_7, - MAX_SOCKET_ENUM_IDX, -#ifndef SL_TINY_EXT + SOCKET_0, + SOCKET_1, + SOCKET_2, + SOCKET_3, + SOCKET_4, + SOCKET_5, + SOCKET_6, + SOCKET_7, + MAX_SOCKET_ENUM_IDX, +#ifndef SL_TINY_EXT ACCEPT_ID = MAX_SOCKET_ENUM_IDX, CONNECT_ID, #else CONNECT_ID = MAX_SOCKET_ENUM_IDX, #endif -#ifndef SL_TINY_EXT - SELECT_ID, +#ifndef SL_TINY_EXT + SELECT_ID, +#endif + GETHOSYBYNAME_ID, +#ifndef SL_TINY_EXT + GETHOSYBYSERVICE_ID, + PING_ID, #endif - GETHOSYBYNAME_ID, -#ifndef SL_TINY_EXT - GETHOSYBYSERVICE_ID, - PING_ID, -#endif START_STOP_ID, - RECV_ID + RECV_ID }_SlActionID_e; typedef struct _SlActionLookup_t { - _u8 ActionID; - _u16 ActionAsyncOpcode; - _SlSpawnEntryFunc_t AsyncEventHandler; + _u8 ActionID; + _u16 ActionAsyncOpcode; + _SlSpawnEntryFunc_t AsyncEventHandler; } _SlActionLookup_t; @@ -142,7 +222,7 @@ typedef enum typedef struct { _u8 *pAsyncBuf; /* place to write pointer to buffer with CmdResp's Header + Arguments */ - _u8 ActionIndex; + _u8 ActionIndex; _SlSpawnEntryFunc_t AsyncEvtHandler; /* place to write pointer to AsyncEvent handler (calc-ed by Opcode) */ _SlRxMsgClass_e RxMsgClass; /* type of Rx message */ } AsyncExt_t; @@ -151,9 +231,9 @@ typedef _u8 _SlSd_t; typedef struct { - _SlCmdCtrl_t *pCmdCtrl; - _u8 *pTxRxDescBuff; - _SlCmdExt_t *pCmdExt; + _SlCmdCtrl_t *pCmdCtrl; + _u8 *pTxRxDescBuff; + _SlCmdExt_t *pCmdExt; AsyncExt_t AsyncExt; }_SlFunctionParams_t; @@ -166,26 +246,30 @@ typedef struct P_INIT_CALLBACK pInitCallback; _SlPoolObj_t ObjPool[MAX_CONCURRENT_ACTIONS]; - _u8 FreePoolIdx; - _u8 PendingPoolIdx; - _u8 ActivePoolIdx; - _u32 ActiveActionsBitmap; - _SlLockObj_t ProtectionLockObj; + _u8 FreePoolIdx; + _u8 PendingPoolIdx; + _u8 ActivePoolIdx; + _u32 ActiveActionsBitmap; + _SlLockObj_t ProtectionLockObj; - _SlSyncObj_t CmdSyncObj; + _SlSyncObj_t CmdSyncObj; _u8 IsCmdRespWaited; _SlFlowContCB_t FlowContCB; _u8 TxSeqNum; _u8 RxDoneCnt; _u8 SocketNonBlocking; - _u8 SocketTXFailure; + _u8 SocketTXFailure; /* for stack reduction the parameters are globals */ _SlFunctionParams_t FunctionParams; _u8 ActionIndex; }_SlDriverCb_t; -extern _volatile _u8 RxIrqCnt; +extern _volatile _u8 RxIrqCnt; + +#ifndef SL_TINY_EXT +extern _volatile _u8 g_bDeviceRestartIsRequired; +#endif extern _SlDriverCb_t* g_pCB; extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc; @@ -193,49 +277,67 @@ extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc; /*****************************************************************************/ /* Function prototypes */ /*****************************************************************************/ -extern void _SlDrvDriverCBInit(void); -extern void _SlDrvDriverCBDeinit(void); -extern void _SlDrvRxIrqHandler(void *pValue); + +extern _SlReturnVal_t _SlDrvDriverCBInit(void); +extern _SlReturnVal_t _SlDrvDriverCBDeinit(void); +extern _SlReturnVal_t _SlDrvRxIrqHandler(void *pValue); extern _SlReturnVal_t _SlDrvCmdOp(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); extern _SlReturnVal_t _SlDrvCmdSend(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); extern _SlReturnVal_t _SlDrvDataReadOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); extern _SlReturnVal_t _SlDrvDataWriteOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt); -extern void _sl_HandleAsync_InitComplete(void *pVoidBuf); -extern void _sl_HandleAsync_Connect(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_InitComplete(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_Connect(void *pVoidBuf); +extern _SlReturnVal_t _SlDrvGlobalObjUnLock(void); +extern _SlReturnVal_t _SlDrvMsgReadSpawnCtx(void *pValue); #ifndef SL_TINY_EXT extern _i16 _SlDrvBasicCmd(_SlOpcode_t Opcode); -extern void _sl_HandleAsync_Accept(void *pVoidBuf); -extern void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf); -extern void _sl_HandleAsync_Select(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_Accept(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_Select(void *pVoidBuf); +#ifdef sl_GetTimestamp +extern void _SlDrvStartMeasureTimeout(_SlTimeoutParams_t *pTimeoutInfo, _u32 TimeoutInMsec); +extern _u8 _SlDrvIsTimeoutExpired(_SlTimeoutParams_t *pTimeoutInfo); #endif +#endif +extern _SlReturnVal_t _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf); +extern _SlReturnVal_t _sl_HandleAsync_PingResponse(void *pVoidBuf); +extern _SlReturnVal_t _SlDrvNetAppEventHandler(void* pArgs); + +#if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) +extern void _SlDrvDispatchHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse); +#endif -extern void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf); -extern void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf); -extern void _sl_HandleAsync_PingResponse(void *pVoidBuf); -extern void _SlDrvNetAppEventHandler(void* pArgs); -extern void _SlDrvDeviceEventHandler(void* pArgs); extern void _sl_HandleAsync_Stop(void *pVoidBuf); -extern _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID); +extern _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID); extern void _SlDrvReleasePoolObj(_u8 pObj); -extern _u16 _SlDrvAlignSize(_u16 msgLen); -extern _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID); +extern _u16 _SlDrvAlignSize(_u16 msgLen); +extern _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _SlActionID_e ActionID, _u8 SocketID); + -extern void _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj); -extern void _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj); -extern void _SlDrvObjLock(_SlLockObj_t *pLockObj, _SlTime_t Timeout); -extern void _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj); -extern void _SlDrvProtectionObjLockWaitForever(); -extern void _SlDrvObjUnLock(_SlLockObj_t *pLockObj); -extern void _SlDrvProtectionObjUnLock(); +extern _SlReturnVal_t _SlDrvDeviceEventHandler(void* pEventInfo); +extern _SlReturnVal_t _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj); +extern _SlReturnVal_t _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj); +extern _SlReturnVal_t _SlDrvSyncObjWaitTimeout(_SlSyncObj_t *pSyncObj, + _u32 timeoutVal, + SlDriverAPIWithTimeout_e apiIdx); + +extern _SlReturnVal_t _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj); +extern _SlReturnVal_t _SlDrvObjLock(_SlLockObj_t *pLockObj, _SlTime_t Timeout); +extern _SlReturnVal_t _SlDrvProtectionObjLockWaitForever(void); +extern _SlReturnVal_t _SlDrvObjUnLock(_SlLockObj_t *pLockObj); +extern _SlReturnVal_t _SlDrvProtectionObjUnLock(void); extern void _SlDrvMemZero(void* Addr, _u16 size); extern void _SlDrvResetCmdExt(_SlCmdExt_t* pCmdExt); - +#ifndef SL_TINY_EXT +extern void _SlDriverHandleError(SlDeviceDriverError_e eError, _u32 info1, _u32 info2); +#endif #define _SL_PROTOCOL_ALIGN_SIZE(msgLen) (((msgLen)+3) & (~3)) #define _SL_IS_PROTOCOL_ALIGNED_SIZE(msgLen) (!((msgLen) & 3)) diff --git a/hardware/lm4f/libraries/WiFi/utility/flowcont.c b/hardware/lm4f/libraries/WiFi/utility/flowcont.c index aa71780ccf2..f785c9d5236 100644 --- a/hardware/lm4f/libraries/WiFi/utility/flowcont.c +++ b/hardware/lm4f/libraries/WiFi/utility/flowcont.c @@ -1,35 +1,35 @@ /* * flowcont.c - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ diff --git a/hardware/lm4f/libraries/WiFi/utility/flowcont.h b/hardware/lm4f/libraries/WiFi/utility/flowcont.h index 587f3d8b763..2f8f7c8c2d7 100644 --- a/hardware/lm4f/libraries/WiFi/utility/flowcont.h +++ b/hardware/lm4f/libraries/WiFi/utility/flowcont.h @@ -1,35 +1,35 @@ /* * flowcont.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -38,7 +38,7 @@ #define __FLOWCONT_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif diff --git a/hardware/lm4f/libraries/WiFi/utility/fs.c b/hardware/lm4f/libraries/WiFi/utility/fs.c index 35ca0a084b6..2a57ae2aad2 100644 --- a/hardware/lm4f/libraries/WiFi/utility/fs.c +++ b/hardware/lm4f/libraries/WiFi/utility/fs.c @@ -1,35 +1,35 @@ /* * fs.c - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -55,10 +55,12 @@ #ifndef SL_TINY +static _u16 _sl_Strlen(const _u8 *buffer); + /*****************************************************************************/ /* _sl_Strlen */ /*****************************************************************************/ -_u16 _sl_Strlen(const _u8 *buffer) +static _u16 _sl_Strlen(const _u8 *buffer) { _u16 len = 0; if( buffer != NULL ) @@ -75,12 +77,12 @@ _u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags) { _u32 granIdx = 0; _u32 granNum = 0; - _u32 granTable[_FS_MAX_MODE_SIZE_GRAN] = {256,1024,4096,16384,65536}; - for(granIdx= _FS_MODE_SIZE_GRAN_256B ;granIdx< _FS_MAX_MODE_SIZE_GRAN;granIdx++) - { - if( granTable[granIdx]*255 >= maxSizeInBytes ) - break; - } + _u32 granTable[_FS_MAX_MODE_SIZE_GRAN] = {256,1024,4096,16384,65536}; + for(granIdx= _FS_MODE_SIZE_GRAN_256B ;granIdx< _FS_MAX_MODE_SIZE_GRAN;granIdx++) + { + if( granTable[granIdx]*255 >= maxSizeInBytes ) + break; + } granNum = maxSizeInBytes/granTable[granIdx]; if( maxSizeInBytes % granTable[granIdx] != 0 ) granNum++; @@ -95,22 +97,22 @@ _u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags) /*****************************************************************************/ /*****************************************************************************/ -/* sl_FsOpen */ +/* sl_FsOpen */ /*****************************************************************************/ typedef union { - _FsOpenCommand_t Cmd; - _FsOpenResponse_t Rsp; + _FsOpenCommand_t Cmd; + _FsOpenResponse_t Rsp; }_SlFsOpenMsg_u; #if _SL_INCLUDE_FUNC(sl_FsOpen) -const _SlCmdCtrl_t _SlFsOpenCmdCtrl = +static const _SlCmdCtrl_t _SlFsOpenCmdCtrl = { SL_OPCODE_NVMEM_FILEOPEN, - sizeof(_FsOpenCommand_t), - sizeof(_FsOpenResponse_t) + (_SlArgSize_t)sizeof(_FsOpenCommand_t), + (_SlArgSize_t)sizeof(_FsOpenResponse_t) }; _i32 sl_FsOpen(const _u8 *pFileName,const _u32 AccessModeAndMaxSize, _u32 *pToken,_i32 *pFileHandle) @@ -119,74 +121,85 @@ _i32 sl_FsOpen(const _u8 *pFileName,const _u32 AccessModeAndMaxSize, _u32 *pToke _SlFsOpenMsg_u Msg; _SlCmdExt_t CmdExt; - CmdExt.TxPayloadLen = (_sl_Strlen(pFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */ + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + CmdExt.TxPayloadLen = (_u16)((_sl_Strlen(pFileName)+4) & (~3)); /* add 4: 1 for NULL and the 3 for align */ CmdExt.RxPayloadLen = 0; CmdExt.pTxPayload = (_u8*)pFileName; CmdExt.pRxPayload = NULL; - Msg.Cmd.Mode = AccessModeAndMaxSize; + Msg.Cmd.Mode = AccessModeAndMaxSize; - if(pToken != NULL) - { + if(pToken != NULL) + { Msg.Cmd.Token = *pToken; - } + } else - { + { Msg.Cmd.Token = 0; - } + } RetVal = _SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsOpenCmdCtrl, &Msg, &CmdExt); - *pFileHandle = Msg.Rsp.FileHandle; - if (pToken != NULL) - { + *pFileHandle = (_i32)Msg.Rsp.FileHandle; + if (pToken != NULL) + { *pToken = Msg.Rsp.Token; - } - - /* in case of an error, return the erros file handler as an error code */ - if( *pFileHandle < 0 ) - { - return *pFileHandle; - } + } + + /* in case of an error, return the erros file handler as an error code */ + if( *pFileHandle < 0 ) + { + return *pFileHandle; + } return (_i32)RetVal; } #endif /*****************************************************************************/ -/* sl_FsClose */ +/* sl_FsClose */ /*****************************************************************************/ typedef union { - _FsCloseCommand_t Cmd; - _BasicResponse_t Rsp; + _FsCloseCommand_t Cmd; + _BasicResponse_t Rsp; }_SlFsCloseMsg_u; #if _SL_INCLUDE_FUNC(sl_FsClose) -const _SlCmdCtrl_t _SlFsCloseCmdCtrl = +static const _SlCmdCtrl_t _SlFsCloseCmdCtrl = { SL_OPCODE_NVMEM_FILECLOSE, - sizeof(_FsCloseCommand_t), - sizeof(_FsCloseResponse_t) + (_SlArgSize_t)sizeof(_FsCloseCommand_t), + (_SlArgSize_t)sizeof(_FsCloseResponse_t) }; + _i16 sl_FsClose(const _i32 FileHdl, const _u8* pCeritificateFileName,const _u8* pSignature ,const _u32 SignatureLen) { - _SlFsCloseMsg_u Msg = {0}; - _SlCmdExt_t ExtCtrl; - - Msg.Cmd.FileHandle = FileHdl; + _SlFsCloseMsg_u Msg; + _SlCmdExt_t ExtCtrl; + + _SlDrvMemZero(&Msg, (_u16)sizeof(_FsCloseCommand_t)); + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + Msg.Cmd.FileHandle = (_u32)FileHdl; if( pCeritificateFileName != NULL ) { - Msg.Cmd.CertificFileNameLength = (_sl_Strlen(pCeritificateFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */ + Msg.Cmd.CertificFileNameLength = (_u32)((_sl_Strlen(pCeritificateFileName)+4) & (~3)); /* add 4: 1 for NULL and the 3 for align */ } Msg.Cmd.SignatureLen = SignatureLen; - - ExtCtrl.TxPayloadLen = ((SignatureLen+3) & (~3)); /* align */ + + ExtCtrl.TxPayloadLen = (_u16)(((SignatureLen+3) & (~3))); /* align */ ExtCtrl.pTxPayload = (_u8*)pSignature; ExtCtrl.RxPayloadLen = (_i16)Msg.Cmd.CertificFileNameLength; ExtCtrl.pRxPayload = (_u8*)pCeritificateFileName; /* Add signature */ - + if(ExtCtrl.pRxPayload != NULL && ExtCtrl.RxPayloadLen != 0) { ExtCtrl.RxPayloadLen = ExtCtrl.RxPayloadLen * (-1); @@ -200,23 +213,23 @@ _i16 sl_FsClose(const _i32 FileHdl, const _u8* pCeritificateFileName,const _u8* /*****************************************************************************/ -/* sl_FsRead */ +/* sl_FsRead */ /*****************************************************************************/ typedef union { - _FsReadCommand_t Cmd; - _FsReadResponse_t Rsp; + _FsReadCommand_t Cmd; + _FsReadResponse_t Rsp; }_SlFsReadMsg_u; #if _SL_INCLUDE_FUNC(sl_FsRead) -const _SlCmdCtrl_t _SlFsReadCmdCtrl = +static const _SlCmdCtrl_t _SlFsReadCmdCtrl = { SL_OPCODE_NVMEM_FILEREADCOMMAND, - sizeof(_FsReadCommand_t), - sizeof(_FsReadResponse_t) -}; + (_SlArgSize_t)sizeof(_FsReadCommand_t), + (_SlArgSize_t)sizeof(_FsReadResponse_t) +}; _i32 sl_FsRead(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) { @@ -226,15 +239,19 @@ _i32 sl_FsRead(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) _SlReturnVal_t RetVal =0; _i32 RetCount = 0; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + ExtCtrl.TxPayloadLen = 0; ExtCtrl.pTxPayload = NULL; ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len); - ExtCtrl.RxPayloadLen = ChunkLen; + ExtCtrl.RxPayloadLen = (_i16)ChunkLen; ExtCtrl.pRxPayload = (_u8 *)(pData); Msg.Cmd.Offset = Offset; Msg.Cmd.Len = ChunkLen; - Msg.Cmd.FileHandle = FileHdl; + Msg.Cmd.FileHandle = (_u32)FileHdl; do { RetVal = _SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsReadCmdCtrl, &Msg, &ExtCtrl); @@ -257,9 +274,9 @@ _i32 sl_FsRead(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) Msg.Cmd.Offset = Offset; ExtCtrl.pRxPayload += ChunkLen; ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len); - ExtCtrl.RxPayloadLen = ChunkLen; + ExtCtrl.RxPayloadLen = (_i16)ChunkLen; Msg.Cmd.Len = ChunkLen; - Msg.Cmd.FileHandle = FileHdl; + Msg.Cmd.FileHandle = (_u32)FileHdl; } else { @@ -272,22 +289,22 @@ _i32 sl_FsRead(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) #endif /*****************************************************************************/ -/* sl_FsWrite */ +/* sl_FsWrite */ /*****************************************************************************/ typedef union { - _FsWriteCommand_t Cmd; - _FsWriteResponse_t Rsp; + _FsWriteCommand_t Cmd; + _FsWriteResponse_t Rsp; }_SlFsWriteMsg_u; #if _SL_INCLUDE_FUNC(sl_FsWrite) -const _SlCmdCtrl_t _SlFsWriteCmdCtrl = +static const _SlCmdCtrl_t _SlFsWriteCmdCtrl = { SL_OPCODE_NVMEM_FILEWRITECOMMAND, - sizeof(_FsWriteCommand_t), - sizeof(_FsWriteResponse_t) + (_SlArgSize_t)sizeof(_FsWriteCommand_t), + (_SlArgSize_t)sizeof(_FsWriteResponse_t) }; _i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) @@ -298,6 +315,10 @@ _i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) _SlReturnVal_t RetVal; _i32 RetCount = 0; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + ExtCtrl.RxPayloadLen = 0; ExtCtrl.pRxPayload = NULL; @@ -306,11 +327,11 @@ _i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) ExtCtrl.pTxPayload = (_u8 *)(pData); Msg.Cmd.Offset = Offset; Msg.Cmd.Len = ChunkLen; - Msg.Cmd.FileHandle = FileHdl; + Msg.Cmd.FileHandle = (_u32)FileHdl; do { - + RetVal = _SlDrvCmdOp((_SlCmdCtrl_t *)&_SlFsWriteCmdCtrl, &Msg, &ExtCtrl); if(SL_OS_RET_CODE_OK == RetVal) { @@ -334,7 +355,7 @@ _i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) ChunkLen = (_u16)sl_min(MAX_NVMEM_CHUNK_SIZE,Len); ExtCtrl.TxPayloadLen = ChunkLen; Msg.Cmd.Len = ChunkLen; - Msg.Cmd.FileHandle = FileHdl; + Msg.Cmd.FileHandle = (_u32)FileHdl; } else { @@ -347,23 +368,23 @@ _i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset, _u8* pData,_u32 Len) #endif /*****************************************************************************/ -/* sl_FsGetInfo */ +/* sl_FsGetInfo */ /*****************************************************************************/ typedef union { - _FsGetInfoCommand_t Cmd; - _FsGetInfoResponse_t Rsp; + _FsGetInfoCommand_t Cmd; + _FsGetInfoResponse_t Rsp; }_SlFsGetInfoMsg_u; #if _SL_INCLUDE_FUNC(sl_FsGetInfo) -const _SlCmdCtrl_t _SlFsGetInfoCmdCtrl = +static const _SlCmdCtrl_t _SlFsGetInfoCmdCtrl = { SL_OPCODE_NVMEM_FILEGETINFOCOMMAND, - sizeof(_FsGetInfoCommand_t), - sizeof(_FsGetInfoResponse_t) + (_SlArgSize_t)sizeof(_FsGetInfoCommand_t), + (_SlArgSize_t)sizeof(_FsGetInfoResponse_t) }; _i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileInfo) @@ -371,7 +392,11 @@ _i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileI _SlFsGetInfoMsg_u Msg; _SlCmdExt_t CmdExt; - CmdExt.TxPayloadLen = (_sl_Strlen(pFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */ + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + CmdExt.TxPayloadLen = (_u16)((_sl_Strlen(pFileName)+4) & (~3)); /* add 4: 1 for NULL and the 3 for align */ CmdExt.RxPayloadLen = 0; CmdExt.pTxPayload = (_u8*)pFileName; CmdExt.pRxPayload = NULL; @@ -391,22 +416,22 @@ _i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileI #endif /*****************************************************************************/ -/* sl_FsDel */ +/* sl_FsDel */ /*****************************************************************************/ typedef union { - _FsDeleteCommand_t Cmd; - _FsDeleteResponse_t Rsp; + _FsDeleteCommand_t Cmd; + _FsDeleteResponse_t Rsp; }_SlFsDeleteMsg_u; #if _SL_INCLUDE_FUNC(sl_FsDel) -const _SlCmdCtrl_t _SlFsDeleteCmdCtrl = +static const _SlCmdCtrl_t _SlFsDeleteCmdCtrl = { SL_OPCODE_NVMEM_FILEDELCOMMAND, - sizeof(_FsDeleteCommand_t), - sizeof(_FsDeleteResponse_t) + (_SlArgSize_t)sizeof(_FsDeleteCommand_t), + (_SlArgSize_t)sizeof(_FsDeleteResponse_t) }; _i16 sl_FsDel(const _u8 *pFileName,const _u32 Token) @@ -414,7 +439,10 @@ _i16 sl_FsDel(const _u8 *pFileName,const _u32 Token) _SlFsDeleteMsg_u Msg; _SlCmdExt_t CmdExt; - CmdExt.TxPayloadLen = (_sl_Strlen(pFileName)+4) & (~3); /* add 4: 1 for NULL and the 3 for align */ + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + CmdExt.TxPayloadLen = (_u16)((_sl_Strlen(pFileName)+4) & (~3)); /* add 4: 1 for NULL and the 3 for align */ CmdExt.RxPayloadLen = 0; CmdExt.pTxPayload = (_u8*)pFileName; CmdExt.pRxPayload = NULL; diff --git a/hardware/lm4f/libraries/WiFi/utility/fs.h b/hardware/lm4f/libraries/WiFi/utility/fs.h index 2c47a56bb81..02232999547 100644 --- a/hardware/lm4f/libraries/WiFi/utility/fs.h +++ b/hardware/lm4f/libraries/WiFi/utility/fs.h @@ -1,35 +1,35 @@ /* * fs.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -39,7 +39,7 @@ /*****************************************************************************/ #include "simplelink.h" - + #ifndef __FS_H__ #define __FS_H__ @@ -154,7 +154,7 @@ extern "C" { /* Open for Write (in case file exist) */ #define FS_MODE_OPEN_WRITE _FS_MODE(_FS_MODE_OPEN_WRITE,0,0,0) /* Open for Creating a new file */ -#define FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) _sl_GetCreateFsMode(maxSizeInBytes,accessModeFlags) +#define FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) _sl_GetCreateFsMode(maxSizeInBytes,accessModeFlags) /*****************************************************************************/ /* Structure/Enum declarations */ @@ -207,12 +207,12 @@ _u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags); /*! \brief open file for read or write from/to storage device - - \param[in] pFileName File Name buffer pointer + + \param[in] pFileName File Name buffer pointer \param[in] AccessModeAndMaxSize Options: As described below \param[in] pToken Reserved for future use. Use NULL for this field - \param[out] pFileHandle Pointing on the file and used for read and write commands to the file - + \param[out] pFileHandle Pointing on the file and used for read and write commands to the file + AccessModeAndMaxSize possible input \n FS_MODE_OPEN_READ - Read a file \n FS_MODE_OPEN_WRITE - Open for write for an existing file \n @@ -220,11 +220,11 @@ _u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags); For optimal FS size, use max size in 4K-512 bytes steps (e.g. 3584,7680,117760) \n Several access modes bits can be combined together from SlFileOpenFlags_e enum - \return On success, zero is returned. On error, an error code is returned - - \sa sl_FsRead sl_FsWrite sl_FsClose - \note belongs to \ref basic_api - \warning + \return On success, zero is returned. On error, an error code is returned + + \sa sl_FsRead sl_FsWrite sl_FsClose + \note belongs to \ref basic_api + \warning \par Example: \code char* DeviceFileName = "MyFile.txt"; @@ -263,20 +263,20 @@ _i32 sl_FsOpen(const _u8 *pFileName,const _u32 AccessModeAndMaxSize,_u32 *pToken /*! \brief close file in storage device - - \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen) + + \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen) \param[in] pCeritificateFileName Reserved for future use. Use NULL. \param[in] pSignature Reserved for future use. Use NULL. \param[in] SignatureLen Reserved for future use. Use 0. - - \return On success, zero is returned. On error, an error code is returned - - \sa sl_FsRead sl_FsWrite sl_FsOpen + + \return On success, zero is returned. On error, an error code is returned + + \sa sl_FsRead sl_FsWrite sl_FsOpen \note Call the fs_Close with signature = 'A' signature len = 1 for activating an abort action \warning \par Example: - \code + \code sl_FsClose(FileHandle,0,0,0); \endcode */ @@ -286,19 +286,19 @@ _i16 sl_FsClose(const _i32 FileHdl,const _u8* pCeritificateFileName,const _u8* p /*! \brief Read block of data from a file in storage device - - \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen) + + \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen) \param[in] Offset Offset to specific read block \param[out] pData Pointer for the received data \param[in] Len Length of the received data - - \return On success, returns the number of read bytes. On error, negative number is returned - - \sa sl_FsClose sl_FsWrite sl_FsOpen - \note belongs to \ref basic_api - \warning + + \return On success, returns the number of read bytes. On error, negative number is returned + + \sa sl_FsClose sl_FsWrite sl_FsOpen + \note belongs to \ref basic_api + \warning \par Example: - \code + \code Status = sl_FsRead(FileHandle, 0, &readBuff[0], readSize); \endcode */ @@ -308,19 +308,19 @@ _i32 sl_FsRead(const _i32 FileHdl,_u32 Offset ,_u8* pData,_u32 Len); /*! \brief write block of data to a file in storage device - - \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen) + + \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen) \param[in] Offset Offset to specific block to be written \param[in] pData Pointer the transmitted data to the storage device \param[in] Len Length of the transmitted data - + \return On success, returns the number of written bytes. On error, an error code is returned - - \sa - \note belongs to \ref basic_api - \warning + + \sa + \note belongs to \ref basic_api + \warning \par Example: - \code + \code Status = sl_FsWrite(FileHandle, 0, &buff[0], readSize); \endcode */ @@ -330,18 +330,18 @@ _i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset,_u8* pData,_u32 Len); /*! \brief get info on a file - + \param[in] pFileName File name \param[in] Token Reserved for future use. Use 0 - \param[out] pFsFileInfo Returns the File's Information: flags,file size, allocated size and Tokens - - \return On success, zero is returned. On error, an error code is returned - - \sa sl_FsOpen - \note belongs to \ref basic_api - \warning + \param[out] pFsFileInfo Returns the File's Information: flags,file size, allocated size and Tokens + + \return On success, zero is returned. On error, an error code is returned + + \sa sl_FsOpen + \note belongs to \ref basic_api + \warning \par Example: - \code + \code Status = sl_FsGetInfo("FileName.html",0,&FsFileInfo); \endcode */ @@ -351,16 +351,16 @@ _i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileI /*! \brief Delete specific file from a storage or all files from a storage (format) - - \param[in] pFileName File Name + + \param[in] pFileName File Name \param[in] Token Reserved for future use. Use 0 - \return On success, zero is returned. On error, an error code is returned - - \sa - \note belongs to \ref basic_api - \warning + \return On success, zero is returned. On error, an error code is returned + + \sa + \note belongs to \ref basic_api + \warning \par Example: - \code + \code Status = sl_FsDel("FileName.html",0); \endcode */ diff --git a/hardware/lm4f/libraries/WiFi/utility/netapp.c b/hardware/lm4f/libraries/WiFi/utility/netapp.c index 48ec036f372..1de32dacee1 100644 --- a/hardware/lm4f/libraries/WiFi/utility/netapp.c +++ b/hardware/lm4f/libraries/WiFi/utility/netapp.c @@ -1,39 +1,39 @@ /* * netapp.c - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + /*****************************************************************************/ @@ -46,7 +46,7 @@ /*****************************************************************************/ /* Macro declarations */ /*****************************************************************************/ -#define NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT ((_u32)0x1 << 31) +#define NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT ((_u32)0x1 << 31) #ifdef SL_TINY #define NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH 63 @@ -58,45 +58,50 @@ /*****************************************************************************/ /* Functions prototypes */ /*****************************************************************************/ -void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf); +_SlReturnVal_t _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf); #ifndef SL_TINY_EXT -void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf); -void _sl_HandleAsync_PingResponse(void *pVoidBuf); +_SlReturnVal_t _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf); +_SlReturnVal_t _sl_HandleAsync_PingResponse(void *pVoidBuf); #endif -void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport); -_i16 sl_NetAppMDNSRegisterUnregisterService(const _i8* pServiceName, - const _u8 ServiceNameLen, - const _i8* pText, - const _u8 TextLen, - const _u16 Port, - const _u32 TTL, - const _u32 Options); +static void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport); +_i16 sl_NetAppMDNSRegisterUnregisterService(const _i8* pServiceName, + const _u8 ServiceNameLen, + const _i8* pText, + const _u8 TextLen, + const _u16 Port, + const _u32 TTL, + const _u32 Options); #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) _u16 _sl_NetAppSendTokenValue(slHttpServerData_t * Token); #endif typedef union { - _NetAppStartStopCommand_t Cmd; - _NetAppStartStopResponse_t Rsp; + _NetAppStartStopCommand_t Cmd; + _NetAppStartStopResponse_t Rsp; }_SlNetAppStartStopMsg_u; #if _SL_INCLUDE_FUNC(sl_NetAppStart) -const _SlCmdCtrl_t _SlNetAppStartCtrl = +static const _SlCmdCtrl_t _SlNetAppStartCtrl = + { SL_OPCODE_NETAPP_START_COMMAND, - sizeof(_NetAppStartStopCommand_t), - sizeof(_NetAppStartStopResponse_t) + (_SlArgSize_t)sizeof(_NetAppStartStopCommand_t), + (_SlArgSize_t)sizeof(_NetAppStartStopResponse_t) }; _i16 sl_NetAppStart(const _u32 AppBitMap) { _SlNetAppStartStopMsg_u Msg; Msg.Cmd.appId = AppBitMap; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStartCtrl, &Msg, NULL)); return Msg.Rsp.status; @@ -109,11 +114,11 @@ _i16 sl_NetAppStart(const _u32 AppBitMap) #if _SL_INCLUDE_FUNC(sl_NetAppStop) -const _SlCmdCtrl_t _SlNetAppStopCtrl = +static const _SlCmdCtrl_t _SlNetAppStopCtrl = { SL_OPCODE_NETAPP_STOP_COMMAND, - sizeof(_NetAppStartStopCommand_t), - sizeof(_NetAppStartStopResponse_t) + (_SlArgSize_t)sizeof(_NetAppStartStopCommand_t), + (_SlArgSize_t)sizeof(_NetAppStartStopResponse_t) }; @@ -121,6 +126,10 @@ const _SlCmdCtrl_t _SlNetAppStopCtrl = _i16 sl_NetAppStop(const _u32 AppBitMap) { _SlNetAppStartStopMsg_u Msg; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); Msg.Cmd.appId = AppBitMap; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStopCtrl, &Msg, NULL)); @@ -142,36 +151,40 @@ typedef struct typedef union { - NetappGetServiceListCMD_t Cmd; - _BasicResponse_t Rsp; + NetappGetServiceListCMD_t Cmd; + _BasicResponse_t Rsp; }_SlNetappGetServiceListMsg_u; #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList) -const _SlCmdCtrl_t _SlGetServiceListeCtrl = +static const _SlCmdCtrl_t _SlGetServiceListeCtrl = { SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE, - sizeof(NetappGetServiceListCMD_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(NetappGetServiceListCMD_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i16 sl_NetAppGetServiceList(const _u8 IndexOffest, - const _u8 MaxServiceCount, - const _u8 Flags, - _i8 *pBuffer, - const _u32 RxBufferLength - ) + const _u8 MaxServiceCount, + const _u8 Flags, + _i8 *pBuffer, + const _u32 RxBufferLength + ) { - _i32 retVal= 0; + _i32 retVal= 0; _SlNetappGetServiceListMsg_u Msg; _SlCmdExt_t CmdExt; - _u16 ServiceSize = 0; - _u16 BufferSize = 0; + _u16 ServiceSize = 0; + _u16 BufferSize = 0; - /* - Calculate RX pBuffer size + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + /* + Calculate RX pBuffer size WARNING: if this size is BufferSize than 1480 error should be returned because there is no place in the RX packet. @@ -179,41 +192,41 @@ _i16 sl_NetAppGetServiceList(const _u8 IndexOffest, switch(Flags) { case SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE: - ServiceSize = sizeof(SlNetAppGetFullServiceWithTextIpv4List_t); + ServiceSize = (_u16)sizeof(SlNetAppGetFullServiceWithTextIpv4List_t); break; case SL_NET_APP_FULL_SERVICE_IPV4_TYPE: - ServiceSize = sizeof(SlNetAppGetFullServiceIpv4List_t); + ServiceSize = (_u16)sizeof(SlNetAppGetFullServiceIpv4List_t); break; case SL_NET_APP_SHORT_SERVICE_IPV4_TYPE: - ServiceSize = sizeof(SlNetAppGetShortServiceIpv4List_t); + ServiceSize = (_u16)sizeof(SlNetAppGetShortServiceIpv4List_t); break; default: - ServiceSize = sizeof(_BasicResponse_t); - break; + ServiceSize = (_u16)sizeof(_BasicResponse_t); + break; } - BufferSize = MaxServiceCount * ServiceSize; + BufferSize = MaxServiceCount * ServiceSize; - /*Check the size of the requested services is smaller than size of the user buffer. - If not an error is returned in order to avoid overwriting memory. */ - if(RxBufferLength <= BufferSize) - { - return SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR; - } + /*Check the size of the requested services is smaller than size of the user buffer. + If not an error is returned in order to avoid overwriting memory. */ + if(RxBufferLength <= BufferSize) + { + return SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR; + } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = BufferSize; - CmdExt.pRxPayload = (_u8 *)pBuffer; + CmdExt.RxPayloadLen = (_i16)BufferSize; + CmdExt.pRxPayload = (_u8 *)pBuffer; - Msg.Cmd.IndexOffest = IndexOffest; + Msg.Cmd.IndexOffest = IndexOffest; Msg.Cmd.MaxServiceCount = MaxServiceCount; - Msg.Cmd.Flags = Flags; - Msg.Cmd.Padding = 0; + Msg.Cmd.Flags = Flags; + Msg.Cmd.Padding = 0; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetServiceListeCtrl, &Msg, &CmdExt)); retVal = Msg.Rsp.status; @@ -235,7 +248,7 @@ _i16 sl_NetAppGetServiceList(const _u8 IndexOffest, 4. TTL - The TTL of the service 5. Options - bitwise parameters: bit 0 - is unique (means if the service needs to be unique) - bit 31 - for internal use if the service should be added or deleted (set means ADD). + bit 31 - for internal use if the service should be added or deleted (set means ADD). bit 1-30 for future. NOTE: @@ -257,18 +270,18 @@ typedef struct typedef union { - NetappMdnsSetService_t Cmd; - _BasicResponse_t Rsp; + NetappMdnsSetService_t Cmd; + _BasicResponse_t Rsp; }_SlNetappMdnsRegisterServiceMsg_u; #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterUnregisterService) -const _SlCmdCtrl_t _SlRegisterServiceCtrl = +static const _SlCmdCtrl_t _SlRegisterServiceCtrl = { SL_OPCODE_NETAPP_MDNSREGISTERSERVICE, - sizeof(NetappMdnsSetService_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(NetappMdnsSetService_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; /****************************************************************************** @@ -280,16 +293,16 @@ const _SlCmdCtrl_t _SlRegisterServiceCtrl = DESCRIPTION: Add/delete service - The function manipulates the command that register the service and call - to the NWP in order to add/delete the service to/from the mDNS package and to/from the DB. - - This register service is a service offered by the application. - This unregister service is a service offered by the application before. - - The service name should be full service name according to RFC + The function manipulates the command that register the service and call + to the NWP in order to add/delete the service to/from the mDNS package and to/from the DB. + + This register service is a service offered by the application. + This unregister service is a service offered by the application before. + + The service name should be full service name according to RFC of the DNS-SD - means the value in name field in SRV answer. - - Example for service name: + + Example for service name: 1. PC1._ipp._tcp.local 2. PC2_server._ftp._tcp.local @@ -297,14 +310,14 @@ const _SlCmdCtrl_t _SlRegisterServiceCtrl = it is unique before starting to announce the service on the network. Instance is the instance portion of the service name. - + PARAMETERS: The command is from constant parameters and variables parameters. - Constant parameters are: + Constant parameters are: ServiceLen - The length of the service. TextLen - The length of the service should be smaller than 64. @@ -326,151 +339,158 @@ const _SlCmdCtrl_t _SlRegisterServiceCtrl = should be as mentioned in the RFC (according to type of the service IPP,FTP...) - NOTE - pay attention + NOTE - pay attention - 1. Temporary - there is an allocation on stack of internal buffer. - Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. - It means that the sum of the text length and service name length cannot be bigger than - NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. - If it is - An error is returned. + 1. Temporary - there is an allocation on stack of internal buffer. + Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. + It means that the sum of the text length and service name length cannot be bigger than + NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. + If it is - An error is returned. - 2. According to now from certain constraints the variables parameters are set in the - attribute part (contain constant parameters) + 2. According to now from certain constraints the variables parameters are set in the + attribute part (contain constant parameters) - RETURNS: Status - the immediate response of the command status. - 0 means success. + RETURNS: Status - the immediate response of the command status. + 0 means success. ******************************************************************************/ -_i16 sl_NetAppMDNSRegisterUnregisterService( const _i8* pServiceName, - const _u8 ServiceNameLen, - const _i8* pText, - const _u8 TextLen, - const _u16 Port, - const _u32 TTL, - const _u32 Options) +_i16 sl_NetAppMDNSRegisterUnregisterService( const _i8* pServiceName, + const _u8 ServiceNameLen, + const _i8* pText, + const _u8 TextLen, + const _u16 Port, + const _u32 TTL, + const _u32 Options) { - _SlNetappMdnsRegisterServiceMsg_u Msg; - _SlCmdExt_t CmdExt ; - _i8 ServiceNameAndTextBuffer[NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH]; - _i8 *TextPtr; - - /* - - NOTE - pay attention - - 1. Temporary - there is an allocation on stack of internal buffer. - Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. - It means that the sum of the text length and service name length cannot be bigger than - NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. - If it is - An error is returned. - - 2. According to now from certain constraints the variables parameters are set in the - attribute part (contain constant parameters) - - - */ - - /*build the attribute part of the command. - It contains the constant parameters of the command*/ - - Msg.Cmd.ServiceNameLen = ServiceNameLen; - Msg.Cmd.Options = Options; - Msg.Cmd.Port = Port; - Msg.Cmd.TextLen = TextLen; - Msg.Cmd.TTL = TTL; - - /*Build the payload part of the command - Copy the service name and text to one buffer. - NOTE - pay attention - The size of the service length + the text length should be smaller than 255, - Until the simplelink drive supports to variable length through SPI command. */ - if(TextLen + ServiceNameLen > (NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH - 1 )) /*-1 is for giving a place to set null termination at the end of the text*/ - { - return -1; - } - - _SlDrvMemZero(ServiceNameAndTextBuffer, NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH); - - - /*Copy the service name*/ - sl_Memcpy(ServiceNameAndTextBuffer, - pServiceName, - ServiceNameLen); - - if(TextLen > 0 ) - { - - TextPtr = &ServiceNameAndTextBuffer[ServiceNameLen]; - /*Copy the text just after the service name*/ - sl_Memcpy(TextPtr, - pText, - TextLen); - - - } + _SlNetappMdnsRegisterServiceMsg_u Msg; + _SlCmdExt_t CmdExt ; + _i8 ServiceNameAndTextBuffer[NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH]; + _i8 *TextPtr; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + /* + + NOTE - pay attention + + 1. Temporary - there is an allocation on stack of internal buffer. + Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. + It means that the sum of the text length and service name length cannot be bigger than + NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. + If it is - An error is returned. + + 2. According to now from certain constraints the variables parameters are set in the + attribute part (contain constant parameters) + + + */ + + /*build the attribute part of the command. + It contains the constant parameters of the command*/ + + Msg.Cmd.ServiceNameLen = ServiceNameLen; + Msg.Cmd.Options = Options; + Msg.Cmd.Port = Port; + Msg.Cmd.TextLen = TextLen; + Msg.Cmd.TTL = TTL; + + /*Build the payload part of the command + Copy the service name and text to one buffer. + NOTE - pay attention + The size of the service length + the text length should be smaller than 255, + Until the simplelink drive supports to variable length through SPI command. */ + if(TextLen + ServiceNameLen > (NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH - 1 )) /*-1 is for giving a place to set null termination at the end of the text*/ + { + return -1; + } + + _SlDrvMemZero(ServiceNameAndTextBuffer, (_u16)NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH); + + + /*Copy the service name*/ + sl_Memcpy(ServiceNameAndTextBuffer, + pServiceName, + ServiceNameLen); + + if(TextLen > 0 ) + { + + TextPtr = &ServiceNameAndTextBuffer[ServiceNameLen]; + /*Copy the text just after the service name*/ + sl_Memcpy(TextPtr, + pText, + TextLen); + + + } _SlDrvResetCmdExt(&CmdExt); CmdExt.TxPayloadLen = (TextLen + ServiceNameLen); CmdExt.pTxPayload = (_u8 *)ServiceNameAndTextBuffer; - - VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRegisterServiceCtrl, &Msg, &CmdExt)); - return (_i16)Msg.Rsp.status; + VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRegisterServiceCtrl, &Msg, &CmdExt)); + + return (_i16)Msg.Rsp.status; + - } #endif /**********************************************************************************************/ #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService) -_i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, - const _u8 ServiceNameLen, - const _i8* pText, - const _u8 TextLen, - const _u16 Port, - const _u32 TTL, - _u32 Options) +_i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, + const _u8 ServiceNameLen, + const _i8* pText, + const _u8 TextLen, + const _u16 Port, + const _u32 TTL, + _u32 Options) { - /* + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); - NOTE - pay attention + /* - 1. Temporary - there is an allocation on stack of internal buffer. - Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. - It means that the sum of the text length and service name length cannot be bigger than - NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. - If it is - An error is returned. + NOTE - pay attention - 2. According to now from certain constraints the variables parameters are set in the - attribute part (contain constant parameters) + 1. Temporary - there is an allocation on stack of internal buffer. + Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. + It means that the sum of the text length and service name length cannot be bigger than + NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. + If it is - An error is returned. - */ + 2. According to now from certain constraints the variables parameters are set in the + attribute part (contain constant parameters) - /*Set the add service bit in the options parameter. - In order not use different opcodes for the register service and unregister service - bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added - if it is cleared it means that the service should be deleted and there is only meaning to pServiceName - and ServiceNameLen values. */ - Options |= NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT; + */ + + /*Set the add service bit in the options parameter. + In order not use different opcodes for the register service and unregister service + bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added + if it is cleared it means that the service should be deleted and there is only meaning to pServiceName + and ServiceNameLen values. */ + Options |= NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT; + + return sl_NetAppMDNSRegisterUnregisterService( pServiceName, + ServiceNameLen, + pText, + TextLen, + Port, + TTL, + Options); - return sl_NetAppMDNSRegisterUnregisterService( pServiceName, - ServiceNameLen, - pText, - TextLen, - Port, - TTL, - Options); - } #endif /**********************************************************************************************/ @@ -480,40 +500,44 @@ _i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, /**********************************************************************************************/ #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService) -_i16 sl_NetAppMDNSUnRegisterService( const _i8* pServiceName, - const _u8 ServiceNameLen) +_i16 sl_NetAppMDNSUnRegisterService( const _i8* pServiceName, + const _u8 ServiceNameLen) { _u32 Options = 0; - /* - - NOTE - pay attention + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + /* + + NOTE - pay attention + + The size of the service length should be smaller than 255, + Until the simplelink drive supports to variable length through SPI command. - The size of the service length should be smaller than 255, - Until the simplelink drive supports to variable length through SPI command. + */ - */ + /*Clear the add service bit in the options parameter. + In order not use different opcodes for the register service and unregister service + bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added + if it is cleared it means that the service should be deleted and there is only meaning to pServiceName + and ServiceNameLen values.*/ - /*Clear the add service bit in the options parameter. - In order not use different opcodes for the register service and unregister service - bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added - if it is cleared it means that the service should be deleted and there is only meaning to pServiceName - and ServiceNameLen values.*/ - - Options &= (~NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT); + Options &= (~NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT); + + return sl_NetAppMDNSRegisterUnregisterService( pServiceName, + ServiceNameLen, + NULL, + 0, + 0, + 0, + Options); - return sl_NetAppMDNSRegisterUnregisterService( pServiceName, - ServiceNameLen, - NULL, - 0, - 0, - 0, - Options); - } #endif /**********************************************************************************************/ @@ -531,11 +555,11 @@ _i16 sl_NetAppMDNSUnRegisterService( const _i8* pServiceName, * */ -typedef struct +typedef struct { - _u8 ServiceLen; - _u8 AddrLen; - _u16 Padding; + _u8 ServiceLen; + _u8 AddrLen; + _u16 Padding; }_GetHostByServiceCommand_t; @@ -544,32 +568,32 @@ typedef struct * The below structure depict the constant parameters that are returned in the Async event answer * according to command/API sl_DnsGetHostByService for IPv4 and IPv6. * - 1Status - The status of the response. - 2.Address - Contains the IP address of the service. - 3.Port - Contains the port of the service. - 4.TextLen - Contains the max length of the text that the user wants to get. - it means that if the test of service is bigger that its value than - the text is cut to inout_TextLen value. - Output: Contain the length of the text that is returned. Can be full text or part - of the text (see above). - + 1Status - The status of the response. + 2.Address - Contains the IP address of the service. + 3.Port - Contains the port of the service. + 4.TextLen - Contains the max length of the text that the user wants to get. + it means that if the test of service is bigger that its value than + the text is cut to inout_TextLen value. + Output: Contain the length of the text that is returned. Can be full text or part + of the text (see above). + * */ -typedef struct +typedef struct { - _u16 Status; - _u16 TextLen; - _u32 Port; - _u32 Address; + _u16 Status; + _u16 TextLen; + _u32 Port; + _u32 Address; }_GetHostByServiceIPv4AsyncResponse_t; -typedef struct +typedef struct { - _u16 Status; - _u16 TextLen; - _u32 Port; - _u32 Address[4]; + _u16 Status; + _u16 TextLen; + _u32 Port; + _u32 Address[4]; }_GetHostByServiceIPv6AsyncResponse_t; @@ -580,89 +604,93 @@ typedef union }_GetHostByServiceAsyncResponseAttribute_u; /* - * The below struct contains pointers to the output parameters that the user gives + * The below struct contains pointers to the output parameters that the user gives * */ typedef struct { _i16 Status; - _u32 *out_pAddr; - _u32 *out_pPort; - _u16 *inout_TextLen; /* in: max len , out: actual len */ + _u32 *out_pAddr; + _u32 *out_pPort; + _u16 *inout_TextLen; /* in: max len , out: actual len */ _i8 *out_pText; }_GetHostByServiceAsyncResponse_t; typedef union { - _GetHostByServiceCommand_t Cmd; - _BasicResponse_t Rsp; + _GetHostByServiceCommand_t Cmd; + _BasicResponse_t Rsp; }_SlGetHostByServiceMsg_u; #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService) -const _SlCmdCtrl_t _SlGetHostByServiceCtrl = +static const _SlCmdCtrl_t _SlGetHostByServiceCtrl = { SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICE, - sizeof(_GetHostByServiceCommand_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_GetHostByServiceCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; /******************************************************************************/ -_i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */ - const _u8 ServiceLen, - const _u8 Family, /* 4-IPv4 , 16-IPv6 */ - _u32 pAddr[], - _u32 *pPort, - _u16 *pTextLen, /* in: max len , out: actual len */ - _i8 *pText - ) +_i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */ + const _u8 ServiceLen, + const _u8 Family, /* 4-IPv4 , 16-IPv6 */ + _u32 pAddr[], + _u32 *pPort, + _u16 *pTextLen, /* in: max len , out: actual len */ + _i8 *pText + ) { _SlGetHostByServiceMsg_u Msg; _SlCmdExt_t CmdExt ; _GetHostByServiceAsyncResponse_t AsyncRsp; - _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); /* - Note: - 1. The return's attributes are belonged to first service that is found. - It can be other services with the same service name will response to - the query. The results of these responses are saved in the peer cache of the NWP, and - should be read by another API. + Note: + 1. The return's attributes are belonged to first service that is found. + It can be other services with the same service name will response to + the query. The results of these responses are saved in the peer cache of the NWP, and + should be read by another API. - 2. Text length can be 120 bytes only - not more - It is because of constraints in the NWP on the buffer that is allocated for the Async event. + 2. Text length can be 120 bytes only - not more + It is because of constraints in the NWP on the buffer that is allocated for the Async event. - 3.The API waits to Async event by blocking. It means that the API is finished only after an Async event - is sent by the NWP. + 3.The API waits to Async event by blocking. It means that the API is finished only after an Async event + is sent by the NWP. + + 4.No rolling option!!! - only PTR type is sent. - 4.No rolling option!!! - only PTR type is sent. - */ - /*build the attribute part of the command. - It contains the constant parameters of the command */ + /*build the attribute part of the command. + It contains the constant parameters of the command */ - Msg.Cmd.ServiceLen = ServiceLen; - Msg.Cmd.AddrLen = Family; + Msg.Cmd.ServiceLen = ServiceLen; + Msg.Cmd.AddrLen = Family; - /*Build the payload part of the command - Copy the service name and text to one buffer.*/ + /*Build the payload part of the command + Copy the service name and text to one buffer.*/ _SlDrvResetCmdExt(&CmdExt); - CmdExt.TxPayloadLen = ServiceLen; + CmdExt.TxPayloadLen = ServiceLen; CmdExt.pTxPayload = (_u8 *)pServiceName; - /*set pointers to the output parameters (the returned parameters). - This pointers are belonged to local struct that is set to global Async response parameter. - It is done in order not to run more than one sl_DnsGetHostByService at the same time. - The API should be run only if global parameter is pointed to NULL. */ - AsyncRsp.out_pText = pText; - AsyncRsp.inout_TextLen = (_u16* )pTextLen; - AsyncRsp.out_pPort = pPort; - AsyncRsp.out_pAddr = (_u32 *)pAddr; + /*set pointers to the output parameters (the returned parameters). + This pointers are belonged to local struct that is set to global Async response parameter. + It is done in order not to run more than one sl_DnsGetHostByService at the same time. + The API should be run only if global parameter is pointed to NULL. */ + AsyncRsp.out_pText = pText; + AsyncRsp.inout_TextLen = (_u16* )pTextLen; + AsyncRsp.out_pPort = pPort; + AsyncRsp.out_pAddr = (_u32 *)pAddr; ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, GETHOSYBYSERVICE_ID, SL_MAX_SOCKETS); @@ -672,25 +700,25 @@ _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all return SL_POOL_IS_EMPTY; } - - if (SL_AF_INET6 == Family) - { - g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK; - } + + if (SL_AF_INET6 == Family) + { + g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK; + } /* Send the command */ - VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByServiceCtrl, &Msg, &CmdExt)); + VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByServiceCtrl, &Msg, &CmdExt)); + + - - /* If the immediate reponse is O.K. than wait for aSYNC event response. */ - if(SL_RET_CODE_OK == Msg.Rsp.status) - { - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); - - /* If we are - it means that Async event was sent. - The results are copied in the Async handle return functions */ - - Msg.Rsp.status = AsyncRsp.Status; + if(SL_RET_CODE_OK == Msg.Rsp.status) + { + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj); + + /* If we are - it means that Async event was sent. + The results are copied in the Async handle return functions */ + + Msg.Rsp.status = AsyncRsp.Status; } _SlDrvReleasePoolObj(ObjIdx); @@ -706,45 +734,45 @@ _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all CALLER NWP - Async event on sl_DnsGetHostByService with IPv4 Family - DESCRIPTION: - - Async event on sl_DnsGetHostByService command with IPv4 Family. - Return service attributes like IP address, port and text according to service name. - The user sets a service name Full/Part (see example below), and should get the: - 1. IP of the service - 2. The port of service. - 3. The text of service. + DESCRIPTION: + + Async event on sl_DnsGetHostByService command with IPv4 Family. + Return service attributes like IP address, port and text according to service name. + The user sets a service name Full/Part (see example below), and should get the: + 1. IP of the service + 2. The port of service. + 3. The text of service. + + Hence it can make a connection to the specific service and use it. + It is similar to get host by name method. - Hence it can make a connection to the specific service and use it. - It is similar to get host by name method. + It is done by a single shot query with PTR type on the service name. - It is done by a single shot query with PTR type on the service name. + Note: + 1. The return's attributes are belonged to first service that is found. + It can be other services with the same service name will response to + the query. The results of these responses are saved in the peer cache of the NWP, and + should be read by another API. - Note: - 1. The return's attributes are belonged to first service that is found. - It can be other services with the same service name will response to - the query. The results of these responses are saved in the peer cache of the NWP, and - should be read by another API. - - PARAMETERS: + PARAMETERS: pVoidBuf - is point to opcode of the event. - it contains the outputs that are given to the user + it contains the outputs that are given to the user + + outputs description: - outputs description: + 1.out_pAddr[] - output: Contain the IP address of the service. + 2.out_pPort - output: Contain the port of the service. + 3.inout_TextLen - Input: Contain the max length of the text that the user wants to get. + it means that if the test of service is bigger that its value than + the text is cut to inout_TextLen value. + Output: Contain the length of the text that is returned. Can be full text or part + of the text (see above). - 1.out_pAddr[] - output: Contain the IP address of the service. - 2.out_pPort - output: Contain the port of the service. - 3.inout_TextLen - Input: Contain the max length of the text that the user wants to get. - it means that if the test of service is bigger that its value than - the text is cut to inout_TextLen value. - Output: Contain the length of the text that is returned. Can be full text or part - of the text (see above). - - 4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description). + 4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description). * @@ -757,79 +785,81 @@ _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all ******************************************************************************/ #ifndef SL_TINY_EXT -void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf) { - _GetHostByServiceAsyncResponse_t* Res; - _u16 TextLen; - _u16 UserTextLen; + _GetHostByServiceAsyncResponse_t* Res; + _u16 TextLen; + _u16 UserTextLen; - /*pVoidBuf - is point to opcode of the event.*/ - - /*set pMsgArgs to point to the attribute of the event.*/ - _GetHostByServiceIPv4AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); + /*pVoidBuf - is point to opcode of the event.*/ + + /*set pMsgArgs to point to the attribute of the event.*/ + _GetHostByServiceIPv4AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); - /*IPv6*/ - if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) - { - return; - } - /*IPv4*/ - else - { + /*IPv6*/ + if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) + { + return SL_RET_CODE_OK; + } + /*IPv4*/ + else + { /************************************************************************************************* - - 1. Copy the attribute part of the evnt to the attribute part of the response - sl_Memcpy(g_pCB->GetHostByServiceCB.pAsyncRsp, pMsgArgs, sizeof(_GetHostByServiceIPv4AsyncResponse_t)); + + 1. Copy the attribute part of the evnt to the attribute part of the response + sl_Memcpy(g_pCB->GetHostByServiceCB.pAsyncRsp, pMsgArgs, sizeof(_GetHostByServiceIPv4AsyncResponse_t)); set to TextLen the text length of the service.*/ - TextLen = pMsgArgs->TextLen; - - /*Res pointed to mDNS global object struct */ - Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs; + TextLen = pMsgArgs->TextLen; + + /*Res pointed to mDNS global object struct */ + Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs; - /*It is 4 bytes so we avoid from memcpy*/ - Res->out_pAddr[0] = pMsgArgs->Address; - Res->out_pPort[0] = pMsgArgs->Port; - Res->Status = pMsgArgs->Status; - - /*set to TextLen the text length of the user (input fromthe user).*/ - UserTextLen = Res->inout_TextLen[0]; - - /*Cut the service text if the user requested for smaller text.*/ - UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen; - Res->inout_TextLen[0] = UserTextLen ; + /*It is 4 bytes so we avoid from memcpy*/ + Res->out_pAddr[0] = pMsgArgs->Address; + Res->out_pPort[0] = pMsgArgs->Port; + Res->Status = (_i16)pMsgArgs->Status; + + /*set to TextLen the text length of the user (input fromthe user).*/ + UserTextLen = Res->inout_TextLen[0]; + + /*Cut the service text if the user requested for smaller text.*/ + UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen; + Res->inout_TextLen[0] = UserTextLen ; /************************************************************************************************** - 2. Copy the payload part of the evnt (the text) to the payload part of the response - the lenght of the copy is according to the text length in the attribute part. */ - + 2. Copy the payload part of the evnt (the text) to the payload part of the response + the lenght of the copy is according to the text length in the attribute part. */ + - sl_Memcpy(Res->out_pText , - (_i8 *)(& pMsgArgs[1]) , /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/ - UserTextLen ); + sl_Memcpy(Res->out_pText , + (_i8 *)(& pMsgArgs[1]) , /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/ + UserTextLen ); /**************************************************************************************************/ - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - return; - } + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + return SL_RET_CODE_OK; + } } /*****************************************************************************/ /* _sl_HandleAsync_DnsGetHostByAddr */ /*****************************************************************************/ -void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf) { SL_TRACE0(DBG_MSG, MSG_303, "STUB: _sl_HandleAsync_DnsGetHostByAddr not implemented yet!"); - return; + (void)pVoidBuf; + + return SL_RET_CODE_OK; } #endif @@ -844,17 +874,17 @@ typedef union typedef union { - _GetHostByNameCommand_t Cmd; - _BasicResponse_t Rsp; + _GetHostByNameCommand_t Cmd; + _BasicResponse_t Rsp; }_SlGetHostByNameMsg_u; #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName) -const _SlCmdCtrl_t _SlGetHostByNameCtrl = +static const _SlCmdCtrl_t _SlGetHostByNameCtrl = { SL_OPCODE_NETAPP_DNSGETHOSTBYNAME, - sizeof(_GetHostByNameCommand_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_GetHostByNameCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ip_addr,const _u8 family) @@ -862,8 +892,11 @@ _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ _SlGetHostByNameMsg_u Msg; _SlCmdExt_t ExtCtrl; _GetHostByNameAsyncResponse_u AsyncRsp; - _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&ExtCtrl); ExtCtrl.TxPayloadLen = usNameLen; @@ -872,36 +905,36 @@ _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ Msg.Cmd.Len = usNameLen; Msg.Cmd.family = family; - /*Use Obj to issue the command, if not available try later */ - ObjIdx = (_u8)_SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS); - if (MAX_CONCURRENT_ACTIONS == ObjIdx) - { - return SL_POOL_IS_EMPTY; - } + /*Use Obj to issue the command, if not available try later */ + ObjIdx = (_u8)_SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS); + if (MAX_CONCURRENT_ACTIONS == ObjIdx) + { + return SL_POOL_IS_EMPTY; + } + + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); - _SlDrvProtectionObjLockWaitForever(); + g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp; + /*set bit to indicate IPv6 address is expected */ + if (SL_AF_INET6 == family) + { + g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK; + } - g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp; - /*set bit to indicate IPv6 address is expected */ - if (SL_AF_INET6 == family) - { - g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK; - } - - _SlDrvProtectionObjUnLock(); + SL_DRV_PROTECTION_OBJ_UNLOCK(); VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByNameCtrl, &Msg, &ExtCtrl)); if(SL_RET_CODE_OK == Msg.Rsp.status) { - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); - - Msg.Rsp.status = AsyncRsp.IpV4.status; + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj); + + Msg.Rsp.status = (_i16)AsyncRsp.IpV4.status; if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status) { sl_Memcpy((_i8 *)out_ip_addr, - (_i8 *)&AsyncRsp.IpV4.ip0, + (_i8 *)&AsyncRsp.IpV4.ip0, (SL_AF_INET == family) ? SL_IPV4_ADDRESS_SIZE : SL_IPV6_ADDRESS_SIZE); } } @@ -914,32 +947,34 @@ _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ /******************************************************************************/ /* _sl_HandleAsync_DnsGetHostByName */ /******************************************************************************/ -void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf) { _GetHostByNameIPv4AsyncResponse_t *pMsgArgs = (_GetHostByNameIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); - /*IPv6 */ - if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) - { - sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv6AsyncResponse_t)); - } - /*IPv4 */ - else - { - sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv4AsyncResponse_t)); - } - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - _SlDrvProtectionObjUnLock(); - return; + /*IPv6 */ + if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK) + { + sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv6AsyncResponse_t)); + } + /*IPv4 */ + else + { + sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv4AsyncResponse_t)); + } + + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + SL_DRV_PROTECTION_OBJ_UNLOCK(); + + return SL_RET_CODE_OK; } #ifndef SL_TINY_EXT -void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport) +static void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport) { pReport->PacketsSent = pResults->numSendsPings; pReport->PacketsReceived = pResults->numSuccsessPings; @@ -952,11 +987,11 @@ void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pRe /*****************************************************************************/ /* _sl_HandleAsync_PingResponse */ /*****************************************************************************/ -void _sl_HandleAsync_PingResponse(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_PingResponse(void *pVoidBuf) { _PingReportResponse_t *pMsgArgs = (_PingReportResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); SlPingReport_t pingReport; - + if(pPingCallBackFunc) { CopyPingResultsToReport(pMsgArgs,&pingReport); @@ -964,19 +999,20 @@ void _sl_HandleAsync_PingResponse(void *pVoidBuf) } else { - - _SlDrvProtectionObjLockWaitForever(); - + + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); + VERIFY_SOCKET_CB(NULL != g_pCB->PingCB.PingAsync.pAsyncRsp); - if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs) - { - sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_PingReportResponse_t)); - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - } - _SlDrvProtectionObjUnLock(); + if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs) + { + sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_PingReportResponse_t)); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + } + SL_DRV_PROTECTION_OBJ_UNLOCK(); } - return; + + return SL_RET_CODE_OK; } #endif @@ -985,8 +1021,8 @@ void _sl_HandleAsync_PingResponse(void *pVoidBuf) /*****************************************************************************/ typedef union { - _PingStartCommand_t Cmd; - _PingReportResponse_t Rsp; + _PingStartCommand_t Cmd; + _PingReportResponse_t Rsp; }_SlPingStartMsg_u; @@ -1000,14 +1036,18 @@ typedef enum #if _SL_INCLUDE_FUNC(sl_NetAppPingStart) _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback) { - _SlCmdCtrl_t CmdCtrl = {0, sizeof(_PingStartCommand_t), sizeof(_BasicResponse_t)}; + _SlCmdCtrl_t CmdCtrl = {0, (_SlArgSize_t)sizeof(_PingStartCommand_t), (_SlArgSize_t)sizeof(_BasicResponse_t)}; _SlPingStartMsg_u Msg; _PingReportResponse_t PingRsp; _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; - if( 0 == pPingParams->Ip ) + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + if( 0 == pPingParams->Ip ) {/* stop any ongoing ping */ - return _SlDrvBasicCmd(SL_OPCODE_NETAPP_PINGSTOP); + return _SlDrvBasicCmd(SL_OPCODE_NETAPP_PINGSTOP); } if(SL_AF_INET == family) @@ -1027,19 +1067,19 @@ _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family Msg.Cmd.totalNumberOfAttempts = pPingParams->TotalNumberOfAttempts; Msg.Cmd.flags = pPingParams->Flags; - + if( pPingCallback ) - { + { pPingCallBackFunc = pPingCallback; } else { /*Use Obj to issue the command, if not available try later */ - ObjIdx = (_u8)_SlDrvWaitForPoolObj(PING_ID,SL_MAX_SOCKETS); - if (MAX_CONCURRENT_ACTIONS == ObjIdx) - { - return SL_POOL_IS_EMPTY; - } + ObjIdx = (_u8)_SlDrvWaitForPoolObj(PING_ID,SL_MAX_SOCKETS); + if (MAX_CONCURRENT_ACTIONS == ObjIdx) + { + return SL_POOL_IS_EMPTY; + } OSI_RET_OK_CHECK(sl_LockObjLock(&g_pCB->ProtectionLockObj, SL_OS_WAIT_FOREVER)); /* async response handler for non callback mode */ g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&PingRsp; @@ -1047,15 +1087,22 @@ _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->ProtectionLockObj)); } - + VERIFY_RET_OK(_SlDrvCmdOp(&CmdCtrl, &Msg, NULL)); - /*send the command*/ + /*send the command*/ if(CMD_PING_TEST_RUNNING == (_i16)Msg.Rsp.status || CMD_PING_TEST_STOPPED == (_i16)Msg.Rsp.status ) { /* block waiting for results if no callback function is used */ if( NULL == pPingCallback ) { +#ifdef SL_TINY_EXT _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); +#else + SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj, + SL_DRIVER_TIMEOUT_LONG, + SL_DRIVER_API_NETAPP_PING_START + ); +#endif if( SL_OS_RET_CODE_OK == (_i16)PingRsp.status ) { @@ -1066,13 +1113,13 @@ _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family } else { /* ping failure, no async response */ - if( NULL == pPingCallback ) - { + if( NULL == pPingCallback ) + { _SlDrvReleasePoolObj(ObjIdx); } } - return Msg.Rsp.status; + return (_i16)Msg.Rsp.status; } #endif @@ -1088,11 +1135,11 @@ typedef union #if _SL_INCLUDE_FUNC(sl_NetAppSet) -const _SlCmdCtrl_t _SlNetAppSetCmdCtrl = +static const _SlCmdCtrl_t _SlNetAppSetCmdCtrl = { SL_OPCODE_NETAPP_NETAPPSET, - sizeof(_NetAppSetGet_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_NetAppSetGet_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u8 *pOptionValue) @@ -1100,15 +1147,18 @@ _i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _ _SlNetAppMsgSet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); - CmdExt.TxPayloadLen = (OptionLen+3) & (~3); + CmdExt.TxPayloadLen = (OptionLen+3) & (~3); CmdExt.pTxPayload = (_u8 *)pOptionValue; Msg.Cmd.AppId = AppId; Msg.Cmd.ConfigLen = OptionLen; - Msg.Cmd.ConfigOpt = Option; + Msg.Cmd.ConfigOpt = Option; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSetCmdCtrl, &Msg, &CmdExt)); @@ -1131,28 +1181,28 @@ typedef union const _SlCmdCtrl_t _SlNetAppSendTokenValueCmdCtrl = { SL_OPCODE_NETAPP_HTTPSENDTOKENVALUE, - sizeof(sl_NetAppHttpServerSendToken_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(sl_NetAppHttpServerSendToken_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _u16 _sl_NetAppSendTokenValue(slHttpServerData_t * Token_value) { - _SlNetAppMsgSendTokenValue_u Msg; - _SlCmdExt_t CmdExt; + _SlNetAppMsgSendTokenValue_u Msg; + _SlCmdExt_t CmdExt; - CmdExt.TxPayloadLen = (Token_value->value_len+3) & (~3); + CmdExt.TxPayloadLen = (Token_value->value_len+3) & (~3); CmdExt.RxPayloadLen = 0; - CmdExt.pTxPayload = (_u8 *) Token_value->token_value; + CmdExt.pTxPayload = (_u8 *) Token_value->token_value; CmdExt.pRxPayload = NULL; - Msg.Cmd.token_value_len = Token_value->value_len; - Msg.Cmd.token_name_len = Token_value->name_len; - sl_Memcpy(&Msg.Cmd.token_name[0], Token_value->token_name, Token_value->name_len); - + Msg.Cmd.token_value_len = Token_value->value_len; + Msg.Cmd.token_name_len = Token_value->name_len; + sl_Memcpy(&Msg.Cmd.token_name[0], Token_value->token_name, Token_value->name_len); + - VERIFY_RET_OK(_SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppSendTokenValueCmdCtrl, &Msg, &CmdExt)); + VERIFY_RET_OK(_SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppSendTokenValueCmdCtrl, &Msg, &CmdExt)); - return Msg.Rsp.status; + return Msg.Rsp.status; } #endif @@ -1162,17 +1212,17 @@ _u16 _sl_NetAppSendTokenValue(slHttpServerData_t * Token_value) /*****************************************************************************/ typedef union { - _NetAppSetGet_t Cmd; - _NetAppSetGet_t Rsp; + _NetAppSetGet_t Cmd; + _NetAppSetGet_t Rsp; }_SlNetAppMsgGet_u; #if _SL_INCLUDE_FUNC(sl_NetAppGet) -const _SlCmdCtrl_t _SlNetAppGetCmdCtrl = +static const _SlCmdCtrl_t _SlNetAppGetCmdCtrl = { SL_OPCODE_NETAPP_NETAPPGET, - sizeof(_NetAppSetGet_t), - sizeof(_NetAppSetGet_t) + (_SlArgSize_t)sizeof(_NetAppSetGet_t), + (_SlArgSize_t)sizeof(_NetAppSetGet_t) }; _i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue) @@ -1180,21 +1230,25 @@ _i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptio _SlNetAppMsgGet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (*pOptionLen == 0) { return SL_EZEROLEN; } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = *pOptionLen; + CmdExt.RxPayloadLen = (_i16)(*pOptionLen); CmdExt.pRxPayload = (_u8 *)pOptionValue; Msg.Cmd.AppId = AppId; Msg.Cmd.ConfigOpt = Option; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppGetCmdCtrl, &Msg, &CmdExt)); - - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { *pOptionLen = (_u8)CmdExt.RxPayloadLen; return SL_ESMALLBUF; @@ -1203,7 +1257,7 @@ _i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptio { *pOptionLen = (_u8)CmdExt.ActualRxPayloadLen; } - + return (_i16)Msg.Rsp.Status; } #endif @@ -1212,21 +1266,21 @@ _i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptio /*****************************************************************************/ /* _SlDrvNetAppEventHandler */ /*****************************************************************************/ -void _SlDrvNetAppEventHandler(void* pArgs) +_SlReturnVal_t _SlDrvNetAppEventHandler(void* pArgs) { _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs; #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) - SlHttpServerEvent_t httpServerEvent; - SlHttpServerResponse_t httpServerResponse; + SlHttpServerEvent_t httpServerEvent; + SlHttpServerResponse_t httpServerResponse; #endif - + switch(pHdr->GenHeader.Opcode) { case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE: case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6: _sl_HandleAsync_DnsGetHostByName(pArgs); break; -#ifndef SL_TINY_EXT +#ifndef SL_TINY_EXT case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE: case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6: _sl_HandleAsync_DnsGetHostByService(pArgs); @@ -1237,68 +1291,70 @@ void _SlDrvNetAppEventHandler(void* pArgs) #endif #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS) - case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE: - { - _u8 *pTokenName; - slHttpServerData_t Token_value; - sl_NetAppHttpServerGetToken_t *httpGetToken = (sl_NetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr); + case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE: + { + _u8 *pTokenName; + slHttpServerData_t Token_value; + sl_NetAppHttpServerGetToken_t *httpGetToken = (sl_NetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr); pTokenName = (_u8 *)((sl_NetAppHttpServerGetToken_t *)httpGetToken + 1); - httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE; - httpServerResponse.ResponseData.token_value.len = MAX_TOKEN_VALUE_LEN; + httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE; + httpServerResponse.ResponseData.token_value.len = MAX_TOKEN_VALUE_LEN; /* Reuse the async buffer for getting the token value response from the user */ - httpServerResponse.ResponseData.token_value.data = (_u8 *)_SL_RESP_ARGS_START(pHdr) + MAX_TOKEN_NAME_LEN; + httpServerResponse.ResponseData.token_value.data = (_u8 *)_SL_RESP_ARGS_START(pHdr) + MAX_TOKEN_NAME_LEN; httpServerEvent.Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT; - httpServerEvent.EventData.httpTokenName.len = httpGetToken->token_name_len; - httpServerEvent.EventData.httpTokenName.data = pTokenName; + httpServerEvent.EventData.httpTokenName.len = httpGetToken->token_name_len; + httpServerEvent.EventData.httpTokenName.data = pTokenName; - Token_value.token_name = pTokenName; + Token_value.token_name = pTokenName; - _SlDrvHandleHttpServerEvents (&httpServerEvent, &httpServerResponse); + _SlDrvDispatchHttpServerEvents (&httpServerEvent, &httpServerResponse); - Token_value.value_len = httpServerResponse.ResponseData.token_value.len; - Token_value.name_len = httpServerEvent.EventData.httpTokenName.len; - Token_value.token_value = httpServerResponse.ResponseData.token_value.data; - + Token_value.value_len = httpServerResponse.ResponseData.token_value.len; + Token_value.name_len = httpServerEvent.EventData.httpTokenName.len; + Token_value.token_value = httpServerResponse.ResponseData.token_value.data; - _sl_NetAppSendTokenValue(&Token_value); - } - break; - case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE: - { - _u8 *pPostParams; + _sl_NetAppSendTokenValue(&Token_value); + } + break; - sl_NetAppHttpServerPostToken_t *httpPostTokenArgs = (sl_NetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr); - pPostParams = (_u8 *)((sl_NetAppHttpServerPostToken_t *)httpPostTokenArgs + 1); + case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE: + { + _u8 *pPostParams; - httpServerEvent.Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT; + sl_NetAppHttpServerPostToken_t *httpPostTokenArgs = (sl_NetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr); + pPostParams = (_u8 *)((sl_NetAppHttpServerPostToken_t *)httpPostTokenArgs + 1); - httpServerEvent.EventData.httpPostData.action.len = httpPostTokenArgs->post_action_len; - httpServerEvent.EventData.httpPostData.action.data = pPostParams; - pPostParams+=httpPostTokenArgs->post_action_len; + httpServerEvent.Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT; - httpServerEvent.EventData.httpPostData.token_name.len = httpPostTokenArgs->token_name_len; - httpServerEvent.EventData.httpPostData.token_name.data = pPostParams; - pPostParams+=httpPostTokenArgs->token_name_len; + httpServerEvent.EventData.httpPostData.action.len = httpPostTokenArgs->post_action_len; + httpServerEvent.EventData.httpPostData.action.data = pPostParams; + pPostParams+=httpPostTokenArgs->post_action_len; - httpServerEvent.EventData.httpPostData.token_value.len = httpPostTokenArgs->token_value_len; - httpServerEvent.EventData.httpPostData.token_value.data = pPostParams; + httpServerEvent.EventData.httpPostData.token_name.len = httpPostTokenArgs->token_name_len; + httpServerEvent.EventData.httpPostData.token_name.data = pPostParams; + pPostParams+=httpPostTokenArgs->token_name_len; - httpServerResponse.Response = SL_NETAPP_RESPONSE_NONE; + httpServerEvent.EventData.httpPostData.token_value.len = httpPostTokenArgs->token_value_len; + httpServerEvent.EventData.httpPostData.token_value.data = pPostParams; - _SlDrvHandleHttpServerEvents (&httpServerEvent, &httpServerResponse); - - } - break; + httpServerResponse.Response = SL_NETAPP_RESPONSE_NONE; + + _SlDrvDispatchHttpServerEvents (&httpServerEvent, &httpServerResponse); + + } + break; #endif - + default: SL_ERROR_TRACE2(MSG_305, "ASSERT: _SlDrvNetAppEventHandler : invalid opcode = 0x%x = %1", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode); VERIFY_PROTOCOL(0); } + + return SL_RET_CODE_OK; } diff --git a/hardware/lm4f/libraries/WiFi/utility/netapp.h b/hardware/lm4f/libraries/WiFi/utility/netapp.h index 3556e897366..c110d2bf6a3 100644 --- a/hardware/lm4f/libraries/WiFi/utility/netapp.h +++ b/hardware/lm4f/libraries/WiFi/utility/netapp.h @@ -1,35 +1,35 @@ /* * netapp.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -76,7 +76,7 @@ extern "C" { #define MAX_ACTION_LEN (30) /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */ -#define MAX_TOKEN_NAME_LEN (20) +#define MAX_TOKEN_NAME_LEN (20) #define MAX_TOKEN_VALUE_LEN MAX_INPUT_STRING #define NETAPP_MAX_SERVICE_TEXT_SIZE (256) @@ -116,13 +116,13 @@ extern "C" { /********************************************************************************************************/ /* sl_NetAppDnsGetHostByName error codes */ -#define SL_NET_APP_DNS_QUERY_NO_RESPONSE (-159) /* DNS query failed, no response */ -#define SL_NET_APP_DNS_NO_SERVER (-161) /* No DNS server was specified */ +#define SL_NET_APP_DNS_QUERY_NO_RESPONSE (-159) /* DNS query failed, no response */ +#define SL_NET_APP_DNS_NO_SERVER (-161) /* No DNS server was specified */ #define SL_NET_APP_DNS_PARAM_ERROR (-162) /* mDNS parameters error */ -#define SL_NET_APP_DNS_QUERY_FAILED (-163) /* DNS query failed; no DNS server sent an 'answer' */ +#define SL_NET_APP_DNS_QUERY_FAILED (-163) /* DNS query failed; no DNS server sent an 'answer' */ #define SL_NET_APP_DNS_INTERNAL_1 (-164) #define SL_NET_APP_DNS_INTERNAL_2 (-165) -#define SL_NET_APP_DNS_MALFORMED_PACKET (-166) /* Improperly formed or corrupted DNS packet received */ +#define SL_NET_APP_DNS_MALFORMED_PACKET (-166) /* Improperly formed or corrupted DNS packet received */ #define SL_NET_APP_DNS_INTERNAL_3 (-167) #define SL_NET_APP_DNS_INTERNAL_4 (-168) #define SL_NET_APP_DNS_INTERNAL_5 (-169) @@ -139,7 +139,7 @@ extern "C" { #define SL_NET_APP_DNS_NOT_STARTED (-180) /* mDNS is not running */ #define SL_NET_APP_DNS_HOST_NAME_ERROR (-181) /* Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 */ #define SL_NET_APP_DNS_NO_MORE_ENTRIES (-182) /* No more entries be found. */ - + #define SL_NET_APP_DNS_MAX_SERVICES_ERROR (-200) /* Maximum advertise services are already configured */ #define SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR (-201) /* Trying to register a service that is already exists */ #define SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR (-203) /* Trying to delete service that does not existed */ @@ -151,7 +151,7 @@ extern "C" { #define SL_NET_APP_DNS_NO_CONFIGURATION_ERROR (-209) /* Set Dev name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */ -#define SL_ERROR_DEVICE_NAME_LEN_ERR (-117) +#define SL_ERROR_DEVICE_NAME_LEN_ERR (-117) #define SL_ERROR_DEVICE_NAME_INVALID (-118) /* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */ #define SL_ERROR_DOMAIN_NAME_LEN_ERR (-119) @@ -165,16 +165,16 @@ extern "C" { #define SL_NET_APP_MDNS_ID (4) #define SL_NET_APP_DNS_SERVER_ID (8) #define SL_NET_APP_DEVICE_CONFIG_ID (16) -/* NetApp application set/get options */ -#define NETAPP_SET_DHCP_SRV_BASIC_OPT (0) -/* HTTP server set/get options */ +/* NetApp application set/get options */ +#define NETAPP_SET_DHCP_SRV_BASIC_OPT (0) +/* HTTP server set/get options */ #define NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER (0) #define NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK (1) #define NETAPP_SET_GET_HTTP_OPT_AUTH_NAME (2) #define NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD (3) #define NETAPP_SET_GET_HTTP_OPT_AUTH_REALM (4) #define NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS (5) - + #define NETAPP_SET_GET_MDNS_CONT_QUERY_OPT (1) #define NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT (2) #define NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT (3) @@ -264,7 +264,7 @@ typedef struct _u32 lease_time; _u32 ipv4_addr_start; _u32 ipv4_addr_last; -}SlNetAppDhcpServerBasicOpt_t; +}SlNetAppDhcpServerBasicOpt_t; /*mDNS parameters*/ typedef enum @@ -272,7 +272,7 @@ typedef enum SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1, SL_NET_APP_FULL_SERVICE_IPV4_TYPE, SL_NET_APP_SHORT_SERVICE_IPV4_TYPE - + } SlNetAppGetServiceListType_e; typedef struct @@ -341,20 +341,20 @@ typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*); Gets and starts network application for the current WLAN mode \param[in] AppBitMap application bitmap, could be one or combination of the following: \n - - SL_NET_APP_HTTP_SERVER_ID - - SL_NET_APP_DHCP_SERVER_ID - - SL_NET_APP_MDNS_ID + - SL_NET_APP_HTTP_SERVER_ID + - SL_NET_APP_DHCP_SERVER_ID + - SL_NET_APP_MDNS_ID \return On error, negative number is returned \sa Stop one or more the above started applications using sl_NetAppStop \note This command activates the application for the current WLAN mode (AP or STA) \warning - \par Example: - \code - For example: Starting internal HTTP server + DHCP server: + \par Example: + \code + For example: Starting internal HTTP server + DHCP server: sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID) - + \endcode */ #if _SL_INCLUDE_FUNC(sl_NetAppStart) @@ -366,9 +366,9 @@ _i16 sl_NetAppStart(const _u32 AppBitMap); Gets and stops network application for the current WLAN mode \param[in] AppBitMap application id, could be one of the following: \n - - SL_NET_APP_HTTP_SERVER_ID - - SL_NET_APP_DHCP_SERVER_ID - - SL_NET_APP_MDNS_ID + - SL_NET_APP_HTTP_SERVER_ID + - SL_NET_APP_DHCP_SERVER_ID + - SL_NET_APP_MDNS_ID \return On error, negative number is returned @@ -376,11 +376,11 @@ _i16 sl_NetAppStart(const _u32 AppBitMap); \note This command disables the application for the current active WLAN mode (AP or STA) \warning \par Example: - \code - - For example: Stopping internal HTTP server: - sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID); - + \code + + For example: Stopping internal HTTP server: + sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID); + \endcode */ #if _SL_INCLUDE_FUNC(sl_NetAppStop) @@ -404,23 +404,23 @@ _i16 sl_NetAppStop(const _u32 AppBitMap); SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS Possible DNS error codes: - - SL_NET_APP_DNS_QUERY_NO_RESPONSE - - SL_NET_APP_DNS_NO_SERVER - - SL_NET_APP_DNS_QUERY_FAILED - - SL_NET_APP_DNS_MALFORMED_PACKET - - SL_NET_APP_DNS_MISMATCHED_RESPONSE + - SL_NET_APP_DNS_QUERY_NO_RESPONSE + - SL_NET_APP_DNS_NO_SERVER + - SL_NET_APP_DNS_QUERY_FAILED + - SL_NET_APP_DNS_MALFORMED_PACKET + - SL_NET_APP_DNS_MISMATCHED_RESPONSE \sa \note Only one sl_NetAppDnsGetHostByName can be handled at a time. Calling this API while the same command is called from another thread, may result in one of the two scenarios: 1. The command will wait (internal) until the previous command finish, and then be executed. - 2. There are not enough resources and POOL_IS_EMPTY error will return. + 2. There are not enough resources and POOL_IS_EMPTY error will return. In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command. \warning - In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not - try to access the DNS and it will return the input address on the 'out_ip_addr' field + In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not + try to access the DNS and it will return the input address on the 'out_ip_addr' field \par Example: \code _u32 DestinationIP; @@ -481,12 +481,12 @@ _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ \note The returns attributes belongs to the first service found. There may be other services with the same service name that will response to the query. The results of these responses are saved in the peer cache of the Device and should be read by another API. - + Only one sl_NetAppDnsGetHostByService can be handled at a time. Calling this API while the same command is called from another thread, may result in one of the two scenarios: 1. The command will wait (internal) until the previous command finish, and then be executed. - 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. + 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command. @@ -496,7 +496,7 @@ _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */ const _u8 ServiceLen, const _u8 Family, /* 4-IPv4 , 16-IPv6 */ - _u32 pAddr[], + _u32 pAddr[], _u32 *pPort, _u16 *pTextLen, /* in: max len , out: actual len */ _i8 *pText @@ -513,10 +513,10 @@ _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all - Full service parameters. - Short service parameters (port and IP only) especially for tiny hosts. - The different types of struct are made to give the - Possibility to save memory in the host + The different types of struct are made to give the + Possibility to save memory in the host + - The user also chose how many max services to get and start point index NWP peer cache. For example: @@ -528,27 +528,27 @@ _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all from index 6 are inserted into pBuffer (services that are in indexes 6,7). See below - command parameters. - + \param[in] indexOffset - The start index in the peer cache that from it the first service is returned. - \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index + \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index in the peer cache - \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill) + \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill) - use SlNetAppGetFullServiceWithTextIpv4List_t - use SlNetAppGetFullServiceIpv4List_t - use SlNetAppGetShortServiceIpv4List_t - \param[out] Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags + \param[out] Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags input parameter. - - \return ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found + + \return ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found negative number means an error \sa sl_NetAppMDNSRegisterService - \note - \warning + \note + \warning if the out pBuffer size is bigger than an RX packet(1480), than an error is returned because there is no place in the RX packet. - The size is a multiply of MaxServiceCount and size of service struct(that is set + The size is a multiply of MaxServiceCount and size of service struct(that is set according to flag value). */ @@ -569,7 +569,7 @@ _i16 sl_NetAppGetServiceList(const _u8 IndexOffest, The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n The service name should be the full service name according to RFC of the DNS-SD - meaning the value in name field in the SRV answer. - + Examples for service names: 1. PC1._ipp._tcp.local 2. PC2_server._ftp._tcp.local @@ -578,11 +578,11 @@ _i16 sl_NetAppGetServiceList(const _u8 IndexOffest, Example for service name: 1. PC1._ipp._tcp.local 2. PC2_server._ftp._tcp.local - \param[in] ServiceLen The length of the service. - \return On success, zero is returned + \param[in] ServiceLen The length of the service. + \return On success, zero is returned \sa sl_NetAppMDNSRegisterService - \note - \warning + \note + \warning The size of the service length should be smaller than 255. */ #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService) @@ -593,7 +593,7 @@ _i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNam \brief Register a new mDNS service \par This function registers a new mDNS service to the mDNS package and the DB. - + This registered service is a service offered by the application. The service name should be full service name according to RFC of the DNS-SD - meaning the value in name field in the SRV answer. @@ -625,7 +625,7 @@ _i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNam \return On success, zero is returned Possible error codes: - - Maximum advertise services are already configured. + - Maximum advertise services are already configured. Delete another existed service that is registered and then register again the new service - Trying to register a service that is already exists - Trying to delete service that does not existed @@ -637,11 +637,11 @@ _i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNam - mDNS internal cache error - mDNS internal error - Adding a service is not allowed as it is already exist (duplicate service) - - mDNS is not running + - mDNS is not running - Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 - List size buffer is bigger than internally allowed in the NWP (API get service list), - change the APIs’ parameters to decrease the size of the list - + change the APIs? parameters to decrease the size of the list + \sa sl_NetAppMDNSUnRegisterService @@ -654,7 +654,7 @@ _i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNam attribute part (contain constant parameters) */ #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService) -_i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, +_i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, const _u8 ServiceNameLen, const _i8* pText, const _u8 TextLen, @@ -671,9 +671,9 @@ _i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, \param[in] pPingParams Pointer to the ping request structure: \n - if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n - if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts. - - if flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones. + - if flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones. For stopping an ongoing ping activity, set parameters IP address to 0 - + \param[in] family SL_AF_INET or SL_AF_INET6 \param[out] pReport Ping pReport \param[out] pCallback Callback function upon completion. @@ -689,35 +689,35 @@ _i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, Calling this API while the same command is called from another thread, may result in one of the two scenarios: 1. The command will wait (internal) until the previous command finish, and then be executed. - 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. + 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command. - \warning + \warning \par Example: - \code - - An example of sending 20 ping requests and reporting results to a callback routine when + \code + + An example of sending 20 ping requests and reporting results to a callback routine when all requests are sent: // callback routine void pingRes(SlPingReport_t* pReport) { - // handle ping results + // handle ping results } - + // ping activation void PingTest() { SlPingReport_t report; SlPingStartCommand_t pingCommand; - + pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200 - pingCommand.PingSize = 150; // size of ping, in bytes + pingCommand.PingSize = 150; // size of ping, in bytes pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds - pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever + pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever pingCommand.Flags = 0; // report only when finished - + sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ; } @@ -767,9 +767,9 @@ _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family \par \code Set DHCP Server (AP mode) parameters example: - - SlNetAppDhcpServerBasicOpt_t dhcpParams; - _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); + + SlNetAppDhcpServerBasicOpt_t dhcpParams; + _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address dhcpParams.ipv4_addr_start = SL_IPV4_VAL(192,168,1,10); // first IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1) dhcpParams.ipv4_addr_last = SL_IPV4_VAL(192,168,1,16); // last IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1) @@ -779,10 +779,10 @@ _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family \endcode \code Set Device URN name example: - - Device name, maximum length of 33 characters + + Device name, maximum length of 33 characters Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P) - In case no device URN name set, the default name is "mysimplelink" + In case no device URN name set, the default name is "mysimplelink" Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-' _u8 *my_device = "MY-SIMPLELINK-DEV"; @@ -844,22 +844,22 @@ _i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u SlNetAppDhcpServerBasicOpt_t dhcpParams; _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (_u8* )&dhcpParams); - - printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n", + + printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n", SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2), - SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0), + SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0), SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2), - SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0), - dhcpParams.lease_time); + SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0), + dhcpParams.lease_time); \endcode \code Get Device URN name example: - Maximum length of 33 characters of device name. + Maximum length of 33 characters of device name. Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P) - in case no device URN name set, the default name is "mysimplelink" + in case no device URN name set, the default name is "mysimplelink" _u8 my_device_name[35]; - sl_NetAppGet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device_name), (_u8 *)my_device_name); + sl_NetAppGet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device_name), (_u8 *)my_device_name); \endcode */ #if _SL_INCLUDE_FUNC(sl_NetAppGet) diff --git a/hardware/lm4f/libraries/WiFi/utility/netcfg.c b/hardware/lm4f/libraries/WiFi/utility/netcfg.c index d408454b9eb..272fd5651a5 100644 --- a/hardware/lm4f/libraries/WiFi/utility/netcfg.c +++ b/hardware/lm4f/libraries/WiFi/utility/netcfg.c @@ -1,37 +1,37 @@ /* -* netcfg.c - CC31xx/CC32xx Host Driver Implementation -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the -* distribution. -* -* Neither the name of Texas Instruments Incorporated nor the names of -* its contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* + * netcfg.c - CC31xx/CC32xx Host Driver Implementation + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * */ @@ -54,11 +54,11 @@ typedef union #if _SL_INCLUDE_FUNC(sl_NetCfgSet) -const _SlCmdCtrl_t _SlNetCfgSetCmdCtrl = +static const _SlCmdCtrl_t _SlNetCfgSetCmdCtrl = { SL_OPCODE_DEVICE_NETCFG_SET_COMMAND, - sizeof(_NetCfgSetGet_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_NetCfgSetGet_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i32 sl_NetCfgSet(const _u8 ConfigId ,const _u8 ConfigOpt,const _u8 ConfigLen,const _u8 *pValues) @@ -66,6 +66,9 @@ _i32 sl_NetCfgSet(const _u8 ConfigId ,const _u8 ConfigOpt,const _u8 ConfigLen,co _SlNetCfgMsgSet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); CmdExt.TxPayloadLen = (ConfigLen+3) & (~3); @@ -88,17 +91,17 @@ _i32 sl_NetCfgSet(const _u8 ConfigId ,const _u8 ConfigOpt,const _u8 ConfigLen,co /*****************************************************************************/ typedef union { - _NetCfgSetGet_t Cmd; - _NetCfgSetGet_t Rsp; + _NetCfgSetGet_t Cmd; + _NetCfgSetGet_t Rsp; }_SlNetCfgMsgGet_u; #if _SL_INCLUDE_FUNC(sl_NetCfgGet) -const _SlCmdCtrl_t _SlNetCfgGetCmdCtrl = +static const _SlCmdCtrl_t _SlNetCfgGetCmdCtrl = { SL_OPCODE_DEVICE_NETCFG_GET_COMMAND, - sizeof(_NetCfgSetGet_t), - sizeof(_NetCfgSetGet_t) + (_SlArgSize_t)sizeof(_NetCfgSetGet_t), + (_SlArgSize_t)sizeof(_NetCfgSetGet_t) }; _i32 sl_NetCfgGet(const _u8 ConfigId, _u8 *pConfigOpt,_u8 *pConfigLen, _u8 *pValues) @@ -106,13 +109,17 @@ _i32 sl_NetCfgGet(const _u8 ConfigId, _u8 *pConfigOpt,_u8 *pConfigLen, _u8 *pVal _SlNetCfgMsgGet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (*pConfigLen == 0) { return SL_EZEROLEN; } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = *pConfigLen; + CmdExt.RxPayloadLen = (_i16)(*pConfigLen); CmdExt.pRxPayload = (_u8 *)pValues; Msg.Cmd.ConfigLen = *pConfigLen; Msg.Cmd.ConfigId = ConfigId; @@ -127,7 +134,7 @@ _i32 sl_NetCfgGet(const _u8 ConfigId, _u8 *pConfigOpt,_u8 *pConfigLen, _u8 *pVal { *pConfigOpt = (_u8)Msg.Rsp.ConfigOpt; } - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { *pConfigLen = (_u8)CmdExt.RxPayloadLen; if( SL_MAC_ADDRESS_GET == ConfigId ) @@ -144,7 +151,7 @@ _i32 sl_NetCfgGet(const _u8 ConfigId, _u8 *pConfigOpt,_u8 *pConfigLen, _u8 *pVal *pConfigLen = (_u8)CmdExt.ActualRxPayloadLen; } - return (_i16)Msg.Rsp.Status; + return (_i32)Msg.Rsp.Status; } #endif diff --git a/hardware/lm4f/libraries/WiFi/utility/netcfg.h b/hardware/lm4f/libraries/WiFi/utility/netcfg.h index eb1a545827e..6ff1ee24251 100644 --- a/hardware/lm4f/libraries/WiFi/utility/netcfg.h +++ b/hardware/lm4f/libraries/WiFi/utility/netcfg.h @@ -1,35 +1,35 @@ /* * netcfg.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -39,7 +39,7 @@ /*****************************************************************************/ #include "simplelink.h" - + #ifndef __NETCFG_H__ #define __NETCFG_H__ @@ -75,13 +75,16 @@ extern "C" { typedef enum { SL_MAC_ADDRESS_SET = 1, - SL_MAC_ADDRESS_GET = 2, + SL_MAC_ADDRESS_GET = 2, SL_IPV4_STA_P2P_CL_GET_INFO = 3, SL_IPV4_STA_P2P_CL_DHCP_ENABLE = 4, SL_IPV4_STA_P2P_CL_STATIC_ENABLE = 5, SL_IPV4_AP_P2P_GO_GET_INFO = 6, SL_IPV4_AP_P2P_GO_STATIC_ENABLE = 7, SL_SET_HOST_RX_AGGR = 8, + SL_IPV4_DHCP_CLIENT = 9, + SL_IPV4_DNS_CLIENT = 10, + SL_IPV4_ARP_FLUSH = 11, MAX_SETTINGS = 0xFF }Sl_NetCfg_e; @@ -94,6 +97,33 @@ typedef struct _u32 ipV4DnsServer; }SlNetCfgIpV4Args_t; +typedef struct +{ + _u32 Ip; + _u32 Gateway; + _u32 Mask; + _u32 Dns[2]; + _u32 DhcpServer; + _u32 LeaseTime; + _u8 DhcpState; + _u8 Reserved[3]; +}SlNetCfgIpV4DhcpClientArgs_t; + +typedef enum +{ + SL_NETCFG_DHCP_CLIENT_UNKNOWN = 0, + SL_NETCFG_DHCP_CLIENT_DISABLED, + SL_NETCFG_DHCP_CLIENT_ENABLED, + SL_NETCFG_DHCP_CLIENT_BOUND, + SL_NETCFG_DHCP_CLIENT_RENEW, + SL_NETCFG_DHCP_CLIENT_REBIND +}SlNetCfgIpv4DhcpClientState_e; + +typedef struct +{ + _u32 DnsSecondServerAddr; + _u32 DnsMaxRetries; +}SlNetCfgIpV4DnsClientArgs_t; /*****************************************************************************/ /* Function prototypes */ @@ -102,26 +132,26 @@ typedef struct /*! \brief Internal function for setting network configurations - \return On success, zero is returned. On error, -1 is + \return On success, zero is returned. On error, -1 is returned - + \param[in] ConfigId configuration id \param[in] ConfigOpt configurations option \param[in] ConfigLen configurations len \param[in] pValues configurations values - - \sa - \note - \warning + + \sa + \note + \warning \par Examples: \code SL_MAC_ADDRESS_SET: - + Setting MAC address to the Device. The new MAC address will override the default MAC address and it be saved in the FileSystem. Requires restarting the device for updating this setting. - + _u8 MAC_Address[6]; MAC_Address[0] = 0x8; MAC_Address[1] = 0x0; @@ -132,9 +162,9 @@ typedef struct sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)newMacAddress); sl_Stop(0); sl_Start(NULL,NULL,NULL); - \endcode + \endcode - \code + \code SL_IPV4_STA_P2P_CL_STATIC_ENABLE: Setting a static IP address to the device working in STA mode or P2P client. @@ -142,17 +172,17 @@ typedef struct In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET SlNetCfgIpV4Args_t ipV4; - ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address + ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address - sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4); + sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4); sl_Stop(0); sl_Start(NULL,NULL,NULL); \endcode - \code + \code SL_IPV4_STA_P2P_CL_DHCP_ENABLE: Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client. @@ -164,14 +194,14 @@ typedef struct sl_Start(NULL,NULL,NULL); \endcode - \code + \code SL_IPV4_AP_P2P_GO_STATIC_ENABLE: Setting a static IP address to the device working in AP mode or P2P go. The IP address will be stored in the FileSystem. Requires restart. - + SlNetCfgIpV4Args_t ipV4; - ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address + ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this AP/P2P ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address @@ -181,7 +211,35 @@ typedef struct sl_Start(NULL,NULL,NULL); \endcode - + \code + SL_IPV4_DNS_CLIENT: + + Set DNS max retries (range 5-32, default 32 retries) and secondary DNS address (DHCP and static configuration) + changes not saved on the internal flash. + + _i32 Status; + SlNetCfgIpV4DnsClientArgs_t DnsOpt; + DnsOpt.DnsSecondServerAddr = SL_IPV4_VAL(8,8,8,8); ; + DnsOpt.DnsMaxRetries = 12; + Status = sl_NetCfgSet(SL_IPV4_DNS_CLIENT,0,sizeof(SlNetCfgIpV4DnsClientArgs_t),(unsigned char *)&DnsOpt); + if( Status ) + { + // error + } + \endcode + \code + SL_IPV4_ARP_FLUSH: + + Flush ARP table + + _i32 Status; + Status = sl_NetCfgSet(SL_IPV4_ARP_FLUSH,0,0,NULL); + if( Status ) + { + // + } + \endcode + */ #if _SL_INCLUDE_FUNC(sl_NetCfgSet) _i32 sl_NetCfgSet(const _u8 ConfigId,const _u8 ConfigOpt,const _u8 ConfigLen,const _u8 *pValues); @@ -191,77 +249,109 @@ _i32 sl_NetCfgSet(const _u8 ConfigId,const _u8 ConfigOpt,const _u8 ConfigLen,con /*! \brief Internal function for getting network configurations - \return On success, zero is returned. On error, -1 is + \return On success, zero is returned. On error, -1 is returned - + \param[in] ConfigId configuration id - \param[out] pConfigOpt Get configurations option + \param[out] pConfigOpt Get configurations option \param[out] pConfigLen The length of the allocated memory as input, when the function complete, the value of this parameter would be - the len that actually read from the device.\n - If the device return length that is longer from the input + the len that actually read from the device.\n + If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return ESMALLBUF \param[out] pValues - get configurations values - \sa - \note - \warning + \sa + \note + \warning \par Examples: \code SL_MAC_ADDRESS_GET: - + Get the device MAC address. The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address is retrieved from HW. - + _u8 macAddressVal[SL_MAC_ADDR_LEN]; _u8 macAddressLen = SL_MAC_ADDR_LEN; sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(_u8 *)macAddressVal); - + \endcode \code SL_IPV4_STA_P2P_CL_GET_INFO: - - Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP. - + + Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP. + _u8 len = sizeof(SlNetCfgIpV4Args_t); _u8 dhcpIsOn = 0; SlNetCfgIpV4Args_t ipV4 = {0}; sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4); - - printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n", - (dhcpIsOn > 0) ? "ON" : "OFF", - SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0), - SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0), - SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0), + + printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n", + (dhcpIsOn > 0) ? "ON" : "OFF", + SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0), + SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0), + SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0), SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0)); \endcode \code SL_IPV4_AP_P2P_GO_GET_INFO: - - Get static IP address for AP or P2P go. - + + Get static IP address for AP or P2P go. + _u8 len = sizeof(SlNetCfgIpV4Args_t); _u8 dhcpIsOn = 0; // this flag is meaningless on AP/P2P go. SlNetCfgIpV4Args_t ipV4 = {0}; sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4); - - printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n", - SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0), - SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0), - SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0), + + printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n", + SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0), + SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0), + SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0), SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0)); \endcode - + \code + + SL_IPV4_DHCP_CLIENT: + + Get DHCP client inforamtion, when DhcpState is SL_NETCFG_DHCP_CLIENT_BOUND, SL_NETCFG_DHCP_CLIENT_RENEW or SL_NETCFG_DHCP_CLIENT_REBIND, dhcp inforamtion is not zeroed + + _u8 ConfigOpt = 0, ConfigLen = sizeof(SlNetCfgIpV4DhcpClientArgs_t); + _i32 Status; + SlNetCfgIpV4DhcpClientArgs_t Dhcp; + Status = sl_NetCfgGet(SL_IPV4_DHCP_CLIENT,&ConfigOpt,&ConfigLen,(_u8 *)&Dhcp); + if( Status ) + { + // error + } + \endcode + + \code + SL_IPV4_DNS_CLIENT: + + Get DNS max retries and secondary DNS address (DHCP and static configuration) + + _u8 ConfigOpt; + _i32 Status; + _u8 pConfigLen = sizeof(SlNetCfgIpV4DnsClientArgs_t); + SlNetCfgIpV4DnsClientArgs_t DnsOpt; + Status = sl_NetCfgGet(SL_IPV4_DNS_CLIENT,&ConfigOpt,&pConfigLen,&DnsOpt); + if( Status ) + { + // error + } + \endcode + + */ #if _SL_INCLUDE_FUNC(sl_NetCfgGet) _i32 sl_NetCfgGet(const _u8 ConfigId ,_u8 *pConfigOpt, _u8 *pConfigLen, _u8 *pValues); diff --git a/hardware/lm4f/libraries/WiFi/utility/nonos.c b/hardware/lm4f/libraries/WiFi/utility/nonos.c index ce851c3665b..621881792d8 100644 --- a/hardware/lm4f/libraries/WiFi/utility/nonos.c +++ b/hardware/lm4f/libraries/WiFi/utility/nonos.c @@ -1,37 +1,37 @@ /* -* nonos.c - CC31xx/CC32xx Host Driver Implementation -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the -* distribution. -* -* Neither the name of Texas Instruments Incorporated nor the names of -* its contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* + * nonos.c - CC31xx/CC32xx Host Driver Implementation + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * */ @@ -43,29 +43,13 @@ #include "protocol.h" #include "driver.h" + #ifndef SL_PLATFORM_MULTI_THREADED #include "nonos.h" -#ifndef SL_TINY_EXT -#define NONOS_MAX_SPAWN_ENTRIES 5 -#else -#define NONOS_MAX_SPAWN_ENTRIES 1 -#endif - -typedef struct -{ - _SlSpawnEntryFunc_t pEntry; - void* pValue; -}_SlNonOsSpawnEntry_t; - -typedef struct -{ - _SlNonOsSpawnEntry_t SpawnEntries[NONOS_MAX_SPAWN_ENTRIES]; -}_SlNonOsCB_t; - -_SlNonOsCB_t g__SlNonOsCB; +_SlNonOsCB_t g__SlNonOsCB = {0}; _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value) @@ -76,8 +60,26 @@ _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Val _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout) { +#if (!defined (SL_TINY)) && (defined(sl_GetTimestamp)) + _SlTimeoutParams_t TimeoutInfo={0}; +#endif + + /* If timeout 0 configured, just detect the value and return */ + if ((Timeout ==0) && (WaitValue == *pSyncObj)) + { + *pSyncObj = SetValue; + return NONOS_RET_OK; + } + +#if (!defined (SL_TINY)) && (defined(sl_GetTimestamp)) + if ((Timeout != NONOS_WAIT_FOREVER) && (Timeout != NONOS_NO_WAIT)) + { + _SlDrvStartMeasureTimeout(&TimeoutInfo, Timeout); + } +#endif + #ifdef _SlSyncWaitLoopCallback - _SlNonOsTime_t timeOutRequest = Timeout; + _SlNonOsTime_t timeOutRequest = Timeout; #endif while (Timeout>0) { @@ -86,11 +88,28 @@ _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t Wai *pSyncObj = SetValue; break; } +#if (!defined (sl_GetTimestamp)) || (defined (SL_TINY_EXT)) if (Timeout != NONOS_WAIT_FOREVER) - { + { Timeout--; } - _SlNonOsMainLoopTask(); +#else + if ((Timeout != NONOS_WAIT_FOREVER) && (Timeout != NONOS_NO_WAIT)) + { + if (_SlDrvIsTimeoutExpired(&TimeoutInfo)) + { + return (_SlNonOsRetVal_t)NONOS_RET_ERR; + } + + } + #endif + + /* If we are in cmd context and waiting for its cmd response + * do not handle spawn async events as the global lock was already taken */ + if (FALSE == g_pCB->IsCmdRespWaited) + { + (void)_SlNonOsMainLoopTask(); + } #ifdef _SlSyncWaitLoopCallback if( (__NON_OS_SYNC_OBJ_SIGNAL_VALUE == WaitValue) && (timeOutRequest != NONOS_NO_WAIT) ) { @@ -117,55 +136,62 @@ _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t Wai _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags) { - _i8 i = 0; - -#ifndef SL_TINY_EXT - for (i=0 ; ipEntry) - { - pE->pValue = pValue; - pE->pEntry = pEntry; -#ifndef SL_TINY_EXT - break; -#endif - } - } - - + _i8 i = 0; + + (void)flags; + +#ifndef SL_TINY_EXT + for (i=0 ; iIsAllocated == FALSE) + { + pE->pValue = pValue; + pE->pEntry = pEntry; + pE->IsAllocated = TRUE; +#ifndef SL_TINY_EXT + break; +#endif + } + } + + return NONOS_RET_OK; } _SlNonOsRetVal_t _SlNonOsMainLoopTask(void) { - _i8 i=0; - + _i8 i=0; + void* pValue; #ifndef SL_TINY_EXT - for (i=0 ; ipEntry; - - if (NULL != pF) - { - if(RxIrqCnt != (g_pCB)->RxDoneCnt) - { - pF(0); /* (pValue) */ - } - - pE->pEntry = NULL; - pE->pValue = NULL; - } - } - + { + _SlNonOsSpawnEntry_t* pE = &g__SlNonOsCB.SpawnEntries[i]; + + + if (pE->IsAllocated == TRUE) + { + _SlSpawnEntryFunc_t pF = pE->pEntry; + pValue = pE->pValue; + + + /* Clear the entry */ + pE->pEntry = NULL; + pE->pValue = NULL; + pE->IsAllocated = FALSE; + + /* execute the spawn function */ + pF(pValue); + } + } + return NONOS_RET_OK; } - + #endif /*(SL_PLATFORM != SL_PLATFORM_NON_OS)*/ diff --git a/hardware/lm4f/libraries/WiFi/utility/nonos.h b/hardware/lm4f/libraries/WiFi/utility/nonos.h index 2fbf3806efe..a1146fe8db0 100644 --- a/hardware/lm4f/libraries/WiFi/utility/nonos.h +++ b/hardware/lm4f/libraries/WiFi/utility/nonos.h @@ -1,35 +1,35 @@ /* * nonos.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -52,6 +52,25 @@ extern "C" { #define _SlSyncWaitLoopCallback UserSleepFunction */ +#ifndef SL_TINY_EXT +#define NONOS_MAX_SPAWN_ENTRIES 5 +#else +#define NONOS_MAX_SPAWN_ENTRIES 1 +#endif + + + +typedef struct +{ + _SlSpawnEntryFunc_t pEntry; + void* pValue; + _u8 IsAllocated; +}_SlNonOsSpawnEntry_t; + +typedef struct +{ + _SlNonOsSpawnEntry_t SpawnEntries[NONOS_MAX_SPAWN_ENTRIES]; +}_SlNonOsCB_t; #define NONOS_WAIT_FOREVER 0xFF @@ -74,11 +93,11 @@ typedef _i8 _SlNonOsRetVal_t; /*! \brief type definition for a time value */ -typedef _u8 _SlNonOsTime_t; +typedef _u32 _SlNonOsTime_t; /*! \brief type definition for a sync object container - + Sync object is object used to synchronize between two threads or thread and interrupt handler. One thread is waiting on the object and the other thread send a signal, which then release the waiting thread. @@ -96,7 +115,7 @@ typedef _u8 _SlNonOsSemObj_t; #define SL_OS_WAIT_FOREVER NONOS_WAIT_FOREVER -#define SL_OS_RET_CODE_OK NONOS_RET_OK +#define SL_OS_RET_CODE_OK NONOS_RET_OK #define SL_OS_NO_WAIT NONOS_NO_WAIT @@ -107,11 +126,11 @@ typedef _u8 _SlNonOsSemObj_t; /*! \brief This function creates a sync object - The sync object is used for synchronization between different thread or ISR and + The sync object is used for synchronization between different thread or ISR and a thread. \param pSyncObj - pointer to the sync object control block - + \return upon successful creation the function return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -123,7 +142,7 @@ typedef _u8 _SlNonOsSemObj_t; \brief This function deletes a sync object \param pSyncObj - pointer to the sync object control block - + \return upon successful deletion the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -132,12 +151,12 @@ typedef _u8 _SlNonOsSemObj_t; #define _SlNonOsSyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0) /*! - \brief This function generates a sync signal for the object. - + \brief This function generates a sync signal for the object. + All suspended threads waiting on this sync object are resumed \param pSyncObj - pointer to the sync object control block - + \return upon successful signaling the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note the function could be called from ISR context @@ -149,12 +168,12 @@ typedef _u8 _SlNonOsSemObj_t; \brief This function waits for a sync signal of the specific sync object \param pSyncObj - pointer to the sync object control block - \param Timeout - numeric value specifies the maximum number of mSec to + \param Timeout - numeric value specifies the maximum number of mSec to stay suspended while waiting for the sync signal Currently, the simple link driver uses only two values: - NONOS_WAIT_FOREVER - NONOS_NO_WAIT - + \return upon successful reception of the signal within the timeout window return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -166,7 +185,7 @@ typedef _u8 _SlNonOsSemObj_t; \brief This function clears a sync object \param pSyncObj - pointer to the sync object control block - + \return upon successful clearing the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -176,12 +195,12 @@ typedef _u8 _SlNonOsSemObj_t; /*! \brief This function creates a locking object. - - The locking object is used for protecting a shared resources between different + + The locking object is used for protecting a shared resources between different threads. \param pLockObj - pointer to the locking object control block - + \return upon successful creation the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -191,9 +210,9 @@ typedef _u8 _SlNonOsSemObj_t; /*! \brief This function deletes a locking object. - + \param pLockObj - pointer to the locking object control block - + \return upon successful deletion the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -202,19 +221,19 @@ typedef _u8 _SlNonOsSemObj_t; #define _SlNonOsLockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0) /*! - \brief This function locks a locking object. - - All other threads that call this function before this thread calls - the _SlNonOsLockObjUnlock would be suspended - + \brief This function locks a locking object. + + All other threads that call this function before this thread calls + the _SlNonOsLockObjUnlock would be suspended + \param pLockObj - pointer to the locking object control block - \param Timeout - numeric value specifies the maximum number of mSec to + \param Timeout - numeric value specifies the maximum number of mSec to stay suspended while waiting for the locking object Currently, the simple link driver uses only two values: - NONOS_WAIT_FOREVER - NONOS_NO_WAIT - - + + \return upon successful reception of the locking object the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -224,9 +243,9 @@ typedef _u8 _SlNonOsSemObj_t; /*! \brief This function unlock a locking object. - + \param pLockObj - pointer to the locking object control block - + \return upon successful unlocking the function should return 0 Otherwise, a negative value indicating the error code shall be returned \note @@ -237,14 +256,14 @@ typedef _u8 _SlNonOsSemObj_t; /*! \brief This function call the pEntry callback from a different context - - \param pEntry - pointer to the entry callback function - + + \param pEntry - pointer to the entry callback function + \param pValue - pointer to any type of memory structure that would be passed to pEntry callback from the execution thread. - + \param flags - execution flags - reserved for future usage - + \return upon successful registration of the spawn the function return 0 (the function is not blocked till the end of the execution of the function and could be returned before the execution is actually completed) @@ -257,9 +276,9 @@ _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 /*! \brief This function must be called from the main loop in non-os paltforms - + \param None - + \return 0 - No more activities 1 - Activity still in progress \note @@ -270,12 +289,11 @@ _SlNonOsRetVal_t _SlNonOsMainLoopTask(void); extern _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout); extern _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value); extern _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags); - + #if (defined(_SlSyncWaitLoopCallback)) extern void _SlSyncWaitLoopCallback(void); #endif - /***************************************************************************** Overwrite SimpleLink driver OS adaptation functions @@ -316,6 +334,7 @@ extern void _SlSyncWaitLoopCallback(void); #undef _SlTaskEntry #define _SlTaskEntry _SlNonOsMainLoopTask + #endif /* !SL_PLATFORM_MULTI_THREADED */ #ifdef __cplusplus diff --git a/hardware/lm4f/libraries/WiFi/utility/objInclusion.h b/hardware/lm4f/libraries/WiFi/utility/objInclusion.h index e49844ec0ea..5a912cb536e 100644 --- a/hardware/lm4f/libraries/WiFi/utility/objInclusion.h +++ b/hardware/lm4f/libraries/WiFi/utility/objInclusion.h @@ -1,35 +1,35 @@ /* * objInclusion.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -39,26 +39,26 @@ #ifndef OBJINCLUSION_H_ #define OBJINCLUSION_H_ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif /****************************************************************************** - + For future use - + *******************************************************************************/ -#define __inln /* if inline functions requiered: #define __inln inline */ +#define __inln /* if inline functions requiered: #define __inln inline */ -#define SL_DEVICE /* Device silo is currently always mandatory */ +#define SL_DEVICE /* Device silo is currently always mandatory */ /****************************************************************************** - Qualifiers for package customizations - + Qualifiers for package customizations + *******************************************************************************/ #if defined (SL_DEVICE) @@ -97,7 +97,7 @@ extern "C" { #else #define __nap__ext 0 #endif - + #if defined (SL_INC_NET_CFG_PKG) #define __ncg 1 #else @@ -165,7 +165,7 @@ extern "C" { #endif /* The return 1 is the function need to be included in the output */ -#define _SL_INCLUDE_FUNC(Name) (_SL_INC_##Name) +#define _SL_INCLUDE_FUNC(Name) (_SL_INC_##Name) /* Driver */ #define _SL_INC_sl_NetAppStart __nap__ext @@ -174,12 +174,12 @@ extern "C" { #define _SL_INC_sl_NetAppDnsGetHostByName __nap__clt -#define _SL_INC_sl_NetAppDnsGetHostByService __nap__ext -#define _SL_INC_sl_NetAppMDNSRegisterService __nap__ext -#define _SL_INC_sl_NetAppMDNSUnRegisterService __nap__ext -#define _SL_INC_sl_NetAppMDNSRegisterUnregisterService __nap__ext -#define _SL_INC_sl_NetAppGetServiceList __nap__ext - +#define _SL_INC_sl_NetAppDnsGetHostByService __nap__ext +#define _SL_INC_sl_NetAppMDNSRegisterService __nap__ext +#define _SL_INC_sl_NetAppMDNSUnRegisterService __nap__ext +#define _SL_INC_sl_NetAppMDNSRegisterUnregisterService __nap__ext +#define _SL_INC_sl_NetAppGetServiceList __nap__ext + #define _SL_INC_sl_DnsGetHostByAddr __nap__ext #define _SL_INC_sl_NetAppPingStart __nap__ext @@ -243,7 +243,7 @@ extern "C" { #define _SL_INC_sl_Htonl __sck #define _SL_INC_sl_Htons __sck - + /* wlan */ #define _SL_INC_sl_WlanConnect __wln__ext @@ -276,11 +276,11 @@ extern "C" { #define _SL_INC_sl_WlanSmartConfigStop __wln -#define _SL_INC_sl_WlanSetMode __wln +#define _SL_INC_sl_WlanSetMode __wln -#define _SL_INC_sl_WlanSet __wln +#define _SL_INC_sl_WlanSet __wln -#define _SL_INC_sl_WlanGet __wln +#define _SL_INC_sl_WlanGet __wln #define _SL_INC_sl_SmartConfigOptSet __wln__ext @@ -302,17 +302,17 @@ extern "C" { #define _SL_INC_sl_StatusGet __dev -#ifdef SL_IF_TYPE_UART -#define _SL_INC_sl_UartSetMode __dev__ext +#ifdef SL_IF_TYPE_UART +#define _SL_INC_sl_UartSetMode __dev__ext #endif #define _SL_INC_sl_EventMaskGet __dev__ext #define _SL_INC_sl_EventMaskSet __dev__ext -#define _SL_INC_sl_DevGet __dev__ext +#define _SL_INC_sl_DevGet __dev__ext -#define _SL_INC_sl_DevSet __dev__ext +#define _SL_INC_sl_DevSet __dev__ext #ifdef __cplusplus diff --git a/hardware/lm4f/libraries/WiFi/utility/protocol.h b/hardware/lm4f/libraries/WiFi/utility/protocol.h index 243dc452e60..7586c35998f 100644 --- a/hardware/lm4f/libraries/WiFi/utility/protocol.h +++ b/hardware/lm4f/libraries/WiFi/utility/protocol.h @@ -1,35 +1,35 @@ /* * protocol.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -68,6 +68,7 @@ #define H2N_DUMMY_PATTERN (_u32)0xFFFFFFFF #define N2H_SYNC_PATTERN (_u32)0xABCDDCBA + #define SYNC_PATTERN_LEN (_u32)sizeof(_u32) #define UART_SET_MODE_MAGIC_CODE (_u32)0xAA55AA55 #define SPI_16BITS_BUG(pattern) (_u32)((_u32)pattern & (_u32)0xFFFF7FFF) @@ -77,8 +78,8 @@ typedef struct { - _u16 Opcode; - _u16 Len; + _u16 Opcode; + _u16 Len; }_SlGenericHeader_t; @@ -131,11 +132,11 @@ typedef struct ** OPCODES ****************************************************************************/ #define SL_IPV4_IPV6_OFFSET ( 9 ) -#define SL_OPCODE_IPV4 ( 0x0 << SL_IPV4_IPV6_OFFSET ) -#define SL_OPCODE_IPV6 ( 0x1 << SL_IPV4_IPV6_OFFSET ) +#define SL_OPCODE_IPV4 ( 0x0 << SL_IPV4_IPV6_OFFSET ) +#define SL_OPCODE_IPV6 ( 0x1 << SL_IPV4_IPV6_OFFSET ) #define SL_SYNC_ASYNC_OFFSET ( 10 ) -#define SL_OPCODE_SYNC (0x1 << SL_SYNC_ASYNC_OFFSET ) +#define SL_OPCODE_SYNC (0x1 << SL_SYNC_ASYNC_OFFSET ) #define SL_OPCODE_SILO_OFFSET ( 11 ) #define SL_OPCODE_SILO_MASK ( 0xF << SL_OPCODE_SILO_OFFSET ) #define SL_OPCODE_SILO_DEVICE ( 0x0 << SL_OPCODE_SILO_OFFSET ) @@ -148,125 +149,125 @@ typedef struct #define SL_FAMILY_SHIFT (0x4) #define SL_FLAGS_MASK (0xF) -#define SL_OPCODE_DEVICE_INITCOMPLETE 0x0008 -#define SL_OPCODE_DEVICE_ABORT 0x000C -#define SL_OPCODE_DEVICE_STOP_COMMAND 0x8473 -#define SL_OPCODE_DEVICE_STOP_RESPONSE 0x0473 -#define SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE 0x0073 -#define SL_OPCODE_DEVICE_DEVICEASYNCDUMMY 0x0063 - -#define SL_OPCODE_DEVICE_VERSIONREADCOMMAND 0x8470 -#define SL_OPCODE_DEVICE_VERSIONREADRESPONSE 0x0470 -#define SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR 0x0078 -#define SL_OPCODE_WLAN_WLANCONNECTCOMMAND 0x8C80 -#define SL_OPCODE_WLAN_WLANCONNECTRESPONSE 0x0C80 -#define SL_OPCODE_WLAN_WLANASYNCCONNECTEDRESPONSE 0x0880 +#define SL_OPCODE_DEVICE_INITCOMPLETE 0x0008 +#define SL_OPCODE_DEVICE_ABORT 0x000C +#define SL_OPCODE_DEVICE_STOP_COMMAND 0x8473 +#define SL_OPCODE_DEVICE_STOP_RESPONSE 0x0473 +#define SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE 0x0073 +#define SL_OPCODE_DEVICE_DEVICEASYNCDUMMY 0x0063 + +#define SL_OPCODE_DEVICE_VERSIONREADCOMMAND 0x8470 +#define SL_OPCODE_DEVICE_VERSIONREADRESPONSE 0x0470 +#define SL_OPCODE_DEVICE_ASYNC_GENERAL_ERROR 0x0078 +#define SL_OPCODE_WLAN_WLANCONNECTCOMMAND 0x8C80 +#define SL_OPCODE_WLAN_WLANCONNECTRESPONSE 0x0C80 +#define SL_OPCODE_WLAN_WLANASYNCCONNECTEDRESPONSE 0x0880 #define SL_OPCODE_WLAN_P2P_DEV_FOUND 0x0830 #define SL_OPCODE_WLAN_CONNECTION_FAILED 0x0831 #define SL_OPCODE_WLAN_P2P_NEG_REQ_RECEIVED 0x0832 -#define SL_OPCODE_WLAN_WLANDISCONNECTCOMMAND 0x8C81 -#define SL_OPCODE_WLAN_WLANDISCONNECTRESPONSE 0x0C81 -#define SL_OPCODE_WLAN_WLANASYNCDISCONNECTEDRESPONSE 0x0881 -#define SL_OPCODE_WLAN_WLANCONNECTEAPCOMMAND 0x8C82 -#define SL_OPCODE_WLAN_WLANCONNECTEAPCRESPONSE 0x0C82 -#define SL_OPCODE_WLAN_PROFILEADDCOMMAND 0x8C83 -#define SL_OPCODE_WLAN_PROFILEADDRESPONSE 0x0C83 -#define SL_OPCODE_WLAN_PROFILEGETCOMMAND 0x8C84 -#define SL_OPCODE_WLAN_PROFILEGETRESPONSE 0x0C84 -#define SL_OPCODE_WLAN_PROFILEDELCOMMAND 0x8C85 -#define SL_OPCODE_WLAN_PROFILEDELRESPONSE 0x0C85 -#define SL_OPCODE_WLAN_POLICYSETCOMMAND 0x8C86 -#define SL_OPCODE_WLAN_POLICYSETRESPONSE 0x0C86 -#define SL_OPCODE_WLAN_POLICYGETCOMMAND 0x8C87 -#define SL_OPCODE_WLAN_POLICYGETRESPONSE 0x0C87 -#define SL_OPCODE_WLAN_FILTERADD 0x8C88 -#define SL_OPCODE_WLAN_FILTERADDRESPONSE 0x0C88 -#define SL_OPCODE_WLAN_FILTERGET 0x8C89 -#define SL_OPCODE_WLAN_FILTERGETRESPONSE 0x0C89 -#define SL_OPCODE_WLAN_FILTERDELETE 0x8C8A -#define SL_OPCODE_WLAN_FILTERDELETERESPOSNE 0x0C8A -#define SL_OPCODE_WLAN_WLANGETSTATUSCOMMAND 0x8C8F -#define SL_OPCODE_WLAN_WLANGETSTATUSRESPONSE 0x0C8F -#define SL_OPCODE_WLAN_STARTTXCONTINUESCOMMAND 0x8CAA -#define SL_OPCODE_WLAN_STARTTXCONTINUESRESPONSE 0x0CAA -#define SL_OPCODE_WLAN_STOPTXCONTINUESCOMMAND 0x8CAB -#define SL_OPCODE_WLAN_STOPTXCONTINUESRESPONSE 0x0CAB -#define SL_OPCODE_WLAN_STARTRXSTATCOMMAND 0x8CAC -#define SL_OPCODE_WLAN_STARTRXSTATRESPONSE 0x0CAC -#define SL_OPCODE_WLAN_STOPRXSTATCOMMAND 0x8CAD -#define SL_OPCODE_WLAN_STOPRXSTATRESPONSE 0x0CAD -#define SL_OPCODE_WLAN_GETRXSTATCOMMAND 0x8CAF -#define SL_OPCODE_WLAN_GETRXSTATRESPONSE 0x0CAF -#define SL_OPCODE_WLAN_POLICYSETCOMMANDNEW 0x8CB0 -#define SL_OPCODE_WLAN_POLICYSETRESPONSENEW 0x0CB0 -#define SL_OPCODE_WLAN_POLICYGETCOMMANDNEW 0x8CB1 -#define SL_OPCODE_WLAN_POLICYGETRESPONSENEW 0x0CB1 - -#define SL_OPCODE_WLAN_SMART_CONFIG_START_COMMAND 0x8CB2 -#define SL_OPCODE_WLAN_SMART_CONFIG_START_RESPONSE 0x0CB2 -#define SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE 0x08B2 -#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_COMMAND 0x8CB3 -#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_RESPONSE 0x0CB3 -#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE 0x08B3 +#define SL_OPCODE_WLAN_WLANDISCONNECTCOMMAND 0x8C81 +#define SL_OPCODE_WLAN_WLANDISCONNECTRESPONSE 0x0C81 +#define SL_OPCODE_WLAN_WLANASYNCDISCONNECTEDRESPONSE 0x0881 +#define SL_OPCODE_WLAN_WLANCONNECTEAPCOMMAND 0x8C82 +#define SL_OPCODE_WLAN_WLANCONNECTEAPCRESPONSE 0x0C82 +#define SL_OPCODE_WLAN_PROFILEADDCOMMAND 0x8C83 +#define SL_OPCODE_WLAN_PROFILEADDRESPONSE 0x0C83 +#define SL_OPCODE_WLAN_PROFILEGETCOMMAND 0x8C84 +#define SL_OPCODE_WLAN_PROFILEGETRESPONSE 0x0C84 +#define SL_OPCODE_WLAN_PROFILEDELCOMMAND 0x8C85 +#define SL_OPCODE_WLAN_PROFILEDELRESPONSE 0x0C85 +#define SL_OPCODE_WLAN_POLICYSETCOMMAND 0x8C86 +#define SL_OPCODE_WLAN_POLICYSETRESPONSE 0x0C86 +#define SL_OPCODE_WLAN_POLICYGETCOMMAND 0x8C87 +#define SL_OPCODE_WLAN_POLICYGETRESPONSE 0x0C87 +#define SL_OPCODE_WLAN_FILTERADD 0x8C88 +#define SL_OPCODE_WLAN_FILTERADDRESPONSE 0x0C88 +#define SL_OPCODE_WLAN_FILTERGET 0x8C89 +#define SL_OPCODE_WLAN_FILTERGETRESPONSE 0x0C89 +#define SL_OPCODE_WLAN_FILTERDELETE 0x8C8A +#define SL_OPCODE_WLAN_FILTERDELETERESPOSNE 0x0C8A +#define SL_OPCODE_WLAN_WLANGETSTATUSCOMMAND 0x8C8F +#define SL_OPCODE_WLAN_WLANGETSTATUSRESPONSE 0x0C8F +#define SL_OPCODE_WLAN_STARTTXCONTINUESCOMMAND 0x8CAA +#define SL_OPCODE_WLAN_STARTTXCONTINUESRESPONSE 0x0CAA +#define SL_OPCODE_WLAN_STOPTXCONTINUESCOMMAND 0x8CAB +#define SL_OPCODE_WLAN_STOPTXCONTINUESRESPONSE 0x0CAB +#define SL_OPCODE_WLAN_STARTRXSTATCOMMAND 0x8CAC +#define SL_OPCODE_WLAN_STARTRXSTATRESPONSE 0x0CAC +#define SL_OPCODE_WLAN_STOPRXSTATCOMMAND 0x8CAD +#define SL_OPCODE_WLAN_STOPRXSTATRESPONSE 0x0CAD +#define SL_OPCODE_WLAN_GETRXSTATCOMMAND 0x8CAF +#define SL_OPCODE_WLAN_GETRXSTATRESPONSE 0x0CAF +#define SL_OPCODE_WLAN_POLICYSETCOMMANDNEW 0x8CB0 +#define SL_OPCODE_WLAN_POLICYSETRESPONSENEW 0x0CB0 +#define SL_OPCODE_WLAN_POLICYGETCOMMANDNEW 0x8CB1 +#define SL_OPCODE_WLAN_POLICYGETRESPONSENEW 0x0CB1 + +#define SL_OPCODE_WLAN_SMART_CONFIG_START_COMMAND 0x8CB2 +#define SL_OPCODE_WLAN_SMART_CONFIG_START_RESPONSE 0x0CB2 +#define SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE 0x08B2 +#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_COMMAND 0x8CB3 +#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_RESPONSE 0x0CB3 +#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE 0x08B3 #define SL_OPCODE_WLAN_SET_MODE 0x8CB4 #define SL_OPCODE_WLAN_SET_MODE_RESPONSE 0x0CB4 #define SL_OPCODE_WLAN_CFG_SET 0x8CB5 #define SL_OPCODE_WLAN_CFG_SET_RESPONSE 0x0CB5 #define SL_OPCODE_WLAN_CFG_GET 0x8CB6 #define SL_OPCODE_WLAN_CFG_GET_RESPONSE 0x0CB6 -#define SL_OPCODE_WLAN_STA_CONNECTED 0x082E -#define SL_OPCODE_WLAN_STA_DISCONNECTED 0x082F +#define SL_OPCODE_WLAN_STA_CONNECTED 0x082E +#define SL_OPCODE_WLAN_STA_DISCONNECTED 0x082F #define SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND 0x8C67 -#define SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND_RESPONSE 0x0C67 - -#define SL_OPCODE_SOCKET_SOCKET 0x9401 -#define SL_OPCODE_SOCKET_SOCKETRESPONSE 0x1401 -#define SL_OPCODE_SOCKET_CLOSE 0x9402 -#define SL_OPCODE_SOCKET_CLOSERESPONSE 0x1402 -#define SL_OPCODE_SOCKET_ACCEPT 0x9403 -#define SL_OPCODE_SOCKET_ACCEPTRESPONSE 0x1403 -#define SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE 0x1003 -#define SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE_V6 0x1203 -#define SL_OPCODE_SOCKET_BIND 0x9404 -#define SL_OPCODE_SOCKET_BIND_V6 0x9604 -#define SL_OPCODE_SOCKET_BINDRESPONSE 0x1404 -#define SL_OPCODE_SOCKET_LISTEN 0x9405 -#define SL_OPCODE_SOCKET_LISTENRESPONSE 0x1405 -#define SL_OPCODE_SOCKET_CONNECT 0x9406 -#define SL_OPCODE_SOCKET_CONNECT_V6 0x9606 -#define SL_OPCODE_SOCKET_CONNECTRESPONSE 0x1406 -#define SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE 0x1006 -#define SL_OPCODE_SOCKET_SELECT 0x9407 -#define SL_OPCODE_SOCKET_SELECTRESPONSE 0x1407 -#define SL_OPCODE_SOCKET_SELECTASYNCRESPONSE 0x1007 -#define SL_OPCODE_SOCKET_SETSOCKOPT 0x9408 -#define SL_OPCODE_SOCKET_SETSOCKOPTRESPONSE 0x1408 -#define SL_OPCODE_SOCKET_GETSOCKOPT 0x9409 -#define SL_OPCODE_SOCKET_GETSOCKOPTRESPONSE 0x1409 -#define SL_OPCODE_SOCKET_RECV 0x940A -#define SL_OPCODE_SOCKET_RECVASYNCRESPONSE 0x100A -#define SL_OPCODE_SOCKET_RECVFROM 0x940B -#define SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE 0x100B -#define SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 0x120B -#define SL_OPCODE_SOCKET_SEND 0x940C -#define SL_OPCODE_SOCKET_SENDTO 0x940D -#define SL_OPCODE_SOCKET_SENDTO_V6 0x960D -#define SL_OPCODE_SOCKET_TXFAILEDASYNCRESPONSE 0x100E +#define SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND_RESPONSE 0x0C67 + +#define SL_OPCODE_SOCKET_SOCKET 0x9401 +#define SL_OPCODE_SOCKET_SOCKETRESPONSE 0x1401 +#define SL_OPCODE_SOCKET_CLOSE 0x9402 +#define SL_OPCODE_SOCKET_CLOSERESPONSE 0x1402 +#define SL_OPCODE_SOCKET_ACCEPT 0x9403 +#define SL_OPCODE_SOCKET_ACCEPTRESPONSE 0x1403 +#define SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE 0x1003 +#define SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE_V6 0x1203 +#define SL_OPCODE_SOCKET_BIND 0x9404 +#define SL_OPCODE_SOCKET_BIND_V6 0x9604 +#define SL_OPCODE_SOCKET_BINDRESPONSE 0x1404 +#define SL_OPCODE_SOCKET_LISTEN 0x9405 +#define SL_OPCODE_SOCKET_LISTENRESPONSE 0x1405 +#define SL_OPCODE_SOCKET_CONNECT 0x9406 +#define SL_OPCODE_SOCKET_CONNECT_V6 0x9606 +#define SL_OPCODE_SOCKET_CONNECTRESPONSE 0x1406 +#define SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE 0x1006 +#define SL_OPCODE_SOCKET_SELECT 0x9407 +#define SL_OPCODE_SOCKET_SELECTRESPONSE 0x1407 +#define SL_OPCODE_SOCKET_SELECTASYNCRESPONSE 0x1007 +#define SL_OPCODE_SOCKET_SETSOCKOPT 0x9408 +#define SL_OPCODE_SOCKET_SETSOCKOPTRESPONSE 0x1408 +#define SL_OPCODE_SOCKET_GETSOCKOPT 0x9409 +#define SL_OPCODE_SOCKET_GETSOCKOPTRESPONSE 0x1409 +#define SL_OPCODE_SOCKET_RECV 0x940A +#define SL_OPCODE_SOCKET_RECVASYNCRESPONSE 0x100A +#define SL_OPCODE_SOCKET_RECVFROM 0x940B +#define SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE 0x100B +#define SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 0x120B +#define SL_OPCODE_SOCKET_SEND 0x940C +#define SL_OPCODE_SOCKET_SENDTO 0x940D +#define SL_OPCODE_SOCKET_SENDTO_V6 0x960D +#define SL_OPCODE_SOCKET_TXFAILEDASYNCRESPONSE 0x100E #define SL_OPCODE_SOCKET_SOCKETASYNCEVENT 0x100F #define SL_OPCODE_NETAPP_START_COMMAND 0x9C0A -#define SL_OPCODE_NETAPP_START_RESPONSE 0x1C0A -#define SL_OPCODE_NETAPP_NETAPPSTARTRESPONSE 0x1C0A -#define SL_OPCODE_NETAPP_STOP_COMMAND 0x9C61 -#define SL_OPCODE_NETAPP_STOP_RESPONSE 0x1C61 -#define SL_OPCODE_NETAPP_NETAPPSET 0x9C0B -#define SL_OPCODE_NETAPP_NETAPPSETRESPONSE 0x1C0B -#define SL_OPCODE_NETAPP_NETAPPGET 0x9C27 -#define SL_OPCODE_NETAPP_NETAPPGETRESPONSE 0x1C27 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAME 0x9C20 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMERESPONSE 0x1C20 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE 0x1820 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6 0x1A20 +#define SL_OPCODE_NETAPP_START_RESPONSE 0x1C0A +#define SL_OPCODE_NETAPP_NETAPPSTARTRESPONSE 0x1C0A +#define SL_OPCODE_NETAPP_STOP_COMMAND 0x9C61 +#define SL_OPCODE_NETAPP_STOP_RESPONSE 0x1C61 +#define SL_OPCODE_NETAPP_NETAPPSET 0x9C0B +#define SL_OPCODE_NETAPP_NETAPPSETRESPONSE 0x1C0B +#define SL_OPCODE_NETAPP_NETAPPGET 0x9C27 +#define SL_OPCODE_NETAPP_NETAPPGETRESPONSE 0x1C27 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAME 0x9C20 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMERESPONSE 0x1C20 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE 0x1820 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6 0x1A20 #define SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE 0x9C71 #define SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE_RESPONSE 0x1C72 #define SL_OPCODE_NETAPP_MDNSREGISTERSERVICE 0x9C34 @@ -275,82 +276,82 @@ typedef struct #define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICERESPONSE 0x1C35 #define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE 0x1835 #define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6 0x1A35 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDR 0x9C26 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDR_V6 0x9E26 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDRRESPONSE 0x1C26 -#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDRASYNCRESPONSE 0x1826 -#define SL_OPCODE_NETAPP_PINGSTART 0x9C21 -#define SL_OPCODE_NETAPP_PINGSTART_V6 0x9E21 -#define SL_OPCODE_NETAPP_PINGSTARTRESPONSE 0x1C21 -#define SL_OPCODE_NETAPP_PINGREPORTREQUEST 0x9C22 -#define SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE 0x1822 -#define SL_OPCODE_NETAPP_PINGSTOP 0x9C23 -#define SL_OPCODE_NETAPP_PINGSTOPRESPONSE 0x1C23 -#define SL_OPCODE_NETAPP_ARPFLUSH 0x9C24 -#define SL_OPCODE_NETAPP_ARPFLUSHRESPONSE 0x1C24 -#define SL_OPCODE_NETAPP_IPACQUIRED 0x1825 -#define SL_OPCODE_NETAPP_IPV4_LOST 0x1832 -#define SL_OPCODE_NETAPP_DHCP_IPV4_ACQUIRE_TIMEOUT 0x1833 -#define SL_OPCODE_NETAPP_IPACQUIRED_V6 0x1A25 -#define SL_OPCODE_NETAPP_IPERFSTARTCOMMAND 0x9C28 -#define SL_OPCODE_NETAPP_IPERFSTARTRESPONSE 0x1C28 -#define SL_OPCODE_NETAPP_IPERFSTOPCOMMAND 0x9C29 -#define SL_OPCODE_NETAPP_IPERFSTOPRESPONSE 0x1C29 -#define SL_OPCODE_NETAPP_CTESTSTARTCOMMAND 0x9C2A -#define SL_OPCODE_NETAPP_CTESTSTARTRESPONSE 0x1C2A -#define SL_OPCODE_NETAPP_CTESTASYNCRESPONSE 0x182A -#define SL_OPCODE_NETAPP_CTESTSTOPCOMMAND 0x9C2B -#define SL_OPCODE_NETAPP_CTESTSTOPRESPONSE 0x1C2B -#define SL_OPCODE_NETAPP_IP_LEASED 0x182C -#define SL_OPCODE_NETAPP_IP_RELEASED 0x182D -#define SL_OPCODE_NETAPP_HTTPGETTOKENVALUE 0x182E -#define SL_OPCODE_NETAPP_HTTPSENDTOKENVALUE 0x9C2F -#define SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE 0x1830 -#define SL_OPCODE_NVMEM_FILEOPEN 0xA43C -#define SL_OPCODE_NVMEM_FILEOPENRESPONSE 0x243C -#define SL_OPCODE_NVMEM_FILECLOSE 0xA43D -#define SL_OPCODE_NVMEM_FILECLOSERESPONSE 0x243D -#define SL_OPCODE_NVMEM_FILEREADCOMMAND 0xA440 -#define SL_OPCODE_NVMEM_FILEREADRESPONSE 0x2440 -#define SL_OPCODE_NVMEM_FILEWRITECOMMAND 0xA441 -#define SL_OPCODE_NVMEM_FILEWRITERESPONSE 0x2441 -#define SL_OPCODE_NVMEM_FILEGETINFOCOMMAND 0xA442 -#define SL_OPCODE_NVMEM_FILEGETINFORESPONSE 0x2442 -#define SL_OPCODE_NVMEM_FILEDELCOMMAND 0xA443 -#define SL_OPCODE_NVMEM_FILEDELRESPONSE 0x2443 -#define SL_OPCODE_NVMEM_NVMEMFORMATCOMMAND 0xA444 -#define SL_OPCODE_NVMEM_NVMEMFORMATRESPONSE 0x2444 - -#define SL_OPCODE_DEVICE_SETDEBUGLEVELCOMMAND 0x846A -#define SL_OPCODE_DEVICE_SETDEBUGLEVELRESPONSE 0x046A - -#define SL_OPCODE_DEVICE_NETCFG_SET_COMMAND 0x8432 -#define SL_OPCODE_DEVICE_NETCFG_SET_RESPONSE 0x0432 -#define SL_OPCODE_DEVICE_NETCFG_GET_COMMAND 0x8433 -#define SL_OPCODE_DEVICE_NETCFG_GET_RESPONSE 0x0433 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDR 0x9C26 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDR_V6 0x9E26 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDRRESPONSE 0x1C26 +#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDRASYNCRESPONSE 0x1826 +#define SL_OPCODE_NETAPP_PINGSTART 0x9C21 +#define SL_OPCODE_NETAPP_PINGSTART_V6 0x9E21 +#define SL_OPCODE_NETAPP_PINGSTARTRESPONSE 0x1C21 +#define SL_OPCODE_NETAPP_PINGREPORTREQUEST 0x9C22 +#define SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE 0x1822 +#define SL_OPCODE_NETAPP_PINGSTOP 0x9C23 +#define SL_OPCODE_NETAPP_PINGSTOPRESPONSE 0x1C23 +#define SL_OPCODE_NETAPP_ARPFLUSH 0x9C24 +#define SL_OPCODE_NETAPP_ARPFLUSHRESPONSE 0x1C24 +#define SL_OPCODE_NETAPP_IPACQUIRED 0x1825 +#define SL_OPCODE_NETAPP_IPV4_LOST 0x1832 +#define SL_OPCODE_NETAPP_DHCP_IPV4_ACQUIRE_TIMEOUT 0x1833 +#define SL_OPCODE_NETAPP_IPACQUIRED_V6 0x1A25 +#define SL_OPCODE_NETAPP_IPERFSTARTCOMMAND 0x9C28 +#define SL_OPCODE_NETAPP_IPERFSTARTRESPONSE 0x1C28 +#define SL_OPCODE_NETAPP_IPERFSTOPCOMMAND 0x9C29 +#define SL_OPCODE_NETAPP_IPERFSTOPRESPONSE 0x1C29 +#define SL_OPCODE_NETAPP_CTESTSTARTCOMMAND 0x9C2A +#define SL_OPCODE_NETAPP_CTESTSTARTRESPONSE 0x1C2A +#define SL_OPCODE_NETAPP_CTESTASYNCRESPONSE 0x182A +#define SL_OPCODE_NETAPP_CTESTSTOPCOMMAND 0x9C2B +#define SL_OPCODE_NETAPP_CTESTSTOPRESPONSE 0x1C2B +#define SL_OPCODE_NETAPP_IP_LEASED 0x182C +#define SL_OPCODE_NETAPP_IP_RELEASED 0x182D +#define SL_OPCODE_NETAPP_HTTPGETTOKENVALUE 0x182E +#define SL_OPCODE_NETAPP_HTTPSENDTOKENVALUE 0x9C2F +#define SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE 0x1830 +#define SL_OPCODE_NVMEM_FILEOPEN 0xA43C +#define SL_OPCODE_NVMEM_FILEOPENRESPONSE 0x243C +#define SL_OPCODE_NVMEM_FILECLOSE 0xA43D +#define SL_OPCODE_NVMEM_FILECLOSERESPONSE 0x243D +#define SL_OPCODE_NVMEM_FILEREADCOMMAND 0xA440 +#define SL_OPCODE_NVMEM_FILEREADRESPONSE 0x2440 +#define SL_OPCODE_NVMEM_FILEWRITECOMMAND 0xA441 +#define SL_OPCODE_NVMEM_FILEWRITERESPONSE 0x2441 +#define SL_OPCODE_NVMEM_FILEGETINFOCOMMAND 0xA442 +#define SL_OPCODE_NVMEM_FILEGETINFORESPONSE 0x2442 +#define SL_OPCODE_NVMEM_FILEDELCOMMAND 0xA443 +#define SL_OPCODE_NVMEM_FILEDELRESPONSE 0x2443 +#define SL_OPCODE_NVMEM_NVMEMFORMATCOMMAND 0xA444 +#define SL_OPCODE_NVMEM_NVMEMFORMATRESPONSE 0x2444 + +#define SL_OPCODE_DEVICE_SETDEBUGLEVELCOMMAND 0x846A +#define SL_OPCODE_DEVICE_SETDEBUGLEVELRESPONSE 0x046A + +#define SL_OPCODE_DEVICE_NETCFG_SET_COMMAND 0x8432 +#define SL_OPCODE_DEVICE_NETCFG_SET_RESPONSE 0x0432 +#define SL_OPCODE_DEVICE_NETCFG_GET_COMMAND 0x8433 +#define SL_OPCODE_DEVICE_NETCFG_GET_RESPONSE 0x0433 /* */ -#define SL_OPCODE_DEVICE_SETUARTMODECOMMAND 0x846B -#define SL_OPCODE_DEVICE_SETUARTMODERESPONSE 0x046B -#define SL_OPCODE_DEVICE_SSISIZESETCOMMAND 0x846B -#define SL_OPCODE_DEVICE_SSISIZESETRESPONSE 0x046B +#define SL_OPCODE_DEVICE_SETUARTMODECOMMAND 0x846B +#define SL_OPCODE_DEVICE_SETUARTMODERESPONSE 0x046B +#define SL_OPCODE_DEVICE_SSISIZESETCOMMAND 0x846B +#define SL_OPCODE_DEVICE_SSISIZESETRESPONSE 0x046B /* */ -#define SL_OPCODE_DEVICE_EVENTMASKSET 0x8464 -#define SL_OPCODE_DEVICE_EVENTMASKSETRESPONSE 0x0464 -#define SL_OPCODE_DEVICE_EVENTMASKGET 0x8465 -#define SL_OPCODE_DEVICE_EVENTMASKGETRESPONSE 0x0465 +#define SL_OPCODE_DEVICE_EVENTMASKSET 0x8464 +#define SL_OPCODE_DEVICE_EVENTMASKSETRESPONSE 0x0464 +#define SL_OPCODE_DEVICE_EVENTMASKGET 0x8465 +#define SL_OPCODE_DEVICE_EVENTMASKGETRESPONSE 0x0465 -#define SL_OPCODE_DEVICE_DEVICEGET 0x8466 +#define SL_OPCODE_DEVICE_DEVICEGET 0x8466 #define SL_OPCODE_DEVICE_DEVICEGETRESPONSE 0x0466 -#define SL_OPCODE_DEVICE_DEVICESET 0x84B7 -#define SL_OPCODE_DEVICE_DEVICESETRESPONSE 0x04B7 +#define SL_OPCODE_DEVICE_DEVICESET 0x84B7 +#define SL_OPCODE_DEVICE_DEVICESETRESPONSE 0x04B7 -#define SL_OPCODE_WLAN_SCANRESULTSGETCOMMAND 0x8C8C -#define SL_OPCODE_WLAN_SCANRESULTSGETRESPONSE 0x0C8C -#define SL_OPCODE_WLAN_SMARTCONFIGOPTSET 0x8C8D -#define SL_OPCODE_WLAN_SMARTCONFIGOPTSETRESPONSE 0x0C8D -#define SL_OPCODE_WLAN_SMARTCONFIGOPTGET 0x8C8E -#define SL_OPCODE_WLAN_SMARTCONFIGOPTGETRESPONSE 0x0C8E +#define SL_OPCODE_WLAN_SCANRESULTSGETCOMMAND 0x8C8C +#define SL_OPCODE_WLAN_SCANRESULTSGETRESPONSE 0x0C8C +#define SL_OPCODE_WLAN_SMARTCONFIGOPTSET 0x8C8D +#define SL_OPCODE_WLAN_SMARTCONFIGOPTSETRESPONSE 0x0C8D +#define SL_OPCODE_WLAN_SMARTCONFIGOPTGET 0x8C8E +#define SL_OPCODE_WLAN_SMARTCONFIGOPTGETRESPONSE 0x0C8E /* Rx Filters opcodes */ @@ -442,8 +443,8 @@ typedef struct typedef struct { - _u32 BaudRate; - _u8 FlowControlEnable; + _u32 BaudRate; + _u8 FlowControlEnable; }_DevUartSetModeCommand_t; typedef _BasicResponse_t _DevUartSetModeResponse_t; @@ -459,24 +460,24 @@ typedef struct /*****************************************************************************************/ /* WLAN structs */ /*****************************************************************************************/ -#define MAXIMAL_PASSWORD_LENGTH (64) +#define MAXIMAL_PASSWORD_LENGTH (64) typedef struct{ - _u8 SecType; - _u8 SsidLen; - _u8 Bssid[6]; - _u8 PasswordLen; + _u8 SecType; + _u8 SsidLen; + _u8 Bssid[6]; + _u8 PasswordLen; }_WlanConnectCommon_t; #define SSID_STRING(pCmd) (_i8 *)((_WlanConnectCommon_t *)(pCmd) + 1) #define PASSWORD_STRING(pCmd) (SSID_STRING(pCmd) + ((_WlanConnectCommon_t *)(pCmd))->SsidLen) typedef struct{ - _WlanConnectCommon_t Common; - _u8 UserLen; - _u8 AnonUserLen; - _u8 CertIndex; - _u32 EapBitmask; + _WlanConnectCommon_t Common; + _u8 UserLen; + _u8 AnonUserLen; + _u8 CertIndex; + _u32 EapBitmask; }_WlanConnectEapCommand_t; #define EAP_SSID_STRING(pCmd) (_i8 *)((_WlanConnectEapCommand_t *)(pCmd) + 1) @@ -487,30 +488,30 @@ typedef struct{ typedef struct { - _u8 PolicyType; + _u8 PolicyType; _u8 Padding; - _u8 PolicyOption; - _u8 PolicyOptionLen; + _u8 PolicyOption; + _u8 PolicyOptionLen; }_WlanPoliciySetGet_t; typedef struct{ - _u32 minDwellTime; - _u32 maxDwellTime; - _u32 numProbeResponse; - _u32 G_Channels_mask; - _i32 rssiThershold; - _i32 snrThershold; - _i32 defaultTXPower; - _u16 intervalList[16]; + _u32 minDwellTime; + _u32 maxDwellTime; + _u32 numProbeResponse; + _u32 G_Channels_mask; + _i32 rssiThershold; + _i32 snrThershold; + _i32 defaultTXPower; + _u16 intervalList[16]; }_WlanScanParamSetCommand_t; typedef struct{ - _i8 SecType; - _u8 SsidLen; - _u8 Priority; - _u8 Bssid[6]; + _i8 SecType; + _u8 SsidLen; + _u8 Priority; + _u8 Bssid[6]; _u8 PasswordLen; _u8 WepKeyId; }_WlanAddGetProfile_t; @@ -540,17 +541,17 @@ typedef struct{ typedef struct { - _u8 index; - _u8 padding[3]; + _u8 index; + _u8 padding[3]; }_WlanProfileDelGetCommand_t; typedef _BasicResponse_t _WlanGetNetworkListResponse_t; typedef struct { - _u8 index; - _u8 count; - _i8 padding[2]; + _u8 index; + _u8 count; + _i8 padding[2]; }_WlanGetNetworkListCommand_t; @@ -558,7 +559,7 @@ typedef struct typedef struct { - _u32 groupIdBitmask; + _u32 groupIdBitmask; _u8 cipher; _u8 publicKeyLen; _u8 group1KeyLen; @@ -571,9 +572,9 @@ typedef struct -typedef struct +typedef struct { - _u8 mode; + _u8 mode; _u8 padding[3]; }_WlanSetMode_t; @@ -595,20 +596,20 @@ typedef struct /* -- 80 bytes */ typedef struct _WlanRxFilterAddCommand_t { - /* -- 1 byte */ - SlrxFilterRuleType_t RuleType; - /* -- 1 byte */ - SlrxFilterFlags_t FilterFlags; - /* -- 1 byte */ - SlrxFilterID_t FilterId; - /* -- 1 byte */ - _u8 Padding; - /* -- 56 byte */ - SlrxFilterRule_t Rule; - /* -- 12 byte ( 3 padding ) */ - SlrxFilterTrigger_t Trigger; - /* -- 8 byte */ - SlrxFilterAction_t Action; + /* -- 1 byte */ + SlrxFilterRuleType_t RuleType; + /* -- 1 byte */ + SlrxFilterFlags_t FilterFlags; + /* -- 1 byte */ + SlrxFilterID_t FilterId; + /* -- 1 byte */ + _u8 Padding; + /* -- 56 byte */ + SlrxFilterRule_t Rule; + /* -- 12 byte ( 3 padding ) */ + SlrxFilterTrigger_t Trigger; + /* -- 8 byte */ + SlrxFilterAction_t Action; }_WlanRxFilterAddCommand_t; @@ -616,12 +617,12 @@ typedef struct _WlanRxFilterAddCommand_t /* -- 4 bytes */ typedef struct l_WlanRxFilterAddCommandReponse_t { - /* -- 1 byte */ - SlrxFilterID_t FilterId; - /* -- 1 Byte */ - _u8 Status; - /* -- 2 byte */ - _u8 Padding[2]; + /* -- 1 byte */ + SlrxFilterID_t FilterId; + /* -- 1 Byte */ + _u8 Status; + /* -- 2 byte */ + _u8 Padding[2]; }_WlanRxFilterAddCommandReponse_t; @@ -632,10 +633,10 @@ typedef struct l_WlanRxFilterAddCommandReponse_t */ typedef struct _WlanRxFilterSetCommand_t { - _u16 InputBufferLength; - /* 1 byte */ - SLrxFilterOperation_t RxFilterOperation; - _u8 Padding[1]; + _u16 InputBufferLength; + /* 1 byte */ + SLrxFilterOperation_t RxFilterOperation; + _u8 Padding[1]; }_WlanRxFilterSetCommand_t; /** @@ -643,10 +644,10 @@ typedef struct _WlanRxFilterSetCommand_t */ typedef struct _WlanRxFilterSetCommandReponse_t { - /* 1 byte */ - _u8 Status; - /* 3 bytes */ - _u8 Padding[3]; + /* 1 byte */ + _u8 Status; + /* 3 bytes */ + _u8 Padding[3]; }_WlanRxFilterSetCommandReponse_t; @@ -655,10 +656,10 @@ typedef struct _WlanRxFilterSetCommandReponse_t */ typedef struct _WlanRxFilterGetCommand_t { - _u16 OutputBufferLength; - /* 1 byte */ - SLrxFilterOperation_t RxFilterOperation; - _u8 Padding[1]; + _u16 OutputBufferLength; + /* 1 byte */ + SLrxFilterOperation_t RxFilterOperation; + _u8 Padding[1]; }_WlanRxFilterGetCommand_t; /** @@ -666,12 +667,12 @@ typedef struct _WlanRxFilterGetCommand_t */ typedef struct _WlanRxFilterGetCommandReponse_t { - /* 1 byte */ - _u8 Status; - /* 1 bytes */ - _u8 Padding; - /* 2 byte */ - _u16 OutputBufferLength; + /* 1 byte */ + _u8 Status; + /* 1 bytes */ + _u8 Padding; + /* 2 byte */ + _u16 OutputBufferLength; }_WlanRxFilterGetCommandReponse_t; @@ -702,8 +703,8 @@ typedef struct _u8 ipV4Mask[4]; _u8 ipV4Gateway[4]; _u8 ipV4DnsServer[4]; - _u8 ipV4Start[4]; - _u8 ipV4End[4]; + _u8 ipV4Start[4]; + _u8 ipV4End[4]; }_NetCfgIpV4AP_Args_t; @@ -718,17 +719,17 @@ typedef struct typedef struct { _u16 Status; - _u16 ConfigId; - _u16 ConfigOpt; - _u16 ConfigLen; + _u16 ConfigId; + _u16 ConfigOpt; + _u16 ConfigLen; }_NetCfgSetGet_t; typedef struct { - _u16 Status; - _u16 DeviceSetId; - _u16 Option; - _u16 ConfigLen; + _u16 Status; + _u16 DeviceSetId; + _u16 Option; + _u16 ConfigLen; }_DeviceSetGet_t; @@ -921,9 +922,9 @@ typedef struct typedef struct { _u16 Status; - _u16 AppId; - _u16 ConfigOpt; - _u16 ConfigLen; + _u16 AppId; + _u16 ConfigOpt; + _u16 ConfigLen; }_NetAppSetGet_t; typedef struct { @@ -937,25 +938,25 @@ typedef struct typedef struct _sl_NetAppHttpServerGetToken_t { - _u8 token_name_len; - _u8 padd1; - _u16 padd2; + _u8 token_name_len; + _u8 padd1; + _u16 padd2; }sl_NetAppHttpServerGetToken_t; typedef struct _sl_NetAppHttpServerSendToken_t { - _u8 token_value_len; - _u8 token_name_len; - _u8 token_name[MAX_TOKEN_NAME_LEN]; - _u16 padd; + _u8 token_value_len; + _u8 token_name_len; + _u8 token_name[MAX_TOKEN_NAME_LEN]; + _u16 padd; }sl_NetAppHttpServerSendToken_t; typedef struct _sl_NetAppHttpServerPostToken_t { - _u8 post_action_len; - _u8 token_name_len; - _u8 token_value_len; - _u8 padding; + _u8 post_action_len; + _u8 token_name_len; + _u8 token_value_len; + _u8 padding; }sl_NetAppHttpServerPostToken_t; @@ -1096,8 +1097,8 @@ typedef struct { _u32 FileHandle; _u32 Offset; - _u16 Len; - _u16 Padding; + _u16 Len; + _u16 Padding; }_FsReadCommand_t; typedef struct @@ -1106,7 +1107,7 @@ typedef struct _u32 Token; }_FsOpenCommand_t; -typedef struct +typedef struct { _u32 FileHandle; _u32 Token; @@ -1176,7 +1177,7 @@ typedef _BasicResponse_t _FsWriteResponse_t; #define RECVFROM_IPV4_ARGS_SIZE (sizeof(_SocketAddrAsyncIPv4Response_t)) #define RECVFROM_IPV6_ARGS_SIZE (sizeof(_SocketAddrAsyncIPv6Response_t)) -#define SL_IPV4_ADDRESS_SIZE (sizeof(_u32)) -#define SL_IPV6_ADDRESS_SIZE (4 * sizeof(_u32)) +#define SL_IPV4_ADDRESS_SIZE (sizeof(_u32)) +#define SL_IPV6_ADDRESS_SIZE (4 * sizeof(_u32)) #endif /* _SL_PROTOCOL_TYPES_H_ */ diff --git a/hardware/lm4f/libraries/WiFi/utility/simplelink.h b/hardware/lm4f/libraries/WiFi/utility/simplelink.h index 1a0f4357265..c8108e7ed1d 100644 --- a/hardware/lm4f/libraries/WiFi/utility/simplelink.h +++ b/hardware/lm4f/libraries/WiFi/utility/simplelink.h @@ -1,35 +1,35 @@ /* * simplelink.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -52,7 +52,7 @@ \section modules_sec Module Names - To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo). + To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo). These capabilities range from basic device management through wireless network configuration, standard BSD socket and much more. Listed below are the various modules in the SimpleLink CC31xx/CC32xx driver: @@ -60,7 +60,7 @@ -# \ref wlan - controls the use of the WiFi WLAN module including: - Connection features, such as: profiles, policies, SmartConfig™ - Advanced WLAN features, such as: scans, rx filters and rx statistics collection - -# \ref socket - controls standard client/server sockets programming options and capabilities + -# \ref socket - controls standard client/server sockets programming options and capabilities -# \ref netapp - activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS. -# \ref netcfg - controls the configuration of the device addresses (i.e. IP and MAC addresses) -# \ref FileSystem - provides file system capabilities to TI's CC31XX that can be used by both the CC31XX device and the user. @@ -178,44 +178,57 @@ * * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - - + + #ifndef __SIMPLELINK_H__ #define __SIMPLELINK_H__ +/* define the default types + * If user wants to overwrite it, + * he need to undef and define again */ +#define _u8 unsigned char +#define _i8 signed char +#define _u16 unsigned short +#define _i16 signed short +#define _u32 unsigned long +#define _i32 signed long + +#define _volatile volatile +#define _const const + #include "user.h" #ifdef __cplusplus @@ -225,17 +238,17 @@ extern "C" /*! \attention Async event activation notes - Function prototypes for event callback handlers - Event handler function names should be defined in the user.h file - e.g. - "#define sl_WlanEvtHdlr SLWlanEventHandler" - Indicates all WLAN events are handled by User func "SLWlanEventHandler" - Important notes: - 1. Event handlers cannot activate another SimpleLink API from the event's context - 2. Event's data is valid during event's context. Any application data - which is required for the user application should be copied or marked - into user's variables - 3. It is not recommended to delay the execution of the event callback handler + Function prototypes for event callback handlers + Event handler function names should be defined in the user.h file + e.g. + "#define sl_WlanEvtHdlr SLWlanEventHandler" + Indicates all WLAN events are handled by User func "SLWlanEventHandler" + Important notes: + 1. Event handlers cannot activate another SimpleLink API from the event's context + 2. Event's data is valid during event's context. Any application data + which is required for the user application should be copied or marked + into user's variables + 3. It is not recommended to delay the execution of the event callback handler */ @@ -250,11 +263,11 @@ extern "C" /*****************************************************************************/ /* Macro declarations for Host Driver version */ /*****************************************************************************/ -#define SL_DRIVER_VERSION "1.0.0.10" +#define SL_DRIVER_VERSION "1.0.1.6" #define SL_MAJOR_VERSION_NUM 1L #define SL_MINOR_VERSION_NUM 0L -#define SL_VERSION_NUM 0L -#define SL_SUB_VERSION_NUM 10L +#define SL_VERSION_NUM 1L +#define SL_SUB_VERSION_NUM 6L /*****************************************************************************/ @@ -310,29 +323,29 @@ extern "C" #define SL_INC_SET_UART_MODE #endif -#define SL_RET_CODE_OK (0) -#define SL_RET_CODE_INVALID_INPUT (-2) -#define SL_RET_CODE_SELF_ERROR (-3) -#define SL_RET_CODE_NWP_IF_ERROR (-4) -#define SL_RET_CODE_MALLOC_ERROR (-5) +#define SL_RET_CODE_OK (0) +#define SL_RET_CODE_INVALID_INPUT (-2) +#define SL_RET_CODE_SELF_ERROR (-3) +#define SL_RET_CODE_NWP_IF_ERROR (-4) +#define SL_RET_CODE_MALLOC_ERROR (-5) +#define SL_RET_CODE_ABORT (-6) +#define SL_RET_CODE_PROTOCOL_ERROR (-7) -#define sl_Memcpy memcpy -#define sl_Memset memset -#define sl_SyncObjClear(pObj) sl_SyncObjWait(pObj,SL_OS_NO_WAIT) +/* #define sl_Memcpy memcpy */ +#define sl_Memset(addr, val, len) memset(addr, val, (size_t)len) +#define sl_Memcpy(dest, src, len) memcpy(dest, src, (size_t)len) #ifndef SL_TINY_EXT -#define SL_MAX_SOCKETS (8) +#define SL_MAX_SOCKETS (_u8)(8) #else -#define SL_MAX_SOCKETS (2) +#define SL_MAX_SOCKETS (_u8)(2) #endif - - /*****************************************************************************/ /* Types definitions */ -/*****************************************************************************/ +/*****************************************************************************/ #ifndef NULL #define NULL (0) @@ -350,19 +363,6 @@ extern "C" #define OK (0) #endif -#ifndef _SL_USER_TYPES - typedef unsigned char _u8; - typedef signed char _i8; - - typedef unsigned short _u16; - typedef signed short _i16; - - typedef unsigned long _u32; - typedef signed long _i32; - #define _volatile volatile - #define _const const -#endif - typedef _u16 _SlOpcode_t; typedef _u8 _SlArgSize_t; typedef _i16 _SlDataSize_t; @@ -381,8 +381,8 @@ typedef _i16 _SlReturnVal_t; */ typedef enum { - EVENT_PROPAGATION_BLOCK = 0, - EVENT_PROPAGATION_CONTINUE + EVENT_PROPAGATION_BLOCK = 0, + EVENT_PROPAGATION_CONTINUE } _SlEventPropogationStatus_e; @@ -396,10 +396,10 @@ typedef _i16 _SlReturnVal_t; /*****************************************************************************/ -/* - objInclusion.h and user.h must be included before all api header files - objInclusion.h must be the last arrangement just before including the API header files - since it based on the other configurations to decide which object should be included +/* + objInclusion.h and user.h must be included before all api header files + objInclusion.h must be the last arrangement just before including the API header files + since it based on the other configurations to decide which object should be included */ #include "objInclusion.h" #include "trace.h" @@ -443,13 +443,11 @@ typedef _i16 _SlReturnVal_t; #endif - #ifndef __CONCAT -#define __CONCAT(x,y) x ## y -#define __CONCAT2(x,y) __CONCAT(x,y) +#define __CONCAT(x,y) x ## y +#define __CONCAT2(x,y) __CONCAT(x,y) #endif - /* * The section below handles the external lib event registration * according to the desired events it specified in its API header file. @@ -458,49 +456,49 @@ typedef _i16 _SlReturnVal_t; #ifdef SL_EXT_LIB_1 /* General Event Registration */ - #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_GENERAL_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) (SlDeviceEvent_t *); - #define SlExtLib1GeneralEventHandler __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) + #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_GENERAL_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) (SlDeviceEvent_t *); + #define SlExtLib1GeneralEventHandler __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) - #undef EXT_LIB_REGISTERED_GENERAL_EVENTS + #undef EXT_LIB_REGISTERED_GENERAL_EVENTS #define EXT_LIB_REGISTERED_GENERAL_EVENTS - #endif + #endif - /* Wlan Event Registration */ - #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_WLAN_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) (SlWlanEvent_t *); - #define SlExtLib1WlanEventHandler __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) + /* Wlan Event Registration */ + #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_WLAN_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) (SlWlanEvent_t *); + #define SlExtLib1WlanEventHandler __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) - #undef EXT_LIB_REGISTERED_WLAN_EVENTS + #undef EXT_LIB_REGISTERED_WLAN_EVENTS #define EXT_LIB_REGISTERED_WLAN_EVENTS - #endif + #endif - /* NetApp Event Registration */ - #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) (SlNetAppEvent_t *); - #define SlExtLib1NetAppEventHandler __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) + /* NetApp Event Registration */ + #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) (SlNetAppEvent_t *); + #define SlExtLib1NetAppEventHandler __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) - #undef EXT_LIB_REGISTERED_NETAPP_EVENTS + #undef EXT_LIB_REGISTERED_NETAPP_EVENTS #define EXT_LIB_REGISTERED_NETAPP_EVENTS - #endif + #endif - /* Http Server Event Registration */ - #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_HTTP_SERVER_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); - #define SlExtLib1HttpServerEventHandler __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) + /* Http Server Event Registration */ + #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_HTTP_SERVER_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); + #define SlExtLib1HttpServerEventHandler __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) - #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS + #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS - #endif + #endif - /* Socket Event Registration */ - #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_SOCK_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) (SlSockEvent_t *); - #define SlExtLib1SockEventHandler __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) + /* Socket Event Registration */ + #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_SOCK_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) (SlSockEvent_t *); + #define SlExtLib1SockEventHandler __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) - #undef EXT_LIB_REGISTERED_SOCK_EVENTS + #undef EXT_LIB_REGISTERED_SOCK_EVENTS #define EXT_LIB_REGISTERED_SOCK_EVENTS - #endif + #endif #endif @@ -508,49 +506,49 @@ typedef _i16 _SlReturnVal_t; #ifdef SL_EXT_LIB_2 /* General Event Registration */ - #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_GENERAL_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) (SlDeviceEvent_t *); - #define SlExtLib2GeneralEventHandler __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) + #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_GENERAL_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) (SlDeviceEvent_t *); + #define SlExtLib2GeneralEventHandler __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) - #undef EXT_LIB_REGISTERED_GENERAL_EVENTS + #undef EXT_LIB_REGISTERED_GENERAL_EVENTS #define EXT_LIB_REGISTERED_GENERAL_EVENTS - #endif + #endif - /* Wlan Event Registration */ - #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_WLAN_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) (SlWlanEvent_t *); - #define SlExtLib2WlanEventHandler __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) + /* Wlan Event Registration */ + #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_WLAN_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) (SlWlanEvent_t *); + #define SlExtLib2WlanEventHandler __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) - #undef EXT_LIB_REGISTERED_WLAN_EVENTS + #undef EXT_LIB_REGISTERED_WLAN_EVENTS #define EXT_LIB_REGISTERED_WLAN_EVENTS - #endif + #endif - /* NetApp Event Registration */ - #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) (SlNetAppEvent_t *); - #define SlExtLib2NetAppEventHandler __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) + /* NetApp Event Registration */ + #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) (SlNetAppEvent_t *); + #define SlExtLib2NetAppEventHandler __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) - #undef EXT_LIB_REGISTERED_NETAPP_EVENTS + #undef EXT_LIB_REGISTERED_NETAPP_EVENTS #define EXT_LIB_REGISTERED_NETAPP_EVENTS - #endif + #endif - /* Http Server Event Registration */ - #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_HTTP_SERVER_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); - #define SlExtLib2HttpServerEventHandler __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) + /* Http Server Event Registration */ + #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_HTTP_SERVER_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); + #define SlExtLib2HttpServerEventHandler __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) - #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS + #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS - #endif + #endif - /* Socket Event Registration */ - #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_SOCK_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) (SlSockEvent_t *); - #define SlExtLib2SockEventHandler __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) + /* Socket Event Registration */ + #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_SOCK_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) (SlSockEvent_t *); + #define SlExtLib2SockEventHandler __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) - #undef EXT_LIB_REGISTERED_SOCK_EVENTS + #undef EXT_LIB_REGISTERED_SOCK_EVENTS #define EXT_LIB_REGISTERED_SOCK_EVENTS - #endif + #endif #endif @@ -558,49 +556,49 @@ typedef _i16 _SlReturnVal_t; #ifdef SL_EXT_LIB_3 /* General Event Registration */ - #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_GENERAL_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) (SlDeviceEvent_t *); - #define SlExtLib3GeneralEventHandler __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) + #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_GENERAL_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) (SlDeviceEvent_t *); + #define SlExtLib3GeneralEventHandler __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) - #undef EXT_LIB_REGISTERED_GENERAL_EVENTS + #undef EXT_LIB_REGISTERED_GENERAL_EVENTS #define EXT_LIB_REGISTERED_GENERAL_EVENTS - #endif + #endif - /* Wlan Event Registration */ - #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_WLAN_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) (SlWlanEvent_t *); - #define SlExtLib3WlanEventHandler __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) + /* Wlan Event Registration */ + #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_WLAN_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) (SlWlanEvent_t *); + #define SlExtLib3WlanEventHandler __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) - #undef EXT_LIB_REGISTERED_WLAN_EVENTS + #undef EXT_LIB_REGISTERED_WLAN_EVENTS #define EXT_LIB_REGISTERED_WLAN_EVENTS - #endif + #endif - /* NetApp Event Registration */ - #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) (SlNetAppEvent_t *); - #define SlExtLib3NetAppEventHandler __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) + /* NetApp Event Registration */ + #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) (SlNetAppEvent_t *); + #define SlExtLib3NetAppEventHandler __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) - #undef EXT_LIB_REGISTERED_NETAPP_EVENTS + #undef EXT_LIB_REGISTERED_NETAPP_EVENTS #define EXT_LIB_REGISTERED_NETAPP_EVENTS - #endif + #endif - /* Http Server Event Registration */ - #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_HTTP_SERVER_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); - #define SlExtLib3HttpServerEventHandler __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) + /* Http Server Event Registration */ + #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_HTTP_SERVER_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); + #define SlExtLib3HttpServerEventHandler __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) - #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS + #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS - #endif + #endif - /* Socket Event Registration */ - #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_SOCK_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) (SlSockEvent_t *); - #define SlExtLib3SockEventHandler __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) + /* Socket Event Registration */ + #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_SOCK_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) (SlSockEvent_t *); + #define SlExtLib3SockEventHandler __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) - #undef EXT_LIB_REGISTERED_SOCK_EVENTS + #undef EXT_LIB_REGISTERED_SOCK_EVENTS #define EXT_LIB_REGISTERED_SOCK_EVENTS - #endif + #endif #endif @@ -608,49 +606,49 @@ typedef _i16 _SlReturnVal_t; #ifdef SL_EXT_LIB_4 /* General Event Registration */ - #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_GENERAL_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) (SlDeviceEvent_t *); - #define SlExtLib4GeneralEventHandler __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) + #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_GENERAL_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) (SlDeviceEvent_t *); + #define SlExtLib4GeneralEventHandler __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) - #undef EXT_LIB_REGISTERED_GENERAL_EVENTS + #undef EXT_LIB_REGISTERED_GENERAL_EVENTS #define EXT_LIB_REGISTERED_GENERAL_EVENTS - #endif + #endif - /* Wlan Event Registration */ - #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_WLAN_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) (SlWlanEvent_t *); - #define SlExtLib4WlanEventHandler __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) + /* Wlan Event Registration */ + #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_WLAN_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) (SlWlanEvent_t *); + #define SlExtLib4WlanEventHandler __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) - #undef EXT_LIB_REGISTERED_WLAN_EVENTS + #undef EXT_LIB_REGISTERED_WLAN_EVENTS #define EXT_LIB_REGISTERED_WLAN_EVENTS - #endif + #endif - /* NetApp Event Registration */ - #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) (SlNetAppEvent_t *); - #define SlExtLib4NetAppEventHandler __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) + /* NetApp Event Registration */ + #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) (SlNetAppEvent_t *); + #define SlExtLib4NetAppEventHandler __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) - #undef EXT_LIB_REGISTERED_NETAPP_EVENTS + #undef EXT_LIB_REGISTERED_NETAPP_EVENTS #define EXT_LIB_REGISTERED_NETAPP_EVENTS - #endif + #endif - /* Http Server Event Registration */ - #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_HTTP_SERVER_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); - #define SlExtLib4HttpServerEventHandler __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) + /* Http Server Event Registration */ + #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_HTTP_SERVER_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); + #define SlExtLib4HttpServerEventHandler __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) - #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS + #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS - #endif + #endif - /* Socket Event Registration */ - #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_SOCK_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) (SlSockEvent_t *); - #define SlExtLib4SockEventHandler __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) + /* Socket Event Registration */ + #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_SOCK_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) (SlSockEvent_t *); + #define SlExtLib4SockEventHandler __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) - #undef EXT_LIB_REGISTERED_SOCK_EVENTS + #undef EXT_LIB_REGISTERED_SOCK_EVENTS #define EXT_LIB_REGISTERED_SOCK_EVENTS - #endif + #endif #endif @@ -658,49 +656,49 @@ typedef _i16 _SlReturnVal_t; #ifdef SL_EXT_LIB_5 /* General Event Registration */ - #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_GENERAL_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) (SlDeviceEvent_t *); - #define SlExtLib5GeneralEventHandler __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) + #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_GENERAL_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) (SlDeviceEvent_t *); + #define SlExtLib5GeneralEventHandler __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) - #undef EXT_LIB_REGISTERED_GENERAL_EVENTS + #undef EXT_LIB_REGISTERED_GENERAL_EVENTS #define EXT_LIB_REGISTERED_GENERAL_EVENTS - #endif + #endif - /* Wlan Event Registration */ - #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_WLAN_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) (SlWlanEvent_t *); - #define SlExtLib5WlanEventHandler __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) + /* Wlan Event Registration */ + #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_WLAN_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) (SlWlanEvent_t *); + #define SlExtLib5WlanEventHandler __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) - #undef EXT_LIB_REGISTERED_WLAN_EVENTS + #undef EXT_LIB_REGISTERED_WLAN_EVENTS #define EXT_LIB_REGISTERED_WLAN_EVENTS - #endif + #endif - /* NetApp Event Registration */ - #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) (SlNetAppEvent_t *); - #define SlExtLib5NetAppEventHandler __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) + /* NetApp Event Registration */ + #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) (SlNetAppEvent_t *); + #define SlExtLib5NetAppEventHandler __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) - #undef EXT_LIB_REGISTERED_NETAPP_EVENTS + #undef EXT_LIB_REGISTERED_NETAPP_EVENTS #define EXT_LIB_REGISTERED_NETAPP_EVENTS - #endif + #endif - /* Http Server Event Registration */ - #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_HTTP_SERVER_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); - #define SlExtLib5HttpServerEventHandler __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) + /* Http Server Event Registration */ + #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_HTTP_SERVER_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*); + #define SlExtLib5HttpServerEventHandler __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) - #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS + #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS - #endif + #endif - /* Socket Event Registration */ - #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_SOCK_EVENT) - extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) (SlSockEvent_t *); - #define SlExtLib5SockEventHandler __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) + /* Socket Event Registration */ + #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_SOCK_EVENT) + extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) (SlSockEvent_t *); + #define SlExtLib5SockEventHandler __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) - #undef EXT_LIB_REGISTERED_SOCK_EVENTS + #undef EXT_LIB_REGISTERED_SOCK_EVENTS #define EXT_LIB_REGISTERED_SOCK_EVENTS - #endif + #endif #endif @@ -728,7 +726,9 @@ extern void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent); #endif -typedef void (*_SlSpawnEntryFunc_t)(void* pValue); +typedef short (*_SlSpawnEntryFunc_t)(void* pValue); + +#define SL_SPAWN_FLAG_FROM_SL_IRQ_HANDLER (0X1) #ifdef SL_PLATFORM_MULTI_THREADED #include "utility/spawn.h" @@ -742,25 +742,25 @@ typedef void (*_SlSpawnEntryFunc_t)(void* pValue); /*! \brief General async event for inspecting general events - - \param[out] pSlDeviceEvent pointer to SlDeviceEvent_t - + + \param[out] pSlDeviceEvent pointer to SlDeviceEvent_t + \par Parameters: \n - pSlDeviceEvent->Event = SL_DEVICE_FATAL_ERROR_EVENT - - pSlDeviceEvent->EventData.deviceEvent fields: + - pSlDeviceEvent->EventData.deviceEvent fields: - status: An error code indication from the device - - sender: The sender originator which is based on SlErrorSender_e enum + - sender: The sender originator which is based on SlErrorSender_e enum - pSlDeviceEvent->Event = SL_DEVICE_ABORT_ERROR_EVENT - Indicates a severe error occured and the device stopped - - pSlDeviceEvent->EventData.deviceReport fields: + Indicates a severe error occured and the device stopped + - pSlDeviceEvent->EventData.deviceReport fields: - AbortType: An idication of the event type - - AbortData: Additional info about the data error - - - \par Example for fatal error: - \code + - AbortData: Additional info about the data error + + + \par Example for fatal error: + \code printf(General Event Handler - ID=%d Sender=%d\n\n", pSlDeviceEvent->EventData.deviceEvent.status, // status of the general event pSlDeviceEvent->EventData.deviceEvent.sender); // sender type @@ -768,24 +768,22 @@ typedef void (*_SlSpawnEntryFunc_t)(void* pValue); \par Example for abort request: \code printf(Abort type =%d Abort Data=%d\n\n", - pSlDeviceEvent->EventData.deviceReport.AbortType, - pSlDeviceEvent->EventData.deviceReport.AbortData); + pSlDeviceEvent->EventData.deviceReport.AbortType, + pSlDeviceEvent->EventData.deviceReport.AbortData); \endcode */ -#if (defined(sl_GeneralEvtHdlr)) extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent); -#endif /*! \brief WLAN Async event handler - - \param[out] pSlWlanEvent pointer to SlWlanEvent_t data - + + \param[out] pSlWlanEvent pointer to SlWlanEvent_t data + \par Parameters: - + - pSlWlanEvent->Event = SL_WLAN_CONNECT_EVENT , STA or P2P client connection indication event - pSlWlanEvent->EventData.STAandP2PModeWlanConnected main fields: - ssid_name @@ -793,14 +791,14 @@ extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent); - bssid - go_peer_device_name - go_peer_device_name_len - - - pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT , STA or P2P client disconnection event + + - pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT , STA or P2P client disconnection event - pSlWlanEvent->EventData.STAandP2PModeDisconnected main fields: - ssid_name - ssid_len - reason_code - - pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT , AP/P2P(Go) connected STA/P2P(Client) + - pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT , AP/P2P(Go) connected STA/P2P(Client) - pSlWlanEvent->EventData.APModeStaConnected fields: - go_peer_device_name - mac @@ -808,8 +806,8 @@ extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent); - wps_dev_password_id - own_ssid: relevant for event sta-connected only - own_ssid_len: relevant for event sta-connected only - - - pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT , AP/P2P(Go) disconnected STA/P2P(Client) + + - pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT , AP/P2P(Go) disconnected STA/P2P(Client) - pSlWlanEvent->EventData.APModestaDisconnected fields: - go_peer_device_name - mac @@ -818,19 +816,19 @@ extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent); - own_ssid: relevant for event sta-connected only - own_ssid_len: relevant for event sta-connected only - - pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT + - pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT - pSlWlanEvent->EventData.smartConfigStartResponse fields: - status - ssid_len - ssid - private_token_len - private_token - - - pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT - - pSlWlanEvent->EventData.smartConfigStopResponse fields: + + - pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT + - pSlWlanEvent->EventData.smartConfigStopResponse fields: - status - - - pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT + + - pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT - pSlWlanEvent->EventData.P2PModeDevFound fields: - go_peer_device_name - mac @@ -838,18 +836,18 @@ extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent); - wps_dev_password_id - own_ssid: relevant for event sta-connected only - own_ssid_len: relevant for event sta-connected only - - - pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT + + - pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT - pSlWlanEvent->EventData.P2PModeNegReqReceived fields - go_peer_device_name - mac - go_peer_device_name_len - wps_dev_password_id - own_ssid: relevant for event sta-connected only - + - pSlWlanEvent->Event = SL_WLAN_CONNECTION_FAILED_EVENT , P2P only - pSlWlanEvent->EventData.P2PModewlanConnectionFailure fields: - - status + - status */ #if (defined(sl_WlanEvtHdlr)) extern void sl_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent); @@ -858,9 +856,9 @@ extern void sl_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent); /*! \brief NETAPP Async event handler - - \param[out] pSlNetApp pointer to SlNetAppEvent_t data - + + \param[out] pSlNetApp pointer to SlNetAppEvent_t data + \par Parameters: - pSlNetApp->Event = SL_NETAPP_IPV4_IPACQUIRED_EVENT, IPV4 acquired event @@ -868,7 +866,7 @@ extern void sl_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent); - ip - gateway - dns - + - pSlNetApp->Event = SL_NETAPP_IP_LEASED_EVENT, AP or P2P go dhcp lease event - pSlNetApp->EventData.ipLeased fields: - ip_address @@ -888,9 +886,9 @@ extern void sl_NetAppEvtHdlr(SlNetAppEvent_t* pSlNetApp); /*! \brief Socket Async event handler - - \param[out] pSlSockEvent pointer to SlSockEvent_t data - + + \param[out] pSlSockEvent pointer to SlSockEvent_t data + \par Parameters:\n - pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT @@ -900,7 +898,7 @@ extern void sl_NetAppEvtHdlr(SlNetAppEvent_t* pSlNetApp); - pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT - pSlSockEvent->SockAsyncData fields: - sd - - type: SSL_ACCEPT or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED + - type: SSL_ACCEPT or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED - val */ @@ -925,27 +923,44 @@ extern void sl_SockEvtHdlr(SlSockEvent_t* pSlSockEvent); - pSlHttpServerResponse->ResponseData fields: - data - len - + - pSlHttpServerEvent->Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT - pSlHttpServerEvent->EventData.httpPostData fields: - action - token_name - - token_value + - token_value - pSlHttpServerResponse->ResponseData fields: - data - - len - + - len + */ #if (defined(sl_HttpServerCallback)) extern void sl_HttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse); #endif + + + + +/*! + \brief SL get timestamp routine. + It returns the timer counter value in ticks unit. + The counter must count from zero to its max value + + \par + Parameters: \n + +*/ +#if defined (sl_GetTimestamp) +extern _u32 sl_GetTimestamp(void); +#endif + /*! Close the Doxygen group. @} */ - + //#ifdef __cplusplus //} //#endif /* __cplusplus */ diff --git a/hardware/lm4f/libraries/WiFi/utility/socket.c b/hardware/lm4f/libraries/WiFi/utility/socket.c index 680d95d7201..55ff3cea8e4 100644 --- a/hardware/lm4f/libraries/WiFi/utility/socket.c +++ b/hardware/lm4f/libraries/WiFi/utility/socket.c @@ -1,39 +1,39 @@ /* * socket.c - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + @@ -45,15 +45,15 @@ #include "driver.h" -void _sl_BuildAddress(const SlSockAddr_t *addr, _SocketAddrCommand_u *pCmd); -void _sl_HandleAsync_Connect(void *pVoidBuf); +static void _sl_BuildAddress(const SlSockAddr_t *addr, _SocketAddrCommand_u *pCmd); +_SlReturnVal_t _sl_HandleAsync_Connect(void *pVoidBuf); #ifndef SL_TINY_EXT void _sl_ParseAddress(_SocketAddrResponse_u *pRsp, SlSockAddr_t *addr, SlSocklen_t *addrlen); -void _sl_HandleAsync_Accept(void *pVoidBuf); -void _sl_HandleAsync_Select(void *pVoidBuf); +_SlReturnVal_t _sl_HandleAsync_Accept(void *pVoidBuf); +_SlReturnVal_t _sl_HandleAsync_Select(void *pVoidBuf); #endif -_u16 _sl_TruncatePayloadByProtocol(const _i16 pSd, const _u16 length); +static _u16 _sl_TruncatePayloadByProtocol(const _i16 pSd, const _u16 length); /*******************************************************************************/ /* Functions */ @@ -65,7 +65,7 @@ _u16 _sl_TruncatePayloadByProtocol(const _i16 pSd, const _u16 length); /* three families. */ #define SL_SOCKET_PAYLOAD_BASE (1350) -const _u8 _SlPayloadByProtocolLUT[16] = +static const _u8 _SlPayloadByProtocolLUT[16] = { (1472 - SL_SOCKET_PAYLOAD_BASE), /* SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4 */ (1460 - SL_SOCKET_PAYLOAD_BASE), /* SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4 */ @@ -90,13 +90,13 @@ const _u8 _SlPayloadByProtocolLUT[16] = /* ******************************************************************************/ /* _sl_BuildAddress */ /* ******************************************************************************/ -void _sl_BuildAddress(const SlSockAddr_t *addr, _SocketAddrCommand_u *pCmd) +static void _sl_BuildAddress(const SlSockAddr_t *addr, _SocketAddrCommand_u *pCmd) { /* Note: parsing of family and port in the generic way for all IPV4, IPV6 and EUI48 is possible as long as these parameters are in the same offset and size for these three families. */ - pCmd->IpV4.FamilyAndFlags = (addr->sa_family << 4) & 0xF0; + pCmd->IpV4.FamilyAndFlags = (_u8)((addr->sa_family << 4) & 0xF0); pCmd->IpV4.port = ((SlSockAddrIn_t *)addr)->sin_port; if(SL_AF_INET == addr->sa_family) @@ -117,14 +117,14 @@ void _sl_BuildAddress(const SlSockAddr_t *addr, _SocketAddrCommand_u *pCmd) /***************************************************************************** - _sl_TruncatePayloadByProtocol + _sl_TruncatePayloadByProtocol *****************************************************************************/ -_u16 _sl_TruncatePayloadByProtocol(const _i16 sd, const _u16 length) +static _u16 _sl_TruncatePayloadByProtocol(const _i16 sd, const _u16 length) { - unsigned int maxLength; + _u16 maxLength; - maxLength = SL_SOCKET_PAYLOAD_BASE + _SlPayloadByProtocolLUT[((sd & SL_SOCKET_PAYLOAD_TYPE_MASK) >> 4)]; + maxLength = (_u16)(SL_SOCKET_PAYLOAD_BASE + _SlPayloadByProtocolLUT[((sd & SL_SOCKET_PAYLOAD_TYPE_MASK) >> 4)]); @@ -151,7 +151,7 @@ void _sl_ParseAddress(_SocketAddrResponse_u *pRsp, SlSockAddr_t *addr, SlSock addr->sa_family = pRsp->IpV4.family; ((SlSockAddrIn_t *)addr)->sin_port = pRsp->IpV4.port; - *addrlen = (SL_AF_INET == addr->sa_family) ? sizeof(SlSockAddrIn_t) : sizeof(SlSockAddrIn6_t); + *addrlen = (SlSocklen_t)((SL_AF_INET == addr->sa_family) ? sizeof(SlSockAddrIn_t) : sizeof(SlSockAddrIn6_t)); if(SL_AF_INET == addr->sa_family) { @@ -177,37 +177,41 @@ void _sl_ParseAddress(_SocketAddrResponse_u *pRsp, SlSockAddr_t *addr, SlSock typedef union { _u32 Dummy; - _SocketCommand_t Cmd; - _SocketResponse_t Rsp; + _SocketCommand_t Cmd; + _SocketResponse_t Rsp; }_SlSockSocketMsg_u; #if _SL_INCLUDE_FUNC(sl_Socket) -const _SlCmdCtrl_t _SlSockSocketCmdCtrl = +static const _SlCmdCtrl_t _SlSockSocketCmdCtrl = { SL_OPCODE_SOCKET_SOCKET, - sizeof(_SocketCommand_t), - sizeof(_SocketResponse_t) + (_SlArgSize_t)sizeof(_SocketCommand_t), + (_SlArgSize_t)sizeof(_SocketResponse_t) }; _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol) { _SlSockSocketMsg_u Msg; - Msg.Cmd.Domain = (_u8)Domain; - Msg.Cmd.Type = (_u8)Type; - Msg.Cmd.Protocol = (_u8)Protocol; + Msg.Cmd.Domain = (_u8)Domain; + Msg.Cmd.Type = (_u8)Type; + Msg.Cmd.Protocol = (_u8)Protocol; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlSockSocketCmdCtrl, &Msg, NULL)); if( Msg.Rsp.statusOrLen < 0 ) - { - return( Msg.Rsp.statusOrLen ); - } - else - { + { + return( Msg.Rsp.statusOrLen ); + } + else + { return (_i16)((_u8)Msg.Rsp.sd); } } @@ -218,23 +222,27 @@ _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol) /*******************************************************************************/ typedef union { - _CloseCommand_t Cmd; - _SocketResponse_t Rsp; + _CloseCommand_t Cmd; + _SocketResponse_t Rsp; }_SlSockCloseMsg_u; #if _SL_INCLUDE_FUNC(sl_Close) -const _SlCmdCtrl_t _SlSockCloseCmdCtrl = +static const _SlCmdCtrl_t _SlSockCloseCmdCtrl = { - SL_OPCODE_SOCKET_CLOSE, - sizeof(_CloseCommand_t), - sizeof(_SocketResponse_t) + SL_OPCODE_SOCKET_CLOSE, + (_SlArgSize_t)sizeof(_CloseCommand_t), + (_SlArgSize_t)sizeof(_SocketResponse_t) }; _i16 sl_Close(_i16 sd) { - _SlSockCloseMsg_u Msg; + _SlSockCloseMsg_u Msg; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); Msg.Cmd.sd = (_u8)sd; @@ -249,32 +257,36 @@ _i16 sl_Close(_i16 sd) /*******************************************************************************/ typedef union { - _SocketAddrCommand_u Cmd; - _SocketResponse_t Rsp; + _SocketAddrCommand_u Cmd; + _SocketResponse_t Rsp; }_SlSockBindMsg_u; #if _SL_INCLUDE_FUNC(sl_Bind) _i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) { - _SlSockBindMsg_u Msg; - _SlCmdCtrl_t CmdCtrl = {0, 0, sizeof(_SocketResponse_t)}; + _SlSockBindMsg_u Msg; + _SlCmdCtrl_t CmdCtrl = {0, 0, (_SlArgSize_t)sizeof(_SocketResponse_t)}; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); switch(addr->sa_family) { case SL_AF_INET : CmdCtrl.Opcode = SL_OPCODE_SOCKET_BIND; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv4Command_t); + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv4Command_t); break; -#ifndef SL_TINY_EXT +#ifndef SL_TINY_EXT case SL_AF_INET6_EUI_48: CmdCtrl.Opcode = SL_OPCODE_SOCKET_BIND_V6; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv6EUI48Command_t); - break; + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv6EUI48Command_t); + break; #ifdef SL_SUPPORT_IPV6 case AF_INET6: CmdCtrl.Opcode = SL_OPCODE_SOCKET_BIND_V6; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv6Command_t); + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv6Command_t); break; #endif #endif @@ -314,6 +326,10 @@ _i16 sl_SendTo(_i16 sd, const void *pBuf, _i16 Len, _i16 flags, const SlSockAddr _u16 ChunkLen; _i16 RetVal; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + _SlDrvResetCmdExt(&CmdExt); CmdExt.TxPayloadLen = (_u16)Len; CmdExt.pTxPayload = (_u8 *)pBuf; @@ -322,17 +338,17 @@ _i16 sl_SendTo(_i16 sd, const void *pBuf, _i16 Len, _i16 flags, const SlSockAddr { case SL_AF_INET: CmdCtrl.Opcode = SL_OPCODE_SOCKET_SENDTO; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv4Command_t); + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv4Command_t); break; -#ifndef SL_TINY_EXT +#ifndef SL_TINY_EXT case SL_AF_INET6_EUI_48: CmdCtrl.Opcode = SL_OPCODE_SOCKET_BIND_V6; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv6EUI48Command_t); - break; + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv6EUI48Command_t); + break; #ifdef SL_SUPPORT_IPV6 case AF_INET6: CmdCtrl.Opcode = SL_OPCODE_SOCKET_SENDTO_V6; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv6Command_t); + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv6Command_t); break; #endif #endif @@ -341,8 +357,8 @@ _i16 sl_SendTo(_i16 sd, const void *pBuf, _i16 Len, _i16 flags, const SlSockAddr return SL_RET_CODE_INVALID_INPUT; } - ChunkLen = _sl_TruncatePayloadByProtocol(sd,Len); - Msg.Cmd.IpV4.lenOrPadding = ChunkLen; + ChunkLen = _sl_TruncatePayloadByProtocol(sd,(_u16)Len); + Msg.Cmd.IpV4.lenOrPadding = (_i16)ChunkLen; CmdExt.TxPayloadLen = ChunkLen; Msg.Cmd.IpV4.sd = (_u8)sd; @@ -361,7 +377,7 @@ _i16 sl_SendTo(_i16 sd, const void *pBuf, _i16 Len, _i16 flags, const SlSockAddr ChunkLen = (_u16)((_u8 *)pBuf + Len - CmdExt.pTxPayload); ChunkLen = _sl_TruncatePayloadByProtocol(sd,ChunkLen); CmdExt.TxPayloadLen = ChunkLen; - Msg.Cmd.IpV4.lenOrPadding = ChunkLen; + Msg.Cmd.IpV4.lenOrPadding = (_i16)ChunkLen; } else { @@ -378,15 +394,15 @@ _i16 sl_SendTo(_i16 sd, const void *pBuf, _i16 Len, _i16 flags, const SlSockAddr /*******************************************************************************/ typedef union { - _sendRecvCommand_t Cmd; - _SocketAddrResponse_u Rsp; + _sendRecvCommand_t Cmd; + _SocketAddrResponse_u Rsp; }_SlRecvfromMsg_u; -const _SlCmdCtrl_t _SlRecvfomCmdCtrl = +static const _SlCmdCtrl_t _SlRecvfomCmdCtrl = { - SL_OPCODE_SOCKET_RECVFROM, - sizeof(_sendRecvCommand_t), - sizeof(_SocketAddrResponse_u) + SL_OPCODE_SOCKET_RECVFROM, + (_SlArgSize_t)sizeof(_sendRecvCommand_t), + (_SlArgSize_t)sizeof(_SocketAddrResponse_u) }; @@ -398,18 +414,22 @@ _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, S _SlCmdExt_t CmdExt; _i16 RetVal; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); CmdExt.RxPayloadLen = Len; CmdExt.pRxPayload = (_u8 *)buf; Msg.Cmd.sd = (_u8)sd; - Msg.Cmd.StatusOrLen = Len; + Msg.Cmd.StatusOrLen = (_u16)Len; + /* no size truncation in recv path */ - CmdExt.RxPayloadLen = Msg.Cmd.StatusOrLen; + CmdExt.RxPayloadLen = (_i16)Msg.Cmd.StatusOrLen; - Msg.Cmd.FamilyAndFlags = flags & 0x0F; + Msg.Cmd.FamilyAndFlags = (_u8)(flags & 0x0F); if(sizeof(SlSockAddrIn_t) == *fromlen) @@ -428,14 +448,14 @@ _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, S RetVal = _SlDrvDataReadOp((_SlSd_t)sd, (_SlCmdCtrl_t *)&_SlRecvfomCmdCtrl, &Msg, &CmdExt); if( RetVal != SL_OS_RET_CODE_OK ) { - return RetVal; + return RetVal; } RetVal = Msg.Rsp.IpV4.statusOrLen; if(RetVal >= 0) { - VERIFY_PROTOCOL(sd == Msg.Rsp.IpV4.sd); + VERIFY_PROTOCOL(sd == (_i16)Msg.Rsp.IpV4.sd); #if 0 _sl_ParseAddress(&Msg.Rsp, from, fromlen); #else @@ -444,7 +464,7 @@ _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, S { ((SlSockAddrIn_t *)from)->sin_port = Msg.Rsp.IpV4.port; ((SlSockAddrIn_t *)from)->sin_addr.s_addr = Msg.Rsp.IpV4.address; - *fromlen = sizeof(SlSockAddrIn_t); + *fromlen = (SlSocklen_t)sizeof(SlSockAddrIn_t); } else if (SL_AF_INET6_EUI_48 == from->sa_family ) { @@ -473,8 +493,8 @@ _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, S /*******************************************************************************/ typedef union { - _SocketAddrCommand_u Cmd; - _SocketResponse_t Rsp; + _SocketAddrCommand_u Cmd; + _SocketResponse_t Rsp; }_SlSockConnectMsg_u; #if _SL_INCLUDE_FUNC(sl_Connect) @@ -482,26 +502,30 @@ _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) { _SlSockConnectMsg_u Msg; _SlReturnVal_t RetVal; - _SlCmdCtrl_t CmdCtrl = {0, 0, sizeof(_SocketResponse_t)}; + _SlCmdCtrl_t CmdCtrl = {0, (_SlArgSize_t)0, (_SlArgSize_t)sizeof(_SocketResponse_t)}; _SocketResponse_t AsyncRsp; _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + switch(addr->sa_family) { case SL_AF_INET : CmdCtrl.Opcode = SL_OPCODE_SOCKET_CONNECT; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv4Command_t); + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv4Command_t); /* Do nothing - cmd already initialized to this type */ break; case SL_AF_INET6_EUI_48: CmdCtrl.Opcode = SL_OPCODE_SOCKET_CONNECT_V6; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv6EUI48Command_t); - break; + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv6EUI48Command_t); + break; #ifdef SL_SUPPORT_IPV6 case AF_INET6: CmdCtrl.Opcode = SL_OPCODE_SOCKET_CONNECT_V6; - CmdCtrl.TxDescLen = sizeof(_SocketAddrIPv6Command_t); + CmdCtrl.TxDescLen = (_SlArgSize_t)sizeof(_SocketAddrIPv6Command_t); break; #endif case SL_AF_RF: @@ -515,7 +539,7 @@ _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) _sl_BuildAddress(addr, &Msg.Cmd); - ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, CONNECT_ID, sd & BSD_SOCKET_ID_MASK); + ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, CONNECT_ID, (_u8)(sd & BSD_SOCKET_ID_MASK)); if (MAX_CONCURRENT_ACTIONS == ObjIdx) { @@ -524,16 +548,29 @@ _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) /* send the command */ VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, &Msg, NULL)); - VERIFY_PROTOCOL(Msg.Rsp.sd == sd) + VERIFY_PROTOCOL(Msg.Rsp.sd == (_u8)sd) - RetVal = Msg.Rsp.statusOrLen; + RetVal = Msg.Rsp.statusOrLen; if(SL_RET_CODE_OK == RetVal) { - /* wait for async and get Data Read parameters */ - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); - - VERIFY_PROTOCOL(AsyncRsp.sd == sd); +#ifndef SL_TINY_EXT + /*In case socket is non-blocking one, the async event should be received immediately */ + if( g_pCB->SocketNonBlocking >> (sd & BSD_SOCKET_ID_MASK)) + { + SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj, + SL_DRIVER_TIMEOUT_SHORT, + SL_DRIVER_API_SOCKET_CONNECT + ); + } + else +#endif + { + /* wait for async and get Data Read parameters */ + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj); + } + + VERIFY_PROTOCOL(AsyncRsp.sd == (_u8)sd); RetVal = AsyncRsp.statusOrLen; } @@ -550,23 +587,24 @@ _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) /*******************************************************************************/ /* _sl_HandleAsync_Connect */ /*******************************************************************************/ -void _sl_HandleAsync_Connect(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_Connect(void *pVoidBuf) { _SocketResponse_t *pMsgArgs = (_SocketResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); VERIFY_PROTOCOL((pMsgArgs->sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); - + ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->sd = pMsgArgs->sd; ((_SocketResponse_t *)(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs))->statusOrLen = pMsgArgs->statusOrLen; - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - _SlDrvProtectionObjUnLock(); - return; + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + SL_DRV_PROTECTION_OBJ_UNLOCK(); + + return SL_RET_CODE_OK; } /*******************************************************************************/ @@ -574,15 +612,15 @@ void _sl_HandleAsync_Connect(void *pVoidBuf) /*******************************************************************************/ typedef union { - _sendRecvCommand_t Cmd; + _sendRecvCommand_t Cmd; /* no response for 'sendto' commands*/ }_SlSendMsg_u; -const _SlCmdCtrl_t _SlSendCmdCtrl = +static const _SlCmdCtrl_t _SlSendCmdCtrl = { SL_OPCODE_SOCKET_SEND, - sizeof(_sendRecvCommand_t), - 0 + (_SlArgSize_t)sizeof(_sendRecvCommand_t), + (_SlArgSize_t)0 }; #if _SL_INCLUDE_FUNC(sl_Send) @@ -592,27 +630,31 @@ _i16 sl_Send(_i16 sd, const void *pBuf, _i16 Len, _i16 flags) _SlCmdExt_t CmdExt; _u16 ChunkLen; _i16 RetVal; - _u32 tempVal; - _u8 runSingleChunk = FALSE; + _u32 tempVal; + _u8 runSingleChunk = FALSE; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); - CmdExt.TxPayloadLen = Len; + CmdExt.TxPayloadLen = (_u16)Len; CmdExt.pTxPayload = (_u8 *)pBuf; - + /* Only for RAW transceiver type socket, relay the flags parameter in the 2 bytes (4 byte aligned) before the actual payload */ if ((sd & SL_SOCKET_PAYLOAD_TYPE_MASK) == SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER) { - tempVal = flags; + tempVal = (_u32)flags; CmdExt.pRxPayload = (_u8 *)&tempVal; - CmdExt.RxPayloadLen = -4; /* mark as Rx data to send */ - runSingleChunk = TRUE; + CmdExt.RxPayloadLen = -4; /* mark as Rx data to send */ + runSingleChunk = TRUE; } else { CmdExt.pRxPayload = NULL; } - ChunkLen = _sl_TruncatePayloadByProtocol(sd,Len); + ChunkLen = _sl_TruncatePayloadByProtocol(sd,(_u16)Len); CmdExt.TxPayloadLen = ChunkLen; Msg.Cmd.StatusOrLen = ChunkLen; Msg.Cmd.sd = (_u8)sd; @@ -624,8 +666,8 @@ _i16 sl_Send(_i16 sd, const void *pBuf, _i16 Len, _i16 flags) if(SL_OS_RET_CODE_OK == RetVal) { CmdExt.pTxPayload += ChunkLen; - ChunkLen = (_u8 *)pBuf + Len - CmdExt.pTxPayload; - ChunkLen = _sl_TruncatePayloadByProtocol(sd,ChunkLen); + ChunkLen = (_u16)((_u8 *)pBuf + Len - CmdExt.pTxPayload); + ChunkLen = _sl_TruncatePayloadByProtocol(sd, ChunkLen); CmdExt.TxPayloadLen = ChunkLen; Msg.Cmd.StatusOrLen = ChunkLen; } @@ -634,7 +676,7 @@ _i16 sl_Send(_i16 sd, const void *pBuf, _i16 Len, _i16 flags) return RetVal; } }while((ChunkLen > 0) && (runSingleChunk==FALSE)); - + return (_i16)Len; } #endif @@ -644,7 +686,7 @@ _i16 sl_Send(_i16 sd, const void *pBuf, _i16 Len, _i16 flags) /*******************************************************************************/ typedef union { - _ListenCommand_t Cmd; + _ListenCommand_t Cmd; _BasicResponse_t Rsp; }_SlListenMsg_u; @@ -652,17 +694,21 @@ typedef union #if _SL_INCLUDE_FUNC(sl_Listen) -const _SlCmdCtrl_t _SlListenCmdCtrl = +static const _SlCmdCtrl_t _SlListenCmdCtrl = { SL_OPCODE_SOCKET_LISTEN, - sizeof(_ListenCommand_t), - sizeof(_BasicResponse_t), + (_SlArgSize_t)sizeof(_ListenCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t), }; _i16 sl_Listen(_i16 sd, _i16 backlog) { _SlListenMsg_u Msg; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.sd = (_u8)sd; Msg.Cmd.backlog = (_u8)backlog; @@ -677,65 +723,83 @@ _i16 sl_Listen(_i16 sd, _i16 backlog) /*******************************************************************************/ typedef union { - _AcceptCommand_t Cmd; - _SocketResponse_t Rsp; + _AcceptCommand_t Cmd; + _SocketResponse_t Rsp; }_SlSockAcceptMsg_u; #if _SL_INCLUDE_FUNC(sl_Accept) -const _SlCmdCtrl_t _SlAcceptCmdCtrl = +static const _SlCmdCtrl_t _SlAcceptCmdCtrl = { SL_OPCODE_SOCKET_ACCEPT, - sizeof(_AcceptCommand_t), - sizeof(_BasicResponse_t), + (_SlArgSize_t)sizeof(_AcceptCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t), }; _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen) { - _SlSockAcceptMsg_u Msg; + _SlSockAcceptMsg_u Msg; _SlReturnVal_t RetVal; _SocketAddrResponse_u AsyncRsp; - _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.sd = (_u8)sd; - Msg.Cmd.family = (sizeof(SlSockAddrIn_t) == *addrlen) ? SL_AF_INET : SL_AF_INET6; + Msg.Cmd.family = (_u8)((sizeof(SlSockAddrIn_t) == *addrlen) ? SL_AF_INET : SL_AF_INET6); - ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, ACCEPT_ID, sd & BSD_SOCKET_ID_MASK ); + ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, ACCEPT_ID, (_u8)sd & BSD_SOCKET_ID_MASK ); if (MAX_CONCURRENT_ACTIONS == ObjIdx) { return SL_POOL_IS_EMPTY; } - - /* send the command */ + + /* send the command */ VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlAcceptCmdCtrl, &Msg, NULL)); - VERIFY_PROTOCOL(Msg.Rsp.sd == sd); + VERIFY_PROTOCOL(Msg.Rsp.sd == (_u8)sd); RetVal = Msg.Rsp.statusOrLen; if(SL_OS_RET_CODE_OK == RetVal) { - /* wait for async and get Data Read parameters */ - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); - - VERIFY_PROTOCOL(AsyncRsp.IpV4.sd == sd); +#ifndef SL_TINY_EXT + /* in case socket is non-blocking one, the async event should be received immediately */ + if( g_pCB->SocketNonBlocking & (1<<(sd & BSD_SOCKET_ID_MASK) )) + { + SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj, + SL_DRIVER_TIMEOUT_SHORT, + SL_DRIVER_API_SOCKET_ACCEPT + ); + } + else +#endif + { + /* wait for async and get Data Read parameters */ + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj); + } + + VERIFY_PROTOCOL(AsyncRsp.IpV4.sd == (_u8)sd); RetVal = AsyncRsp.IpV4.statusOrLen; - if( (NULL != addr) && (NULL != addrlen) ) + if( (NULL != addr) && (NULL != addrlen) ) { #if 0 /* Kept for backup */ _sl_ParseAddress(&AsyncRsp, addr, addrlen); #else - addr->sa_family = AsyncRsp.IpV4.family; + addr->sa_family = AsyncRsp.IpV4.family; - if(SL_AF_INET == addr->sa_family) - { - if( *addrlen == sizeof( SlSockAddrIn_t ) ) + if(SL_AF_INET == addr->sa_family) + { + if( *addrlen == (SlSocklen_t)sizeof( SlSockAddrIn_t ) ) { ((SlSockAddrIn_t *)addr)->sin_port = AsyncRsp.IpV4.port; ((SlSockAddrIn_t *)addr)->sin_addr.s_addr = AsyncRsp.IpV4.address; @@ -744,10 +808,10 @@ _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen) { *addrlen = 0; } - } - else if (SL_AF_INET6_EUI_48 == addr->sa_family ) - { - if( *addrlen == sizeof( SlSockAddrIn6_t ) ) + } + else if (SL_AF_INET6_EUI_48 == addr->sa_family ) + { + if( *addrlen == (SlSocklen_t)sizeof( SlSockAddrIn6_t ) ) { ((SlSockAddrIn6_t *)addr)->sin6_port = AsyncRsp.IpV6EUI48.port ; /* will be called from here and from _sl_BuildAddress*/ @@ -757,22 +821,22 @@ _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen) { *addrlen = 0; } - } + } #ifdef SL_SUPPORT_IPV6 - else - { + else + { if( *addrlen == sizeof( sockaddr_in6 ) ) { - ((sockaddr_in6 *)addr)->sin6_port = AsyncRsp.IpV6.port ; - sl_Memcpy(((sockaddr_in6 *)addr)->sin6_addr._S6_un._S6_u32, AsyncRsp.IpV6.address, 16); + ((sockaddr_in6 *)addr)->sin6_port = AsyncRsp.IpV6.port ; + sl_Memcpy(((sockaddr_in6 *)addr)->sin6_addr._S6_un._S6_u32, AsyncRsp.IpV6.address, 16); } else { *addrlen = 0; } - } + } +#endif #endif -#endif } } @@ -787,8 +851,8 @@ _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen) /*******************************************************************************/ _u32 sl_Htonl( _u32 val ) { - _u32 i = 1; - _i8 *p = (_i8 *)&i; + _u32 i = 1; + _i8 *p = (_i8 *)&i; if (p[0] == 1) /* little endian */ { p[0] = ((_i8* )&val)[3]; @@ -799,7 +863,7 @@ _u32 sl_Htonl( _u32 val ) } else /* big endian */ { - return val; + return val; } } @@ -808,17 +872,17 @@ _u32 sl_Htonl( _u32 val ) /*******************************************************************************/ _u16 sl_Htons( _u16 val ) { - _i16 i = 1; - _i8 *p = (_i8 *)&i; + _i16 i = 1; + _i8 *p = (_i8 *)&i; if (p[0] == 1) /* little endian */ { p[0] = ((_i8* )&val)[1]; p[1] = ((_i8* )&val)[0]; - return i; + return (_u16)i; } else /* big endian */ { - return val; + return val; } } @@ -826,39 +890,40 @@ _u16 sl_Htons( _u16 val ) /* _sl_HandleAsync_Accept */ /*******************************************************************************/ #ifndef SL_TINY_EXT -void _sl_HandleAsync_Accept(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_Accept(void *pVoidBuf) { _SocketAddrResponse_u *pMsgArgs = (_SocketAddrResponse_u *)_SL_RESP_ARGS_START(pVoidBuf); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); VERIFY_PROTOCOL(( pMsgArgs->IpV4.sd & BSD_SOCKET_ID_MASK) <= SL_MAX_SOCKETS); VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); - sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs,sizeof(_SocketAddrResponse_u)); - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs,sizeof(_SocketAddrResponse_u)); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - _SlDrvProtectionObjUnLock(); - return; + SL_DRV_PROTECTION_OBJ_UNLOCK(); + return SL_RET_CODE_OK; } /*******************************************************************************/ /* _sl_HandleAsync_Select */ /*******************************************************************************/ -void _sl_HandleAsync_Select(void *pVoidBuf) +_SlReturnVal_t _sl_HandleAsync_Select(void *pVoidBuf) { _SelectAsyncResponse_t *pMsgArgs = (_SelectAsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf); - _SlDrvProtectionObjLockWaitForever(); + SL_DRV_PROTECTION_OBJ_LOCK_FOREVER(); VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs); sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_SelectAsyncResponse_t)); - _SlDrvSyncObjSignal(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); - _SlDrvProtectionObjUnLock(); + SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj); + + SL_DRV_PROTECTION_OBJ_UNLOCK(); - return; + return SL_RET_CODE_OK; } #endif @@ -868,18 +933,18 @@ void _sl_HandleAsync_Select(void *pVoidBuf) /*******************************************************************************/ typedef union { - _sendRecvCommand_t Cmd; - _SocketResponse_t Rsp; + _sendRecvCommand_t Cmd; + _SocketResponse_t Rsp; }_SlRecvMsg_u; #if _SL_INCLUDE_FUNC(sl_Recv) -const _SlCmdCtrl_t _SlRecvCmdCtrl = +static const _SlCmdCtrl_t _SlRecvCmdCtrl = { SL_OPCODE_SOCKET_RECV, - sizeof(_sendRecvCommand_t), - sizeof(_SocketResponse_t) + (_SlArgSize_t)sizeof(_sendRecvCommand_t), + (_SlArgSize_t)sizeof(_SocketResponse_t) }; @@ -889,24 +954,28 @@ _i16 sl_Recv(_i16 sd, void *pBuf, _i16 Len, _i16 flags) _SlCmdExt_t CmdExt; _SlReturnVal_t status; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + _SlDrvResetCmdExt(&CmdExt); CmdExt.RxPayloadLen = Len; CmdExt.pRxPayload = (_u8 *)pBuf; Msg.Cmd.sd = (_u8)sd; - Msg.Cmd.StatusOrLen = Len; + Msg.Cmd.StatusOrLen = (_u16)Len; /* no size truncation in recv path */ - CmdExt.RxPayloadLen = Msg.Cmd.StatusOrLen; + CmdExt.RxPayloadLen = (_i16)Msg.Cmd.StatusOrLen; - Msg.Cmd.FamilyAndFlags = flags & 0x0F; + Msg.Cmd.FamilyAndFlags = (_u8)(flags & 0x0F); status = _SlDrvDataReadOp((_SlSd_t)sd, (_SlCmdCtrl_t *)&_SlRecvCmdCtrl, &Msg, &CmdExt); if( status != SL_OS_RET_CODE_OK ) { - return status; + return status; } - + /* if the Device side sends less than expected it is not the Driver's role */ /* the returned value could be smaller than the requested size */ return (_i16)Msg.Rsp.statusOrLen; @@ -918,15 +987,15 @@ _i16 sl_Recv(_i16 sd, void *pBuf, _i16 Len, _i16 flags) /*******************************************************************************/ typedef union { - _setSockOptCommand_t Cmd; - _SocketResponse_t Rsp; + _setSockOptCommand_t Cmd; + _SocketResponse_t Rsp; }_SlSetSockOptMsg_u; -const _SlCmdCtrl_t _SlSetSockOptCmdCtrl = +static const _SlCmdCtrl_t _SlSetSockOptCmdCtrl = { SL_OPCODE_SOCKET_SETSOCKOPT, - sizeof(_setSockOptCommand_t), - sizeof(_SocketResponse_t) + (_SlArgSize_t)sizeof(_setSockOptCommand_t), + (_SlArgSize_t)sizeof(_SocketResponse_t) }; #if _SL_INCLUDE_FUNC(sl_SetSockOpt) @@ -935,6 +1004,9 @@ _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSock _SlSetSockOptMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); CmdExt.TxPayloadLen = optlen; @@ -956,18 +1028,18 @@ _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSock /*******************************************************************************/ typedef union { - _getSockOptCommand_t Cmd; - _getSockOptResponse_t Rsp; + _getSockOptCommand_t Cmd; + _getSockOptResponse_t Rsp; }_SlGetSockOptMsg_u; #if _SL_INCLUDE_FUNC(sl_GetSockOpt) -const _SlCmdCtrl_t _SlGetSockOptCmdCtrl = +static const _SlCmdCtrl_t _SlGetSockOptCmdCtrl = { SL_OPCODE_SOCKET_GETSOCKOPT, - sizeof(_getSockOptCommand_t), - sizeof(_getSockOptResponse_t) + (_SlArgSize_t)sizeof(_getSockOptCommand_t), + (_SlArgSize_t)sizeof(_getSockOptResponse_t) }; _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen) @@ -975,13 +1047,16 @@ _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t _SlGetSockOptMsg_u Msg; _SlCmdExt_t CmdExt; - if (*optlen == 0) - { - return SL_EZEROLEN; - } + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (*optlen == 0) + { + return SL_EZEROLEN; + } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = *optlen; + CmdExt.RxPayloadLen = (_i16)(*optlen); CmdExt.pRxPayload = optval; Msg.Cmd.sd = (_u8)sd; @@ -991,15 +1066,15 @@ _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetSockOptCmdCtrl, &Msg, &CmdExt)); - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) - { - *optlen = Msg.Rsp.optionLen; - return SL_ESMALLBUF; - } - else - { - *optlen = (_u8)CmdExt.ActualRxPayloadLen; - } + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + { + *optlen = Msg.Rsp.optionLen; + return SL_ESMALLBUF; + } + else + { + *optlen = (_u8)CmdExt.ActualRxPayloadLen; + } return (_i16)Msg.Rsp.status; } #endif @@ -1009,8 +1084,8 @@ _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t /* ******************************************************************************/ typedef union { - _SelectCommand_t Cmd; - _BasicResponse_t Rsp; + _SelectCommand_t Cmd; + _BasicResponse_t Rsp; }_SlSelectMsg_u; @@ -1018,11 +1093,11 @@ typedef union #ifndef SL_TINY_EXT #if _SL_INCLUDE_FUNC(sl_Select) -const _SlCmdCtrl_t _SlSelectCmdCtrl = +static const _SlCmdCtrl_t _SlSelectCmdCtrl = { SL_OPCODE_SOCKET_SELECT, - sizeof(_SelectCommand_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_SelectCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; @@ -1030,51 +1105,55 @@ _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *ex { _SlSelectMsg_u Msg; _SelectAsyncResponse_t AsyncRsp; - _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + _u8 ObjIdx = MAX_CONCURRENT_ACTIONS; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); Msg.Cmd.nfds = (_u8)nfds; Msg.Cmd.readFdsCount = 0; Msg.Cmd.writeFdsCount = 0; - + Msg.Cmd.readFds = 0; - Msg.Cmd.writeFds = 0; + Msg.Cmd.writeFds = 0; + - if( readsds ) { - Msg.Cmd.readFds = (_u16)readsds->fd_array[0]; + Msg.Cmd.readFds = (_u16)readsds->fd_array[0]; } if( writesds ) { - Msg.Cmd.writeFds = (_u16)writesds->fd_array[0]; + Msg.Cmd.writeFds = (_u16)writesds->fd_array[0]; } - if( NULL == timeout ) - { - Msg.Cmd.tv_sec = 0xffff; - Msg.Cmd.tv_usec = 0xffff; - } - else - { - if( 0xffff <= timeout->tv_sec ) - { - Msg.Cmd.tv_sec = 0xffff; - } - else - { - Msg.Cmd.tv_sec = (_u16)timeout->tv_sec; - } - timeout->tv_usec = timeout->tv_usec >> 10; /* convert to milliseconds */ - if( 0xffff <= timeout->tv_usec ) - { - Msg.Cmd.tv_usec = 0xffff; - } - else - { - Msg.Cmd.tv_usec = (_u16)timeout->tv_usec; - } - } - - /* Use Obj to issue the command, if not available try later */ + if( NULL == timeout ) + { + Msg.Cmd.tv_sec = 0xffff; + Msg.Cmd.tv_usec = 0xffff; + } + else + { + if( 0xffff <= timeout->tv_sec ) + { + Msg.Cmd.tv_sec = 0xffff; + } + else + { + Msg.Cmd.tv_sec = (_u16)timeout->tv_sec; + } + timeout->tv_usec = timeout->tv_usec >> 10; /* convert to milliseconds */ + if( 0xffff <= timeout->tv_usec ) + { + Msg.Cmd.tv_usec = 0xffff; + } + else + { + Msg.Cmd.tv_usec = (_u16)timeout->tv_usec; + } + } + + /* Use Obj to issue the command, if not available try later */ ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, SELECT_ID, SL_MAX_SOCKETS); if (MAX_CONCURRENT_ACTIONS == ObjIdx) @@ -1082,15 +1161,15 @@ _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *ex return SL_POOL_IS_EMPTY; } - - /* send the command */ + + /* send the command */ VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlSelectCmdCtrl, &Msg, NULL)); if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status) { - _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj); - - Msg.Rsp.status = AsyncRsp.status; + SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj); + + Msg.Rsp.status = (_i16)AsyncRsp.status; if( ((_i16)Msg.Rsp.status) >= 0 ) { @@ -1100,7 +1179,7 @@ _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *ex } if( writesds ) { - writesds->fd_array[0] = AsyncRsp.writeFds; + writesds->fd_array[0] = AsyncRsp.writeFds; } } } @@ -1137,7 +1216,7 @@ _i16 SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset) } /*******************************************************************************/ /* SL_FD_ZERO */ -/*******************************************************************************/ +/*******************************************************************************/ void SL_FD_ZERO(SlFdSet_t *fdset) { fdset->fd_array[0] = 0; diff --git a/hardware/lm4f/libraries/WiFi/utility/socket.h b/hardware/lm4f/libraries/WiFi/utility/socket.h index 526b157740f..46a036c6bb6 100644 --- a/hardware/lm4f/libraries/WiFi/utility/socket.h +++ b/hardware/lm4f/libraries/WiFi/utility/socket.h @@ -1,39 +1,39 @@ /* * socket.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + /*****************************************************************************/ /* Include files */ /*****************************************************************************/ @@ -75,7 +75,7 @@ extern "C" { #define SL_AF_INET (2) /* IPv4 socket (UDP, TCP, etc) */ #define SL_AF_INET6 (3) /* IPv6 socket (UDP, TCP, etc) */ #define SL_AF_INET6_EUI_48 (9) -#define SL_AF_RF (6) /* data include RF parameter, All layer by user (Wifi could be disconnected) */ +#define SL_AF_RF (6) /* data include RF parameter, All layer by user (Wifi could be disconnected) */ #define SL_AF_PACKET (17) /* Protocol families, same as address families. */ #define SL_PF_INET AF_INET @@ -110,12 +110,12 @@ extern "C" { #define SL_EADDRNOTAVAIL (-99) /* Cannot assign requested address */ #define SL_ENETUNREACH (-101) /* Network is unreachable */ #define SL_ENOBUFS (-105) /* No buffer space available */ -#define SL_EOBUFF SL_ENOBUFS +#define SL_EOBUFF SL_ENOBUFS #define SL_EISCONN (-106) /* Transport endpoint is already connected */ #define SL_ENOTCONN (-107) /* Transport endpoint is not connected */ #define SL_ETIMEDOUT (-110) /* Connection timed out */ #define SL_ECONNREFUSED (-111) /* Connection refused */ -#define SL_EALREADY (-114) /* Non blocking connect in progress, try again */ +#define SL_EALREADY (-114) /* Non blocking connect in progress, try again */ #define SL_ESEC_RSA_WRONG_TYPE_E (-130) /* RSA wrong block type for RSA function */ #define SL_ESEC_RSA_BUFFER_E (-131) /* RSA buffer error, output too small or */ @@ -212,35 +212,35 @@ extern "C" { #define SL_ESEC_MATCH_SUITE_ERROR (-291 ) /* can't match cipher suite */ /* ssl tls security start with -300 offset */ -#define SL_ESEC_CLOSE_NOTIFY (-300) /* ssl/tls alerts */ -#define SL_ESEC_UNEXPECTED_MESSAGE (-310) /* ssl/tls alerts */ -#define SL_ESEC_BAD_RECORD_MAC (-320) /* ssl/tls alerts */ -#define SL_ESEC_DECRYPTION_FAILED (-321) /* ssl/tls alerts */ -#define SL_ESEC_RECORD_OVERFLOW (-322) /* ssl/tls alerts */ -#define SL_ESEC_DECOMPRESSION_FAILURE (-330) /* ssl/tls alerts */ -#define SL_ESEC_HANDSHAKE_FAILURE (-340) /* ssl/tls alerts */ -#define SL_ESEC_NO_CERTIFICATE (-341) /* ssl/tls alerts */ -#define SL_ESEC_BAD_CERTIFICATE (-342) /* ssl/tls alerts */ -#define SL_ESEC_UNSUPPORTED_CERTIFICATE (-343) /* ssl/tls alerts */ -#define SL_ESEC_CERTIFICATE_REVOKED (-344) /* ssl/tls alerts */ -#define SL_ESEC_CERTIFICATE_EXPIRED (-345) /* ssl/tls alerts */ -#define SL_ESEC_CERTIFICATE_UNKNOWN (-346) /* ssl/tls alerts */ -#define SL_ESEC_ILLEGAL_PARAMETER (-347) /* ssl/tls alerts */ -#define SL_ESEC_UNKNOWN_CA (-348) /* ssl/tls alerts */ -#define SL_ESEC_ACCESS_DENIED (-349) /* ssl/tls alerts */ -#define SL_ESEC_DECODE_ERROR (-350) /* ssl/tls alerts */ -#define SL_ESEC_DECRYPT_ERROR (-351) /* ssl/tls alerts */ -#define SL_ESEC_EXPORT_RESTRICTION (-360) /* ssl/tls alerts */ -#define SL_ESEC_PROTOCOL_VERSION (-370) /* ssl/tls alerts */ -#define SL_ESEC_INSUFFICIENT_SECURITY (-371) /* ssl/tls alerts */ -#define SL_ESEC_INTERNAL_ERROR (-380) /* ssl/tls alerts */ -#define SL_ESEC_USER_CANCELLED (-390) /* ssl/tls alerts */ -#define SL_ESEC_NO_RENEGOTIATION (-400) /* ssl/tls alerts */ -#define SL_ESEC_UNSUPPORTED_EXTENSION (-410) /* ssl/tls alerts */ -#define SL_ESEC_CERTIFICATE_UNOBTAINABLE (-411) /* ssl/tls alerts */ -#define SL_ESEC_UNRECOGNIZED_NAME (-412) /* ssl/tls alerts */ -#define SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE (-413) /* ssl/tls alerts */ -#define SL_ESEC_BAD_CERTIFICATE_HASH_VALUE (-414) /* ssl/tls alerts */ +#define SL_ESEC_CLOSE_NOTIFY (-300) /* ssl/tls alerts */ +#define SL_ESEC_UNEXPECTED_MESSAGE (-310) /* ssl/tls alerts */ +#define SL_ESEC_BAD_RECORD_MAC (-320) /* ssl/tls alerts */ +#define SL_ESEC_DECRYPTION_FAILED (-321) /* ssl/tls alerts */ +#define SL_ESEC_RECORD_OVERFLOW (-322) /* ssl/tls alerts */ +#define SL_ESEC_DECOMPRESSION_FAILURE (-330) /* ssl/tls alerts */ +#define SL_ESEC_HANDSHAKE_FAILURE (-340) /* ssl/tls alerts */ +#define SL_ESEC_NO_CERTIFICATE (-341) /* ssl/tls alerts */ +#define SL_ESEC_BAD_CERTIFICATE (-342) /* ssl/tls alerts */ +#define SL_ESEC_UNSUPPORTED_CERTIFICATE (-343) /* ssl/tls alerts */ +#define SL_ESEC_CERTIFICATE_REVOKED (-344) /* ssl/tls alerts */ +#define SL_ESEC_CERTIFICATE_EXPIRED (-345) /* ssl/tls alerts */ +#define SL_ESEC_CERTIFICATE_UNKNOWN (-346) /* ssl/tls alerts */ +#define SL_ESEC_ILLEGAL_PARAMETER (-347) /* ssl/tls alerts */ +#define SL_ESEC_UNKNOWN_CA (-348) /* ssl/tls alerts */ +#define SL_ESEC_ACCESS_DENIED (-349) /* ssl/tls alerts */ +#define SL_ESEC_DECODE_ERROR (-350) /* ssl/tls alerts */ +#define SL_ESEC_DECRYPT_ERROR (-351) /* ssl/tls alerts */ +#define SL_ESEC_EXPORT_RESTRICTION (-360) /* ssl/tls alerts */ +#define SL_ESEC_PROTOCOL_VERSION (-370) /* ssl/tls alerts */ +#define SL_ESEC_INSUFFICIENT_SECURITY (-371) /* ssl/tls alerts */ +#define SL_ESEC_INTERNAL_ERROR (-380) /* ssl/tls alerts */ +#define SL_ESEC_USER_CANCELLED (-390) /* ssl/tls alerts */ +#define SL_ESEC_NO_RENEGOTIATION (-400) /* ssl/tls alerts */ +#define SL_ESEC_UNSUPPORTED_EXTENSION (-410) /* ssl/tls alerts */ +#define SL_ESEC_CERTIFICATE_UNOBTAINABLE (-411) /* ssl/tls alerts */ +#define SL_ESEC_UNRECOGNIZED_NAME (-412) /* ssl/tls alerts */ +#define SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE (-413) /* ssl/tls alerts */ +#define SL_ESEC_BAD_CERTIFICATE_HASH_VALUE (-414) /* ssl/tls alerts */ /* propierty secure */ #define SL_ESECGENERAL (-450) /* error secure level general error */ #define SL_ESECDECRYPT (-451) /* error secure level, decrypt recv packet fail */ @@ -270,10 +270,10 @@ extern "C" { #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6_SECURE (0x70) /* */ #define SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER (0x80) /* 1536 bytes */ #define SL_SOCKET_PAYLOAD_TYPE_RAW_PACKET (0x90) /* 1536 bytes */ -#define SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 (0xa0) -#define SL_SOCKET_PAYLOAD_TYPE_RAW_IP6 (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 ) +#define SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 (0xa0) +#define SL_SOCKET_PAYLOAD_TYPE_RAW_IP6 (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 ) + - #define SL_SOL_SOCKET (1) /* Define the socket option category. */ #define SL_IPPROTO_IP (2) /* Define the IP option category. */ @@ -291,6 +291,8 @@ extern "C" { #define SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME (31) /* This option used to configue secure file */ #define SL_SO_SECURE_FILES_CA_FILE_NAME (32) /* This option used to configue secure file */ #define SL_SO_SECURE_FILES_DH_KEY_FILE_NAME (33) /* This option used to configue secure file */ +#define SO_SECURE_DOMAIN_NAME_VERIFICATION (35) +#define SECURE_MAX_DOMAIN_LENGTH (64) #define SL_IP_MULTICAST_IF (60) /* Specify outgoing multicast interface */ #define SL_IP_MULTICAST_TTL (61) /* Specify the TTL value to use for outgoing multicast packet. */ @@ -301,7 +303,7 @@ extern "C" { #define SL_IP_RAW_IPV6_HDRINCL (69) /* Transmitted buffer over IPv6 socket contains IPv6 header. */ #define SL_SO_PHY_RATE (100) /* WLAN Transmit rate */ -#define SL_SO_PHY_TX_POWER (101) /* TX Power level */ +#define SL_SO_PHY_TX_POWER (101) /* TX Power level */ #define SL_SO_PHY_NUM_FRAMES_TO_TX (102) /* Number of frames to transmit */ #define SL_SO_PHY_PREAMBLE (103) /* Preamble for transmission */ @@ -334,72 +336,72 @@ extern "C" { #define SL_IP_LEASE_EXPIRED (2) /* possible types when receiving SL_SOCKET_ASYNC_EVENT*/ -#define SSL_ACCEPT (1) /* accept failed due to ssl issue ( tcp pass) */ -#define RX_FRAGMENTATION_TOO_BIG (2) /* connection less mode, rx packet fragmentation > 16K, packet is being released */ -#define OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED (3) /* remote side down from secure to unsecure */ +#define SSL_ACCEPT (0) /* accept failed due to ssl issue ( tcp pass) */ +#define RX_FRAGMENTATION_TOO_BIG (1) /* connection less mode, rx packet fragmentation > 16K, packet is being released */ +#define OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED (2) /* remote side down from secure to unsecure */ #ifdef SL_INC_STD_BSD_API_NAMING -#define FD_SETSIZE SL_FD_SETSIZE - -#define SOCK_STREAM SL_SOCK_STREAM -#define SOCK_DGRAM SL_SOCK_DGRAM -#define SOCK_RAW SL_SOCK_RAW -#define IPPROTO_TCP SL_IPPROTO_TCP -#define IPPROTO_UDP SL_IPPROTO_UDP -#define IPPROTO_RAW SL_IPPROTO_RAW - -#define AF_INET SL_AF_INET -#define AF_INET6 SL_AF_INET6 +#define FD_SETSIZE SL_FD_SETSIZE + +#define SOCK_STREAM SL_SOCK_STREAM +#define SOCK_DGRAM SL_SOCK_DGRAM +#define SOCK_RAW SL_SOCK_RAW +#define IPPROTO_TCP SL_IPPROTO_TCP +#define IPPROTO_UDP SL_IPPROTO_UDP +#define IPPROTO_RAW SL_IPPROTO_RAW + +#define AF_INET SL_AF_INET +#define AF_INET6 SL_AF_INET6 #define AF_INET6_EUI_48 SL_AF_INET6_EUI_48 -#define AF_RF SL_AF_RF -#define AF_PACKET SL_AF_PACKET - -#define PF_INET SL_PF_INET -#define PF_INET6 SL_PF_INET6 - -#define INADDR_ANY SL_INADDR_ANY -#define ERROR SL_SOC_ERROR -#define INEXE SL_INEXE -#define EBADF SL_EBADF -#define ENSOCK SL_ENSOCK -#define EAGAIN SL_EAGAIN -#define EWOULDBLOCK SL_EWOULDBLOCK -#define ENOMEM SL_ENOMEM -#define EACCES SL_EACCES -#define EFAULT SL_EFAULT -#define EINVAL SL_EINVAL -#define EDESTADDRREQ SL_EDESTADDRREQ -#define EPROTOTYPE SL_EPROTOTYPE -#define ENOPROTOOPT SL_ENOPROTOOPT -#define EPROTONOSUPPORT SL_EPROTONOSUPPORT -#define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT -#define EOPNOTSUPP SL_EOPNOTSUPP -#define EAFNOSUPPORT SL_EAFNOSUPPORT -#define EADDRINUSE SL_EADDRINUSE -#define EADDRNOTAVAIL SL_EADDRNOTAVAIL -#define ENETUNREACH SL_ENETUNREACH -#define ENOBUFS SL_ENOBUFS -#define EOBUFF SL_EOBUFF -#define EISCONN SL_EISCONN -#define ENOTCONN SL_ENOTCONN -#define ETIMEDOUT SL_ETIMEDOUT -#define ECONNREFUSED SL_ECONNREFUSED - -#define SOL_SOCKET SL_SOL_SOCKET -#define IPPROTO_IP SL_IPPROTO_IP -#define SO_KEEPALIVE SL_SO_KEEPALIVE - -#define SO_RCVTIMEO SL_SO_RCVTIMEO -#define SO_NONBLOCKING SL_SO_NONBLOCKING - -#define IP_MULTICAST_IF SL_IP_MULTICAST_IF -#define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL -#define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP -#define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP - +#define AF_RF SL_AF_RF +#define AF_PACKET SL_AF_PACKET + +#define PF_INET SL_PF_INET +#define PF_INET6 SL_PF_INET6 + +#define INADDR_ANY SL_INADDR_ANY +#define ERROR SL_SOC_ERROR +#define INEXE SL_INEXE +#define EBADF SL_EBADF +#define ENSOCK SL_ENSOCK +#define EAGAIN SL_EAGAIN +#define EWOULDBLOCK SL_EWOULDBLOCK +#define ENOMEM SL_ENOMEM +#define EACCES SL_EACCES +#define EFAULT SL_EFAULT +#define EINVAL SL_EINVAL +#define EDESTADDRREQ SL_EDESTADDRREQ +#define EPROTOTYPE SL_EPROTOTYPE +#define ENOPROTOOPT SL_ENOPROTOOPT +#define EPROTONOSUPPORT SL_EPROTONOSUPPORT +#define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT +#define EOPNOTSUPP SL_EOPNOTSUPP +#define EAFNOSUPPORT SL_EAFNOSUPPORT +#define EADDRINUSE SL_EADDRINUSE +#define EADDRNOTAVAIL SL_EADDRNOTAVAIL +#define ENETUNREACH SL_ENETUNREACH +#define ENOBUFS SL_ENOBUFS +#define EOBUFF SL_EOBUFF +#define EISCONN SL_EISCONN +#define ENOTCONN SL_ENOTCONN +#define ETIMEDOUT SL_ETIMEDOUT +#define ECONNREFUSED SL_ECONNREFUSED + +#define SOL_SOCKET SL_SOL_SOCKET +#define IPPROTO_IP SL_IPPROTO_IP +#define SO_KEEPALIVE SL_SO_KEEPALIVE + +#define SO_RCVTIMEO SL_SO_RCVTIMEO +#define SO_NONBLOCKING SL_SO_NONBLOCKING + +#define IP_MULTICAST_IF SL_IP_MULTICAST_IF +#define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL +#define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP +#define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP + #define socklen_t SlSocklen_t #define timeval SlTimeval_t #define sockaddr SlSockAddr_t @@ -407,14 +409,14 @@ extern "C" { #define sockaddr_in6 SlSockAddrIn6_t #define in_addr SlInAddr_t #define sockaddr_in SlSockAddrIn_t - -#define MSG_DONTWAIT SL_MSG_DONTWAIT - -#define FD_SET SL_FD_SET -#define FD_CLR SL_FD_CLR + +#define MSG_DONTWAIT SL_MSG_DONTWAIT + +#define FD_SET SL_FD_SET +#define FD_CLR SL_FD_CLR #define FD_ISSET SL_FD_ISSET -#define FD_ZERO SL_FD_ZERO -#define fd_set SlFdSet_t +#define FD_ZERO SL_FD_ZERO +#define fd_set SlFdSet_t #define socket sl_Socket #define close sl_Close @@ -444,7 +446,7 @@ extern "C" { /* Internet address */ typedef struct SlInAddr_t { -#ifndef s_addr +#ifndef s_addr _u32 s_addr; /* Internet address 32 bits */ #else union S_un { @@ -457,22 +459,22 @@ typedef struct SlInAddr_t /* sockopt */ -typedef struct +typedef struct { _u32 KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/ }SlSockKeepalive_t; -typedef struct +typedef struct { _u32 ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/ }SlSockReuseaddr_t; -typedef struct +typedef struct { _u32 Winsize; /* receive window size for tcp sockets */ }SlSockWinsize_t; -typedef struct +typedef struct { _u32 NonblockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/ }SlSockNonblocking_t; @@ -530,7 +532,7 @@ typedef enum SL_BSD_SECURED_DH_IDX }slBsd_secureSocketFilesIndex_e; -typedef struct +typedef struct { SlInAddr_t imr_multiaddr; /* The IPv4 multicast address to join */ SlInAddr_t imr_interface; /* The interface to use for this group */ @@ -560,7 +562,7 @@ typedef struct SlSockAddr_t /* IpV6 or Ipv6 EUI64 */ typedef struct SlIn6Addr_t { - union + union { _u8 _S6_u8[16]; _u32 _S6_u32[4]; @@ -593,7 +595,7 @@ typedef struct _u32 dns; }SlIpV4AcquiredAsync_t; -typedef struct +typedef struct { _u32 type; _u32 ip[4]; @@ -621,7 +623,7 @@ typedef union { SlIpV4AcquiredAsync_t ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/ SlIpV6AcquiredAsync_t ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/ - _u32 sd; /*SL_SOCKET_TX_FAILED_EVENT*/ + _u32 sd; /*SL_SOCKET_TX_FAILED_EVENT*/ SlIpLeasedAsync_t ipLeased; /* SL_NETAPP_IP_LEASED_EVENT */ SlIpReleasedAsync_t ipReleased; /* SL_NETAPP_IP_RELEASED_EVENT */ } SlNetAppEventData_u; @@ -640,8 +642,8 @@ typedef struct sock_secureFiles typedef struct SlFdSet_t /* The select socket array manager */ -{ - _u32 fd_array[(SL_FD_SETSIZE + 31)/32]; /* Bit map of SOCKET Descriptors */ +{ + _u32 fd_array[(SL_FD_SETSIZE + (_u8)31)/(_u8)32]; /* Bit map of SOCKET Descriptors */ } SlFdSet_t; typedef struct @@ -662,17 +664,17 @@ typedef struct /*! \brief create an endpoint for communication - - The socket function creates a new socket of a certain socket type, identified + + The socket function creates a new socket of a certain socket type, identified by an integer number, and allocates system resources to it. This function is called by the application layer to obtain a socket handle. - + \param[in] domain specifies the protocol family of the created socket. For example: AF_INET for network protocol IPv4 - AF_RF for starting transceiver mode. Notes: + AF_RF for starting transceiver mode. Notes: - sending and receiving any packet overriding 802.11 header - - for optimized power consumption the socket will be started in TX + - for optimized power consumption the socket will be started in TX only mode until receive command is activated AF_INET6 for IPv6 @@ -685,27 +687,27 @@ typedef struct SOCK_DGRAM - L2 socket SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment) - \param[in] protocol specifies a particular transport to be used with + \param[in] protocol specifies a particular transport to be used with the socket. - The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP, + The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP, IPPROTO_DCCP. - The value 0 may be used to select a default + The value 0 may be used to select a default protocol from the selected domain and type - - \return On success, socket handle that is used for consequent socket operations. + + \return On success, socket handle that is used for consequent socket operations. A successful return code should be a positive number (int16) On error, a negative (int16) value will be returned specifying the error code. SL_EAFNOSUPPORT - illegal domain parameter SL_EPROTOTYPE - illegal type parameter SL_EACCES - permission denied - SL_ENSOCK - exceeded maximal number of socket + SL_ENSOCK - exceeded maximal number of socket SL_ENOMEM - memory allocation error SL_EINVAL - error in socket configuration SL_EPROTONOSUPPORT - illegal protocol parameter SL_EOPNOTSUPP - illegal combination of protocol and type parameters - - + + \sa sl_Close \note belongs to \ref basic_api \warning @@ -722,8 +724,8 @@ _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol); \param[in] sd socket handle (received in sl_Socket) - \return On success, zero is returned. - On error, a negative number is returned. + \return On success, zero is returned. + On error, a negative number is returned. \sa sl_Socket \note belongs to \ref ext_api @@ -735,27 +737,27 @@ _i16 sl_Close(_i16 sd); /*! \brief Accept a connection on a socket - + This function is used with connection-based socket types (SOCK_STREAM). - It extracts the first connection request on the queue of pending - connections, creates a new connected socket, and returns a new file + It extracts the first connection request on the queue of pending + connections, creates a new connected socket, and returns a new file descriptor referring to that socket. - The newly created socket is not in the listening state. The - original socket sd is unaffected by this call. - The argument sd is a socket that has been created with - sl_Socket(), bound to a local address with sl_Bind(), and is - listening for connections after a sl_Listen(). The argument \b - \e addr is a pointer to a sockaddr structure. This structure - is filled in with the address of the peer socket, as known to - the communications layer. The exact format of the address - returned addr is determined by the socket's address family. - The \b \e addrlen argument is a value-result argument: it - should initially contain the size of the structure pointed to - by addr, on return it will contain the actual length (in + The newly created socket is not in the listening state. The + original socket sd is unaffected by this call. + The argument sd is a socket that has been created with + sl_Socket(), bound to a local address with sl_Bind(), and is + listening for connections after a sl_Listen(). The argument \b + \e addr is a pointer to a sockaddr structure. This structure + is filled in with the address of the peer socket, as known to + the communications layer. The exact format of the address + returned addr is determined by the socket's address family. + The \b \e addrlen argument is a value-result argument: it + should initially contain the size of the structure pointed to + by addr, on return it will contain the actual length (in bytes) of the address returned. - + \param[in] sd socket descriptor (handle) - \param[out] addr the argument addr is a pointer + \param[out] addr the argument addr is a pointer to a sockaddr structure. This structure is filled in with the address of the peer socket, as @@ -769,16 +771,16 @@ _i16 sl_Close(_i16 sd); only AF_INET is supported.\n - socket address, the length depends on the code format - \param[out] addrlen the addrlen argument is a value-result + \param[out] addrlen the addrlen argument is a value-result argument: it should initially contain the size of the structure pointed to by addr - + \return On success, a socket handle. On a non-blocking accept a possible negative value is SL_EAGAIN. On failure, negative value. SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS - + \sa sl_Socket sl_Bind sl_Listen \note belongs to \ref server_side \warning @@ -789,16 +791,16 @@ _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen); /*! \brief assign a name to a socket - + This function gives the socket the local address addr. addr is addrlen bytes long. Traditionally, this is called When a socket is created with socket, it exists in a name space (address family) but has no name assigned. It is necessary to assign a local address before a SOCK_STREAM socket may receive connections. - + \param[in] sd socket descriptor (handle) - \param[in] addr specifies the destination + \param[in] addr specifies the destination addrs\n sockaddr:\n - code for the address format. On this version only AF_INET is @@ -806,9 +808,9 @@ _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen); the length depends on the code format \param[in] addrlen contains the size of the structure pointed to by addr - + \return On success, zero is returned. On error, a negative error code is returned. - + \sa sl_Socket sl_Accept sl_Listen \note belongs to \ref basic_api \warning @@ -819,20 +821,20 @@ _i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen); /*! \brief listen for connections on a socket - + The willingness to accept incoming connections and a queue limit for incoming connections are specified with listen(), and then the connections are accepted with accept. The listen() call applies only to sockets of type SOCK_STREAM The backlog parameter defines the maximum length the queue of - pending connections may grow to. - + pending connections may grow to. + \param[in] sd socket descriptor (handle) - \param[in] backlog specifies the listen queue depth. - - + \param[in] backlog specifies the listen queue depth. + + \return On success, zero is returned. On error, a negative error code is returned. - + \sa sl_Socket sl_Accept sl_Bind \note belongs to \ref server_side \warning @@ -842,22 +844,22 @@ _i16 sl_Listen(_i16 sd, _i16 backlog); #endif /*! - \brief Initiate a connection on a socket - - Function connects the socket referred to by the socket - descriptor sd, to the address specified by addr. The addrlen - argument specifies the size of addr. The format of the - address in addr is determined by the address space of the - socket. If it is of type SOCK_DGRAM, this call specifies the - peer with which the socket is to be associated; this address - is that to which datagrams are to be sent, and the only - address from which datagrams are to be received. If the - socket is of type SOCK_STREAM, this call attempts to make a - connection to another socket. The other socket is specified - by address, which is an address in the communications space - of the socket. - - + \brief Initiate a connection on a socket + + Function connects the socket referred to by the socket + descriptor sd, to the address specified by addr. The addrlen + argument specifies the size of addr. The format of the + address in addr is determined by the address space of the + socket. If it is of type SOCK_DGRAM, this call specifies the + peer with which the socket is to be associated; this address + is that to which datagrams are to be sent, and the only + address from which datagrams are to be received. If the + socket is of type SOCK_STREAM, this call attempts to make a + connection to another socket. The other socket is specified + by address, which is an address in the communications space + of the socket. + + \param[in] sd socket descriptor (handle) \param[in] addr specifies the destination addr\n sockaddr:\n - code for the @@ -865,16 +867,16 @@ _i16 sl_Listen(_i16 sd, _i16 backlog); only AF_INET is supported.\n - socket address, the length depends on the code format - - \param[in] addrlen contains the size of the structure pointed + + \param[in] addrlen contains the size of the structure pointed to by addr - + \return On success, a socket handle. On a non-blocking connect a possible negative value is SL_EALREADY. On failure, negative value. SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS - + \sa sl_Socket \note belongs to \ref client_side \warning @@ -885,23 +887,23 @@ _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen); /*! \brief Monitor socket activity - + Select allow a program to monitor multiple file descriptors, - waiting until one or more of the file descriptors become - "ready" for some class of I/O operation - - + waiting until one or more of the file descriptors become + "ready" for some class of I/O operation + + \param[in] nfds the highest-numbered file descriptor in any of the three sets, plus 1. \param[out] readsds socket descriptors list for read monitoring and accept monitoring \param[out] writesds socket descriptors list for connect monitoring only, write monitoring is not supported, non blocking connect is supported \param[out] exceptsds socket descriptors list for exception monitoring, not supported. \param[in] timeout is an upper bound on the amount of time elapsed - before select() returns. Null or above 0xffff seconds means + before select() returns. Null or above 0xffff seconds means infinity timeout. The minimum timeout is 10 milliseconds, - less than 10 milliseconds will be set automatically to 10 milliseconds. + less than 10 milliseconds will be set automatically to 10 milliseconds. Max microseconds supported is 0xfffc00. - + \return On success, select() returns the number of file descriptors contained in the three returned descriptor sets (that is, the total number of bits that @@ -910,25 +912,25 @@ _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen); happens. On error, a negative value is returned. readsds - return the sockets on which Read request will return without delay with valid data. - writesds - return the sockets on which Write request + writesds - return the sockets on which Write request will return without delay. - exceptsds - return the sockets closed recently. + exceptsds - return the sockets closed recently. SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS - + \sa sl_Socket - \note If the timeout value set to less than 5ms it will automatically set + \note If the timeout value set to less than 5ms it will automatically set to 5ms to prevent overload of the system belongs to \ref basic_api - + Only one sl_Select can be handled at a time. Calling this API while the same command is called from another thread, may result in one of the two scenarios: 1. The command will wait (internal) until the previous command finish, and then be executed. - 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. + 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command. - + \warning */ #if _SL_INCLUDE_FUNC(sl_Select) @@ -937,14 +939,14 @@ _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *ex /*! \brief Select's SlFdSet_t SET function - + Sets current socket descriptor on SlFdSet_t container */ void SL_FD_SET(_i16 fd, SlFdSet_t *fdset); /*! \brief Select's SlFdSet_t CLR function - + Clears current socket descriptor on SlFdSet_t container */ void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset); @@ -952,7 +954,7 @@ void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset); /*! \brief Select's SlFdSet_t ISSET function - + Checks if current socket descriptor is set (TRUE/FALSE) \return Returns TRUE if set, FALSE if unset @@ -962,7 +964,7 @@ _i16 SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset); /*! \brief Select's SlFdSet_t ZERO function - + Clears all socket descriptors from SlFdSet_t */ void SL_FD_ZERO(SlFdSet_t *fdset); @@ -973,29 +975,29 @@ void SL_FD_ZERO(SlFdSet_t *fdset); /*! \brief set socket options - + This function manipulate the options associated with a socket. Options may exist at multiple protocol levels; they are always present at the uppermost socket level. - + When manipulating socket options the level at which the option resides and the name of the option must be specified. To manipulate options at the socket level, level is specified as SOL_SOCKET. To manipulate options at any other level the protocol number of the appropriate proto- col controlling the option is supplied. For example, to indicate that an option is to be interpreted by the TCP protocol, level should be set to - the protocol number of TCP; - - The parameters optval and optlen are used to access optval - - ues for setsockopt(). For getsockopt() they identify a - buffer in which the value for the requested option(s) are to - be returned. For getsockopt(), optlen is a value-result - parameter, initially containing the size of the buffer - pointed to by option_value, and modified on return to - indicate the actual size of the value returned. If no option - value is to be supplied or returned, option_value may be + the protocol number of TCP; + + The parameters optval and optlen are used to access optval - + ues for setsockopt(). For getsockopt() they identify a + buffer in which the value for the requested option(s) are to + be returned. For getsockopt(), optlen is a value-result + parameter, initially containing the size of the buffer + pointed to by option_value, and modified on return to + indicate the actual size of the value returned. If no option + value is to be supplied or returned, option_value may be NULL. - + \param[in] sd socket handle \param[in] level defines the protocol level for this option - SL_SOL_SOCKET Socket level configurations (L4, transport layer) @@ -1030,30 +1032,30 @@ void SL_FD_ZERO(SlFdSet_t *fdset); This options takes SlSockSecureMask struct as parameter - SL_SO_SECURE_FILES_CA_FILE_NAME \n Map secured socket to CA file by name \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME \n Map secured socket to private key by name \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME \n Map secured socket to certificate file by name \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - SL_SO_SECURE_FILES_DH_KEY_FILE_NAME \n Map secured socket to Diffie Hellman file by name \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - SL_SO_CHANGE_CHANNEL \n Sets channel in transceiver mode. This options takes _u32 as channel number parameter - - SL_IPPROTO_IP + - SL_IPPROTO_IP - SL_IP_MULTICAST_TTL \n Set the time-to-live value of outgoing multicast packets for this socket. \n - This options takes _u8 as parameter + This options takes _u8 as parameter - SL_IP_ADD_MEMBERSHIP \n UDP socket, Join a multicast group. \n This options takes SlSockIpMreq struct as parameter - SL_IP_DROP_MEMBERSHIP \n UDP socket, Leave a multicast group \n This options takes SlSockIpMreq struct as parameter - - SL_IP_RAW_RX_NO_HEADER \n + - SL_IP_RAW_RX_NO_HEADER \n Raw socket remove IP header from received data. \n Default: data includes ip header \n This options takes _u32 as parameter @@ -1084,47 +1086,47 @@ void SL_FD_ZERO(SlFdSet_t *fdset); - SL_SO_PHY_PREAMBLE \n RAW socket, set WLAN PHY preamble for Long/Short\n This options takes _u32 as parameter - + \param[in] optval specifies a value for the option - \param[in] optlen specifies the length of the + \param[in] optlen specifies the length of the option value - - \return On success, zero is returned. - On error, a negative value is returned. + + \return On success, zero is returned. + On error, a negative value is returned. \sa sl_getsockopt - \note belongs to \ref basic_api + \note belongs to \ref basic_api \warning \par Examples: - \par + \par SL_SO_KEEPALIVE: (disable Keepalive) - \code + \code SlSockKeepalive_t enableOption; enableOption.KeepaliveEnabled = 0; - sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (_u8 *)&enableOption,sizeof(enableOption)); + sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (_u8 *)&enableOption,sizeof(enableOption)); \endcode - \par + \par SL_SO_RCVTIMEO: \code struct SlTimeval_t timeVal; timeVal.tv_sec = 1; // Seconds timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution - sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); // Enable receive timeout + sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); // Enable receive timeout \endcode - \par + \par SL_SO_RCVBUF: \code SlSockWinsize_t size; size.Winsize = 3000; // bytes sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVBUF, (_u8 *)&size, sizeof(size)); \endcode - \par + \par SL_SO_NONBLOCKING: \code SlSockNonblocking_t enableOption; enableOption.NonblockingEnabled = 1; sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode \endcode - \par + \par SL_SO_SECMETHOD: \code SlSockSecureMethod method; @@ -1132,108 +1134,108 @@ void SL_FD_ZERO(SlFdSet_t *fdset); SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET); sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (_u8 *)&method, sizeof(method)); \endcode - \par + \par SL_SO_SECURE_MASK: - \code + \code SlSockSecureMask cipher; cipher.secureMask = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA; // cipher type SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET); sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SEC_MASK,(_u8 *)&cipher, sizeof(cipher)); \endcode - \par + \par SL_SO_SECURE_FILES_CA_FILE_NAME: - \code + \code sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"exuifaxCaCert.der",strlen("exuifaxCaCert.der")); \endcode - \par + \par SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME: - \code + \code sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME,"myPrivateKey.der",strlen("myPrivateKey.der")); \endcode - \par + \par SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME: \code sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME,"myCertificate.der",strlen("myCertificate.der")); \endcode - \par + \par SL_SO_SECURE_FILES_DH_KEY_FILE_NAME: \code sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_DH_KEY_FILE_NAME,"myDHinServerMode.der",strlen("myDHinServerMode.der")); \endcode - \par + \par SL_IP_MULTICAST_TTL: \code _u8 ttl = 20; sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_MULTICAST_TTL, &ttl, sizeof(ttl)); \endcode - \par + \par SL_IP_ADD_MEMBERSHIP: \code SlSockIpMreq mreq; sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); \endcode - \par + \par SL_IP_DROP_MEMBERSHIP: \code SlSockIpMreq mreq; sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); \endcode - \par + \par SL_SO_CHANGE_CHANNEL: \code _u32 newChannel = 6; // range is 1-13 - sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel)); + sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel)); \endcode - \par + \par SL_IP_RAW_RX_NO_HEADER: \code _u32 header = 1; // remove ip header sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_RX_NO_HEADER, &header, sizeof(header)); \endcode - \par + \par SL_IP_HDRINCL: \code _u32 header = 1; sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header)); \endcode - \par + \par SL_IP_RAW_IPV6_HDRINCL: \code _u32 header = 1; sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_IPV6_HDRINCL, &header, sizeof(header)); \endcode - \par + \par SL_SO_PHY_RATE: \code _u32 rate = 6; // see wlan.h RateIndex_e for values - sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate)); + sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate)); \endcode - \par + \par SL_SO_PHY_TX_POWER: \code _u32 txpower = 1; // valid range is 1-15 sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_POWER, &txpower, sizeof(txpower)); \endcode - \par + \par SL_SO_PHY_NUM_FRAMES_TO_TX: \code - _u32 numframes = 1; + _u32 numframes = 1; sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes)); \endcode - \par + \par SL_SO_PHY_PREAMBLE: \code _u32 preamble = 1; @@ -1247,38 +1249,38 @@ _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSock /*! \brief Get socket options - + This function manipulate the options associated with a socket. Options may exist at multiple protocol levels; they are always present at the uppermost socket level. - + When manipulating socket options the level at which the option resides and the name of the option must be specified. To manipulate options at the socket level, level is specified as SOL_SOCKET. To manipulate options at any other level the protocol number of the appropriate proto- col controlling the option is supplied. For example, to indicate that an option is to be interpreted by the TCP protocol, level should be set to - the protocol number of TCP; - - The parameters optval and optlen are used to access optval - - ues for setsockopt(). For getsockopt() they identify a - buffer in which the value for the requested option(s) are to - be returned. For getsockopt(), optlen is a value-result - parameter, initially containing the size of the buffer - pointed to by option_value, and modified on return to - indicate the actual size of the value returned. If no option - value is to be supplied or returned, option_value may be - NULL. - - + the protocol number of TCP; + + The parameters optval and optlen are used to access optval - + ues for setsockopt(). For getsockopt() they identify a + buffer in which the value for the requested option(s) are to + be returned. For getsockopt(), optlen is a value-result + parameter, initially containing the size of the buffer + pointed to by option_value, and modified on return to + indicate the actual size of the value returned. If no option + value is to be supplied or returned, option_value may be + NULL. + + \param[in] sd socket handle \param[in] level defines the protocol level for this option \param[in] optname defines the option name to interrogate \param[out] optval specifies a value for the option - \param[out] optlen specifies the length of the + \param[out] optlen specifies the length of the option value - - \return On success, zero is returned. + + \return On success, zero is returned. On error, a negative value is returned. \sa sl_SetSockOpt \note See sl_SetSockOpt @@ -1291,31 +1293,31 @@ _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t /*! \brief read data from TCP socket - + function receives a message from a connection-mode socket - + \param[in] sd socket handle - \param[out] buf Points to the buffer where the + \param[out] buf Points to the buffer where the message should be stored. - \param[in] Len Specifies the length in bytes of - the buffer pointed to by the buffer argument. + \param[in] Len Specifies the length in bytes of + the buffer pointed to by the buffer argument. Range: 1-16000 bytes - \param[in] flags Specifies the type of message + \param[in] flags Specifies the type of message reception. On this version, this parameter is not supported. - - \return return the number of bytes received, + + \return return the number of bytes received, or a negative value if an error occurred. using a non-blocking recv a possible negative value is SL_EAGAIN. SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS - + \sa sl_RecvFrom \note belongs to \ref recv_api \warning \par Examples: \code An example of receiving data using TCP socket: - + SlSockAddrIn_t Addr; SlSockAddrIn_t LocalAddr; _i16 AddrSize = sizeof(SlSockAddrIn_t); @@ -1348,7 +1350,7 @@ _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t size = sl_Recv(sd,buffer,1536,0); transHeader = (SlTransceiverRxOverHead_t *)buffer; printf("RSSI is %d frame type is 0x%x size %d\n",transHeader->rssi,buffer[sizeof(SlTransceiverRxOverHead_t)],size); - } + } \endcode */ #if _SL_INCLUDE_FUNC(sl_Recv) @@ -1357,18 +1359,18 @@ _i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags); /*! \brief read data from socket - + function receives a message from a connection-mode or connectionless-mode socket - - \param[in] sd socket handle + + \param[in] sd socket handle \param[out] buf Points to the buffer where the message should be stored. \param[in] Len Specifies the length in bytes of the buffer pointed to by the buffer argument. Range: 1-16000 bytes \param[in] flags Specifies the type of message reception. On this version, this parameter is not supported. - \param[in] from pointer to an address structure + \param[in] from pointer to an address structure indicating the source address.\n sockaddr:\n - code for the address format. On this @@ -1378,21 +1380,21 @@ _i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags); format \param[in] fromlen source address structure size. This parameter MUST be set to the size of the structure pointed to by addr. - - - \return return the number of bytes received, + + + \return return the number of bytes received, or a negative value if an error occurred. using a non-blocking recv a possible negative value is SL_EAGAIN. - SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length. + SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length. SL_POOL_IS_EMPTY may be return in case there are no resources in the system In this case try again later or increase MAX_CONCURRENT_ACTIONS - + \sa sl_Recv \note belongs to \ref recv_api \warning \par Example: \code An example of receiving data: - + SlSockAddrIn_t Addr; SlSockAddrIn_t LocalAddr; _i16 AddrSize = sizeof(SlSockAddrIn_t); @@ -1416,34 +1418,34 @@ _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, S /*! \brief write data to TCP socket - + This function is used to transmit a message to another socket. Returns immediately after sending data to device. In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to be received. - In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the - frame data buffer for WLAN FCS - + In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the + frame data buffer for WLAN FCS + \param[in] sd socket handle - \param[in] buf Points to a buffer containing + \param[in] buf Points to a buffer containing the message to be sent \param[in] Len message size in bytes. Range: 1-1460 bytes - \param[in] flags Specifies the type of message + \param[in] flags Specifies the type of message transmission. On this version, this parameter is not supported for TCP. For transceiver mode, the SL_RAW_RF_TX_PARAMS macro can be used to determine transmission parameters (channel,rate,tx_power,preamble) - - - \return Return the number of bytes transmitted, + + + \return Return the number of bytes transmitted, or -1 if an error occurred - - \sa sl_SendTo + + \sa sl_SendTo \note belongs to \ref send_api - \warning + \warning \par Example: \code An example of sending data: - + SlSockAddrIn_t Addr; _i16 AddrSize = sizeof(SlSockAddrIn_t); _i16 SockID; @@ -1457,30 +1459,30 @@ _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, S SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0); Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize); Status = sl_Send(SockID, Buf, 1460, 0 ); - + \endcode - */ + */ #if _SL_INCLUDE_FUNC(sl_Send ) _i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags); #endif /*! \brief write data to socket - + This function is used to transmit a message to another socket (connection less socket SOCK_DGRAM, SOCK_RAW). Returns immediately after sending data to device. In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to be received. - + \param[in] sd socket handle - \param[in] buf Points to a buffer containing + \param[in] buf Points to a buffer containing the message to be sent \param[in] Len message size in bytes. Range: 1-1460 bytes - \param[in] flags Specifies the type of message + \param[in] flags Specifies the type of message transmission. On this version, this parameter is not - supported - \param[in] to pointer to an address structure + supported + \param[in] to pointer to an address structure indicating the destination address.\n sockaddr:\n - code for the address format. On this @@ -1488,17 +1490,17 @@ _i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags); supported.\n - socket address, the length depends on the code format - \param[in] tolen destination address structure size - - \return Return the number of transmitted bytes, + \param[in] tolen destination address structure size + + \return Return the number of transmitted bytes, or -1 if an error occurred - + \sa sl_Send \note belongs to \ref send_api \warning \par Example: \code An example of sending data: - + SlSockAddrIn_t Addr; _i16 AddrSize = sizeof(SlSockAddrIn_t); _i16 SockID; @@ -1520,16 +1522,16 @@ _i16 sl_SendTo(_i16 sd, const void *buf, _i16 Len, _i16 flags, const SlSockAddr_ /*! \brief Reorder the bytes of a 32-bit unsigned value - + This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order. - - \param[in] var variable to reorder - - \return Return the reorder variable, - + + \param[in] var variable to reorder + + \return Return the reorder variable, + \sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept \note belongs to \ref send_api - \warning + \warning */ #if _SL_INCLUDE_FUNC(sl_Htonl ) _u32 sl_Htonl( _u32 val ); @@ -1539,16 +1541,16 @@ _u32 sl_Htonl( _u32 val ); /*! \brief Reorder the bytes of a 16-bit unsigned value - + This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order. - - \param[in] var variable to reorder - - \return Return the reorder variable, - + + \param[in] var variable to reorder + + \return Return the reorder variable, + \sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept \note belongs to \ref send_api - \warning + \warning */ #if _SL_INCLUDE_FUNC(sl_Htons ) _u16 sl_Htons( _u16 val ); diff --git a/hardware/lm4f/libraries/WiFi/utility/spawn.c b/hardware/lm4f/libraries/WiFi/utility/spawn.c index d83bbbafeb5..7a79d062b20 100644 --- a/hardware/lm4f/libraries/WiFi/utility/spawn.c +++ b/hardware/lm4f/libraries/WiFi/utility/spawn.c @@ -1,35 +1,35 @@ /* * spawn.c - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -40,6 +40,8 @@ /* Include files */ /*****************************************************************************/ #include "simplelink.h" +#include "protocol.h" +#include "driver.h" #if (defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN)) @@ -48,31 +50,34 @@ typedef struct _SlInternalSpawnEntry_t { - _SlSpawnEntryFunc_t pEntry; - void* pValue; + _SlSpawnEntryFunc_t pEntry; + void* pValue; struct _SlInternalSpawnEntry_t* pNext; }_SlInternalSpawnEntry_t; typedef struct { - _SlInternalSpawnEntry_t SpawnEntries[_SL_MAX_INTERNAL_SPAWN_ENTRIES]; + _SlInternalSpawnEntry_t SpawnEntries[_SL_MAX_INTERNAL_SPAWN_ENTRIES]; _SlInternalSpawnEntry_t* pFree; _SlInternalSpawnEntry_t* pWaitForExe; _SlInternalSpawnEntry_t* pLastInWaitList; _SlSyncObj_t SyncObj; _SlLockObj_t LockObj; + _u8 IrqWriteCnt; + _u8 IrqReadCnt; + void* pIrqFuncValue; }_SlInternalSpawnCB_t; _SlInternalSpawnCB_t g_SlInternalSpawnCB; -void _SlInternalSpawnTaskEntry() +void _SlInternalSpawnTaskEntry() { _i16 i; _SlInternalSpawnEntry_t* pEntry; _u8 LastEntry; - /* create and lock the locking object. lock in order to avoid race condition + /* create and lock the locking object. lock in order to avoid race condition on the first creation */ sl_LockObjCreate(&g_SlInternalSpawnCB.LockObj,"SlSpawnProtect"); sl_LockObjLock(&g_SlInternalSpawnCB.LockObj,SL_OS_NO_WAIT); @@ -93,24 +98,38 @@ void _SlInternalSpawnTaskEntry() } g_SlInternalSpawnCB.SpawnEntries[i].pNext = NULL; - _SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj); + g_SlInternalSpawnCB.IrqWriteCnt =0; + g_SlInternalSpawnCB.IrqReadCnt = 0; + g_SlInternalSpawnCB.pIrqFuncValue = NULL; + + SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj); /* here we ready to execute entries */ while (TRUE) { sl_SyncObjWait(&g_SlInternalSpawnCB.SyncObj,SL_OS_WAIT_FOREVER); + + /* handle IRQ requests */ + while (g_SlInternalSpawnCB.IrqWriteCnt != g_SlInternalSpawnCB.IrqReadCnt) + { + /* handle the ones that came from ISR context*/ + _SlDrvMsgReadSpawnCtx(g_SlInternalSpawnCB.pIrqFuncValue); + g_SlInternalSpawnCB.IrqReadCnt++; + } + /* go over all entries that already waiting for execution */ LastEntry = FALSE; + do { /* get entry to execute */ - _SlDrvObjLockWaitForever(&g_SlInternalSpawnCB.LockObj); + SL_DRV_OBJ_LOCK_FOREVER(&g_SlInternalSpawnCB.LockObj); pEntry = g_SlInternalSpawnCB.pWaitForExe; if ( NULL == pEntry ) { - _SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj); + SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj); break; } g_SlInternalSpawnCB.pWaitForExe = pEntry->pNext; @@ -120,7 +139,7 @@ void _SlInternalSpawnTaskEntry() LastEntry = TRUE; } - _SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj); + SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj); /* pEntry could be null in case that the sync was already set by some of the entries during execution of earlier entry */ @@ -129,8 +148,8 @@ void _SlInternalSpawnTaskEntry() pEntry->pEntry(pEntry->pValue); /* free the entry */ - _SlDrvObjLockWaitForever(&g_SlInternalSpawnCB.LockObj); - + SL_DRV_OBJ_LOCK_FOREVER(&g_SlInternalSpawnCB.LockObj); + pEntry->pNext = g_SlInternalSpawnCB.pFree; g_SlInternalSpawnCB.pFree = pEntry; @@ -141,7 +160,7 @@ void _SlInternalSpawnTaskEntry() LastEntry = FALSE; } - _SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj); + SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj); } @@ -155,13 +174,25 @@ _i16 _SlInternalSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags) _i16 Res = 0; _SlInternalSpawnEntry_t* pSpawnEntry; - if (NULL == pEntry) + + /* Increment the counter that specifies that async event has recived + from interrupt context and should be handled by the internal spawn task */ + if (flags & SL_SPAWN_FLAG_FROM_SL_IRQ_HANDLER) + { + g_SlInternalSpawnCB.IrqWriteCnt++; + g_SlInternalSpawnCB.pIrqFuncValue = pValue; + SL_DRV_SYNC_OBJ_SIGNAL(&g_SlInternalSpawnCB.SyncObj); + return Res; + } + + + if (NULL == pEntry || (g_SlInternalSpawnCB.pFree == NULL)) { Res = -1; } else { - _SlDrvObjLockWaitForever(&g_SlInternalSpawnCB.LockObj); + SL_DRV_OBJ_LOCK_FOREVER(&g_SlInternalSpawnCB.LockObj); pSpawnEntry = g_SlInternalSpawnCB.pFree; g_SlInternalSpawnCB.pFree = pSpawnEntry->pNext; @@ -181,10 +212,10 @@ _i16 _SlInternalSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags) g_SlInternalSpawnCB.pLastInWaitList = pSpawnEntry; } - _SlDrvObjUnLock(&g_SlInternalSpawnCB.LockObj); - + SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj); + /* this sync is called after releasing the lock object to avoid unnecessary context switches */ - _SlDrvSyncObjSignal(&g_SlInternalSpawnCB.SyncObj); + SL_DRV_SYNC_OBJ_SIGNAL(&g_SlInternalSpawnCB.SyncObj); } return Res; diff --git a/hardware/lm4f/libraries/WiFi/utility/spawn.h b/hardware/lm4f/libraries/WiFi/utility/spawn.h index aff10c11875..a9bbfc69fb8 100644 --- a/hardware/lm4f/libraries/WiFi/utility/spawn.h +++ b/hardware/lm4f/libraries/WiFi/utility/spawn.h @@ -1,43 +1,43 @@ /* * spawn.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -#ifndef __NONOS_H__ -#define __NONOS_H__ +#ifndef __SPAWN_H__ +#define __SPAWN_H__ -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif diff --git a/hardware/lm4f/libraries/WiFi/utility/trace.h b/hardware/lm4f/libraries/WiFi/utility/trace.h index 91c29a366e8..5461bb4b43e 100644 --- a/hardware/lm4f/libraries/WiFi/utility/trace.h +++ b/hardware/lm4f/libraries/WiFi/utility/trace.h @@ -1,39 +1,39 @@ /* * trace.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - + #include "simplelink.h" @@ -51,10 +51,16 @@ extern "C" { /*****************************************************************************/ #define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000) - -#define _SlDrvAssert(line ) { while(1); } -#define _SL_ASSERT(expr) { if(!(expr)){_SlDrvAssert(__LINE__); } } +#ifdef SL_TINY_EXT +#define _SlDrvAssert(line ) { while(1); } +#else +#define _SlDrvAssert( ) { _SlDriverHandleError(SL_DEVICE_DRIVER_ASSERT_ERROR_EVENT, 0, 0); } +#endif + +#define _SL_ASSERT(expr) { if(!(expr)){ \ + _SlDrvAssert(); } \ +} #define _SL_ERROR(expr, error) { if(!(expr)){return (error); } } #define SL_HANDLING_ASSERT 2 @@ -63,13 +69,18 @@ extern "C" { #ifndef SL_TINY_EXT -#define SL_SELF_COND_HANDLING SL_HANDLING_ASSERT -#define SL_PROTOCOL_HANDLING SL_HANDLING_ASSERT -#define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ASSERT -#define SL_NWP_IF_HANDLING SL_HANDLING_ASSERT -#define SL_OSI_RET_OK_HANDLING SL_HANDLING_ASSERT -#define SL_MALLOC_OK_HANDLING SL_HANDLING_ASSERT -#define SL_USER_ARGS_HANDLING SL_HANDLING_ASSERT + +#if 1 +#define SL_SELF_COND_HANDLING SL_HANDLING_ERROR +#define SL_PROTOCOL_HANDLING SL_HANDLING_ERROR +#define SL_DRV_RET_CODE_HANDLING SL_HANDLING_ERROR +#define SL_NWP_IF_HANDLING SL_HANDLING_ERROR +#define SL_OSI_RET_OK_HANDLING SL_HANDLING_ERROR +#define SL_MALLOC_OK_HANDLING SL_HANDLING_ERROR +#define SL_USER_ARGS_HANDLING SL_HANDLING_ERROR +#define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_ERROR +#endif + #else #define SL_SELF_COND_HANDLING SL_HANDLING_NONE #define SL_PROTOCOL_HANDLING SL_HANDLING_NONE @@ -78,9 +89,16 @@ extern "C" { #define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE #define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE #define SL_USER_ARGS_HANDLING SL_HANDLING_NONE +#define SL_ERR_IN_PROGRESS_HANDLING SL_HANDLING_NONE #endif +#if (SL_ERR_IN_PROGRESS_HANDLING == SL_HANDLING_ERROR) +#define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS() { \ + if ( g_bDeviceRestartIsRequired == (_u8)TRUE) return SL_API_ABORTED; } +#else +#define VERIFY_NO_ERROR_HANDLING_IN_PROGRESS() +#endif #if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT) #define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)} #elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR) @@ -106,8 +124,8 @@ extern "C" { #endif #if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT) -#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} -#define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} +#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} +#define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (_i16)(len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)} #elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR) #define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);} #define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);} @@ -188,7 +206,7 @@ extern "C" { #define SL_DBG_LEVEL_3 4 #define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3) -#define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK) +#define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK) #define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3 #define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1 diff --git a/hardware/lm4f/libraries/WiFi/utility/user.h b/hardware/lm4f/libraries/WiFi/utility/user.h index ade82bd28e1..fc5df99ba39 100644 --- a/hardware/lm4f/libraries/WiFi/utility/user.h +++ b/hardware/lm4f/libraries/WiFi/utility/user.h @@ -94,7 +94,7 @@ extern "C" { \warning In case of setting to one, recommend to use non-blocking recv\recvfrom to allow multiple socket recv */ -#define MAX_CONCURRENT_ACTIONS 10 +#define MAX_CONCURRENT_ACTIONS 32 //PJL /*! ****************************************************************************** diff --git a/hardware/lm4f/libraries/WiFi/utility/wlan.c b/hardware/lm4f/libraries/WiFi/utility/wlan.c index 380e915584c..2ef6fb0dc0b 100644 --- a/hardware/lm4f/libraries/WiFi/utility/wlan.c +++ b/hardware/lm4f/libraries/WiFi/utility/wlan.c @@ -1,37 +1,37 @@ /* -* wlan.c - CC31xx/CC32xx Host Driver Implementation -* -* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ -* -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the -* distribution. -* -* Neither the name of Texas Instruments Incorporated nor the names of -* its contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* + * wlan.c - CC31xx/CC32xx Host Driver Implementation + * + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Texas Instruments Incorporated nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * */ @@ -56,7 +56,7 @@ /***************************************************************************** sl_WlanConnect *****************************************************************************/ -typedef struct +typedef struct { _WlanConnectEapCommand_t Args; _i8 Strings[MAX_SSID_LEN + MAX_KEY_LEN + MAX_USER_LEN + MAX_ANON_USER_LEN]; @@ -65,18 +65,24 @@ typedef struct typedef union { _WlanConnectCmd_t Cmd; - _BasicResponse_t Rsp; + _BasicResponse_t Rsp; }_SlWlanConnectMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanConnect) _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams) { - _SlWlanConnectMsg_u Msg = {0}; - _SlCmdCtrl_t CmdCtrl = {0}; + _SlWlanConnectMsg_u Msg; + _SlCmdCtrl_t CmdCtrl = {0,0,0}; + + _SlDrvMemZero(&Msg, (_u16)sizeof(_SlWlanConnectMsg_u)); + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); CmdCtrl.TxDescLen = 0;/* init */ - CmdCtrl.RxDescLen = sizeof(_BasicResponse_t); + CmdCtrl.RxDescLen = (_SlArgSize_t)sizeof(_BasicResponse_t); /* verify SSID length */ VERIFY_PROTOCOL(NameLen <= MAX_SSID_LEN); @@ -111,7 +117,7 @@ _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,con /* update key length */ Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; ARG_CHECK_PTR(pSecParams->Key); - /* copy key */ + /* copy key */ sl_Memcpy(EAP_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen); CmdCtrl.TxDescLen += pSecParams->KeyLen; } @@ -159,7 +165,7 @@ _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,con CmdCtrl.Opcode = SL_OPCODE_WLAN_WLANCONNECTCOMMAND; CmdCtrl.TxDescLen += sizeof(_WlanConnectCommon_t); /* copy SSID */ - sl_Memcpy(SSID_STRING(&Msg), pName, NameLen); + sl_Memcpy(SSID_STRING(&Msg), pName, NameLen); CmdCtrl.TxDescLen += NameLen; /* Copy password if supplied */ if( NULL != pSecParams ) @@ -185,7 +191,7 @@ _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,con { Msg.Cmd.Args.Common.PasswordLen = 0; Msg.Cmd.Args.Common.SecType = SL_SEC_TYPE_OPEN; - } + } } /* If BSSID is not null, copy to buffer, otherwise set to 0 */ if(NULL != pMacAddr) @@ -194,7 +200,7 @@ _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,con } else { - _SlDrvMemZero(Msg.Cmd.Args.Common.Bssid, sizeof(Msg.Cmd.Args.Common.Bssid)); + _SlDrvMemZero(Msg.Cmd.Args.Common.Bssid, (_u16)sizeof(Msg.Cmd.Args.Common.Bssid)); } @@ -210,6 +216,10 @@ _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,con #if _SL_INCLUDE_FUNC(sl_WlanDisconnect) _i16 sl_WlanDisconnect(void) { + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + return _SlDrvBasicCmd(SL_OPCODE_WLAN_WLANDISCONNECTCOMMAND); } #endif @@ -220,16 +230,16 @@ _i16 sl_WlanDisconnect(void) typedef union { _WlanPoliciySetGet_t Cmd; - _BasicResponse_t Rsp; + _BasicResponse_t Rsp; }_SlPolicyMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanPolicySet) -const _SlCmdCtrl_t _SlPolicySetCmdCtrl = +static const _SlCmdCtrl_t _SlPolicySetCmdCtrl = { SL_OPCODE_WLAN_POLICYSETCOMMAND, - sizeof(_WlanPoliciySetGet_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_WlanPoliciySetGet_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i16 sl_WlanPolicySet(const _u8 Type , const _u8 Policy, _u8 *pVal,const _u8 ValLen) @@ -237,6 +247,9 @@ _i16 sl_WlanPolicySet(const _u8 Type , const _u8 Policy, _u8 *pVal,const _u8 Val _SlPolicyMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); CmdExt.TxPayloadLen = ValLen; @@ -259,17 +272,17 @@ _i16 sl_WlanPolicySet(const _u8 Type , const _u8 Policy, _u8 *pVal,const _u8 Val /******************************************************************************/ typedef union { - _WlanPoliciySetGet_t Cmd; - _WlanPoliciySetGet_t Rsp; + _WlanPoliciySetGet_t Cmd; + _WlanPoliciySetGet_t Rsp; }_SlPolicyGetMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanPolicyGet) -const _SlCmdCtrl_t _SlPolicyGetCmdCtrl = +static const _SlCmdCtrl_t _SlPolicyGetCmdCtrl = { SL_OPCODE_WLAN_POLICYGETCOMMAND, - sizeof(_WlanPoliciySetGet_t), - sizeof(_WlanPoliciySetGet_t) + (_SlArgSize_t)sizeof(_WlanPoliciySetGet_t), + (_SlArgSize_t)sizeof(_WlanPoliciySetGet_t) }; _i16 sl_WlanPolicyGet(const _u8 Type ,_u8 Policy,_u8 *pVal,_u8 *pValLen) @@ -277,13 +290,17 @@ _i16 sl_WlanPolicyGet(const _u8 Type ,_u8 Policy,_u8 *pVal,_u8 *pValLen) _SlPolicyGetMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (*pValLen == 0) { return SL_EZEROLEN; } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = *pValLen; + CmdExt.RxPayloadLen = (_i16)(*pValLen); CmdExt.pRxPayload = pVal; Msg.Cmd.PolicyType = Type; @@ -291,7 +308,7 @@ _i16 sl_WlanPolicyGet(const _u8 Type ,_u8 Policy,_u8 *pVal,_u8 *pValLen) VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlPolicyGetCmdCtrl, &Msg, &CmdExt)); - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { *pValLen = Msg.Rsp.PolicyOptionLen; return SL_ESMALLBUF; @@ -316,14 +333,14 @@ _i16 sl_WlanPolicyGet(const _u8 Type ,_u8 Policy,_u8 *pVal,_u8 *pValLen) /*******************************************************************************/ typedef struct { - _WlanAddGetEapProfile_t Args; + _WlanAddGetEapProfile_t Args; _i8 Strings[MAX_SSID_LEN + MAX_KEY_LEN + MAX_USER_LEN + MAX_ANON_USER_LEN]; }_SlProfileParams_t; typedef union { - _SlProfileParams_t Cmd; - _BasicResponse_t Rsp; + _SlProfileParams_t Cmd; + _BasicResponse_t Rsp; }_SlProfileAddMsg_u; @@ -332,12 +349,20 @@ typedef union _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams,const _u32 Priority,const _u32 Options) { _SlProfileAddMsg_u Msg; - _SlCmdCtrl_t CmdCtrl = {0}; + _SlCmdCtrl_t CmdCtrl = {0,0,0}; CmdCtrl.TxDescLen = 0;/* init */ - CmdCtrl.RxDescLen = sizeof(_BasicResponse_t); + CmdCtrl.RxDescLen = (_SlArgSize_t)(sizeof(_BasicResponse_t)); + + + /* Options paramater is currently not in use */ + (void)Options; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); /* update priority */ - Msg.Cmd.Args.Common.Priority = (_u8)Priority; + Msg.Cmd.Args.Common.Priority = (_u8)Priority; /* verify SSID is not NULL */ if( NULL == pName ) { @@ -357,14 +382,14 @@ _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAdd CmdCtrl.TxDescLen += sizeof(_WlanAddGetEapProfile_t); /* copy SSID */ - sl_Memcpy(EAP_PROFILE_SSID_STRING(&Msg), pName, NameLen); + sl_Memcpy(EAP_PROFILE_SSID_STRING(&Msg), pName, NameLen); CmdCtrl.TxDescLen += NameLen; /* Copy password if supplied */ if ((NULL != pSecParams) && (pSecParams->KeyLen > 0)) { /* update security type */ - Msg.Cmd.Args.Common.SecType = pSecParams->Type; + Msg.Cmd.Args.Common.SecType = (_i8)(pSecParams->Type); if( SL_SEC_TYPE_WEP == Msg.Cmd.Args.Common.SecType ) { @@ -378,7 +403,7 @@ _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAdd } VERIFY_PROTOCOL(pSecParams->KeyLen <= MAX_KEY_LEN); /* update key length */ - Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; + Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; CmdCtrl.TxDescLen += pSecParams->KeyLen; ARG_CHECK_PTR(pSecParams->Key); /* copy key */ @@ -441,7 +466,7 @@ _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAdd if( NULL != pSecParams ) { /* update security type */ - Msg.Cmd.Args.Common.SecType = pSecParams->Type; + Msg.Cmd.Args.Common.SecType = (_i8)(pSecParams->Type); if( SL_SEC_TYPE_WEP == Msg.Cmd.Args.Common.SecType ) { @@ -478,7 +503,7 @@ _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAdd } else { - _SlDrvMemZero(Msg.Cmd.Args.Common.Bssid, sizeof(Msg.Cmd.Args.Common.Bssid)); + _SlDrvMemZero(Msg.Cmd.Args.Common.Bssid, (_u16)sizeof(Msg.Cmd.Args.Common.Bssid)); } VERIFY_RET_OK(_SlDrvCmdOp(&CmdCtrl, &Msg, NULL)); @@ -492,17 +517,17 @@ _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAdd typedef union { _WlanProfileDelGetCommand_t Cmd; - _SlProfileParams_t Rsp; + _SlProfileParams_t Rsp; }_SlProfileGetMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanProfileGet) -const _SlCmdCtrl_t _SlProfileGetCmdCtrl = +static const _SlCmdCtrl_t _SlProfileGetCmdCtrl = { SL_OPCODE_WLAN_PROFILEGETCOMMAND, - sizeof(_WlanProfileDelGetCommand_t), - sizeof(_SlProfileParams_t) + (_SlArgSize_t)sizeof(_WlanProfileDelGetCommand_t), + (_SlArgSize_t)sizeof(_SlProfileParams_t) }; _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAddr, SlSecParams_t* pSecParams, SlGetSecParamsExt_t* pEntParams, _u32 *pPriority) @@ -510,9 +535,13 @@ _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAd _SlProfileGetMsg_u Msg; Msg.Cmd.index = (_u8)Index; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlProfileGetCmdCtrl, &Msg, NULL)); - pSecParams->Type = Msg.Rsp.Args.Common.SecType; + pSecParams->Type = (_u8)(Msg.Rsp.Args.Common.SecType); /* since password is not transferred in getprofile, password length should always be zero */ pSecParams->KeyLen = Msg.Rsp.Args.Common.PasswordLen; if (NULL != pEntParams) @@ -520,7 +549,7 @@ _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAd pEntParams->UserLen = Msg.Rsp.Args.UserLen; /* copy user name */ if (pEntParams->UserLen > 0) - { + { sl_Memcpy(pEntParams->User, EAP_PROFILE_USER_STRING(&Msg), pEntParams->UserLen); } pEntParams->AnonUserLen = Msg.Rsp.Args.AnonUserLen; @@ -531,8 +560,8 @@ _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAd } } - *pNameLen = Msg.Rsp.Args.Common.SsidLen; - *pPriority = Msg.Rsp.Args.Common.Priority; + *pNameLen = (_i16)(Msg.Rsp.Args.Common.SsidLen); + *pPriority = Msg.Rsp.Args.Common.Priority; if (NULL != Msg.Rsp.Args.Common.Bssid) { @@ -550,24 +579,28 @@ _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAd /*******************************************************************************/ typedef union { - _WlanProfileDelGetCommand_t Cmd; - _BasicResponse_t Rsp; + _WlanProfileDelGetCommand_t Cmd; + _BasicResponse_t Rsp; }_SlProfileDelMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanProfileDel) -const _SlCmdCtrl_t _SlProfileDelCmdCtrl = +static const _SlCmdCtrl_t _SlProfileDelCmdCtrl = { SL_OPCODE_WLAN_PROFILEDELCOMMAND, - sizeof(_WlanProfileDelGetCommand_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_WlanProfileDelGetCommand_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i16 sl_WlanProfileDel(const _i16 Index) { _SlProfileDelMsg_u Msg; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.index = (_u8)Index; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlProfileDelCmdCtrl, &Msg, NULL)); @@ -589,11 +622,11 @@ typedef union #if _SL_INCLUDE_FUNC(sl_WlanGetNetworkList) -const _SlCmdCtrl_t _SlWlanGetNetworkListCtrl = +static const _SlCmdCtrl_t _SlWlanGetNetworkListCtrl = { SL_OPCODE_WLAN_SCANRESULTSGETCOMMAND, - sizeof(_WlanGetNetworkListCommand_t), - sizeof(_WlanGetNetworkListResponse_t) + (_SlArgSize_t)sizeof(_WlanGetNetworkListCommand_t), + (_SlArgSize_t)sizeof(_WlanGetNetworkListResponse_t) }; _i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry_t *pEntries) @@ -602,14 +635,18 @@ _i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry_ _SlWlanGetNetworkListMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (Count == 0) { return SL_EZEROLEN; } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = sizeof(Sl_WlanNetworkEntry_t)*(Count); - CmdExt.pRxPayload = (_u8 *)pEntries; + CmdExt.RxPayloadLen = (_i16)(sizeof(Sl_WlanNetworkEntry_t)*(Count)); + CmdExt.pRxPayload = (_u8 *)pEntries; Msg.Cmd.index = Index; Msg.Cmd.count = Count; @@ -632,7 +669,7 @@ _i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry_ /* Set command */ typedef union { - _WlanRxFilterAddCommand_t Cmd; + _WlanRxFilterAddCommand_t Cmd; _WlanRxFilterAddCommandReponse_t Rsp; }_SlrxFilterAddMsg_u; @@ -640,7 +677,7 @@ typedef union /* Set command */ typedef union _SlRxFilterSetMsg_u { - _WlanRxFilterSetCommand_t Cmd; + _WlanRxFilterSetCommand_t Cmd; _WlanRxFilterSetCommandReponse_t Rsp; }_SlRxFilterSetMsg_u; @@ -648,33 +685,38 @@ typedef union _SlRxFilterSetMsg_u /* Get command */ typedef union _SlRxFilterGetMsg_u { - _WlanRxFilterGetCommand_t Cmd; + _WlanRxFilterGetCommand_t Cmd; _WlanRxFilterGetCommandReponse_t Rsp; }_SlRxFilterGetMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd) -const _SlCmdCtrl_t _SlRxFilterAddtCmdCtrl = +static const _SlCmdCtrl_t _SlRxFilterAddtCmdCtrl = { SL_OPCODE_WLAN_WLANRXFILTERADDCOMMAND, - sizeof(_WlanRxFilterAddCommand_t), - sizeof(_WlanRxFilterAddCommandReponse_t) + (_SlArgSize_t)sizeof(_WlanRxFilterAddCommand_t), + (_SlArgSize_t)sizeof(_WlanRxFilterAddCommandReponse_t) }; /***************************************************************************** RX filters *****************************************************************************/ -SlrxFilterID_t sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, - SlrxFilterFlags_t FilterFlags, - const SlrxFilterRule_t* const Rule, - const SlrxFilterTrigger_t* const Trigger, - const SlrxFilterAction_t* const Action, +_i16 sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, + SlrxFilterFlags_t FilterFlags, + const SlrxFilterRule_t* const Rule, + const SlrxFilterTrigger_t* const Trigger, + const SlrxFilterAction_t* const Action, SlrxFilterID_t* pFilterId) { _SlrxFilterAddMsg_u Msg; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.RuleType = RuleType; /* filterId is zero */ Msg.Cmd.FilterId = 0; @@ -696,11 +738,11 @@ SlrxFilterID_t sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, /*******************************************************************************/ #if _SL_INCLUDE_FUNC(sl_WlanRxFilterSet) -const _SlCmdCtrl_t _SlRxFilterSetCmdCtrl = +static const _SlCmdCtrl_t _SlRxFilterSetCmdCtrl = { SL_OPCODE_WLAN_WLANRXFILTERSETCOMMAND, - sizeof(_WlanRxFilterSetCommand_t), - sizeof(_WlanRxFilterSetCommandReponse_t) + (_SlArgSize_t)sizeof(_WlanRxFilterSetCommand_t), + (_SlArgSize_t)sizeof(_WlanRxFilterSetCommandReponse_t) }; _i16 sl_WlanRxFilterSet(const SLrxFilterOperation_t RxFilterOperation, @@ -710,6 +752,9 @@ _i16 sl_WlanRxFilterSet(const SLrxFilterOperation_t RxFilterOperation, _SlRxFilterSetMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); _SlDrvResetCmdExt(&CmdExt); CmdExt.TxPayloadLen = InputbufferLength; @@ -731,11 +776,11 @@ _i16 sl_WlanRxFilterSet(const SLrxFilterOperation_t RxFilterOperation, /******************************************************************************/ #if _SL_INCLUDE_FUNC(sl_WlanRxFilterGet) -const _SlCmdCtrl_t _SlRxFilterGetCmdCtrl = +static const _SlCmdCtrl_t _SlRxFilterGetCmdCtrl = { SL_OPCODE_WLAN_WLANRXFILTERGETCOMMAND, - sizeof(_WlanRxFilterGetCommand_t), - sizeof(_WlanRxFilterGetCommandReponse_t) + (_SlArgSize_t)sizeof(_WlanRxFilterGetCommand_t), + (_SlArgSize_t)sizeof(_WlanRxFilterGetCommandReponse_t) }; @@ -746,13 +791,17 @@ _i16 sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation, _SlRxFilterGetMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (OutputbufferLength == 0) { return SL_EZEROLEN; } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = OutputbufferLength; + CmdExt.RxPayloadLen = (_i16)OutputbufferLength; CmdExt.pRxPayload = (_u8 *)pOutputBuffer; Msg.Cmd.RxFilterOperation = RxFilterOperation; @@ -761,7 +810,7 @@ _i16 sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation, VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterGetCmdCtrl, &Msg, &CmdExt) ); - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { return SL_ESMALLBUF; } @@ -776,6 +825,10 @@ _i16 sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation, #if _SL_INCLUDE_FUNC(sl_WlanRxStatStart) _i16 sl_WlanRxStatStart(void) { + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + return _SlDrvBasicCmd(SL_OPCODE_WLAN_STARTRXSTATCOMMAND); } #endif @@ -783,6 +836,10 @@ _i16 sl_WlanRxStatStart(void) #if _SL_INCLUDE_FUNC(sl_WlanRxStatStop) _i16 sl_WlanRxStatStop(void) { + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + return _SlDrvBasicCmd(SL_OPCODE_WLAN_STOPRXSTATCOMMAND); } #endif @@ -790,10 +847,17 @@ _i16 sl_WlanRxStatStop(void) #if _SL_INCLUDE_FUNC(sl_WlanRxStatGet) _i16 sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,const _u32 Flags) { - _SlCmdCtrl_t CmdCtrl = {SL_OPCODE_WLAN_GETRXSTATCOMMAND, 0, sizeof(SlGetRxStatResponse_t)}; - - _SlDrvMemZero(pRxStat, sizeof(SlGetRxStatResponse_t)); - VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, pRxStat, NULL)); + _SlCmdCtrl_t CmdCtrl = {SL_OPCODE_WLAN_GETRXSTATCOMMAND, 0, (_SlArgSize_t)sizeof(SlGetRxStatResponse_t)}; + + /* Flags paramater is currently not in use */ + (void)Flags; + + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + + _SlDrvMemZero(pRxStat, (_u16)sizeof(SlGetRxStatResponse_t)); + VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, pRxStat, NULL)); return 0; } @@ -807,6 +871,10 @@ _i16 sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,const _u32 Flags) #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStop) _i16 sl_WlanSmartConfigStop(void) { + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + return _SlDrvBasicCmd(SL_OPCODE_WLAN_SMART_CONFIG_STOP_COMMAND); } #endif @@ -819,23 +887,23 @@ _i16 sl_WlanSmartConfigStop(void) typedef struct { - _WlanSmartConfigStartCommand_t Args; + _WlanSmartConfigStartCommand_t Args; _i8 Strings[3 * MAX_SMART_CONFIG_KEY]; /* public key + groupId1 key + groupId2 key */ }_SlSmartConfigStart_t; typedef union { - _SlSmartConfigStart_t Cmd; - _BasicResponse_t Rsp; + _SlSmartConfigStart_t Cmd; + _BasicResponse_t Rsp; }_SlSmartConfigStartMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStart) -const _SlCmdCtrl_t _SlSmartConfigStartCmdCtrl = +static const _SlCmdCtrl_t _SlSmartConfigStartCmdCtrl = { SL_OPCODE_WLAN_SMART_CONFIG_START_COMMAND, - sizeof(_SlSmartConfigStart_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_SlSmartConfigStart_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i16 sl_WlanSmartConfigStart( const _u32 groupIdBitmask, @@ -849,6 +917,10 @@ _i16 sl_WlanSmartConfigStart( const _u32 groupIdBitmask, { _SlSmartConfigStartMsg_u Msg; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.Args.groupIdBitmask = (_u8)groupIdBitmask; Msg.Cmd.Args.cipher = (_u8)cipher; Msg.Cmd.Args.publicKeyLen = (_u8)publicKeyLen; @@ -874,20 +946,20 @@ _i16 sl_WlanSmartConfigStart( const _u32 groupIdBitmask, /*******************************************************************************/ typedef union { - _WlanSetMode_t Cmd; - _BasicResponse_t Rsp; + _WlanSetMode_t Cmd; + _BasicResponse_t Rsp; }_SlwlanSetModeMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanSetMode) -const _SlCmdCtrl_t _SlWlanSetModeCmdCtrl = +static const _SlCmdCtrl_t _SlWlanSetModeCmdCtrl = { SL_OPCODE_WLAN_SET_MODE, - sizeof(_WlanSetMode_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_WlanSetMode_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; -/* possible values are: +/* possible values are: WLAN_SET_STA_MODE = 1 WLAN_SET_AP_MODE = 2 WLAN_SET_P2P_MODE = 3 */ @@ -895,6 +967,10 @@ _i16 sl_WlanSetMode(const _u8 mode) { _SlwlanSetModeMsg_u Msg; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + Msg.Cmd.mode = mode; VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); @@ -911,18 +987,18 @@ _i16 sl_WlanSetMode(const _u8 mode) /* ******************************************************************************/ typedef union { - _WlanCfgSetGet_t Cmd; - _BasicResponse_t Rsp; + _WlanCfgSetGet_t Cmd; + _BasicResponse_t Rsp; }_SlWlanCfgSetMsg_u; #if _SL_INCLUDE_FUNC(sl_WlanSet) -const _SlCmdCtrl_t _SlWlanCfgSetCmdCtrl = +static const _SlCmdCtrl_t _SlWlanCfgSetCmdCtrl = { SL_OPCODE_WLAN_CFG_SET, - sizeof(_WlanCfgSetGet_t), - sizeof(_BasicResponse_t) + (_SlArgSize_t)sizeof(_WlanCfgSetGet_t), + (_SlArgSize_t)sizeof(_BasicResponse_t) }; _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,const _u8 *pValues) @@ -930,8 +1006,12 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c _SlWlanCfgSetMsg_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + _SlDrvResetCmdExt(&CmdExt); - CmdExt.TxPayloadLen = (ConfigLen+3) & (~3); + CmdExt.TxPayloadLen = (_u16)((ConfigLen+3) & (~3)); CmdExt.pTxPayload = (_u8 *)pValues; Msg.Cmd.ConfigId = ConfigId; @@ -950,17 +1030,17 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c /******************************************************************************/ typedef union { - _WlanCfgSetGet_t Cmd; - _WlanCfgSetGet_t Rsp; + _WlanCfgSetGet_t Cmd; + _WlanCfgSetGet_t Rsp; }_SlWlanCfgMsgGet_u; #if _SL_INCLUDE_FUNC(sl_WlanGet) -const _SlCmdCtrl_t _SlWlanCfgGetCmdCtrl = +static const _SlCmdCtrl_t _SlWlanCfgGetCmdCtrl = { SL_OPCODE_WLAN_CFG_GET, - sizeof(_WlanCfgSetGet_t), - sizeof(_WlanCfgSetGet_t) + (_SlArgSize_t)sizeof(_WlanCfgSetGet_t), + (_SlArgSize_t)sizeof(_WlanCfgSetGet_t) }; _i16 sl_WlanGet(const _u16 ConfigId, _u16 *pConfigOpt,_u16 *pConfigLen, _u8 *pValues) @@ -968,16 +1048,22 @@ _i16 sl_WlanGet(const _u16 ConfigId, _u16 *pConfigOpt,_u16 *pConfigLen, _u8 *pVa _SlWlanCfgMsgGet_u Msg; _SlCmdExt_t CmdExt; + /* verify no erorr handling in progress. if in progress than + ignore the API execution and return immediately with an error */ + VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); + if (*pConfigLen == 0) { return SL_EZEROLEN; } _SlDrvResetCmdExt(&CmdExt); - CmdExt.RxPayloadLen = *pConfigLen; + CmdExt.RxPayloadLen = (_i16)*pConfigLen; CmdExt.pRxPayload = (_u8 *)pValues; Msg.Cmd.ConfigId = ConfigId; + Msg.Cmd.ConfigLen = *pConfigLen; + if( pConfigOpt ) { Msg.Cmd.ConfigOpt = (_u16)*pConfigOpt; @@ -988,7 +1074,7 @@ _i16 sl_WlanGet(const _u16 ConfigId, _u16 *pConfigOpt,_u16 *pConfigLen, _u8 *pVa { *pConfigOpt = (_u8)Msg.Rsp.ConfigOpt; } - if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) + if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { *pConfigLen = (_u8)CmdExt.RxPayloadLen; return SL_ESMALLBUF; diff --git a/hardware/lm4f/libraries/WiFi/utility/wlan.h b/hardware/lm4f/libraries/WiFi/utility/wlan.h index 2181c3e73e4..cfc34e3c217 100644 --- a/hardware/lm4f/libraries/WiFi/utility/wlan.h +++ b/hardware/lm4f/libraries/WiFi/utility/wlan.h @@ -1,35 +1,35 @@ /* * wlan.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -38,7 +38,7 @@ /* Include files */ /*****************************************************************************/ #include "simplelink.h" - + #ifndef __WLAN_H__ #define __WLAN_H__ @@ -61,46 +61,50 @@ extern "C" { */ -#define SL_BSSID_LENGTH (6) -#define MAXIMAL_SSID_LENGTH (32) +#define SL_BSSID_LENGTH (6) +#define MAXIMAL_SSID_LENGTH (32) + +#define NUM_OF_RATE_INDEXES (20) +#define SIZE_OF_RSSI_HISTOGRAM (6) -#define NUM_OF_RATE_INDEXES (20) -#define SIZE_OF_RSSI_HISTOGRAM (6) - /* WLAN Disconnect Reason Codes */ -#define SL_DISCONNECT_RESERVED_0 (0) -#define SL_DISCONNECT_UNSPECIFIED_REASON (1) -#define SL_PREVIOUS_AUTHENTICATION_NO_LONGER_VALID (2) -#define SL_DEAUTHENTICATED_BECAUSE_SENDING_STATION_IS_LEAVING (3) -#define SL_DISASSOCIATED_DUE_TO_INACTIVITY (4) -#define SL_DISASSOCIATED_BECAUSE_AP_IS_UNABLE_TO_HANDLE_ALL_CURRENTLY_ASSOCIATED_STATIONS (5) -#define SL_CLASS_2_FRAME_RECEIVED_FROM_NONAUTHENTICATED_STATION (6) -#define SL_CLASS_3_FRAME_RECEIVED_FROM_NONASSOCIATED_STATION (7) -#define SL_DISASSOCIATED_BECAUSE_SENDING_STATION_IS_LEAVING_BSS (8) -#define SL_STATION_REQUESTING_ASSOCIATION_IS_NOT_AUTHENTICATED_WITH_RESPONDING_STATION (9) -#define SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_POWER_CAPABILITY_ELEMENT_IS_UNACCEPTABLE (10) -#define SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_SUPPORTED_CHANNELS_ELEMENT_IS_UNACCEPTABLE (11) -#define SL_DISCONNECT_RESERVED_1 (12) -#define SL_INVALID_INFORMATION_ELEMENT (13) -#define SL_MESSAGE_INTEGRITY_CODE_MIC_FAILURE (14) -#define SL_FOUR_WAY_HANDSHAKE_TIMEOUT (15) -#define SL_GROUP_KEY_HANDSHAKE_TIMEOUT (16) -#define SL_RE_ASSOCIATION_REQUEST_PROBE_RESPONSE_BEACON_FRAME (17) -#define SL_INVALID_GROUP_CIPHER (18) -#define SL_INVALID_PAIRWISE_CIPHER (19) -#define SL_INVALID_AKMP (20) -#define SL_UNSUPPORTED_RSN_INFORMATION_ELEMENT_VERSION (21) -#define SL_INVALID_RSN_INFORMATION_ELEMENT_CAPABILITIES (22) -#define SL_IEEE_802_1X_AUTHENTICATION_FAILED (23) -#define SL_CIPHER_SUITE_REJECTED_BECAUSE_OF_THE_SECURITY_POLICY (24) -#define SL_DISCONNECT_RESERVED_2 (25) -#define SL_DISCONNECT_RESERVED_3 (26) -#define SL_DISCONNECT_RESERVED_4 (27) -#define SL_DISCONNECT_RESERVED_5 (28) -#define SL_DISCONNECT_RESERVED_6 (29) -#define SL_DISCONNECT_RESERVED_7 (30) -#define SL_DISCONNECT_RESERVED_8 (31) -#define SL_USER_INITIATED_DISCONNECTION (200) +#define SL_WLAN_DISCONNECT_UNSPECIFIED_REASON (1) +#define SL_WLAN_DISCONNECT_PREV_AUTH_NOT_VALID (2) +#define SL_WLAN_DISCONNECT_DEAUTH_LEAVING (3) +#define SL_WLAN_DISCONNECT_DISASSOC_DUE_TO_INACTIVITY (4) +#define SL_WLAN_DISCONNECT_DISASSOC_AP_BUSY (5) +#define SL_WLAN_DISCONNECT_CLASS2_FRAME_FROM_NONAUTH_STA (6) +#define SL_WLAN_DISCONNECT_CLASS3_FRAME_FROM_NONASSOC_STA (7) +#define SL_WLAN_DISCONNECT_DISASSOC_STA_HAS_LEFT (8) +#define SL_WLAN_DISCONNECT_STA_REQ_ASSOC_WITHOUT_AUTH (9) +#define SL_WLAN_DISCONNECT_PWR_CAPABILITY_NOT_VALID (10) +#define SL_WLAN_DISCONNECT_SUPPORTED_CHANNEL_NOT_VALID (11) +#define SL_WLAN_DISCONNECT_INVALID_IE (13) +#define SL_WLAN_DISCONNECT_MIC_FAILURE (14) +#define SL_WLAN_DISCONNECT_4WAY_HANDSHAKE_TIMEOUT (15) +#define SL_WLAN_DISCONNECT_GROUP_KEY_UPDATE_TIMEOUT (16) +#define SL_WLAN_DISCONNECT_IE_IN_4WAY_DIFFERS (17) +#define SL_WLAN_DISCONNECT_GROUP_CIPHER_NOT_VALID (18) +#define SL_WLAN_DISCONNECT_PAIRWISE_CIPHER_NOT_VALID (19) +#define SL_WLAN_DISCONNECT_AKMP_NOT_VALID (20) +#define SL_WLAN_DISCONNECT_UNSUPPORTED_RSN_IE_VERSION (21) +#define SL_WLAN_DISCONNECT_INVALID_RSN_IE_CAPAB (22) +#define SL_WLAN_DISCONNECT_IEEE_802_1X_AUTH_FAILED (23) +#define SL_WLAN_DISCONNECT_CIPHER_SUITE_REJECTED (24) +#define SL_WLAN_DISCONNECT_DISASSOC_LOW_ACK (34) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_NONE (100) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_LOW_TX_RATE (104) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_LOW_SNR (105) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_LOW_QUALITY (106) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_TSPEC_REJECTED (107) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_MAX_TX_RETRIES (108) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_BSS_LOSS (109) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_BSS_LOSS_DUE_TO_MAX_TX_RETRY (110) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_SWITCH_CHANNEL (111) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_AP_DISCONNECT (112) +#define SL_WLAN_DISCONNECT_ROAMING_TRIGGER_SECURITY_ATTACK (113) +#define SL_WLAN_DISCONNECT_USER_INITIATED_DISCONNECTION (200) + /* Wlan error codes */ #define SL_ERROR_KEY_ERROR (-3) @@ -136,17 +140,16 @@ extern "C" { #define SL_SEC_TYPE_P2P_PIN_AUTO (9) /* NOT Supported yet */ - + #define SL_SCAN_SEC_TYPE_OPEN (0) #define SL_SCAN_SEC_TYPE_WEP (1) -#define SL_SCAN_SEC_TYPE_WPA (2) +#define SL_SCAN_SEC_TYPE_WPA (2) #define SL_SCAN_SEC_TYPE_WPA2 (3) - - + #define TLS (0x1) #define MSCHAP (0x0) -#define PSK (0x2) +#define PSK (0x2) #define TTLS (0x10) #define PEAP0 (0x20) #define PEAP1 (0x40) @@ -160,7 +163,7 @@ extern "C" { #define EAPMETHOD_PAIRWISE_CIPHER_SHIFT (19) #define EAPMETHOD_GROUP_CIPHER_SHIFT (27) -#define WPA_CIPHER_CCMP (0x1) +#define WPA_CIPHER_CCMP (0x1) #define WPA_CIPHER_TKIP (0x2) #define CC31XX_DEFAULT_CIPHER (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP) @@ -176,15 +179,15 @@ extern "C" { #define SL_ENT_EAP_METHOD_TTLS_MSCHAPv2 EAPMETHOD(TTLS , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_TTLS_PSK EAPMETHOD(TTLS , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_PEAP0_TLS EAPMETHOD(PEAP0 , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) -#define SL_ENT_EAP_METHOD_PEAP0_MSCHAPv2 EAPMETHOD(PEAP0 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) +#define SL_ENT_EAP_METHOD_PEAP0_MSCHAPv2 EAPMETHOD(PEAP0 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_PEAP0_PSK EAPMETHOD(PEAP0 , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_PEAP1_TLS EAPMETHOD(PEAP1 , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) -#define SL_ENT_EAP_METHOD_PEAP1_MSCHAPv2 EAPMETHOD(PEAP1 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) +#define SL_ENT_EAP_METHOD_PEAP1_MSCHAPv2 EAPMETHOD(PEAP1 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_PEAP1_PSK EAPMETHOD(PEAP1 , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_FAST_AUTH_PROVISIONING EAPMETHOD(FAST , FAST_AUTH_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_FAST_UNAUTH_PROVISIONING EAPMETHOD(FAST , FAST_UNAUTH_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) #define SL_ENT_EAP_METHOD_FAST_NO_PROVISIONING EAPMETHOD(FAST , FAST_NO_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER) - + #define SL_LONG_PREAMBLE (0) #define SL_SHORT_PREAMBLE (1) @@ -286,6 +289,53 @@ extern "C" { #define INFO_ELEMENT_DEFAULT_OUI (0x000000) /* 08, 00, 28 will be used */ + + + +/************************************************** +For backward compatability (version 1.0.0.10) +**************************************************/ +#define SL_DISCONNECT_UNSPECIFIED_REASON SL_WLAN_DISCONNECT_UNSPECIFIED_REASON +#define SL_PREVIOUS_AUTHENTICATION_NO_LONGER_VALID SL_WLAN_DISCONNECT_PREV_AUTH_NOT_VALID +#define SL_DEAUTHENTICATED_BECAUSE_SENDING_STATION_IS_LEAVING SL_WLAN_DISCONNECT_DEAUTH_LEAVING +#define SL_DISASSOCIATED_DUE_TO_INACTIVITY SL_WLAN_DISCONNECT_DISASSOC_DUE_TO_INACTIVITY +#define SL_DISASSOCIATED_BECAUSE_AP_IS_UNABLE_TO_HANDLE_ALL_CURRENTLY_ASSOCIATED_STATIONS SL_WLAN_DISCONNECT_DISASSOC_AP_BUSY +#define SL_CLASS_2_FRAME_RECEIVED_FROM_NONAUTHENTICATED_STATION SL_WLAN_DISCONNECT_CLASS2_FRAME_FROM_NONAUTH_STA +#define SL_CLASS_3_FRAME_RECEIVED_FROM_NONASSOCIATED_STATION SL_WLAN_DISCONNECT_CLASS3_FRAME_FROM_NONASSOC_STA +#define SL_DISASSOCIATED_BECAUSE_SENDING_STATION_IS_LEAVING_BSS SL_WLAN_DISCONNECT_DISASSOC_STA_HAS_LEFT +#define SL_STATION_REQUESTING_ASSOCIATION_IS_NOT_AUTHENTICATED_WITH_RESPONDING_STATION SL_WLAN_DISCONNECT_STA_REQ_ASSOC_WITHOUT_AUTH +#define SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_POWER_CAPABILITY_ELEMENT_IS_UNACCEPTABLE SL_WLAN_DISCONNECT_PWR_CAPABILITY_NOT_VALID +#define SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_SUPPORTED_CHANNELS_ELEMENT_IS_UNACCEPTABLE SL_WLAN_DISCONNECT_SUPPORTED_CHANNEL_NOT_VALID +#define SL_INVALID_INFORMATION_ELEMENT SL_WLAN_DISCONNECT_INVALID_IE +#define SL_MESSAGE_INTEGRITY_CODE_MIC_FAILURE SL_WLAN_DISCONNECT_MIC_FAILURE +#define SL_FOUR_WAY_HANDSHAKE_TIMEOUT SL_WLAN_DISCONNECT_4WAY_HANDSHAKE_TIMEOUT +#define SL_GROUP_KEY_HANDSHAKE_TIMEOUT SL_WLAN_DISCONNECT_GROUP_KEY_UPDATE_TIMEOUT +#define SL_RE_ASSOCIATION_REQUEST_PROBE_RESPONSE_BEACON_FRAME SL_WLAN_DISCONNECT_IE_IN_4WAY_DIFFERS +#define SL_INVALID_GROUP_CIPHER SL_WLAN_DISCONNECT_GROUP_CIPHER_NOT_VALID +#define SL_INVALID_PAIRWISE_CIPHER SL_WLAN_DISCONNECT_PAIRWISE_CIPHER_NOT_VALID +#define SL_INVALID_AKMP SL_WLAN_DISCONNECT_AKMP_NOT_VALID +#define SL_UNSUPPORTED_RSN_INFORMATION_ELEMENT_VERSION SL_WLAN_DISCONNECT_UNSUPPORTED_RSN_IE_VERSION +#define SL_INVALID_RSN_INFORMATION_ELEMENT_CAPABILITIES SL_WLAN_DISCONNECT_INVALID_RSN_IE_CAPAB +#define SL_IEEE_802_1X_AUTHENTICATION_FAILED SL_WLAN_DISCONNECT_IEEE_802_1X_AUTH_FAILED +#define SL_CIPHER_SUITE_REJECTED_BECAUSE_OF_THE_SECURITY_POLICY SL_WLAN_DISCONNECT_CIPHER_SUITE_REJECTED +#define SL_USER_INITIATED_DISCONNECTION SL_WLAN_DISCONNECT_USER_INITIATED_DISCONNECTION + + +#define SL_DISCONNECT_RESERVED_0 (0) +#define SL_DISCONNECT_RESERVED_1 (12) +#define SL_DISCONNECT_RESERVED_2 (26) +#define SL_DISCONNECT_RESERVED_3 (27) +#define SL_DISCONNECT_RESERVED_4 (28) +#define SL_DISCONNECT_RESERVED_5 (29) +#define SL_DISCONNECT_RESERVED_6 (30) +#define SL_DISCONNECT_RESERVED_7 (31) +#define SL_DISCONNECT_RESERVED_8 (32) + +/****************************** +End of backward compatability. +*******************************/ + + /*****************************************************************************/ /* Structure/Enum declarations */ /*****************************************************************************/ @@ -372,8 +422,8 @@ typedef union { slSmartConfigStartAsyncResponse_t smartConfigStartResponse; /*SL_WLAN_SMART_CONFIG_COMPLETE_EVENT*/ slSmartConfigStopAsyncResponse_t smartConfigStopResponse; /*SL_WLAN_SMART_CONFIG_STOP_EVENT */ - slPeerInfoAsyncResponse_t APModeStaConnected; /* SL_WLAN_STA_CONNECTED_EVENT - relevant only in AP mode - holds information regarding a new STA connection */ - slPeerInfoAsyncResponse_t APModestaDisconnected; /* SL_WLAN_STA_DISCONNECTED_EVENT - relevant only in AP mode - holds information regarding a STA disconnection */ + slPeerInfoAsyncResponse_t APModeStaConnected; /* SL_WLAN_STA_CONNECTED_EVENT - relevant only in AP mode - holds information regarding a new STA connection */ + slPeerInfoAsyncResponse_t APModestaDisconnected; /* SL_WLAN_STA_DISCONNECTED_EVENT - relevant only in AP mode - holds information regarding a STA disconnection */ slWlanConnectAsyncResponse_t STAandP2PModeWlanConnected; /* SL_WLAN_CONNECT_EVENT - relevant only in STA and P2P mode - holds information regarding a new connection */ slWlanConnectAsyncResponse_t STAandP2PModeDisconnected; /* SL_WLAN_DISCONNECT_EVENT - relevant only in STA and P2P mode - holds information regarding a disconnection */ slPeerInfoAsyncResponse_t P2PModeDevFound; /* SL_WLAN_P2P_DEV_FOUND_EVENT - relevant only in P2P mode */ @@ -389,10 +439,10 @@ typedef struct } SlWlanEvent_t; -typedef struct +typedef struct { _u32 ReceivedValidPacketsNumber; /* sum of the packets that been received OK (include filtered) */ - _u32 ReceivedFcsErrorPacketsNumber; /* sum of the packets that been dropped due to FCS error */ + _u32 ReceivedFcsErrorPacketsNumber; /* sum of the packets that been dropped due to FCS error */ _u32 ReceivedAddressMismatchPacketsNumber; /* sum of the packets that been received but filtered out by one of the HW filters */ _i16 AvarageDataCtrlRssi; /* average RSSI for all valid data packets received */ _i16 AvarageMgMntRssi; /* average RSSI for all valid management packets received */ @@ -413,15 +463,15 @@ typedef struct _i8 reserved[3]; }Sl_WlanNetworkEntry_t; - -typedef struct + +typedef struct { _u8 Type; _i8* Key; _u8 KeyLen; }SlSecParams_t; - -typedef struct + +typedef struct { _i8* User; _u8 UserLen; @@ -431,7 +481,7 @@ typedef struct _u32 EapMethod; }SlSecParamsExt_t; -typedef struct +typedef struct { _i8 User[32]; _u8 UserLen; @@ -443,13 +493,16 @@ typedef struct typedef enum { - ROLE_STA = 0, - ROLE_AP = 2, - ROLE_P2P = 3, - ROLE_STA_ERR = -1, /* Failure to load MAC/PHY in STA role */ - ROLE_AP_ERR = -ROLE_AP, /* Failure to load MAC/PHY in AP role */ - ROLE_P2P_ERR = -ROLE_P2P /* Failure to load MAC/PHY in P2P role */ -}SlWlanMode_t; + ROLE_STA = 0, + ROLE_UNKNOWN = 1, + ROLE_AP = 2, + ROLE_P2P = 3, + ROLE_STA_ERR = -1, /* Failure to load MAC/PHY in STA role */ + ROLE_AP_ERR = -2, /* Failure to load MAC/PHY in AP role */ + ROLE_P2P_ERR = -3, /* Failure to load MAC/PHY in P2P role */ + INIT_CALIB_FAIL = -4 /* Failure of calibration */ +}SlWlanMode_e; + typedef struct { @@ -458,7 +511,7 @@ typedef struct }slWlanScanParamCommand_t; -typedef struct +typedef struct { _u8 id; _u8 oui[3]; @@ -466,7 +519,7 @@ typedef struct _u8 data[252]; } sl_protocol_InfoElement_t; -typedef struct +typedef struct { _u8 index; /* 0 - MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED */ _u8 role; /* bit0: AP = 0, GO = 1 */ @@ -481,7 +534,7 @@ typedef struct /*! \brief Connect to wlan network as a station - + \param[in] pName up to 32 bytes in case of STA the name is the SSID of the Access Point \param[in] NameLen name length \param[in] pMacAddr 6 bytes for MAC address @@ -492,71 +545,71 @@ typedef struct - SL_SEC_TYPE_WPA_WPA2 - SL_SEC_TYPE_WPA_ENT - SL_SEC_TYPE_WPS_PBC - - SL_SEC_TYPE_WPS_PIN - + - SL_SEC_TYPE_WPS_PIN + \param[in] pSecExtParams Enterprise parameters (set NULL in case Enterprise parameters is not in use) - + \return On success, zero is returned. On error, negative is returned In case error number (-71) is returned, it indicates a connection was activated while the device it running in AP role - - \sa sl_WlanDisconnect - \note belongs to \ref ext_api + + \sa sl_WlanDisconnect + \note belongs to \ref ext_api \warning In this version only single enterprise mode could be used SL_SEC_TYPE_WPA is a deprecated definition, the new definition is SL_SEC_TYPE_WPA_WPA2 -*/ +*/ #if _SL_INCLUDE_FUNC(sl_WlanConnect) _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams); #endif /*! \brief wlan disconnect - - Disconnect connection - + + Disconnect connection + \return 0 disconnected done, other already disconnected - - \sa sl_WlanConnect - \note belongs to \ref ext_api - \warning + + \sa sl_WlanConnect + \note belongs to \ref ext_api + \warning */ #if _SL_INCLUDE_FUNC(sl_WlanDisconnect) _i16 sl_WlanDisconnect(void); #endif /*! - \brief add profile - + \brief add profile + When auto start is enabled, the device connects to a station from the profiles table. Up to 7 profiles are supported. If several profiles configured the device chose the highest priority profile, within each priority group, device will chose profile based on security policy, signal - strength, etc parameters. + strength, etc parameters. - \param[in] pName up to 32 bytes in case of STA the name is the + \param[in] pName up to 32 bytes in case of STA the name is the SSID of the Access Point in case of P2P the name is the remote device name \param[in] NameLen name length \param[in] pMacAddr 6 bytes for MAC address - \param[in] pSecParams Security parameters - security type + \param[in] pSecParams Security parameters - security type (SL_SEC_TYPE_OPEN,SL_SEC_TYPE_WEP,SL_SEC_TYPE_WPA_WPA2, SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD,SL_SEC_TYPE_P2P_PIN_DISPLAY, SL_SEC_TYPE_WPA_ENT), key, and key length in case of p2p security type pin the key refers to pin code - \param[in] pSecExtParams Enterprise parameters - identity, identity length, + \param[in] pSecExtParams Enterprise parameters - identity, identity length, Anonymous, Anonymous length, CertIndex (not supported, certificates need to be placed in a specific file ID), EapMethod.Use NULL in case Enterprise parameters is not in use \param[in] Priority profile priority. Lowest priority: 0 \param[in] Options Not supported - - \return On success, profile stored index is returned. On error, negative value is returned - \sa sl_WlanProfileGet , sl_WlanProfileDel + \return On success, profile stored index is returned. On error, negative value is returned + + \sa sl_WlanProfileGet , sl_WlanProfileDel \note belongs to \ref ext_api \warning Only one Enterprise profile is supported. - Please Note that in case of adding an existing profile (compared by pName,pMACAddr and security type) + Please Note that in case of adding an existing profile (compared by pName,pMACAddr and security type) the old profile will be deleted and the same index will be returned. SL_SEC_TYPE_WPA is a deprecated definition, the new definition is SL_SEC_TYPE_WPA_WPA2 @@ -566,32 +619,32 @@ _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr #endif /*! - \brief get profile - - read profile from the device - + \brief get profile + + read profile from the device + \param[in] Index profile stored index, if index does not exists error is return \param[out] pName up to 32 bytes, in case of sta mode the name of the Access Point in case of p2p mode the name of the Remote Device - \param[out] pNameLen name length + \param[out] pNameLen name length \param[out] pMacAddr 6 bytes for MAC address - \param[out] pSecParams security parameters - security type + \param[out] pSecParams security parameters - security type (SL_SEC_TYPE_OPEN, SL_SEC_TYPE_WEP, SL_SEC_TYPE_WPA_WPA2 or - SL_SEC_TYPE_WPS_PBC, SL_SEC_TYPE_WPS_PIN, SL_SEC_TYPE_WPA_ENT,SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD or SL_SEC_TYPE_P2P_PIN_DISPLAY), key and key length are not + SL_SEC_TYPE_WPS_PBC, SL_SEC_TYPE_WPS_PIN, SL_SEC_TYPE_WPA_ENT,SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD or SL_SEC_TYPE_P2P_PIN_DISPLAY), key and key length are not in case of p2p security type pin the key refers to pin code return due to security reasons. - \param[out] pSecExtParams enterprise parameters - identity, identity + \param[out] pSecExtParams enterprise parameters - identity, identity length, Anonymous, Anonymous length CertIndex (not supported), EapMethod. \param[out] Priority profile priority - \return On success, Profile security type is returned (0 or positive number). On error, -1 is - returned - - \sa sl_WlanProfileAdd , sl_WlanProfileDel + \return On success, Profile security type is returned (0 or positive number). On error, -1 is + returned + + \sa sl_WlanProfileAdd , sl_WlanProfileDel \note belongs to \ref ext_api - \warning + \warning */ #if _SL_INCLUDE_FUNC(sl_WlanProfileGet) _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAddr, SlSecParams_t* pSecParams, SlGetSecParamsExt_t* pSecExtParams, _u32 *pPriority); @@ -599,18 +652,18 @@ _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAd /*! \brief Delete WLAN profile - - Delete WLAN profile - + + Delete WLAN profile + \param[in] index number of profile to delete.Possible values are 0 to 6. - Index value 255 will delete all saved profiles - - \return On success, zero is returned. On error, -1 is + Index value 255 will delete all saved profiles + + \return On success, zero is returned. On error, -1 is returned - - \sa sl_WlanProfileAdd , sl_WlanProfileGet + + \sa sl_WlanProfileAdd , sl_WlanProfileGet \note belongs to \ref ext_api - \warning + \warning */ #if _SL_INCLUDE_FUNC(sl_WlanProfileDel) _i16 sl_WlanProfileDel(const _i16 Index); @@ -618,36 +671,36 @@ _i16 sl_WlanProfileDel(const _i16 Index); /*! \brief Set policy values - - \param[in] Type Type of policy to be modified. The Options are:\n - - SL_POLICY_CONNECTION - - SL_POLICY_SCAN + + \param[in] Type Type of policy to be modified. The Options are:\n + - SL_POLICY_CONNECTION + - SL_POLICY_SCAN - SL_POLICY_PM - SL_POLICY_P2P \param[in] Policy The option value which depends on action type \param[in] pVal An optional value pointer \param[in] ValLen An optional value length, in bytes - \return On success, zero is returned. On error, -1 is - returned + \return On success, zero is returned. On error, -1 is + returned \sa sl_WlanPolicyGet \note belongs to \ref ext_api - \warning - \par + \warning + \par SL_POLICY_CONNECTION type defines three options available to connect the CC31xx device to the AP: \n - + - If Auto Connect is set, the CC31xx device tries to automatically reconnect to one of its stored profiles, each time the connection fails or the device is rebooted.\n To set this option, use: \n sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0) - If Fast Connect is set, the CC31xx device tries to establish a fast connection to AP. \n To set this option, use: \n sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,1,0,0,0),NULL,0) - - (relevant for P2P mode only) - If Any P2P is set, CC31xx/CC32xx device tries to automatically connect to the first P2P device available, \n + - (relevant for P2P mode only) - If Any P2P is set, CC31xx/CC32xx device tries to automatically connect to the first P2P device available, \n supporting push button only. To set this option, use: \n sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,0,0,1,0),NULL,0) - For auto smart config upon restart (any command from Host will end this state) use: \n sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,0,0,0,1),NULL,0) \n The options above could be combined to a single action, if more than one action is required. \n - \par + \par SL_POLICY_SCAN defines system scan time interval.Default interval is 10 minutes. \n After settings scan interval, an immediate scan is activated. The next scan will be based on the interval settings. \n - For example, setting scan interval to 1 minute interval use: \n @@ -658,7 +711,7 @@ _i16 sl_WlanProfileDel(const _i16 Index); - For example, disable scan: \n #define SL_SCAN_DISABLE 0 \n sl_WlanPolicySet(SL_POLICY_SCAN,SL_SCAN_DISABLE,0,0); \n - \par + \par SL_POLICY_PM defines a power management policy for Station mode only: - For setting normal power management (default) policy use: sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL,0) - For setting low latency power management policy use: sl_WlanPolicySet(SL_POLICY_PM , SL_LOW_LATENCY_POLICY, NULL,0) @@ -667,7 +720,7 @@ _i16 sl_WlanProfileDel(const _i16 Index); - For setting Long Sleep Interval policy use: \n _u16 PolicyBuff[4] = {0,0,800,0}; // PolicyBuff[2] is max sleep time in mSec \n sl_WlanPolicySet(SL_POLICY_PM , SL_LONG_SLEEP_INTERVAL_POLICY, (_u8*)PolicyBuff,sizeof(PolicyBuff)); \n - + SL_POLICY_P2P defines p2p negotiation policy parameters for P2P role: - To set intent negotiation value, set on of the following: SL_P2P_ROLE_NEGOTIATE - intent 3 @@ -686,21 +739,21 @@ _i16 sl_WlanPolicySet(const _u8 Type , const _u8 Policy, _u8 *pVal,const _u8 Val #endif /*! \brief get policy values - + \param[in] Type SL_POLICY_CONNECTION, SL_POLICY_SCAN, SL_POLICY_PM,SL_POLICY_P2P \n \param[in] Policy argument may be set to any value \n \param[out] The returned values, depends on each policy type, will be stored in the allocated buffer pointed by pVal with a maximum buffer length set by the calling function and pointed to by argument *pValLen - - \return On success, zero is returned. On error, -1 is returned - + + \return On success, zero is returned. On error, -1 is returned + \sa sl_WlanPolicySet \note belongs to \ref ext_api - \warning The value pointed by the argument *pValLen should be set to a value different from 0 and + \warning The value pointed by the argument *pValLen should be set to a value different from 0 and greater than the buffer length returned from the SL device. Otherwise, an error will be returned. */ @@ -709,24 +762,24 @@ _i16 sl_WlanPolicyGet(const _u8 Type , _u8 Policy,_u8 *pVal,_u8 *pValLen); #endif /*! \brief Gets the WLAN scan operation results - + Gets scan results , gets entry from scan result table - + \param[in] Index - Starting index identifier (range 0-19) for getting scan results \param[in] Count - How many entries to fetch. Max is (20-"Index"). - \param[out] pEntries - pointer to an allocated Sl_WlanNetworkEntry_t. - the number of array items should match "Count" + \param[out] pEntries - pointer to an allocated Sl_WlanNetworkEntry_t. + the number of array items should match "Count" sec_type: SL_SCAN_SEC_TYPE_OPEN, SL_SCAN_SEC_TYPE_WEP, SL_SCAN_SEC_TYPE_WPA or SL_SCAN_SEC_TYPE_WPA2 - - + + \return Number of valid networks list items - - \sa + + \sa \note belongs to \ref ext_api - \warning This command do not initiate any active scanning action + \warning This command do not initiate any active scanning action \par Example: \code An example of fetching max 10 results: - + Sl_WlanNetworkEntry_t netEntries[10]; _i16 resultsCount = sl_WlanGetNetworkList(0,10,&netEntries[0]); for(i=0; i< resultsCount; i++) @@ -740,15 +793,15 @@ _i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry #endif /*! - \brief Start collecting wlan RX statistics, for unlimited time. - - \return On success, zero is returned. On error, -1 is returned - + \brief Start collecting wlan RX statistics, for unlimited time. + + \return On success, zero is returned. On error, -1 is returned + \sa sl_WlanRxStatStop sl_WlanRxStatGet - \note belongs to \ref ext_api - \warning + \note belongs to \ref ext_api + \warning \par Example: - \code Getting wlan RX statistics: + \code Getting wlan RX statistics: void RxStatCollectTwice() { @@ -761,16 +814,16 @@ _i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry sl_WlanRxStatStart(); // set statistics mode - rawSocket = sl_Socket(SL_AF_RF, SL_SOCK_RAW, eChannel); + rawSocket = sl_Socket(SL_AF_RF, SL_SOCK_RAW, eChannel); // set timeout - in case we have no activity for the specified channel - sl_SetSockOpt(rawSocket,SL_SOL_SOCKET,SL_SO_RCVTIMEO, &timeval, sizeof(timeval)); // Enable receive timeout + sl_SetSockOpt(rawSocket,SL_SOL_SOCKET,SL_SO_RCVTIMEO, &timeval, sizeof(timeval)); // Enable receive timeout status = sl_Recv(rawSocket, DataFrame, sizeof(DataFrame), 0); Sleep(1000); // sleep for 1 sec sl_WlanRxStatGet(&rxStat,0); // statistics has been cleared upon read Sleep(1000); // sleep for 1 sec - sl_WlanRxStatGet(&rxStat,0); - + sl_WlanRxStatGet(&rxStat,0); + } \endcode */ @@ -781,12 +834,12 @@ _i16 sl_WlanRxStatStart(void); /*! \brief Stop collecting wlan RX statistic, (if previous called sl_WlanRxStatStart) - - \return On success, zero is returned. On error, -1 is returned - + + \return On success, zero is returned. On error, -1 is returned + \sa sl_WlanRxStatStart sl_WlanRxStatGet - \note belongs to \ref ext_api - \warning + \note belongs to \ref ext_api + \warning */ #if _SL_INCLUDE_FUNC(sl_WlanRxStatStop) _i16 sl_WlanRxStatStop(void); @@ -795,14 +848,14 @@ _i16 sl_WlanRxStatStop(void); /*! \brief Get wlan RX statistics. upon calling this command, the statistics counters will be cleared. - + \param[in] Flags should be 0 ( not applicable right now, will be added the future ) \param[in] pRxStat a pointer to SlGetRxStatResponse_t filled with Rx statistics results - \return On success, zero is returned. On error, -1 is returned - - \sa sl_WlanRxStatStart sl_WlanRxStatStop - \note belongs to \ref ext_api - \warning + \return On success, zero is returned. On error, -1 is returned + + \sa sl_WlanRxStatStart sl_WlanRxStatStop + \note belongs to \ref ext_api + \warning */ #if _SL_INCLUDE_FUNC(sl_WlanRxStatGet) _i16 sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,const _u32 Flags); @@ -812,16 +865,16 @@ _i16 sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,const _u32 Flags); /*! \brief Stop Smart Config procedure. Once Smart Config will be stopped, Asynchronous event will be received - SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE. - + \param[in] none \param[out] none - + \return 0 - if Stop Smart Config is about to be executed without errors. - - \sa sl_WlanSmartConfigStart - \note belongs to \ref ext_api - \warning - + + \sa sl_WlanSmartConfigStart + \note belongs to \ref ext_api + \warning + */ #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStop) _i16 sl_WlanSmartConfigStop(void); @@ -843,7 +896,7 @@ _i16 sl_WlanSmartConfigStop(void); The Event will hold the SSID and an extra field that might have been delivered as well (i.e. - device name) \param[in] groupIdBitmask - each bit represent a group ID that should be searched. - The Default group ID id BIT_0. 2 more group can be searched + The Default group ID id BIT_0. 2 more group can be searched in addition. The range is BIT_0 - BIT_15. \param[in] chiper - 0: check in flash, 1 - AES, 0xFF - do not check in flash \param[in] publicKeyLen - public key len (used for the default group ID - BIT_0) @@ -854,15 +907,15 @@ _i16 sl_WlanSmartConfigStop(void); \param[in] group2Key - group ID2 key \param[out] none - + \return 0 - if Smart Config started successfully. - - \sa sl_WlanSmartConfigStop - \note belongs to \ref ext_api - \warning - \par + + \sa sl_WlanSmartConfigStop + \note belongs to \ref ext_api + \warning + \par \code An example of starting smart Config on group ID's 0 + 1 + 2 - + sl_WlanSmartConfigStart(7, //group ID's (BIT_0 | BIT_1 | BIT_2) 1, //decrypt key by AES method 16, //decryption key length for group ID0 @@ -895,10 +948,10 @@ _i16 sl_WlanSmartConfigStart(const _u32 groupIdBitmask, - ROLE_STA - for WLAN station mode - ROLE_AP - for WLAN AP mode - ROLE_P2P -for WLAN P2P mode - \return 0 - if mode was set correctly + \return 0 - if mode was set correctly \sa sl_Start sl_Stop - \note belongs to \ref ext_api - \warning After setting the mode the system must be restarted for activating the new mode + \note belongs to \ref ext_api + \warning After setting the mode the system must be restarted for activating the new mode \par Example: \code //Switch from any role to STA: @@ -922,17 +975,17 @@ _i16 sl_WlanSetMode(const _u8 mode); - CONF_OLD_FILE_VERSION (-3) - CONF_ERROR_NO_SUCH_COUNTRY_CODE (-4) - - \param[in] ConfigId - configuration id + + \param[in] ConfigId - configuration id - SL_WLAN_CFG_AP_ID - SL_WLAN_CFG_GENERAL_PARAM_ID - - SL_WLAN_CFG_P2P_PARAM_ID - + - SL_WLAN_CFG_P2P_PARAM_ID + \param[in] ConfigOpt - configurations option - SL_WLAN_CFG_AP_ID - WLAN_AP_OPT_SSID \n Set SSID for AP mode. \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - WLAN_AP_OPT_CHANNEL \n Set channel for AP mode. \n The channel is dependant on the country code which is set. i.e. for "US" the channel should be in the range of [1-11] \n @@ -954,22 +1007,22 @@ _i16 sl_WlanSetMode(const _u8 mode); Set Password for for AP mode (for WEP or for WPA): \n Password - for WPA: 8 - 63 characters \n for WEP: 5 / 13 characters (ascii) \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - SL_WLAN_CFG_GENERAL_PARAM_ID - WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS \n Set scan parameters. This option uses slWlanScanParamCommand_t as parameter - WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE \n Set Country Code for AP mode \n - This options takes _u8 2 bytes buffer as parameter + This options takes _u8 2 bytes buffer as parameter - WLAN_GENERAL_PARAM_OPT_STA_TX_POWER \n Set STA mode Tx power level \n Number between 0-15, as dB offset from max power (0 will set MAX power) \n - This options takes _u8 as parameter - - WLAN_GENERAL_PARAM_OPT_AP_TX_POWER + This options takes _u8 as parameter + - WLAN_GENERAL_PARAM_OPT_AP_TX_POWER Set AP mode Tx power level \n Number between 0-15, as dB offset from max power (0 will set MAX power) \n - This options takes _u8 as parameter + This options takes _u8 as parameter - WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT Set Info Element for AP mode. \n The Application can set up to MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED info elements per Role (AP / P2P GO). \n @@ -978,12 +1031,12 @@ _i16 sl_WlanSetMode(const _u8 mode); However, for AP - no more than INFO_ELEMENT_MAX_TOTAL_LENGTH_AP bytes can be stored for all info elements. \n For P2P GO - no more than INFO_ELEMENT_MAX_TOTAL_LENGTH_P2P_GO bytes can be stored for all info elements. \n This option takes sl_protocol_WlanSetInfoElement_t as parameter - - SL_WLAN_CFG_P2P_PARAM_ID + - SL_WLAN_CFG_P2P_PARAM_ID - WLAN_P2P_OPT_DEV_TYPE \n Set P2P Device type.Maximum length of 17 characters. Device type is published under P2P I.E, \n allows to make devices easier to recognize. \n In case no device type is set, the default type is "1-0050F204-1" \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - WLAN_P2P_OPT_CHANNEL_N_REGS \n Set P2P Channels. \n listen channel (either 1/6/11 for 2.4GHz) \n @@ -992,20 +1045,20 @@ _i16 sl_WlanSetMode(const _u8 mode); oper regulatory class (81 for 2.4GHz) \n listen channel and regulatory class will determine the device listen channel during p2p find listen phase \n oper channel and regulatory class will determine the operating channel preferred by this device (in case it is group owner this will be the operating channel) \n - channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected. - This option takes pointer to _u8[4] as parameter - + channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected. + This option takes pointer to _u8[4] as parameter + \param[in] ConfigLen - configurations len \param[in] pValues - configurations values - \sa - \note + \sa + \note \warning \par Examples: \par WLAN_AP_OPT_SSID: - \code + \code _u8 str[33]; memset(str, 0, 33); memcpy(str, ssid, len); // ssid string of 32 characters @@ -1019,34 +1072,34 @@ _i16 sl_WlanSetMode(const _u8 mode); \endcode \par WLAN_AP_OPT_HIDDEN_SSID: - \code + \code _u8 val = hidden; sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_HIDDEN_SSID, 1, (_u8 *)&val); \endcode \par WLAN_AP_OPT_SECURITY_TYPE: - \code - _u8 val = SL_SEC_TYPE_WPA_WPA2; + \code + _u8 val = SL_SEC_TYPE_WPA_WPA2; sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (_u8 *)&val); \endcode \par WLAN_AP_OPT_PASSWORD: - \code - _u8 str[65]; - _u16 len = strlen(password); + \code + _u8 str[65]; + _u16 len = strlen(password); memset(str, 0, 65); memcpy(str, password, len); sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, len, (_u8 *)str); \endcode \par WLAN_GENERAL_PARAM_OPT_STA_TX_POWER: - \code + \code _u8 stapower=(_u8)power; sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER,1,(_u8 *)&stapower); \endcode - \par + \par WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS: - \code + \code slWlanScanParamCommand_t ScanParamConfig; ScanParamConfig.G_Channels_mask = 0x01; // bit mask for channels:1 means channel 1 is enabled, 3 means channels 1 + 2 are enabled ScanParamConfig.rssiThershold = -70; // only for RSSI level which is higher than -70 @@ -1057,8 +1110,8 @@ _i16 sl_WlanSetMode(const _u8 mode); WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE: \code _u8* str = (_u8 *) country; // string of 2 characters. i.e. - "US" - sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE, 2, str); - \endcode + sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE, 2, str); + \endcode \par WLAN_GENERAL_PARAM_OPT_AP_TX_POWER: \code @@ -1068,9 +1121,9 @@ _i16 sl_WlanSetMode(const _u8 mode); \par WLAN_P2P_OPT_DEV_TYPE: \code - _u8 str[17]; + _u8 str[17]; _u16 len = strlen(device_type); - memset(str, 0, 17); + memset(str, 0, 17); memcpy(str, device_type, len); sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE, len, str); \endcode @@ -1086,13 +1139,13 @@ _i16 sl_WlanSetMode(const _u8 mode); \endcode \par WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT: - \code - sl_protocol_WlanSetInfoElement_t infoele; + \code + sl_protocol_WlanSetInfoElement_t infoele; infoele.index = Index; // Index of the info element. range: 0 - MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED infoele.role = Role; // INFO_ELEMENT_AP_ROLE (0) or INFO_ELEMENT_P2P_GO_ROLE (1) infoele.ie.id = Id; // Info element ID. if INFO_ELEMENT_DEFAULT_ID (0) is set, ID will be set to 221. // Organization unique ID. If all 3 bytes are zero - it will be replaced with 08,00,28. - infoele.ie.oui[0] = Oui0; // Organization unique ID first Byte + infoele.ie.oui[0] = Oui0; // Organization unique ID first Byte infoele.ie.oui[1] = Oui1; // Organization unique ID second Byte infoele.ie.oui[2] = Oui2; // Organization unique ID third Byte infoele.ie.length = Len; // Length of the info element. must be smaller than 253 bytes @@ -1102,7 +1155,7 @@ _i16 sl_WlanSetMode(const _u8 mode); memcpy(infoele.ie.data, IE, Len); // Info element. length of the info element is [0-252] sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(_u8* ) &infoele); } - sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(_u8* ) &infoele); + sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(_u8* ) &infoele); \endcode */ @@ -1113,20 +1166,20 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c /*! \brief Internal function for getting WLAN configurations - \return On success, zero is returned. On error, -1 is + \return On success, zero is returned. On error, -1 is returned - + \param[in] ConfigId - configuration id - SL_WLAN_CFG_AP_ID - SL_WLAN_CFG_GENERAL_PARAM_ID - SL_WLAN_CFG_P2P_PARAM_ID - - \param[out] pConfigOpt - get configurations option + + \param[out] pConfigOpt - get configurations option - SL_WLAN_CFG_AP_ID - WLAN_AP_OPT_SSID \n Get SSID for AP mode. \n Get up to 32 characters of SSID \n - This options takes _u8 as parameter + This options takes _u8 as parameter - WLAN_AP_OPT_CHANNEL \n Get channel for AP mode. \n This option takes _u8 as a parameter @@ -1146,23 +1199,23 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c - WLAN_AP_OPT_PASSWORD \n Get Password for for AP mode (for WEP or for WPA): \n Returns password - string, fills up to 64 characters. \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - SL_WLAN_CFG_GENERAL_PARAM_ID - WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS \n Get scan parameters. This option uses slWlanScanParamCommand_t as parameter - WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE \n Get Country Code for AP mode \n - This options takes _u8 buffer as parameter + This options takes _u8 buffer as parameter - WLAN_GENERAL_PARAM_OPT_STA_TX_POWER \n Get STA mode Tx power level \n Number between 0-15, as dB offset from max power (0 indicates MAX power) \n - This options takes _u8 as parameter - - WLAN_GENERAL_PARAM_OPT_AP_TX_POWER + This options takes _u8 as parameter + - WLAN_GENERAL_PARAM_OPT_AP_TX_POWER Get AP mode Tx power level \n Number between 0-15, as dB offset from max power (0 indicates MAX power) \n - This options takes _u8 as parameter - - SL_WLAN_CFG_P2P_PARAM_ID + This options takes _u8 as parameter + - SL_WLAN_CFG_P2P_PARAM_ID - WLAN_P2P_OPT_CHANNEL_N_REGS \n Get P2P Channels. \n listen channel (either 1/6/11 for 2.4GHz) \n @@ -1172,12 +1225,12 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c listen channel and regulatory class will determine the device listen channel during p2p find listen phase \n oper channel and regulatory class will determine the operating channel preferred by this device (in case it is group owner this will be the operating channel) \n channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected. \n - This option takes pointer to _u8[4] as parameter - + This option takes pointer to _u8[4] as parameter + \param[out] pConfigLen - The length of the allocated memory as input, when the function complete, the value of this parameter would be - the len that actually read from the device. - If the device return length that is longer from the input + the len that actually read from the device. + If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return SL_ESMALLBUF. @@ -1186,20 +1239,20 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c \sa sl_WlanSet - \note + \note - \warning + \warning \par Examples: - \par + \par WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS: - \code + \code slWlanScanParamCommand_t ScanParamConfig; _u16 Option = WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS; _u16 OptionLen = sizeof(slWlanScanParamCommand_t); sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&ScanParamConfig); \endcode - \par + \par WLAN_GENERAL_PARAM_OPT_AP_TX_POWER: \code _i8 TXPower = 0; @@ -1207,32 +1260,32 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c _u16 OptionLen = sizeof(_i8); sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&TXPower); \endcode - \par + \par WLAN_GENERAL_PARAM_OPT_STA_TX_POWER: - \code + \code _i8 TXPower = 0; _u16 Option = WLAN_GENERAL_PARAM_OPT_STA_TX_POWER; _u16 OptionLen = sizeof(_i8); - + sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&TXPower); \endcode - \par + \par WLAN_P2P_OPT_DEV_TYPE: - \code + \code _i8 device_type[18]; _u16 len = 18; - _u16 config_opt = WLAN_P2P_OPT_DEV_TYPE; + _u16 config_opt = WLAN_P2P_OPT_DEV_TYPE; sl_WlanGet(SL_WLAN_CFG_P2P_PARAM_ID, &config_opt , &len, (_u8* )device_type); \endcode - \par + \par WLAN_AP_OPT_SSID: - \code + \code _i8 ssid[32]; _u16 len = 32; _u16 config_opt = WLAN_AP_OPT_SSID; sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt , &len, (_u8* )ssid); \endcode - \par + \par WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE: \code _i8 country[3]; @@ -1240,7 +1293,7 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c _u16 config_opt = WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE; sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID, &config_opt, &len, (_u8* )country); \endcode - \par + \par WLAN_AP_OPT_CHANNEL: \code _i8 channel; @@ -1248,23 +1301,23 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c _u16 config_opt = WLAN_AP_OPT_CHANNEL; sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&channel); \endcode - \par + \par WLAN_AP_OPT_HIDDEN_SSID: \code _u8 hidden; _u16 len = 1; _u16 config_opt = WLAN_AP_OPT_HIDDEN_SSID; - sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&hidden); + sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&hidden); \endcode - \par + \par WLAN_AP_OPT_SECURITY_TYPE: - \code + \code _u8 sec_type; _u16 len = 1; _u16 config_opt = WLAN_AP_OPT_SECURITY_TYPE; sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&sec_type); \endcode - \par + \par WLAN_AP_OPT_PASSWORD: \code _u8 password[64]; @@ -1274,7 +1327,7 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )password); \endcode - \par + \par WLAN_P2P_OPT_CHANNEL_N_REGS: \code _u16 listen_channel,listen_reg,oper_channel,oper_reg; @@ -1282,10 +1335,10 @@ _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,c _u16 config_opt = WLAN_P2P_OPT_CHANNEL_N_REGS; _u8 channel_n_regs[4]; sl_WlanGet(SL_WLAN_CFG_P2P_PARAM_ID, &config_opt, &len, (_u8* )channel_n_regs); - listen_channel = channel_n_regs[0]; + listen_channel = channel_n_regs[0]; listen_reg = channel_n_regs[1]; oper_channel = channel_n_regs[2]; - oper_reg = channel_n_regs[3]; + oper_reg = channel_n_regs[3]; \endcode */ diff --git a/hardware/lm4f/libraries/WiFi/utility/wlan_rx_filters.h b/hardware/lm4f/libraries/WiFi/utility/wlan_rx_filters.h index 019ed048369..6868336744d 100644 --- a/hardware/lm4f/libraries/WiFi/utility/wlan_rx_filters.h +++ b/hardware/lm4f/libraries/WiFi/utility/wlan_rx_filters.h @@ -1,35 +1,35 @@ /* * wlan_rx_filters.h - CC31xx/CC32xx Host Driver Implementation * - * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -91,7 +91,7 @@ extern "C" { #define RXFL_OK (0) /* O.K */ #define RXFL_OUTPUT_OR_INPUT_BUFFER_LENGTH_TOO_SMALL (76) /* ! The output buffer length is smaller than required for that operation */ #define RXFL_DEPENDENT_FILTER_SOFTWARE_FILTER_NOT_FIT (75) /* Node filter can't be child of software filter and vice_versa */ -#define RXFL_DEPENDENCY_IS_NOT_PERSISTENT (74) /* Dependency filter is not persistent */ +#define RXFL_DEPENDENCY_IS_NOT_PERSISTENT (74) /* Dependency filter is not persistent */ #define RXFL_SYSTEM_STATE_NOT_SUPPORTED_FOR_THIS_FILTER (72) /* System state is not supported */ #define RXFL_TRIGGER_USE_REG5_TO_REG8 (71) /* Only counters 5 - 8 are allowed, for Tigger */ #define RXFL_TRIGGER_USE_REG1_TO_REG4 (70) /* Only counters 1 - 4 are allowed, for trigger */ @@ -257,11 +257,11 @@ typedef union SlrxFilterFlags_t */ /* _u8 Binary: 1; */ /*! - * + * */ /* _u8 AutoSort : 1; */ /*! - * + * */ /* _u8 AutoFaultDetect : 1; */ /*! @@ -420,7 +420,7 @@ typedef struct SlrxFilterRuleHeaderArgsAndMask_t typedef struct SlrxFilterHeaderType_t { /*! see :: SlrxFilterRuleHeaderArgsAndMask_t */ - /* -- 52 bytes */ + /* -- 52 bytes */ SlrxFilterRuleHeaderArgsAndMask_t RuleHeaderArgsAndMask; /*! Packet HDR field which will be compared to the argument */ @@ -528,7 +528,7 @@ typedef union SlrxFilterTriggerRoles_t /* _u8 PromiscuousMode :1; */ /* _u8 RoleReserved :5; */ /* }; */ - /* ! Bit fiels of the Filter role */ + /* ! Bit fiels of the Filter role */ _u8 IntRepresentation; }SlrxFilterTriggerRoles_t; @@ -556,7 +556,7 @@ typedef union SlrxFilterTriggerConnectionStates_t /* */ /* ! */ _u8 IntRepresentation; - + }SlrxFilterTriggerConnectionStates_t; /*! \typedef SlrxFilterDBTriggerArg_t @@ -845,10 +845,10 @@ typedef _u8 SLrxFilterOperation_t; \return On success, zero is returned. Otherwise error code is returned */ #if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd) -SlrxFilterID_t sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, - SlrxFilterFlags_t FilterFlags, - const SlrxFilterRule_t* const Rule, - const SlrxFilterTrigger_t* const Trigger, +_i16 sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, + SlrxFilterFlags_t FilterFlags, + const SlrxFilterRule_t* const Rule, + const SlrxFilterTrigger_t* const Trigger, const SlrxFilterAction_t* const Action, SlrxFilterID_t* pFilterId);