Skip to content

Commit 69138f8

Browse files
committed
Added the network info example and extra network operators
1 parent 4ef569b commit 69138f8

File tree

4 files changed

+189
-8
lines changed

4 files changed

+189
-8
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
Register your SARA-R5/SIM combo on a mobile network operator
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: October 20th 2020
6+
7+
Please see LICENSE.md for the license information
8+
9+
This example demonstrates how to initialize your MicroMod Asset Tracker Carrier Board and
10+
connect it to a mobile network operator (Verizon, AT&T, T-Mobile, etc.).
11+
12+
Before beginning, you may need to adjust the mobile network operator (MNO)
13+
setting on line 83. See comments above that line to help select either
14+
Verizon, T-Mobile, AT&T or others.
15+
16+
This code is intend to run on the MicroMod Asset Tracker Carrier Board
17+
using (e.g.) the MicroMod Artemis Processor Board
18+
19+
Select the SparkFun RedBoard Artemis ATP from the SparkFun Apollo3 boards
20+
21+
*/
22+
23+
//Click here to get the library: http://librarymanager/All#SparkFun_u-blox_SARA-R5_Arduino_Library
24+
#include <SparkFun_u-blox_SARA-R5_Arduino_Library.h>
25+
26+
// Uncomment the next line to connect to the SARA-R5 using hardware Serial1
27+
#define saraSerial Serial1
28+
29+
// Uncomment the next line to create a SoftwareSerial object to pass to the SARA-R5 library instead
30+
//SoftwareSerial saraSerial(8, 9);
31+
32+
// Create a SARA_R5 object to use throughout the sketch
33+
SARA_R5 assetTracker;
34+
35+
// Map registration status messages to more readable strings
36+
String registrationString[] =
37+
{
38+
"Not registered", // 0
39+
"Registered, home", // 1
40+
"Searching for operator", // 2
41+
"Registration denied", // 3
42+
"Registration unknown", // 4
43+
"Registered, roaming", // 5
44+
"Registered, home (SMS only)", // 6
45+
"Registered, roaming (SMS only)", // 7
46+
"Registered, emergency service only", // 8
47+
"Registered, home, CSFB not preferred", // 9
48+
"Registered, roaming, CSFB not prefered" // 10
49+
};
50+
51+
// Network operator can be set to e.g.:
52+
// MNO_SW_DEFAULT -- DEFAULT
53+
// MNO_SIM_ICCID -- SIM DEFAULT
54+
// MNO_ATT -- AT&T
55+
// MNO_VERIZON -- Verizon
56+
// MNO_TELSTRA -- Telstra
57+
// MNO_TMO -- T-Mobile US
58+
// MNO_CT -- China Telecom
59+
// MNO_VODAFONE
60+
// MNO_STD_EUROPE
61+
const mobile_network_operator_t MOBILE_NETWORK_OPERATOR = MNO_SIM_ICCID;
62+
63+
// APN -- Access Point Name. Gateway between GPRS MNO
64+
// and another computer network. E.g. "hologram
65+
//const String APN = "hologram";
66+
// The APN can be omitted: this is the so-called "blank APN" setting that may be suggested by
67+
// network operators (e.g. to roaming devices); in this case the APN string is not included in
68+
// the message sent to the network.
69+
const String APN = "";
70+
71+
void setup() {
72+
Serial.begin(9600);
73+
74+
Serial.println(F("Initializing the Asset Tracker (SARA-R5)..."));
75+
Serial.println(F("...this may take ~25 seconds if the SARA is off."));
76+
Serial.println(F("...it may take ~5 seconds if it just turned on."));
77+
78+
// Initialize the SARA
79+
if (assetTracker.begin(saraSerial, 9600))
80+
{
81+
Serial.println(F("Asset Tracker (SARA-R5) connected!"));
82+
}
83+
else
84+
{
85+
Serial.println(F("Unable to communicate with the SARA."));
86+
Serial.println(F("Manually power-on (hold POWER for 3 seconds) on and try again."));
87+
while (1) ; // Loop forever on fail
88+
}
89+
Serial.println();
90+
91+
if (!assetTracker.setNetwork(MOBILE_NETWORK_OPERATOR))
92+
{
93+
Serial.println(F("Error setting network. Try cycling the power."));
94+
while (1) ;
95+
}
96+
97+
if (assetTracker.setAPN(APN) == SARA_R5_SUCCESS)
98+
{
99+
Serial.println(F("APN successfully set."));
100+
}
101+
102+
Serial.println(F("Network set. Ready to go!"));
103+
104+
// RSSI: Received signal strength:
105+
Serial.println("RSSI: " + String(assetTracker.rssi()));
106+
// Registration Status
107+
int regStatus = assetTracker.registration();
108+
if ((regStatus >= 0) && (regStatus <= 10))
109+
{
110+
Serial.println("Network registration: " + registrationString[regStatus]);
111+
}
112+
113+
if (regStatus > 0) {
114+
Serial.println(F("All set. Go to the next example!"));
115+
}
116+
}
117+
118+
void loop() {
119+
// Do nothing. Now that we're registered move on to the next example.
120+
}

keywords.txt

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,23 @@ gpsRequest KEYWORD2
115115
SARA-R410M-02B LITERAL1
116116
MNO_INVALID LITERAL1
117117
MNO_SW_DEFAULT LITERAL1
118-
MNO_SIM_ICCD LITERAL1
118+
MNO_SIM_ICCID LITERAL1
119119
MNO_ATT LITERAL1
120120
MNO_VERIZON LITERAL1
121121
MNO_TELSTRA LITERAL1
122122
MNO_TMO LITERAL1
123123
MNO_CT LITERAL1
124+
MNO_SPRINT LITERAL1
125+
MNO_VODAFONE LITERAL1
126+
MNO_NTT_DOCOMO LITERAL1
127+
MNO_TELUS LITERAL1
128+
MNO_SOFTBANK LITERAL1
129+
MNO_DT LITERAL1
130+
MNO_US_CELLULAR LITERAL1
131+
MNO_SKT LITERAL1
132+
MNO_GLOBAL LITERAL1
133+
MNO_STD_EUROPE LITERAL1
134+
MNO_STD_EU_NOEPCO LITERAL1
124135
SARA_R5_ERROR_INVALID LITERAL1
125136
SARA_R5_ERROR_SUCCESS LITERAL1
126137
SARA_R5_ERROR_OUT_OF_MEMORY LITERAL1
@@ -129,6 +140,7 @@ SARA_R5_ERROR_UNEXPECTED_PARAM LITERAL1
129140
SARA_R5_ERROR_UNEXPECTED_RESPONSE LITERAL1
130141
SARA_R5_ERROR_NO_RESPONSE LITERAL1
131142
SARA_R5_ERROR_DEREGISTERED LITERAL1
143+
SARA_R5_ERROR_ERROR LITERAL1
132144
SARA_R5_SUCCESS LITERAL1
133145
SARA_R5_REGISTRATION_INVALID LITERAL1
134146
SARA_R5_REGISTRATION_NOT_REGISTERED LITERAL1
@@ -139,12 +151,23 @@ SARA_R5_REGISTRATION_UNKNOWN LITERAL1
139151
SARA_R5_REGISTRATION_ROAMING LITERAL1
140152
SARA_R5_REGISTRATION_HOME_SMS_ONLY LITERAL1
141153
SARA_R5_REGISTRATION_ROAMING_SMS_ONLY LITERAL1
154+
SARA_R5_REGISTRATION_EMERGENCY_SERV_ONLY LITERAL1
142155
SARA_R5_REGISTRATION_HOME_CSFB_NOT_PREFERRED LITERAL1
143156
SARA_R5_REGISTRATION_ROAMING_CSFB_NOT_PREFERRED LITERAL1
144157
SARA_R5_TCP LITERAL1
145158
SARA_R5_UDP LITERAL1
146159
SARA_R5_MESSAGE_FORMAT_PDU LITERAL1
147160
SARA_R5_MESSAGE_FORMAT_TEXT LITERAL1
161+
PDP_TYPE_INVALID LITERAL1
162+
PDP_TYPE_IP LITERAL1
163+
PDP_TYPE_NONIP LITERAL1
164+
PDP_TYPE_IPV4V6 LITERAL1
165+
PDP_TYPE_IPV6 LITERAL1
166+
L2P_DEFAULT LITERAL1
167+
L2P_PPP LITERAL1
168+
L2P_M_HEX LITERAL1
169+
L2P_M_RAW_IP LITERAL1
170+
L2P_M_OPT_PPP LITERAL1
148171
GPIO1 LITERAL1
149172
GPIO2 LITERAL1
150173
GPIO3 LITERAL1
@@ -158,16 +181,29 @@ NETWORK_STATUS LITERAL1
158181
GNSS_SUPPLY_ENABLE LITERAL1
159182
GNSS_DATA_READY LITERAL1
160183
GNSS_RTC_SHARING LITERAL1
184+
JAMMING_DETECTION LITERAL1
161185
SIM_CARD_DETECTION LITERAL1
162186
HEADSET_DETECTION LITERAL1
163187
GSM_TX_BURST_INDICATION LITERAL1
164-
MODULE_OPERATING_STATUS_INDICATION LITERAL1
165-
MODULE_FUNCTIONALITY_STATUS_INDICATION LITERAL1
188+
MODULE_STATUS_INDICATION LITERAL1
189+
MODULE_OPERATING_MODE_INDICATION LITERAL1
166190
I2S_DIGITAL_AUDIO_INTERFACE LITERAL1
167191
SPI_SERIAL_INTERFACE LITERAL1
168192
MASTER_CLOCK_GENRATION LITERAL1
169193
UART_INTERFACE LITERAL1
170194
WIFI_ENABLE LITERAL1
171195
RING_INDICATION LITERAL1
172196
LAST_GASP_ENABLE LITERAL1
197+
EXTERNAL_GNSS_ANTENNA LITERAL1
198+
TIME_PULSE_GNSS LITERAL1
199+
TIME_PULSE_OUTPUT LITERAL1
200+
TIMESTAMP LITERAL1
201+
FAST_POWER_OFF LITERAL1
202+
LWM2M_PULSE LITERAL1
203+
HARDWARE_FLOW_CONTROL LITERAL1
204+
ANTENNA_TUNING LITERAL1
205+
EXT_GNSS_TIME_PULSE LITERAL1
206+
EXT_GNSS_TIMESTAMP LITERAL1
207+
DTR_MODE LITERAL1
208+
KHZ_32768_OUT LITERAL1
173209
PAD_DISABLED LITERAL1

src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,18 @@ SARA_R5_error_t SARA_R5::setAPN(String apn, uint8_t cid, SARA_R5_pdp_type pdpTyp
843843
return SARA_R5_ERROR_UNEXPECTED_PARAM;
844844
break;
845845
}
846-
sprintf(command, "%s=%d,\"%s\",\"%s\"", SARA_R5_MESSAGE_PDP_DEF,
846+
if (apn == NULL)
847+
{
848+
if (_printDebug == true) _debugPort->println("APN: NULL");
849+
sprintf(command, "%s=%d,\"%s\",\"\"", SARA_R5_MESSAGE_PDP_DEF,
850+
cid, pdpStr);
851+
}
852+
else
853+
{
854+
if (_printDebug == true) _debugPort->println("APN: " + ((String)apn));
855+
sprintf(command, "%s=%d,\"%s\",\"%s\"", SARA_R5_MESSAGE_PDP_DEF,
847856
cid, pdpStr, apn.c_str());
857+
}
848858

849859
err = sendCommandWithResponse(command, SARA_R5_RESPONSE_OK, NULL,
850860
SARA_R5_STANDARD_RESPONSE_TIMEOUT);

src/SparkFun_u-blox_SARA-R5_Arduino_Library.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,31 @@
4848
#define SARA_R5_POWER_PIN -1
4949
#define SARA_R5_RESET_PIN -1
5050

51+
// The standard Europe profile should be used as the basis for all other MNOs in Europe outside of Vodafone
52+
// and Deutsche Telekom. However, there may be changes that need to be applied to the module for proper
53+
// operation with any given European MNO such as attach type, RAT preference, band selection, etc. Please
54+
// consult with the preferred network provider.
5155
typedef enum
5256
{
5357
MNO_INVALID = -1,
5458
MNO_SW_DEFAULT = 0,
55-
MNO_SIM_ICCD = 1,
56-
MNO_ATT = 2,
59+
MNO_SIM_ICCID = 1,
60+
MNO_ATT = 2, // AT&T
5761
MNO_VERIZON = 3,
5862
MNO_TELSTRA = 4,
59-
MNO_TMO = 5,
60-
MNO_CT = 6
63+
MNO_TMO = 5, // T-Mobile US
64+
MNO_CT = 6, // China Telecom
65+
MNO_SPRINT = 8,
66+
MNO_VODAFONE = 19,
67+
MNO_NTT_DOCOMO = 20,
68+
MNO_TELUS = 21,
69+
MNO_SOFTBANK = 28,
70+
MNO_DT = 31, // Deutsche Telekom
71+
MNO_US_CELLULAR = 32,
72+
MNO_SKT = 39,
73+
MNO_GLOBAL = 90,
74+
MNO_STD_EUROPE = 100,
75+
MNO_STD_EU_NOEPCO = 101
6176
} mobile_network_operator_t;
6277

6378
typedef enum

0 commit comments

Comments
 (0)