NanoService Example for u-blox Cellular modems
Dependencies: Beep LM75B MMA7660 mbed nsdl_lib
Fork of NSDL_HelloWorld by
Revision 9:ccb9e53d5471, committed 2013-10-30
- Comitter:
- zdshelby
- Date:
- Wed Oct 30 00:32:48 2013 +0000
- Parent:
- 8:8452c1eaa690
- Child:
- 10:4cb556c7845e
- Commit message:
- - Attempting to solve debugging issues, no debug available even using plain printf
Changed in this revision
--- a/C12832_lcd.lib Mon Oct 28 19:38:15 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/dreschpe/code/C12832_lcd/#c9afe58d786a
--- a/dbg.h Mon Oct 28 19:38:15 2013 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include "nsdl_support.h"
-#include "mbed.h"
-
-//Debug is disabled by default
-#define DEBUG 1
-
-#if (DEBUG)
-extern Serial pc;
-#define NSDL_DEBUG(x, ...) pc.printf("[NSDL_DEBUG: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
-#else
-#define NSDL_DEBUG(x, ...)
-#endif
-
-#endif
\ No newline at end of file
--- a/main.cpp Mon Oct 28 19:38:15 2013 +0000
+++ b/main.cpp Wed Oct 30 00:32:48 2013 +0000
@@ -5,21 +5,21 @@
#include "Socket.h"
#include "Endpoint.h"
#include "UDPSocket.h"
-#include "C12832_lcd.h"
+// #include "C12832_lcd.h"
#include "nsdl_support.h"
-#include "dbg.h"
// Include various resources
#include "temperature.h"
#include "light.h"
#include "gps.h"
#include "relay.h"
-static C12832_LCD lcd;
-Serial pc(USBTX, USBRX); // tx, rx
+// static C12832_LCD lcd;
// ****************************************************************************
// Configuration section
+#define MODEM_UBLOX_CDMA
+
#ifndef MODEM_APN
#warning APN not specified, using "internet"
#define MODEM_APN "internet"
@@ -72,9 +72,9 @@
int ret = modem.connect(MODEM_APN, MODEM_USERNAME, MODEM_PASSWORD);
if(ret)
{
- NSDL_DEBUG("Could not connect\n");
+ printf("Could not connect\n");
}
- NSDL_DEBUG("Connection OK\n");
+ printf("Connection OK\n");
mbed_interface_uid(mbed_uid);
mbed_uid[32] = '\0';
@@ -93,11 +93,11 @@
nsp.set_address(NSP_ADDRESS, NSP_PORT);
- NSDL_DEBUG("name: %s", endpoint_name);
- NSDL_DEBUG("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT);
+ printf("name: %s", endpoint_name);
+ printf("NSP=%s - port %d\n", NSP_ADDRESS, NSP_PORT);
- lcd.locate(0,22);
- lcd.printf("EP name:%s\n", endpoint_name);
+ // lcd.locate(0,22);
+ // lcd.printf("EP name:%s\n", endpoint_name);
}
// ****************************************************************************
@@ -108,7 +108,7 @@
sn_nsdl_resource_info_s *resource_ptr = NULL;
sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
- NSDL_DEBUG("Creating resources");
+ printf("Creating resources");
/* Create resources */
resource_ptr = (sn_nsdl_resource_info_s*)nsdl_alloc(sizeof(sn_nsdl_resource_info_s));
@@ -137,9 +137,9 @@
/* Register with NSP */
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 registering failed\r\n");
+ printf("NSP registering failed\r\n");
else
- pc.printf("NSP registering OK\r\n");
+ printf("NSP registering OK\r\n");
nsdl_clean_register_endpoint(&endpoint_ptr);
nsdl_free(resource_ptr->resource_parameters_ptr);
@@ -152,10 +152,10 @@
int main()
{
- lcd.cls();
- lcd.locate(0,0);
- lcd.printf("mbed NanoService u-blox");
- NSDL_DEBUG("mbed NanoService u-blox Example App 0.1\n");
+ // lcd.cls();
+ // lcd.locate(0,0);
+ // lcd.printf("mbed NanoService u-blox");
+ printf("mbed NanoService u-blox Example App 0.1\n");
// Initialize Cellular interface first
cellular_init();
--- a/nsdl_support.cpp Mon Oct 28 19:38:15 2013 +0000
+++ b/nsdl_support.cpp Wed Oct 30 00:32:48 2013 +0000
@@ -94,17 +94,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;
}
@@ -117,9 +117,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);
}
}
@@ -133,9 +133,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);
@@ -158,11 +158,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);
}
}
--- a/resources/gps.cpp Mon Oct 28 19:38:15 2013 +0000
+++ b/resources/gps.cpp Wed Oct 30 00:32:48 2013 +0000
@@ -17,7 +17,7 @@
int led_state = 0;
char led_dimm_temp[4];
- pc.printf("gps callback\r\n");
+ printf("gps callback\r\n");
coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
--- a/resources/light.cpp Mon Oct 28 19:38:15 2013 +0000
+++ b/resources/light.cpp Wed Oct 30 00:32:48 2013 +0000
@@ -20,7 +20,7 @@
int led_state = 0;
char led_dimm_temp[4];
- pc.printf("light callback\r\n");
+ printf("light callback\r\n");
if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
{
--- a/resources/relay.cpp Mon Oct 28 19:38:15 2013 +0000
+++ b/resources/relay.cpp Wed Oct 30 00:32:48 2013 +0000
@@ -16,7 +16,7 @@
sn_coap_hdr_s *coap_res_ptr = 0;
static uint8_t relay_state = '0';
- pc.printf("relay callback\r\n");
+ printf("relay callback\r\n");
if(received_coap_ptr->msg_code == COAP_MSG_CODE_REQUEST_GET)
{
--- a/resources/temperature.cpp Mon Oct 28 19:38:15 2013 +0000
+++ b/resources/temperature.cpp Wed Oct 30 00:32:48 2013 +0000
@@ -31,9 +31,9 @@
obs_number++;
sprintf(temp_val,"%2.2f" ,tmp.read());
if(sn_nsdl_send_observation_notification(obs_token_ptr, obs_token_len, (uint8_t*)temp_val, 5, &obs_number, 1, COAP_MSG_TYPE_NON_CONFIRMABLE, 0) == 0)
- pc.printf("Observation sending failed\r\n");
+ printf("Observation sending failed\r\n");
else
- pc.printf("Observation\r\n");
+ printf("Observation\r\n");
}
}
}
@@ -45,7 +45,7 @@
sprintf(temp_val,"%2.2f" ,tmp.read());
sn_coap_hdr_s *coap_res_ptr = 0;
- pc.printf("temp callback\r\n");
+ printf("temp callback\r\n");
coap_res_ptr = sn_coap_build_response(received_coap_ptr, COAP_MSG_CODE_RESPONSE_CONTENT);
coap_res_ptr->payload_len = 5;
@@ -53,7 +53,7 @@
if(received_coap_ptr->token_ptr)
{
- pc.printf("Token included\r\n");
+ printf("Token included\r\n");
if(obs_token_ptr)
{
free(obs_token_ptr);



