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: Beep C027_Support C12832 LM75B MMA7660 mbed-rtos mbed nsdl_lib
This is a port of the NSDL HelloWorld for cellular.
To run the example you need a C027 and the ARM mbed application shield. The example uses cellular instead of ethernet and takes the true position from the GPS instead of using a fixed position.
Diff: nsdl_support.cpp
- Revision:
- 10:443e7f741c8e
- Parent:
- 8:bd9096c4784c
- Child:
- 11:fa12b9f50538
--- a/nsdl_support.cpp Fri Jun 06 15:16:37 2014 +0000 +++ b/nsdl_support.cpp Tue Jun 17 07:05:29 2014 +0000 @@ -6,7 +6,6 @@ #include "UDPSocket.h" #include "rtos.h" -extern Serial pc; extern Endpoint nsp; extern UDPSocket server; extern char endpoint_name[16]; @@ -88,17 +87,17 @@ static uint8_t tx_cb(sn_nsdl_capab_e protocol, uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr) { - pc.printf("TX callback!\n\rSending %d bytes\r\n", data_len); + printf("TX callback!\n\rSending %d bytes\r\n", data_len); if(server.sendTo(nsp, (char*)data_ptr, data_len) != data_len) - pc.printf("sending failed\n\r"); + printf("sending failed\n\r"); return 1; } static uint8_t rx_cb(sn_coap_hdr_s *coap_packet_ptr, sn_nsdl_addr_s *address_ptr) { - pc.printf("RX callback!\r\n"); + printf("RX callback!\r\n"); return 0; } @@ -111,9 +110,9 @@ wait(RD_UPDATE_PERIOD); endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr); if(sn_nsdl_register_endpoint(endpoint_ptr) != 0) - pc.printf("NSP re-registering failed\r\n"); + printf("NSP re-registering failed\r\n"); else - pc.printf("NSP re-registering OK\r\n"); + printf("NSP re-registering OK\r\n"); nsdl_clean_register_endpoint(&endpoint_ptr); } } @@ -127,9 +126,9 @@ 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) - pc.printf("libNsdl init failed\r\n"); + printf("libNsdl init failed\r\n"); else - pc.printf("libNsdl init done\r\n"); + printf("libNsdl init done\r\n"); /* Set nsp address for library */ set_NSP_address(nsp_addr, 5683, SN_NSDL_ADDRESS_TYPE_IPV4); @@ -152,11 +151,11 @@ int n = server.receiveFrom(from, buffer, sizeof(buffer)); if (n < 0) { - pc.printf("Socket error\n\r"); + printf("Socket error\n\r"); } else { - pc.printf("Received %d bytes\r\n", n); + printf("Received %d bytes\r\n", n); sn_nsdl_process_coap((uint8_t*)buffer, n, &received_packet_address); } }