From 77431dbdde33f0a48326f0d4a03b4086064ee02a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 9 Jun 2018 17:59:59 +0200 Subject: [PATCH] GPS testing --- platformio.ini | 2 +- src/globals.h | 2 +- src/gpsread.cpp | 3 +-- src/lorawan.cpp | 2 -- src/main.cpp | 13 ++++--------- src/rcommand.cpp | 2 -- 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/platformio.ini b/platformio.ini index a3eb86d6..eb008f51 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,7 +32,7 @@ lib_deps_display = lib_deps_rgbled = SmartLeds@>=1.1.3 lib_deps_gps = - TinyGPSPlus@>=1.0.0 + https://github.com/mikalhart/TinyGPSPlus.git build_flags = ; we need build_flag for logging, otherwise we can't use ESP_LOGx in arduino framework ; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <--- diff --git a/src/globals.h b/src/globals.h index 30dfd98b..e92e44a6 100644 --- a/src/globals.h +++ b/src/globals.h @@ -58,7 +58,7 @@ typedef struct { uint16_t altitude; } gpsStatus_t; extern gpsStatus_t gps_status; // struct for storing gps data - //extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe + extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe #endif extern configData_t cfg; diff --git a/src/gpsread.cpp b/src/gpsread.cpp index ee9880af..752b1d2e 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -4,7 +4,7 @@ // Local logging tag static const char TAG[] = "main"; -/* + // GPS read data to global struct void gps_read(){ gps_status.latitude = gps.location.lat(); @@ -32,5 +32,4 @@ void gps_loop(void * pvParameters) { vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog } } -*/ #endif // HAS_GPS \ No newline at end of file diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 967007b5..b1079c0f 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -136,7 +136,6 @@ void do_send(osjob_t* j){ ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata)); sprintf(display_lmic, "PACKET QUEUED"); - /* #ifdef HAS_GPS if (cfg.gpsmode && gps.location.isValid()) { gps_read(); @@ -144,7 +143,6 @@ void do_send(osjob_t* j){ ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%d, LON=%d", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude ); } #endif - */ // clear counter if not in cumulative counter mode if (cfg.countermode != 1) { diff --git a/src/main.cpp b/src/main.cpp index f7b69266..87fe4ffb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -581,10 +581,10 @@ xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 2048, ( void * ) 1, 1, NULL // if device has GPS and GPS function is enabled, start GPS reader task on core 0 #ifdef HAS_GPS - //if (cfg.gpsmode) { - //ESP_LOGI(TAG, "Starting GPS task on core 0"); - //xTaskCreatePinnedToCore(gps_loop, "gpsreader", 2048, ( void * ) 1, 1, NULL, 0); - //} + if (cfg.gpsmode) { + ESP_LOGI(TAG, "Starting GPS task on core 0"); + xTaskCreatePinnedToCore(gps_loop, "gpsreader", 2048, ( void * ) 1, 1, NULL, 0); + } #endif // kickoff sendjob -> joins network and rescedules sendjob for cyclic transmitting payload @@ -628,11 +628,6 @@ void loop() { reset_salt(); // get new salt for salting hashes } - // read gps - while (GPS_Serial.available()) { - gps.encode(GPS_Serial.read()); - } - if ( (uptime() % 10000) == 0 ) ESP_LOGI(TAG, "GPS NMEA data passed %d / failed: %d / with fix: %d || Sats: %d / HDOP: %d || m/s: %d / %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix(), gps.satellites.value(), gps.hdop.value(), gps.time.minute(), gps.time.second() ); diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 9d4d1a23..e01860fb 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -259,7 +259,6 @@ void get_voltage (uint8_t val) { void get_gps (uint8_t val) { ESP_LOGI(TAG, "Remote command: get gps status"); - /* #ifdef HAS_GPS if (gps.location.isValid()) { gps_read(); @@ -267,7 +266,6 @@ void get_gps (uint8_t val) { ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%d, LON=%d", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude ); } #endif - */ };