frank dunn
/
example-ttn-workshop_c027
example for iot course with c027 and sx1276 module
Diff: main.cpp
- Revision:
- 50:6e615eea1e6f
- Parent:
- 47:b6d132f1079f
- Child:
- 51:623b49958f8d
--- a/main.cpp Wed Mar 06 13:02:08 2019 +0000 +++ b/main.cpp Wed Mar 13 17:30:20 2019 +0000 @@ -21,7 +21,6 @@ #include "events/EventQueue.h" // Application helpers -#include "DummySensor.h" #include "trace_helper.h" #include "lora_radio_helper.h" @@ -50,15 +49,6 @@ */ #define CONFIRMED_MSG_RETRY_COUNTER 3 -/** - * Dummy pin for dummy sensor - */ -#define PC_9 0 - -/** - * Dummy sensor class object - */ -DS1820 ds1820(PC_9); /** * This event queue is the global event queue for both the @@ -152,20 +142,9 @@ { uint16_t packet_len; int16_t retcode; - float sensor_value; + printf("\n\rHello world"); - if (ds1820.begin()) { - ds1820.startConversion(); - sensor_value = ds1820.read(); - printf("\r\n Dummy Sensor Value = %3.1f \r\n", sensor_value); - ds1820.startConversion(); - } else { - printf("\r\n No sensor found \r\n"); - return; - } - - packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %3.1f", - sensor_value); + packet_len = sprintf((char *) tx_buffer, "Hello world"); retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len, MSG_UNCONFIRMED_FLAG); @@ -188,29 +167,6 @@ } /** - * Receive a message from the Network Server - */ -static void receive_message() -{ - uint8_t port; - int flags; - int16_t retcode = lorawan.receive(rx_buffer, sizeof(rx_buffer), port, flags); - - if (retcode < 0) { - printf("\r\n receive() - Error code %d \r\n", retcode); - return; - } - - printf(" RX Data on port %u (%d bytes): ", port, retcode); - for (uint8_t i = 0; i < retcode; i++) { - printf("%02x ", rx_buffer[i]); - } - printf("\r\n"); - - memset(rx_buffer, 0, sizeof(rx_buffer)); -} - -/** * Event handler */ static void lora_event_handler(lorawan_event_t event) @@ -247,7 +203,6 @@ break; case RX_DONE: printf("\r\n Received message from Network Server \r\n"); - receive_message(); break; case RX_TIMEOUT: case RX_ERROR: