[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 | #ifndef _GSM3SHIELDV1ACCESSPROVIDER_
|
---|
| 35 | #define _GSM3SHIELDV1ACCESSPROVIDER_
|
---|
| 36 |
|
---|
| 37 | #include <GSM3MobileAccessProvider.h>
|
---|
| 38 | #include <GSM3ShieldV1ModemCore.h>
|
---|
| 39 | #include <GSM3ShieldV1BaseProvider.h>
|
---|
| 40 |
|
---|
| 41 | class GSM3ShieldV1AccessProvider : public GSM3MobileAccessProvider, public GSM3ShieldV1BaseProvider
|
---|
| 42 | {
|
---|
| 43 | private:
|
---|
| 44 |
|
---|
| 45 | /** Initialize main modem configuration
|
---|
| 46 | @param pin PIN code
|
---|
| 47 | @return command error if exists
|
---|
| 48 | */
|
---|
| 49 | int ModemConfiguration(char* pin);
|
---|
| 50 |
|
---|
| 51 | /** Continue to modem configuration function
|
---|
| 52 | */
|
---|
| 53 | void ModemConfigurationContinue();
|
---|
| 54 |
|
---|
| 55 | /** Continue to check if modem alive function
|
---|
| 56 | */
|
---|
| 57 | void isModemAliveContinue();
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | public:
|
---|
| 61 |
|
---|
| 62 | /** Constructor
|
---|
| 63 | @param debug Determines debug mode
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | GSM3ShieldV1AccessProvider(bool debug=false);
|
---|
| 67 |
|
---|
| 68 | /** Start the GSM/GPRS modem, attaching to the GSM network
|
---|
| 69 | @param pin SIM PIN number (4 digits in a string, example: "1234"). If
|
---|
| 70 | NULL the SIM has no configured PIN.
|
---|
| 71 | @param restart Restart the modem. Default is TRUE. The modem receives
|
---|
| 72 | a signal through the Ctrl/D7 pin. If it is shut down, it will
|
---|
| 73 | start-up. If it is running, it will restart. Takes up to 10
|
---|
| 74 | seconds
|
---|
| 75 | @param synchronous If TRUE the call only returns after the Start is complete
|
---|
| 76 | or fails. If FALSE the call will return inmediately. You have
|
---|
| 77 | to call repeatedly ready() until you get a result. Default is TRUE.
|
---|
| 78 | @return If synchronous, GSM3_NetworkStatus_t. If asynchronous, returns 0.
|
---|
| 79 | */
|
---|
| 80 | GSM3_NetworkStatus_t begin(char* pin=0,bool restart=true, bool synchronous=true);
|
---|
| 81 |
|
---|
| 82 | /** Check network access status
|
---|
| 83 | @return 1 if Alive, 0 if down
|
---|
| 84 | */
|
---|
| 85 | int isAccessAlive();
|
---|
| 86 |
|
---|
| 87 | /** Shutdown the modem (power off really)
|
---|
| 88 | @return true if successful
|
---|
| 89 | */
|
---|
| 90 | bool shutdown();
|
---|
| 91 |
|
---|
| 92 | /** Secure shutdown the modem (power off really)
|
---|
| 93 | @return true if successful
|
---|
| 94 | */
|
---|
| 95 | bool secureShutdown();
|
---|
| 96 |
|
---|
| 97 | /** Returns 0 if last command is still executing
|
---|
| 98 | @return 1 if success, >1 if error
|
---|
| 99 | */
|
---|
| 100 | int ready(){return GSM3ShieldV1BaseProvider::ready();};
|
---|
| 101 |
|
---|
| 102 | /** Returns modem status
|
---|
| 103 | @return modem network status
|
---|
| 104 | */
|
---|
| 105 | inline GSM3_NetworkStatus_t getStatus(){return theGSM3ShieldV1ModemCore.getStatus();};
|
---|
| 106 |
|
---|
| 107 | void manageResponse(byte from, byte to);
|
---|
| 108 |
|
---|
| 109 | /** Restart the modem (will shut down if running)
|
---|
| 110 | @return 1 if success, >1 if error
|
---|
| 111 | */
|
---|
| 112 | int HWrestart();
|
---|
| 113 |
|
---|
| 114 | /** Start the modem (will not shut down if running)
|
---|
| 115 | @return 1 if success, >1 if error
|
---|
| 116 | */
|
---|
| 117 | int HWstart();
|
---|
| 118 |
|
---|
| 119 | };
|
---|
| 120 |
|
---|
| 121 | #endif
|
---|