Skip to content

Commit c795bbf

Browse files
fixing merge conflict 2
2 parents 053f727 + b1aa3cd commit c795bbf

File tree

9 files changed

+380
-44
lines changed

9 files changed

+380
-44
lines changed

docs/api.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This class provides methods to interact with the Arduino Pro Modem, such as conn
1818
--------------------------------|---------------------------------------------
1919
| [`ArduinoCellular`](#class_arduino_cellular_1a96d1d9f3fbe80adc3d460b4364d47870) | Default constructor. |
2020
| [`begin`](#class_arduino_cellular_1ad5ca7cf61f48c40569f41f3029d6516e) | Initializes the modem. |
21-
| [`connect`](#class_arduino_cellular_1afbd8079987c3a2eb880e57357cbf0d6b) | Connects to the network using the specified APN, GPRS username, and GPRS password. |
21+
| [`connect`](#class_arduino_cellular_1a7551e64b14a8c04b38de598e12c2a819) | Connects to the network using the specified APN, GPRS username, and GPRS password. |
2222
| [`isConnectedToOperator`](#class_arduino_cellular_1af7453ef90702e9042e2b4b18fa89db03) | Checks if the modem is registered on the network. |
2323
| [`isConnectedToInternet`](#class_arduino_cellular_1a6f8251e06de1810897b8bd8f8fb1b1a2) | Checks if the GPRS network is connected. |
2424
| [`enableGPS`](#class_arduino_cellular_1abe77a53e0eba6e8d62ba5db3bb6f5e92) | Enables or disables the GPS module. |
@@ -58,10 +58,10 @@ Initializes the modem.
5858

5959
<hr />
6060

61-
### `connect` <a id="class_arduino_cellular_1afbd8079987c3a2eb880e57357cbf0d6b" class="anchor"></a>
61+
### `connect` <a id="class_arduino_cellular_1a7551e64b14a8c04b38de598e12c2a819" class="anchor"></a>
6262

6363
```cpp
64-
bool connect(const char * apn, const char * gprsUser, const char * gprsPass)
64+
bool connect(const char * apn, const char * gprsUser, const char * gprsPass, const char * pin)
6565
```
6666
6767
Connects to the network using the specified APN, GPRS username, and GPRS password.
@@ -73,6 +73,8 @@ Connects to the network using the specified APN, GPRS username, and GPRS passwor
7373
7474
* `gprsPass` The GPRS password.
7575
76+
* `pin` The SIM card PIN.
77+
7678
#### Returns
7779
True if the connection is successful, false otherwise.
7880
<hr />

examples/HTTPClient/HTTPClient.ino

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
#include "ArduinoCellular.h"
44
#include "arduino_secrets.h"
55

6-
76
const char server[] = "vsh.pp.ua";
87
const char resource[] = "/TinyGSM/logo.txt";
98
const int port = 80;
109

1110
ArduinoCellular cellular = ArduinoCellular();
12-
HttpClient http = cellular.getHTTPClient(server, port);
13-
11+
HttpClient client = cellular.getHTTPClient(server, port);
1412

1513
void setup(){
1614
Serial.begin(115200);
@@ -23,19 +21,18 @@ void loop(){
2321

2422
Serial.println("Making GET request...");
2523

26-
http.get(resource);
24+
client.get(resource);
2725

28-
int status_code = http.responseStatusCode();
29-
String response = http.responseBody();
26+
int statusCode = client.responseStatusCode();
27+
String response = client.responseBody();
3028

3129
Serial.print("Status code: ");
32-
Serial.println(status_code);
30+
Serial.println(statusCode);
3331
Serial.print("Response: ");
3432
Serial.println(response);
3533

36-
http.stop();
34+
client.stop();
3735

3836
delay(5000);
3937

4038
}
41-

examples/HTTPSClient/HTTPSClient.ino

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
#include <ArduinoHttpClient.h>
55
#include "arduino_secrets.h"
66

7-
87
const char server[] = "example.com";
98
const char resource[] = "/";
109
const int port = 443;
1110

1211
ArduinoCellular cellular = ArduinoCellular();
13-
HttpClient http = cellular.getHTTPSClient(server, port);
12+
HttpClient client = cellular.getHTTPSClient(server, port);
1413

1514
void setup(){
1615
Serial.begin(115200);
@@ -20,21 +19,19 @@ void setup(){
2019
cellular.connect(SECRET_GPRS_APN, SECRET_GPRS_LOGIN, SECRET_GPRS_PASSWORD, SECRET_PINNUMBER);
2120
}
2221

23-
void loop()
24-
{
22+
void loop(){
2523
Serial.println("Making GET request...");
2624

27-
http.get(resource);
25+
client.get(resource);
2826

29-
int status_code = http.responseStatusCode();
30-
String response = http.responseBody();
27+
int statusCode = client.responseStatusCode();
28+
String response = client.responseBody();
3129

3230
Serial.print("Status code: ");
33-
Serial.println(status_code);
31+
Serial.println(statusCode);
3432
Serial.print("Response: ");
3533
Serial.println(response);
3634

37-
http.stop();
38-
35+
client.stop();
3936
delay(5000);
40-
}
37+
}
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#include "ArduinoCellular.h"
22
#include "arduino_secrets.h"
33

4+
// #define TINY_GSM_DEBUG Serial
5+
// #define ARDUINO_CELLULAR_DEBUG
46

5-
6-
#define TINY_GSM_DEBUG Serial
7-
#define ARDUINO_CELLULAR_DEBUG
7+
constexpr int NEW_SMS_INTERRUPT_PIN = A0;
88

99
ArduinoCellular cellular = ArduinoCellular();
10-
11-
boolean newSMS = false;
12-
10+
volatile boolean newSMSavailable = false;
1311

1412
void printMessages(std::vector<SMS> msg){
1513
for(int i = 0; i < msg.size(); i++){
@@ -20,18 +18,20 @@ void printMessages(std::vector<SMS> msg){
2018
}
2119
}
2220
void newSMSCallback(){
23-
Serial.println("new sms received");
24-
newSMS = true;
21+
Serial.println("New SMS received!");
22+
newSMSavailable = true;
2523
}
2624

2725
void setup(){
2826
Serial.begin(115200);
2927
while (!Serial);
28+
3029
cellular.begin();
30+
Serial.println("Connecting...");
3131
cellular.connect(SECRET_GPRS_APN, SECRET_GPRS_LOGIN, SECRET_GPRS_PASSWORD, SECRET_PINNUMBER);
3232

33-
34-
attachInterrupt(digitalPinToInterrupt(A0), newSMSCallback, RISING);
33+
// Register interrupt based callback for new SMS
34+
attachInterrupt(digitalPinToInterrupt(NEW_SMS_INTERRUPT_PIN), newSMSCallback, RISING);
3535

3636
Serial.println("Read SMS:");
3737
std::vector<SMS> readSMS = cellular.getReadSMS();
@@ -40,16 +40,14 @@ void setup(){
4040
Serial.println("Unread SMS:");
4141
std::vector<SMS> unreadSMS = cellular.getUnreadSMS();
4242
printMessages(unreadSMS);
43-
44-
cellular.sendSMS("+40788494946", "bleep bleep");
4543
}
4644

4745
void loop(){
48-
if(newSMS){
49-
newSMS = false;
46+
if(newSMSavailable){
47+
newSMSavailable = false;
5048
std::vector<SMS> unreadSMS = cellular.getUnreadSMS();
5149
if (unreadSMS.size() > 0){
5250
printMessages(unreadSMS);
5351
}
5452
}
55-
}
53+
}

examples/SendSMS/SendSMS.ino

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This example shows how to send an SMS message using the Arduino_Cellular library.
3+
*
4+
* Instructions:
5+
* 1. Insert a SIM card with or without PIN code in the Arduino Pro 4G Module.
6+
* 2. Provide sufficient power to the Arduino Pro 4G Module. Ideally, use a 5V power supply
7+
* with a current rating of at least 2A and connect it to the VIN and GND pins.
8+
* 3. Make sure the SIM card has enough credit to send SMS messages.
9+
* 4. Specify the APN, GPRS username, and GPRS password of your mobile network provider.
10+
* 5. Specify the PIN code of your SIM card if it has one.
11+
* 6. Specify the phone number of the recipient and the message you want to send.
12+
* 7. Upload the sketch to the connected Arduino board.
13+
*
14+
* Initial author: Sebastian Romero @sebromero
15+
*/
16+
#include "ArduinoCellular.h"
17+
18+
const char apn[] = "internet";
19+
const char gprsUser[] = "";
20+
const char gprsPass[] = "";
21+
22+
ArduinoCellular cellular = ArduinoCellular();
23+
24+
void setup(){
25+
Serial.begin(115200);
26+
while (!Serial);
27+
delay(1000); // Give the serial monitor some time to start
28+
29+
cellular.begin();
30+
String pinCode = "1234"; // If your SIM card has a PIN code, specify it here
31+
32+
Serial.println("Connecting to network...");
33+
cellular.connect(apn, gprsUser, gprsPass, pinCode);
34+
35+
Serial.println("Sending SMS...");
36+
cellular.sendSMS("+41791234567", "bleep bleep");
37+
Serial.println("Done.");
38+
}
39+
40+
void loop(){
41+
delay(1000);
42+
}

library.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name=Arduino_Cellular
2-
sentence=This library provides a toolkit for interacting with the official Arduino 4G Modules.
3-
4-
paragraph=A library that allows you to connect to the internet, send and receive SMS messages, and get location from the cellular network or GPS using the official Arduino 4G Modules on the Portenta Mid Carrier board.
2+
sentence=This library provides a toolkit for interacting with the official Arduino Pro 4G Modules.
3+
paragraph=A library that allows you to connect to the Internet, send and receive SMS messages, and get location from the cellular network or GPS using the official Arduino Pro 4G Modules on the Portenta Mid Carrier board.
54
category=Communication
65
url=https://github.com/arduino-libraries/ArduinoCellular
7-
architectures=*
8-
includes=ArduinoCellular.h
6+
depends=ArduinoBearSSL,StreamDebugger,TinyGsm,ArduinoHttpClient
7+
architectures=renesas_portenta, mbed_portenta
8+
includes=ArduinoCellular.h

0 commit comments

Comments
 (0)