LED Demo for Tech Con 2014

Dependencies:   EthernetInterface PololuLedStripx mbed-rtos mbed nanoservice_client_1_12_X

Fork of LPC1768_LWM2M_Client by MBED_DEMOS

Files at this revision

API Documentation at this revision

Comitter:
michaeljkoster
Date:
Sun Sep 28 23:59:14 2014 +0000
Parent:
6:30232e15ea5f
Child:
8:1358fc888c9c
Commit message:
Working on problem with slow or no response to received packets. UDP socket not returning anything or returning zero bytes in non blocking mode

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
nsdl_support.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Sep 28 03:15:49 2014 +0000
+++ b/main.cpp	Sun Sep 28 23:59:14 2014 +0000
@@ -32,7 +32,7 @@
 //static const char* NSP_ADDRESS = "192.168.1.200"; 
 static const int NSP_PORT = 5683;
 char endpoint_name[24] = "LED-booth-";
-uint8_t ep_type[] = {"mbed_device"};
+uint8_t ep_type[] = {"LED-STRIP"};
 uint8_t lifetime_ptr[] = {"60"};
 char mac[6];
 char macstring[13] ;
@@ -65,6 +65,10 @@
 
 UDPSocket server;
 Endpoint nsp;
+
+bool UDP_blocking = false;
+unsigned int UDP_timeout = 1000;
+
 char * ipstring;
 char * uid;
 
@@ -72,6 +76,9 @@
 {
     server.init();
     server.bind(NSP_PORT);
+    
+    /* server.set_blocking(UDP_blocking, UDP_timeout); */
+
 
     nsp.set_address(NSP_ADDRESS, NSP_PORT);
     
--- a/nsdl_support.cpp	Sun Sep 28 03:15:49 2014 +0000
+++ b/nsdl_support.cpp	Sun Sep 28 23:59:14 2014 +0000
@@ -27,7 +27,7 @@
 extern uint8_t lifetime_ptr[];
 char null_ep_name[] = "";
 uint8_t null_ep_type[] = "";
-uint8_t null_lifetime_ptr[] = "";
+uint8_t null_lifetime_ptr[] = "60";
 bool nsdl_reg_update_needed = false;
 
 /* The number of seconds between NSP registration messages */
@@ -189,11 +189,12 @@
     while(1)
     {
         int n = server.receiveFrom(from, buffer, sizeof(buffer));
+        pc.printf("receive:\r\n");
         if (n < 0)
         {
             pc.printf("Socket error\n\r");
         }
-        else
+        else if (n > 0)
         {   
             pc.printf("Received %d bytes\r\n", n);
             sn_nsdl_process_coap((uint8_t*)buffer, n, &received_packet_address);