Pelion workshop with Grove sensors.

Revision:
6:254a7e7fbef1
Parent:
5:c18fab181ede
Child:
8:ace9e5de6491
--- a/main.cpp	Wed Feb 14 17:26:42 2018 -0600
+++ b/main.cpp	Thu Feb 15 10:14:35 2018 -0600
@@ -111,9 +111,6 @@
         printf("IP address %s\n", ip_addr);
     }
 
-    // Placeholder for callback to update local resource when GET comes.
-    timer.attach(&button_press, 5.0);
-
     SimpleMbedCloudClient mbedClient(&net);
     // Save pointer to mbedClient so that other functions can access it.
     client = &mbedClient;
@@ -144,6 +141,14 @@
 
     mbedClient.register_and_connect();
 
+    // Wait for client to finish registering
+    while (!mbedClient.is_client_registered()) {
+        wait_ms(100);
+    }
+
+    // Placeholder for callback to update local resource when GET comes.
+    timer.attach(&button_press, 5.0);
+
     // Check if client is registering or registered, if true sleep and repeat.
     while (mbedClient.is_register_called()) {
         static int button_count = 0;