#include "legato.h"
#include "interfaces.h"
static le_gnss_PositionHandlerRef_t PositionHandlerRef = NULL;
char ShortSuplCertificate[50]={0};
static uint64_t EpochTime=0;
static uint32_t TimeAccuracy=0;
static le_gnss_Resolution_t DopRes = LE_GNSS_RES_ONE_DECIMAL;
#define WAIT_MAX_FOR_3DFIX 60
#define UNKNOWN_CONSTELLATION 0x80
#ifdef SIERRA_MDM9X40
#define MDM9X40_PLATFORM 1
#else
#define MDM9X40_PLATFORM 0
#endif
#ifdef SIERRA_MDM9X28
#define MDM9X28_PLATFORM 1
#else
#define MDM9X28_PLATFORM 0
#endif
#ifdef LE_CONFIG_LINUX
#define LINUX_OS 1
#else
#define LINUX_OS 0
#endif
static void TestLeGnssDevice
(
void
)
{
uint32_t ttffValue;
uint32_t acqRate;
uint8_t minElevation;
int32_t altitudeOnWgs84=0;
int64_t altitudeOnPZ90;
le_gnss_ConstellationBitMask_t constellationMask;
le_gnss_NmeaBitMask_t nmeaMask = 0;
le_gnss_ConstellationArea_t constellationArea;
LE_INFO(
"Start Test Testle_gnss_DeviceTest");
"Factory restart in disabled state");
"Hot start in disabled state");
"Warm start in disabled state");
"Cold start in disabled state");
"Factory start in disabled state");
"Set constellation in disabled state");
"Get constellation in disabled state");
LE_GNSS_WORLDWIDE_AREA),
"Set GPS constellation area in disabled state");
&constellationArea),
"Get GPS constellation area in disabled state");
LE_GNSS_WORLDWIDE_AREA),
"Set GLONASS constellation area in disabled state");
&constellationArea),
"Get GLONASS constellation area in disabled state");
"Get acquisition rate in disabled state");
"Set acquisition rate in disabled state");
"Set NMEA sentences in disabled state");
"Get NMEA sentences in disabled state");
minElevation = 40;
LE_INFO(
"GNSS min elevation obtained: %d",minElevation);
LE_TEST_OK(minElevation == 40,
"Confirm min elevation is set to %d", minElevation);
"Set constellation GPS");
LE_TEST_OK(constellationMask == LE_GNSS_CONSTELLATION_GPS,
"Confirm constellation is set to %d", LE_GNSS_CONSTELLATION_GPS);
LE_GNSS_UNSET_AREA)),
"Set invalid Galileo constellation area");
LE_GNSS_OUTSIDE_US_AREA),
"Set Galileo constellation area outside US");
&constellationArea),
"Get Galileo constellation area");
LE_TEST_OK(LE_GNSS_OUTSIDE_US_AREA == constellationArea,
"Confirm Galileo constellation area is set to %d", LE_GNSS_OUTSIDE_US_AREA);
LE_GNSS_WORLDWIDE_AREA),
"Set Galileo constellation area worldwide");
&constellationArea),
"Get Galileo constellation area");
LE_TEST_OK(LE_GNSS_WORLDWIDE_AREA == constellationArea,
"Confirm Galileo constellation area is set to %d", LE_GNSS_WORLDWIDE_AREA);
acqRate = 0;
"Set invalid acquisition rate");
acqRate = 1100;
minElevation = 0;
LE_TEST_INFO(
"GNSS min elevation obtained: %d",minElevation);
LE_TEST_OK(minElevation == 0,
"Confirm min elevation is set to 0");
"Set constellation in wrong state");
"Get constellation in wrong state");
"Hot start in active state");
"Warm start in active state");
"Cold start in active state");
"Factory start in active state");
"Get acquisition rate in wrong state");
"Set acquisition rate in wrong state");
"Set NMEA sentences in wrong state");
"Get NMEA sentences in wrong state");
minElevation = LE_GNSS_MIN_ELEVATION_MAX_DEGREE;
LE_TEST_INFO(
"GNSS min elevation obtained: %d",minElevation);
LE_TEST_OK(minElevation == LE_GNSS_MIN_ELEVATION_MAX_DEGREE,
"Confirm min elevation is set to %d", LE_GNSS_MIN_ELEVATION_MAX_DEGREE);
minElevation = LE_GNSS_MIN_ELEVATION_MAX_DEGREE+1;
"Set invalid min elevation");
"Set GPS constellation");
LE_TEST_OK(constellationMask == LE_GNSS_CONSTELLATION_GPS,
"Confirm constellation is set to GPS");
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_LATITUDE,
altitudeOnWgs84,
NULL)),
"ConvertDataCoordinateSystem error test: NULL pointer");
LE_GNSS_COORDINATE_SYSTEM_MAX,
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_LATITUDE,
altitudeOnWgs84,
&altitudeOnPZ90)),
"ConvertDataCoordinateSystem error test: invalid source coordinate");
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_LATITUDE,
altitudeOnWgs84,
&altitudeOnPZ90)),
"ConvertDataCoordinateSystem error test: wrong source coordinate");
LE_GNSS_COORDINATE_SYSTEM_WGS84,
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_MAX,
altitudeOnWgs84,
&altitudeOnPZ90)),
"ConvertDataCoordinateSystem error test: invalid data type");
LE_GNSS_COORDINATE_SYSTEM_WGS84,
LE_GNSS_POS_ALTITUDE,
altitudeOnWgs84,
&altitudeOnPZ90)),
"ConvertDataCoordinateSystem error test: mismatched coordinates");
}
static void PositionHandlerFunction
(
le_gnss_SampleRef_t positionSampleRef,
void* contextPtr
)
{
uint16_t year;
uint16_t month;
uint16_t day;
uint16_t hours;
uint16_t minutes;
uint16_t seconds;
uint16_t milliseconds;
uint32_t gpsWeek;
uint32_t gpsTimeOfWeek;
uint8_t leapSeconds = 0;
le_gnss_FixState_t state;
int32_t latitude;
int32_t longitude;
int64_t latitudeOnPZ90;
int64_t longitudeOnPZ90;
int32_t altitude;
int32_t altitudeOnWgs84;
int64_t altitudeOnPZ90;
int32_t hAccuracy;
int32_t vAccuracy;
int32_t magneticDeviation;
uint16_t dop;
uint32_t hSpeed;
uint32_t hSpeedAccuracy;
int32_t vSpeed = 0;
int32_t vSpeedAccuracy = 0;
uint32_t direction = 0;
uint32_t directionAccuracy = 0;
le_gnss_DopType_t dopType = LE_GNSS_PDOP;
le_gnss_Resolution_t dataRes = LE_GNSS_RES_ZERO_DECIMAL;
uint16_t satIdPtr[LE_GNSS_SV_INFO_MAX_LEN];
le_gnss_Constellation_t satConstPtr[LE_GNSS_SV_INFO_MAX_LEN];
bool satUsedPtr[LE_GNSS_SV_INFO_MAX_LEN];
uint8_t satSnrPtr[LE_GNSS_SV_INFO_MAX_LEN];
uint16_t satAzimPtr[LE_GNSS_SV_INFO_MAX_LEN];
uint8_t satElevPtr[LE_GNSS_SV_INFO_MAX_LEN];
uint8_t satsInViewCount;
uint8_t satsTrackingCount;
uint8_t satsUsedCount;
int i;
static const char *tabDop[] =
{
"Position dilution of precision (PDOP)",
"Horizontal dilution of precision (HDOP)",
"Vertical dilution of precision (VDOP)",
"Geometric dilution of precision (GDOP)",
"Time dilution of precision (TDOP)"
};
if (NULL == positionSampleRef)
{
LE_ERROR(
"New Position sample is NULL!");
}
else
{
LE_DEBUG(
"New Position sample %p", positionSampleRef);
}
if(state == LE_GNSS_STATE_FIX_NO_POS)
{
return;
}
LE_TEST_INFO(
"Position state: %s", (LE_GNSS_STATE_FIX_NO_POS == state)?
"No Fix" :(LE_GNSS_STATE_FIX_2D == state)?"2D Fix"
:(LE_GNSS_STATE_FIX_3D == state)?"3D Fix"
: "Unknown");
result =
le_gnss_GetTime(positionSampleRef, &hours, &minutes, &seconds, &milliseconds);
LE_TEST_INFO(
"%02d:%02d:%02d %d-%02d-%02d,", hours, minutes, seconds, year, month, day);
LE_TEST_INFO(
"epoch time: %llu:", (
unsigned long long int) EpochTime);
LE_TEST_INFO(
"GPS time W %02d:ToW %dms", gpsWeek, gpsTimeOfWeek);
LE_TEST_INFO(
"UTC leap seconds in advance %d", leapSeconds);
{
LE_INFO(
"Position lat.%f, long.%f, hAccuracy.%f",
(float)latitude/1000000.0,
(float)longitude/1000000.0,
(float)hAccuracy/100.0);
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_LATITUDE,
latitude,
&latitudeOnPZ90);
"Convert latitude from WGS84 to PZ90");
{
LE_INFO(
"Latitude: On WGS84 %d, On PZ90 %" PRId64
", float %f",
latitude,
latitudeOnPZ90,
(float)latitudeOnPZ90/1000000.0);
}
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_LONGITUDE,
longitude,
&longitudeOnPZ90);
"Convert longitude from WGS84 to PZ90");
{
LE_TEST_INFO(
"Longitude: On WGS84 %d, On PZ90 %" PRId64
", float %f",
longitude,
longitudeOnPZ90,
(float)longitudeOnPZ90/1000000.0);
}
}
else
{
if (INT32_MAX != latitude)
{
}
else
{
}
if (INT32_MAX != longitude)
{
}
else
{
}
if (INT32_MAX != hAccuracy)
{
LE_TEST_INFO(
"Horizontal accuracy %f", (
float)hAccuracy/100.0);
}
else
{
}
}
LE_TEST_INFO(
"Test SetDataResolution() for vAccuracy parameter of le_gnss_GetAltitude() function");
for (dataRes=LE_GNSS_RES_ZERO_DECIMAL; dataRes<LE_GNSS_RES_UNKNOWN; dataRes++)
{
"Set data resolution for vAccuracy");
{
switch(dataRes)
{
case LE_GNSS_RES_ZERO_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, altitude.%f, vAccuracy.%f",
dataRes, (float)altitude/1000.0, (float)vAccuracy);
break;
case LE_GNSS_RES_ONE_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, altitude.%f, vAccuracy.%f",
dataRes, (float)altitude/1000.0, (float)vAccuracy/10.0);
break;
case LE_GNSS_RES_TWO_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, altitude.%f, vAccuracy.%f",
dataRes, (float)altitude/1000.0, (float)vAccuracy/100.0);
break;
case LE_GNSS_RES_THREE_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, altitude.%f, vAccuracy.%f",
dataRes, (float)altitude/1000.0, (float)vAccuracy/1000.0);
break;
default:
break;
}
}
else
{
LE_TEST_INFO(
"Altitude unknown [%d,%d]", altitude, vAccuracy);
}
}
{
LE_TEST_INFO(
"AltitudeOnWgs84: %f", (
float)altitudeOnWgs84/1000.0);
LE_GNSS_COORDINATE_SYSTEM_PZ90,
LE_GNSS_POS_ALTITUDE,
altitudeOnWgs84,
&altitudeOnPZ90);
"Convert altitude from WGS84 to PZ90");
{
LE_TEST_INFO(
"Altitude: On WGS84: %d, On PZ90 %" PRId64
", float %f",
altitudeOnWgs84,
altitudeOnPZ90,
(float)altitudeOnPZ90/1000.0);
}
}
else
{
LE_TEST_INFO(
"AltitudeOnWgs84 unknown [%d]", altitudeOnWgs84);
}
LE_TEST_INFO(
"Set DOP resolution: %d decimal place\n", DopRes);
do
{
{
switch(DopRes)
{
case LE_GNSS_RES_ZERO_DECIMAL:
DopRes, tabDop[dopType], (float)dop);
break;
case LE_GNSS_RES_ONE_DECIMAL:
DopRes, tabDop[dopType], (float)(dop)/10);
break;
case LE_GNSS_RES_TWO_DECIMAL:
DopRes, tabDop[dopType], (float)(dop)/100);
break;
case LE_GNSS_RES_THREE_DECIMAL:
default:
DopRes, tabDop[dopType], (float)(dop)/1000);
break;
}
}
else
{
}
dopType++;
}
while (dopType != LE_GNSS_DOP_LAST);
LE_TEST_INFO(
"Test SetDataResolution() for hSpeedAccuracy parameter of le_gnss_GetHorizontalSpeed() \ function");
for (dataRes=LE_GNSS_RES_ZERO_DECIMAL; dataRes<LE_GNSS_RES_UNKNOWN; dataRes++)
{
"Set data resolution for hSpeedAccuracy");
{
switch(dataRes)
{
case LE_GNSS_RES_ZERO_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, hSpeed %u - Accuracy %.3f",
dataRes, hSpeed/100, (float)hSpeedAccuracy);
break;
case LE_GNSS_RES_ONE_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, hSpeed %u - Accuracy %.3f",
dataRes, hSpeed/100, (float)hSpeedAccuracy/10);
break;
case LE_GNSS_RES_TWO_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, hSpeed %u - Accuracy %.3f",
dataRes, hSpeed/100, (float)hSpeedAccuracy/100);
break;
case LE_GNSS_RES_THREE_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, hSpeed %u - Accuracy %.3f",
dataRes, hSpeed/100, (float)hSpeedAccuracy/1000);
break;
default:
break;
}
}
else
{
LE_TEST_INFO(
"hSpeed unknown [%u,%.3f]", hSpeed, (
float)hSpeedAccuracy);
}
}
for (dataRes=LE_GNSS_RES_ZERO_DECIMAL; dataRes<LE_GNSS_RES_UNKNOWN; dataRes++)
{
"Set data resolution for vSpeedAccuracy");
{
switch(dataRes)
{
case LE_GNSS_RES_ZERO_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, vSpeed %d - Accuracy %.3f",
dataRes, vSpeed/100, (float)vSpeedAccuracy);
break;
case LE_GNSS_RES_ONE_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, vSpeed %d - Accuracy %.3f",
dataRes, vSpeed/100, (float)vSpeedAccuracy/10);
break;
case LE_GNSS_RES_TWO_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, vSpeed %d - Accuracy %.3f",
dataRes, vSpeed/100, (float)vSpeedAccuracy/100);
break;
case LE_GNSS_RES_THREE_DECIMAL:
LE_TEST_INFO(
"Resolution: %d decimal place, vSpeed %d - Accuracy %.3f",
dataRes, vSpeed/100, (float)vSpeedAccuracy/1000);
break;
default:
break;
}
}
else
{
LE_TEST_INFO(
"vSpeed unknown [%d,%.3f]", vSpeed, (
float)vSpeedAccuracy);
}
}
{
LE_TEST_INFO(
"direction %u - Accuracy %u", direction/10, directionAccuracy/10);
}
else
{
LE_TEST_INFO(
"direction unknown [%u,%u]", direction, directionAccuracy);
}
{
LE_TEST_INFO(
"magnetic deviation %d", magneticDeviation/10);
}
else
{
LE_TEST_INFO(
"magnetic deviation unknown [%d]",magneticDeviation);
}
&satsInViewCount,
&satsTrackingCount,
&satsUsedCount);
"Get satellite status");
LE_TEST_INFO(
"satsInView %d - satsTracking %d - satsUsed %d",
satsInViewCount,
satsTrackingCount,
satsUsedCount);
satIdPtr,
&satIdNumElements,
satConstPtr,
&satConstNumElements,
satUsedPtr,
&satUsedNumElements,
satSnrPtr,
&satSnrNumElements,
satAzimPtr,
&satAzimNumElements,
satElevPtr,
&satElevNumElements);
"Get satellite info");
for (i=0; i<satIdNumElements; i++)
{
if ((0 != satIdPtr[i]) && (UINT16_MAX != satIdPtr[i]))
{
LE_TEST_INFO(
"[%02d] SVid %03d - C%01d - U%d - SNR%02d - Azim%03d - Elev%02d",
i,
satIdPtr[i],
satConstPtr[i],
satUsedPtr[i],
satSnrPtr[i],
satAzimPtr[i],
satElevPtr[i]);
if (LE_GNSS_SV_CONSTELLATION_SBAS == satConstPtr[i])
{
}
}
}
}
static void* PositionThread
(
void* context
)
{
LE_INFO(
"======== Position Handler thread ========");
"Confirm position handler was added successfully");
return NULL;
}
static void TestLeGnssPositionHandler
(
void
)
{
le_thread_Ref_t positionThreadRef;
uint32_t ttff = 0;
uint8_t minElevation;
le_gnss_NmeaBitMask_t mask = LE_GNSS_NMEA_MASK_GPGGA | LE_GNSS_NMEA_MASK_GPGLL |
LE_GNSS_NMEA_MASK_GPRMC | LE_GNSS_NMEA_MASK_GPGNS |
LE_GNSS_NMEA_MASK_GPVTG | LE_GNSS_NMEA_MASK_GPZDA |
LE_GNSS_NMEA_MASK_GPGST | LE_GNSS_NMEA_MASK_GPGSA |
LE_GNSS_NMEA_MASK_GPGSV;
minElevation = 10;
{
LE_INFO(
"Set minElevation %d",minElevation);
}
LE_GNSS_RES_ONE_DECIMAL),
"Set invalid data resolution");
sleep(5);
LE_GNSS_RES_UNKNOWN),
"Set invalid data resolution for vAccuracy");
positionThreadRef = le_thread_Create("PositionThread",PositionThread,NULL);
le_thread_Start(positionThreadRef);
sleep(5);
LE_TEST_OK(0 != EpochTime,
"Confirm EpochTime is not 0");
LE_TEST_INFO(
"TimeAccuracy %d EpochTime %llu",TimeAccuracy, (
unsigned long long int)EpochTime);
time.
sec = WAIT_MAX_FOR_3DFIX;
"Wait until position handler has executed successfully");
{
}
else
{
}
sleep(5);
#ifdef LE_CONFIG_LINUX
le_thread_Cancel(positionThreadRef);
#endif
EpochTime=0;
TimeAccuracy=0;
}
static void TestLeGnssStart
(
void
)
{
uint32_t rate = 0;
le_gnss_ConstellationBitMask_t constellationMask;
le_gnss_NmeaBitMask_t nmeaMask;
uint32_t ttff = 0;
sleep(120);
{
}
else
{
}
sleep(3);
sleep(5);
sleep(3);
"le_gnss_StartMode(Warm start)");
sleep(5);
sleep(3);
"le_gnss_StartMode(Cold start)");
sleep(5);
sleep(3);
"le_gnss_StartMode(Factory start)");
sleep(5);
LE_TEST_INFO(
"GNSS running, confirm EXT_GPS_LNA_EN signal is high");
sleep(30);
"Try to disable LNA when GNSS active");
"Try to enable LNA when GNSS active");
EpochTime=0;
TimeAccuracy=0;
}
static void TestLeGnssRestart
(
void
)
{
uint32_t ttff = 0;
uint64_t epochTime;
le_gnss_SampleRef_t positionSampleRef;
sleep(60);
{
}
else
{
}
sleep(3);
sleep(60);
{
}
else
{
}
sleep(3);
sleep(60);
{
}
else
{
}
sleep(3);
sleep(5);
"Get epoch time after cold restart");
LE_TEST_OK(0 == epochTime,
"Confirm epoch time is invalid");
sleep(60);
{
}
else
{
}
sleep(3);
LE_TEST_INFO(
"TTFF is checked as not available immediatly after a FACTORY start");
sleep(5);
"Get epoch time after factory restart");
LE_TEST_OK(0 == epochTime,
"Confirm epoch time is invalid");
sleep(60);
{
}
else
{
}
sleep(1);
EpochTime=0;
TimeAccuracy=0;
}
static void LoopToGet3Dfix
(
uint32_t *ttffPtr
)
{
int32_t cnt=0;
while ((result ==
LE_BUSY) && (cnt < WAIT_MAX_FOR_3DFIX))
{
{
}
else
{
cnt++;
LE_TEST_INFO(
"TTFF not calculated (Position not fixed) BUSY");
sleep(1);
}
}
}
static void TestLeGnssTtffMeasurement
(
void
)
{
uint32_t ttff = 0;
uint32_t ttffSave = 0;
LoopToGet3Dfix(&ttff);
ttffSave = ttff;
sleep(3);
LoopToGet3Dfix(&ttff);
sleep(5);
EpochTime=0;
TimeAccuracy=0;
}
static void TestLeGnssConstellations
(
void
)
{
le_gnss_ConstellationBitMask_t constellationMask;
le_gnss_ConstellationArea_t constellationArea;
constellationMask = 0;
"Set unsupported constellation %d", constellationMask);
constellationMask = LE_GNSS_CONSTELLATION_SBAS;
"Set unsupported constellation %d", constellationMask);
constellationMask = LE_GNSS_CONSTELLATION_GPS | LE_GNSS_CONSTELLATION_SBAS;
"Set unsupported constellation %d", constellationMask);
constellationMask = LE_GNSS_CONSTELLATION_GPS | LE_GNSS_CONSTELLATION_GLONASS;
"Set constellation %d", constellationMask);
"Get constellation");
LE_TEST_OK((LE_GNSS_CONSTELLATION_GPS | LE_GNSS_CONSTELLATION_GLONASS) == constellationMask,
"Confirm constellation is set to %d", constellationMask);
constellationMask = LE_GNSS_CONSTELLATION_BEIDOU;
"Set unsupported constellation %d", constellationMask);
LE_TEST_OK((LE_GNSS_CONSTELLATION_GPS | LE_GNSS_CONSTELLATION_GLONASS) == constellationMask,
"Confirm constellation is unchanged after error");
LE_GNSS_OUTSIDE_US_AREA)),
"Set unsupported GPS constellation area");
LE_GNSS_OUTSIDE_US_AREA)),
"Set unsupported GLONASS constellation area");
&constellationArea),
"Get GLONASS constellation area");
LE_TEST_OK(LE_GNSS_WORLDWIDE_AREA == constellationArea,
"Confirm GLONASS constellation area is worldwide");
constellationMask = LE_GNSS_CONSTELLATION_GPS |
LE_GNSS_CONSTELLATION_SBAS |
LE_GNSS_CONSTELLATION_QZSS;
"Set unsupported constellation %d", constellationMask);
constellationMask = LE_GNSS_CONSTELLATION_GPS |
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU;
"Set constellation %d", constellationMask);
"Get constellation");
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU) == constellationMask,
"Confirm constellation mask is set to %d", LE_GNSS_CONSTELLATION_GPS |
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU);
constellationMask = LE_GNSS_CONSTELLATION_GPS |
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU |
LE_GNSS_CONSTELLATION_GALILEO |
LE_GNSS_CONSTELLATION_QZSS;
"Set constellation %d", constellationMask);
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU |
LE_GNSS_CONSTELLATION_GALILEO |
LE_GNSS_CONSTELLATION_QZSS) == constellationMask,
"Confirm constellation mask is set to %d", LE_GNSS_CONSTELLATION_GPS |
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU |
LE_GNSS_CONSTELLATION_GALILEO |
LE_GNSS_CONSTELLATION_QZSS);
constellationMask |= UNKNOWN_CONSTELLATION;
"Set unknown constellation %d", constellationMask);
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU |
LE_GNSS_CONSTELLATION_GALILEO |
LE_GNSS_CONSTELLATION_QZSS) == constellationMask,
"Confirm constellation mask is set to %d", LE_GNSS_CONSTELLATION_GPS |
LE_GNSS_CONSTELLATION_GLONASS |
LE_GNSS_CONSTELLATION_BEIDOU |
LE_GNSS_CONSTELLATION_GALILEO |
LE_GNSS_CONSTELLATION_QZSS);
LE_GNSS_WORLDWIDE_AREA),
"Set Beidou constellation area worldwide");
&constellationArea),
"Get constellation area for Beidou");
LE_TEST_OK(LE_GNSS_WORLDWIDE_AREA == constellationArea,
"Confirm Beidou constellation area is set to %d", LE_GNSS_WORLDWIDE_AREA);
}
static void TestLeGnssNmeaSentences
(
void
)
{
int i = 0;
le_gnss_NmeaBitMask_t nmeaMask;
le_gnss_NmeaBitMask_t saveNmeaMask;
nmeaMask = (LE_GNSS_NMEA_SENTENCES_MAX << 1) | 1;
"Set invalid NMEA mask %d", nmeaMask);
le_gnss_NmeaBitMask_t nmeaSentencesList[] = {
LE_GNSS_NMEA_MASK_GPGGA,
LE_GNSS_NMEA_MASK_GPGSA,
LE_GNSS_NMEA_MASK_GPGSV,
LE_GNSS_NMEA_MASK_GPRMC,
LE_GNSS_NMEA_MASK_GPVTG,
LE_GNSS_NMEA_MASK_GPGLL,
#ifdef LE_CONFIG_LINUX
LE_GNSS_NMEA_MASK_GLGSV,
LE_GNSS_NMEA_MASK_GNGNS,
LE_GNSS_NMEA_MASK_GNGSA,
LE_GNSS_NMEA_MASK_GAGGA,
LE_GNSS_NMEA_MASK_GAGSA,
LE_GNSS_NMEA_MASK_GAGSV,
LE_GNSS_NMEA_MASK_GARMC,
LE_GNSS_NMEA_MASK_GAVTG,
#else
LE_GNSS_NMEA_MASK_GPGNS,
LE_GNSS_NMEA_MASK_GPZDA,
LE_GNSS_NMEA_MASK_GPGST,
#endif
0
};
for (i = 0; nmeaSentencesList[i]; i++)
{
"Set NMEA sentence mask to 0x%08X",nmeaSentencesList[i]);
"Confirm NMEA sentence mask is set to 0x%08X", nmeaSentencesList[i]);
}
"Set NMEA sentence mask to %08X", LE_GNSS_NMEA_MASK_PQXFI);
LE_TEST_OK(nmeaMask == (LE_GNSS_NMEA_MASK_PQXFI | LE_GNSS_NMEA_MASK_PTYPE),
"Confirm NMEA sentence mask is set to %08X",
(LE_GNSS_NMEA_MASK_PQXFI | LE_GNSS_NMEA_MASK_PTYPE));
"Set NMEA sentence mask to %08X",LE_GNSS_NMEA_MASK_PTYPE);
LE_TEST_OK(nmeaMask == (LE_GNSS_NMEA_MASK_PQXFI | LE_GNSS_NMEA_MASK_PTYPE),
"Confirm NMEA sentence mask is set to %08X",
(LE_GNSS_NMEA_MASK_PQXFI | LE_GNSS_NMEA_MASK_PTYPE));
"Set NMEA sentence mask to %08X", LE_GNSS_NMEA_MASK_PSTIS);
LE_TEST_OK((LE_GNSS_NMEA_MASK_PSTIS == nmeaMask) || (0 == nmeaMask),
"Confirm NMEA sentence mask is set to %08X or 0", LE_GNSS_NMEA_MASK_PSTIS);
"set NMEA sentence mask to %08X", LE_GNSS_NMEA_MASK_GPGRS);
"Get NMEA sentences");
LE_TEST_OK((LE_GNSS_NMEA_MASK_GPGRS == nmeaMask) || (0 == nmeaMask),
"Confirm NMEA sentence mas is set to %08X or 0", LE_GNSS_NMEA_MASK_GPGRS);
"Set NMEA sentence mask to %08X", LE_GNSS_NMEA_MASK_DEBUG);
LE_TEST_OK((LE_GNSS_NMEA_MASK_DEBUG == nmeaMask) || (0 == nmeaMask),
"Confirm NMEA sentence mask is set to %08X or 0", LE_GNSS_NMEA_MASK_DEBUG);
"Set NMEA sentence mask to %08X", LE_GNSS_NMEA_MASK_GPDTM);
"Get NMEA sentences");
LE_TEST_OK((LE_GNSS_NMEA_MASK_GPDTM == nmeaMask) || (0 == nmeaMask),
"Confirm NMEA sentence mask is set to %08X or 0", LE_GNSS_NMEA_MASK_GPDTM);
"Set NMEA sentences to %08X", LE_GNSS_NMEA_MASK_GAGNS);
"Get NMEA sentences");
LE_TEST_OK((LE_GNSS_NMEA_MASK_GAGNS == nmeaMask) || (0 == nmeaMask),
"Confirm NMEA sentence mask is set to %08X or 0", LE_GNSS_NMEA_MASK_GAGNS);
"Set NMEA sentence mask to %08X", LE_GNSS_NMEA_MASK_GPGLL);
"Get NMEA sentences");
LE_TEST_OK((LE_GNSS_NMEA_MASK_GPGLL == nmeaMask) || (0 == nmeaMask),
"Confirm NMEA sentence mask is set to %08X or 0", LE_GNSS_NMEA_MASK_GPGLL);
saveNmeaMask = LE_GNSS_NMEA_MASK_GPGGA | LE_GNSS_NMEA_MASK_GPGSA | LE_GNSS_NMEA_MASK_GPGSV;
"Set NMEA sentence mask to %08X", saveNmeaMask);
"Get NMEA sentences");
"Confirm NMEA sentence mask is set to %08X", saveNmeaMask);
"Set NMEA sentence mask to %08X", (saveNmeaMask | LE_GNSS_NMEA_MASK_GPRMC));
LE_TEST_OK(((saveNmeaMask | LE_GNSS_NMEA_MASK_GPRMC) == nmeaMask) || (saveNmeaMask == nmeaMask),
"Confirm NMEA mask is set correctly");
"Set NMEA sentence mask to %08X", (saveNmeaMask | LE_GNSS_NMEA_MASK_GPGLL));
LE_TEST_OK(((saveNmeaMask | LE_GNSS_NMEA_MASK_GPGLL) == nmeaMask) || (saveNmeaMask == nmeaMask),
"Confirm NMEA mask is set correctly");
"Set NMEA sentence mask to %08X", (saveNmeaMask | LE_GNSS_NMEA_MASK_DEBUG));
LE_TEST_OK(((saveNmeaMask | LE_GNSS_NMEA_MASK_DEBUG) == nmeaMask) ||
(saveNmeaMask == nmeaMask), "Confirm NMEA sentence mask is set correctly");
"Set NMEA sentence mask to %08X", (saveNmeaMask | LE_GNSS_NMEA_MASK_GPDTM));
LE_TEST_OK(((saveNmeaMask | LE_GNSS_NMEA_MASK_GPDTM) == nmeaMask) || (saveNmeaMask == nmeaMask),
"Confirm NMEA sentence mask is set correctly");
"Set NMEA sentence mask to %08X", (saveNmeaMask | LE_GNSS_NMEA_MASK_GAGNS));
LE_TEST_OK(((saveNmeaMask | LE_GNSS_NMEA_MASK_GAGNS) == nmeaMask) || (saveNmeaMask == nmeaMask),
"Confirm NMEA sentence mask is set correctly");
}
static void TestSuplCertificate
(
void
)
{
le_gnss_AssistedMode_t gnssMode;
memset(&ShortSuplCertificate, 0x69, sizeof(ShortSuplCertificate));
"Set supl mode to standalone");
"Get supl assisted mode");
"Confirm supl mode is standalone");
"Set supl mode to MS based");
"Get supl assisted mode");
"Confirm supl mode is set to MS based");
"Set supl mode to MS assisted");
"Get supl assisted mode");
"Confirm supl mode is set to MS assisted");
"Set invalid supl mode");
"Get supl assisted mode");
"Confirm supl mode is unchanged after previous error");
"Set supl server URL");
"Set supl server URL");
"Inject 0 length supl certificate");
strlen(ShortSuplCertificate),ShortSuplCertificate)),
"Inject supl certificate with invalid ID");
strlen(ShortSuplCertificate),ShortSuplCertificate)),
"Inject valid supl certificate");
"Delete out of range supl certificate");
"Delete unused supl certificate");
"Delete the valid supl certificate");
}
static void TestLeGnssLeapSeconds
(
void
)
{
int32_t currentLeapSec = 0, nextLeapSec = 0;
uint64_t gpsTimeMs = 0, nextEventMs = 0;
"Get leap seconds");
LE_TEST_INFO(
"Current GPS time %"PRIu64
"ms, leap seconds %"PRIi32
"ms", gpsTimeMs, currentLeapSec);
LE_TEST_INFO(
"Next event in %"PRIu64
"ms, next leap seconds %"PRIi32
"ms", nextEventMs, nextLeapSec);
}
static void TestLeGnssCapabilities
(
void
)
{
le_gnss_ConstellationBitMask_t supportedConstellations;
le_gnss_NmeaBitMask_t supportedNmeaSentences;
uint32_t maxNmeaRate;
uint32_t minNmeaRate;
"Get supported NMEA sentences");
LE_TEST_INFO(
"Supported NMEA sentence mask:0x%08X", supportedNmeaSentences);
"Get supported constellations");
LE_TEST_INFO(
"Supported constellation mask:0x%08X", supportedConstellations);
"Get minimum NMEA rate");
"Get maximum NMEA rate");
}
{
TestLeGnssDevice();
TestLeGnssStart();
TestLeGnssRestart();
LE_TEST_INFO(
"======== GNSS position handler Test ========");
TestLeGnssPositionHandler();
TestLeGnssTtffMeasurement();
TestLeGnssConstellations();
TestLeGnssNmeaSentences();
TestLeGnssLeapSeconds();
TestSuplCertificate();
LE_TEST_INFO(
"======== GNSS capabilities API test ========");
TestLeGnssCapabilities();
}