#include <m2mconnectionhandler.h>
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, SOCKET_TIMEOUT = -13 } |
enum | SocketPriority { DEFAULT_PRIORITY = 0, HIGH_PRIORITY = 10, ALERT_PRIORITY = 46 } |
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, bool is_server_ping=false) |
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'. | |
bool | set_socket_priority (M2MConnectionHandler::SocketPriority priority) |
Set socket priority. More... | |
void | store_cid () |
Stores CID persistently for DTLS connections. | |
void | remove_cid () |
Removes CID for DTLS connections. | |
bool | is_cid_available () |
Status of CID availability in client. More... | |
void | set_cid_value (const uint8_t *data_ptr, const size_t data_len) |
Internal test function. Set CID for current tls session. More... | |
Friends | |
class | Test_M2MConnectionHandler |
class | Test_M2MConnectionHandler_mbed |
class | Test_M2MConnectionHandler_linux |
class | M2MConnection_TestObserver |
This class handles the socket connection for the LWM2M Client.
This enum defines an error that can come from the socket read and write operation.
This enum defines priority for the socket. Used for setting traffic class socket option.
bool M2MConnectionHandler::bind_connection | ( | const uint16_t | listen_port | ) |
This binds the socket connection.
listen_port | The port to be listened to for an incoming connection. |
void M2MConnectionHandler::force_close | ( | ) |
Closes the open connection.
void M2MConnectionHandler::handle_connection_error | ( | int | error | ) |
Error handling for DTLS connectivity.
error | An error code from the TLS library. |
bool M2MConnectionHandler::is_cid_available | ( | ) |
Status of CID availability in client.
bool M2MConnectionHandler::resolve_server_address | ( | const String & | server_address, |
const uint16_t | server_port, | ||
M2MConnectionObserver::ServerType | server_type, | ||
const M2MSecurity * | security, | ||
bool | is_server_ping = false |
||
) |
This resolves the server address. The output is returned through a callback.
String | The server address. |
uint16_t | The server port. |
ServerType | The server type to be resolved. |
security | The M2MSecurity object that determines which type of secure connection is used by the socket. |
is_server_ping | Defines whether the call is for Server ping or not. |
bool M2MConnectionHandler::send_data | ( | uint8_t * | data_ptr, |
uint16_t | data_len, | ||
sn_nsdl_addr_s * | address_ptr | ||
) |
Sends data to the connected server.
data_ptr | The data to be sent. |
data_len | The length of data to be sent. |
address_ptr | The address structure to which the data needs to be sent. |
void M2MConnectionHandler::set_cid_value | ( | const uint8_t * | data_ptr, |
const size_t | data_len | ||
) |
Internal test function. Set CID for current tls session.
data_ptr | CID |
data_len | length of the CID |
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.
handler | A 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::set_socket_priority | ( | M2MConnectionHandler::SocketPriority | priority | ) |
Set socket priority.
bool M2MConnectionHandler::start_listening_for_data | ( | ) |
Listens to the incoming data from a remote server.