source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/libraries/GSM/examples/Tools/TestModem/TestModem.ino @ 46

Last change on this file since 46 was 46, checked in by jrpelegrina, 4 years ago

First release to Xenial

File size: 1.5 KB
Line 
1/*
2
3 This example tests to see if the modem of the
4 GSM shield is working correctly. You do not need
5 a SIM card for this example.
6
7 Circuit:
8 * GSM shield attached
9
10 Created 12 Jun 2012
11 by David del Peral
12 modified 21 Nov 2012
13 by Tom Igoe
14
15 http://www.arduino.cc/en/Tutorial/GSMToolsTestModem
16
17 This sample code is part of the public domain
18
19 */
20
21// libraries
22#include <GSM.h>
23
24// modem verification object
25GSMModem modem;
26
27// IMEI variable
28String IMEI = "";
29
30void setup() {
31  // initialize serial communications and wait for port to open:
32  Serial.begin(9600);
33  while (!Serial) {
34    ; // wait for serial port to connect. Needed for Leonardo only
35  }
36
37  // start modem test (reset and check response)
38  Serial.print("Starting modem test...");
39  if (modem.begin()) {
40    Serial.println("modem.begin() succeeded");
41  } else {
42    Serial.println("ERROR, no modem answer.");
43  }
44}
45
46void loop() {
47  // get modem IMEI
48  Serial.print("Checking IMEI...");
49  IMEI = modem.getIMEI();
50
51  // check IMEI response
52  if (IMEI != NULL) {
53    // show IMEI in serial monitor
54    Serial.println("Modem's IMEI: " + IMEI);
55    // reset modem to check booting:
56    Serial.print("Resetting modem...");
57    modem.begin();
58    // get and check IMEI one more time
59    if (modem.getIMEI() != NULL) {
60      Serial.println("Modem is functoning properly");
61    } else {
62      Serial.println("Error: getIMEI() failed after modem.begin()");
63    }
64  } else {
65    Serial.println("Error: Could not get IMEI");
66  }
67  // do nothing:
68  while (true);
69}
70
Note: See TracBrowser for help on using the repository browser.