CC3000 driver update from David Sidrane (part 2 of 2)
This commit is contained in:
parent
607acec781
commit
8c094aeda8
@ -5884,4 +5884,6 @@
|
||||
(2015-10-25).
|
||||
* configs/spark: Spark configuration updated by David Sidrane
|
||||
(2013-10-25).
|
||||
* drivers/wireless/cc3000 and include/nuttx/wireless/cc3000:
|
||||
CC3000 driver update from David Sidrane (2013-10-25).
|
||||
|
||||
|
@ -54,16 +54,20 @@
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
#define DEV_FORMAT "/dev/wireless%d"
|
||||
#define DEV_NAMELEN 16
|
||||
#define QUEUE_FORMAT "wlq%d"
|
||||
#define QUEUE_NAMELEN 6
|
||||
|
||||
#define DEV_FORMAT "/dev/wireless%d" /* The device Name*/
|
||||
#define DEV_NAMELEN 17 /* The buffer size to hold formatted string*/
|
||||
|
||||
#define QUEUE_FORMAT "wlq%d" /* The Queue name */
|
||||
#define QUEUE_NAMELEN 8 /* The buffer size to hold formatted string*/
|
||||
|
||||
#define SEM_FORMAT "wls%d" /* The Spi Resume Senaphore name*/
|
||||
#define SEM_NAMELEN 8 /* The buffer size to hold formatted string*/
|
||||
|
||||
|
||||
/* IOCTL commands */
|
||||
|
||||
#define CC3000IOC_GETQUEID _WLIOC_USER(0x0001) /* arg: Address of int for number*/
|
||||
#define CC3000IOC_COMPLETE _WLIOC_USER(0x0002) /* arg: none resumes the Event WL Asynchronous events */
|
||||
#define CC3000IOC_GETQUESEMID _WLIOC_USER(0x0001) /* arg: Address of int for number*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@ -88,57 +92,54 @@ extern "C" {
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN void wlan_init( tWlanCB sWlanCB,
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CC3000_wlan_init
|
||||
*
|
||||
* @param sWlanCB Asynchronous events callback.
|
||||
* 0 no event call back.
|
||||
* -call back parameters:
|
||||
* 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event,
|
||||
* HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event,
|
||||
* HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done,
|
||||
* HCI_EVNT_WLAN_UNSOL_DHCP dhcp report,
|
||||
* HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR
|
||||
* HCI_EVNT_WLAN_KEEPALIVE keepalive.
|
||||
* 2) data: pointer to extra data that received by the event
|
||||
* (NULL no data).
|
||||
* 3) length: data length.
|
||||
* -Events with extra data:
|
||||
* HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask,
|
||||
* 4 bytes default gateway, 4 bytes DHCP server and 4 bytes
|
||||
* for DNS server.
|
||||
* HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent,
|
||||
* 4 bytes Packets received, 4 bytes Min round time,
|
||||
* 4 bytes Max round time and 4 bytes for Avg round time.
|
||||
*
|
||||
* @param sFWPatches 0 no patch or pointer to FW patches
|
||||
* @param sDriverPatches 0 no patch or pointer to driver patches
|
||||
* @param sBootLoaderPatches 0 no patch or pointer to bootloader patches
|
||||
*
|
||||
* @return none
|
||||
*
|
||||
* @sa wlan_set_event_mask , wlan_start , wlan_stop
|
||||
*
|
||||
* @brief Initialize wlan driver
|
||||
*
|
||||
* @warning This function must be called before ANY other wlan driver function
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void wlan_init( tWlanCB sWlanCB,
|
||||
tFWPatches sFWPatches,
|
||||
tDriverPatches sDriverPatches,
|
||||
tBootLoaderPatches sBootLoaderPatches,
|
||||
tWlanReadInteruptPin sReadWlanInterruptPin,
|
||||
tWlanInterruptEnable sWlanInterruptEnable,
|
||||
tWlanInterruptDisable sWlanInterruptDisable,
|
||||
tWriteWlanPin sWriteWlanPin);
|
||||
tBootLoaderPatches sBootLoaderPatches);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* CC3000_wlan_init
|
||||
*
|
||||
* @param sWlanCB Asynchronous events callback.
|
||||
* 0 no event call back.
|
||||
* -call back parameters:
|
||||
* 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event,
|
||||
* HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event,
|
||||
* HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done,
|
||||
* HCI_EVNT_WLAN_UNSOL_DHCP dhcp report,
|
||||
* HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR
|
||||
* HCI_EVNT_WLAN_KEEPALIVE keepalive.
|
||||
* 2) data: pointer to extra data that received by the event
|
||||
* (NULL no data).
|
||||
* 3) length: data length.
|
||||
* -Events with extra data:
|
||||
* HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask,
|
||||
* 4 bytes default gateway, 4 bytes DHCP server and 4 bytes
|
||||
* for DNS server.
|
||||
* HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent,
|
||||
* 4 bytes Packets received, 4 bytes Min round time,
|
||||
* 4 bytes Max round time and 4 bytes for Avg round time.
|
||||
*
|
||||
* @param sFWPatches 0 no patch or pointer to FW patches
|
||||
* @param sDriverPatches 0 no patch or pointer to driver patches
|
||||
* @param sBootLoaderPatches 0 no patch or pointer to bootloader patches
|
||||
*
|
||||
* @return none
|
||||
*
|
||||
* @sa wlan_set_event_mask , wlan_start , wlan_stop
|
||||
*
|
||||
* @brief Initialize wlan driver
|
||||
*
|
||||
* @warning This function must be called before ANY other wlan driver function
|
||||
*
|
||||
****************************************************************************/
|
||||
EXTERN void CC3000_wlan_init(tWlanCB sWlanCB,
|
||||
tFWPatches sFWPatches,
|
||||
tDriverPatches sDriverPatches,
|
||||
tBootLoaderPatches sBootLoaderPatches);
|
||||
void cc3000_wlan_init(tWlanCB sWlanCB,
|
||||
tFWPatches sFWPatches,
|
||||
tDriverPatches sDriverPatches,
|
||||
tBootLoaderPatches sBootLoaderPatches);
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -230,10 +230,6 @@ typedef struct
|
||||
tDriverPatches sDriverPatches;
|
||||
tBootLoaderPatches sBootLoaderPatches;
|
||||
tWlanCB sWlanCB;
|
||||
tWlanReadInteruptPin ReadWlanInterruptPin;
|
||||
tWlanInterruptEnable WlanInterruptEnable;
|
||||
tWlanInterruptDisable WlanInterruptDisable;
|
||||
tWriteWlanPin WriteWlanPin;
|
||||
|
||||
signed long slTransmitDataError;
|
||||
uint16_t usNumberOfFreeBuffers;
|
||||
|
@ -12,156 +12,169 @@
|
||||
*
|
||||
* 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
|
||||
* 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 _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
#define _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/wireless/cc3000/hci.h>
|
||||
#include <nuttx/wireless/cc3000/include/sys/socket.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// If building with a C++ compiler, make all of the definitions in this header
|
||||
// have a C binding.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Prototypes for the APIs.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! hci_event_handler
|
||||
//!
|
||||
//! @param pRetParams incoming data buffer
|
||||
//! @param from from information (in case of data received)
|
||||
//! @param fromlen from information length (in case of data received)
|
||||
//!
|
||||
//! @return none
|
||||
//!
|
||||
//! @brief Parse the incoming events packets and issues corresponding
|
||||
//! event handler from global array of handlers pointers
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! hci_unsol_event_handler
|
||||
//!
|
||||
//! @param event_hdr event header
|
||||
//!
|
||||
//! @return 1 if event supported and handled
|
||||
//! 0 if event is not supported
|
||||
//!
|
||||
//! @brief Handle unsolicited events
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern long hci_unsol_event_handler(char *event_hdr);
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
//! hci_unsolicited_event_handler
|
||||
//!
|
||||
//! @param None
|
||||
//!
|
||||
//! @return ESUCCESS if successful, EFAIL if an error occurred
|
||||
//!
|
||||
//! @brief Parse the incoming unsolicited event packets and issues
|
||||
//! corresponding event handler.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern long hci_unsolicited_event_handler(void);
|
||||
|
||||
#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
|
||||
#define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)\
|
||||
((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
|
||||
|
||||
#define SOCKET_STATUS_ACTIVE 0
|
||||
#define SOCKET_STATUS_INACTIVE 1
|
||||
/* Init socket_active_status = 'all ones': init all sockets with SOCKET_STATUS_INACTIVE.
|
||||
Will be changed by 'set_socket_active_status' upon 'connect' and 'accept' calls */
|
||||
|
||||
/* Init socket_active_status = 'all ones': init all sockets with
|
||||
* SOCKET_STATUS_INACTIVE. Will be changed by 'set_socket_active_status' upon
|
||||
* 'connect' and 'accept' calls
|
||||
*/
|
||||
|
||||
#define SOCKET_STATUS_INIT_VAL 0xFFFF
|
||||
#define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7))
|
||||
#define M_IS_VALID_STATUS(status) (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
|
||||
#define M_IS_VALID_STATUS(status) \
|
||||
(((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
|
||||
|
||||
extern unsigned long socket_active_status;
|
||||
#define BSD_RECV_FROM_FROMLEN_OFFSET (4)
|
||||
#define BSD_RECV_FROM_FROM_OFFSET (16)
|
||||
|
||||
extern void set_socket_active_status(long Sd, long Status);
|
||||
extern long get_socket_active_status(long Sd);
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct _bsd_accept_return_t
|
||||
{
|
||||
long iSocketDescriptor;
|
||||
long iStatus;
|
||||
sockaddr tSocketAddress;
|
||||
|
||||
long iSocketDescriptor;
|
||||
long iStatus;
|
||||
struct sockaddr tSocketAddress;
|
||||
} tBsdReturnParams;
|
||||
|
||||
|
||||
typedef struct _bsd_read_return_t
|
||||
{
|
||||
long iSocketDescriptor;
|
||||
long iNumberOfBytes;
|
||||
unsigned long uiFlags;
|
||||
long iSocketDescriptor;
|
||||
long iNumberOfBytes;
|
||||
unsigned long uiFlags;
|
||||
} tBsdReadReturnParams;
|
||||
|
||||
#define BSD_RECV_FROM_FROMLEN_OFFSET (4)
|
||||
#define BSD_RECV_FROM_FROM_OFFSET (16)
|
||||
|
||||
|
||||
typedef struct _bsd_select_return_t
|
||||
{
|
||||
long iStatus;
|
||||
unsigned long uiRdfd;
|
||||
unsigned long uiWrfd;
|
||||
unsigned long uiExfd;
|
||||
long iStatus;
|
||||
unsigned long uiRdfd;
|
||||
unsigned long uiWrfd;
|
||||
unsigned long uiExfd;
|
||||
} tBsdSelectRecvParams;
|
||||
|
||||
|
||||
typedef struct _bsd_getsockopt_return_t
|
||||
{
|
||||
uint8_t ucOptValue[4];
|
||||
char iStatus;
|
||||
uint8_t ucOptValue[4];
|
||||
char iStatus;
|
||||
} tBsdGetSockOptReturnParams;
|
||||
|
||||
typedef struct _bsd_gethostbyname_return_t
|
||||
{
|
||||
long retVal;
|
||||
long outputAddress;
|
||||
long retVal;
|
||||
long outputAddress;
|
||||
} tBsdGethostbynameParams;
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Mark the end of the C bindings section for C++ compilers.
|
||||
//
|
||||
//*****************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern unsigned long socket_active_status;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: hci_event_handler
|
||||
*
|
||||
* Description:
|
||||
* Parse the incoming events packets and issues corresponding event
|
||||
* handler from global array of handlers pointers
|
||||
*
|
||||
* Input Parameters:
|
||||
* pRetParams incoming data buffer
|
||||
* from from information (in case of data received)
|
||||
* fromlen from information length (in case of data received)
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t *hci_event_handler(void *pRetParams, uint8_t *from, uint8_t *fromlen);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: hci_unsol_event_handler
|
||||
*
|
||||
* Description:
|
||||
* Handle unsolicited events
|
||||
*
|
||||
* Input Parameters:
|
||||
* event_hdr event header
|
||||
*
|
||||
* Returned Values:
|
||||
* 1 if event supported and handled; 0 if event is not supported
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
long hci_unsol_event_handler(char *event_hdr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: hci_unsolicited_event_handler
|
||||
*
|
||||
* Description:
|
||||
* Parse the incoming unsolicited event packets and issues corresponding
|
||||
* event handler.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Values:
|
||||
* ESUCCESS if successful, EFAIL if an error occurred
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
long hci_unsolicited_event_handler(void);
|
||||
|
||||
void set_socket_active_status(long Sd, long Status);
|
||||
long get_socket_active_status(long Sd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
|
||||
#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_EVENT_HANDLER_H
|
||||
|
@ -141,7 +141,7 @@ struct cc3000_config_s
|
||||
void (*irq_enable)(FAR struct cc3000_config_s *state, bool enable);
|
||||
void (*irq_clear)(FAR struct cc3000_config_s *state);
|
||||
void (*power_enable)(FAR struct cc3000_config_s *state,bool enable);
|
||||
void (*chip_select)(FAR struct cc3000_config_s *state,bool enable);
|
||||
void (*chip_chip_select)(FAR struct cc3000_config_s *state,bool enable);
|
||||
bool (*irq_read)(FAR struct cc3000_config_s *state);
|
||||
bool (*probe)(FAR struct cc3000_config_s *state, int n, bool s);
|
||||
};
|
||||
|
@ -35,171 +35,37 @@
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_SYS_SOCKET_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_CC3000_INCLUDE_SYS_SOCKET_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
/*****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
#define CC3000_SOCKETS /* Indicate using CC3000 sockets */
|
||||
#define CC3000_SOCKETS_ST /* Indicate single threaded version */
|
||||
|
||||
#define HOSTNAME_MAX_LENGTH (230) /* 230 bytes + header shouldn't exceed 8
|
||||
* bit value */
|
||||
|
||||
/*--------- Address Families --------*/
|
||||
|
||||
#define AF_INET 2
|
||||
#define AF_INET6 23
|
||||
|
||||
#define PF_INET AF_INET /* IPv4 Internet protocols */
|
||||
#define PF_INET6 AF_INET6 /* IPv6 Internet protocols */
|
||||
|
||||
|
||||
/*------------ Socket Types ------------*/
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
#define SOCK_RAW 3 /* Raw sockets allow new IPv4
|
||||
* protocols to be implemented in
|
||||
* user space. A raw socket receives
|
||||
* or sends the raw datagram not
|
||||
* including link level headers */
|
||||
#define SOCK_RDM 4
|
||||
#define SOCK_SEQPACKET 5
|
||||
|
||||
/*----------- Socket Protocol ----------*/
|
||||
|
||||
#define IPPROTO_IP 0 /* Dummy for IP */
|
||||
#define IPPROTO_ICMP 1 /* Control message protocol */
|
||||
#define IPPROTO_IPV4 IPPROTO_IP /* IP inside IP */
|
||||
#define IPPROTO_TCP 6 /* TCP */
|
||||
#define IPPROTO_UDP 17 /* User datagram protocol */
|
||||
#define IPPROTO_IPV6 41 /* IPv6 in IPv6 */
|
||||
#define IPPROTO_NONE 59 /* No next header */
|
||||
#define IPPROTO_RAW 255 /* Raw IP packet */
|
||||
#define IPPROTO_MAX 256
|
||||
|
||||
/*----------- Socket retunr codes -----------*/
|
||||
|
||||
#define SOC_ERROR (-1) /* Error */
|
||||
#define SOC_IN_PROGRESS (-2) /* Socket in progress */
|
||||
|
||||
/*----------- Socket Options -----------*/
|
||||
#define SOL_SOCKET 0xffff /* Socket level */
|
||||
#define SOCKOPT_RECV_NONBLOCK 0 /* recv non block mode, set SOCK_ON or
|
||||
* SOCK_OFF (default block mode) */
|
||||
#define SOCKOPT_RECV_TIMEOUT 1 /* optname to configure recv and recvfromtimeout */
|
||||
#define SOCKOPT_ACCEPT_NONBLOCK 2 /* accept non block mode, set SOCK_ON or SOCK_OFF
|
||||
* (default block mode) */
|
||||
#define SOCK_ON 0 /* socket non-blocking mode is enabled */
|
||||
#define SOCK_OFF 1 /* socket blocking mode is enabled */
|
||||
|
||||
#define TCP_NODELAY 0x0001
|
||||
#define TCP_BSDURGENT 0x7000
|
||||
|
||||
#define MAX_PACKET_SIZE 1500
|
||||
#define MAX_LISTEN_QUEUE 4
|
||||
|
||||
#define IOCTL_SOCKET_EVENTMASK
|
||||
|
||||
#define __FD_SETSIZE 32
|
||||
|
||||
#define ASIC_ADDR_LEN 8
|
||||
|
||||
#define NO_QUERY_RECIVED -3
|
||||
|
||||
/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
|
||||
|
||||
#define __NFDBITS (8 * sizeof (__fd_mask))
|
||||
#define __FDELT(d) ((d) / __NFDBITS)
|
||||
#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
|
||||
|
||||
#define __FDS_BITS(set) ((set)->fds_bits)
|
||||
|
||||
/* We don't use `memset' because this would require a prototype and
|
||||
* the array isn't too big.
|
||||
*/
|
||||
|
||||
#define __FD_ZERO(set) \
|
||||
do { \
|
||||
unsigned int __i; \
|
||||
TICC3000fd_set *__arr = (set); \
|
||||
for (__i = 0; __i < sizeof (TICC3000fd_set) / sizeof (__fd_mask); ++__i) \
|
||||
__FDS_BITS (__arr)[__i] = 0; \
|
||||
} while (0)
|
||||
#define __FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
|
||||
#define __FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
|
||||
#define __FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
|
||||
|
||||
/* Access macros for 'TICC3000fd_set' */
|
||||
|
||||
#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
|
||||
#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
|
||||
#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
|
||||
#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
|
||||
|
||||
/* Use in case of Big Endian only */
|
||||
|
||||
#define htonl(A) ((((unsigned long)(A) & 0xff000000) >> 24) | \
|
||||
(((unsigned long)(A) & 0x00ff0000) >> 8) | \
|
||||
(((unsigned long)(A) & 0x0000ff00) << 8) | \
|
||||
(((unsigned long)(A) & 0x000000ff) << 24))
|
||||
|
||||
#define ntohl htonl
|
||||
|
||||
/* Use in case of Big Endian only */
|
||||
#define htons(A) ((((unsigned long)(A) & 0xff00) >> 8) | \
|
||||
(((unsigned long)(A) & 0x00ff) << 8))
|
||||
|
||||
|
||||
#define ntohs htons
|
||||
|
||||
/* mDNS port - 5353 mDNS multicast address - 224.0.0.251 */
|
||||
|
||||
#define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \
|
||||
sockaddr.sa_data[1] = 0xe9; \
|
||||
sockaddr.sa_data[2] = 0xe0; \
|
||||
sockaddr.sa_data[3] = 0x0; \
|
||||
sockaddr.sa_data[4] = 0x0; \
|
||||
sockaddr.sa_data[5] = 0xfb;
|
||||
#define socket(a,t,p) cc3000_socket(a,t,p)
|
||||
#define closesocket(s) cc3000_closesocket(s)
|
||||
#define bind(s,a,l) cc3000_bind(s,a,l)
|
||||
#define connect(s,a,l) cc3000_connect(s,a,l)
|
||||
#define listen(s,b) cc3000_listen(s,b)
|
||||
#define accept(s,a,l) cc3000_accept(s,a,l)
|
||||
#define send(s,b,l,f) cc3000_send(s,b,l,f)
|
||||
#define sendto(s,b,l,f,a,n) cc3000_sendto(s,b,l,f,a,n)
|
||||
#define recv(s,b,l,f) cc3000_recv(s,b,l,f)
|
||||
#define recvfrom(s,b,l,f,a,n) cc3000_recvfrom(s,b,l,f,a,n)
|
||||
#define setsockopt(s,l,o,v,n) cc3000_setsockopt(s,l,o,v,n)
|
||||
#define getsockopt(s,l,o,v,n) cc3000_getsockopt(s,l,o,v,n)
|
||||
#define gethostbyname(h,l,i) cc3000_gethostbyname(h,l,i)
|
||||
#define mdnsadvertiser(e,n,l) cc3000_mdnsadvertiser(e,n,l)
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Types
|
||||
*****************************************************************************/
|
||||
|
||||
typedef struct _in_addr_t
|
||||
{
|
||||
unsigned long s_addr; /* load with inet_aton() */
|
||||
} in_addr;
|
||||
|
||||
typedef struct sockaddr
|
||||
{
|
||||
uint16_t sa_family;
|
||||
uint8_t sa_data[14];
|
||||
} sockaddr;
|
||||
|
||||
typedef struct _sockaddr_in_t
|
||||
{
|
||||
int16_t sin_family; /* e.g. AF_INET */
|
||||
uint16_t sin_port; /* e.g. htons(3490) */
|
||||
in_addr sin_addr; /* see struct in_addr, below */
|
||||
char sin_zero[8]; /* zero this if you want to */
|
||||
} sockaddr_in;
|
||||
|
||||
#if 0 /* acassis: conflict with previous declaration on nuttx */
|
||||
typedef unsigned long socklen_t;
|
||||
#endif
|
||||
|
||||
/* The fd_set member is required to be an array of longs. */
|
||||
|
||||
typedef long int __fd_mask;
|
||||
|
||||
/* fd_set for select and pselect. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
|
||||
} TICC3000fd_set;
|
||||
|
||||
/*****************************************************************************
|
||||
* Public Data
|
||||
*****************************************************************************/
|
||||
@ -235,7 +101,7 @@ extern "C" {
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int socket(long domain, long type, long protocol);
|
||||
int socket(int domain, int type, int protocol);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: closesocket
|
||||
@ -244,14 +110,14 @@ int socket(long domain, long type, long protocol);
|
||||
* The socket function closes a created socket.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle.
|
||||
* sockfd socket handle.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
long closesocket(long sd);
|
||||
int closesocket(int sockfd);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: accept
|
||||
@ -276,7 +142,7 @@ long closesocket(long sd);
|
||||
* length (in bytes) of the address returned.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket descriptor (handle)
|
||||
* sockfd socket descriptor (handle)
|
||||
* addr the argument 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.
|
||||
@ -298,7 +164,7 @@ long closesocket(long sd);
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
long accept(long sd, sockaddr *addr, socklen_t *addrlen);
|
||||
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: bind
|
||||
@ -313,7 +179,7 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen);
|
||||
* socket may receive connections.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket descriptor (handle)
|
||||
* sockfd socket descriptor (handle)
|
||||
* addr specifies the destination address. On this version
|
||||
* only AF_INET is supported.
|
||||
* addrlen contains the size of the structure pointed to by addr.
|
||||
@ -323,7 +189,7 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen);
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
long bind(long sd, const sockaddr *addr, long addrlen);
|
||||
int bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: listen
|
||||
@ -340,17 +206,303 @@ long bind(long sd, const sockaddr *addr, long addrlen);
|
||||
* NOTE: On this version, backlog is not supported
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket descriptor (handle)
|
||||
* sockfd socket descriptor (handle)
|
||||
* backlog specifies the listen queue depth. On this version
|
||||
* backlog is not supported.
|
||||
* backlog is not supported.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
long listen(long sd, long backlog);
|
||||
int listen(int sockfd, int backlog);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: connect
|
||||
*
|
||||
* Decription:
|
||||
* 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. Note that the function implements only blocking behavior
|
||||
* thus the caller will be waiting either for the connection
|
||||
* establishment or for the connection establishment failure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket descriptor (handle)
|
||||
* addr specifies the destination addr. On this version
|
||||
* only AF_INET is supported.
|
||||
* addrlen contains the size of the structure pointed to by addr
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: select
|
||||
*
|
||||
* Decription:
|
||||
* 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
|
||||
*
|
||||
* NOTE: If the timeout value set to less than 5ms it will automatically set
|
||||
* to 5ms to prevent overload of the system
|
||||
*
|
||||
* Input Parameters:
|
||||
* nfds the highest-numbered file descriptor in any of the
|
||||
* three sets, plus 1.
|
||||
* readfds socket descriptors list for read monitoring
|
||||
* writefds socket descriptors list for write monitoring
|
||||
* exceptfds socket descriptors list for exception monitoring
|
||||
* timeout is an upper bound on the amount of time elapsed
|
||||
* before select() returns. Null means infinity
|
||||
* timeout. The minimum timeout is 5 milliseconds,
|
||||
* less than 5 milliseconds will be set
|
||||
* automatically to 5 milliseconds.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, select() returns the number of file descriptors
|
||||
* contained in the three returned descriptor sets (that is, the
|
||||
* total number of bits that are set in readfds, writefds,
|
||||
* exceptfds) which may be zero if the timeout expires before
|
||||
* anything interesting happens.
|
||||
* On error, -1 is returned.
|
||||
* *readfds - return the sockets on which Read request will
|
||||
* return without delay with valid data.
|
||||
* *writefds - return the sockets on which Write request
|
||||
* will return without delay.
|
||||
* *exceptfds - return the sockets which closed recently.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds,
|
||||
struct timeval *timeout);
|
||||
|
||||
#ifndef CC3000_TINY_DRIVER
|
||||
/*****************************************************************************
|
||||
* Name: setsockopt
|
||||
*
|
||||
* Decription:
|
||||
* 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 protocol 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 value and value_len are used to access value -
|
||||
* use for setsockopt(). For getsockopt() they identify a buffer
|
||||
* in which the value for the requested option(s) are to
|
||||
* be returned. For getsockopt(), value_len 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.
|
||||
*
|
||||
* NOTE: On this version the following two socket options are enabled:
|
||||
* The only protocol level supported in this version
|
||||
* is SOL_SOCKET (level).
|
||||
* 1. SOCKOPT_RECV_TIMEOUT (option)
|
||||
* SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
|
||||
* in milliseconds.
|
||||
* In that case value should be pointer to unsigned long.
|
||||
* 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on
|
||||
* or off.
|
||||
* In that case value should be SOCK_ON or SOCK_OFF (value).
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket handle
|
||||
* level defines the protocol level for this option
|
||||
* option defines the option name to Interrogate
|
||||
* value specifies a value for the option
|
||||
* value_len specifies the length of the option value
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int setsockopt(int sockfd, int level, int option, FAR const void *value, socklen_t value_len);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: getsockopt
|
||||
*
|
||||
* Decription:
|
||||
* 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 protocol 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 value and value_len are used to access value -
|
||||
* use for setsockopt(). For getsockopt() they identify a buffer
|
||||
* in which the value for the requested option(s) are to
|
||||
* be returned. For getsockopt(), value_len 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.
|
||||
*
|
||||
* NOTE: On this version the following two socket options are enabled:
|
||||
* The only protocol level supported in this version
|
||||
* is SOL_SOCKET (level).
|
||||
*
|
||||
* 1. SOCKOPT_RECV_TIMEOUT (option)
|
||||
* SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
|
||||
* in milliseconds. In that case value should be pointer to unsigned
|
||||
* long.
|
||||
* 2. SOCKOPT_NONBLOCK (option). sets the socket non-blocking mode on
|
||||
* or off. In that case value should be SOCK_ON or SOCK_OFF (value).
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket handle
|
||||
* level defines the protocol level for this option
|
||||
* option defines the option name to Interrogate
|
||||
* value specifies a value for the option
|
||||
* value_len specifies the length of the option value
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int getsockopt(int sockfd, int level, int option, FAR void *value, FAR socklen_t *value_len);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: recv
|
||||
*
|
||||
* Decription:
|
||||
* function receives a message from a connection-mode socket
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket handle
|
||||
* buf Points to the buffer where the message should be stored
|
||||
* len Specifies the length in bytes of the buffer pointed to
|
||||
* by the buffer argument.
|
||||
* flags Specifies the type of message reception.
|
||||
* On this version, this parameter is not supported.
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes received, or -1 if an error
|
||||
* occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ssize_t recv(int sockfd, FAR void *buf, size_t len, int flags);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: recvfrom
|
||||
*
|
||||
* Decription:
|
||||
* read data from socket
|
||||
* function receives a message from a connection-mode or
|
||||
* connectionless-mode socket. Note that raw sockets are not
|
||||
* supported.
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket handle
|
||||
* buf Points to the buffer where the message should be stored
|
||||
* len Specifies the length in bytes of the buffer pointed to
|
||||
* by the buffer argument.
|
||||
* flags Specifies the type of message reception.
|
||||
* On this version, this parameter is not supported.
|
||||
* from pointer to an address structure indicating the source
|
||||
* address: sockaddr. On this version only AF_INET is
|
||||
* supported.
|
||||
* fromlen source address tructure size
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes received, or -1 if an error
|
||||
* occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags,
|
||||
FAR struct sockaddr *from, FAR socklen_t *fromlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: send
|
||||
*
|
||||
* Decription:
|
||||
* Write data to TCP socket
|
||||
* This function is used to transmit a message to another
|
||||
* socket.
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket handle
|
||||
* buf Points to a buffer containing the message to be sent
|
||||
* len message size in bytes
|
||||
* flags On this version, this parameter is not supported
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes transmitted, or -1 if an
|
||||
* error occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: sendto
|
||||
*
|
||||
* Decription:
|
||||
* Write data to TCP socket
|
||||
* This function is used to transmit a message to another
|
||||
* socket.
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sockfd socket handle
|
||||
* buf Points to a buffer containing the message to be sent
|
||||
* len message size in bytes
|
||||
* flags On this version, this parameter is not supported
|
||||
* to pointer to an address structure indicating the destination
|
||||
* address: sockaddr. On this version only AF_INET is
|
||||
* supported.
|
||||
* tolen destination address structure size
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes transmitted, or -1 if an
|
||||
* error occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
|
||||
FAR const struct sockaddr *to, socklen_t tolen);
|
||||
|
||||
#ifndef CC3000_TINY_DRIVER
|
||||
/*****************************************************************************
|
||||
* Name: gethostbyname
|
||||
*
|
||||
@ -374,297 +526,9 @@ long listen(long sd, long backlog);
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef CC3000_TINY_DRIVER
|
||||
int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_addr);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: connect
|
||||
*
|
||||
* Decription:
|
||||
* 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. Note that the function implements only blocking behavior
|
||||
* thus the caller will be waiting either for the connection
|
||||
* establishment or for the connection establishment failure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket descriptor (handle)
|
||||
* addr specifies the destination addr. On this version
|
||||
* only AF_INET is supported.
|
||||
* addrlen contains the size of the structure pointed to by addr
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
long connect(long sd, const sockaddr *addr, long addrlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: select
|
||||
*
|
||||
* Decription:
|
||||
* 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
|
||||
*
|
||||
* NOTE: If the timeout value set to less than 5ms it will automatically set
|
||||
* to 5ms to prevent overload of the system
|
||||
*
|
||||
* Input Parameters:
|
||||
* nfds the highest-numbered file descriptor in any of the
|
||||
* three sets, plus 1.
|
||||
* writesds socket descriptors list for write monitoring
|
||||
* readsds socket descriptors list for read monitoring
|
||||
* exceptsds socket descriptors list for exception monitoring
|
||||
* timeout is an upper bound on the amount of time elapsed
|
||||
* before select() returns. Null means infinity
|
||||
* timeout. The minimum timeout is 5 milliseconds,
|
||||
* less than 5 milliseconds will be set
|
||||
* automatically to 5 milliseconds.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, select() returns the number of file descriptors
|
||||
* contained in the three returned descriptor sets (that is, the
|
||||
* total number of bits that are set in readfds, writefds,
|
||||
* exceptfds) which may be zero if the timeout expires before
|
||||
* anything interesting happens.
|
||||
* On error, -1 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
|
||||
* will return without delay.
|
||||
* *exceptsds - return the sockets which closed recently.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
|
||||
TICC3000fd_set *exceptsds, struct timeval *timeout);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: setsockopt
|
||||
*
|
||||
* Decription:
|
||||
* 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 protocol 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 -
|
||||
* use 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.
|
||||
*
|
||||
* NOTE: On this version the following two socket options are enabled:
|
||||
* The only protocol level supported in this version
|
||||
* is SOL_SOCKET (level).
|
||||
* 1. SOCKOPT_RECV_TIMEOUT (optname)
|
||||
* SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
|
||||
* in milliseconds.
|
||||
* In that case optval should be pointer to unsigned long.
|
||||
* 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
|
||||
* or off.
|
||||
* In that case optval should be SOCK_ON or SOCK_OFF (optval).
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* level defines the protocol level for this option
|
||||
* optname defines the option name to Interrogate
|
||||
* optval specifies a value for the option
|
||||
* optlen specifies the length of the option value
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef CC3000_TINY_DRIVER
|
||||
int setsockopt(long sd, long level, long optname, const void *optval,
|
||||
socklen_t optlen);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: getsockopt
|
||||
*
|
||||
* Decription:
|
||||
* 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 protocol 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 -
|
||||
* use 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.
|
||||
*
|
||||
* NOTE: On this version the following two socket options are enabled:
|
||||
* The only protocol level supported in this version
|
||||
* is SOL_SOCKET (level).
|
||||
* 1. SOCKOPT_RECV_TIMEOUT (optname)
|
||||
* SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
|
||||
* in milliseconds.
|
||||
* In that case optval should be pointer to unsigned long.
|
||||
* 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
|
||||
* or off.
|
||||
* In that case optval should be SOCK_ON or SOCK_OFF (optval).
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* level defines the protocol level for this option
|
||||
* optname defines the option name to Interrogate
|
||||
* optval specifies a value for the option
|
||||
* optlen specifies the length of the option value
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, zero is returned. On error, -1 is returned
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int getsockopt(long sd, long level, long optname, void *optval,
|
||||
socklen_t *optlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: recv
|
||||
*
|
||||
* Decription:
|
||||
* function receives a message from a connection-mode socket
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* buf Points to the buffer where the message should be stored
|
||||
* len Specifies the length in bytes of the buffer pointed to
|
||||
* by the buffer argument.
|
||||
* flags Specifies the type of message reception.
|
||||
* On this version, this parameter is not supported.
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes received, or -1 if an error
|
||||
* occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int recv(long sd, void *buf, long len, long flags);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: recvfrom
|
||||
*
|
||||
* Decription:
|
||||
* read data from socket
|
||||
* function receives a message from a connection-mode or
|
||||
* connectionless-mode socket. Note that raw sockets are not
|
||||
* supported.
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* buf Points to the buffer where the message should be stored
|
||||
* len Specifies the length in bytes of the buffer pointed to
|
||||
* by the buffer argument.
|
||||
* flags Specifies the type of message reception.
|
||||
* On this version, this parameter is not supported.
|
||||
* from pointer to an address structure indicating the source
|
||||
* address: sockaddr. On this version only AF_INET is
|
||||
* supported.
|
||||
* fromlen source address tructure size
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes received, or -1 if an error
|
||||
* occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
|
||||
socklen_t *fromlen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: send
|
||||
*
|
||||
* Decription:
|
||||
* Write data to TCP socket
|
||||
* This function is used to transmit a message to another
|
||||
* socket.
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* buf Points to a buffer containing the message to be sent
|
||||
* len message size in bytes
|
||||
* flags On this version, this parameter is not supported
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes transmitted, or -1 if an
|
||||
* error occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int send(long sd, const void *buf, long len, long flags);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: sendto
|
||||
*
|
||||
* Decription:
|
||||
* Write data to TCP socket
|
||||
* This function is used to transmit a message to another
|
||||
* socket.
|
||||
*
|
||||
* NOTE: On this version, only blocking mode is supported.
|
||||
*
|
||||
* Input Parameters:
|
||||
* sd socket handle
|
||||
* buf Points to a buffer containing the message to be sent
|
||||
* len message size in bytes
|
||||
* flags On this version, this parameter is not supported
|
||||
* to pointer to an address structure indicating the destination
|
||||
* address: sockaddr. On this version only AF_INET is
|
||||
* supported.
|
||||
* tolen destination address structure size
|
||||
*
|
||||
* Returned Value:
|
||||
* Return the number of bytes transmitted, or -1 if an
|
||||
* error occurred
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
|
||||
socklen_t tolen);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: mdnsAdvertiser
|
||||
*
|
||||
@ -683,8 +547,9 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int mdnsAdvertiser(uint16_t mdnsEnabled, char * deviceServiceName,
|
||||
int mdnsadvertiser(uint16_t mdnsEnabled, char *deviceServiceName,
|
||||
uint16_t deviceServiceNameLength);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
@ -13,29 +13,29 @@
|
||||
*
|
||||
* 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
|
||||
* 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 _INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
|
||||
#define _INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
|
||||
#ifndef __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
|
||||
#define __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
|
||||
|
||||
/*****************************************************************************
|
||||
* Included Files
|
||||
@ -112,12 +112,7 @@ extern "C" {
|
||||
|
||||
void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
|
||||
tDriverPatches sDriverPatches,
|
||||
tBootLoaderPatches sBootLoaderPatches,
|
||||
tWlanReadInteruptPin sReadWlanInterruptPin,
|
||||
tWlanInterruptEnable sWlanInterruptEnable,
|
||||
tWlanInterruptDisable sWlanInterruptDisable,
|
||||
tWriteWlanPin sWriteWlanPin);
|
||||
|
||||
tBootLoaderPatches sBootLoaderPatches);
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: wlan_start
|
||||
@ -514,4 +509,4 @@ long wlan_smart_config_process(void);
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
|
||||
#endif // __INCLUDE_NUTTX_WIRELESS_CC3000_WLAN_H
|
||||
|
Loading…
Reference in New Issue
Block a user