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
Diff: main.cpp
- Revision:
- 70:65b2f1cc2859
- Parent:
- 69:316fee01f5d9
- Child:
- 71:ca2425c0a864
--- a/main.cpp Sun Jan 19 15:53:57 2020 +0000 +++ b/main.cpp Tue Jan 21 13:20:59 2020 +0000 @@ -38,21 +38,23 @@ bool GPS_activ,LORA_activ,AtHome; -DigitalOut GPSdisable(PC_6); uint32_t TickCounter; uint32_t TickTime=1000; uint32_t LoraTickCounter; uint32_t LoraTickTime=15000; - - - -uint32_t TimeWithoutMoving; - bool IsLoading; AnalogIn LadeSpannung(PB_0); // 1/11 der gleichgerichteten Spannung am Dynamo -static Light light(&ev_queue); -static GPS GPS_modul(PC_4, PC_5, 9600); + +//Light +DigitalOut LichtAus(PC_12); +DigitalOut LichtHell(PC_9); +Light light(&ev_queue,&LichtAus,&LichtHell); + +//GPS +DigitalOut GPSdisable(PC_6); +GPS GPS_modul(PC_4, PC_5, 9600,&GPSdisable); +uint32_t TimeWithoutMoving; Lora lora(&ev_queue, &light, &GPS_modul); @@ -75,7 +77,7 @@ printf("\n[LiveTick] --- [%i] ", TickCounter); //Dynamo - Fahrrad in Bewegung - if(LadeSpannung.read() > 0.05f) { + if(LadeSpannung.read()*3.3f*11 > 5) { IsLoading = 1; TimeWithoutMoving =0 ; printf("[SYSTEM] Akku laden mit: %fV", LadeSpannung.read()*3.3f*11); @@ -86,7 +88,10 @@ } light.adjust(IsLoading,TimeWithoutMoving); - if (!USERButton){light.Blinken_ein(10000);}; + if (!USERButton){ + light.Blinken_ein(4000); + GPS_modul.set_manual_tracking(true); + }; } @@ -103,26 +108,12 @@ mbed_stats_cpu_get(&stats); printf("\n[SYSTEM] Uptime: %llu Idle: %llu Sleep: %llu Deep: %llu", stats.uptime / 1000 , stats.idle_time / 1000, stats.sleep_time / 1000,stats.deep_sleep_time / 1000); - //GPS - GPS_modul.idle(TimeWithoutMoving<300000); - if (!GPS_modul.is_idle){ - GPS_modul.GPS_aktiv(); - } - else{ - printf("\n[GPS] Idle - Energie sparen"); - } + GPS_modul.idle(TimeWithoutMoving>300000); + GPS_modul.GPS_aktiv(); -//LORA - - if(false){ - printf("\n[LORA] Connected\n"); - lora.send_Position_to_Lora(0x01, GPS_modul.time,GPS_modul.longitude,GPS_modul.latitude); - } - else - { - printf("\n[LORA] not Connected\n"); - } +//LORA + lora.send_Position_to_Lora(0x01, GPS_modul.time,GPS_modul.longitude,GPS_modul.latitude); } @@ -143,7 +134,7 @@ // setup tracing - //setup_trace(); + setup_trace(); lora.Lora_init();