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: GPS/GPS.cpp
- Revision:
- 71:ca2425c0a864
- Parent:
- 70:65b2f1cc2859
- Child:
- 72:67c5bce77999
--- a/GPS/GPS.cpp Tue Jan 21 13:20:59 2020 +0000 +++ b/GPS/GPS.cpp Fri Jan 24 07:32:42 2020 +0000 @@ -35,13 +35,14 @@ void GPS::idle(bool idle) { - this->is_idle = idle; + this->is_idle = idle; } void GPS::set_manual_tracking(bool mt) { this->manual_tracking = mt; printf("\n[GPS] Manual Tracking %x",mt); + gps_off->write(!mt); } int GPS::sample() @@ -50,11 +51,12 @@ int h; lock = 0; - for (h = 0; h < 10; h++) { + for (h = 0; h < 3; h++) { printf("\n[GPS] Line %i:",h); getline(); if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,%f,%c,%f", &time, &latitude, &ns, &longitude, &ew, &lock, &sats, &hdop, &alt, &unit, &geoid)>=1) { + printf(msg); if(!lock) { printf("\n[GPS] Kein Lock: %f %ih %im %is\n",time,hour,minute,seconed); //time = 0.0; @@ -64,6 +66,7 @@ // //hdop = 0.0; // alt = 0.0; // geoid = 0.0; + GPS_signal_okay=0; } else { //GPGGA format according http://aprs.gids.nl/nmea/#gga // time (float), lat (f), (N/S) (c), long (f), (E/W) (c), fix (d), sats (d), @@ -77,7 +80,7 @@ seconed = int(time) % 100; printf("\n[GPS] Lock: %ih %im %is lat:%, lon:%\n",hour,minute,seconed,latitude, longitude); - + GPS_signal_okay=1; return lock ; }//endiflock } //endifscan @@ -103,7 +106,7 @@ while(_gps.getc() != '$'); // wait for the start of a line for(int i=0; i<256; i++) { msg[i] = _gps.getc(); - printf("%c",msg[i]); + //printf("%c",msg[i]); if(msg[i] == '\r') { msg[i] = 0; return; @@ -117,24 +120,12 @@ { if (manual_tracking or !is_idle){ printf("\n[GPS] active"); - gps_off->write(0); - // uint8_t GPS_MaxPerformance[] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x00, 0x21, 0x91}; - // _gps.printf("%c",GPS_MaxPerformance); if (this->sample()) { - float Homelat = 52.143734; - float Homelon = 7.323368; - float dx,dy,distance; - dx = 71.5 * abs(longitude /100 - Homelon); - dy = 111.3 * abs(latitude /100 - Homelat); - - distance = sqrt(dx * dx + dy * dy) ; printf("[GPS] Position: %f , %f\n", longitude,latitude); - printf("[GPS] HomeEntfernung: %f\n", distance); } } else { - printf("[GPS] idle"); - gps_off->write(1); + printf("[GPS] idle"); } }