Sample code for Start/Stop GNSS device

//--------------------------------------------------------------------------------------------------
/**
* Test: GNSS Position request.
*
*/
//--------------------------------------------------------------------------------------------------
static void TestLeGnssStart
(
void
)
{
uint32_t rate = 0;
le_gnss_ConstellationBitMask_t constellationMask;
le_gnss_NmeaBitMask_t nmeaMask;
uint32_t ttff = 0;
 
 
LE_TEST_INFO("Start Test Testle_gnss_StartTest");
 
LE_TEST_BEGIN_SKIP(!LINUX_OS, 2);
LE_TEST_OK(le_gnss_GetAcquisitionRate(&rate) == LE_OK, "Get acquisition rate");
LE_TEST_INFO("Acquisition rate %d ms", rate);
LE_TEST_OK(le_gnss_SetAcquisitionRate(rate) == LE_OK, "Set acquisition rate");
 
LE_TEST_OK(le_gnss_GetConstellation(&constellationMask) == LE_OK, "Get constellation");
LE_TEST_INFO("Constellation 0x%X", constellationMask);
LE_TEST_OK(le_gnss_SetConstellation(constellationMask) == LE_OK, "Set constellation");
 
LE_TEST_OK((le_gnss_GetNmeaSentences(&nmeaMask)) == LE_OK, "Get NMEA sentences");
LE_TEST_INFO("Enabled NMEA sentences 0x%08X", nmeaMask);
LE_TEST_OK((le_gnss_SetNmeaSentences(nmeaMask)) == LE_OK, "Set NMEA sentences");
 
LE_TEST_INFO("Start GNSS");
LE_TEST_ASSERT((le_gnss_Start()) == LE_OK, "Start GNSS");
 
/* Wait for a position fix */
LE_TEST_INFO("Wait 120 seconds for a 3D fix");
sleep(120);
 
// Get TTFF
result = le_gnss_GetTtff(&ttff);
LE_TEST_OK((result == LE_OK) || (result == LE_BUSY), "Get TTFF");
if(result == LE_OK)
{
LE_TEST_INFO("TTFF start = %d msec", ttff);
}
else
{
LE_TEST_INFO("TTFF start not available");
}
 
LE_TEST_INFO("Stop GNSS");
LE_TEST_OK((le_gnss_Stop()) == LE_OK, "Stop GNSS");
 
// Test le_gnss_StartMode()
// HOT start
LE_TEST_INFO("Ask for a Hot start in 3 seconds...");
sleep(3);
LE_TEST_OK(le_gnss_StartMode(LE_GNSS_UNKNOWN_START) == LE_BAD_PARAMETER, "Hot start");
 
LE_TEST_ASSERT((le_gnss_StartMode(LE_GNSS_HOT_START)) == LE_OK, "le_gnss_StartMode(Hot start)");
 
// Wait 5 sec
sleep(5);
// Stop GNSS engine
LE_TEST_ASSERT((le_gnss_Stop()) == LE_OK, "Stop GNSS");
 
/* WARM start */
LE_TEST_INFO("Ask for a Warm start in 3 seconds...");
sleep(3);
LE_TEST_ASSERT((le_gnss_StartMode(LE_GNSS_WARM_START)) == LE_OK,
"le_gnss_StartMode(Warm start)");
 
// Wait 5 sec
sleep(5);
// Stop GNSS engine
LE_TEST_ASSERT((le_gnss_Stop()) == LE_OK, "Stop GNSS");
 
/* COLD Restart */
LE_TEST_INFO("Ask for a Cold start in 3 seconds...");
sleep(3);
LE_TEST_ASSERT((le_gnss_StartMode(LE_GNSS_COLD_START)) == LE_OK,
"le_gnss_StartMode(Cold start)");
 
// Wait 5 sec
sleep(5);
// Stop GNSS engine
LE_TEST_ASSERT((le_gnss_Stop()) == LE_OK, "Stop GNSS");
 
// FACTORY start
LE_TEST_INFO("Ask for a Factory start in 3 seconds...");
sleep(3);
LE_TEST_ASSERT((le_gnss_StartMode(LE_GNSS_FACTORY_START)) == LE_OK,
"le_gnss_StartMode(Factory start)");
 
// Wait 5 sec
sleep(5);
// Stop GNSS engine
LE_TEST_ASSERT((le_gnss_Stop()) == LE_OK, "Stop GNSS");
 
LE_TEST_BEGIN_SKIP(LINUX_OS, 6);
LE_TEST_OK(LE_OK == le_gnss_EnableExternalLna(), "Enable external LNA");
LE_TEST_ASSERT(LE_OK == le_gnss_Start(), "Start GNSS");
LE_TEST_INFO("GNSS running, confirm EXT_GPS_LNA_EN signal is high");
LE_TEST_INFO("Wait 30 seconds");
sleep(30);
 
"Try to disable LNA when GNSS active");
"Try to enable LNA when GNSS active");
 
LE_TEST_ASSERT(LE_OK == le_gnss_Stop(), "Start GNSS");
LE_TEST_OK(LE_OK == le_gnss_DisableExternalLna(), "Disable external LNA");
 
EpochTime=0;
TimeAccuracy=0;
}