Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SocketModem nanoservice_client_1_12
Diff: main.cpp
- Revision:
- 5:6adec9967f93
- Parent:
- 4:5bfd59673a99
- Child:
- 7:d2c5894dcd5e
--- a/main.cpp Tue Feb 18 01:02:16 2014 +0000
+++ b/main.cpp Tue Feb 18 01:10:21 2014 +0000
@@ -11,6 +11,9 @@
// NanoService includes
#include "sn_nsdl.h"
#include "sn_coap_header.h"
+#include "sn_coap_protocol.h"
+#include "sn_nsdl_lib.h"
+#include <stdint.h>
using namespace mts;
@@ -92,6 +95,34 @@
free(ptr_to_free);
}
+static uint8_t tx_cb(sn_nsdl_capab_e protocol, uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr)
+{
+ DEBUG("TX callback!\n\rSending %d bytes", data_len);
+
+ if(cellular->write((char*)data_ptr, data_len, -1) != data_len)
+ DEBUG("sending failed");
+
+ return 1;
+}
+
+static uint8_t rx_cb(sn_coap_hdr_s *coap_packet_ptr, sn_nsdl_addr_s *address_ptr)
+{
+ DEBUG("RX callback!");
+ return 0;
+}
+
+void nsdl_init()
+{
+ sn_nsdl_mem_s memory_cbs;
+ memory_cbs.sn_nsdl_alloc = &nsdl_alloc;
+ memory_cbs.sn_nsdl_free = &nsdl_free;
+ if(sn_nsdl_init(&tx_cb, &rx_cb, &memory_cbs) == -1) {
+ DEBUG("libNsdl init failed");
+ } else {
+ DEBUG("libNsdl init done");
+ }
+}
+
void socket_event_loop()
{
//sn_nsdl_addr_s received_packet_address;
@@ -129,10 +160,9 @@
nsp_init();
// Initalize NanoService library
- sn_coap_builder_and_parser_init(&nsdl_alloc, &nsdl_free);
-
+ nsdl_init();
+
// Start socket listening loop
socket_event_loop();
-
-
+
}
