Synergy Software Package User's Manual
BSD Socket over Quectel CATM1 on-chip stack API

SF_CELLULAR Socket Framework API on Quectel CATM1. More...

Functions

ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_Open (sf_cellular_socket_ctrl_t *p_ctrl, sf_cellular_socket_cfg_t const *const p_cfg)
 Open the Cellular Device driver to use the Socket Layer on Cellular Driver On-Chip stack. More...
 
ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_Close (sf_cellular_socket_ctrl_t *const p_ctrl)
 Close the Cellular Device driver. More...
 
ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_PING (sf_cellular_socket_ctrl_t *const p_ctrl, ULONG *p_ip_address, uint32_t count, uint32_t interval_ms)
 
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...
 
ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_VersionGet (ssp_version_t *const p_version)
 This function gets the version information of the underlying driver. More...
 

Detailed Description

SF_CELLULAR Socket Framework API on Quectel CATM1.

Function Documentation

◆ accept()

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

This accepts connection from remote socket.

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.

◆ bind()

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

This binds socket to IP address.

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.

◆ close()

int close ( int  sockfd)

This closes 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.

◆ connect()

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

This connects with remote socket(stream socket).

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.

◆ 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.

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.

◆ listen()

int listen ( int  sockfd,
int  backlog 
)

This listens for connection on socket.

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.

◆ recv()

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

This receives data over STREAM socket.

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.

◆ 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.

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.

◆ 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.

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).

◆ send()

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

This sends data over STREAM socket.

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.

◆ 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.

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.

◆ 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.

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.

◆ SF_CELLULAR_QCTLCATM1_SOCKET_Close()

ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_Close ( sf_cellular_socket_ctrl_t *const  p_ctrl)

Close the Cellular Device driver.

Implements sf_cellular_socket_api_t::close Calls the low level Cellular device driver's Close API to close the cellular Driver.

Return values
SSP_SUCCESSCellular Driver stop successfully.
SSP_ERR_NOT_OPENDevice is not opened.
SSP_ERR_ASSERTIONArgument NULL is passed
SSP_ERR_CELLULAR_FAILEDDriver un-initialization failed
SSP_ERR_IN_USEDevice already in use

SF Cellular instance variable

SF Cellular API structure variable

SF Cellular Stack control block structure

◆ SF_CELLULAR_QCTLCATM1_SOCKET_Open()

ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_Open ( sf_cellular_socket_ctrl_t p_ctrl,
sf_cellular_socket_cfg_t const *const  p_cfg 
)

Open the Cellular Device driver to use the Socket Layer on Cellular Driver On-Chip stack.

Implements sf_cellular_socket_api_t::open Calls the low level Cellular device driver's Open API to Initialize the Cellular Device Driver, for using Socket Layer on On-Chip stack.

Return values
SSP_SUCCESSDriver initialization successfully.
SSP_ERR_ALREADY_OPENCellular Quectel CATM1 Driver is already opened.
SSP_ERR_CELLULAR_CONFIG_FAILEDCellular Quectel CATM1 module Configuration failed
SSP_ERR_CELLULAR_INIT_FAILEDCellular Quectel CATM1 module initialization failed
SSP_ERR_ASSERTIONArgument NULL is passed
SSP_ERR_CELLULAR_FAILEDDriver initialization failed
SSP_ERR_IN_USEDevice already in use

SF Cellular instance variable

SF Cellular API structure variable

SF Cellular configuration structure variable

SF Cellular Stack control block structure

Initialize Cellular Modem

Initialize Socket Interface global variable , if module open successfully or already open

◆ SF_CELLULAR_QCTLCATM1_SOCKET_PING()

ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_PING ( sf_cellular_socket_ctrl_t *const  p_ctrl,
ULONG *  p_ip_address,
uint32_t  count,
uint32_t  interval_ms 
)

Ping an IP address on the network.

Parameters
[in]p_ctrlPointer to control structure.
[in]p_ip_addressPointer to IP address.
[in]countNumber of ping attempts.
[in]interval_msInterval between ping attempts.
Return values
SSP_ERR_UNSUPPORTEDFunctionality not supported

◆ SF_CELLULAR_QCTLCATM1_SOCKET_VersionGet()

ssp_err_t SF_CELLULAR_QCTLCATM1_SOCKET_VersionGet ( ssp_version_t *const  p_version)

This function gets the version information of the underlying driver.

Implements sf_cellular_socket_api_t::versionGet

Parameters
[out]p_versionDriver version information
Return values
SSP_ERR_ASSERTIONArgument NULL is passed
SSP_SUCCESSSuccessfully read version information

◆ socket()

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

This creates socket for communication.

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