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 _GSM3SMSSERVICE_
|
---|
35 | #define _GSM3SMSSERVICE_
|
---|
36 |
|
---|
37 | #include <GSM3MobileSMSProvider.h>
|
---|
38 | #include <Stream.h>
|
---|
39 |
|
---|
40 | class GSM3SMSService : public Stream
|
---|
41 | {
|
---|
42 | private:
|
---|
43 |
|
---|
44 | uint8_t flags;
|
---|
45 |
|
---|
46 | /** Makes synchronous the functions, if needed
|
---|
47 | @param returnvalue Return value
|
---|
48 | @return returns 0 if last command is still executing, 1 success, >1 error
|
---|
49 | */
|
---|
50 | int waitForAnswerIfNeeded(int returnvalue);
|
---|
51 |
|
---|
52 | public:
|
---|
53 |
|
---|
54 | /** Constructor
|
---|
55 | @param synch Determines sync mode
|
---|
56 | */
|
---|
57 | GSM3SMSService(bool synch=true);
|
---|
58 |
|
---|
59 | /** Write a character in SMS message
|
---|
60 | @param c Character
|
---|
61 | @return size
|
---|
62 | */
|
---|
63 | size_t write(uint8_t c);
|
---|
64 |
|
---|
65 | /** Begin a SMS to send it
|
---|
66 | @param to Destination
|
---|
67 | @return error command if it exists
|
---|
68 | */
|
---|
69 | int beginSMS(const char* to);
|
---|
70 |
|
---|
71 | /** Get last command status
|
---|
72 | @return returns 0 if last command is still executing, 1 success, >1 error
|
---|
73 | */
|
---|
74 | int ready();
|
---|
75 |
|
---|
76 | /** End SMS
|
---|
77 | @return error command if it exists
|
---|
78 | */
|
---|
79 | int endSMS();
|
---|
80 |
|
---|
81 | /** Check if SMS available and prepare it to be read
|
---|
82 | @return number of bytes in a received SMS
|
---|
83 | */
|
---|
84 | int available();
|
---|
85 |
|
---|
86 | /** Read sender number phone
|
---|
87 | @param number Buffer for save number phone
|
---|
88 | @param nlength Buffer length
|
---|
89 | @return 1 success, >1 error
|
---|
90 | */
|
---|
91 | int remoteNumber(char* number, int nlength);
|
---|
92 |
|
---|
93 | /** Read one char for SMS buffer (advance circular buffer)
|
---|
94 | @return byte
|
---|
95 | */
|
---|
96 | int read();
|
---|
97 |
|
---|
98 | /** Read a byte but do not advance the buffer header (circular buffer)
|
---|
99 | @return byte
|
---|
100 | */
|
---|
101 | int peek();
|
---|
102 |
|
---|
103 | /** Delete the SMS from Modem memory and proccess answer
|
---|
104 | */
|
---|
105 | void flush();
|
---|
106 |
|
---|
107 | };
|
---|
108 |
|
---|
109 |
|
---|
110 | #endif
|
---|