Skip to content

Commit e94101b

Browse files
added library documentation
1 parent c795bbf commit e94101b

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/ArduinoCellular.cpp

+34-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
#include "ArduinoCellular.h"
24

35
unsigned long ArduinoCellular::getTime() {
@@ -41,16 +43,16 @@ void ArduinoCellular::begin() {
4143

4244
}
4345

44-
bool ArduinoCellular::connect(String apn, String gprsUser, String gprsPass, String pin){
46+
bool ArduinoCellular::connect(const char * apn, const char * gprsUser, const char * gprsPass, const char * pin){
4547
SimStatus simStatus = getSimStatus();
4648
if(simStatus == SimStatus::SIM_LOCKED) {
47-
unlockSIM(pin.c_str());
49+
unlockSIM(pin);
4850
}
4951

5052
simStatus = getSimStatus();
5153
if(simStatus == SimStatus::SIM_READY) {
5254
if(awaitNetworkRegistration()){
53-
if(connectToGPRS(apn.c_str(), gprsUser.c_str(), gprsPass.c_str())){
55+
if(connectToGPRS(apn, gprsUser, gprsPass)){
5456
Serial.println("Setting DNS...");
5557
Serial.println(this->sendATCommand("+QIDNSCFG=1,\"8.8.8.8\",\"8.8.4.4\""));
5658
return true;
@@ -130,6 +132,10 @@ HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
130132
return HttpClient(* new BearSSLClient(* new TinyGsmClient(modem)), server, port);
131133
}
132134

135+
BearSSLClient ArduinoCellular::getSecureNetworkClient(){
136+
return BearSSLClient(* new TinyGsmClient(modem));
137+
}
138+
133139
bool ArduinoCellular::isConnectedToOperator(){
134140
return modem.isNetworkConnected();
135141
}
@@ -194,7 +200,6 @@ bool ArduinoCellular::enableGPS(bool assisted){
194200

195201
modem.enableGPS();
196202
//delay(10000);
197-
// TODO: ^ move this to the sketch
198203
}
199204

200205
String ArduinoCellular::sendATCommand( char * command, unsigned long timeout){
@@ -297,4 +302,28 @@ std::vector<SMS> ArduinoCellular::getUnreadSMS(){
297302
} else {
298303
return parseSMSData(rawMessages);
299304
}
300-
}
305+
}
306+
307+
308+
309+
bool ArduinoCellular::connect(String apn, String gprsUser, String gprsPass, String pin){
310+
SimStatus simStatus = getSimStatus();
311+
if(simStatus == SimStatus::SIM_LOCKED) {
312+
unlockSIM(pin.c_str());
313+
}
314+
315+
simStatus = getSimStatus();
316+
if(simStatus == SimStatus::SIM_READY) {
317+
if(awaitNetworkRegistration()){
318+
if(connectToGPRS(apn.c_str(), gprsUser.c_str(), gprsPass.c_str())){
319+
Serial.println("Setting DNS...");
320+
Serial.println(this->sendATCommand("+QIDNSCFG=1,\"8.8.8.8\",\"8.8.4.4\""));
321+
return true;
322+
}
323+
} else {
324+
return false;
325+
}
326+
} else {
327+
return false;
328+
}
329+
}

src/ArduinoCellular.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/**
23
* @file ArduinoCellular.h
34
* @brief Header file for the ArduinoCellular library.
@@ -179,6 +180,12 @@ class ArduinoCellular {
179180
*/
180181
TinyGsmClient getNetworkClient();
181182

183+
/**
184+
* @brief Gets the Transport Layer Security (TLS) client. (OSI Layer 4)
185+
* @return The GSM client.
186+
*/
187+
BearSSLClient getSecureNetworkClient();
188+
182189
/**
183190
* @brief Gets the HTTP client for the specified server and port.
184191
* @param server The server address.
@@ -246,4 +253,4 @@ class ArduinoCellular {
246253
};
247254

248255

249-
#endif
256+
#endif

0 commit comments

Comments
 (0)