Synergy Software Package User's Manual

RTOS-integrated SF Socket WIFI Framework Interface. More...

Data Structures

struct  in_addr
 
struct  sockaddr
 
struct  sockaddr_in
 
struct  sf_socket_ctrl_t
 
struct  sf_socket_cfg_t
 
struct  sf_socket_api_t
 
struct  sf_socket_instance_t
 

Macros

#define SF_SOCKET_WIFI_API_VER_MAJOR   (2U)
 
#define SF_SOCKET_WIFI_API_VER_MINOR   (0U)
 
#define SF_SOCKET_WIFI_NO_OF_BIT_IN_BYTE   (8U)
 

Typedefs

typedef int32_t socklen_t
 

Functions

int socket (int domain, int type, int protocol)
 This creates socket for communication. More...
 
int close (int sockfd)
 This closes socket. More...
 
int bind (int sockfd, const struct sockaddr *p_local_sock_addr, socklen_t addrlen)
 This binds socket to IP address. More...
 
int listen (int sockfd, int backlog)
 This listens for connection on socket. More...
 
int connect (int sockfd, const struct sockaddr *p_serv_addr, socklen_t addrlen)
 This connects with remote socket(stream socket). More...
 
int accept (int sockfd, struct sockaddr *p_cliaddr, socklen_t *p_addrlen)
 This accepts connection from remote socket. More...
 
ssize_t send (int sockfd, const void *p_buf, size_t length, int flags)
 This sends data over STREAM socket. More...
 
ssize_t recv (int sockfd, void *p_buf, size_t length, int flags)
 This receives data over STREAM socket. More...
 
ssize_t sendto (int sockfd, const void *p_buf, size_t length, int flags, const struct sockaddr *p_dest_addr, socklen_t addrlen)
 This sends data over DGRAM socket. More...
 
ssize_t recvfrom (int sockfd, void *p_buf, size_t length, int flags, struct sockaddr *p_src_addr, socklen_t *p_addrlen)
 This receives data over DGRAM socket. More...
 
int setsockopt (int sockfd, int level, int optname, const void *p_optval, socklen_t optlen)
 This updates socket specific options. Quectel CATM1 supports following socket options SO_SNDBUF: Transmission packet size TCP_MAX_RETRIES: Maximum Number of retransmission TCP_MAX_RTO: Maximum interval time of TCP retransmission. More...
 
int getsockopt (int sockfd, int level, int optname, void *p_optval, socklen_t *p_optlen)
 This reads socket specific options. Quectel CATM1 supports following socket options SO_SNDBUF: Transmission packet size TCP_MAX_RETRIES: Maximum Number of retransmission TCP_MAX_RTO: Maximum interval time of TCP retransmission. More...
 
int select (int nfds, fd_set *p_readfds, fd_set *p_writefds, fd_set *p_exceptfds, struct timeval *p_timeout)
 This waits for any activity on socket. More...
 

Detailed Description

RTOS-integrated SF Socket WIFI Framework Interface.

Summary

This SSP Interface provides access OnChip stack BSD Socket API.

Macro Definition Documentation

◆ SF_SOCKET_WIFI_API_VER_MAJOR

#define SF_SOCKET_WIFI_API_VER_MAJOR   (2U)

Major Version of the API defined in this file

◆ SF_SOCKET_WIFI_API_VER_MINOR

#define SF_SOCKET_WIFI_API_VER_MINOR   (0U)

Minor Version of the API defined in this file

◆ SF_SOCKET_WIFI_NO_OF_BIT_IN_BYTE

#define SF_SOCKET_WIFI_NO_OF_BIT_IN_BYTE   (8U)

SF WiFi Socket Number of Bits in a Byte

Typedef Documentation

◆ socklen_t

typedef int32_t socklen_t

Socket Structure Length

Function Documentation

◆ accept()

int accept ( int  sockfd,
struct sockaddr p_cliaddr,
socklen_t p_addrlen 
)

This accepts connection from remote socket.

Accept connection request from remote.

Parameters
[in]sockfdLocal socket
[out]p_cliaddrPointer to remote socket address which trying to connect
[out]p_addrlenPointer to address length of client socket address

Implements accept This function accepts connection from remote socket. This API is used only with socket type STREAM. The call is blocked if no connection is present or the socket is blocking.

Parameters
[in]sockfdSocket File Descriptor
[out]p_cliaddrRemote machine Network address
[out]p_addrlenSize of Socket address structure
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Error accepting the connection
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSConnection is received successfully.

Implements accept This function accepts connection from remote socket. This API is used only with socket type STREAM. The call is blocked if no connection is present or the socket is blocking.

Parameters
[in]sockfdSocket File Descriptor
[out]p_cliaddrRemote machine Network address (Can be NULL)
[out]p_addrlenSize of Socket address structure(Can be NULL)
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDError accepting the connection or invalid input parameters
Returns
Otherwise Connection is received successfully.

◆ bind()

int bind ( int  sockfd,
const struct sockaddr p_local_sock_addr,
socklen_t  addrlen 
)

This binds socket to IP address.

Bind socket to interface which is identified by IP address

Parameters
[in]sockfdLocal socket
[in]p_local_sock_addrPointer to local socket address
[in]addrlenSize of sock address structure

Implements bind This function binds socket to given IP address and port.

Parameters
sockfdSocket file descriptor
p_local_sock_addrSocket address structure
addrlenSize of Socket address structure
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDBinding socket failed
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSSocket is bound successfully.

Implements bind This function binds socket to given IP address and port.

Parameters
sockfdSocket file descriptor
p_local_sock_addrSocket address structure
addrlenSize of Socket address structure
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDBinding socket failed or invalid input parameters
Returns
Otherwise Socket is bound successfully.

◆ close()

int close ( int  sockfd)

This closes socket.

API which closes socket

Parameters
[in]sockfdLocal socket

Implements close Close opened socket

Parameters
[in]sockfdSocket file descriptor
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Closing socket failed
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSSocket is closed successfully.

Implements close Close opened socket

Parameters
[in]sockfdSocket file descriptor
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDClosing socket failed or invalid input parameters
Returns
Otherwise Socket is closed successfully.

◆ connect()

int connect ( int  sockfd,
const struct sockaddr p_serv_addr,
socklen_t  addrlen 
)

This connects with remote socket(stream socket).

Establish TCP connection with remote socket

Parameters
[in]sockfdLocal socket
[in]p_serv_addrPointer to remote socket address
[in]addrlenSize of sock address structure

Implements connect This function connects local socket with remote socket. The call is blocked until a connection is established or error is returned.

Parameters
[in]sockfdSocket File Descriptor
[in]p_serv_addrRemote machine Network address
[in]addrlenSize of Socket address structure
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Error occurred.
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSSocket is connected successfully.

Implements connect This function connects local socket with remote socket. The call is blocked until a connection is established or error is returned.

Parameters
[in]sockfdSocket File Descriptor
[in]p_serv_addrRemote machine Network address
[in]addrlenSize of Socket address structure
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDError occurred or invalid input parameters
Returns
Otherwise Socket is connected successfully.

◆ getsockopt()

int getsockopt ( int  sockfd,
int  level,
int  optname,
void *  p_optval,
socklen_t p_optlen 
)

This reads socket specific options. Quectel CATM1 supports following socket options SO_SNDBUF: Transmission packet size TCP_MAX_RETRIES: Maximum Number of retransmission TCP_MAX_RTO: Maximum interval time of TCP retransmission.

Get Socket options.

Parameters
[in]sockfdLocal socket
[in]levelSockets API level
[in]optnameOption to be get
[out]p_optvalOption value to be get
[in]p_optlenLength of option value

Implements getsockopt This gets options for an existing socket.

Parameters
[in]sockfdSocket file descriptor
[in]levelLevel
[in]optnameSocket option name
[out]p_optvalSocket option value
[out]p_optlenSize of Socket option
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Error reading socket option
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSSocket option read successfully.

This reads socket specific options. Quectel CATM1 supports following socket options SO_SNDBUF: Transmission packet size TCP_MAX_RETRIES: Maximum Number of retransmission TCP_MAX_RTO: Maximum interval time of TCP retransmission.

Implements getsockopt This gets options for an existing socket.

Parameters
[in]sockfdSocket file descriptor
[in]levelLevel
[in]optnameSocket option name
[out]p_optvalSocket option value
[out]p_optlenSize of Socket option
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDError reading socket option or invalid socket descriptor
Returns
Otherwise Socket option read successfully.

◆ listen()

int listen ( int  sockfd,
int  backlog 
)

This listens for connection on socket.

Listen for tcp connection. Set socket in listen mode for tcp connection.

Parameters
[in]sockfdLocal socket
[in]backlogMax number of connection queue.

Implements listen This function listen for connection on socket.

Parameters
[in]sockfdSocket File Descriptor
[in]backlognumber of maximum connection can be accepted
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDFailed to set socket in Listen mode
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSSet socket in Listen mode successfully.

Implements listen This function listen for connection on socket.

Parameters
[in]sockfdSocket File Descriptor
[in]backlognumber of maximum connection can be accepted
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDFailed to set socket in Listen mode or invalid input parameters
Returns
Otherwise Set socket in Listen mode successfully.

◆ recv()

ssize_t recv ( int  sockfd,
void *  p_buf,
size_t  length,
int  flags 
)

This receives data over STREAM socket.

Receive data from remote socket.

Parameters
[in]sockfdLocal socket
[out]p_bufPointer to data buffer where data will be received
[in]lengthMaximum length of data which can be received
[in]flagsSocket flags

Implements receive This function receives data on a stream socket in connected state. If no packet is available, the socket is blocked until it is set to non-blocking. The application must provide a valid buffer to receive the payload. If the buffer length is smaller than the available payload, the API will do a partial copy, and hold on the rest of the payload for a subsequent call to the API.

Parameters
[in]sockfdSocket File Descriptor
[out]p_bufBuffer to read data
[in]lengthData length
[in]flagsSocket flag
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Failed to receive data.
Returns
Otherwise Number of Data bytes received successfully.

Implements receive This function receives data on a stream socket in connected state. If no packet is available, the socket is blocked until it is set to non-blocking. The application must provide a valid buffer to receive the payload. If the buffer length is smaller than the available payload, the API will do a partial copy, and hold on the rest of the payload for a subsequent call to the API.

Parameters
[in]sockfdSocket File Descriptor
[out]p_bufBuffer to read data
[out]lengthData length
[in]flagsSocket flag
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDFailed to receive data or invalid input parameters
Returns
Otherwise Data received successfully.

◆ recvfrom()

ssize_t recvfrom ( int  sockfd,
void *  p_buf,
size_t  length,
int  flags,
struct sockaddr p_src_addr,
socklen_t p_addrlen 
)

This receives data over DGRAM socket.

Receive data from remote socket.

Parameters
[in]sockfdLocal socket
[out]p_bufPointer to data buffer where data will be received
[in]lengthMaximum length of data which can be received
[in]flagsSocket flag
[out]p_src_addrPointer to remote socket address which has sent data
[out]p_addrlenLength of socket address structure

Implements recvfrom This function receives data on a dgram socket. If no packet is available, the socket is blocked until it is set to non-blocking. The application must provide a valid buffer to receive the payload. If the buffer length is smaller than the available payload, the API will do a partial copy, and hold on the rest of the payload for a subsequent call to the API.

Parameters
[in]sockfdSocket file descriptor
[out]p_bufData buffer pointer to read data
[in]lengthLength of data to read
[in]flagsFlags
[in]p_src_addrRemote machine network address
[in]p_addrlenSize of Remote machine network
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Error receiving data
Returns
Otherwise Numbers of data bytes received successfully.

Implements recvfrom This function receives data on a dgram socket. If no packet is available, the socket is blocked until it is set to non-blocking. The application must provide a valid buffer to receive the payload. If the buffer length is smaller than the available payload, the API will do a partial copy, and hold on the rest of the payload for a subsequent call to the API.

Parameters
[in]sockfdSocket file descriptor
[out]p_bufData buffer pointer to read data
[in]lengthLength of data to read
[in]flagsFlags
[in]p_src_addrRemote machine network address (Can be NULL)
[in]p_addrlenSize of Remote machine network (Can be NULL)
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDError receiving data or invalid input parameters
Returns
Otherwise Numbers of data bytes received successfully.

◆ select()

int select ( int  nfds,
fd_set *  p_readfds,
fd_set *  p_writefds,
fd_set *  p_exceptfds,
struct timeval *  p_timeout 
)

This waits for any activity on socket.

Wait on a given socket for specified amount of time. In case of any activity e.g. arrival of packet it comes out of wait.

Parameters
[in]nfdsMax fd
[in]p_readfdsPointer to fd_set to check whether data is available for read
[in]p_writefdsPointer to fd_set to check whether data is available for write
[in]p_exceptfdsPointer to fd_set to check whether exceptional condition occurred
[in]p_timeoutWait time in milliseconds

Implements select Allow an application thread to block on a given socket handle for a specified time period. This API checks for any activity on specified socket, for example arrival of a packet at the receive queue.

Parameters
[in]nfdsNumber of socket fds in to check
[in]p_readfdsRead socket fd set
[in]p_writefdsWrite socket fd set. If no descriptor is to be tested for writing, p_writefds should be NULL
[in]p_exceptfdsExceptional socket fd set. If no descriptor is to be tested for exceptions, p_exceptfds should be NULL
[in]p_timeoutTimeout
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDTimeout occurred, no activity.
Returns
Otherwise Activity detected(Packet available).

Implements select Allow an application thread to block on a given socket handle for a specified time period. This API checks for any activity on specified socket, for example arrival of a packet at the receive queue.

Parameters
[in]nfdsNumber of socket fds in to check
[in]p_readfdsRead socket fd set
[in]p_writefdsWrite socket fd set - API does not used this parameter
[in]p_exceptfdsExceptional socket fd set - API does not used this parameter
[in]p_timeoutTimeout
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDTimeout occurred, no activity or invalid socket descriptor
Returns
Otherwise Activity detected(Packet available).

◆ send()

ssize_t send ( int  sockfd,
const void *  p_buf,
size_t  length,
int  flags 
)

This sends data over STREAM socket.

Send data to remote socket.

Parameters
[in]sockfdLocal socket
[in]p_bufPointer to data buffer
[in]lengthData buffer length
[in]flagsSocket flags

Implements send This function sends data on a stream socket in connected state.

Parameters
[in]sockfdSocket File Descriptor
[in]p_bufBuffer data to send
[in]lengthData length
[in]flagsSocket flag
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Failed to send data.
Returns
Otherwise Number of Data bytes sent successfully.

Implements send This function sends data on a stream socket in connected state.

Parameters
[in]sockfdSocket File Descriptor
[in]p_bufBuffer data to send
[in]lengthData length
[in]flagsSocket flag
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDFailed to send data or invalid input parameters
Returns
Otherwise Data sent successfully.

◆ sendto()

ssize_t sendto ( int  sockfd,
const void *  p_buf,
size_t  length,
int  flags,
const struct sockaddr p_dest_addr,
socklen_t  addrlen 
)

This sends data over DGRAM socket.

Send data to remote socket.

Parameters
[in]sockfdLocal socket
[in]p_bufPointer to data buffer to sent
[in]lengthData buffer length
[in]flagsSocket flag
[in]p_dest_addrPointer to remote socket address where to send data
[in]addrlenLength of socket address structure

Implements sendto This function sends data to remote.

Parameters
[in]sockfdSocket File Descriptor
[in]p_bufBuffer data pointer
[in]lengthLength of data
[in]flagsFlag
[in]p_dest_addrAddress of remote UDP server
[in]addrlenSize of Network address structure
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Error Sending data.
Returns
Otherwise Numbers of bytes sent successfully.

Implements sendto This function sends data to remote.

Parameters
[in]sockfdSocket File Descriptor
[in]p_bufBuffer data pointer
[in]lengthLength of data
[in]flagsFlag
[in]p_dest_addrAddress of remote UDP server
[in]addrlenSize of Network address structure
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDError Sending data or invalid input parameters
Returns
Otherwise Numbers of bytes sent successfully.

◆ setsockopt()

int setsockopt ( int  sockfd,
int  level,
int  optname,
const void *  p_optval,
socklen_t  optlen 
)

This updates socket specific options. Quectel CATM1 supports following socket options SO_SNDBUF: Transmission packet size TCP_MAX_RETRIES: Maximum Number of retransmission TCP_MAX_RTO: Maximum interval time of TCP retransmission.

Set Socket options.

Parameters
[in]sockfdLocal socket
[in]levelSockets API level
[in]optnameOption to be set
[in]p_optvalOption value to be set
[in]optlenLength of option value

Implements setsockopt This sets options for an existing socket.

Parameters
[in]sockfdSocket file descriptor
[in]levelLevel
[in]optnameSocket option name
[in]p_optvalSocket option value
[in]optlenSize of Socket option
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDInvalid input arguments OR Error setting socket option
SF_CELLULAR_QCTLCATM1_SOCKET_SUCCESSSocket option set successfully.

This updates socket specific options. Quectel CATM1 supports following socket options SO_SNDBUF: Transmission packet size TCP_MAX_RETRIES: Maximum Number of retransmission TCP_MAX_RTO: Maximum interval time of TCP retransmission.

Implements setsockopt This sets options for an existing socket.

Parameters
[in]sockfdSocket file descriptor
[in]levelLevel
[in]optnameSocket option name
[in]p_optvalSocket option value
[in]optlenSize of Socket option
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDError setting socket option or invalid socket descriptor
Returns
Otherwise Socket option set successfully.

◆ socket()

int socket ( int  domain,
int  type,
int  protocol 
)

This creates socket for communication.

API which creates socket

Parameters
[in]domainSocket family
[in]typeSocket type
[in]protocolProtocol type

Implements socket Creates socket with given parameters.

Parameters
[in]domainNetwork Domain
[in]typeSocket type
[in]protocolProtocol type
Return values
SF_CELLULAR_QCTLCATM1_SOCKET_INVALID_FDSocket creation failed
Returns
Otherwise Socket descriptor of newly created socket

Implements socket Creates socket with given parameters.

Parameters
[in]domainNetwork Domain
[in]typeSocket type
[in]protocolProtocol type
Return values
SF_CELLULAR_RYZ014CATM1_SOCKET_INVALID_FDSocket creation failed
Returns
Otherwise Socket created successfully