Sample code for Enable/Disable GNSS device

//--------------------------------------------------------------------------------------------------
/**
* Test: Legato GNSS functions.
*
*/
//--------------------------------------------------------------------------------------------------
static void TestLeGnssDevice
(
void
)
{
uint32_t ttffValue;
uint32_t acqRate;
uint8_t minElevation;
le_result_t result;
 
le_gnss_ConstellationBitMask_t constellationMask;
le_gnss_NmeaBitMask_t nmeaMask = 0;
le_gnss_ConstellationArea_t constellationArea;
 
LE_INFO("Start Test Testle_gnss_DeviceTest");
// GNSS device enabled by default
// Disable GNSS device (DISABLED state)
LE_ASSERT((le_gnss_Disable()) == LE_OK);
// Check Disabled state
 
&constellationArea)));
 
&constellationArea)));
 
result = le_gnss_SetAcquisitionRate(acqRate);
LE_ASSERT((result == LE_NOT_PERMITTED)||(result == LE_OUT_OF_RANGE));
 
// test le_gnss_Get/SetMinElevation when GNSS device is disabled and the engine is not started.
minElevation = 40;
LE_ASSERT((le_gnss_SetMinElevation(minElevation)) == LE_OK);
LE_ASSERT((le_gnss_GetMinElevation(&minElevation)) == LE_OK);
LE_INFO("GNSS min elevation obtained: %d",minElevation);
LE_ASSERT(minElevation == 40);
 
// Enable GNSS device (READY state)
LE_ASSERT((le_gnss_Enable()) == LE_OK);
LE_ASSERT((le_gnss_Disable()) == LE_OK);
LE_ASSERT((le_gnss_Enable()) == LE_OK);
LE_ASSERT_OK(le_gnss_GetConstellation(&constellationMask));
LE_ASSERT(constellationMask == LE_GNSS_CONSTELLATION_GPS);
 
 
&constellationArea));
LE_ASSERT(LE_GNSS_OUTSIDE_US_AREA == constellationArea);
 
&constellationArea));
LE_ASSERT(LE_GNSS_WORLDWIDE_AREA == constellationArea);
 
LE_ASSERT((le_gnss_GetAcquisitionRate(&acqRate)) == LE_OK);
acqRate = 0;
acqRate = 1100;
LE_ASSERT((le_gnss_SetAcquisitionRate(acqRate)) == LE_OK);
LE_ASSERT((le_gnss_GetNmeaSentences(&nmeaMask)) == LE_OK);
LE_ASSERT((le_gnss_SetNmeaSentences(nmeaMask)) == LE_OK);
 
// test le_gnss_Get/SetMinElevation when GNSS device is enabled and the engine is not started.
minElevation = 0;
LE_ASSERT((le_gnss_SetMinElevation(minElevation)) == LE_OK);
LE_ASSERT((le_gnss_GetMinElevation(&minElevation)) == LE_OK);
LE_INFO("GNSS min elevation obtained: %d",minElevation);
LE_ASSERT(minElevation == 0);
 
// Start GNSS device (ACTIVE state)
LE_ASSERT((le_gnss_Start()) == LE_OK);
result = le_gnss_SetAcquisitionRate(acqRate);
LE_ASSERT((result == LE_NOT_PERMITTED)||(result == LE_OUT_OF_RANGE));
 
// test le_gnss_Get/SetMinElevation when le_gnss_ENABLE ON and le_gnss_Start ON
LE_ASSERT((le_gnss_SetMinElevation(minElevation)) == LE_OK);
LE_ASSERT((le_gnss_GetMinElevation(&minElevation)) == LE_OK);
LE_INFO("GNSS min elevation obtained: %d",minElevation);
 
// test le_gnss_SetMinElevation wrong value (when le_gnss_ENABLE ON and le_gnss_Start ON)
 
// Stop GNSS device (READY state)
LE_ASSERT((le_gnss_Stop()) == LE_OK);
LE_ASSERT((le_gnss_Disable()) == LE_OK);
LE_ASSERT((le_gnss_Enable()) == LE_OK);
LE_ASSERT((le_gnss_GetConstellation(&constellationMask)) == LE_OK);
LE_ASSERT(constellationMask == LE_GNSS_CONSTELLATION_GPS);
LE_ASSERT((le_gnss_GetAcquisitionRate(&acqRate)) == LE_OK);
LE_ASSERT((le_gnss_SetAcquisitionRate(acqRate)) == LE_OK);
LE_ASSERT((le_gnss_GetNmeaSentences(&nmeaMask)) == LE_OK);
LE_ASSERT((le_gnss_SetNmeaSentences(nmeaMask)) == LE_OK);
}