Sample code for restart GNSS device and get TTFF

//--------------------------------------------------------------------------------------------------
/**
* Test: Restart to Cold start.
*
*/
//--------------------------------------------------------------------------------------------------
static void TestLeGnssRestart
(
void
)
{
uint32_t ttff = 0;
uint64_t epochTime;
le_gnss_SampleRef_t positionSampleRef;
 
LE_INFO("Start Test le_pos_RestartTest");
 
 
 
/* Wait for a position fix */
LE_INFO("Wait 60 seconds for a 3D fix");
sleep(60);
// Get TTFF
result = le_gnss_GetTtff(&ttff);
LE_ASSERT((result == LE_OK) || (result == LE_BUSY));
if(result == LE_OK)
{
LE_INFO("TTFF start = %d msec", ttff);
}
else
{
LE_INFO("TTFF start not available");
}
 
/* HOT Restart */
LE_INFO("Ask for a Hot restart in 3 seconds...");
sleep(3);
// Wait for a 3D fix
LE_INFO("Wait 60 seconds for a 3D fix");
sleep(60);
// Get TTFF
result = le_gnss_GetTtff(&ttff);
LE_ASSERT((result == LE_OK) || (result == LE_BUSY));
if(result == LE_OK)
{
LE_INFO("TTFF Hot restart = %d msec", ttff);
}
else
{
LE_INFO("TTFF Hot restart not available");
}
 
/* WARM Restart */
LE_INFO("Ask for a Warm restart in 3 seconds...");
sleep(3);
// Wait for a 3D fix
LE_INFO("Wait 60 seconds for a 3D fix");
sleep(60);
// Get TTFF
result = le_gnss_GetTtff(&ttff);
LE_ASSERT((result == LE_OK) || (result == LE_BUSY));
if(result == LE_OK)
{
LE_INFO("TTFF Warm restart = %d msec", ttff);
}
else
{
LE_INFO("TTFF Warm restart not available");
}
 
/* COLD Restart */
LE_INFO("Ask for a Cold restart in 3 seconds...");
sleep(3);
 
sleep(1);
// Get Epoch time : it should be 0 after a COLD restart
positionSampleRef = le_gnss_GetLastSampleRef();
LE_ASSERT((LE_OUT_OF_RANGE == le_gnss_GetEpochTime(positionSampleRef, &epochTime)));
LE_ASSERT(0 == epochTime);
 
// Wait for a 3D fix
LE_INFO("Wait 60 seconds for a 3D fix");
sleep(60);
// Get TTFF
result = le_gnss_GetTtff(&ttff);
LE_ASSERT((result == LE_OK) || (result == LE_BUSY));
if(result == LE_OK)
{
LE_INFO("TTFF Cold restart = %d msec", ttff);
}
else
{
LE_INFO("TTFF Cold restart not available");
}
 
/* FACTORY Restart */
LE_INFO("Ask for a Factory restart in 3 seconds...");
sleep(3);
// Get TTFF,position fix should be still in progress for the FACTORY start
result = le_gnss_GetTtff(&ttff);
LE_ASSERT(result == LE_BUSY);
LE_INFO("TTFF is checked as not available immediatly after a FACTORY start");
 
sleep(1);
// Get Epoch time : it should be 0 after a FACTORY restart
positionSampleRef = le_gnss_GetLastSampleRef();
LE_ASSERT((LE_OUT_OF_RANGE == le_gnss_GetEpochTime(positionSampleRef, &epochTime)));
LE_ASSERT(0 == epochTime);
 
// Wait for a 3D fix
LE_INFO("Wait 60 seconds for a 3D fix");
sleep(60);
// Get TTFF
result = le_gnss_GetTtff(&ttff);
LE_ASSERT((result == LE_OK) || (result == LE_BUSY));
if(result == LE_OK)
{
LE_INFO("TTFF Factory restart = %d msec", ttff);
}
else
{
LE_INFO("TTFF Factory restart not available");
}
 
/* Stop GNSS engine*/
sleep(1);
EpochTime=0;
TimeAccuracy=0;
 
}