Mbed OS Reference
|
Public Types | |
typedef mbed::Callback< nsapi_error_t(int delay_ms, mbed::Callback< void()> user_cb)> | call_in_callback_cb_t |
Type for a call-in callback. More... | |
Public Member Functions | |
virtual nsapi_error_t | gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL) |
Translates a hostname to an IP address with specific version. More... | |
virtual nsapi_error_t | get_ip_address (SocketAddress *address) |
Get the local IP address. More... | |
void | set_cid (int cid) |
Set PDP context ID for this stack. More... | |
virtual nsapi_error_t | get_ipv6_link_local_address (SocketAddress *address) |
Get the IPv6 link local address. More... | |
virtual nsapi_error_t | get_ip_address_if (SocketAddress *address, const char *interface_name) |
Get the local IP address on interface name. More... | |
virtual nsapi_value_or_error_t | getaddrinfo (const char *hostname, SocketAddress *hints, SocketAddress **res, const char *interface_name=NULL) |
Translate a hostname to the multiple IP addresses with specific version using network interface name. More... | |
virtual nsapi_value_or_error_t | gethostbyname_async (const char *host, hostbyname_cb_t callback, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL) |
Translates a hostname to multiple IP addresses (asynchronous) More... | |
virtual nsapi_value_or_error_t | getaddrinfo_async (const char *hostname, SocketAddress *hints, hostbyname_cb_t callback, const char *interface_name=NULL) |
Translates a hostname to the multiple IP addresses (asynchronous) More... | |
virtual nsapi_error_t | gethostbyname_async_cancel (int id) |
Cancels asynchronous hostname translation. More... | |
virtual nsapi_error_t | add_dns_server (const SocketAddress &address, const char *interface_name=NULL) |
Add a domain name server to list of servers to query. More... | |
virtual nsapi_error_t | get_dns_server (int index, SocketAddress *address, const char *interface_name=NULL) |
Get a domain name server from a list of servers to query. More... | |
virtual OnboardNetworkStack * | onboardNetworkStack () |
Dynamic downcast to a OnboardNetworkStack. More... | |
Protected Member Functions | |
virtual nsapi_error_t | socket_listen (nsapi_socket_t handle, int backlog) |
Listen for connections on a TCP socket. More... | |
virtual nsapi_error_t | socket_accept (nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0) |
Accepts a connection on a TCP socket. More... | |
virtual nsapi_error_t | create_socket_impl (CellularSocket *socket) |
Implements modem specific AT command set for creating socket. More... | |
virtual nsapi_error_t | socket_connect (nsapi_socket_t handle, const SocketAddress &address) |
Connects TCP socket to a remote host. More... | |
virtual nsapi_size_or_error_t | socket_sendto_impl (CellularSocket *socket, const SocketAddress &address, const void *data, nsapi_size_t size) |
Implements modem specific AT command set for sending data. More... | |
virtual nsapi_size_or_error_t | socket_recvfrom_impl (CellularSocket *socket, SocketAddress *address, void *buffer, nsapi_size_t size) |
Implements modem specific AT command set for receiving data. More... | |
virtual nsapi_error_t | socket_close_impl (int sock_id) |
Implements modem specific AT command set for socket closing. More... | |
virtual nsapi_error_t | socket_open (nsapi_socket_t *handle, nsapi_protocol_t proto) |
Note: Socket_open does not actually open socket on all drivers, but that's deferred until calling sendto . More... | |
virtual nsapi_error_t | socket_close (nsapi_socket_t handle) |
Close the socket. More... | |
virtual nsapi_error_t | socket_bind (nsapi_socket_t handle, const SocketAddress &address) |
Bind a specific address to a socket. More... | |
virtual nsapi_size_or_error_t | socket_send (nsapi_socket_t handle, const void *data, nsapi_size_t size) |
Send data over a TCP socket. More... | |
virtual nsapi_size_or_error_t | socket_recv (nsapi_socket_t handle, void *data, nsapi_size_t size) |
Receive data over a TCP socket. More... | |
virtual nsapi_size_or_error_t | socket_sendto (nsapi_socket_t handle, const SocketAddress &address, const void *data, nsapi_size_t size) |
Send a packet over a UDP socket. More... | |
virtual nsapi_size_or_error_t | socket_recvfrom (nsapi_socket_t handle, SocketAddress *address, void *buffer, nsapi_size_t size) |
Receive a packet over a UDP socket. More... | |
virtual void | socket_attach (nsapi_socket_t handle, void(*callback)(void *), void *data) |
Register a callback on state change of the socket. More... | |
CellularSocket * | find_socket (int index) |
Find the socket handle based on the index of the socket construct in the socket container. More... | |
int | find_socket_index (nsapi_socket_t handle) |
Find the index of the given CellularSocket handle. More... | |
bool | is_addr_stack_compatible (const SocketAddress &addr) |
Checks if send to address is valid and if current stack type supports sending to that address type. More... | |
virtual nsapi_size_or_error_t | socket_sendto_control (nsapi_socket_t handle, const SocketAddress &address, const void *data, nsapi_size_t size, nsapi_msghdr_t *control, nsapi_size_t control_size) |
Send a packet with ancillary data over a UDP socket. More... | |
virtual nsapi_size_or_error_t | socket_recvfrom_control (nsapi_socket_t handle, SocketAddress *address, void *data, nsapi_size_t size, nsapi_msghdr_t *control, nsapi_size_t control_size) |
Receive a packet with ancillary data over a UDP socket. More... | |
virtual nsapi_error_t | setsockopt (nsapi_socket_t handle, int level, int optname, const void *optval, unsigned optlen) |
Set stack-specific socket options. More... | |
virtual nsapi_error_t | getsockopt (nsapi_socket_t handle, int level, int optname, void *optval, unsigned *optlen) |
Get stack-specific socket options. More... | |
Static Protected Attributes | |
static const int | SOCKET_UNUSED = -1 |
Socket "unused" value. More... | |
static constexpr seconds | SOCKET_TIMEOUT = 1s |
Socket timeout value in milliseconds. More... | |
static const int | RM1000_MAX_PACKET_SIZE = 1024 |
The maximum number of bytes in a packet that can be write/read from the AT interface in one go. More... | |
Definition at line 31 of file RM1000_AT_CellularStack.h.
|
inherited |
Type for a call-in callback.
This is a pointer to a function that will call the provided callback from the network stack after a given delay, or immediately if delay_ms
is 0.
Definition at line 235 of file NetworkStack.h.
|
virtual |
Translates a hostname to an IP address with specific version.
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
host | Hostname to resolve |
address | Pointer to a SocketAddress to store the result. |
version | IP version of address to resolve, NSAPI_UNSPEC indicates version is chosen by the stack (defaults to NSAPI_UNSPEC) |
interface_name | Network interface_name |
NSAPI_ERROR_OK | on success |
NSAPI_ERROR_PARAMETER | if invalid (null) name is provided |
NSAPI_ERROR_DNS_FAILURE | if DNS resolution fails |
int | other negative errors, see nsapi_dns_query |
Reimplemented from NetworkStack.
|
protectedvirtual |
Listen for connections on a TCP socket.
Marks the socket as a passive socket that can be used to accept incoming connections.
handle | Socket handle |
backlog | Number of pending connections that can be queued simultaneously |
Reimplemented from AT_CellularStack.
|
protectedvirtual |
Accepts a connection on a TCP socket.
The server socket must be bound and set to listen for connections. On a new connection, creates a network socket and stores it in the specified handle. The handle must be passed to following calls on the socket.
A stack may have a finite number of sockets, in this case NSAPI_ERROR_NO_SOCKET is returned if no socket is available.
This call is non-blocking. If accept would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
server | Socket handle to server to accept from |
handle | Destination for a handle to the newly created socket |
address | Destination for the remote address or NULL |
Reimplemented from AT_CellularStack.
|
protectedvirtual |
Implements modem specific AT command set for creating socket.
socket | Cellular socket handle |
Implements AT_CellularStack.
|
protectedvirtual |
Connects TCP socket to a remote host.
Initiates a connection to a remote server specified by the indicated address.
handle | Socket handle |
address | The SocketAddress of the remote host |
Reimplemented from AT_CellularStack.
|
protectedvirtual |
Implements modem specific AT command set for sending data.
socket | Cellular socket handle |
address | The SocketAddress of the remote host |
data | Buffer of data to send to the host |
size | Size of the buffer in bytes |
Implements AT_CellularStack.
|
protectedvirtual |
Implements modem specific AT command set for receiving data.
socket | Socket handle |
address | Destination for the source address or NULL |
buffer | Destination buffer for data received from the host |
size | Size of the buffer in bytes |
Implements AT_CellularStack.
|
protectedvirtual |
Implements modem specific AT command set for socket closing.
sock_id | Socket id |
Implements AT_CellularStack.
|
virtualinherited |
Get the local IP address.
address | SocketAddress representation of the local IP address |
NSAPI_ERROR_OK | on success |
NSAPI_ERROR_UNSUPPORTED | if this feature is not supported |
NSAPI_ERROR_PARAMETER | if the provided pointer is invalid |
NSAPI_ERROR_NO_ADDRESS | if the address cannot be obtained from stack |
Reimplemented from NetworkStack.
|
inherited |
Set PDP context ID for this stack.
cid | value from AT+CGDCONT, where -1 is undefined |
|
protectedvirtualinherited |
Note: Socket_open does not actually open socket on all drivers, but that's deferred until calling sendto
.
The reason is that IP stack implementations are very much modem specific and it's quite common that when a socket is created (via AT commands) it must also be given remote IP address, and that is usually known only when calling sendto
.
Implements NetworkStack.
|
protectedvirtualinherited |
Close the socket.
Closes any open connection and deallocates any memory associated with the socket.
handle | Socket handle |
Implements NetworkStack.
|
protectedvirtualinherited |
Bind a specific address to a socket.
Binding a socket specifies the address and port on which to receive data. If the IP address is zeroed, only the port is bound.
handle | Socket handle |
address | Local address to bind |
Implements NetworkStack.
|
protectedvirtualinherited |
Send data over a TCP socket.
The socket must be connected to a remote host. Returns the number of bytes sent from the buffer.
This call is non-blocking. If send would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
handle | Socket handle |
data | Buffer of data to send to the host |
size | Size of the buffer in bytes |
Implements NetworkStack.
|
protectedvirtualinherited |
Receive data over a TCP socket.
The socket must be connected to a remote host. Returns the number of bytes received into the buffer.
This call is non-blocking. If recv would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
handle | Socket handle |
data | Destination buffer for data received from the host |
size | Size of the buffer in bytes |
Implements NetworkStack.
|
protectedvirtualinherited |
Send a packet over a UDP socket.
Sends data to the specified address. Returns the number of bytes sent from the buffer.
This call is non-blocking. If sendto would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
handle | Socket handle |
address | The SocketAddress of the remote host |
data | Buffer of data to send to the host |
size | Size of the buffer in bytes |
Implements NetworkStack.
|
protectedvirtualinherited |
Receive a packet over a UDP socket.
Receives data and stores the source address in address if address is not NULL. Returns the number of bytes received into the buffer.
This call is non-blocking. If recvfrom would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
handle | Socket handle |
address | Destination for the source address or NULL |
buffer | Destination buffer for data received from the host |
size | Size of the buffer in bytes |
Implements NetworkStack.
|
protectedvirtualinherited |
Register a callback on state change of the socket.
The specified callback will be called on state changes such as when the socket can recv/send/accept successfully and on 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 recv/send calls.
handle | Socket handle |
callback | Function to call on state change |
data | Argument to pass to callback |
Implements NetworkStack.
|
protectedinherited |
Find the socket handle based on the index of the socket construct in the socket container.
Please note that this index may or may not be the socket id. The actual meaning of this index depends upon the modem being used.
index | Index of the socket construct in the container |
|
protectedinherited |
Find the index of the given CellularSocket handle.
This index may or may not be the socket id. The actual meaning of this index depends upon the modem being used.
|
protectedinherited |
Checks if send to address is valid and if current stack type supports sending to that address type.
|
virtualinherited |
Get the IPv6 link local address.
address | SocketAddress representation of the link local IPv6 address |
NSAPI_ERROR_OK | on success |
NSAPI_ERROR_UNSUPPORTED | if this feature is not supported |
NSAPI_ERROR_PARAMETER | if the provided pointer is invalid |
|
virtualinherited |
Get the local IP address on interface name.
address | SocketAddress representation of the link local IPv6 address |
interface_name | Network interface_name |
NSAPI_ERROR_OK | on success |
NSAPI_ERROR_UNSUPPORTED | if this feature is not supported |
NSAPI_ERROR_PARAMETER | if the provided pointer is invalid |
NSAPI_ERROR_NO_ADDRESS | if the address cannot be obtained from stack |
|
virtualinherited |
Translate a hostname to the multiple IP addresses with specific version using network interface name.
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
hostname | Hostname to resolve. |
hints | Pointer to a SocketAddress with query parameters. |
res | Pointer to a SocketAddress array to store the result.. |
interface_name | Network interface name |
Implements DNS.
|
virtualinherited |
Translates a hostname to multiple IP addresses (asynchronous)
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
Call is non-blocking. Result of the DNS operation is returned by the callback. If this function returns failure, callback will not be called. In case result is success (IP address was found from DNS cache), callback will be called before function returns.
host | Hostname to resolve |
callback | Callback that is called for result |
version | IP version of address to resolve, NSAPI_UNSPEC indicates version is chosen by the stack (defaults to NSAPI_UNSPEC) |
interface_name | Network interface_name |
Implements DNS.
Reimplemented in Nanostack.
|
virtualinherited |
Translates a hostname to the multiple IP addresses (asynchronous)
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
The call is non-blocking. Result of the DNS operation is returned by the callback. If this function returns failure, callback will not be called. In case that IP addresses are found from DNS cache, callback will be called before function returns.
hostname | Hostname to resolve |
hints | Pointer to a SocketAddress with query parameters. |
callback | Callback that is called for result |
interface_name | Network interface_name |
Implements DNS.
|
virtualinherited |
Cancels asynchronous hostname translation.
When translation is cancelled, callback will not be called.
id | Unique id of the hostname translation operation |
Implements DNS.
|
virtualinherited |
Add a domain name server to list of servers to query.
address | Destination for the host address |
interface_name | Network interface name. Currently unused, the server is added for all interfaces. |
Implements DNS.
|
virtualinherited |
Get a domain name server from a list of servers to query.
Returns a DNS server address for a index. If returns error no more DNS servers to read.
index | Index of the DNS server, starts from zero |
address | Destination for the host address |
interface_name | Network interface name |
Reimplemented in Nanostack.
|
virtualinherited |
Dynamic downcast to a OnboardNetworkStack.
Reimplemented in OnboardNetworkStack.
Definition at line 225 of file NetworkStack.h.
|
protectedvirtualinherited |
Send a packet with ancillary data over a UDP socket.
Sends data to the specified address. Returns the number of bytes sent from the buffer.
This call is non-blocking. If sendto would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
handle | Socket handle |
address | The SocketAddress of the remote host |
data | Buffer of data to send to the host |
size | Size of the buffer in bytes |
control | Storage for ancillary data |
control_size | Size of ancillary data |
Definition at line 408 of file NetworkStack.h.
|
protectedvirtualinherited |
Receive a packet with ancillary data over a UDP socket.
Receives data and stores the source address in address if address is not NULL. Returns the number of bytes received into the buffer.
Ancillary data is stored into control
. The caller needs to allocate a buffer that is large enough to contain the data they want to receive, then pass the pointer in through the control
member. The data will be filled into control
, beginning with a header specifying what data was received. See MsgHeaderIterator for how to parse this data.
This call is non-blocking. If recvfrom would block, NSAPI_ERROR_WOULD_BLOCK is returned immediately.
handle | Socket handle |
address | Destination for the source address or NULL |
data | Destination buffer for data received from the host |
size | Size of the buffer in bytes |
control | Storage for ancillary data |
control_size | Size of ancillary data |
Definition at line 441 of file NetworkStack.h.
|
protectedvirtualinherited |
Set stack-specific socket options.
The setsockopt allow an application to pass stack-specific hints to the underlying stack. For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned and the socket is unmodified.
handle | Socket handle. |
level | Stack-specific protocol level. |
optname | Stack-specific option identifier. |
optval | Option value. |
optlen | Length of the option value. |
Reimplemented in Nanostack.
|
protectedvirtualinherited |
Get stack-specific socket options.
The getstackopt allow an application to retrieve stack-specific hints from the underlying stack. For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned and optval is unmodified.
handle | Socket handle. |
level | Stack-specific protocol level. |
optname | Stack-specific option identifier. |
optval | Destination for option value. |
optlen | Length of the option value. |
Reimplemented in Nanostack.
|
staticprotected |
Socket "unused" value.
Definition at line 53 of file RM1000_AT_CellularStack.h.
|
staticconstexprprotected |
Socket timeout value in milliseconds.
Note: the sockets layer above will retry the call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK and the user has set a larger timeout or full blocking.
Definition at line 60 of file RM1000_AT_CellularStack.h.
|
staticprotected |
The maximum number of bytes in a packet that can be write/read from the AT interface in one go.
Definition at line 65 of file RM1000_AT_CellularStack.h.