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

SF_CELLULAR Socket Framework API on RYZ014CATM1. More...

Functions

ssp_err_t SF_CELLULAR_RYZ014CATM1_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_RYZ014CATM1_SOCKET_Close (sf_cellular_socket_ctrl_t *const p_ctrl)
 Close the Cellular Device driver. More...
 
ssp_err_t SF_CELLULAR_RYZ014CATM1_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 sets socket specific options. More...
 
int getsockopt (int sockfd, int level, int optname, void *p_optval, socklen_t *p_optlen)
 This gets socket specific options. 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_RYZ014CATM1_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 RYZ014CATM1.

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

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.

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

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 gets socket specific options.

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.

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.

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.

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.

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.

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.

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 sets socket specific options.

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.

◆ SF_CELLULAR_RYZ014CATM1_SOCKET_Close()

ssp_err_t SF_CELLULAR_RYZ014CATM1_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 used

SF Cellular instance variable

SF Cellular API structure variable

SF Cellular Stack control block structure

Close cellular framework

◆ SF_CELLULAR_RYZ014CATM1_SOCKET_Open()

ssp_err_t SF_CELLULAR_RYZ014CATM1_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 RYZ014CATM1 Driver is already opened.
SSP_ERR_CELLULAR_CONFIG_FAILEDCellular RYZ014CATM1 module Configuration failed
SSP_ERR_CELLULAR_INIT_FAILEDCellular RYZ014CATM1 module initialization failed
SSP_ERR_ASSERTIONArgument NULL is passed
SSP_ERR_CELLULAR_FAILEDDriver initialization failed
SSP_ERR_IN_USEDevice already in used

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

◆ SF_CELLULAR_RYZ014CATM1_SOCKET_PING()

ssp_err_t SF_CELLULAR_RYZ014CATM1_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_SUCCESSFunction completed successfully.
SSP_ERR_CELLULAR_FAILEDDriver initialization failed.
SSP_ERR_IN_USEDevice already in use

Get mutex lock

Ping specified IP address

Release the mutex

◆ SF_CELLULAR_RYZ014CATM1_SOCKET_VersionGet()

ssp_err_t SF_CELLULAR_RYZ014CATM1_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_RYZ014CATM1_SOCKET_INVALID_FDSocket creation failed
Returns
Otherwise Socket created successfully