Skip to content

Commit

Permalink
Simplify Modem Terminal Sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Apr 12, 2024
1 parent 82a1c6e commit 0f7a7ab
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions examples/ModemTerminal/ModemTerminal.ino
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);
}

0 comments on commit 0f7a7ab

Please sign in to comment.