#include "legato.h"
#include "interfaces.h"
static const char * PsapNumber = NULL;
static le_ecall_CallRef_t LastTestECallRef = NULL;
static le_audio_StreamRef_t MdmRxAudioRef = NULL;
static le_audio_StreamRef_t MdmTxAudioRef = NULL;
static le_audio_StreamRef_t FeInRef = NULL;
static le_audio_StreamRef_t FeOutRef = NULL;
static le_audio_ConnectorRef_t AudioInputConnectorRef = NULL;
static le_audio_ConnectorRef_t AudioOutputConnectorRef = NULL;
static void ConnectAudio
(
void
)
{
LE_ERROR_IF((MdmRxAudioRef==NULL),
"OpenModemVoiceRx returns NULL!");
LE_ERROR_IF((MdmTxAudioRef==NULL),
"OpenModemVoiceTx returns NULL!");
if ((FeOutRef==NULL))
{
LE_INFO(
"Switching to PCM Inteface...");
LE_ERROR_IF((FeOutRef==NULL),
"OpenPcmTx returns NULL!");
LE_ERROR_IF((FeInRef==NULL),
"OpenPcmRx returns NULL!");
}
else
{
}
LE_ERROR_IF((AudioInputConnectorRef==NULL),
"AudioInputConnectorRef is NULL!");
LE_ERROR_IF((AudioOutputConnectorRef==NULL),
"AudioOutputConnectorRef is NULL!");
if (MdmRxAudioRef && MdmTxAudioRef && FeOutRef && FeInRef &&
AudioInputConnectorRef && AudioOutputConnectorRef)
{
}
}
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
(
le_ecall_CallRef_t eCallRef,
le_ecall_State_t state,
void* contextPtr
)
{
LE_INFO(
"eCall TEST: New eCall state: %d for eCall ref.%p", state, eCallRef);
switch(state)
{
case LE_ECALL_STATE_STARTED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_STARTED.");
break;
}
case LE_ECALL_STATE_CONNECTED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_CONNECTED.");
break;
}
case LE_ECALL_STATE_DISCONNECTED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_DISCONNECTED.");
break;
}
case LE_ECALL_STATE_WAITING_PSAP_START_IND:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_WAITING_PSAP_START_IND.");
break;
}
case LE_ECALL_STATE_PSAP_START_IND_RECEIVED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_PSAP_START_IND_RECEIVED.");
{
}
break;
}
case LE_ECALL_STATE_MSD_TX_STARTED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_MSD_TX_STARTED.");
break;
}
case LE_ECALL_STATE_LLNACK_RECEIVED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_LLNACK_RECEIVED.");
break;
}
case LE_ECALL_STATE_LLACK_RECEIVED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_LLACK_RECEIVED.");
break;
}
case LE_ECALL_STATE_MSD_TX_COMPLETED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_MSD_TX_COMPLETED.");
break;
}
case LE_ECALL_STATE_MSD_TX_FAILED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_MSD_TX_FAILED.");
break;
}
case LE_ECALL_STATE_ALACK_RECEIVED_POSITIVE:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_ALACK_RECEIVED_POSITIVE.");
break;
}
case LE_ECALL_STATE_ALACK_RECEIVED_CLEAR_DOWN:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_ALACK_RECEIVED_CLEAR_DOWN.");
break;
}
case LE_ECALL_STATE_STOPPED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_STOPPED.");
break;
}
case LE_ECALL_STATE_RESET:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_RESET.");
break;
}
case LE_ECALL_STATE_COMPLETED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_COMPLETED.");
break;
}
case LE_ECALL_STATE_FAILED:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_FAILED.");
break;
}
case LE_ECALL_STATE_END_OF_REDIAL_PERIOD:
{
LE_INFO(
"eCall state is LE_ECALL_STATE_END_OF_REDIAL_PERIOD.");
break;
}
case LE_ECALL_STATE_UNKNOWN:
default:
{
break;
}
}
}
static void StartTestECall
(
void
)
{
le_ecall_State_t state = LE_ECALL_STATE_UNKNOWN;
le_ecall_StateChangeHandlerRef_t stateChangeHandlerRef = 0x00;
ConnectAudio();
LE_ASSERT(((state>=LE_ECALL_STATE_STARTED) && (state<=LE_ECALL_STATE_FAILED)));
}
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:",
" app runProc eCallWVoice --exe=eCallWVoice -- <PSAP number>",
};
{
if(sandboxed)
{
}
else
{
fprintf(stderr, "%s\n", usagePtr[idx]);
}
}
}
{
{
signal(SIGINT, SigHandler);
LE_INFO(
"======== Start eCallWVoice Test with PSAP.%s ========", PsapNumber);
LE_INFO(
" Audio will be connected on Analogic or PCM interface.");
StartTestECall();
LE_INFO(
"======== eCallWVoice Test SUCCESS ========");
}
else
{
PrintUsage();
exit(EXIT_FAILURE);
}
}