#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <semaphore.h>
#include "Console.h"
#include <Basic.h>
#include "interfaces.h"
#include "main.h"
#ifdef ENABLE_SIMUL
#define NAVIGATION_HANDLER_CALL_THRESHOLD 5
static uint32_t NavigationHandlerCallCount = 0;
#endif
static void TenMeterNavigationHandler(
le_pos_SampleRef_t positionSampleRef,
void* contextPtr)
{
int32_t val, val1, accuracy;
uint32_t uval, uAccuracy;
uint16_t year;
uint16_t month;
uint16_t day;
uint16_t hours;
uint16_t minutes;
uint16_t seconds;
uint16_t milliseconds;
if(positionSampleRef == NULL)
{
LE_ERROR(
"New Position sample is NULL!");
}
else
{
LE_INFO(
"New Position sample %p", positionSampleRef);
}
#ifdef ENABLE_SIMUL
NavigationHandlerCallCount++;
#endif
LE_INFO(
"Check le_pos_sample_Get2DLocation passed, lat.%d, long.%d, accuracy.%d", val, val1, accuracy);
LE_INFO(
"Check le_pos_sample_GetDate passed, year.%d, month.%d, day.%d", year, month, day);
LE_INFO(
"Check le_pos_sample_GetTime passed, hours.%d, minutes.%d, seconds.%d, milliseconds.%d",
hours, minutes, seconds, milliseconds);
LE_INFO(
"Check le_pos_sample_GetAltitude passed, alt.%d, accuracy.%d", val, accuracy);
LE_INFO(
"Check le_pos_sample_GetHorizontalSpeed passed, hSpeed.%u, accuracy.%u", uval,
uAccuracy);
LE_INFO(
"Check le_pos_sample_GetVerticalSpeed passed, vSpeed.%d, accuracy.%d", val, accuracy);
LE_INFO(
"Check le_pos_sample_GetHeading passed, heading.%u, accuracy.%u", uval, uAccuracy);
LE_INFO(
"Check le_pos_sample_GetDirection passed, direction.%u, accuracy.%u", uval, uAccuracy);
#ifdef ENABLE_SIMUL
if (NavigationHandlerCallCount == NAVIGATION_HANDLER_CALL_THRESHOLD)
{
LE_INFO(
"Reached feedback threshold (%d), test PASS.", NAVIGATION_HANDLER_CALL_THRESHOLD);
exit(0);
}
else
{
LE_INFO(
"NavigationHandlerCallCount=%d", NavigationHandlerCallCount);
}
#endif
}
static void TwentyMeterNavigationHandler(
le_pos_SampleRef_t positionSampleRef,
void* contextPtr)
{
int32_t val, val1, accuracy;
uint32_t uval, uAccuracy;
if(positionSampleRef == NULL)
{
LE_ERROR(
"New Position sample is NULL!");
}
else
{
LE_INFO(
"New Position sample %p", positionSampleRef);
}
#ifdef ENABLE_SIMUL
NavigationHandlerCallCount++;
#endif
LE_INFO(
"Check le_pos_sample_Get2DLocation passed, lat.%d, long.%d, accuracy.%d", val, val1,
accuracy);
LE_INFO(
"Check le_pos_sample_GetAltitude passed, alt.%d, accuracy.%d", val, accuracy);
LE_INFO(
"Check le_pos_sample_GetHorizontalSpeed passed, hSpeed.%u, accuracy.%u", uval, uAccuracy);
LE_INFO(
"Check le_pos_sample_GetVerticalSpeed passed, vSpeed.%d, accuracy.%d", val, accuracy);
LE_INFO(
"Check le_pos_sample_GetHeading passed, heading.%u, accuracy.%u", uval, uAccuracy);
LE_INFO(
"Check le_pos_sample_GetDirection passed, direction.%u, accuracy.%u", uval, uAccuracy);
#ifdef ENABLE_SIMUL
if (NavigationHandlerCallCount == 5)
{
exit(0);
}
#endif
}
void Testle_pos_Fix()
{
int32_t latitude;
int32_t longitude;
int32_t altitude;
int32_t hAccuracy;
int32_t vAccuracy;
uint32_t hSpeed;
uint32_t hSpeedAccuracy;
int32_t vSpeed;
int32_t vSpeedAccuracy;
uint32_t heading;
uint32_t headingAccuracy=0;
uint32_t direction;
uint32_t directionAccuracy=0;
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"position fix state %d", fixState);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_Get2DLocation latitude.%d, longitude.%d, hAccuracy.%d", latitude,
longitude, hAccuracy);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_Get3DLocation latitude.%d, longitude.%d, hAccuracy.%d, altitude.%d, vAccuracy.%d", latitude, longitude, hAccuracy, altitude, vAccuracy);
#if ENABLE_SIMUL
#else
CU_ASSERT_EQUAL(res, LE_OK);
#endif
LE_INFO(
"Check le_pos_GetMotion hSpeed.%u, hSpeedAccuracy.%u, vSpeed.%d, vSpeedAccuracy.%d",
hSpeed, hSpeedAccuracy, vSpeed, vSpeedAccuracy);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_GetHeading heading.%u, headingAccuracy.%u", heading, headingAccuracy);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_GetDirection direction.%u, directionAccuracy.%u", direction,
directionAccuracy);
sleep (6);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_Get2DLocation latitude.%d, longitude.%d, hAccuracy.%d", latitude,
longitude, hAccuracy);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_Get3DLocation latitude.%d, longitude.%d, hAccuracy.%d, altitude.%d, vAccuracy.%d", latitude, longitude, hAccuracy, altitude, vAccuracy);
#if ENABLE_SIMUL
#else
CU_ASSERT_EQUAL(res, LE_OK);
#endif
LE_INFO(
"Check le_pos_GetMotion hSpeed.%u, hSpeedAccuracy.%u, vSpeed.%d, vSpeedAccuracy.%d",
hSpeed, hSpeedAccuracy, vSpeed, vSpeedAccuracy);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_GetHeading heading.%u, headingAccuracy.%u", heading, headingAccuracy);
CU_ASSERT_EQUAL(res, LE_OK);
LE_INFO(
"Check le_pos_GetDirection direction.%u, directionAccuracy.%u", direction,
directionAccuracy);
}
void Testle_pos_Navigation()
{
CU_ASSERT_PTR_NOT_NULL(navigHandlerRef);
CU_ASSERT_PTR_NOT_NULL(navigHandlerRef);
}