Skip to content

Commit

Permalink
Rename Location to CellularLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Apr 29, 2024
1 parent 6531063 commit bb81766
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/ArduinoCellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ void ArduinoCellular::begin() {
modem.sendAT("+CNMI=2,1,0,0,0");
modem.waitResponse();


#if defined(ARDUINO_CELLULAR_BEARSSL)
ArduinoBearSSL.onGetTime(ArduinoCellular::getTime);
#endif

}

Expand Down Expand Up @@ -87,7 +88,7 @@ bool ArduinoCellular::connect(String apn, String username, String password){
}


Location ArduinoCellular::getGPSLocation(unsigned long timeout){
CellularLocation ArduinoCellular::getGPSLocation(unsigned long timeout){
if (model == ModemModel::EG25){
float latitude = 0.00000;
float longitude = 0.00000;
Expand All @@ -98,7 +99,7 @@ Location ArduinoCellular::getGPSLocation(unsigned long timeout){
delay(1000);
}

Location loc;
CellularLocation loc;
loc.latitude = latitude;
loc.longitude = longitude;

Expand All @@ -107,7 +108,7 @@ Location ArduinoCellular::getGPSLocation(unsigned long timeout){
if(this->debugStream != nullptr){
this->debugStream->println("Unsupported modem model");
}
return Location();
return CellularLocation();
}
}

Expand Down Expand Up @@ -155,13 +156,15 @@ HttpClient ArduinoCellular::getHTTPClient(const char * server, const int port){
return HttpClient(* new TinyGsmClient(modem), server, port);
}

#if defined(ARDUINO_CELLULAR_BEARSSL)
HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
return HttpClient(* new BearSSLClient(* new TinyGsmClient(modem)), server, port);
}

BearSSLClient ArduinoCellular::getSecureNetworkClient(){
return BearSSLClient(* new TinyGsmClient(modem));
}
#endif

bool ArduinoCellular::isConnectedToOperator(){
return modem.isNetworkConnected();
Expand Down Expand Up @@ -214,11 +217,13 @@ bool ArduinoCellular::awaitNetworkRegistration(){
if(this->debugStream != nullptr){
this->debugStream->println("Waiting for network registration...");
}
/* reduce max wait time */
while (!modem.waitForNetwork()) {
if(this->debugStream != nullptr){
this->debugStream->print(".");
}
delay(2000);
/* Add watchdog kik*/
}
return true;
}
Expand Down
20 changes: 16 additions & 4 deletions src/ArduinoCellular.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@

#include <Arduino.h>
#include <vector>
#include "ArduinoBearSSLConfig.h"
#include <ArduinoBearSSL.h>

#if defined __has_include
#if !__has_include (<ArduinoIoTCloud.h>)
#define ARDUINO_CELLULAR_BEARSSL
#endif
#endif

#if defined(ARDUINO_CELLULAR_BEARSSL)
#include "ArduinoBearSSLConfig.h"
#include <ArduinoBearSSL.h>
#endif

#include <ModemInterface.h>
#include <TimeUtils.h>

Expand Down Expand Up @@ -71,7 +81,7 @@ class SMS {
* @struct Location
* @brief Represents a geographic location with latitude and longitude coordinates.
*/
struct Location {
struct CellularLocation {
float latitude; /**< The latitude coordinate of the location. */
float longitude; /**< The longitude coordinate of the location. */
};
Expand Down Expand Up @@ -136,7 +146,7 @@ class ArduinoCellular {
* @param timeout The timeout (In milliseconds) to wait for the GPS location.
* @return The GPS location. If the location is not retrieved, the latitude and longitude will be 0.0.
*/
Location getGPSLocation(unsigned long timeout = 60000);
CellularLocation getGPSLocation(unsigned long timeout = 60000);

/**
* @brief Gets the current time from the network.
Expand Down Expand Up @@ -206,7 +216,9 @@ class ArduinoCellular {
* @brief Gets the Transport Layer Security (TLS) client. (OSI Layer 4)
* @return The GSM client.
*/
#if defined(ARDUINO_CELLULAR_BEARSSL)
BearSSLClient getSecureNetworkClient();
#endif

/**
* @brief Gets the HTTP client for the specified server and port.
Expand Down

0 comments on commit bb81766

Please sign in to comment.