acsip s76g

Dependencies:   TinyGPSPlus

Revision:
52:922d8fdaae44
Parent:
50:6e615eea1e6f
Child:
53:a3344ee53c2c
--- a/main.cpp	Sun Jul 05 13:43:53 2020 +0000
+++ b/main.cpp	Sun Jul 05 20:31:13 2020 +0000
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 #include <stdio.h>
-
+#include "mbed.h"
 #include "lorawan/LoRaWANInterface.h"
 #include "lorawan/system/lorawan_data_structures.h"
 #include "events/EventQueue.h"
@@ -49,7 +49,8 @@
  */
 #define CONFIRMED_MSG_RETRY_COUNTER     3
 
-
+//Serial pc(PC_11,PC_10);
+Serial pc(PA_9,PA_10);
 /**
 * This event queue is the global event queue for both the
 * application and stack. To conserve memory, the stack is designed to run
@@ -81,7 +82,8 @@
  * Entry point for application
  */
 int main(void)
-{
+{ 
+   pc.printf("hello");
     // setup tracing
     setup_trace();
 
@@ -90,11 +92,11 @@
 
     // Initialize LoRaWAN stack
     if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
-        printf("\r\n LoRa initialization failed! \r\n");
+        pc.printf("\r\n LoRa initialization failed! \r\n");
         return -1;
     }
 
-    printf("\r\n Mbed LoRaWANStack initialized \r\n");
+    pc.printf("\r\n Mbed LoRaWANStack initialized \r\n");
 
     // prepare application callbacks
     callbacks.events = mbed::callback(lora_event_handler);
@@ -103,7 +105,7 @@
     // Set number of retries in case of CONFIRMED messages
     if (lorawan.set_confirmed_msg_retries(CONFIRMED_MSG_RETRY_COUNTER)
             != LORAWAN_STATUS_OK) {
-        printf("\r\n set_confirmed_msg_retries failed! \r\n\r\n");
+        pc.printf("\r\n set_confirmed_msg_retries failed! \r\n\r\n");
         return -1;
     }
 
@@ -112,18 +114,18 @@
 
     // Enable adaptive data rate
     if (lorawan.enable_adaptive_datarate() != LORAWAN_STATUS_OK) {
-        printf("\r\n enable_adaptive_datarate failed! \r\n");
+        pc.printf("\r\n enable_adaptive_datarate failed! \r\n");
         return -1;
     }
 
-    printf("\r\n Adaptive data  rate (ADR) - Enabled \r\n");
+    pc.printf("\r\n Adaptive data  rate (ADR) - Enabled \r\n");
 
     retcode = lorawan.connect();
 
     if (retcode == LORAWAN_STATUS_OK ||
             retcode == LORAWAN_STATUS_CONNECT_IN_PROGRESS) {
     } else {
-        printf("\r\n Connection error, code = %d \r\n", retcode);
+        pc.printf("\r\n Connection error, code = %d \r\n", retcode);
         return -1;
     }
 
@@ -142,7 +144,7 @@
 {
     uint16_t packet_len;
     int16_t retcode;
-    printf("\n\rHello world");    
+    pc.printf("\n\rHello world");    
 
     packet_len = sprintf((char *) tx_buffer, "Hello world");
 
@@ -150,8 +152,8 @@
                            MSG_UNCONFIRMED_FLAG);
 
     if (retcode < 0) {
-        retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")
-        : printf("\r\n send() - Error code %d \r\n", retcode);
+        retcode == LORAWAN_STATUS_WOULD_BLOCK ? pc.printf("send - WOULD BLOCK\r\n")
+        : pc.printf("\r\n send() - Error code %d \r\n", retcode);
 
         if (retcode == LORAWAN_STATUS_WOULD_BLOCK) {
             //retry in 3 seconds
@@ -162,7 +164,7 @@
         return;
     }
 
-    printf("\r\n %d bytes scheduled for transmission \r\n", retcode);
+    pc.printf("\r\n %d bytes scheduled for transmission \r\n", retcode);
     memset(tx_buffer, 0, sizeof(tx_buffer));
 }