18#ifndef AT_CELLULAR_STACK_H_
19#define AT_CELLULAR_STACK_H_
23#include "rtos/Mutex.h"
24#include "AT_CellularDevice.h"
39#define PDP_IPV6_SIZE 63+1
105 remoteAddress(
"", 0),
122 nsapi_protocol_t proto;
200 int get_socket_index_by_port(uint16_t port);
207 char _ip[PDP_IPV6_SIZE];
213 nsapi_ip_stack_t _stack_type;
216 nsapi_version_t _ip_ver_sendto;
virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address)
Bind a specific address to a socket.
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.
virtual nsapi_error_t create_socket_impl(CellularSocket *socket)=0
Implements modem specific AT command set for creating socket.
virtual nsapi_error_t get_ip_address(SocketAddress *address)
Get the local IP address.
virtual nsapi_error_t socket_close_impl(int sock_id)=0
Implements modem specific AT command set for socket closing.
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)
Connects TCP socket to a remote host.
int find_socket_index(nsapi_socket_t handle)
Find the index of the given CellularSocket handle.
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.
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog)
Listen for connections on a TCP socket.
virtual void socket_attach(nsapi_socket_t handle, void(*callback)(void *), void *data)
Register a callback on state change of the socket.
virtual nsapi_error_t socket_accept(nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0)
Accepts a connection on a TCP socket.
void set_cid(int cid)
Set PDP context ID for this stack.
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.
virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address, const void *data, nsapi_size_t size)=0
Implements modem specific AT command set for sending data.
CellularSocket * find_socket(int index)
Find the socket handle based on the index of the socket construct in the socket container.
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 sen...
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle, void *data, nsapi_size_t size)
Receive data over a TCP socket.
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address, void *buffer, nsapi_size_t size)=0
Implements modem specific AT command set for receiving data.
virtual nsapi_error_t socket_close(nsapi_socket_t handle)
Close the socket.
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.
Class for sending AT commands and parsing AT responses.
The Mutex class is used to synchronize the execution of threads.
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
signed int nsapi_error_t
Type used to represent error codes.
void * nsapi_socket_t
Opaque handle for network sockets.
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.