testing GPS

This commit is contained in:
Klaus K Wilting committed 2018-06-09 19:20:34 +02:00
1 parent 77431dbdde
commit a43da889d1
7 files changed
+33 -25

No files matched your search

+5 -5
View File
@@ -51,14 +51,14 @@ typedef struct {
#ifdef HAS_GPS
typedef struct {
uint32_t latitude;
uint32_t longitude;
uint8_t hdop;
double latitude;
double longitude;
double hdop;
uint32_t satellites;
uint16_t altitude;
double 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;
+24 -11
View File
@@ -9,9 +9,9 @@ static const char TAG[] = "main";
void gps_read(){
gps_status.latitude = gps.location.lat();
gps_status.longitude = gps.location.lng();
gps_status.satellites = (uint8_t) gps.satellites.value();
gps_status.hdop = (uint8_t) (gps.hdop.value() / 100);
gps_status.altitude = (uint16_t) gps.altitude.meters();
gps_status.satellites = gps.satellites.value();
gps_status.hdop = gps.hdop.value();
gps_status.altitude = gps.altitude.meters();
}
/// GPS serial feed FreeRTos Task
@@ -19,17 +19,30 @@ void gps_loop(void * pvParameters) {
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
HardwareSerial GPS_Serial(1);
//GPS_Serial.begin(HAS_GPS);
GPS_Serial.begin(9600, SERIAL_8N1, 12, 15 );
HardwareSerial GPS_Serial(1);
while(1) {
while (GPS_Serial.available()) {
gps.encode(GPS_Serial.read());
if (cfg.gpsmode)
{
// if GPS function is enabled try serial connect to GPS device
GPS_Serial.begin(HAS_GPS);
while(cfg.gpsmode) {
// feed GPS decoder with serial NMEA data from GPS device
while (GPS_Serial.available()) {
gps.encode(GPS_Serial.read());
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
}
}
// after GPS function was disabled, close connect to GPS device
GPS_Serial.end();
}
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
}
}
} // end of infinite loop
} // gps_loop()
#endif // HAS_GPS
+1 -2
View File
@@ -6,8 +6,7 @@
//#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 1
#define HAS_GPS 9600, SERIAL_8N1, 12, 15
// 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
-2
View File
@@ -129,8 +129,6 @@ void do_send(osjob_t* j){
mydata[3] = 0;
}
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(COUNTERPORT, mydata, sizeof(mydata), (cfg.countermode & 0x02));
ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata));
+1 -4
View File
@@ -598,9 +598,6 @@ 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.
@@ -629,7 +626,7 @@ void loop() {
}
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() );
ESP_LOGI(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", gps.passedChecksum(), gps.failedChecksum(), gps.sentencesWithFix());
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog