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:
105:aeaaee8fbb1d
Parent:
101:305cc6527e20
Child:
106:8c504a89c1dc
--- a/source/ConnectorEndpoint.cpp	Fri Apr 21 03:57:44 2017 +0000
+++ b/source/ConnectorEndpoint.cpp	Mon Apr 24 20:42:24 2017 +0000
@@ -50,11 +50,6 @@
 // LWIP Network interface instance
 NetworkInterface *__network_interface = NULL;
 
-#ifdef ENABLE_MBED_CLOUD_SUPPORT
-// Static mbed endpoint
-static MbedCloudClient __mbed_cloud_client;
-#endif
-
 // Connector namespace
 namespace Connector {
 
@@ -264,12 +259,20 @@
 void Endpoint::createCloudEndpointInterface() {
 	if (this->m_endpoint_interface == NULL) {
 		if (this->initializeStorage() && this->initializeFactoryFlow()) {
-			this->m_endpoint_interface = &__mbed_cloud_client;
-			
-			// enable hooks for Updater support (R1.2+)
-			update_ui_set_cloud_client(&__mbed_cloud_client);
-	        __mbed_cloud_client.set_update_authorize_handler(&Connector::Endpoint::update_authorize);
-	        __mbed_cloud_client.set_update_progress_handler(&Connector::Endpoint::update_progress);
+			// create a new instance of mbedCloudClient
+			this->m_endpoint_interface = new MbedCloudClient();
+			if (this->m_endpoint_interface == NULL) {
+				// unable to allocate the MbedCloudClient instance
+				this->logger()->log("createCloudEndpointInterface: ERROR: unable to allocate MbedCloudClient instance...");
+			}
+			else {
+				// enable hooks for Updater support (R1.2+) (if enabled)
+#ifdef MBED_CLOUD_CLIENT_SUPPORT_UPDATE			
+				update_ui_set_cloud_client(this->m_endpoint_interface);
+		        this->m_endpoint_interface->set_update_authorize_handler(&Connector::Endpoint::update_authorize);
+		        this->m_endpoint_interface->set_update_progress_handler(&Connector::Endpoint::update_progress);
+#endif
+			}
         }
 	}