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 | #include <GSM3ShieldV1.h>
|
---|
35 | #include <HardwareSerial.h>
|
---|
36 | #include <Arduino.h>
|
---|
37 |
|
---|
38 | #define __RESETPIN__ 7
|
---|
39 | #define __TOUTLOCALCOMS__ 500
|
---|
40 | #define __TOUTSHUTDOWN__ 5000
|
---|
41 | #define __TOUTMODEMCONFIGURATION__ 5000//equivalent to 30000 because of time in interrupt routine.
|
---|
42 | #define __TOUTAT__ 1000
|
---|
43 | #define __TOUTSMS__ 7000
|
---|
44 | #define __TOUTCALL__ 15000
|
---|
45 | #define __TOUTGPRS__ 10000
|
---|
46 | #define __NCLIENTS_MAX__ 3
|
---|
47 |
|
---|
48 | //Constructor.
|
---|
49 | GSM3ShieldV1::GSM3ShieldV1(bool db)
|
---|
50 | {
|
---|
51 | theGSM3ShieldV1ModemCore.setCommandCounter(1);
|
---|
52 | socketsAccepted=0;
|
---|
53 | theGSM3ShieldV1ModemCore.registerUMProvider(this);
|
---|
54 | theProvider=this;
|
---|
55 | }
|
---|
56 |
|
---|
57 | //Response management.
|
---|
58 | void GSM3ShieldV1::manageResponse(byte from, byte to)
|
---|
59 | {
|
---|
60 | switch(theGSM3ShieldV1ModemCore.getOngoingCommand())
|
---|
61 | {
|
---|
62 | case NONE:
|
---|
63 | theGSM3ShieldV1ModemCore.gss.cb.deleteToTheEnd(from);
|
---|
64 | break;
|
---|
65 |
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | //Function for 2 sec delay inside an interruption.
|
---|
70 | void GSM3ShieldV1::delayInsideInterrupt2seg()
|
---|
71 | {
|
---|
72 | for (int k=0;k<40;k++) theGSM3ShieldV1ModemCore.gss.tunedDelay(50000);
|
---|
73 | }
|
---|
74 |
|
---|
75 | ///////////////////////////////////////////////////////UNSOLICITED RESULT CODE (URC) FUNCTIONS///////////////////////////////////////////////////////////////////
|
---|
76 |
|
---|
77 | //URC recognize.
|
---|
78 | bool GSM3ShieldV1::recognizeUnsolicitedEvent(byte oldTail)
|
---|
79 | {
|
---|
80 |
|
---|
81 | int nlength;
|
---|
82 | char auxLocate [15];
|
---|
83 | //POWER DOWN.
|
---|
84 | prepareAuxLocate(PSTR("POWER DOWN"), auxLocate);
|
---|
85 | if(theGSM3ShieldV1ModemCore.gss.cb.locate(auxLocate))
|
---|
86 | {
|
---|
87 | theGSM3ShieldV1ModemCore.gss.cb.flush();
|
---|
88 | return true;
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | return false;
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|