Skip to content

Commit ac5d453

Browse files
committed
Use upper case M for Modem singleton
1 parent 9da2572 commit ac5d453

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

src/ArduinoCellular.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
unsigned long ArduinoCellular::getTime() {
1010
int year, month, day, hour, minute, second;
1111
float tz;
12-
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
12+
Modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
1313
return Time(year, month, day, hour, minute, second).getUNIXTimestamp();
1414
}
1515

@@ -21,7 +21,7 @@ ArduinoCellular::~ArduinoCellular() {
2121
}
2222

2323
void ArduinoCellular::begin() {
24-
modem.init();
24+
Modem.init();
2525

2626
String modemInfo = this ->sendATCommand("I");
2727
if(modemInfo.indexOf("EC200A") > 0){
@@ -33,15 +33,15 @@ void ArduinoCellular::begin() {
3333
}
3434

3535
// Set GSM module to text mode
36-
modem.sendAT("+CMGF=1");
37-
modem.waitResponse();
36+
Modem.sendAT("+CMGF=1");
37+
Modem.waitResponse();
3838

39-
modem.sendAT(GF("+CSCS=\"GSM\""));
40-
modem.waitResponse();
39+
Modem.sendAT(GF("+CSCS=\"GSM\""));
40+
Modem.waitResponse();
4141

4242
// Send intrerupt when SMS has been received
43-
modem.sendAT("+CNMI=2,1,0,0,0");
44-
modem.waitResponse();
43+
Modem.sendAT("+CNMI=2,1,0,0,0");
44+
Modem.waitResponse();
4545

4646
#if defined(ARDUINO_CELLULAR_BEARSSL)
4747
ArduinoBearSSL.onGetTime(ArduinoCellular::getTime);
@@ -108,7 +108,7 @@ Geolocation ArduinoCellular::getGPSLocation(unsigned long timeout){
108108
unsigned long startTime = millis();
109109

110110
while((latitude == 0.00000 || longitude == 0.00000) && (millis() - startTime < timeout)) {
111-
modem.getGPS(&latitude, &longitude);
111+
Modem.getGPS(&latitude, &longitude);
112112
delay(1000);
113113
}
114114

@@ -127,7 +127,7 @@ Geolocation ArduinoCellular::getGPSLocation(unsigned long timeout){
127127

128128
Time ArduinoCellular::getGPSTime(){
129129
int year, month, day, hour, minute, second;
130-
modem.getGPSTime(&year, &month, &day, &hour, &minute, &second);
130+
Modem.getGPSTime(&year, &month, &day, &hour, &minute, &second);
131131
return Time(year, month, day, hour, minute, second);
132132
}
133133

@@ -139,22 +139,22 @@ Time ArduinoCellular::getCellularTime(){
139139
int minute = 0;
140140
int second = 0;
141141
float tz;
142-
if (modem.NTPServerSync() == 0) {
143-
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
142+
if (Modem.NTPServerSync() == 0) {
143+
Modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
144144
}
145145
return Time(year, month, day, hour, minute, second);
146146
}
147147

148148

149149
void ArduinoCellular::sendSMS(String number, String message){
150-
modem.sendAT("+CMGF=1");
151-
modem.waitResponse(1000);
152-
modem.sendAT(GF("+CMGS=\""), number, GF("\""));
153-
if (modem.waitResponse(GF(">")) != 1) { }
154-
modem.stream->print(message); // Actually send the message
155-
modem.stream->write(static_cast<char>(0x1A)); // Terminate the message
156-
modem.stream->flush();
157-
auto response = modem.waitResponse(10000L);
150+
Modem.sendAT("+CMGF=1");
151+
Modem.waitResponse(1000);
152+
Modem.sendAT(GF("+CMGS=\""), number, GF("\""));
153+
if (Modem.waitResponse(GF(">")) != 1) { }
154+
Modem.stream->print(message); // Actually send the message
155+
Modem.stream->write(static_cast<char>(0x1A)); // Terminate the message
156+
Modem.stream->flush();
157+
auto response = Modem.waitResponse(10000L);
158158

159159
if(this->debugStream != nullptr){
160160
this->debugStream->println("Response: " + String(response));
@@ -163,24 +163,24 @@ void ArduinoCellular::sendSMS(String number, String message){
163163

164164

165165
IPAddress ArduinoCellular::getIPAddress(){
166-
return modem.localIP();
166+
return Modem.localIP();
167167
}
168168

169169
int ArduinoCellular::getSignalQuality(){
170-
return modem.getSignalQuality();
170+
return Modem.getSignalQuality();
171171
}
172172

173173
TinyGsmClient ArduinoCellular::getNetworkClient(){
174-
return ManagedTinyGsmClient(modem);
174+
return ManagedTinyGsmClient(Modem);
175175
}
176176

177177
HttpClient ArduinoCellular::getHTTPClient(const char * server, const int port){
178-
return HttpClient(* new ManagedTinyGsmClient(modem), server, port);
178+
return HttpClient(* new ManagedTinyGsmClient(Modem), server, port);
179179
}
180180

181181
#if defined(ARDUINO_CELLULAR_BEARSSL)
182182
HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
183-
auto gsmClient = std::make_unique<ManagedTinyGsmClient>(modem);
183+
auto gsmClient = std::make_unique<ManagedTinyGsmClient>(Modem);
184184
auto sslClient = std::make_unique<BearSSLClient>(*gsmClient);
185185
auto& sslRef = *sslClient;
186186

@@ -190,7 +190,7 @@ HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
190190
}
191191

192192
BearSSLClient ArduinoCellular::getSecureNetworkClient(){
193-
return BearSSLClient(* new ManagedTinyGsmClient(modem));
193+
return BearSSLClient(* new ManagedTinyGsmClient(Modem));
194194
}
195195
#endif
196196

@@ -209,14 +209,14 @@ size_t ArduinoCellular::getManagedClientCount() const {
209209
}
210210

211211
bool ArduinoCellular::isConnectedToOperator(){
212-
return modem.isNetworkConnected();
212+
return Modem.isNetworkConnected();
213213
}
214214

215215
bool ArduinoCellular::connectToGPRS(const char * apn, const char * gprsUser, const char * gprsPass){
216216
if(this->debugStream != nullptr){
217217
this->debugStream->println("Connecting to 4G network...");
218218
}
219-
while(!modem.gprsConnect(apn, gprsUser, gprsPass)) {
219+
while(!Modem.gprsConnect(apn, gprsUser, gprsPass)) {
220220
if(this->debugStream != nullptr){
221221
this->debugStream->print(".");
222222
}
@@ -226,11 +226,11 @@ bool ArduinoCellular::connectToGPRS(const char * apn, const char * gprsUser, con
226226
}
227227

228228
bool ArduinoCellular::isConnectedToInternet(){
229-
return modem.isGprsConnected();
229+
return Modem.isGprsConnected();
230230
}
231231

232232
SimStatus ArduinoCellular::getSimStatus(){
233-
int simStatus = modem.getSimStatus();
233+
int simStatus = Modem.getSimStatus();
234234
if(this->debugStream != nullptr){
235235
this->debugStream->println("SIM Status: " + String(simStatus));
236236
}
@@ -249,12 +249,12 @@ SimStatus ArduinoCellular::getSimStatus(){
249249
}
250250

251251
bool ArduinoCellular::unlockSIM(String pin){
252-
int simStatus = modem.getSimStatus();
252+
int simStatus = Modem.getSimStatus();
253253
if(simStatus == SIM_LOCKED) {
254254
if(this->debugStream != nullptr){
255255
this->debugStream->println("Unlocking SIM...");
256256
}
257-
return modem.simUnlock(pin.c_str());
257+
return Modem.simUnlock(pin.c_str());
258258
}
259259
else if(simStatus == SIM_ERROR || simStatus == SIM_ANTITHEFT_LOCKED) {
260260
return false;
@@ -267,7 +267,7 @@ bool ArduinoCellular::awaitNetworkRegistration(bool waitForever){
267267
if(this->debugStream != nullptr){
268268
this->debugStream->println("Waiting for network registration...");
269269
}
270-
while (!modem.waitForNetwork(waitForNetworkTimeout)) {
270+
while (!Modem.waitForNetwork(waitForNetworkTimeout)) {
271271

272272
if(!waitForever) {
273273
return false;
@@ -308,13 +308,13 @@ bool ArduinoCellular::enableGPS(bool assisted){
308308
return false;
309309
}
310310

311-
return modem.enableGPS();
311+
return Modem.enableGPS();
312312
}
313313

314314
String ArduinoCellular::sendATCommand(const char * command, unsigned long timeout){
315315
String response;
316-
modem.sendAT(command);
317-
modem.waitResponse(timeout, response);
316+
Modem.sendAT(command);
317+
Modem.waitResponse(timeout, response);
318318
return response;
319319
}
320320

@@ -426,7 +426,7 @@ std::vector<SMS> parseSMSData(const String& data) {
426426
}
427427

428428
String ArduinoCellular::sendUSSDCommand(const char * command){
429-
return modem.sendUSSD(command);
429+
return Modem.sendUSSD(command);
430430
}
431431

432432
std::vector<SMS> ArduinoCellular::getReadSMS(){

src/ModemInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
// we need to make sure that the Modem object is initialised before anything else in the sketch to avoid issues with the TinyGSM library
1717
// the init_priority attribute is used to set the priority of the constructor, the lower the number the higher the priority (101 to 65535)
1818
// for more information see https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html
19-
__attribute__ ((init_priority (101))) ModemInterface modem(debugger, PORTENTA_C33_MODEM_ON_PIN);
19+
__attribute__ ((init_priority (101))) ModemInterface Modem(debugger, PORTENTA_C33_MODEM_ON_PIN);
2020
#else
21-
__attribute__ ((init_priority (101))) ModemInterface modem(Serial1_FC, PORTENTA_C33_MODEM_ON_PIN);
21+
__attribute__ ((init_priority (101))) ModemInterface Modem(Serial1_FC, PORTENTA_C33_MODEM_ON_PIN);
2222
#endif
2323

2424
#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(CORE_CM4)
@@ -27,9 +27,9 @@
2727
// P602/P110/P603/P604 -> Serial1
2828
#ifdef DUMP_AT_COMMANDS
2929
StreamDebugger debugger(Serial1, Serial);
30-
__attribute__ ((init_priority (101))) ModemInterface modem(debugger, PinNameToIndex(PORTENTA_H7_MODEM_ON_PIN));
30+
__attribute__ ((init_priority (101))) ModemInterface Modem(debugger, PinNameToIndex(PORTENTA_H7_MODEM_ON_PIN));
3131
#else
32-
__attribute__ ((init_priority (101))) ModemInterface modem(Serial1, PinNameToIndex(PORTENTA_H7_MODEM_ON_PIN));
32+
__attribute__ ((init_priority (101))) ModemInterface Modem(Serial1, PinNameToIndex(PORTENTA_H7_MODEM_ON_PIN));
3333
#endif
3434

3535
#else

src/ModemInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ class ModemInterface : public TinyGsmBG96 {
7272
/**
7373
* @brief The global modem object.
7474
*/
75-
extern ModemInterface modem;
75+
extern ModemInterface Modem;
7676

7777
#endif

0 commit comments

Comments
 (0)