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:
110:0af085ececd2
Parent:
109:e3fc9140cbbf
Child:
111:9407038559f7
--- a/source/ConnectorEndpoint.cpp	Wed Apr 26 03:11:06 2017 +0000
+++ b/source/ConnectorEndpoint.cpp	Wed Apr 26 04:23:14 2017 +0000
@@ -62,36 +62,46 @@
 		__endpoint = (Connector::Endpoint *)utils_init_endpoint(canActAsRouterNode);
 	}
 	
-	// set the device manager
-	if (device_manager != NULL) {
-		// device manager has been supplied
-		printf("Connector::Endpoint::plumbNetwork: setting a device manager...\r\n");
-		__endpoint->setDeviceManager(device_manager);
+	// make sure we have an endpoint...
+	if (__endpoint != NULL) {
+		// set the device manager
+		if (device_manager != NULL) {
+			// device manager has been supplied
+			printf("Connector::Endpoint::plumbNetwork: setting a device manager...\r\n");
+			__endpoint->setDeviceManager(device_manager);
+		}
+	
+	    // configure the endpoint...
+	    printf("Connector::Endpoint::plumbNetwork: configuring endpoint...\r\n");
+	    utils_configure_endpoint((void *)__endpoint);
+	    
+	    // plumb the endpoint's network...
+		printf("Connector::Endpoint::plumbNetwork: plumbing network...\r\n");
+		net_plumb_network((void *)__endpoint);
 	}
-	else {
-		// no device manager supplied
-		printf("Connector::Endpoint::plumbNetwork: no device manager supplied (OK)\r\n");
-	}
-
-    // configure the endpoint...
-    printf("Connector::Endpoint::plumbNetwork: configuring endpoint...\r\n");
-    utils_configure_endpoint((void *)__endpoint);
-    
-    // plumb the endpoint's network...
-	printf("Connector::Endpoint::plumbNetwork: plumbing network...\r\n");
-	net_plumb_network((void *)__endpoint);
 }
 
 // STATIC: Finalize the endpoint's configuration and begin the endpoint's main even loop (static, not tied into Logger)
 void Endpoint::start()
 {
-    // build out the endpoint with its configuration...
-    printf("Connector::Endpoint::start: building out endpoint...\r\n");
-    utils_build_endpoint((void *)__endpoint);
-    
-    // finalize the endpoint and start its main loop
-    printf("Endpoint::start: finalize and run the endpoint main loop..\r\n");
-	net_finalize_and_run_endpoint_main_loop((void *)__endpoint);
+    if (__endpoint != NULL) {
+	    // build out the endpoint with its configuration...
+	    printf("Connector::Endpoint::start: building out endpoint...\r\n");
+	    utils_build_endpoint((void *)__endpoint);
+	    
+	    // finalize the endpoint and start its main loop
+	    printf("Endpoint::start: finalize and run the endpoint main loop..\r\n");
+		net_finalize_and_run_endpoint_main_loop((void *)__endpoint);
+	}
+	else {
+		// not starting the endpoint due to errors
+		printf("Connector::Endpoint::start: Not starting endpoint due to errors... exiting...\r\n");
+		
+		// end in error... 
+		while(true) {
+			Thread::wait(1000);
+		}
+	}
 }
 
 // STATIC: Set the ConnectionStatusInterface Implementation instance
@@ -218,7 +228,7 @@
 	// Resets storage to an empty state.
 	// Use this function when you want to clear SD card from all the factory-tool generated data and user data.
 	// After this operation device must be injected again by using factory tool or developer certificate.
-#ifdef RESET_STORAGE
+#ifdef MBED_RESET_STORAGE
     this->logger()->log("initializeStorage: Resetting storage to an empty state...");
     mfcc_status_e delete_status = mfcc_storage_delete();
     if (delete_status != MFCC_STATUS_SUCCESS) {