Mistake on this page? Email us
M2MConnectionHandler Class Reference

Public Types

enum  ConnectionError {
  ERROR_NONE = 0, ERROR_GENERIC = -1, CONNECTION_ERROR_WANTS_READ = -2, CONNECTION_ERROR_WANTS_WRITE = -3,
  SSL_PEER_CLOSE_NOTIFY = -4, MEMORY_ALLOCATION_FAILED = -5, SSL_CONNECTION_ERROR = -6, SOCKET_READ_ERROR = -7,
  SOCKET_SEND_ERROR = -8, SOCKET_ABORT = -9, DNS_RESOLVING_ERROR = -10, SSL_HANDSHAKE_ERROR = -11,
  FAILED_TO_READ_CREDENTIALS = -12
}
 

Public Member Functions

 M2MConnectionHandler (M2MConnectionObserver &observer, M2MConnectionSecurity *sec, M2MInterface::BindingMode mode, M2MInterface::NetworkStack stack)
 Constructor.
 
 ~M2MConnectionHandler ()
 Destructor.
 
bool bind_connection (const uint16_t listen_port)
 This binds the socket connection. More...
 
bool resolve_server_address (const String &server_address, const uint16_t server_port, M2MConnectionObserver::ServerType server_type, const M2MSecurity *security)
 This resolves the server address. The output is returned through a callback. More...
 
bool send_data (uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr)
 Sends data to the connected server. More...
 
bool start_listening_for_data ()
 Listens to the incoming data from a remote server. More...
 
void stop_listening ()
 Stops listening to the incoming data.
 
void force_close ()
 Closes the open connection. More...
 
void handle_connection_error (int error)
 Error handling for DTLS connectivity. More...
 
void set_platform_network_handler (void *handler=NULL)
 Sets the network interface handler that is used by the client to connect to a network over IP. More...
 
void claim_mutex ()
 Claims mutex to prevent thread clashes in multithreaded environment.
 
void release_mutex ()
 Releases mutex to prevent thread clashes in multithreaded environment.
 
void unregister_network_handler ()
 Unregisters the network interface handler that is set in 'set_platform_network_handler'.
 

Friends

class Test_M2MConnectionHandler
 
class Test_M2MConnectionHandler_mbed
 
class Test_M2MConnectionHandler_linux
 
class M2MConnection_TestObserver
 

Member Enumeration Documentation

This enum defines an error that can come from the socket read and write operation.

Member Function Documentation

bool M2MConnectionHandler::bind_connection ( const uint16_t  listen_port)

This binds the socket connection.

Parameters
listen_portThe port to be listened to for an incoming connection.
Returns
True if successful, else false.
void M2MConnectionHandler::force_close ( )

Closes the open connection.

Note
This must be called from the same event loop context!
void M2MConnectionHandler::handle_connection_error ( int  error)

Error handling for DTLS connectivity.

Parameters
errorAn error code from the TLS library.
bool M2MConnectionHandler::resolve_server_address ( const String server_address,
const uint16_t  server_port,
M2MConnectionObserver::ServerType  server_type,
const M2MSecurity security 
)

This resolves the server address. The output is returned through a callback.

Parameters
StringThe server address.
uint16_tThe server port.
ServerTypeThe server type to be resolved.
securityThe M2MSecurity object that determines which type of secure connection is used by the socket.
Returns
True if the address is valid, else false.
bool M2MConnectionHandler::send_data ( uint8_t *  data_ptr,
uint16_t  data_len,
sn_nsdl_addr_s *  address_ptr 
)

Sends data to the connected server.

Parameters
data_ptrThe data to be sent.
data_lenThe length of data to be sent.
address_ptrThe address structure to which the data needs to be sent.
Returns
True if data is sent successfully, else false.
void M2MConnectionHandler::set_platform_network_handler ( void *  handler = NULL)

Sets the network interface handler that is used by the client to connect to a network over IP.

Parameters
handlerA network interface handler that is used by the client to connect. This API is optional but it provides a mechanism for different platforms to manage the usage of underlying network interface by client.
bool M2MConnectionHandler::start_listening_for_data ( )

Listens to the incoming data from a remote server.

Returns
True if successful, else false.

The documentation for this class was generated from the following file: