Multitech + KL46Z NanoService example with the RTOS

Dependencies:   mbed SocketModem nanoservice_client_1_12

Files at this revision

API Documentation at this revision

Comitter:
zdshelby
Date:
Tue Feb 18 01:02:16 2014 +0000
Parent:
3:1e981a0aebfb
Child:
5:6adec9967f93
Commit message:
- Added manual nanoservice library import

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
nanoservice_client_1_12.lib Show annotated file Show diff for this revision Revisions of this file
nsdl_lib.lib Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Feb 17 22:50:23 2014 +0000
+++ b/main.cpp	Tue Feb 18 01:02:16 2014 +0000
@@ -9,6 +9,8 @@
 #include "MTSSerialFlowControl.h"
 
 // NanoService includes
+#include "sn_nsdl.h"
+#include "sn_coap_header.h"
 
 using namespace mts;
 
@@ -80,6 +82,16 @@
     DEBUG("TCP connection to NSP successful.");  
 }
 
+extern "C" void *nsdl_alloc(uint16_t size)
+{
+    return malloc(size);
+}
+
+extern "C" void nsdl_free(void* ptr_to_free)
+{
+    free(ptr_to_free);
+}
+
 void socket_event_loop()
 {
     //sn_nsdl_addr_s received_packet_address;
@@ -89,6 +101,7 @@
     //memset(&received_packet_address, 0, sizeof(sn_nsdl_addr_s));
     //received_packet_address.addr_ptr = received_address; 
 
+    DEBUG("Starting socket read loop...");
     while(1)
     {
         int n = cellular->read(buffer, sizeof(buffer), -1);
@@ -115,6 +128,9 @@
     // Bind the socket and configure NSP settings
     nsp_init();
     
+    // Initalize NanoService library
+    sn_coap_builder_and_parser_init(&nsdl_alloc, &nsdl_free);
+    
     // Start socket listening loop
     socket_event_loop();
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nanoservice_client_1_12.lib	Tue Feb 18 01:02:16 2014 +0000
@@ -0,0 +1,1 @@
+nanoservice_client_1_12#aafd54b05111
--- a/nsdl_lib.lib	Mon Feb 17 22:50:23 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/teams/Sensinode/code/nsdl_lib/#050d0f54a0dc