-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
#include "ArduinoCellular.h" | ||
#include "arduino_secrets.h" | ||
|
||
|
||
ArduinoCellular cellular = ArduinoCellular(); | ||
|
||
float lat = 0.00; | ||
float lon = 0.00; | ||
|
||
|
||
void setup(){ | ||
Serial.begin(115200); | ||
while (!Serial); | ||
cellular.setDebugStream(Serial); // Uncomment this line to enable debug output | ||
cellular.begin(); | ||
cellular.connect(SECRET_GPRS_APN, SECRET_GPRS_LOGIN, SECRET_GPRS_PASSWORD, SECRET_PINNUMBER); | ||
|
||
if(String(SECRET_PINNUMBER).length() > 0 && !cellular.unlockSIM(SECRET_PINNUMBER)){ | ||
Serial.println("Failed to unlock SIM card."); | ||
while(true); // Stop here | ||
} | ||
|
||
Serial.println("Connecting..."); | ||
cellular.connect(SECRET_GPRS_APN, SECRET_GPRS_LOGIN, SECRET_GPRS_PASSWORD); | ||
Serial.println("Connected!"); | ||
} | ||
|
||
void loop() { | ||
if (Serial.available() > 0) { | ||
// Define a buffer to store incoming data. Adjust the size as needed. | ||
char incomingData[255]; // Adjust the size according to your needs | ||
|
||
// Read data from serial until newline is found | ||
int size = Serial.readBytesUntil('\n', incomingData, sizeof(incomingData) - 1); // Leave space for null terminator | ||
|
||
// Null-terminate the string | ||
incomingData[size] = '\0'; | ||
// Call the sendATCommand function with the read data | ||
Serial.println(cellular.sendATCommand(GF(incomingData))); | ||
} | ||
while(Serial.available() == 0); // Wait for user input | ||
|
||
// Read data from serial until newline | ||
String userInput = Serial.readStringUntil('\n'); | ||
|
||
// Call the sendATCommand function with the read data | ||
String response = cellular.sendATCommand(userInput.c_str()); | ||
Serial.println(response); | ||
} |