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:
- 66:a11c79073f1f
- Parent:
- 64:85fa08519e1e
- Child:
- 67:7bb75ed97500
--- a/GPS/GPS.cpp Sat Jan 11 11:35:11 2020 +0000 +++ b/GPS/GPS.cpp Tue Jan 14 13:48:39 2020 +0000 @@ -28,10 +28,31 @@ _gps.baud(Baud); longitude = 0.0; latitude = 0.0; - _gps.printf("$$PMTK161,0*28\r\n"); //sleep + //_gps.printf("$$PMTK161,0*28\r\n"); //sleep //_gps.printf("$$PMTK161,1*28\r\n"); //wake up } + + void GPS::GPS_OFF() + { + + + + uint8_t GPSoff[] = {0xB5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00,0x08, 0x00, 0x16, 0x74}; + uint8_t GPSon[] = {0xB5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00,0x09, 0x00, 0x17, 0x76}; + uint8_t GPS_Powersafemode[] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x01, 0x22, 0x92}; + + uint8_t GPS_MaxPerformance[] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x00, 0x21, 0x91}; + + uint8_t GPS_10s_Period[] ={0xB5, 0x62, 0x06, 0x3B, 0x2C, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x90, 0x03, 0x00, 0x10, 0x27, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x4F, 0xC1, 0x03, 0x00, 0x87, 0x02, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x64, 0x40, 0x01, 0x00, 0xE4, 0x8B}; + //_gps.printf((GPSoff, sizeof(GPSoff)/sizeof(uint8_t)); + + _gps.printf("%c",GPSoff); + + // +// uint8_t GPSon[] = {0xB5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00,0x09, 0x00, 0x17, 0x76}; +// sendUBX(GPSon, sizeof(GPSon)/sizeof(uint8_t)); + } int GPS::sample() { @@ -39,34 +60,22 @@ int lock; int h; - printf("GPS suchen:"); - + for (h = 0; h < 6; h++) - { - printf("\n Try: %i:",h); - getline(); - - - _gps.printf("$$PMTK161,0*28\r\n"); //sleep - - // Check if it is a GPGGA msg (matches both locked and non-locked msg) - //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("\nQualität: %f %f %f\n",time,longitude,latitude); - + { + 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)>0) { - if(false) { - //time = 0.0; - //longitude = 0.0; - //latitude = 0.0; - //sats = 0; - ////hdop = 0.0; - //alt = 0.0; - //geoid = 0.0; - - printf("\n Fehler: %f %ih %im %is\n",time,hour,minute,seconed); - return 0; + if(!lock) { + printf("[GPS] Kein Lock: %f %ih %im %is\n",time,hour,minute,seconed); + time = 0.0; + longitude = 0.0; + latitude = 0.0; + sats = 0; + //hdop = 0.0; + alt = 0.0; + geoid = 0.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), @@ -74,24 +83,24 @@ //GPGGA,092010.000,5210.9546,N,00008.8913,E,1,07,1.3,9.7,M,47.0,M,,0000*5D //format utc time to beijing time,add 8 time zone -// time = time;// + 80000.00f; + time = time+ 10000.00f; hour = int(time) / 10000; minute = (int(time) % 10000) / 100; seconed = int(time) % 100; - printf("\n Erfolg: %f %ih %im %is\n",time,hour,minute,seconed); + printf("\n[GPS] Lock: %ih %im %is\n",time,hour,minute,seconed); - return 1; - } - } + }//endiflock + } //endifscan - } + } //endfor - return 0 ; + return lock ; } + float GPS::trunc(float v) { if(v < 0.0) { @@ -112,11 +121,7 @@ msg[i] = _gps.getc(); printf("%c",msg[i]); if(msg[i] == '\r') { - msg[i] = 0; - - if (msg[3] == 'S' and msg[4] == 'V') - {printf("\nAnzahl Satelliten: %c",msg[11]); } - + msg[i] = 0; return; } }