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:
- 69:316fee01f5d9
- Parent:
- 68:41fff9c3fb4f
- Child:
- 70:65b2f1cc2859
diff -r 41fff9c3fb4f -r 316fee01f5d9 GPS/GPS.cpp --- a/GPS/GPS.cpp Fri Jan 17 13:46:31 2020 +0000 +++ b/GPS/GPS.cpp Sun Jan 19 15:53:57 2020 +0000 @@ -33,21 +33,22 @@ } - void GPS::GPS_OFF() - { - - + void GPS::idle(bool idle) + { + this->is_idle = idle; + this->idle_time=0; + + // +// 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)); - 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); + // _gps.printf("%c",GPSoff); // // uint8_t GPSon[] = {0xB5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00,0x09, 0x00, 0x17, 0x76}; @@ -126,4 +127,51 @@ } } error("GPS::getline Overflowed message limit"); +} + + +void GPS::GPS_aktiv() +{ + + + + if (this->sample()) + { + + // current_Position.Zeitstempel = gpsAda.time; + // current_Position.Longitude = gpsAda.longitude /100; + // current_Position.Latitude = gpsAda.latitude /100; + + 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] HomeEntfernung: %f\n", distance); + + + + // printf("%f\t%c\t%f\t%c\t%f\t%f\t%f\n\r", gpsAda.longitude, gpsAda.ns, gpsAda.latitude, gpsAda.ew, gpsAda.alt, gpsAda.geoid, gpsAda.time); + // printf("%d:%d:%d\n", gpsAda.hour, gpsAda.minute, gpsAda.seconed); + + //packet_len = sprintf((char *) tx_buffer, "%i %f, %i %f\n", Breitengrad, Breitenminuten, Laengengrad, Laengenminuten); + + //retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len, + // MSG_UNCONFIRMED_FLAG); + + + } + else + { + //gpsAda.printf("$$PMTK161,0*28\r\n"); //go to sleep + //gpsAda.printf("$$PMTK161,1*28\r\n"); //wake up + + // current_Position.Zeitstempel = gpsAda.time; +// current_Position.Longitude = 50.123; +// current_Position.Latitude = 7.456; +// + +} } \ No newline at end of file