diff --git a/src/globals.h b/src/globals.h index e92e44a6..30dfd98b 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 f396d8b7..ee9880af 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -4,9 +4,8 @@ // Local logging tag static const char TAG[] = "main"; - +/* // GPS read data to global struct - void gps_read(){ gps_status.latitude = gps.location.lat(); gps_status.longitude = gps.location.lng(); @@ -15,7 +14,7 @@ void gps_read(){ gps_status.altitude = (uint16_t) gps.altitude.meters(); } -// GPS serial feed FreeRTos Task +/// GPS serial feed FreeRTos Task void gps_loop(void * pvParameters) { configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check @@ -33,5 +32,5 @@ 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/hal/ttgobeam.h b/src/hal/ttgobeam.h index 9a05de26..d9e9c5e5 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -6,7 +6,8 @@ //#define HAS_BUTTON GPIO_NUM_39 // on board button "BOOT" (next to reset button) !! seems not to work!! #define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 #define BATT_FACTOR 2 // voltage divider 100k/100k on board -#define HAS_GPS 9600, SERIAL_8N1, 12, 15 +//#define HAS_GPS 9600, SERIAL_8N1, 12, 15 +#define HAS_GPS 1 // re-define pin definitions of pins_arduino.h #define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input diff --git a/src/lorawan.cpp b/src/lorawan.cpp index b1079c0f..967007b5 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -136,6 +136,7 @@ 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(); @@ -143,6 +144,7 @@ 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 61fd74e9..f7b69266 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ u1_t rcmd_data_size; // buffer for rcommand results size #ifdef HAS_GPS gpsStatus_t gps_status; // struct for storing gps data - TinyGPSPlus gps; // create TinyGPS++ instance + TinyGPSPlus gps; // create TinyGPS++ instance #endif portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED; // sync main loop and ISR when modifying IRQ handler shared variables @@ -482,7 +482,6 @@ void setup() { #ifdef HAS_RGB_LED rgb_set_color(COLOR_PINK); strcat(features, " RGB"); - delay(1000); #endif // initialize button handling if needed @@ -582,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 @@ -599,6 +598,9 @@ do_send(&sendjob); void loop() { + HardwareSerial GPS_Serial(1); + GPS_Serial.begin(9600, SERIAL_8N1, 12, 15 ); + while (1) { // simple state machine for controlling uptime, display, LED, button, memory. @@ -626,8 +628,13 @@ 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", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix(), gps.satellites.value(), gps.hdop.value()); + 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() ); vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog diff --git a/src/rcommand.cpp b/src/rcommand.cpp index e01860fb..9d4d1a23 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -259,6 +259,7 @@ 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(); @@ -266,6 +267,7 @@ 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 + */ };