Skip to content

Commit a175f61

Browse files
committed
Add Example 1 - Device Identification
Copied from original SARA-R5 library, and modified to work with new library.
1 parent 904a1c8 commit a175f61

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#include "SparkFun_u-blox_AT_Commands_Arduino_Library.h"
2+
3+
// Uncomment the line below that you need for Serial on your platform
4+
#define mySerial Serial1
5+
// SoftwareSerial mySerial(16, 17);
6+
7+
// Uncomment the module you're using. If your module is not listed below, then
8+
// it's not supported for this example
9+
UBLOX_AT myModule; // This example works with all modules, so the base class can be used
10+
// SARA_R5 myModule; // Base SARA-R5 class
11+
// SARA_R500S myModule;
12+
// SARA_R500S_01B myModule;
13+
// SARA_R500S_61B myModule;
14+
// SARA_R510M8S_61B myModule;
15+
// SARA_R510S myModule;
16+
// LARA_R6 myModule; // Base LARA-R6 class
17+
// LARA_R6001 myModule;
18+
// LARA_R6001D myModule;
19+
// LARA_R6401 myModule;
20+
// LARA_R6401D myModule;
21+
// LARA_R6801_00B myModule;
22+
// LARA_R6801D myModule;
23+
24+
// Map SIM states to more readable strings
25+
String simStateString[] =
26+
{
27+
"Not present", // 0
28+
"PIN needed", // 1
29+
"PIN blocked", // 2
30+
"PUK blocked", // 3
31+
"Not operational", // 4
32+
"Restricted", // 5
33+
"Operational" // 6
34+
};
35+
36+
// processSIMstate is provided to the SARA-R5 library via a
37+
// callback setter -- setSIMstateReadCallback. (See setup())
38+
void processSIMstate(UBLOX_AT_sim_states_t state)
39+
{
40+
Serial.println();
41+
Serial.print(F("SIM state: "));
42+
Serial.print(String(state));
43+
Serial.println();
44+
}
45+
46+
void begin()
47+
{
48+
Serial.begin(115200); // Start the serial console
49+
50+
// Wait for user to press key to begin
51+
Serial.println(F("SARA-R5 Example"));
52+
Serial.println(F("Press any key to begin"));
53+
54+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
55+
;
56+
while (Serial.available()) // Empty the serial RX buffer
57+
Serial.read();
58+
59+
//myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
60+
61+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
62+
// Comment the next line if required
63+
myModule.invertPowerPin(true);
64+
65+
// Initialize the SARA
66+
if (myModule.begin(mySerial, 9600) )
67+
{
68+
Serial.println(F("SARA-R5 connected!"));
69+
}
70+
else
71+
{
72+
Serial.println(F("Unable to communicate with the SARA."));
73+
Serial.println(F("Manually power-on (hold the SARA On button for 3 seconds) on and try again."));
74+
while (1) ; // Loop forever on fail
75+
}
76+
Serial.println();
77+
78+
Serial.println("Manufacturer ID: " + String(myModule.getManufacturerID()));
79+
Serial.println("Model ID: " + String(myModule.getModelID()));
80+
Serial.println("Firmware Version: " + String(myModule.getFirmwareVersion()));
81+
Serial.println("Product Serial No.: " + String(myModule.getSerialNo()));
82+
Serial.println("IMEI: " + String(myModule.getIMEI()));
83+
Serial.println("IMSI: " + String(myModule.getIMSI()));
84+
Serial.println("SIM CCID: " + String(myModule.getCCID()));
85+
Serial.println("Subscriber No.: " + String(myModule.getSubscriberNo()));
86+
Serial.println("Capabilities: " + String(myModule.getCapabilities()));
87+
88+
// Set a callback to return the SIM state once requested
89+
myModule.setSIMstateReportCallback(&processSIMstate);
90+
// Now enable SIM state reporting for states 0 to 6 (by setting the reporting mode LSb)
91+
if (myModule.setSIMstateReportingMode(1) == UBLOX_AT_SUCCESS)
92+
Serial.println("SIM state reports requested...");
93+
// You can disable the SIM staus reports again by calling assetTracker.setSIMstateReportingMode(0)
94+
}
95+
96+
void loop()
97+
{
98+
myModule.poll(); // Keep processing data from the SARA so we can extract the SIM status
99+
}

0 commit comments

Comments
 (0)