Nespresso RGB Sensor / Mbed 2 deprecated EnvoyNespressoEndpointColorDetectorV2

Dependencies:   ColorDetectorV2 ExternalFlashClient SNICInterface mbed-rtos mbed nsdl

Fork of EnvoyNespressoEndpoint by Nespresso RGB Sensor

Revision:
18:a44666d32c2a
Parent:
16:ff5af00f3fb5
Child:
19:85158f5a7775
--- a/main.cpp	Mon Jul 06 20:12:13 2015 +0000
+++ b/main.cpp	Mon Jul 06 21:13:44 2015 +0000
@@ -159,7 +159,7 @@
     memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
 
     // Dynamic resources
-    create_color_detector_resource(resource_ptr);
+//    create_color_detector_resource(resource_ptr);
 
     // Register with NSP
     register_endpoint(true);
@@ -176,10 +176,10 @@
     uint8_t length = block.data[0];
     memcpy(KEY, &(block.data[1]), length);
     KEY[length] = '\0';
-    
+
     // debug output the entire buffer
-    for (int idx = 0; idx < block.length; idx++)
-    {        // zero out content to verify next read
+    for (int idx = 0; idx < block.length; idx++) {
+        // zero out content to verify next read
         block.data[idx] = 0;
     }
 
@@ -193,13 +193,13 @@
     uint8_t length = block.data[0];
     memcpy(SSID, &(block.data[1]), length);
     SSID[length] = '\0';
-    
+
     // debug output the entire buffer
-    for (int idx = 0; idx < block.length; idx++)
-    {        // zero out content to verify next read
+    for (int idx = 0; idx < block.length; idx++) {
+        // zero out content to verify next read
         block.data[idx] = 0;
     }
-    
+
     wifiProvisioned = true;
 }
 
@@ -210,7 +210,7 @@
 {
     // LED is off when high
     led1 = 1;
-    
+
     // blink LED1
     Ticker ticker;
     ticker.attach(tickerISR, 1.0);
@@ -218,7 +218,7 @@
 
     // Begin Color Sensor init
 
-//    // First, ensure I2C bus is released by toggling clock (fixes reset errors)
+    // First, ensure I2C bus is released by toggling clock (fixes reset errors)
 //    DigitalOut scl_dummy(COLOR_SENSOR_SCL);
 
 //    for (int i = 0; i < 100; i++) {
@@ -226,64 +226,64 @@
 //        wait_us(2);
 //    }
 
-//    // Next, initialize I2C
+    // Next, initialize I2C
 //    I2C i2c(COLOR_SENSOR_SDA, COLOR_SENSOR_SCL);
 
-//    // Create color sensor instance
+    // Create color sensor instance
 //    GroveColourSensor colorSensor(&i2c);
 
-//    // Various config
+    // Various config
 //    colorSensor.powerUp();
 //    colorSensor.setGain(1);
 //    colorSensor.setBlockRead();
 
-//    // Create color detector
+    // Create color detector
 //    ColorDetector detector(&colorSensor, 15, 3, 2, 256, 4);
 //    detector.setBaseline();
 
-//    // Pass reference to color detector
+    // Pass reference to color detector
 //    set_color_detector(&detector);
-//    
+//
     printf("read SSID / KEY from flash\r\n");
     flash.read(SSID_ADDRESS, &block, readDone);
-    
+
     // wait for SSID to be read from Nordic chip
     while(!wifiProvisioned) {
-        //printf("wait\r\n");    
+        //printf("wait\r\n");
     }
-        printf("SSID Provisioned Succesfully: ssid= %s\n\r",SSID);
-        wifiProvisioned = false;
-        wait(1); // Dont know why this has to be here, but it does, if I dont do it it doesnt work.
-        
-        // now read the KEY
+    printf("SSID Provisioned Succesfully: ssid= %s\n\r",SSID);
+    wifiProvisioned = false;
+    wait(1); // Dont know why this has to be here, but it does, if I dont do it it doesnt work.
+
+    // now read the KEY
     flash.read(KEY_ADDRESS, &block, readDone2);
     // wait for SSID to be read from Nordic chip
     while(!wifiProvisioned) {
-        //printf("wait\r\n");    
+        //printf("wait\r\n");
     }
-        
+
     printf("ssid: %s, key: %s\r\n", SSID,KEY);
-    
+
     // Ignore rest of program, just for development, it breaks before you get here
-    while(true) {}
+//    while(true) {}
 
-//    // Initialize Ethernet interface first
-//    ethernet_init();
+    // Initialize Ethernet interface first
+    ethernet_init();
 
-//    // Initialize NSP node
-//    nsp_init();
+    // Initialize NSP node
+    nsp_init();
 
 //    // Initialize NSDL stack
-//    nsdl_init();
+    nsdl_init();
 
-//    // Create NSDL resources
-//    create_resources();
+    // Create NSDL resources
+    create_resources();
 
-//    nsdl_event_loop_init();
+    nsdl_event_loop_init();
 
     while(true) {
-//        // Check if any nsdl events need to be handled
-//        nsdl_event_loop_run_once();
+        // Check if any nsdl events need to be handled
+        nsdl_event_loop_run_once();
 
 //        // Sample the color detector and potentially send samples to mDS
 //        run_color_detector();