#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 } |
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'. | |
| 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. return true if CID is available else false. | |
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.
| 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::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_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::start_listening_for_data | ( | ) |
Listens to the incoming data from a remote server.