BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
8af99420
Commit
8af99420
authored
Nov 17, 2016
by
David Frey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup formatting of voice call app
parent
89e178eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
79 deletions
+50
-79
mangohVoiceCall.c
samples/tutorials/voice/mangohVoiceCall/mangohVoiceCall.c
+50
-79
No files found.
samples/tutorials/voice/mangohVoiceCall/mangohVoiceCall.c
View file @
8af99420
/**
* This application allows you to make phone call on mangOH platform
* You will need to have a voice SIM installed on the platform
* Also, you need a headset with mic and speaker connected to headset jack CN500
*
* Page below gives you a good understanding of the fundamentals of the voice call
* http://legato.io/legato-docs/latest/c_audio.html
*
* The voice service connects the modem voice RX to speaker & modem voice TX to Mic
*
* Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
*
*/
/**
* This application allows you to make phone call on mangOH platform. You will need to have a voice
* SIM installed on the platform. Also, you need a headset with mic and speaker connected to headset
* jack CN500.
*
* For information on the fundamentals of the voice call API, visit
* http://legato.io/legato-docs/latest/c_audio.html
*
* The voice service connects the modem voice RX to speaker & modem voice TX to Mic.
*
* Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
*/
#include "legato.h"
#include "interfaces.h"
...
...
@@ -37,7 +36,7 @@ static le_voicecall_StateHandlerRef_t VoiceCallHandlerRef;
* Destination Phone number.
*/
//--------------------------------------------------------------------------------------------------
static
char
DestinationNumber
[
LE_MDMDEFS_PHONE_NUM_MAX_BYTES
];
static
char
DestinationNumber
[
LE_MDMDEFS_PHONE_NUM_MAX_BYTES
];
//--------------------------------------------------------------------------------------------------
...
...
@@ -58,7 +57,6 @@ static le_audio_ConnectorRef_t AudioOutputConnectorRef;
//--------------------------------------------------------------------------------------------------
/**
* Close Audio Stream.
*
*/
//--------------------------------------------------------------------------------------------------
static
void
DisconnectAllAudio
...
...
@@ -76,65 +74,64 @@ static void DisconnectAllAudio
LE_INFO
(
"Disconnect %p from connector.%p"
,
HeadsetMicRef
,
AudioInputConnectorRef
);
le_audio_Disconnect
(
AudioInputConnectorRef
,
HeadsetMicRef
);
}
if
(
MdmTxAudioRef
)
if
(
MdmTxAudioRef
)
{
LE_INFO
(
"Disconnect %p from connector.%p"
,
MdmTxAudioRef
,
AudioInputConnectorRef
);
le_audio_Disconnect
(
AudioInputConnectorRef
,
MdmTxAudioRef
);
}
}
if
(
AudioOutputConnectorRef
)
if
(
AudioOutputConnectorRef
)
{
LE_INFO
(
"le_audio_Disconnect %p from connector.%p"
,
MdmTxAudioRef
,
AudioOutputConnectorRef
);
if
(
HeadsetSpeakerRef
)
LE_INFO
(
"le_audio_Disconnect %p from connector.%p"
,
MdmTxAudioRef
,
AudioOutputConnectorRef
);
if
(
HeadsetSpeakerRef
)
{
LE_INFO
(
"Disconnect %p from connector.%p"
,
HeadsetSpeakerRef
,
AudioOutputConnectorRef
);
le_audio_Disconnect
(
AudioOutputConnectorRef
,
HeadsetSpeakerRef
);
}
if
(
MdmRxAudioRef
)
if
(
MdmRxAudioRef
)
{
LE_INFO
(
"Disconnect %p from connector.%p"
,
MdmRxAudioRef
,
AudioOutputConnectorRef
);
le_audio_Disconnect
(
AudioOutputConnectorRef
,
MdmRxAudioRef
);
}
}
if
(
AudioInputConnectorRef
)
if
(
AudioInputConnectorRef
)
{
le_audio_DeleteConnector
(
AudioInputConnectorRef
);
AudioInputConnectorRef
=
NULL
;
}
if
(
AudioOutputConnectorRef
)
if
(
AudioOutputConnectorRef
)
{
le_audio_DeleteConnector
(
AudioOutputConnectorRef
);
AudioOutputConnectorRef
=
NULL
;
}
if
(
HeadsetMicRef
)
if
(
HeadsetMicRef
)
{
le_audio_Close
(
HeadsetMicRef
);
HeadsetMicRef
=
NULL
;
}
if
(
HeadsetSpeakerRef
)
if
(
HeadsetSpeakerRef
)
{
le_audio_Close
(
HeadsetSpeakerRef
);
HeadsetSpeakerRef
=
NULL
;
}
if
(
MdmRxAudioRef
)
if
(
MdmRxAudioRef
)
{
le_audio_Close
(
MdmRxAudioRef
);
MdmRxAudioRef
=
NULL
;
}
if
(
MdmTxAudioRef
)
if
(
MdmTxAudioRef
)
{
le_audio_Close
(
MdmTxAudioRef
);
MdmTxAudioRef
=
NULL
;
le_audio_Close
(
MdmTxAudioRef
);
MdmTxAudioRef
=
NULL
;
}
}
//--------------------------------------------------------------------------------------------------
/**
* Open Audio Stream.
*
*/
//--------------------------------------------------------------------------------------------------
static
le_result_t
OpenAudio
...
...
@@ -145,10 +142,10 @@ static le_result_t OpenAudio
le_result_t
res
;
MdmRxAudioRef
=
le_voicecall_GetRxAudioStream
(
reference
);
LE_ERROR_IF
((
MdmRxAudioRef
==
NULL
),
"le_voicecall_GetRxAudioStream returns NULL!"
);
LE_ERROR_IF
((
MdmRxAudioRef
==
NULL
),
"le_voicecall_GetRxAudioStream returns NULL!"
);
MdmTxAudioRef
=
le_voicecall_GetTxAudioStream
(
reference
);
LE_ERROR_IF
((
MdmTxAudioRef
==
NULL
),
"le_voicecall_GetRxAudioStream returns NULL!"
);
LE_ERROR_IF
((
MdmTxAudioRef
==
NULL
),
"le_voicecall_GetRxAudioStream returns NULL!"
);
LE_DEBUG
(
"OpenAudio MdmRxAudioRef %p, MdmTxAudioRef %p"
,
MdmRxAudioRef
,
MdmTxAudioRef
);
...
...
@@ -156,36 +153,34 @@ static le_result_t OpenAudio
// Redirect audio to the Headset Microphone and Speaker.
HeadsetSpeakerRef
=
le_audio_OpenSpeaker
();
LE_ERROR_IF
((
HeadsetSpeakerRef
==
NULL
),
"le_audio_OpenSpeaker returns NULL!"
);
LE_ERROR_IF
((
HeadsetSpeakerRef
==
NULL
),
"le_audio_OpenSpeaker returns NULL!"
);
HeadsetMicRef
=
le_audio_OpenMic
();
LE_ERROR_IF
((
HeadsetMicRef
==
NULL
),
"le_audio_OpenMic returns NULL!"
);
LE_ERROR_IF
((
HeadsetMicRef
==
NULL
),
"le_audio_OpenMic returns NULL!"
);
AudioInputConnectorRef
=
le_audio_CreateConnector
();
LE_ERROR_IF
((
AudioInputConnectorRef
==
NULL
),
"AudioInputConnectorRef is NULL!"
);
LE_ERROR_IF
((
AudioInputConnectorRef
==
NULL
),
"AudioInputConnectorRef is NULL!"
);
AudioOutputConnectorRef
=
le_audio_CreateConnector
();
LE_ERROR_IF
((
AudioOutputConnectorRef
==
NULL
),
"AudioOutputConnectorRef is NULL!"
);
LE_ERROR_IF
((
AudioOutputConnectorRef
==
NULL
),
"AudioOutputConnectorRef is NULL!"
);
if
(
MdmRxAudioRef
&&
MdmTxAudioRef
&&
HeadsetSpeakerRef
&&
HeadsetMicRef
&&
AudioInputConnectorRef
&&
AudioOutputConnectorRef
)
AudioInputConnectorRef
&&
AudioOutputConnectorRef
)
{
res
=
le_audio_Connect
(
AudioInputConnectorRef
,
HeadsetMicRef
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect RX on Input connector!"
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect RX on Input connector!"
);
res
=
le_audio_Connect
(
AudioInputConnectorRef
,
MdmTxAudioRef
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect mdmTx on Input connector!"
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect mdmTx on Input connector!"
);
res
=
le_audio_Connect
(
AudioOutputConnectorRef
,
HeadsetSpeakerRef
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect TX on Output connector!"
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect TX on Output connector!"
);
res
=
le_audio_Connect
(
AudioOutputConnectorRef
,
MdmRxAudioRef
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect mdmRx on Output connector!"
);
LE_ERROR_IF
((
res
!=
LE_OK
),
"Failed to connect mdmRx on Output connector!"
);
}
return
LE_OK
;
}
//--------------------------------------------------------------------------------------------------
/**
* Handler function for Call Event Notifications.
*
*/
//--------------------------------------------------------------------------------------------------
static
void
MyCallEventHandler
...
...
@@ -196,11 +191,11 @@ static void MyCallEventHandler
void
*
contextPtr
)
{
le_result_t
res
;
le_result_t
res
;
le_voicecall_TerminationReason_t
term
=
LE_VOICECALL_TERM_UNDEFINED
;
LE_INFO
(
"Voice Call : New Call event: %d for Call %p, from %s"
,
callEvent
,
reference
,
identifier
);
LE_INFO
(
"Voice Call : New Call event: %d for Call %p, from %s"
,
callEvent
,
reference
,
identifier
);
if
(
callEvent
==
LE_VOICECALL_EVENT_ALERTING
)
{
...
...
@@ -216,7 +211,7 @@ static void MyCallEventHandler
DisconnectAllAudio
(
reference
);
LE_INFO
(
"Check MyCallEventHandler passed, event is LE_VOICECALL_EVENT_TERMINATED."
);
le_voicecall_GetTerminationReason
(
reference
,
&
term
);
switch
(
term
)
switch
(
term
)
{
case
LE_VOICECALL_TERM_NETWORK_FAIL
:
{
...
...
@@ -241,7 +236,6 @@ static void MyCallEventHandler
{
LE_INFO
(
"Termination reason is LE_VOICECALL_TERM_REMOTE_ENDED"
);
LE_INFO
(
"---!!!! PLEASE CREATE AN INCOMING CALL !!!!---"
);
}
break
;
...
...
@@ -249,21 +243,18 @@ static void MyCallEventHandler
{
LE_INFO
(
"Termination reason is LE_VOICECALL_TERM_UNDEFINED"
);
LE_ERROR
(
"---!!!! PLEASE CREATE AN INCOMING CALL !!!!---"
);
}
break
;
default:
{
LE_ERROR
(
"Termination reason is %d"
,
term
);
}
break
;
}
le_voicecall_Delete
(
reference
);
exit
(
EXIT_SUCCESS
);
}
else
if
(
callEvent
==
LE_VOICECALL_EVENT_INCOMING
)
{
...
...
@@ -293,35 +284,18 @@ static void MyCallEventHandler
}
}
//--------------------------------------------------------------------------------------------------
/**
* Create and start a voice call.
*
*/
//--------------------------------------------------------------------------------------------------
static
le_result_t
MangohVoicecall_Start
(
void
)
static
le_result_t
MangohVoicecall_Start
(
void
)
{
le_voicecall_TerminationReason_t
reason
=
LE_VOICECALL_TERM_UNDEFINED
;
VoiceCallRef
=
le_voicecall_Start
(
DestinationNumber
);
if
(
!
VoiceCallRef
)
{
LE_INFO
(
"le_voicecall_GetTerminationReason %d"
,
reason
);
return
LE_FAULT
;
}
else
{
return
LE_OK
;
}
}
return
VoiceCallRef
?
LE_OK
:
LE_FAULT
;
}
//--------------------------------------------------------------------------------------------------
/*
...
...
@@ -334,25 +308,22 @@ static le_result_t MangohVoicecall_Start
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO
(
"############### Voice call test"
);
int
nbArgument
=
0
;
nbArgument
=
le_arg_NumArgs
();
if
(
nbArgument
==
1
)
if
(
le_arg_NumArgs
()
==
1
)
{
// This function gets the telephone number from the User.
const
char
*
phoneNumber
=
le_arg_GetArg
(
0
);
strncpy
(
DestinationNumber
,
phoneNumber
,
LE_MDMDEFS_PHONE_NUM_MAX_BYTES
);
strncpy
(
DestinationNumber
,
phoneNumber
,
LE_MDMDEFS_PHONE_NUM_MAX_BYTES
-
1
);
LE_INFO
(
"Phone number %s"
,
DestinationNumber
);
LE_ASSERT
(
MangohVoicecall_Start
()
==
LE_OK
);
}
else
{
LE_INFO
(
"PRINT USAGE => app runProc mangohVoiceCall --exe = mangohVoiceCall -- <Destination phone number>"
);
LE_INFO
(
"PRINT USAGE => app runProc mangohVoiceCall --exe = mangohVoiceCall -- <Destination "
"phone number>"
);
exit
(
EXIT_FAILURE
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment