NanoService Device Library Hello World Ported to K64F

Dependencies:   EthernetInterface mbed-rtos mbed nsdl_lib

Fork of NSDL_HelloWorld by Sensinode

Revision:
9:16f54efbb5fe
Parent:
8:cdf868ccae03
diff -r cdf868ccae03 -r 16f54efbb5fe main.cpp
--- a/main.cpp	Mon Aug 04 17:00:58 2014 +0000
+++ b/main.cpp	Mon Feb 29 05:09:16 2016 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
-#include "C12832_lcd.h"
+//#include "C12832_lcd.h"
 #include "nsdl_support.h"
 #include "dbg.h"
 // Include various resources
@@ -9,7 +9,7 @@
 #include "gps.h"
 #include "relay.h"
 
-static C12832_LCD lcd;
+// static C12832_LCD lcd;
 Serial pc(USBTX, USBRX); // tx, rx
 
 // ****************************************************************************
@@ -26,9 +26,10 @@
 
 // NSP configuration
 /* Change this IP address to that of your NanoService Platform installation */
-static const char* NSP_ADDRESS = "217.140.101.20"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org */ 
+//static const char* NSP_ADDRESS = "217.140.101.20"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org */ 
+static const char* NSP_ADDRESS = "192.168.0.38"; /* demo NSP, web interface at http://nanoservice-demo.mbed.org */ 
 static const int NSP_PORT = 5683;
-char endpoint_name[16] = "mbed-";
+char endpoint_name[16] = "mbed-clientCoAP";
 uint8_t ep_type[] = {"mbed_device"};
 uint8_t lifetime_ptr[] = {"1200"};
 
@@ -39,7 +40,6 @@
 
 static void ethernet_init()
 {
-    char mbed_uid[33]; // for creating unique name for the board
 
     /* Initialize network */
 #ifdef DHCP
@@ -51,12 +51,8 @@
     if(eth.connect(30000) == 0)
         pc.printf("Connect OK\n\r");
 
-    mbed_interface_uid(mbed_uid);
-    mbed_uid[32] = '\0';
-    strncat(endpoint_name, mbed_uid + 27, 15 - strlen(endpoint_name));
-
-    lcd.locate(0,11);
-    lcd.printf("IP:%s", eth.getIPAddress());
+    //lcd.locate(0,11);
+    //lcd.printf("IP:%s", eth.getIPAddress());
 
     NSDL_DEBUG("IP Address:%s ", eth.getIPAddress());
 }
@@ -77,8 +73,8 @@
     NSDL_DEBUG("name: %s", endpoint_name);
     NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT);
 
-    lcd.locate(0,22);
-    lcd.printf("EP name:%s\n", endpoint_name);
+    //lcd.locate(0,22);
+    //lcd.printf("EP name:%s\n", endpoint_name);
 }
 
 // ****************************************************************************
@@ -133,9 +129,16 @@
 
 int main()
 {
-    lcd.cls();
-    lcd.locate(0,0);
-    lcd.printf("mbed NanoService demo");
+    
+    pc.printf("Starting\r\n");
+    for(int i=15; i > 0; i--){
+        pc.printf("Starting in %d Seconds\r\n", i);
+        wait(1.0);
+    }
+
+    //lcd.cls();
+    //lcd.locate(0,0);
+    //lcd.printf("mbed NanoService demo");
     NSDL_DEBUG("mbed NanoService Example App 0.1\n");
     
     // Initialize Ethernet interface first