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:
98:56e429670fdb
Parent:
97:b141b6b8b37f
Child:
99:7f563f0a6c3c
--- a/source/ConnectorEndpoint.cpp	Thu Apr 20 20:15:48 2017 +0000
+++ b/source/ConnectorEndpoint.cpp	Thu Apr 20 20:42:25 2017 +0000
@@ -201,9 +201,7 @@
 // Connector::Endpoint: create our interface
 void Endpoint::createEndpointInterface() {
 #ifdef ENABLE_MBED_CLOUD_SUPPORT
-	if (this->initializeStorage() && this->initializeFactoryFlow()) {
-		this->createCloudEndpointInterface();
-	}
+	this->createCloudEndpointInterface();
 #else
 	this->createConnectorEndpointInterface();
 #endif
@@ -259,7 +257,14 @@
 // mbedCloudClient: create our interface
 void Endpoint::createCloudEndpointInterface() {
 	if (this->m_endpoint_interface == NULL) {
-		this->m_endpoint_interface = &__mbed_cloud_client;
+		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);
+        }
 	}
 	
 	// bind LWIP network interface pointer...                                          
@@ -430,6 +435,18 @@
     }
     printf("Connector::Endpoint(Cloud) Error(%x): %s\r\n",error_code,error);
 }
+
+// mbed-cloud-client: update_authorized
+void Endpoint::update_authorize(int32_t request) {
+	// simple debug for now...
+	printf("Connector::Endpoint(Cloud) Update Authorize: request: %d\n",request);
+}
+	
+// mbed-cloud-client: update_progress
+void Endpoint::update_progress(uint32_t progress, uint32_t total) {
+	// simple debug for now...
+	printf("Connector::Endpoint(Cloud) Update Progress: (%d/%d)\n",progress,total);
+}
 #endif
 
 // mbed-client: Callback from mbed client stack if any error is encountered