Socket interface for C027Interface. Implements the NetworkSocketAPI
Dependencies: C027_Support
Dependents: HelloC027Interface U_Blox_DeviceConnector U_Blox_DeviceConnector U-Blox_Client
Fork of LWIPInterface by
C027Interface Class Reference
C027Interface class Implementation of the NetworkInterface for C027. More...
#include <C027Interface.h>
Public Member Functions | |
C027Interface (const char *simpin=0, bool debug=false) | |
C027Interfacelifetime. | |
virtual nsapi_error_t | set_credentials (const char *apn, const char *username=0, const char *password=0) |
Set the cellular network APN and credentials. | |
virtual nsapi_error_t | connect () |
Start the interface. | |
virtual nsapi_error_t | connect (const char *apn, const char *username=0, const char *password=0) |
Start the interface. | |
virtual int | disconnect () |
Stop the interface. | |
virtual const char * | get_ip_address () |
Get the internally stored IP address. | |
virtual const char * | get_mac_address () |
Get the internally stored MAC address. | |
Protected Member Functions | |
virtual int | socket_open (void **handle, nsapi_protocol_t proto) |
Open a socket. | |
virtual int | socket_close (void *handle) |
Close the socket. | |
virtual int | socket_bind (void *handle, const SocketAddress &address) |
Bind a server socket to a specific port. | |
virtual int | socket_listen (void *handle, int backlog) |
Start listening for incoming connections. | |
virtual int | socket_connect (void *handle, const SocketAddress &address) |
Connects this TCP socket to the server. | |
virtual nsapi_error_t | socket_accept (nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0) |
Accept a new connection. | |
virtual int | socket_send (void *handle, const void *data, unsigned size) |
Send data to the remote host. | |
virtual int | socket_recv (void *handle, void *data, unsigned size) |
Receive data from the remote host. | |
virtual int | socket_sendto (void *handle, const SocketAddress &address, const void *data, unsigned size) |
Send a packet to a remote endpoint. | |
virtual int | socket_recvfrom (void *handle, SocketAddress *address, void *buffer, unsigned size) |
Receive a packet from a remote endpoint. | |
virtual void | socket_attach (void *handle, void(*callback)(void *), void *data) |
Register a callback on state change of the socket. | |
virtual NetworkStack * | get_stack () |
Provide access to the NetworkStack object. |
Detailed Description
C027Interface class Implementation of the NetworkInterface for C027.
Definition at line 28 of file C027Interface.h.
Constructor & Destructor Documentation
C027Interface | ( | const char * | simpin = 0 , |
bool | debug = false |
||
) |
C027Interfacelifetime.
- Parameters:
-
simpin Optional PIN for the SIM debug Enable debugging
Definition at line 23 of file C027Interface.cpp.
Member Function Documentation
nsapi_error_t connect | ( | ) | [virtual] |
Start the interface.
Attempts to connect to a cellular network based on supplied credentials
- Returns:
- 0 on success, negative error code on failure
Definition at line 50 of file C027Interface.cpp.
nsapi_error_t connect | ( | const char * | apn, |
const char * | username = 0 , |
||
const char * | password = 0 |
||
) | [virtual] |
Start the interface.
- Parameters:
-
apn Optional name of the network to connect to username Optional username for your APN password Optional password for your APN
- Returns:
- 0 on success, negative error code on failure
Definition at line 86 of file C027Interface.cpp.
int disconnect | ( | ) | [virtual] |
Stop the interface.
- Returns:
- 0 on success, negative on failure
Definition at line 93 of file C027Interface.cpp.
const char * get_ip_address | ( | ) | [virtual] |
Get the internally stored IP address.
- Returns:
- IP address of the interface or null if not yet connected
Definition at line 102 of file C027Interface.cpp.
const char * get_mac_address | ( | ) | [virtual] |
Get the internally stored MAC address.
- Returns:
- MAC address of the interface
Definition at line 107 of file C027Interface.cpp.
virtual NetworkStack* get_stack | ( | ) | [protected, virtual] |
Provide access to the NetworkStack object.
- Returns:
- The underlying NetworkStack object
Definition at line 182 of file C027Interface.h.
nsapi_error_t set_credentials | ( | const char * | apn, |
const char * | username = 0 , |
||
const char * | password = 0 |
||
) | [virtual] |
Set the cellular network APN and credentials.
- Parameters:
-
apn Optional name of the network to connect to user Optional username for the APN pass Optional password fot the APN
- Returns:
- 0 on success, negative error code on failure
Definition at line 37 of file C027Interface.cpp.
nsapi_error_t socket_accept | ( | nsapi_socket_t | server, |
nsapi_socket_t * | handle, | ||
SocketAddress * | address = 0 |
||
) | [protected, virtual] |
Accept a new connection.
- Parameters:
-
handle Handle in which to store new socket server Socket handle to server to accept from
- Returns:
- 0 on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 169 of file C027Interface.cpp.
void socket_attach | ( | void * | handle, |
void(*)(void *) | callback, | ||
void * | data | ||
) | [protected, virtual] |
Register a callback on state change of the socket.
- Parameters:
-
handle Socket handle callback Function to call on state change data Argument to pass to callback
- Note:
- Callback may be called in an interrupt context.
Definition at line 272 of file C027Interface.cpp.
int socket_bind | ( | void * | handle, |
const SocketAddress & | address | ||
) | [protected, virtual] |
Bind a server socket to a specific port.
- Parameters:
-
handle Socket handle address Local address to listen for incoming connections on
- Returns:
- 0 on success, negative on failure.
Definition at line 148 of file C027Interface.cpp.
int socket_close | ( | void * | handle ) | [protected, virtual] |
Close the socket.
- Parameters:
-
handle Socket handle
- Returns:
- 0 on success, negative on failure
- Note:
- On failure, any memory associated with the socket must still be cleaned up
Definition at line 139 of file C027Interface.cpp.
int socket_connect | ( | void * | handle, |
const SocketAddress & | address | ||
) | [protected, virtual] |
Connects this TCP socket to the server.
- Parameters:
-
handle Socket handle address SocketAddress to connect to
- Returns:
- 0 on success, negative on failure
Definition at line 158 of file C027Interface.cpp.
int socket_listen | ( | void * | handle, |
int | backlog | ||
) | [protected, virtual] |
Start listening for incoming connections.
- Parameters:
-
handle Socket handle backlog Number of pending connections that can be queued up at any one time [Default: 1]
- Returns:
- 0 on success, negative on failure
Definition at line 153 of file C027Interface.cpp.
int socket_open | ( | void ** | handle, |
nsapi_protocol_t | proto | ||
) | [protected, virtual] |
Open a socket.
- Parameters:
-
handle Handle in which to store new socket proto Type of socket to open, NSAPI_TCP or NSAPI_UDP
- Returns:
- 0 on success, negative on failure
Definition at line 119 of file C027Interface.cpp.
int socket_recv | ( | void * | handle, |
void * | data, | ||
unsigned | size | ||
) | [protected, virtual] |
Receive data from the remote host.
- Parameters:
-
handle Socket handle data The buffer in which to store the data received from the host size The maximum length of the buffer
- Returns:
- Number of received bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 189 of file C027Interface.cpp.
int socket_recvfrom | ( | void * | handle, |
SocketAddress * | address, | ||
void * | buffer, | ||
unsigned | size | ||
) | [protected, virtual] |
Receive a packet from a remote endpoint.
- Parameters:
-
handle Socket handle address Destination for the remote SocketAddress or null buffer The buffer for storing the incoming packet data If a packet is too long to fit in the supplied buffer, excess bytes are discarded size The length of the buffer
- Returns:
- the number of received bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 224 of file C027Interface.cpp.
int socket_send | ( | void * | handle, |
const void * | data, | ||
unsigned | size | ||
) | [protected, virtual] |
Send data to the remote host.
- Parameters:
-
handle Socket handle data The buffer to send to the host size The length of the buffer to send
- Returns:
- Number of written bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 175 of file C027Interface.cpp.
int socket_sendto | ( | void * | handle, |
const SocketAddress & | address, | ||
const void * | data, | ||
unsigned | size | ||
) | [protected, virtual] |
Send a packet to a remote endpoint.
- Parameters:
-
handle Socket handle address The remote SocketAddress data The packet to be sent size The length of the packet to be sent
- Returns:
- the number of written bytes on success, negative on failure
- Note:
- This call is not-blocking, if this call would block, must immediately return NSAPI_ERROR_WOULD_WAIT
Definition at line 209 of file C027Interface.cpp.
Generated on Thu Jul 14 2022 12:52:56 by 1.7.2