Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-client by
Revision 5:e36098b177a4, committed 2016-04-07
- Comitter:
- Yogesh Pande
- Date:
- Thu Apr 07 01:54:45 2016 +0300
- Parent:
- 4:ae5178938864
- Commit message:
- Adding support for passing NetworkInterface to setup sockets.
Modifying ConnectionHandler API to handle blocking socket calls with timeouts.
Changed in this revision
--- a/mbed-client/m2mconnectionhandler.h Sat Apr 02 00:31:13 2016 +0300
+++ b/mbed-client/m2mconnectionhandler.h Thu Apr 07 01:54:45 2016 +0300
@@ -115,9 +115,11 @@
* is used by the security classes to receive raw data to be decrypted.
* \param buf Buffer to send.
* \param len The length of the buffer.
- * \return Number of bytes read or -1 if failed.
+ * \param timeout Timeout defined from DTLS to wait for blocking receive calls
+ * before timing out, by default value is 0.
+ * \return Number of bytes read or negative number if failed.
*/
- int receive_from_socket(unsigned char *buf, size_t len);
+ int receive_from_socket(unsigned char *buf, size_t len, uint32_t timeout = 0);
/**
* \brief Closes the open connection.
@@ -130,6 +132,15 @@
*/
void handle_connection_error(int error);
+ /**
+ * \brief Sets the network interface handler that is used by client to connect
+ * to a network over IP..
+ * \param handler A network interface handler that is used by client to connect.
+ * This API is optional but provides a mechanism for different platforms to
+ * manage usage of underlying network interface by client.
+ */
+ void set_platform_network_handler(void *handler = NULL);
+
private:
M2MConnectionObserver &_observer;
--- a/mbed-client/m2minterface.h Sat Apr 02 00:31:13 2016 +0300
+++ b/mbed-client/m2minterface.h Thu Apr 07 01:54:45 2016 +0300
@@ -147,6 +147,14 @@
*/
virtual void set_queue_sleep_handler(callback_handler handler) = 0;
+ /**
+ * \brief Sets the network interface handler that is used by client to connect
+ * to a network over IP..
+ * \param handler A network interface handler that is used by client to connect.
+ * This API is optional but provides a mechanism for different platforms to
+ * manage usage of underlying network interface by client.
+ */
+ virtual void set_platform_network_handler(void *handler = NULL) = 0;
};
#endif // M2M_INTERFACE_H
--- a/source/include/m2minterfaceimpl.h Sat Apr 02 00:31:13 2016 +0300
+++ b/source/include/m2minterfaceimpl.h Thu Apr 07 01:54:45 2016 +0300
@@ -135,6 +135,15 @@
*/
virtual void set_queue_sleep_handler(callback_handler handler);
+ /**
+ * @brief Sets the network interface handler that is used by client to connect
+ * to a network over IP..
+ * @param handler A network interface handler that is used by client to connect.
+ * This API is optional but provides a mechanism for different platforms to
+ * manage usage of underlying network interface by client.
+ */
+ virtual void set_platform_network_handler(void *handler = NULL);
+
protected: // From M2MNsdlObserver
virtual void coap_message_ready(uint8_t *data_ptr,
--- a/source/include/m2mnsdlinterface.h Sat Apr 02 00:31:13 2016 +0300
+++ b/source/include/m2mnsdlinterface.h Thu Apr 07 01:54:45 2016 +0300
@@ -305,8 +305,8 @@
sn_nsdl_addr_s _sn_nsdl_address;
nsdl_s *_nsdl_handle;
uint32_t _counter_for_nsdl;
- uint16_t _register_id;
- uint16_t _unregister_id;
+ int32_t _register_id;
+ int32_t _unregister_id;
uint16_t _update_id;
uint16_t _bootstrap_id;
--- a/source/m2minterfaceimpl.cpp Sat Apr 02 00:31:13 2016 +0300
+++ b/source/m2minterfaceimpl.cpp Thu Apr 07 01:54:45 2016 +0300
@@ -259,6 +259,14 @@
_callback_handler = handler;
}
+void M2MInterfaceImpl::set_platform_network_handler(void *handler)
+{
+ tr_debug("M2MInterfaceImpl::set_platform_network_handler()");
+ if(_connection_handler) {
+ _connection_handler->set_platform_network_handler(handler);
+ }
+}
+
void M2MInterfaceImpl::coap_message_ready(uint8_t *data_ptr,
uint16_t data_len,
sn_nsdl_addr_s *address_ptr)
