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 __GSM3DIRECTMODEMPROVIDER__
|
---|
36 | #define __GSM3DIRECTMODEMPROVIDER__
|
---|
37 |
|
---|
38 | #include <GSM3SoftSerial.h>
|
---|
39 | #include <GSM3MobileNetworkProvider.h>
|
---|
40 | #include <GSM3ShieldV1BaseProvider.h>
|
---|
41 | #include <Stream.h>
|
---|
42 | #include <Arduino.h>
|
---|
43 |
|
---|
44 | class GSM3ShieldV1DirectModemProvider : public GSM3ShieldV1BaseProvider, public Stream
|
---|
45 | {
|
---|
46 | private:
|
---|
47 |
|
---|
48 | bool trace;
|
---|
49 |
|
---|
50 | public:
|
---|
51 |
|
---|
52 | /** Constructor
|
---|
53 | @param trace if true, dumps all AT dialogue to Serial
|
---|
54 | */
|
---|
55 | GSM3ShieldV1DirectModemProvider(bool trace=false);
|
---|
56 |
|
---|
57 | /**
|
---|
58 | */
|
---|
59 | void begin();
|
---|
60 |
|
---|
61 | /**
|
---|
62 | */
|
---|
63 | void restartModem();
|
---|
64 |
|
---|
65 | /** Enable the debug process.
|
---|
66 | */
|
---|
67 | void connect();
|
---|
68 |
|
---|
69 | /** Disable the debug process.
|
---|
70 | */
|
---|
71 | void disconnect();
|
---|
72 |
|
---|
73 | /** Debug write to modem by means of SoftSerial.
|
---|
74 | @param c Character
|
---|
75 | @return size
|
---|
76 | */
|
---|
77 | size_t write(uint8_t c);
|
---|
78 |
|
---|
79 | /** Check for incoming bytes in buffer
|
---|
80 | @return
|
---|
81 | */
|
---|
82 | int available();
|
---|
83 |
|
---|
84 | /** Read from circular buffer
|
---|
85 | @return character
|
---|
86 | */
|
---|
87 | int read();
|
---|
88 |
|
---|
89 | /** Read from circular buffer, but do not delete it
|
---|
90 | @return character
|
---|
91 | */
|
---|
92 | int peek();
|
---|
93 |
|
---|
94 | /** Empty circular buffer
|
---|
95 | */
|
---|
96 | void flush();
|
---|
97 |
|
---|
98 | /** Manages modem response
|
---|
99 | @param from Initial byte of buffer
|
---|
100 | @param to Final byte of buffer
|
---|
101 | */
|
---|
102 | void manageResponse(byte from, byte to){};
|
---|
103 |
|
---|
104 | /** Recognize unsolicited event
|
---|
105 | @param from
|
---|
106 | @return true if successful
|
---|
107 | */
|
---|
108 | bool recognizeUnsolicitedEvent(byte from){return false;};
|
---|
109 |
|
---|
110 | /** Send AT command to modem
|
---|
111 | @param command AT command
|
---|
112 | @param delay Time to wait for response
|
---|
113 | @return response from modem
|
---|
114 | */
|
---|
115 | String writeModemCommand(String command, int delay);
|
---|
116 | };
|
---|
117 |
|
---|
118 | #endif
|
---|