[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 | #include <GSM3ShieldV1ModemVerification.h>
|
---|
| 36 |
|
---|
| 37 | // constructor
|
---|
| 38 | GSM3ShieldV1ModemVerification::GSM3ShieldV1ModemVerification()
|
---|
| 39 | {
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 | // reset the modem for direct access
|
---|
| 43 | int GSM3ShieldV1ModemVerification::begin()
|
---|
| 44 | {
|
---|
| 45 | int result=0;
|
---|
| 46 | String modemResponse;
|
---|
| 47 |
|
---|
| 48 | // check modem response
|
---|
| 49 | modemAccess.begin();
|
---|
| 50 |
|
---|
| 51 | // reset hardware
|
---|
| 52 | modemAccess.restartModem();
|
---|
| 53 |
|
---|
| 54 | modemResponse=modemAccess.writeModemCommand("AT", 1000);
|
---|
| 55 | if(modemResponse.indexOf("OK")>=0)
|
---|
| 56 | result=1;
|
---|
| 57 | modemResponse=modemAccess.writeModemCommand("ATE0", 1000);
|
---|
| 58 | return result;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | // get IMEI
|
---|
| 62 | String GSM3ShieldV1ModemVerification::getIMEI()
|
---|
| 63 | {
|
---|
| 64 | String number(NULL);
|
---|
| 65 | // AT command for obtain IMEI
|
---|
| 66 | String modemResponse = modemAccess.writeModemCommand("AT+GSN", 2000);
|
---|
| 67 | // Parse and check response
|
---|
| 68 | char res_to_compare[modemResponse.length()];
|
---|
| 69 | modemResponse.toCharArray(res_to_compare, modemResponse.length());
|
---|
| 70 | if(strstr(res_to_compare,"OK") != NULL)
|
---|
| 71 | number = modemResponse.substring(1, 17);
|
---|
| 72 | return number;
|
---|
| 73 | }
|
---|