//-------------------------------------------------------------------------------------------------- static void Testle_ecall_StartTest ( void ) { le_ecall_CallRef_t testECallRef = 0x00; le_ecall_State_t state = LE_ECALL_STATE_UNKNOWN; 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_SetMsdPosition(testECallRef, true, +48898064, +2218092, 0) == LE_OK); LE_ASSERT(le_ecall_SetMsdPassengersCount(testECallRef, 3) == LE_OK); LE_ASSERT(le_ecall_StartTest(testECallRef) == LE_OK); LE_ASSERT(le_ecall_StartManual(testECallRef) == LE_BUSY); LE_ASSERT(le_ecall_StartAutomatic(testECallRef) == LE_BUSY); state=le_ecall_GetState(testECallRef); LE_ASSERT(((state>=LE_ECALL_STATE_STARTED) && (state<=LE_ECALL_STATE_FAILED))); le_ecall_Delete(testECallRef); }
//-------------------------------------------------------------------------------------------------- static void Testle_ecall_LoadMsd ( void ) { le_ecall_CallRef_t testECallRef = 0x00; LE_INFO("Start Testle_ecall_LoadMsd"); LE_ASSERT((testECallRef=le_ecall_Create()) != NULL); LE_ASSERT(le_ecall_SetMsdPosition(testECallRef, true, +48898064, +2218092, 0) == LE_OK); LE_ASSERT(le_ecall_SetMsdPassengersCount(testECallRef, 3) == LE_OK); // Check LE_DUPLICATE on le_ecall_SetMsdPosition and le_ecall_SetMsdPassengersCount LE_ASSERT(le_ecall_ImportMsd(testECallRef, ImportedMsd, sizeof(ImportedMsd)) == LE_OK); LE_ASSERT(le_ecall_SetMsdPosition(testECallRef, true, +48070380, -11310000, 45) == LE_DUPLICATE); LE_ASSERT(le_ecall_SetMsdPassengersCount(testECallRef, 3) == LE_DUPLICATE); LE_ASSERT(le_ecall_ResetMsdEraGlonassCrashSeverity(testECallRef) == LE_DUPLICATE); LE_ASSERT(le_ecall_SetMsdEraGlonassCrashSeverity(testECallRef, 0) == LE_DUPLICATE); LE_ASSERT(le_ecall_ResetMsdEraGlonassDiagnosticResult(testECallRef) == LE_DUPLICATE); LE_ASSERT(le_ecall_SetMsdEraGlonassDiagnosticResult(testECallRef, LE_ECALL_DIAG_RESULT_PRESENT_MIC_CONNECTION_FAILURE) == LE_DUPLICATE); LE_ASSERT(le_ecall_ResetMsdEraGlonassCrashInfo(testECallRef) == LE_DUPLICATE); LE_ASSERT(le_ecall_SetMsdEraGlonassCrashInfo(testECallRef, LE_ECALL_CRASH_INFO_PRESENT_CRASH_FRONT_OR_SIDE | LE_ECALL_CRASH_INFO_CRASH_FRONT_OR_SIDE) == LE_DUPLICATE); le_ecall_Delete(testECallRef); }
//-------------------------------------------------------------------------------------------------- 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); }
//-------------------------------------------------------------------------------------------------- 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(); }
//-------------------------------------------------------------------------------------------------- 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); }
//-------------------------------------------------------------------------------------------------- static void SigHandler ( int sigNum ) { LE_INFO("End and delete last test eCall"); le_ecall_End(LastTestECallRef); le_ecall_Delete(LastTestECallRef); exit(EXIT_SUCCESS); }
//-------------------------------------------------------------------------------------------------- void Testle_ecall_AddHandlers ( void ) { int i; // Create a semaphore to coordinate the test ThreadSemaphore = le_sem_Create("HandlerSem",0); // int app context memset(AppCtx, 0, NB_CLIENT*sizeof(AppContext_t)); // Start tasks: simulate multi-user of le_ecall // each thread subcribes to state handler using le_ecall_AddStateChangeHandler for (i=0; i < NB_CLIENT; i++) { char string[20]={0}; snprintf(string,20,"app%dhandler", i); AppCtx[i].appId = i; AppCtx[i].appThreadRef = le_thread_Create(string, AppHandler, &AppCtx[i]); le_thread_Start(AppCtx[i].appThreadRef); } // Wait that the tasks have started before continuing the test SynchTest(); LE_ASSERT((CurrentEcallRef=le_ecall_Create()) != NULL); SimulateAndCheckState(LE_ECALL_STATE_STARTED); SimulateAndCheckState(LE_ECALL_STATE_CONNECTED); SimulateAndCheckState(LE_ECALL_STATE_WAITING_PSAP_START_IND); SimulateAndCheckState(LE_ECALL_STATE_PSAP_START_IND_RECEIVED); SimulateAndCheckState(LE_ECALL_STATE_MSD_TX_STARTED); SimulateAndCheckState(LE_ECALL_STATE_LLNACK_RECEIVED); SimulateAndCheckState(LE_ECALL_STATE_LLACK_RECEIVED); SimulateAndCheckState(LE_ECALL_STATE_MSD_TX_COMPLETED); SimulateAndCheckState(LE_ECALL_STATE_ALACK_RECEIVED_POSITIVE); SimulateAndCheckState(LE_ECALL_STATE_COMPLETED); SimulateAndCheckState(LE_ECALL_STATE_RESET); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T2); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T3); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T5); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T6); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T7); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T9); SimulateAndCheckState(LE_ECALL_STATE_TIMEOUT_T10); // TODO: will be completed once pa_mcc_simu will be ready // SimulateAndCheckState(LE_ECALL_STATE_DISCONNECTED); // Check that no more call of the semaphore LE_ASSERT(le_sem_GetValue(ThreadSemaphore) == 0); le_ecall_Delete(CurrentEcallRef); }
//-------------------------------------------------------------------------------------------------- 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); }
//-------------------------------------------------------------------------------------------------- void Testle_ecall_EraGlonassSettings ( void ) { uint16_t attempts = 0; uint16_t duration = 0; le_ecall_CallRef_t testECallRef = 0x00; LE_INFO("Start Testle_ecall_EraGlonassSettings"); LE_ASSERT((testECallRef=le_ecall_Create()) != NULL); LE_ASSERT(le_ecall_SetEraGlonassManualDialAttempts(7) == LE_OK); LE_ASSERT(le_ecall_GetEraGlonassManualDialAttempts(&attempts) == LE_OK); LE_ASSERT(attempts == 7); LE_ASSERT(le_ecall_SetEraGlonassAutoDialAttempts(9) == LE_OK); LE_ASSERT(le_ecall_GetEraGlonassAutoDialAttempts(&attempts) == LE_OK); LE_ASSERT(attempts == 9); LE_ASSERT(le_ecall_SetEraGlonassDialDuration(240) == LE_OK); LE_ASSERT(le_ecall_GetEraGlonassDialDuration(&duration) == LE_OK); LE_ASSERT(duration == 240); /* Crash Severity configuration */ LE_ASSERT(le_ecall_SetMsdEraGlonassCrashSeverity(testECallRef, 0) == LE_OK); LE_ASSERT(le_ecall_ResetMsdEraGlonassCrashSeverity(testECallRef) == LE_OK); LE_ASSERT(le_ecall_SetMsdEraGlonassCrashSeverity(testECallRef, 99) == LE_OK); /* DataDiagnosticResult configuration */ LE_ASSERT(le_ecall_SetMsdEraGlonassDiagnosticResult(testECallRef, 0x3FFFFFFFFFF) == LE_OK); LE_ASSERT(le_ecall_SetMsdEraGlonassDiagnosticResult(testECallRef, 0) == LE_OK); LE_ASSERT(le_ecall_ResetMsdEraGlonassDiagnosticResult(testECallRef) == LE_OK); LE_ASSERT(le_ecall_SetMsdEraGlonassDiagnosticResult(testECallRef, LE_ECALL_DIAG_RESULT_PRESENT_MIC_CONNECTION_FAILURE) == LE_OK); /* CrashInfo configuration */ LE_ASSERT(le_ecall_SetMsdEraGlonassCrashInfo(testECallRef, 0xFFFF) == LE_OK); LE_ASSERT(le_ecall_SetMsdEraGlonassCrashInfo(testECallRef, 0) == LE_OK); LE_ASSERT(le_ecall_ResetMsdEraGlonassCrashInfo(testECallRef) == LE_OK); LE_ASSERT(le_ecall_SetMsdEraGlonassCrashInfo(testECallRef, LE_ECALL_CRASH_INFO_PRESENT_CRASH_FRONT_OR_SIDE | LE_ECALL_CRASH_INFO_CRASH_FRONT_OR_SIDE) == LE_OK); le_ecall_Delete(testECallRef); }
//-------------------------------------------------------------------------------------------------- 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); }
//-------------------------------------------------------------------------------------------------- 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."); }
//-------------------------------------------------------------------------------------------------- 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; } } }