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;
}