This is an example application based on Mbed-OS LoRaWAN protocol APIs. The Mbed-OS LoRaWAN stack implementation is compliant with LoRaWAN v1.0.2 specification.

Dependencies:   Lorawan_Version_0_1

Dependents:   Lorawan_Version_0_1

Revision:
63:2bfceda4c30c
Parent:
62:35d41c8b9419
Child:
64:85fa08519e1e
--- a/main.cpp	Tue Dec 03 16:02:12 2019 +0000
+++ b/main.cpp	Wed Dec 11 19:35:25 2019 +0000
@@ -35,6 +35,21 @@
 uint8_t tx_buffer[30];
 uint8_t rx_buffer[30];
 
+
+float Home_Longitude;
+float Home_Latitude;
+
+float Home_Distance;
+float Home_Distance_max;
+bool AtHome;
+
+int LiveTick;
+
+bool IsLoading;
+AnalogIn LadeSpannung(PB_0); // 1/11 der gleichgerichteten Spannung am Dynamo
+
+
+
 /*
  * Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing
  */
@@ -52,18 +67,10 @@
  */
 #define CONFIRMED_MSG_RETRY_COUNTER     3
 
-/**
- * Dummy pin for dummy sensor
- */
-#define PC_9                            0
 
   DigitalOut led(LED2);
 
 #include "Fahrrad.h"
-/**
- * Dummy sensor class object
- */
-DS1820  ds1820(PC_9);
 
 /**
 * This event queue is the global event queue for both the
@@ -92,21 +99,52 @@
  */
 static lorawan_app_callbacks_t callbacks;
 
+
+
+static void LifeTicker()
+{
+    LiveTick=LiveTick+1;
+    printf("\n\t\t---LiveTick--- [%i]\n\n", LiveTick);
+    printf("Ladewert: %3.3f%%\n", LadeSpannung.read()*100.0f);
+    if(LadeSpannung.read() > 0.05f) {
+            if (not IsLoading) {Licht_hell();}
+            IsLoading = 1;
+        } else {
+            if (IsLoading) {ev_queue.call_in(3000, Licht_dunkel);}
+            IsLoading = 0;
+        }        
+        
+    
+    
+    ev_queue.call(GPS_aktiv); 
+    
+   // ev_queue.call_in(5000, LifeTicker);
+}
+
+
+
+
 /**
  * Entry point for application
  */
+ 
+ 
+
 int main(void)
 {
     
     
+
+    ev_queue.call_every(5000,LifeTicker);
     
     // setup tracing
     setup_trace();
     
-    Starte_Fahrrad_Eventmanager(); //schonmal die Fahrrad Events Initialisieren falls wir hier auch ohne lorawan empfang was machen wollen
+    //Starte_Fahrrad_Eventmanager(); //schonmal die Fahrrad Events Initialisieren falls wir hier auch ohne lorawan empfang was machen wollen
 
     // stores the status of a call to LoRaWAN protocol
     lorawan_status_t retcode;
+    
 
     // Initialize LoRaWAN stack
     if (lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
@@ -152,10 +190,15 @@
     // make your event queue dispatching events forever
     ev_queue.dispatch_forever();
 
-
+            
     return 0;
 }
 
+
+
+
+
+
 /**
  * Sends a message to the Network Server
  */
@@ -167,21 +210,17 @@
     
     
 
-    if (ds1820.begin()) {
-        ds1820.startConversion();
-        sensor_value = ds1820.read();
-        printf("\r\n Dummy Sensor Value = %d \r\n", sensor_value);
-        ds1820.startConversion();
-    } else {
-        printf("\r\n No sensor found \r\n");
-        return;
-    }
+    //if (ds1820.begin()) {
+//        ds1820.startConversion();
+//        sensor_value = ds1820.read();
+//        printf("\r\n Dummy Sensor Value = %d \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 %d",
-                         sensor_value);
-
-    retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
-                           MSG_UNCONFIRMED_FLAG);
+   
 
     if (retcode < 0) {
         retcode == LORAWAN_STATUS_WOULD_BLOCK ? printf("send - WOULD BLOCK\r\n")
@@ -224,6 +263,8 @@
     if (rx_buffer[0] == 0xb1) Blinken_ein();
     if (rx_buffer[0] == 0xb0) Blinken_aus()   ;   
    
+   
+    
     if (rx_buffer[0] == 0xc1)GPS_anfordern();    
     
     printf("\r\n");
@@ -240,8 +281,8 @@
         case CONNECTED:
             led=1;
             printf("\r\n Connection - Successful \r\n");
-          
-            ev_queue.call_every(15000, send_message);
+
+            //ev_queue.call_every(5000, send_message);
           
 
             break;
@@ -287,4 +328,8 @@
     }
 }
 
+
+
+
+
 // EOF