示例#1
0
文件: main.c 项目: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void Testle_ecall_StartManual
(
    void
)
{
    le_ecall_CallRef_t  testECallRef = 0x00;
    le_ecall_State_t    state = LE_ECALL_STATE_UNKNOWN;

    LE_INFO("Start Testle_ecall_StartManual");

    LE_ASSERT(le_ecall_SetPsapNumber("0102030405") == LE_OK);

    LE_ASSERT(le_ecall_SetMsdTxMode(LE_ECALL_TX_MODE_PUSH) == LE_OK);

    LE_ASSERT((testECallRef=le_ecall_Create()) != NULL);

    LE_ASSERT(le_ecall_ImportMsd(testECallRef, ImportedMsd, sizeof(ImportedMsd)) == LE_OK);

    LE_ASSERT(le_ecall_StartManual(testECallRef) == LE_OK);

    LE_ASSERT(le_ecall_StartTest(testECallRef) == LE_BUSY);
    LE_ASSERT(le_ecall_StartAutomatic(testECallRef) == LE_BUSY);

    LE_ASSERT(le_ecall_End(testECallRef) == LE_OK);

    state=le_ecall_GetState(testECallRef);
    LE_ASSERT(((state>=LE_ECALL_STATE_STARTED) && (state<=LE_ECALL_STATE_FAILED)));

    le_ecall_Delete(testECallRef);
}
示例#2
0
//--------------------------------------------------------------------------------------------------
void Testle_ecall_StartManual
(
    void
)
{
    le_ecall_CallRef_t  testECallRef = 0x00;
    le_ecall_State_t    state = LE_ECALL_STATE_UNKNOWN;
    char                psap[LE_MDMDEFS_PHONE_NUM_MAX_BYTES];

    LE_INFO("Start Testle_ecall_StartManual");

    LE_ASSERT(le_ecall_SetPsapNumber(PsapNumber) == LE_OK);
    LE_ASSERT(le_ecall_GetPsapNumber(psap, sizeof(psap)) == LE_OK);
    LE_INFO("psap %s", psap);
    LE_ASSERT(strncmp(psap, PsapNumber, strlen(PsapNumber)) == 0);

    LE_ASSERT(le_ecall_SetMsdTxMode(LE_ECALL_TX_MODE_PUSH) == LE_OK);

    LE_ASSERT((testECallRef=le_ecall_Create()) != NULL);

    LE_ASSERT(le_ecall_ImportMsd(testECallRef, ImportedMsd, sizeof(ImportedMsd)) == LE_OK);

    LE_ASSERT(le_ecall_StartManual(testECallRef) == LE_OK);

    LE_ASSERT(le_ecall_StartTest(testECallRef) == LE_BUSY);
    LE_ASSERT(le_ecall_StartAutomatic(testECallRef) == LE_BUSY);

    LE_ASSERT(le_ecall_End(testECallRef) == LE_OK);

    state=le_ecall_GetState(testECallRef);
    LE_ASSERT(((state>=LE_ECALL_STATE_STARTED) && (state<=LE_ECALL_STATE_FAILED)));

    le_ecall_Delete(testECallRef);
    sleep(5);
}
示例#3
0
//--------------------------------------------------------------------------------------------------
static void* ECallLoopThread
(
    void* ctxPtr
)
{
    le_ecall_ConnectService();

    while(1)
    {
        LE_INFO("Wait for semaphore...");
        le_sem_Wait(ThreadSemaphore);
        sleep(1);

        if (LastECallState == LE_ECALL_STATE_STARTED)
        {
            LE_INFO("Take the semaphore, End eCall...");
            LE_ASSERT(le_ecall_End(MytECallRef) == LE_OK);
            le_ecall_Delete(MytECallRef);
            MytECallRef = NULL;
        }
        else if (LastECallState == LE_ECALL_STATE_DISCONNECTED)
        {
            TestCount++;
            LE_INFO("Take the semaphore, Start new eCall...");

            LE_ASSERT((MytECallRef=le_ecall_Create()) != NULL);
            LE_ASSERT(le_ecall_SetMsdPosition(MytECallRef, true, +48898064, +2218092, 0) == LE_OK);
            LE_ASSERT(le_ecall_SetMsdPassengersCount(MytECallRef, 3) == LE_OK);
            LE_ASSERT(le_ecall_StartTest(MytECallRef) == LE_OK);
            LE_INFO("Start eCall #%d", TestCount);
        }
    }

    le_event_RunLoop();
}
示例#4
0
//--------------------------------------------------------------------------------------------------
static void SigHandler
(
    int sigNum
)
{
    LE_INFO("End and delete last test eCall");
    le_ecall_End(LastTestECallRef);
    le_ecall_Delete(LastTestECallRef);
    exit(EXIT_SUCCESS);
}
示例#5
0
//--------------------------------------------------------------------------------------------------
static void SigHandler
(
    int sigNum
)
{
    LE_INFO("End and delete last test eCall (TestCount.%d)", TestCount);
    if(MytECallRef)
    {
        le_ecall_End(MytECallRef);
        le_ecall_Delete(MytECallRef);
    }
    exit(EXIT_SUCCESS);
}
示例#6
0
//--------------------------------------------------------------------------------------------------
static void SigHandler
(
    int sigNum
)
{
    LE_INFO("Exit eCallDemo app");
    if (ECallRef)
    {
        le_ecall_End(ECallRef);
        le_ecall_Delete(ECallRef);
        ECallRef = NULL;
    }
    exit(EXIT_SUCCESS);
}
示例#7
0
//--------------------------------------------------------------------------------------------------
static void StartSession
(
    uint32_t paxCount,      ///< [IN] number of passengers
    int32_t  hMinAccuracy,  ///< [IN] minimum horizontal accuracy to trust the position (in meters)
    int32_t  dirMinAccuracy ///< [IN] minimum direction accuracy to trust the position (in degrees)
)
{
    bool                              isPosTrusted = false;
    int32_t                           latitude = 0x7FFFFFFF;
    int32_t                           longitude = 0x7FFFFFFF;
    int32_t                           hAccuracy = 0;
    int32_t                           direction = 0x7FFFFFFF;
    int32_t                           dirAccuracy = 0;

    LE_DEBUG("StartSession called");

    if (ECallRef)
    {
        LE_WARN("End and Delete previous eCall session.");
        le_ecall_End(ECallRef);
        le_ecall_Delete(ECallRef);
        ECallRef = NULL;
    }

    ECallRef=le_ecall_Create();
    LE_FATAL_IF((!ECallRef), "Unable to create an eCall object, exit the app!");
    LE_DEBUG("Create eCallRef.%p",  ECallRef);

    // Get the position data
    if ((le_pos_Get2DLocation(&latitude, &longitude, &hAccuracy) == LE_OK) &&
        (le_pos_GetDirection(&direction, &dirAccuracy) == LE_OK))
    {
        if ((hAccuracy < hMinAccuracy) && (dirAccuracy < dirMinAccuracy))
        {
            isPosTrusted = true;
            LE_INFO("Position can be trusted.");
        }
        else
        {
            LE_WARN("Position can't be trusted!");
        }
    }
    else
    {
        LE_WARN("Position can't be trusted!");
    }

    LE_ERROR_IF((le_ecall_SetMsdPosition(ECallRef,
                                         isPosTrusted,
                                         latitude,
                                         longitude,
                                         direction) != LE_OK),
                "Unable to set the position!");

    if (paxCount > 0)
    {
        LE_ERROR_IF((le_ecall_SetMsdPassengersCount(ECallRef, paxCount) != LE_OK),
                    "Unable to set the number of passengers!");
    }

    LE_ERROR_IF((le_ecall_StartTest(ECallRef) != LE_OK),
                "Unable to start an eCall, try again!");

    LE_INFO("Test eCall has been successfully triggered.");
}
示例#8
0
//--------------------------------------------------------------------------------------------------
static void ECallStateHandler
(
    le_ecall_CallRef_t  eCallRef,
    le_ecall_State_t    state,
    void*               contextPtr
)
{
    LE_INFO("New eCall state for eCallRef.%p",  eCallRef);

    switch(state)
    {
        case LE_ECALL_STATE_STARTED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_STARTED.");
            break;
        }
        case LE_ECALL_STATE_CONNECTED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_CONNECTED.");
            break;
        }
        case LE_ECALL_STATE_DISCONNECTED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_DISCONNECTED.");
            break;
        }
        case LE_ECALL_STATE_WAITING_PSAP_START_IND:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_WAITING_PSAP_START_IND.");
            break;
        }
        case LE_ECALL_STATE_PSAP_START_IND_RECEIVED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_PSAP_START_IND_RECEIVED.");
            if (le_ecall_SendMsd(eCallRef) != LE_OK)
            {
                LE_ERROR("Could not send the MSD");
            }
            break;
        }
        case LE_ECALL_STATE_MSD_TX_STARTED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_MSD_TX_STARTED.");
            break;
        }
        case LE_ECALL_STATE_LLNACK_RECEIVED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_LLNACK_RECEIVED.");
            break;
        }
        case LE_ECALL_STATE_LLACK_RECEIVED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_LLACK_RECEIVED.");
            break;
        }
        case LE_ECALL_STATE_MSD_TX_COMPLETED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_MSD_TX_COMPLETED.");
            break;
        }
        case LE_ECALL_STATE_MSD_TX_FAILED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_MSD_TX_FAILED.");
            break;
        }
        case LE_ECALL_STATE_ALACK_RECEIVED_POSITIVE:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_ALACK_RECEIVED_POSITIVE.");
            break;
        }
        case LE_ECALL_STATE_ALACK_RECEIVED_CLEAR_DOWN:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_ALACK_RECEIVED_CLEAR_DOWN.");
            break;
        }
        case LE_ECALL_STATE_STOPPED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_STOPPED.");
            break;
        }
        case LE_ECALL_STATE_RESET:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_RESET.");
            break;
        }
        case LE_ECALL_STATE_COMPLETED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_COMPLETED.");
            le_ecall_End(eCallRef);
            le_ecall_Delete(eCallRef);
            break;
        }
        case LE_ECALL_STATE_FAILED:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_FAILED.");
            break;
        }
        case LE_ECALL_STATE_END_OF_REDIAL_PERIOD:
        {
            LE_INFO("New eCall state is LE_ECALL_STATE_END_OF_REDIAL_PERIOD.");
            break;
        }
        case LE_ECALL_STATE_UNKNOWN:
        default:
        {
            LE_WARN("Unknown eCall state %d!", state);
            break;
        }
    }

}