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

Revision:
16:d6812604cf92
Parent:
4:727f1aeb717a
--- a/main.cpp	Tue Jun 17 11:05:13 2014 +0000
+++ b/main.cpp	Wed Jun 18 03:29:01 2014 +0000
@@ -16,6 +16,7 @@
 #include "mbed.h"
 #include "cc3000.h"
 #include "main.h"
+#include "UDPSocket.h"
 #include "TCPSocketConnection.h"
 #include "TCPSocketServer.h"
 #include "nsdl_support.h"
@@ -57,6 +58,21 @@
 
 TCPSocketConnection socket;
 
+UDPSocket server;
+Endpoint nsp;
+
+#define MEM_VALID(x) \
+    int s##x=0;\
+    int *h##x = new int [1];\
+    std::printf("[stack]0x%08x\t[heap]0x%08x\t[memory avail]%d bytes \tLine: %d %s\r\n", &s##x, h##x, &s##x-h##x, __LINE__, __FILE__);\
+    if (h##x > &s##x)\
+    printf("collision\n");\
+    else\
+    delete [] h##x;\
+    __nop()
+    
+extern "C" void HardFault_Handler(void){MEM_VALID(0); printf("hard faulted - doh!\r\n"); while(1);}
+
 Serial pc(USBTX, USBRX);
 
 // Slide sensor
@@ -450,7 +466,7 @@
     // Unlock I2C bus if blocked by a device
     I2C_busreset();
 
-    pc.baud(115200);
+//    pc.baud(115200);
 
     // set current to 500mA since we're turning on the Wi-Fi
     Batt.init(CHRG_500MA);
@@ -575,7 +591,7 @@
 
     printf("\r\nAttempting SSID Connection. \r\n");
     if (wifi.connect() == -1) {
-        printf("Failed to connect. Please verify connection details and try again. \r\n");
+        error("Failed to connect. Please verify connection details and try again. \r\n");
     } else {
         printf("Connected - IP address: %s \r\n",wifi.getIPAddress());
     }