Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

CellularNonIPSocket Class Reference

CellularNonIPSocket Class Reference
[Netsocket]

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

#include <CellularNonIPSocket.h>

Inherits Socket.

Public Member Functions

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

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 37 of file CellularNonIPSocket.h.


Constructor & Destructor Documentation

~CellularNonIPSocket (  ) [virtual]

Destroy the socket.

Note:
Closes socket if it's still open.

Definition at line 40 of file CellularNonIPSocket.cpp.

Creates a socket.

Definition at line 24 of file CellularNonIPSocket.cpp.


Member Function Documentation

Socket * accept ( nsapi_error_t error = NULL ) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 222 of file CellularNonIPSocket.cpp.

nsapi_error_t bind ( const SocketAddress address ) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 261 of file CellularNonIPSocket.cpp.

nsapi_error_t close ( void   ) [virtual]

Closes socket.

Returns:
NSAPI_ERROR_OK on success NSAPI_ERROR_NO_SOCKET otherwise

Implements Socket.

Definition at line 63 of file CellularNonIPSocket.cpp.

nsapi_error_t connect ( const SocketAddress address ) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 217 of file CellularNonIPSocket.cpp.

nsapi_error_t getpeername ( SocketAddress address ) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 256 of file CellularNonIPSocket.cpp.

nsapi_error_t getsockopt ( int  level,
int  optname,
void *  optval,
unsigned *  optlen 
) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 251 of file CellularNonIPSocket.cpp.

nsapi_error_t listen ( int  backlog = 1 ) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 230 of file CellularNonIPSocket.cpp.

nsapi_error_t open ( mbed::ControlPlane_netif cp_netif ) [virtual]

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

Definition at line 45 of file CellularNonIPSocket.cpp.

nsapi_error_t open ( mbed::CellularContext cellular_context ) [virtual]

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

Definition at line 31 of file CellularNonIPSocket.cpp.

nsapi_size_or_error_t recv ( void *  data,
nsapi_size_t  size 
) [virtual]

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.

Definition at line 136 of file CellularNonIPSocket.cpp.

nsapi_size_or_error_t recvfrom ( SocketAddress address,
void *  data,
nsapi_size_t  size 
) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 240 of file CellularNonIPSocket.cpp.

nsapi_size_or_error_t send ( const void *  data,
nsapi_size_t  size 
) [virtual]

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.

Definition at line 93 of file CellularNonIPSocket.cpp.

nsapi_size_or_error_t sendto ( const SocketAddress address,
const void *  data,
nsapi_size_t  size 
) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 235 of file CellularNonIPSocket.cpp.

void set_blocking ( bool  blocking ) [virtual]

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.

Definition at line 182 of file CellularNonIPSocket.cpp.

void set_timeout ( int  timeout ) [virtual]

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.

Definition at line 187 of file CellularNonIPSocket.cpp.

nsapi_error_t setsockopt ( int  level,
int  optname,
const void *  optval,
unsigned  optlen 
) [virtual]

NOT APPLICABLE.

Implements Socket.

Definition at line 246 of file CellularNonIPSocket.cpp.

virtual void sigio ( mbed::Callback< void()>  func ) [virtual]

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.