testing gps

This commit is contained in:
Klaus K Wilting 2018-06-09 16:52:51 +02:00
parent 4f2139a715
commit b43834a962
6 changed files with 24 additions and 13 deletions

View File

@ -58,7 +58,7 @@ typedef struct {
uint16_t altitude; uint16_t altitude;
} gpsStatus_t; } gpsStatus_t;
extern gpsStatus_t gps_status; // struct for storing gps data 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 #endif
extern configData_t cfg; extern configData_t cfg;

View File

@ -4,9 +4,8 @@
// Local logging tag // Local logging tag
static const char TAG[] = "main"; static const char TAG[] = "main";
/*
// GPS read data to global struct // GPS read data to global struct
void gps_read(){ void gps_read(){
gps_status.latitude = gps.location.lat(); gps_status.latitude = gps.location.lat();
gps_status.longitude = gps.location.lng(); gps_status.longitude = gps.location.lng();
@ -15,7 +14,7 @@ void gps_read(){
gps_status.altitude = (uint16_t) gps.altitude.meters(); gps_status.altitude = (uint16_t) gps.altitude.meters();
} }
// GPS serial feed FreeRTos Task /// GPS serial feed FreeRTos Task
void gps_loop(void * pvParameters) { void gps_loop(void * pvParameters) {
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
@ -33,5 +32,5 @@ void gps_loop(void * pvParameters) {
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
} }
} }
*/
#endif // HAS_GPS #endif // HAS_GPS

View File

@ -6,7 +6,8 @@
//#define HAS_BUTTON GPIO_NUM_39 // on board button "BOOT" (next to reset button) !! seems not to work!! //#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 HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
#define BATT_FACTOR 2 // voltage divider 100k/100k on board #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 // 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 #define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input

View File

@ -136,6 +136,7 @@ void do_send(osjob_t* j){
ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata)); ESP_LOGI(TAG, "%d bytes queued to send", sizeof(mydata));
sprintf(display_lmic, "PACKET QUEUED"); sprintf(display_lmic, "PACKET QUEUED");
/*
#ifdef HAS_GPS #ifdef HAS_GPS
if (cfg.gpsmode && gps.location.isValid()) { if (cfg.gpsmode && gps.location.isValid()) {
gps_read(); 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 ); ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%d, LON=%d", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude );
} }
#endif #endif
*/
// clear counter if not in cumulative counter mode // clear counter if not in cumulative counter mode
if (cfg.countermode != 1) { if (cfg.countermode != 1) {

View File

@ -482,7 +482,6 @@ void setup() {
#ifdef HAS_RGB_LED #ifdef HAS_RGB_LED
rgb_set_color(COLOR_PINK); rgb_set_color(COLOR_PINK);
strcat(features, " RGB"); strcat(features, " RGB");
delay(1000);
#endif #endif
// initialize button handling if needed // 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 // if device has GPS and GPS function is enabled, start GPS reader task on core 0
#ifdef HAS_GPS #ifdef HAS_GPS
if (cfg.gpsmode) { //if (cfg.gpsmode) {
ESP_LOGI(TAG, "Starting GPS task on core 0"); //ESP_LOGI(TAG, "Starting GPS task on core 0");
xTaskCreatePinnedToCore(gps_loop, "gpsreader", 2048, ( void * ) 1, 1, NULL, 0); //xTaskCreatePinnedToCore(gps_loop, "gpsreader", 2048, ( void * ) 1, 1, NULL, 0);
} //}
#endif #endif
// kickoff sendjob -> joins network and rescedules sendjob for cyclic transmitting payload // kickoff sendjob -> joins network and rescedules sendjob for cyclic transmitting payload
@ -599,6 +598,9 @@ do_send(&sendjob);
void loop() { void loop() {
HardwareSerial GPS_Serial(1);
GPS_Serial.begin(9600, SERIAL_8N1, 12, 15 );
while (1) { while (1) {
// simple state machine for controlling uptime, display, LED, button, memory. // simple state machine for controlling uptime, display, LED, button, memory.
@ -626,8 +628,13 @@ void loop() {
reset_salt(); // get new salt for salting hashes reset_salt(); // get new salt for salting hashes
} }
// read gps
while (GPS_Serial.available()) {
gps.encode(GPS_Serial.read());
}
if ( (uptime() % 10000) == 0 ) 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 vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog

View File

@ -259,6 +259,7 @@ void get_voltage (uint8_t val) {
void get_gps (uint8_t val) { void get_gps (uint8_t val) {
ESP_LOGI(TAG, "Remote command: get gps status"); ESP_LOGI(TAG, "Remote command: get gps status");
/*
#ifdef HAS_GPS #ifdef HAS_GPS
if (gps.location.isValid()) { if (gps.location.isValid()) {
gps_read(); 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 ); ESP_LOGI(TAG, "HDOP=%d, SATS=%d, LAT=%d, LON=%d", gps_status.hdop, gps_status.satellites, gps_status.latitude, gps_status.longitude );
} }
#endif #endif
*/
}; };