Nespresso coffee demo working on the Arch Pro

Dependencies:   EthernetInterface mbed-rtos mbed nsdl rgb_sensor_buffer

Fork of mbed_nsdl by Nespresso RGB Sensor

Revision:
9:9d5b0c43579b
Parent:
8:27e94f52810b
Child:
11:2a853cd96bf7
--- a/main.cpp	Mon Sep 15 14:14:44 2014 +0000
+++ b/main.cpp	Wed Oct 29 18:28:59 2014 +0000
@@ -1,10 +1,12 @@
 #include "mbed.h"
+#include "MODSERIAL.h"
 #include "EthernetInterface.h"
 #include "nsdl_support.h"
 #include "dbg.h"
 #include "buffered_rgb_resource.h"
+#include "beacon_resource.h"
 
-Serial pc(USBTX, USBRX); // tx, rx
+MODSERIAL console(USBTX, USBRX); // tx, rx
 
 // ****************************************************************************
 // Configuration section
@@ -19,8 +21,8 @@
 #define GW      "10.45.0.1"
 
 // NSP configuration
-/* Change this IP address to that of your NanoService Platform installation */
-static const char* NSP_ADDRESS = "23.99.96.113";
+/* Change this create_beacon_resource IP address to that of your NanoService Platform installation */
+static const char* NSP_ADDRESS = "191.239.5.150";
 static const int NSP_PORT = 5683;
 char endpoint_name[] = "nespresso-client";
 uint8_t ep_type[] = {"mbed_device"};
@@ -40,10 +42,9 @@
 #else
     eth.init(IP, MASK, GW);
 #endif
-    if(eth.connect(30000) == 0) 
-    {
-        pc.printf("Connect OK\n\r");
-    } 
+    if(eth.connect(30000) == 0) {
+        console.printf("Connect OK\n\r");
+    }
 
     NSDL_DEBUG("IP Address:%s ", eth.getIPAddress());
 }
@@ -60,7 +61,7 @@
     server.bind(NSP_PORT);
 
     nsp.set_address(NSP_ADDRESS, NSP_PORT);
-    
+
     NSDL_DEBUG("name: %s", endpoint_name);
     NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT);
 }
@@ -72,7 +73,7 @@
 {
     sn_nsdl_resource_info_s *resource_ptr = NULL;
     sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
-    
+
     NSDL_DEBUG("Creating resources");
 
     /* Create resources */
@@ -82,22 +83,21 @@
     memset(resource_ptr, 0, sizeof(sn_nsdl_resource_info_s));
 
     resource_ptr->resource_parameters_ptr = (sn_nsdl_resource_parameters_s*)nsdl_alloc(sizeof(sn_nsdl_resource_parameters_s));
-    if(!resource_ptr->resource_parameters_ptr)
-    {
+    if(!resource_ptr->resource_parameters_ptr) {
         nsdl_free(resource_ptr);
         return 0;
     }
     memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
 
-    //create_nespresso_resource(resource_ptr);
+    create_beacon_resource(resource_ptr);
     create_buffered_rgb_resource(resource_ptr);
 
     /* Register with NSP */
     endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
     if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
-        pc.printf("NSP registering failed\r\n");
+        console.printf("NSP registering failed\r\n");
     else
-        pc.printf("NSP registering OK\r\n");
+        console.printf("NSP registering OK\r\n");
     nsdl_clean_register_endpoint(&endpoint_ptr);
 
     nsdl_free(resource_ptr->resource_parameters_ptr);
@@ -110,28 +110,28 @@
 
 int main()
 {
-    pc.baud(115200);
+    console.baud(115200);
 
     // Initialize Ethernet interface first
-    pc.printf("Initializing ethernet... ");
+    console.printf("Initializing ethernet... ");
     ethernet_init();
-    pc.printf("done.\r\n");
-        
+    console.printf("done.\r\n");
+
     // Initialize NSP node
-    pc.printf("Initializing nsp node... ");
+    console.printf("Initializing nsp node... ");
     nsp_init();
-    pc.printf("done.\r\n");
-    
+    console.printf("done.\r\n");
+
     // Initialize NSDL stack
-    pc.printf("Initializing NSDL stack... ");    
+    console.printf("Initializing NSDL stack... ");
     nsdl_init();
-    pc.printf("done.\r\n");
-    
+    console.printf("done.\r\n");
+
     // Create NSDL resources
-    pc.printf("Initializing resources... ");    
+    console.printf("Initializing resources... ");
     create_resources();
-    pc.printf("done.\r\n");
-    
+    console.printf("done.\r\n");
+
     // Run the NSDL event loop (never returns)
     nsdl_event_loop();
 }