1 | /*
|
---|
2 | This file is part of the GSM3 communications library for Arduino
|
---|
3 | -- Multi-transport communications platform
|
---|
4 | -- Fully asynchronous
|
---|
5 | -- Includes code for the Arduino-Telefonica GSM/GPRS Shield V1
|
---|
6 | -- Voice calls
|
---|
7 | -- SMS
|
---|
8 | -- TCP/IP connections
|
---|
9 | -- HTTP basic clients
|
---|
10 |
|
---|
11 | This library has been developed by Telefónica Digital - PDI -
|
---|
12 | - Physical Internet Lab, as part as its collaboration with
|
---|
13 | Arduino and the Open Hardware Community.
|
---|
14 |
|
---|
15 | September-December 2012
|
---|
16 |
|
---|
17 | This library is free software; you can redistribute it and/or
|
---|
18 | modify it under the terms of the GNU Lesser General Public
|
---|
19 | License as published by the Free Software Foundation; either
|
---|
20 | version 2.1 of the License, or (at your option) any later version.
|
---|
21 |
|
---|
22 | This library is distributed in the hope that it will be useful,
|
---|
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
25 | Lesser General Public License for more details.
|
---|
26 |
|
---|
27 | You should have received a copy of the GNU Lesser General Public
|
---|
28 | License along with this library; if not, write to the Free Software
|
---|
29 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
30 |
|
---|
31 | The latest version of this library can always be found at
|
---|
32 | https://github.com/BlueVia/Official-Arduino
|
---|
33 | */
|
---|
34 | #ifndef _GSM3VOICECALLSERVICE_
|
---|
35 | #define _GSM3VOICECALLSERVICE_
|
---|
36 |
|
---|
37 | #include <GSM3MobileNetworkProvider.h>
|
---|
38 | #include <GSM3MobileVoiceProvider.h>
|
---|
39 |
|
---|
40 | class GSM3VoiceCallService
|
---|
41 | {
|
---|
42 | private:
|
---|
43 | uint8_t flags;
|
---|
44 |
|
---|
45 | /** Make synchronous the functions, if needed
|
---|
46 | @param returnvalue Return value
|
---|
47 | @return returns 0 if last command is still executing, 1 success, >1 error
|
---|
48 | */
|
---|
49 | int waitForAnswerIfNeeded(int returnvalue);
|
---|
50 |
|
---|
51 | public:
|
---|
52 | /** Service creation
|
---|
53 | @param synch If true, the service calls are synchronois
|
---|
54 | */
|
---|
55 | GSM3VoiceCallService(bool synch=true);
|
---|
56 |
|
---|
57 | /** Voice call status
|
---|
58 | @return Status of the voice call, as described in GSM3MobileVoiceProvider.h
|
---|
59 | { IDLE_CALL, CALLING, RECEIVINGCALL, TALKING};
|
---|
60 | */
|
---|
61 | GSM3_voiceCall_st getvoiceCallStatus();
|
---|
62 |
|
---|
63 | /** Get last command status
|
---|
64 | @return Returns 0 if last command is still executing, 1 success, >1 error
|
---|
65 | */
|
---|
66 | int ready();
|
---|
67 |
|
---|
68 | /** Place a voice call. If asynchronous, returns while ringing. If synchronous
|
---|
69 | returns if the call is stablished or cancelled.
|
---|
70 | @param to Receiver number. Country extension can be used or not.
|
---|
71 | Char buffer should not be released or used until command is over
|
---|
72 | @param timeout In millisecods. Time ringing before closing the call.
|
---|
73 | Only used in synchronous mode.
|
---|
74 | If zero, ring undefinitely
|
---|
75 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error
|
---|
76 | In synchronous mode returns 1 if the call is placed, 0 if not.
|
---|
77 | */
|
---|
78 | int voiceCall(const char* to, unsigned long timeout=30000);
|
---|
79 |
|
---|
80 | /** Accept an incoming voice call
|
---|
81 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error
|
---|
82 | In synchronous mode returns 1 if the call is answered, 0 if not.
|
---|
83 | */
|
---|
84 | int answerCall();
|
---|
85 |
|
---|
86 | /** Hang a stablished call or an incoming ring
|
---|
87 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error
|
---|
88 | In synchronous mode returns 1 if the call is answered, 0 if not.
|
---|
89 | */
|
---|
90 | int hangCall();
|
---|
91 |
|
---|
92 | /** Retrieve the calling number, put it in buffer
|
---|
93 | @param buffer pointer to the buffer memory
|
---|
94 | @param bufsize size of available memory area, at least should be 10 characters
|
---|
95 | @return In asynchronous mode returns 0 if last command is still executing, 1 success, >1 error
|
---|
96 | In synchronous mode returns 1 if the number is correcty taken 0 if not
|
---|
97 | */
|
---|
98 | int retrieveCallingNumber(char* buffer, int bufsize);
|
---|
99 | };
|
---|
100 |
|
---|
101 |
|
---|
102 | #endif
|
---|