Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
CellularNonIPSocket Class Reference

Socket implementation for cellular Non-IP data delivery(NIDD). More...

#include <CellularNonIPSocket.h>

Inheritance diagram for CellularNonIPSocket:
Socket

Public Member Functions

 ~CellularNonIPSocket () override
 Destroy the socket. More...
 
 CellularNonIPSocket ()
 Creates a socket. More...
 
nsapi_error_t open (mbed::CellularContext *cellular_context)
 Opens a socket on the given cellular context. More...
 
nsapi_error_t open (mbed::ControlPlane_netif *cp_netif)
 Opens a socket that will use the given control plane interface for data delivery. More...
 
nsapi_error_t close () override
 Closes socket. More...
 
nsapi_size_or_error_t send (const void *data, nsapi_size_t size) override
 Send data over a control plane cellular context. More...
 
nsapi_size_or_error_t recv (void *data, nsapi_size_t size) override
 Receive data from a socket. More...
 
void set_blocking (bool blocking) override
 Set blocking or non-blocking mode of the socket. More...
 
void set_timeout (int timeout) override
 Set timeout on blocking socket operations. More...
 
void sigio (mbed::Callback< void()> func) override
 Register a callback on state change of the socket. More...
 
nsapi_error_t connect (const SocketAddress &address) override
 NOT APPLICABLE. More...
 
Socketaccept (nsapi_error_t *error=NULL) override
 NOT APPLICABLE. More...
 
nsapi_error_t listen (int backlog=1) override
 NOT APPLICABLE. More...
 
nsapi_error_t setsockopt (int level, int optname, const void *optval, unsigned optlen) override
 NOT APPLICABLE. More...
 
nsapi_error_t getsockopt (int level, int optname, void *optval, unsigned *optlen) override
 NOT APPLICABLE. More...
 
nsapi_error_t getpeername (SocketAddress *address) override
 NOT APPLICABLE. More...
 
nsapi_size_or_error_t sendto (const SocketAddress &address, const void *data, nsapi_size_t size) override
 NOT APPLICABLE. More...
 
nsapi_size_or_error_t recvfrom (SocketAddress *address, void *data, nsapi_size_t size) override
 NOT APPLICABLE. More...
 
nsapi_error_t bind (const SocketAddress &address) override
 NOT APPLICABLE. More...
 

Detailed Description

Socket implementation for cellular Non-IP data delivery(NIDD).

Relies on Control Plane CIoT EPS optimization feature, implemented in ControlPlane_netif class.

Definition at line 39 of file CellularNonIPSocket.h.

Constructor & Destructor Documentation

~CellularNonIPSocket ( )
override

Destroy the socket.

Note
Closes socket if it's still open.

Creates a socket.

Member Function Documentation

Socket* accept ( nsapi_error_t error = NULL)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_error_t bind ( const SocketAddress address)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_error_t close ( )
overridevirtual

Closes socket.

Returns
NSAPI_ERROR_OK on success NSAPI_ERROR_NO_SOCKET otherwise

Implements Socket.

nsapi_error_t connect ( const SocketAddress address)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_error_t getpeername ( SocketAddress address)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_error_t getsockopt ( int  level,
int  optname,
void *  optval,
unsigned *  optlen 
)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_error_t listen ( int  backlog = 1)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_error_t open ( mbed::CellularContext cellular_context)

Opens a socket on the given cellular context.

Parameters
cellular_contextCellular PDP context over which this socket is sending and receiving data. The context has support for providing a control plane interface for data delivery.
Returns
NSAPI_ERROR_OK on success NSAPI_ERROR_PARAMETER otherwise

Opens a socket that will use the given control plane interface for data delivery.

Attaches the event as callback to the control plane interface.

Parameters
cp_netifControl plane interface for data delivery.
Returns
NSAPI_ERROR_OK on success NSAPI_ERROR_PARAMETER otherwise
nsapi_size_or_error_t recv ( void *  data,
nsapi_size_t  size 
)
overridevirtual

Receive data from a socket.

By default, recv blocks until some data is received. If socket is set to nonblocking or times out, NSAPI_ERROR_WOULD_BLOCK can be returned to indicate no data.

Parameters
dataPointer to buffer for received data.
sizeSize of the buffer in bytes.
Returns
Number of received bytes on success, negative error code on failure.

Implements Socket.

nsapi_size_or_error_t recvfrom ( SocketAddress address,
void *  data,
nsapi_size_t  size 
)
overridevirtual

NOT APPLICABLE.

Implements Socket.

nsapi_size_or_error_t send ( const void *  data,
nsapi_size_t  size 
)
overridevirtual

Send data over a control plane cellular context.

By default, send blocks until all data is sent. If socket is set to nonblocking or times out, a partial amount can be written. NSAPI_ERROR_WOULD_BLOCK is returned if no data was written.

Parameters
dataBuffer of data to be sent.
sizeSize of the buffer in bytes.
Returns
Number of sent bytes on success, negative error code on failure.

Implements Socket.

nsapi_size_or_error_t sendto ( const SocketAddress address,
const void *  data,
nsapi_size_t  size 
)
overridevirtual

NOT APPLICABLE.

Implements Socket.

void set_blocking ( bool  blocking)
overridevirtual

Set blocking or non-blocking mode of the socket.

Initially all sockets are in blocking mode. In non-blocking mode blocking operations such as send/recv/accept return NSAPI_ERROR_WOULD_BLOCK if they cannot continue.

set_blocking(false) is equivalent to set_timeout(0) set_blocking(true) is equivalent to set_timeout(-1)

Parameters
blockingtrue for blocking mode, false for non-blocking mode.

Implements Socket.

void set_timeout ( int  timeout)
overridevirtual

Set timeout on blocking socket operations.

Initially all sockets have unbounded timeouts. NSAPI_ERROR_WOULD_BLOCK is returned if a blocking operation takes longer than the specified timeout. A timeout of 0 removes the timeout from the socket. A negative value gives the socket an unbounded timeout.

set_timeout(0) is equivalent to set_blocking(false) set_timeout(-1) is equivalent to set_blocking(true)

Parameters
timeoutTimeout in milliseconds

Implements Socket.

nsapi_error_t setsockopt ( int  level,
int  optname,
const void *  optval,
unsigned  optlen 
)
overridevirtual

NOT APPLICABLE.

Implements Socket.

void sigio ( mbed::Callback< void()>  func)
overridevirtual

Register a callback on state change of the socket.

The specified callback is called on state changes, such as when the socket can receive/send/accept successfully and when an error occurs. The callback may also be called spuriously without reason.

The callback may be called in an interrupt context and should not perform expensive operations such as receive/send calls.

Note! This is not intended as a replacement for a poll or attach-like asynchronous API, but rather as a building block for constructing such functionality. The exact timing of the registered function is not guaranteed and susceptible to change.

Parameters
funcFunction to call on state change.

Implements Socket.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.