mbed Connector Interface simplification API on top of mbed-client

Fork of mbedConnectorInterfaceV3 by Doug Anson

NOTE:

This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!

Revision:
61:d02cd5e2bb26
Parent:
60:0d9e607dd678
Child:
62:e5882bd28210
--- a/source/ConnectorEndpoint.cpp	Tue Aug 09 23:46:16 2016 +0000
+++ b/source/ConnectorEndpoint.cpp	Wed Aug 10 00:13:44 2016 +0000
@@ -177,43 +177,44 @@
 	}
 	
 	// DEBUG
-	this->logger()->log("Connector::Endpoint: listening port: %d",listening_port);
+	//this->logger()->log("Connector::Endpoint: listening port: %d",listening_port);
 	
-	// Binding Mode - TCP or UDP
-	M2MInterface::BindingMode network_protocol = M2MInterface::UDP;
-	if (this->m_options->getCoAPConnectionType() == COAP_TCP)  network_protocol = M2MInterface::TCP;
+	// Socket protocol type: TCP or UDP
+	M2MInterface::BindingMode socket_protocol_type = M2MInterface::UDP;
+	if (this->m_options->getCoAPConnectionType() == COAP_TCP)  socket_protocol_type = M2MInterface::TCP;
 	
-	// Network Type IPv4 or IPv6
-	M2MInterface::NetworkStack ip_address_type = M2MInterface::LwIP_IPv4;
-	if (this->m_options->getIPAddressType() == IP_ADDRESS_TYPE_IPV6) {
-		ip_address_type = M2MInterface::LwIP_IPv6;
+	// Socket address type: IPv4 or IPv6
+	M2MInterface::NetworkStack socket_address_type = M2MInterface::LwIP_IPv4;
+	if (this->m_options->getIPAddressType() == socket_address_type_IPV6) {
+		// IPv6 mode for the socket addressing type... 
+		socket_address_type = M2MInterface::LwIP_IPv6;
 		
-		// OVERRIDE (until patched in mbed-client)
 #if defined (IPV4_OVERRIDE)
-		// mbed-client does not support IPv6 directly... so we have to reset this back
-		this->logger()->log("Connector::Endpoint: IP Address Type: IPv4 (IPv6 OVERRIDE)");
-		ip_address_type = M2MInterface::LwIP_IPv4;
+		// OVERRIDE (until patched...)
+		this->logger()->log("Connector::Endpoint: Socket Address Type: IPv4 (IPv6 OVERRIDE)");
+		socket_address_type = M2MInterface::LwIP_IPv4;
 #endif
 	}
 	
 	// DEBUG
-	if (network_protocol == M2MInterface::TCP) this->logger()->log("Connector::Endpoint: Underlying Protocol: TCP");
-	if (network_protocol == M2MInterface::UDP) this->logger()->log("Connector::Endpoint: Underlying Protocol: UDP");
-	if (ip_address_type == M2MInterface::LwIP_IPv4) this->logger()->log("Connector::Endpoint: IP Address Type: IPv4");
-	if (ip_address_type == M2MInterface::LwIP_IPv6) this->logger()->log("Connector::Endpoint: IP Address Type: IPv6");
+	if (socket_protocol_type == M2MInterface::TCP) this->logger()->log("Connector::Endpoint: Socket Protocol: TCP");
+	if (socket_protocol_type == M2MInterface::UDP) this->logger()->log("Connector::Endpoint: Socket Protocol: UDP");
+	if (socket_address_type == M2MInterface::LwIP_IPv4) this->logger()->log("Connector::Endpoint: Socket Address Type: IPv4");
+	if (socket_address_type == M2MInterface::LwIP_IPv6) this->logger()->log("Connector::Endpoint: Socket Address Type: IPv6");
 	
-	// Create the  M2M Interface instance
+	// Create the endpoint M2MInterface instance
     this->m_endpoint_interface = M2MInterfaceFactory::create_interface(*this,
-                                              (char *)this->m_options->getEndpointNodename().c_str(),
-                                              (char *)this->m_options->getEndpointType().c_str(),
-                                              (int32_t)this->m_options->getLifetime(),
-                                              listening_port,									// listening port
-                                              (char *)this->m_options->getDomain().c_str(),
-                                              network_protocol,									// CoAP over UDP or TCP...
-                                              ip_address_type,									// IPv4 addressing or IPv6 addressing
-                                              CONTEXT_ADDRESS_STRING							// context address string
+                                              (char *)this->m_options->getEndpointNodename().c_str(),	// endpoint name
+                                              (char *)this->m_options->getEndpointType().c_str(),		// endpoint type
+                                              (int32_t)this->m_options->getLifetime(),					// registration lifetime (in seconds)
+                                              listening_port,											// listening port (ephemeral...)
+                                              (char *)this->m_options->getDomain().c_str(),				// endpoint domain
+                                              socket_protocol_type,										// Socket protocol type: UDP or TCP...
+                                              socket_address_type,										// Socket addressing type: IPv4 or IPv6 
+                                              CONTEXT_ADDRESS_STRING									// context address string (mbedConnectorInterface.h)
                                               );									
-                                              
+    
+    // bind LWIP network interface pointer...                                          
 	if (__network_interface != NULL && this->m_endpoint_interface != NULL) {
 		this->logger()->log("Connector::Endpoint: binding LWIP network instance...");
 		this->m_endpoint_interface->set_platform_network_handler((void *)__network_interface);