aboutsummaryrefslogtreecommitdiff
path: root/libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
committerCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
commitee90e68e86dd61d86f5d17b69080338328765b22 (patch)
treee620c0edc2690ab789b665e567910640597aa6fe /libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino
parent0ecdc5ebc96ad4c7c548c438a03d9ce00679db8b (diff)
parentf50c307be280dc6ece9e70c43b301c1db36291a0 (diff)
Merged 1.0.5
Merge remote-tracking branch 'arduino/master' into ide-1.5.x Conflicts: app/src/processing/app/Base.java build/shared/revisions.txt hardware/arduino/avr/cores/arduino/malloc.c hardware/arduino/cores/arduino/avr-libc/malloc.c hardware/arduino/cores/arduino/malloc.c todo.txt
Diffstat (limited to 'libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino')
-rw-r--r--libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino95
1 files changed, 95 insertions, 0 deletions
diff --git a/libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino b/libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino
new file mode 100644
index 0000000..0e442eb
--- /dev/null
+++ b/libraries/GSM/examples/Tools/GsmScanNetworks/GsmScanNetworks.ino
@@ -0,0 +1,95 @@
+/*
+
+ GSM Scan Networks
+
+ This example prints out the IMEI number of the modem,
+ then checks to see if it's connected to a carrier. If so,
+ it prints the phone number associated with the card.
+ Then it scans for nearby networks and prints out their signal strengths.
+
+ Circuit:
+ * GSM shield
+ * SIM card
+
+ Created 8 Mar 2012
+ by Tom Igoe, implemented by Javier Carazo
+ Modified 4 Feb 2013
+ by Scott Fitzgerald
+
+ http://arduino.cc/en/Tutorial/GSMToolsGsmScanNetworks
+
+ This example code is part of the public domain
+ */
+
+// libraries
+#include <GSM.h>
+
+// PIN Number
+#define PINNUMBER ""
+
+// initialize the library instance
+GSM gsmAccess; // include a 'true' parameter to enable debugging
+GSMScanner scannerNetworks;
+GSMModem modemTest;
+
+// Save data variables
+String IMEI = "";
+
+// serial monitor result messages
+String errortext = "ERROR";
+
+void setup()
+{
+ // initialize serial communications and wait for port to open:
+ Serial.begin(9600);
+ while (!Serial) {
+ ; // wait for serial port to connect. Needed for Leonardo only
+ }
+
+ Serial.println("GSM networks scanner");
+ scannerNetworks.begin();
+
+ // connection state
+ boolean notConnected = true;
+
+ // Start GSM shield
+ // If your SIM has PIN, pass it as a parameter of begin() in quotes
+ while(notConnected)
+ {
+ if(gsmAccess.begin(PINNUMBER)==GSM_READY)
+ notConnected = false;
+ else
+ {
+ Serial.println("Not connected");
+ delay(1000);
+ }
+ }
+
+ // get modem parameters
+ // IMEI, modem unique identifier
+ Serial.print("Modem IMEI: ");
+ IMEI = modemTest.getIMEI();
+ IMEI.replace("\n","");
+ if(IMEI != NULL)
+ Serial.println(IMEI);
+}
+
+void loop()
+{
+ // scan for existing networks, displays a list of networks
+ Serial.println("Scanning available networks. May take some seconds.");
+ Serial.println(scannerNetworks.readNetworks());
+
+ // currently connected carrier
+ Serial.print("Current carrier: ");
+ Serial.println(scannerNetworks.getCurrentCarrier());
+
+ // returns strength and ber
+ // signal strength in 0-31 scale. 31 means power > 51dBm
+ // BER is the Bit Error Rate. 0-7 scale. 99=not detectable
+ Serial.print("Signal Strength: ");
+ Serial.print(scannerNetworks.getSignalStrength());
+ Serial.println(" [0-31]");
+
+}
+