Nespresso RGB Sensor / Mbed 2 deprecated EnvoyNespressoEndpointColorDetectorV2

Dependencies:   ColorDetectorV2 ExternalFlashClient SNICInterface mbed-rtos mbed nsdl

Fork of EnvoyNespressoEndpoint by Nespresso RGB Sensor

Files at this revision

API Documentation at this revision

Comitter:
mbedAustin
Date:
Mon Jul 06 20:10:20 2015 +0000
Parent:
15:cbac93920f30
Child:
17:d947c48b327d
Commit message:
Things may be working now... maybe...

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jul 06 19:37:18 2015 +0000
+++ b/main.cpp	Mon Jul 06 20:10:20 2015 +0000
@@ -21,8 +21,8 @@
 #define COLOR_SENSOR_SDA I2C_SDA
 
 // Envoy Settings
-#define SSID_ADDRESS    0x0100
-#define KEY_ADDRESS     0x0200
+uint32_t SSID_ADDRESS   = 0x0100;
+uint32_t KEY_ADDRESS    = 0x0200;
 
 // Pins and SPI module for the external flash class
 PinName nSCS = D10;
@@ -39,7 +39,7 @@
                   .maxLength = sizeof(readBuffer)
                 };
 
-bool wifiProvisioned = false;
+volatile bool wifiProvisioned = false;
 
 // debug LEDs
 DigitalOut led1(LED1);
@@ -200,9 +200,6 @@
         block.data[idx] = 0;
     }
     
-    // now read the KEY
-    //flash.read(KEY_ADDRESS, &block, readDone2);
-    
     wifiProvisioned = true;
 }
 
@@ -221,65 +218,74 @@
 
     // Begin Color Sensor init
 
-    // First, ensure I2C bus is released by toggling clock (fixes reset errors)
-    DigitalOut scl_dummy(COLOR_SENSOR_SCL);
+//    // 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++) {
-        scl_dummy = !scl_dummy;
-        wait_us(2);
-    }
+//    for (int i = 0; i < 100; i++) {
+//        scl_dummy = !scl_dummy;
+//        wait_us(2);
+//    }
 
-    // Next, initialize I2C
-    I2C i2c(COLOR_SENSOR_SDA, COLOR_SENSOR_SCL);
+//    // Next, initialize I2C
+//    I2C i2c(COLOR_SENSOR_SDA, COLOR_SENSOR_SCL);
 
-    // Create color sensor instance
-    GroveColourSensor colorSensor(&i2c);
+//    // Create color sensor instance
+//    GroveColourSensor colorSensor(&i2c);
 
-    // Various config
-    colorSensor.powerUp();
-    colorSensor.setGain(1);
-    colorSensor.setBlockRead();
+//    // Various config
+//    colorSensor.powerUp();
+//    colorSensor.setGain(1);
+//    colorSensor.setBlockRead();
 
-    // Create color detector
-    ColorDetector detector(&colorSensor, 15, 3, 2, 256, 4);
-    detector.setBaseline();
+//    // Create color detector
+//    ColorDetector detector(&colorSensor, 15, 3, 2, 256, 4);
+//    detector.setBaseline();
 
-    // Pass reference to color detector
-    set_color_detector(&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 wifi to be read from Nordic chip
+    // wait for SSID to be read from Nordic chip
     while(!wifiProvisioned) {
         //printf("wait\r\n");    
     }
-    
-    // print only the ssid
+        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("ssid: %s, key: %s\r\n", SSID,KEY);
     
     // Ignore rest of program, just for development, it breaks before you get here
     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();
+//    // Initialize NSDL stack
+//    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();
+//        // Sample the color detector and potentially send samples to mDS
+//        run_color_detector();
     }
 }