[136] | 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 |
|
---|
| 35 | #ifndef _GSM3SHIELDV1VOICEPROVIDER_
|
---|
| 36 | #define _GSM3SHIELDV1VOICEPROVIDER_
|
---|
| 37 |
|
---|
| 38 | #include <GSM3MobileVoiceProvider.h>
|
---|
| 39 | #include <GSM3ShieldV1ModemCore.h>
|
---|
| 40 | #include <GSM3ShieldV1BaseProvider.h>
|
---|
| 41 |
|
---|
| 42 | class GSM3ShieldV1VoiceProvider : public GSM3MobileVoiceProvider, public GSM3ShieldV1BaseProvider
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 |
|
---|
| 46 | /** Constructor */
|
---|
| 47 | GSM3ShieldV1VoiceProvider();
|
---|
| 48 |
|
---|
| 49 | /** initilizer, links with modem provider */
|
---|
| 50 | void initialize();
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | /** Manages modem response
|
---|
| 54 | @param from Initial byte of buffer
|
---|
| 55 | @param to Final byte of buffer
|
---|
| 56 | */
|
---|
| 57 | void manageResponse(byte from, byte to);
|
---|
| 58 |
|
---|
| 59 | //Call functions.
|
---|
| 60 |
|
---|
| 61 | /** Launch a voice call
|
---|
| 62 | @param number Phone number to be called
|
---|
| 63 | @return If asynchronous, returns 0. If synchronous, 1 if success, other if error
|
---|
| 64 | */
|
---|
| 65 | int voiceCall(const char* number);
|
---|
| 66 |
|
---|
| 67 | /** Answer a voice call
|
---|
| 68 | @return If asynchronous, returns 0. If synchronous, 1 if success, other if error
|
---|
| 69 | */
|
---|
| 70 | int answerCall();
|
---|
| 71 |
|
---|
| 72 | /** Hang a voice call
|
---|
| 73 | @return If asynchronous, returns 0. If synchronous, 1 if success, other if error
|
---|
| 74 | */
|
---|
| 75 | int hangCall();
|
---|
| 76 |
|
---|
| 77 | /** Retrieve phone number of caller
|
---|
| 78 | @param buffer Buffer for copy phone number
|
---|
| 79 | @param bufsize Buffer size
|
---|
| 80 | @return If asynchronous, returns 0. If synchronous, 1 if success, other if error
|
---|
| 81 | */
|
---|
| 82 | int retrieveCallingNumber(char* buffer, int bufsize);
|
---|
| 83 |
|
---|
| 84 | /** Get last command status
|
---|
| 85 | @return Returns 0 if last command is still executing, 1 success, >1 error
|
---|
| 86 | */
|
---|
| 87 | int ready(){return GSM3ShieldV1BaseProvider::ready();};
|
---|
| 88 |
|
---|
| 89 | /** Recognize URC
|
---|
| 90 | @param oldTail
|
---|
| 91 | @return true if successful
|
---|
| 92 | */
|
---|
| 93 | bool recognizeUnsolicitedEvent(byte oldTail);
|
---|
| 94 |
|
---|
| 95 | /** Returns voice call status
|
---|
| 96 | @return voice call status
|
---|
| 97 | */
|
---|
| 98 | GSM3_voiceCall_st getvoiceCallStatus(){ready(); return _voiceCallstatus;};
|
---|
| 99 |
|
---|
| 100 | /** Set voice call status
|
---|
| 101 | @param status New status for voice call
|
---|
| 102 | */
|
---|
| 103 | void setvoiceCallStatus(GSM3_voiceCall_st status) { _voiceCallstatus = status; };
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | private:
|
---|
| 107 |
|
---|
| 108 | int phonelength; // Phone number length
|
---|
| 109 |
|
---|
| 110 | GSM3_voiceCall_st _voiceCallstatus; // The voiceCall status
|
---|
| 111 |
|
---|
| 112 | /** Continue to voice call function
|
---|
| 113 | */
|
---|
| 114 | void voiceCallContinue();
|
---|
| 115 |
|
---|
| 116 | /** Continue to answer call function
|
---|
| 117 | */
|
---|
| 118 | void answerCallContinue();
|
---|
| 119 |
|
---|
| 120 | /** Continue to hang call function
|
---|
| 121 | */
|
---|
| 122 | void hangCallContinue();
|
---|
| 123 |
|
---|
| 124 | /** Continue to retrieve calling number function
|
---|
| 125 | */
|
---|
| 126 | void retrieveCallingNumberContinue();
|
---|
| 127 |
|
---|
| 128 | /** Parse CLCC response from buffer
|
---|
| 129 | @param number Number initial for extract substring of response
|
---|
| 130 | @param nlength Substring length
|
---|
| 131 | @return true if successful
|
---|
| 132 | */
|
---|
| 133 | bool parseCLCC(char* number, int nlength);
|
---|
| 134 |
|
---|
| 135 | };
|
---|
| 136 |
|
---|
| 137 | #endif
|
---|