From 21c387c0289d595bdcc2cc8ca365fd7146149908 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 10 Jun 2018 00:45:27 +0200 Subject: [PATCH] GPS testing (experimental) --- src/gpsread.cpp | 12 +++++++++--- src/lorawan.cpp | 2 +- src/rcommand.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gpsread.cpp b/src/gpsread.cpp index 4747f7a6..0cedc315 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -7,8 +7,8 @@ static const char TAG[] = "main"; // read GPS data and cast to global struct void gps_read(){ - gps_status.latitude = (uint32_t) gps.location.lat() * 100; - gps_status.longitude = (uint32_t) gps.location.lng() * 100; + gps_status.latitude = (uint32_t) (gps.location.lat() * 1000000); + gps_status.longitude = (uint32_t) (gps.location.lng() * 1000000); gps_status.satellites = (uint8_t) gps.satellites.value(); gps_status.hdop = (uint16_t) gps.hdop.value(); gps_status.altitude = (uint16_t) gps.altitude.meters(); @@ -19,7 +19,13 @@ void gps_loop(void * pvParameters) { configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check - HardwareSerial GPS_Serial(1); + #ifdef GPS_SERIAL + HardwareSerial GPS_Serial(1); + #endif + + #ifdef GPS_I2C + // to be done + #endif while(1) { diff --git a/src/lorawan.cpp b/src/lorawan.cpp index c2565e22..92d2f61c 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -138,7 +138,7 @@ void do_send(osjob_t* j){ if (cfg.gpsmode && gps.location.isValid()) { gps_read(); LMIC_setTxData2(GPSPORT, (byte*)&gps_status, sizeof(gps_status), (cfg.countermode & 0x02)); - ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%f, LON=%f", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude ); + ESP_LOGI(TAG, "lat=%f / lon=%f | Sats=%u | HDOP=%u | Alti=%u", gps_status.latitude / 1000000, gps_status.longitude / 1000000, gps_status.satellites, gps_status.hdop, gps_status.altitude); } #endif diff --git a/src/rcommand.cpp b/src/rcommand.cpp index de2ec09a..fa061f9f 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -262,7 +262,7 @@ void get_gps (uint8_t val) { #ifdef HAS_GPS gps_read(); transmit((byte*)&gps_status, sizeof(gps_status)); - ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%f, LON=%f", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude ); + ESP_LOGI(TAG, "lat=%f / lon=%f | Sats=%u | HDOP=%u | Alti=%u", gps_status.latitude / 1000000, gps_status.longitude / 1000000, gps_status.satellites, gps_status.hdop, gps_status.altitude); #else ESP_LOGE(TAG, "GPS not present"); #endif