#include "interfaces.h"
static const char * PsapNumber = NULL;
static const char AudioFilePath[] = "/male.wav";
static int AudioFileFd = -1;
static void DisconnectAudio
(
void
)
{
if(AudioOutputConnectorRef)
{
if(FileAudioRef)
{
LE_INFO(
"Disconnect %p from connector.%p", FileAudioRef, AudioOutputConnectorRef);
}
if(FeOutRef)
{
LE_INFO(
"Disconnect %p from connector.%p", FeOutRef, AudioOutputConnectorRef);
}
}
if(AudioOutputConnectorRef)
{
AudioOutputConnectorRef = NULL;
}
if(FileAudioRef)
{
FileAudioRef = NULL;
}
if(FeOutRef)
{
FeOutRef = NULL;
}
close(AudioFileFd);
}
static void MyMediaEventHandler
(
void* contextPtr
)
{
switch(event)
{
LE_INFO(
"File event is LE_AUDIO_MEDIA_ENDED.");
{
return;
}
else
{
}
break;
LE_INFO(
"File event is LE_AUDIO_MEDIA_ERROR.");
break;
LE_INFO(
"File event is LE_AUDIO_MEDIA_NO_MORE_SAMPLES.");
break;
default:
LE_INFO(
"File event is %d", event);
break;
}
}
static void ConnectAudio
(
void
)
{
#ifdef ENABLE_CODEC
LE_ERROR_IF((FeOutRef==NULL),
"OpenSpeaker returns NULL!");
LE_INFO(
"Open Speaker: FeOutRef.%p", FeOutRef);
#else
LE_ERROR_IF((FeOutRef==NULL),
"OpenI2sTx returns NULL!");
LE_INFO(
"Open I2S: FeOutRef.%p", FeOutRef);
#endif
LE_ERROR_IF((AudioOutputConnectorRef==NULL),
"AudioOutputConnectorRef is NULL!");
{
"Failed to connect I2S TX on Output connector!");
}
LE_ERROR_IF((FileAudioRef==NULL),
"OpenFilePlayback returns NULL!");
MyMediaEventHandler,
NULL);
{
LE_ERROR(
"Failed to connect FilePlayback on output connector!");
return;
}
if ((AudioFileFd=open(AudioFilePath, O_RDONLY)) == -1)
{
LE_ERROR(
"Open file %s failure: errno.%d (%s)", AudioFilePath, errno, strerror(errno));
DisconnectAudio();
exit(0);
}
else
{
LE_INFO(
"Open file %s with AudioFileFd.%d", AudioFilePath, AudioFileFd);
}
{
return;
}
}
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.");
break;
}
{
#if (ENABLE_CODEC == 1)
LE_INFO(
"Mute Speaker and voice prompt.");
#else
LE_INFO(
"Mute I2S Tx interface and voice prompt.");
#endif
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)
LE_INFO(
"Unmute Speaker and voice prompt.");
#else
LE_INFO(
"Unmute I2S Tx interface and voice prompt.");
#endif
break;
}
{
LE_INFO(
"eCall state is LE_ECALL_STATE_RESET.");
#if (ENABLE_CODEC == 1)
LE_INFO(
"Unmute Speaker and voice prompt.");
#else
LE_INFO(
"Unmute I2S Tx interface and voice prompt.");
#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)
LE_INFO(
"Unmute Speaker and voice prompt.");
#else
LE_INFO(
"Unmute I2S Tx interface and voice prompt.");
#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 eCallWPrompt is:",
" eCallWPrompt <PSAP number>",
};
{
if(sandboxed)
{
}
else
{
fprintf(stderr, "%s\n", usagePtr[idx]);
}
}
}
{
{
signal(SIGINT, SigHandler);
LE_INFO(
"======== Start eCallWPrompt Test with PSAP.%s========",
PsapNumber);
StartTestECall();
LE_INFO(
"======== eCallWPrompt Test SUCCESS ========");
}
else
{
PrintUsage();
exit(EXIT_FAILURE);
}
}