Ublox.flush() hangs

Hi
I am trying to get GPS active in a custom sketch
I have this function :

bool reset_GPS() { 																										consolePrintln("resetting GPS");
	
	pinMode(GPS_ENABLE, OUTPUT);																						consolePrintln("ok 1");
	pinMode(GPS_TIMEPULSE, INPUT);																						consolePrintln("ok 2");
	
	digitalWrite(GPS_ENABLE, HIGH);																						// attempt to turn on and communicate with the GPS
	ublox.enable();																										consolePrintln("ok 3");
	ublox.flush();																										consolePrintln("ok 4");
	
	uint32_t startTime = getNow();
	bool found = false;
	delay(4000);																										consolePrintln(!found && (getNow() - startTime <= GPS_COMM_CHECK_TIMEOUT));
	while (!found && (getNow() - startTime <= GPS_COMM_CHECK_TIMEOUT)) {												consolePrint("testing if ublox exists ... ");
		sodaq_wdt_reset();
		
		found = ublox.exists();																							consolePrintln(found);
	}
	
	if (found) {																										consolePrintln("GPS FOUND");
		setGpsActive(true); 																							// properly turn on before returning
		
		return true;
	}																													consolePrintln("*** GPS not found!");
	
	
	setGpsActive(false);																								// turn off before returning in case of failure
	
	return false;
	
} 

I used these include files and defs :

// -----------------------
// OUTPUT Definitions

#define CONSOLE_STREAM SerialUSB
#define CONSOLE_BAUD 9600
#define consolePrint(x) CONSOLE_STREAM.print(x)
#define consolePrintln(x) CONSOLE_STREAM.println(x)


// -----------------------




// -----------------------
// FLOW CONTROL definitions
#include "Config.h"
bool accelerometer_wasActive = false;
int pathSelection;


// -----------------------





// -----------------------
// TIME Definitions
#include "RTCTimer.h"
#include "RTCZero.h"
#include "Sodaq_wdt.h"
#include "MyTime.h"


#define MAX_RTC_EPOCH_OFFSET 25

RTCZero rtc;
RTCTimer timer;
Time time;

#include "ublox.h"
UBlox ublox;

#define GPS_TIME_VALIDITY 0b00000011 																					// date and time (but not fully resolved)
#define GPS_FIX_FLAGS 0b00000001 																						// just gnssFixOK
#define GPS_COMM_CHECK_TIMEOUT 10 																						// seconds

static bool isGpsInitialized;

void delegateNavPvt(NavigationPositionVelocityTimeSolution* NavPvt);

As you see, it’s copy from the tracker universal code.
It seems that the code hangs at ublox.flush(); after several seconds, no answer.

What am I doing wrong? Thank you.

Hi Sean,

I see no Wire.begin(), did you call it before calling this function?

Regards,
Thom

1 Like