#include "interfaces.h"
static const char * PsapNumber = NULL;
static void ConnectAudio
(
void
)
{
LE_ERROR_IF((MdmRxAudioRef==NULL),
"OpenModemVoiceRx returns NULL!");
LE_ERROR_IF((MdmTxAudioRef==NULL),
"OpenModemVoiceTx returns NULL!");
#if (ENABLE_CODEC == 1)
LE_ERROR_IF((FeOutRef==NULL),
"OpenSpeaker returns NULL!");
#else
LE_ERROR_IF((FeOutRef==NULL),
"OpenPcmTx returns NULL!");
LE_ERROR_IF((FeInRef==NULL),
"OpenPcmRx returns NULL!");
#endif
LE_ERROR_IF((AudioInputConnectorRef==NULL),
"AudioInputConnectorRef is NULL!");
LE_ERROR_IF((AudioOutputConnectorRef==NULL),
"AudioOutputConnectorRef is NULL!");
if (MdmRxAudioRef && MdmTxAudioRef && FeOutRef && FeInRef &&
AudioInputConnectorRef && AudioOutputConnectorRef)
{
LE_ERROR_IF((res!=LE_OK),
"Failed to connect Mic on Input connector!");
LE_ERROR_IF((res!=LE_OK),
"Failed to connect mdmTx on Input connector!");
LE_ERROR_IF((res!=LE_OK),
"Failed to connect Speaker on Output connector!");
LE_ERROR_IF((res!=LE_OK),
"Failed to connect mdmRx on Output connector!");
}
}
static void DisconnectAudio
(
void
)
{
if (AudioInputConnectorRef)
{
if (FeInRef)
{
LE_INFO(
"Disconnect %p from connector.%p", FeInRef, AudioInputConnectorRef);
}
if(MdmTxAudioRef)
{
LE_INFO(
"Disconnect %p from connector.%p", MdmTxAudioRef, AudioInputConnectorRef);
}
}
if(AudioOutputConnectorRef)
{
if(FeOutRef)
{
LE_INFO(
"Disconnect %p from connector.%p", FeOutRef, AudioOutputConnectorRef);
}
if(MdmRxAudioRef)
{
LE_INFO(
"Disconnect %p from connector.%p", MdmRxAudioRef, AudioOutputConnectorRef);
}
}
if(AudioInputConnectorRef)
{
AudioInputConnectorRef = NULL;
}
if(AudioOutputConnectorRef)
{
AudioOutputConnectorRef = NULL;
}
if(FeInRef)
{
FeInRef = NULL;
}
if(FeOutRef)
{
FeOutRef = NULL;
}
if(MdmRxAudioRef)
{
FeOutRef = NULL;
}
if(MdmTxAudioRef)
{
FeOutRef = NULL;
}
}
static void MyECallEventHandler
(
void* contextPtr
)
{
LE_INFO(
"eCall TEST: New eCall state: %d for eCall ref.%p", state, eCallRef);
switch(state)
{
{
LE_INFO(
"eCall state is LE_ECALL_STATE_STARTED.");
#if (ENABLE_CODEC == 1)
#else
#endif
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_CONNECTED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_DISCONNECTED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_WAITING_PSAP_START_IND.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_PSAP_START_IND_RECEIVED.");
{
}
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_MSD_TX_STARTED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_LLNACK_RECEIVED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_LLACK_RECEIVED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_MSD_TX_COMPLETED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_MSD_TX_FAILED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_ALACK_RECEIVED_POSITIVE.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_ALACK_RECEIVED_CLEAR_DOWN.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_STOPPED.");
#if (ENABLE_CODEC == 1)
#else
LE_INFO(
"Unmute PCM Tx interface.");
#endif
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_RESET.");
#if (ENABLE_CODEC == 1)
#else
LE_INFO(
"Unmute PCM Tx interface.");
#endif
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_COMPLETED.");
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_FAILED.");
#if (ENABLE_CODEC == 1)
#else
LE_INFO(
"Unmute PCM Tx interface.");
#endif
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_END_OF_REDIAL_PERIOD.");
break;
}
default:
{
break;
}
}
}
static void StartTestECall
(
void
)
{
ConnectAudio();
}
static void SigHandler
(
int sigNum
)
{
LE_INFO(
"End and delete last test eCall");
DisconnectAudio();
exit(EXIT_SUCCESS);
}
static void PrintUsage()
{
int idx;
bool sandboxed = (getuid() != 0);
const char * usagePtr[] = {
"Usage of the eCallWVoice is:",
" execInApp eCallWVoice eCallWVoice <PSAP number>",
};
{
if(sandboxed)
{
}
else
{
fprintf(stderr, "%s\n", usagePtr[idx]);
}
}
}
{
{
signal(SIGINT, SigHandler);
LE_INFO(
"======== Start eCallWVoice Test with PSAP.%s ========", PsapNumber);
#if (ENABLE_CODEC == 1)
LE_INFO(
" Audio is connected on Analogic interface.");
#else
LE_INFO(
" Audio is connected on PCM interface.");
#endif
StartTestECall();
LE_INFO(
"======== eCallWVoice Test SUCCESS ========");
}
else
{
PrintUsage();
exit(EXIT_FAILURE);
}
}