Demo starter application to connect WiGo to NSP and expose on-board sensors

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket mbed nsdl_lib TEMT6200 TSI Wi-Go_eCompass_Lib_V3 WiGo_BattCharger

This is the mbed project for the IoT World Hackathon event, June 17th and 18th in Palo Also.

The setup instructions for participants are at the Setup page of this wiki:

http://mbed.org/teams/MBED_DEMOS/code/IoT_World_Hackathon_WiGo_NSP_Demo/wiki/Setup-Guide-for-the-IoT-World-Hackathon

Files at this revision

API Documentation at this revision

Comitter:
michaeljkoster
Date:
Fri Jun 13 23:28:26 2014 +0000
Parent:
1:8f4625466fbd
Child:
3:4cfa5d26f35e
Commit message:
Unique EP name from MAC address

Changed in this revision

nsdl_run.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/nsdl_run.cpp	Fri Jun 13 18:46:38 2014 +0000
+++ b/nsdl_run.cpp	Fri Jun 13 23:28:26 2014 +0000
@@ -39,10 +39,13 @@
 //static const char* NSP_ADDRESS = "192.168.1.220"; /* Arndale board running NSP on local network for Hackathon */ 
 static const char* NSP_ADDRESS = "217.140.101.20"; /* public mbed demo server */ 
 static const int NSP_PORT = 5683;
-char endpoint_name[16] = "mbed-TESTNEW";
+char endpoint_name[24] = "mbed-";
 uint8_t ep_type[] = {"mbed_device"};
 uint8_t lifetime_ptr[] = {"120000"}; //30+ hours 
 
+uint8_t myMAC[8];
+char MACstr[20];
+
 // ****************************************************************************
 // Ethernet initialization
 
@@ -71,11 +74,14 @@
 
 //    mbed_interface_uid(mbed_uid);
 // make a unique name from the MAC address
-      pc.printf("MAC: %s\r\n", wifi.getMACAddress());
+      wifi.get_mac_address(myMAC);
+      printf("MAC address %02x:%02x:%02x:%02x:%02x:%02x \r\n", myMAC[0], myMAC[1], myMAC[2], myMAC[3], myMAC[4], myMAC[5]);
+      sprintf(MACstr, "%02X%02X%02X%02X%02X%02X", myMAC[0], myMAC[1], myMAC[2], myMAC[3], myMAC[4], myMAC[5]);
+      pc.printf("MAC: %s", MACstr);
     
 //    mbed_uid[32] = '\0';
 //    strncat(endpoint_name, mbed_uid + 27, 15 - strlen(endpoint_name));
-//    strncat(endpoint_name, wifi.getMACAddress(), 17);
+      strncat(endpoint_name, MACstr, 12);
       pc.printf("EP NAME: %s\r\n",endpoint_name);
 
 //    lcd.locate(0,11);
@@ -129,8 +135,8 @@
     memset(resource_ptr->resource_parameters_ptr, 0, sizeof(sn_nsdl_resource_parameters_s));
 
     // Static resources
-    nsdl_create_static_resource(resource_ptr, sizeof("dev/mfg")-1, (uint8_t*) "dev/mfg", 0, 0,  (uint8_t*) "Sensinode", sizeof("Sensinode")-1);
-    nsdl_create_static_resource(resource_ptr, sizeof("dev/mdl")-1, (uint8_t*) "dev/mdl", 0, 0,  (uint8_t*) "NSDL-C mbed device", sizeof("NSDL-C mbed device")-1);
+    nsdl_create_static_resource(resource_ptr, sizeof("dev/mfg")-1, (uint8_t*) "dev/mfg", 0, 0,  (uint8_t*) "AvnetFreescale", sizeof("AvnetFreescale")-1);
+    nsdl_create_static_resource(resource_ptr, sizeof("dev/mdl")-1, (uint8_t*) "dev/mdl", 0, 0,  (uint8_t*) "WiGoSystem", sizeof("WiGiSystem")-1);
 
     // Dynamic resources
 //    create_temperature_resource(resource_ptr);