drivers, cc3000: Wrap exported functions in a macro for renaming.

This commit is contained in:
Damien George 2014-09-30 23:25:42 +01:00
parent 9d2bf9c405
commit 8762418d0c
17 changed files with 121 additions and 132 deletions

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __COMMON_H__
#define __COMMON_H__
#ifndef __CC3000_COMMON_H__
#define __CC3000_COMMON_H__
#include "data_types.h"
@ -43,6 +43,11 @@
#include <stdlib.h>
#include <stdint.h>
//*****************************************************************************
// Prefix exported names to avoid name clash
//*****************************************************************************
#define CC3000_EXPORT(name) cc3000_ ## name
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
@ -53,7 +58,7 @@
extern "C" {
#endif
extern int errno;
extern int CC3000_EXPORT(errno);
//*****************************************************************************
// ERROR CODES
@ -357,4 +362,4 @@ extern UINT32 STREAM_TO_UINT32_f(CHAR* p, UINT16 offset);
}
#endif // __cplusplus
#endif // __COMMON_H__
#endif // __CC3000_COMMON_H__

View File

@ -34,8 +34,8 @@
*****************************************************************************/
#ifndef __SPI_H__
#define __SPI_H__
#ifndef __CC3000_SPI_H__
#define __CC3000_SPI_H__
//*****************************************************************************
//

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __DATA_TYPES__
#define __DATA_TYPES__
#ifndef __CC3000_DATA_TYPES__
#define __CC3000_DATA_TYPES__
//*****************************************************************************
//
@ -104,4 +104,4 @@ typedef char CHAR;
}
#endif /* __cplusplus */
#endif /* __DATA_TYPE__ */
#endif /* __CC3000_DATA_TYPES__ */

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __EVENT_HANDLER_H__
#define __EVENT_HANDLER_H__
#ifndef __CC3000_EVENT_HANDLER_H__
#define __CC3000_EVENT_HANDLER_H__
#include "hci.h"
#include "socket.h"
@ -162,5 +162,5 @@ typedef struct _bsd_gethostbyname_return_t
}
#endif // __cplusplus
#endif // __EVENT_HANDLER_H__
#endif // __CC3000_EVENT_HANDLER_H__

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __HCI_H__
#define __HCI_H__
#ifndef __CC3000_HCI_H__
#define __CC3000_HCI_H__
#include "cc3000_common.h"
@ -327,4 +327,4 @@ extern void hci_patch_send(UINT8 ucOpcode, UINT8 *pucBuff, CHAR *patch, UINT16 u
}
#endif // __cplusplus
#endif // __HCI_H__
#endif // __CC3000_HCI_H__

View File

@ -32,24 +32,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __HOST_DRIVER_VERSION_H__
#define __HOST_DRIVER_VERSION_H__
#ifndef __CC3000_HOST_DRIVER_VERSION_H__
#define __CC3000_HOST_DRIVER_VERSION_H__
#define DRIVER_VERSION_NUMBER 15
#endif // __VERSION_H__
#endif // __CC3000_HOST_DRIVER_VERSION_H__

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __NETAPP_H__
#define __NETAPP_H__
#ifndef __CC3000_NETAPP_H__
#define __CC3000_NETAPP_H__
#include "data_types.h"
@ -339,5 +339,5 @@ INT32 netapp_set_debug_level(UINT32 ulLevel);
}
#endif // __cplusplus
#endif // __NETAPP_H__
#endif // __CC3000_NETAPP_H__

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __NVRAM_H__
#define __NVRAM_H__
#ifndef __CC3000_NVRAM_H__
#define __CC3000_NVRAM_H__
#include "cc3000_common.h"
@ -245,4 +245,4 @@ extern INT32 nvmem_create_entry(UINT32 file_id, UINT32 newlen);
}
#endif // __cplusplus
#endif // __NVRAM_H__
#endif // __CC3000_NVRAM_H__

View File

@ -1,5 +1,5 @@
#ifndef __PATCH_PROG_H__
#define __PATCH_PROG_H__
#ifndef __CC3000_PATCH_PROG_H__
#define __CC3000_PATCH_PROG_H__
extern unsigned short fw_length;
extern const unsigned char fw_patch[];
@ -8,4 +8,4 @@ extern const unsigned char wlan_drv_patch[];
extern const unsigned char cRMdefaultParams[128];
void patch_prog_start();
#endif //__PATCH_PROG_H__
#endif //__CC3000_PATCH_PROG_H__

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __SECURITY__
#define __SECURITY__
#ifndef __CC3000_SECURITY__
#define __CC3000_SECURITY__
#include "nvmem.h"

View File

@ -32,9 +32,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __SOCKET_H__
#define __SOCKET_H__
#ifndef __CC3000_SOCKET_H__
#define __CC3000_SOCKET_H__
#include "cc3000_common.h"
//*****************************************************************************
//
@ -215,7 +216,7 @@ typedef struct
//! application layer to obtain a socket handle.
//
//*****************************************************************************
extern INT16 socket(INT32 domain, INT32 type, INT32 protocol);
extern INT16 CC3000_EXPORT(socket)(INT32 domain, INT32 type, INT32 protocol);
//*****************************************************************************
//
@ -228,7 +229,7 @@ extern INT16 socket(INT32 domain, INT32 type, INT32 protocol);
//! @brief The socket function closes a created socket.
//
//*****************************************************************************
extern INT32 closesocket(INT32 sd);
extern INT32 CC3000_EXPORT(closesocket)(INT32 sd);
//*****************************************************************************
//
@ -274,7 +275,7 @@ extern INT32 closesocket(INT32 sd);
//! @sa socket ; bind ; listen
//
//*****************************************************************************
extern INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen);
extern INT32 CC3000_EXPORT(accept)(INT32 sd, sockaddr *addr, socklen_t *addrlen);
//*****************************************************************************
//
@ -298,7 +299,7 @@ extern INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen);
//! @sa socket ; accept ; listen
//
//*****************************************************************************
extern INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen);
extern INT32 CC3000_EXPORT(bind)(INT32 sd, const sockaddr *addr, INT32 addrlen);
//*****************************************************************************
//
@ -322,7 +323,7 @@ extern INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen);
//! @note On this version, backlog is not supported
//
//*****************************************************************************
extern INT32 listen(INT32 sd, INT32 backlog);
extern INT32 CC3000_EXPORT(listen)(INT32 sd, INT32 backlog);
//*****************************************************************************
//
@ -343,7 +344,7 @@ extern INT32 listen(INT32 sd, INT32 backlog);
//
//*****************************************************************************
#ifndef CC3000_TINY_DRIVER
extern INT16 gethostbyname(CHAR * hostname, UINT16 usNameLen, UINT32* out_ip_addr);
extern INT16 CC3000_EXPORT(gethostbyname)(CHAR * hostname, UINT16 usNameLen, UINT32* out_ip_addr);
#endif
@ -375,7 +376,7 @@ extern INT16 gethostbyname(CHAR * hostname, UINT16 usNameLen, UINT32* out_ip_add
//! @sa socket
//
//*****************************************************************************
extern INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen);
extern INT32 CC3000_EXPORT(connect)(INT32 sd, const sockaddr *addr, INT32 addrlen);
//*****************************************************************************
//
@ -414,7 +415,7 @@ extern INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen);
//! @sa socket
//
//*****************************************************************************
extern INT16 select(INT32 nfds, fd_set *readsds, fd_set *writesds,
extern INT16 CC3000_EXPORT(select)(INT32 nfds, fd_set *readsds, fd_set *writesds,
fd_set *exceptsds, struct timeval *timeout);
//*****************************************************************************
@ -464,7 +465,7 @@ extern INT16 select(INT32 nfds, fd_set *readsds, fd_set *writesds,
//
//*****************************************************************************
#ifndef CC3000_TINY_DRIVER
extern INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval,
extern INT16 CC3000_EXPORT(setsockopt)(INT32 sd, INT32 level, INT32 optname, const void *optval,
socklen_t optlen);
#endif
//*****************************************************************************
@ -513,7 +514,7 @@ extern INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval
//! @sa setsockopt
//
//*****************************************************************************
extern INT16 getsockopt(INT32 sd, INT32 level, INT32 optname, void *optval,
extern INT16 CC3000_EXPORT(getsockopt)(INT32 sd, INT32 level, INT32 optname, void *optval,
socklen_t *optlen);
//*****************************************************************************
@ -537,7 +538,7 @@ extern INT16 getsockopt(INT32 sd, INT32 level, INT32 optname, void *optval,
//! @Note On this version, only blocking mode is supported.
//
//*****************************************************************************
extern INT16 recv(INT32 sd, void *buf, INT32 len, INT32 flags);
extern INT16 CC3000_EXPORT(recv)(INT32 sd, void *buf, INT32 len, INT32 flags);
//*****************************************************************************
//
@ -567,7 +568,7 @@ extern INT16 recv(INT32 sd, void *buf, INT32 len, INT32 flags);
//! @Note On this version, only blocking mode is supported.
//
//*****************************************************************************
extern INT16 recvfrom(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
extern INT16 CC3000_EXPORT(recvfrom)(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
socklen_t *fromlen);
//*****************************************************************************
@ -592,7 +593,7 @@ extern INT16 recvfrom(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *fro
//
//*****************************************************************************
extern INT16 send(INT32 sd, const void *buf, INT32 len, INT32 flags);
extern INT16 CC3000_EXPORT(send)(INT32 sd, const void *buf, INT32 len, INT32 flags);
//*****************************************************************************
//
@ -620,7 +621,7 @@ extern INT16 send(INT32 sd, const void *buf, INT32 len, INT32 flags);
//
//*****************************************************************************
extern INT16 sendto(INT32 sd, const void *buf, INT32 len, INT32 flags,
extern INT16 CC3000_EXPORT(sendto)(INT32 sd, const void *buf, INT32 len, INT32 flags,
const sockaddr *to, socklen_t tolen);
//*****************************************************************************
@ -639,7 +640,7 @@ extern INT16 sendto(INT32 sd, const void *buf, INT32 len, INT32 flags,
//! @brief Set CC3000 in mDNS advertiser mode in order to advertise itself.
//
//*****************************************************************************
extern INT16 mdnsAdvertiser(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 deviceServiceNameLength);
extern INT16 CC3000_EXPORT(mdnsAdvertiser)(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 deviceServiceNameLength);
//*****************************************************************************
@ -653,7 +654,7 @@ extern INT16 mdnsAdvertiser(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16
//! @brief Returns the MSS value of a TCP connection according to the socket descriptor
//
//*****************************************************************************
extern UINT16 getmssvalue (INT32 sd);
extern UINT16 CC3000_EXPORT(getmssvalue) (INT32 sd);
//*****************************************************************************
//

View File

@ -32,8 +32,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef __WLAN_H__
#define __WLAN_H__
#ifndef __CC3000_WLAN_H__
#define __CC3000_WLAN_H__
#include "cc3000_common.h"
@ -515,4 +515,4 @@ extern INT32 wlan_smart_config_process(void);
}
#endif // __cplusplus
#endif // __WLAN_H__
#endif // __CC3000_WLAN_H__

View File

@ -27,7 +27,7 @@
#define ENOSPC (28)
#define EAFNOSUPPORT (106)
#define SET_ERRNO(err) (errno=-err)
#define SET_ERRNO(err) (CC3000_EXPORT(errno)=-err)
/*
* Format an IPv4 address, more or less like inet_ntoa().

View File

@ -31,7 +31,7 @@ static int inet_pton6(const char *src, unsigned char *dst);
#endif
#define EAFNOSUPPORT (106)
#define SET_ERRNO(err) (errno=-err)
#define SET_ERRNO(err) (CC3000_EXPORT(errno)=-err)
/* int
* inet_pton(af, src, dst)

View File

@ -108,7 +108,7 @@
//! regarding the buffers available.
//
//*****************************************************************************
INT16 HostFlowControlConsumeBuff(INT16 sd)
static INT16 HostFlowControlConsumeBuff(INT16 sd)
{
#ifndef SEND_NON_BLOCKING
/* wait in busy loop */
@ -119,9 +119,9 @@ INT16 HostFlowControlConsumeBuff(INT16 sd)
// Note that the buffer will not be allocated in this case
if (tSLInformation.slTransmitDataError != 0)
{
errno = tSLInformation.slTransmitDataError;
CC3000_EXPORT(errno) = tSLInformation.slTransmitDataError;
tSLInformation.slTransmitDataError = 0;
return errno;
return CC3000_EXPORT(errno);
}
if(SOCKET_STATUS_ACTIVE != get_socket_active_status(sd))
@ -138,9 +138,9 @@ INT16 HostFlowControlConsumeBuff(INT16 sd)
// Note that the buffer will not be allocated in this case
if (tSLInformation.slTransmitDataError != 0)
{
errno = tSLInformation.slTransmitDataError;
CC3000_EXPORT(errno) = tSLInformation.slTransmitDataError;
tSLInformation.slTransmitDataError = 0;
return errno;
return CC3000_EXPORT(errno);
}
if(SOCKET_STATUS_ACTIVE != get_socket_active_status(sd))
return -1;
@ -182,7 +182,7 @@ INT16 HostFlowControlConsumeBuff(INT16 sd)
//
//*****************************************************************************
INT16 socket(INT32 domain, INT32 type, INT32 protocol)
INT16 CC3000_EXPORT(socket)(INT32 domain, INT32 type, INT32 protocol)
{
INT32 ret;
UINT8 *ptr, *args;
@ -203,7 +203,7 @@ INT16 socket(INT32 domain, INT32 type, INT32 protocol)
SimpleLinkWaitEvent(HCI_CMND_SOCKET, &ret);
// Process the event
errno = ret;
CC3000_EXPORT(errno) = ret;
set_socket_active_status(ret, SOCKET_STATUS_ACTIVE);
@ -222,7 +222,7 @@ INT16 socket(INT32 domain, INT32 type, INT32 protocol)
//
//*****************************************************************************
INT32 closesocket(INT32 sd)
INT32 CC3000_EXPORT(closesocket)(INT32 sd)
{
INT32 ret;
UINT8 *ptr, *args;
@ -240,7 +240,7 @@ INT32 closesocket(INT32 sd)
// Since we are in blocking state - wait for event complete
SimpleLinkWaitEvent(HCI_CMND_CLOSE_SOCKET, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
// since 'close' call may result in either OK (and then it closed) or error
// mark this socket as invalid
@ -294,7 +294,7 @@ INT32 closesocket(INT32 sd)
//
//*****************************************************************************
INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen)
INT32 CC3000_EXPORT(accept)(INT32 sd, sockaddr *addr, socklen_t *addrlen)
{
INT32 ret;
UINT8 *ptr, *args;
@ -318,8 +318,8 @@ INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen)
// need specify return parameters!!!
memcpy(addr, &tAcceptReturnArguments.tSocketAddress, ASIC_ADDR_LEN);
*addrlen = ASIC_ADDR_LEN;
errno = tAcceptReturnArguments.iStatus;
ret = errno;
CC3000_EXPORT(errno) = tAcceptReturnArguments.iStatus;
ret = CC3000_EXPORT(errno);
// if succeeded, iStatus = new socket descriptor. otherwise - error number
if(M_IS_VALID_SD(ret))
@ -357,7 +357,7 @@ INT32 accept(INT32 sd, sockaddr *addr, socklen_t *addrlen)
//
//*****************************************************************************
INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen)
INT32 CC3000_EXPORT(bind)(INT32 sd, const sockaddr *addr, INT32 addrlen)
{
INT32 ret;
UINT8 *ptr, *args;
@ -381,7 +381,7 @@ INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen)
// Since we are in blocking state - wait for event complete
SimpleLinkWaitEvent(HCI_CMND_BIND, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
return(ret);
}
@ -409,7 +409,7 @@ INT32 bind(INT32 sd, const sockaddr *addr, INT32 addrlen)
//
//*****************************************************************************
INT32 listen(INT32 sd, INT32 backlog)
INT32 CC3000_EXPORT(listen)(INT32 sd, INT32 backlog)
{
INT32 ret;
UINT8 *ptr, *args;
@ -428,7 +428,7 @@ INT32 listen(INT32 sd, INT32 backlog)
// Since we are in blocking state - wait for event complete
SimpleLinkWaitEvent(HCI_CMND_LISTEN, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
return(ret);
}
@ -453,17 +453,17 @@ INT32 listen(INT32 sd, INT32 backlog)
//*****************************************************************************
#ifndef CC3000_TINY_DRIVER
INT16 gethostbyname(CHAR * hostname, UINT16 usNameLen,
INT16 CC3000_EXPORT(gethostbyname)(CHAR * hostname, UINT16 usNameLen,
UINT32* out_ip_addr)
{
tBsdGethostbynameParams ret;
UINT8 *ptr, *args;
errno = EFAIL;
CC3000_EXPORT(errno) = EFAIL;
if (usNameLen > HOSTNAME_MAX_LENGTH)
{
return errno;
return CC3000_EXPORT(errno);
}
ptr = tSLInformation.pucTxCommandBuffer;
@ -481,11 +481,11 @@ INT16 gethostbyname(CHAR * hostname, UINT16 usNameLen,
// Since we are in blocking state - wait for event complete
SimpleLinkWaitEvent(HCI_EVNT_BSD_GETHOSTBYNAME, &ret);
errno = ret.retVal;
CC3000_EXPORT(errno) = ret.retVal;
(*((INT32*)out_ip_addr)) = ret.outputAddress;
return (errno);
return CC3000_EXPORT(errno);
}
#endif
@ -519,7 +519,7 @@ INT16 gethostbyname(CHAR * hostname, UINT16 usNameLen,
//
//*****************************************************************************
INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen)
INT32 CC3000_EXPORT(connect)(INT32 sd, const sockaddr *addr, INT32 addrlen)
{
INT32 ret;
UINT8 *ptr, *args;
@ -542,7 +542,7 @@ INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen)
// Since we are in blocking state - wait for event complete
SimpleLinkWaitEvent(HCI_CMND_CONNECT, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
return((INT32)ret);
}
@ -586,7 +586,7 @@ INT32 connect(INT32 sd, const sockaddr *addr, INT32 addrlen)
//
//*****************************************************************************
INT16 select(INT32 nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds,
INT16 CC3000_EXPORT(select)(INT32 nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds,
struct timeval *timeout)
{
UINT8 *ptr, *args;
@ -657,7 +657,7 @@ struct timeval *timeout)
}
else
{
errno = tParams.iStatus;
CC3000_EXPORT(errno) = tParams.iStatus;
return(-1);
}
}
@ -710,7 +710,7 @@ struct timeval *timeout)
//*****************************************************************************
#ifndef CC3000_TINY_DRIVER
INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval,
INT16 CC3000_EXPORT(setsockopt)(INT32 sd, INT32 level, INT32 optname, const void *optval,
socklen_t optlen)
{
INT32 ret;
@ -740,7 +740,7 @@ INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval,
}
else
{
errno = ret;
CC3000_EXPORT(errno) = ret;
return ret;
}
}
@ -793,7 +793,7 @@ INT16 setsockopt(INT32 sd, INT32 level, INT32 optname, const void *optval,
//
//*****************************************************************************
INT16 getsockopt (INT32 sd, INT32 level, INT32 optname, void *optval, socklen_t *optlen)
INT16 CC3000_EXPORT(getsockopt) (INT32 sd, INT32 level, INT32 optname, void *optval, socklen_t *optlen)
{
UINT8 *ptr, *args;
tBsdGetSockOptReturnParams tRetParams;
@ -821,8 +821,8 @@ INT16 getsockopt (INT32 sd, INT32 level, INT32 optname, void *optval, socklen_t
}
else
{
errno = tRetParams.iStatus;
return errno;
CC3000_EXPORT(errno) = tRetParams.iStatus;
return CC3000_EXPORT(errno);
}
}
@ -847,7 +847,7 @@ INT16 getsockopt (INT32 sd, INT32 level, INT32 optname, void *optval, socklen_t
//! socket the message is received from
//
//*****************************************************************************
INT16 simple_link_recv(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
static INT16 simple_link_recv(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
socklen_t *fromlen, INT32 opcode)
{
UINT8 *ptr, *args;
@ -875,7 +875,7 @@ INT16 simple_link_recv(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *fr
SimpleLinkWaitData(buf, (UINT8 *)from, (UINT8 *)fromlen);
}
errno = tSocketReadEvent.iNumberOfBytes;
CC3000_EXPORT(errno) = tSocketReadEvent.iNumberOfBytes;
return(tSocketReadEvent.iNumberOfBytes);
}
@ -902,7 +902,7 @@ INT16 simple_link_recv(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *fr
//
//*****************************************************************************
INT16 recv(INT32 sd, void *buf, INT32 len, INT32 flags)
INT16 CC3000_EXPORT(recv)(INT32 sd, void *buf, INT32 len, INT32 flags)
{
return(simple_link_recv(sd, buf, len, flags, NULL, NULL, HCI_CMND_RECV));
}
@ -935,7 +935,7 @@ INT16 recv(INT32 sd, void *buf, INT32 len, INT32 flags)
//! @Note On this version, only blocking mode is supported.
//
//*****************************************************************************
INT16 recvfrom(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
INT16 CC3000_EXPORT(recvfrom)(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
socklen_t *fromlen)
{
return(simple_link_recv(sd, buf, len, flags, from, fromlen,
@ -962,7 +962,7 @@ INT16 recvfrom(INT32 sd, void *buf, INT32 len, INT32 flags, sockaddr *from,
//! socket
//
//*****************************************************************************
INT16 simple_link_send(INT32 sd, const void *buf, INT32 len, INT32 flags,
static INT16 simple_link_send(INT32 sd, const void *buf, INT32 len, INT32 flags,
const sockaddr *to, INT32 tolen, INT32 opcode)
{
UINT8 uArgSize=0, addrlen;
@ -1066,7 +1066,7 @@ INT16 simple_link_send(INT32 sd, const void *buf, INT32 len, INT32 flags,
//
//*****************************************************************************
INT16 send(INT32 sd, const void *buf, INT32 len, INT32 flags)
INT16 CC3000_EXPORT(send)(INT32 sd, const void *buf, INT32 len, INT32 flags)
{
return(simple_link_send(sd, buf, len, flags, NULL, 0, HCI_CMND_SEND));
}
@ -1097,7 +1097,7 @@ INT16 send(INT32 sd, const void *buf, INT32 len, INT32 flags)
//
//*****************************************************************************
INT16 sendto(INT32 sd, const void *buf, INT32 len, INT32 flags, const sockaddr *to,
INT16 CC3000_EXPORT(sendto)(INT32 sd, const void *buf, INT32 len, INT32 flags, const sockaddr *to,
socklen_t tolen)
{
return(simple_link_send(sd, buf, len, flags, to, tolen, HCI_CMND_SENDTO));
@ -1120,7 +1120,7 @@ INT16 sendto(INT32 sd, const void *buf, INT32 len, INT32 flags, const sockaddr *
//
//*****************************************************************************
INT16 mdnsAdvertiser(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 deviceServiceNameLength)
INT16 CC3000_EXPORT(mdnsAdvertiser)(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 deviceServiceNameLength)
{
INT8 ret;
UINT8 *pTxBuffer, *pArgs;
@ -1161,7 +1161,7 @@ INT16 mdnsAdvertiser(UINT16 mdnsEnabled, CHAR * deviceServiceName, UINT16 device
//! @brief Returns the MSS value of a TCP connection according to the socket descriptor
//
//*****************************************************************************
UINT16 getmssvalue (INT32 sd)
UINT16 CC3000_EXPORT(getmssvalue) (INT32 sd)
{
UINT8 *ptr, *args;
UINT16 ret;

View File

@ -430,7 +430,7 @@ INT32 wlan_connect(UINT32 ulSecType, CHAR *ssid, INT32 ssid_len,
// Wait for command complete event
SimpleLinkWaitEvent(HCI_CMND_WLAN_CONNECT, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
return(ret);
}
@ -464,7 +464,7 @@ INT32 wlan_connect(CHAR *ssid, INT32 ssid_len)
// Wait for command complete event
SimpleLinkWaitEvent(HCI_CMND_WLAN_CONNECT, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
return(ret);
}
@ -494,7 +494,7 @@ INT32 wlan_disconnect()
// Wait for command complete event
SimpleLinkWaitEvent(HCI_CMND_WLAN_DISCONNECT, &ret);
errno = ret;
CC3000_EXPORT(errno) = ret;
return(ret);
}

View File

@ -33,9 +33,7 @@
#include <errno.h>
// CC3000 defines its own ENOBUFS (different to standard one!)
// CC3000 uses global variable called errno
#undef ENOBUFS
#undef errno
#include "stm32f4xx_hal.h"
#include "mpconfig.h"
@ -63,7 +61,7 @@
#include "netapp.h"
#include "patch_prog.h"
int errno; // for cc3000 driver
int CC3000_EXPORT(errno); // for cc3000 driver
STATIC mp_obj_t cc3k_socket_new(mp_uint_t family, mp_uint_t type, mp_uint_t protocol, int *_errno);
@ -122,8 +120,8 @@ STATIC mp_obj_t cc3k_socket(mp_obj_t nic, int domain, int type, int fileno, int
STATIC int cc3k_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, uint8_t *out_ip) {
uint32_t ip;
if (gethostbyname((char*)name, len, &ip) < 0) {
return errno;
if (CC3000_EXPORT(gethostbyname)((char*)name, len, &ip) < 0) {
return CC3000_EXPORT(errno);
}
if (ip == 0) {
@ -344,10 +342,10 @@ STATIC mp_obj_t cc3k_socket_new(mp_uint_t family, mp_uint_t type, mp_uint_t prot
s->base.type = (mp_obj_t)&cc3k_socket_type;
// open socket
s->fd = socket(family, type, protocol);
s->fd = CC3000_EXPORT(socket)(family, type, protocol);
if (s->fd < 0) {
m_del_obj(cc3k_socket_obj_t, s);
*_errno = errno;
*_errno = CC3000_EXPORT(errno);
return MP_OBJ_NULL;
}
@ -366,7 +364,7 @@ STATIC mp_uint_t cc3k_socket_send(mp_obj_t self_in, const void *buf, mp_uint_t s
cc3k_socket_obj_t *self = self_in;
if (cc3k_get_fd_closed_state(self->fd)) {
closesocket(self->fd);
CC3000_EXPORT(closesocket)(self->fd);
*errcode = EPIPE;
return 0;
}
@ -376,10 +374,10 @@ STATIC mp_uint_t cc3k_socket_send(mp_obj_t self_in, const void *buf, mp_uint_t s
int bytes = 0;
while (bytes < size) {
int n = MIN((size-bytes), MAX_TX_PACKET);
n = send(self->fd, buf+bytes, n, 0);
n = CC3000_EXPORT(send)(self->fd, buf+bytes, n, 0);
if (n <= 0) {
bytes = n;
*errcode = errno;
*errcode = CC3000_EXPORT(errno);
break;
}
bytes += n;
@ -392,7 +390,7 @@ STATIC mp_uint_t cc3k_socket_recv(mp_obj_t self_in, void *buf, mp_uint_t size, i
cc3k_socket_obj_t *self = self_in;
if (cc3k_get_fd_closed_state(self->fd)) {
closesocket(self->fd);
CC3000_EXPORT(closesocket)(self->fd);
return 0;
}
@ -400,12 +398,12 @@ STATIC mp_uint_t cc3k_socket_recv(mp_obj_t self_in, void *buf, mp_uint_t size, i
int bytes = 0;
while (bytes < size) {
int n = MIN((size-bytes), MAX_RX_PACKET);
n = recv(self->fd, buf+bytes, n, 0);
n = CC3000_EXPORT(recv)(self->fd, buf+bytes, n, 0);
if (n == 0) {
break;
} else if (n < 0) {
bytes = n;
*errcode = errno;
*errcode = CC3000_EXPORT(errno);
break;
}
bytes += n;
@ -435,7 +433,7 @@ STATIC mp_obj_t cc3k_socket_bind(mp_obj_t self_in, mp_obj_t addr_obj) {
}
// bind socket
if (bind(self->fd, (sockaddr*) &addr_in, sizeof(sockaddr_in)) < 0) {
if (CC3000_EXPORT(bind)(self->fd, (sockaddr*) &addr_in, sizeof(sockaddr_in)) < 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "bind failed"));
}
return mp_const_true;
@ -444,7 +442,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc3k_socket_bind_obj, cc3k_socket_bind);
STATIC mp_obj_t cc3k_socket_listen(mp_obj_t self_in, mp_obj_t backlog) {
cc3k_socket_obj_t *self = self_in;
if (listen(self->fd, mp_obj_get_int(backlog)) < 0) {
if (CC3000_EXPORT(listen)(self->fd, mp_obj_get_int(backlog)) < 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "listen failed"));
}
@ -460,7 +458,7 @@ STATIC mp_obj_t cc3k_socket_accept(mp_obj_t self_in) {
socklen_t addr_len = sizeof(sockaddr);
// accept incoming connection
if ((fd = accept(self->fd, &addr, &addr_len)) < 0) {
if ((fd = CC3000_EXPORT(accept)(self->fd, &addr, &addr_len)) < 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "accept failed"));
}
@ -512,7 +510,7 @@ STATIC mp_obj_t cc3k_socket_connect(mp_obj_t self_in, mp_obj_t addr_obj) {
//printf("doing connect: fd=%d, sockaddr=(%d, %d, %lu)\n", self->fd, addr_in.sin_family, addr_in.sin_port, addr_in.sin_addr.s_addr);
int ret = connect(self->fd, (sockaddr*)&addr_in, sizeof(sockaddr_in));
int ret = CC3000_EXPORT(connect)(self->fd, (sockaddr*)&addr_in, sizeof(sockaddr_in));
if (ret != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d] connect failed", ret));
}
@ -526,7 +524,7 @@ STATIC mp_obj_t cc3k_socket_settimeout(mp_obj_t self_in, mp_obj_t timeout) {
int optval = mp_obj_get_int(timeout);
socklen_t optlen = sizeof(optval);
if (setsockopt(self->fd, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT, &optval, optlen) != 0) {
if (CC3000_EXPORT(setsockopt)(self->fd, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT, &optval, optlen) != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "setsockopt failed"));
}
@ -545,8 +543,8 @@ STATIC mp_obj_t cc3k_socket_setblocking(mp_obj_t self_in, mp_obj_t blocking) {
optval = SOCK_ON;
}
if (setsockopt(self->fd, SOL_SOCKET, SOCKOPT_RECV_NONBLOCK, &optval, optlen) != 0 ||
setsockopt(self->fd, SOL_SOCKET, SOCKOPT_ACCEPT_NONBLOCK, &optval, optlen) != 0 ) {
if (CC3000_EXPORT(setsockopt)(self->fd, SOL_SOCKET, SOCKOPT_RECV_NONBLOCK, &optval, optlen) != 0 ||
CC3000_EXPORT(setsockopt)(self->fd, SOL_SOCKET, SOCKOPT_ACCEPT_NONBLOCK, &optval, optlen) != 0 ) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "setsockopt failed"));
}
@ -556,7 +554,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc3k_socket_setblocking_obj, cc3k_socket_setblo
STATIC mp_obj_t cc3k_socket_close(mp_obj_t self_in) {
cc3k_socket_obj_t *self = self_in;
closesocket(self->fd);
CC3000_EXPORT(closesocket)(self->fd);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(cc3k_socket_close_obj, cc3k_socket_close);
@ -614,11 +612,11 @@ mp_uint_t cc3k_ioctl(mp_obj_t self_in, mp_uint_t request, int *errcode, ...) {
timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 1;
int nfds = select(fd + 1, &rfds, &wfds, &xfds, &tv);
int nfds = CC3000_EXPORT(select)(fd + 1, &rfds, &wfds, &xfds, &tv);
// check for error
if (nfds == -1) {
*errcode = errno; // return cc3000's errno
*errcode = CC3000_EXPORT(errno);
return -1;
}