Skip to content

V1.0.0 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 63 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
31eb616
Create library.properties
sfe-SparkFro Nov 15, 2023
216d257
Add base class files
sfe-SparkFro Nov 15, 2023
9aade77
Add SARA-R5 and LARA-R6 class files
sfe-SparkFro Nov 15, 2023
d247a17
Add main library header files
sfe-SparkFro Nov 15, 2023
904a1c8
Add original SARA-R5 header
sfe-SparkFro Nov 15, 2023
a175f61
Add Example 1 - Device Identification
sfe-SparkFro Nov 15, 2023
40e4d0c
Remove duplicate items from original SARA-R5 header
sfe-SparkFro Nov 15, 2023
d87f14b
Fix typo in Example 1
sfe-SparkFro Nov 15, 2023
37db6a8
Update sfe_sara_r5.h
PaulZC Nov 17, 2023
058c38a
Rename files from "AT Commands" to "Cellular"
sfe-SparkFro Nov 17, 2023
e5b3693
Change prefixes from UBLOX_AT to UBX_CELL
sfe-SparkFro Nov 17, 2023
20beede
Fix SARA-R5 backwards compatibility
sfe-SparkFro Nov 17, 2023
84cb26a
Update UBLOX_AT to UBX_CELL prefixes
sfe-SparkFro Nov 17, 2023
bb39060
Merge pull request #1 from sparkfun/Paul_v1.0.0
sfe-SparkFro Nov 17, 2023
0f2b97e
Change base class private members to protected
sfe-SparkFro Nov 17, 2023
71c39a9
Add voice class
sfe-SparkFro Nov 17, 2023
f3e7109
Merge pull request #6 from sparkfun/add_voice_class
sfe-SparkFro Nov 28, 2023
f271ac7
Change to template structure
sfe-SparkFro Nov 29, 2023
920bc7b
Remove unused .cpp files
sfe-SparkFro Dec 4, 2023
1ab5265
Merge pull request #8 from sparkfun/template_structure
sfe-SparkFro Dec 4, 2023
8fbe23f
Change default baud rate
sfe-SparkFro Dec 4, 2023
d26ede0
Update Example 1
sfe-SparkFro Dec 4, 2023
4b2fc8c
Move SARA-R5 features out of base class
sfe-SparkFro Dec 4, 2023
59e9aa7
Update definitions of SARA-R5_Arduino_Library.h
sfe-SparkFro Dec 4, 2023
3c780cd
Add network and operator examples
sfe-SparkFro Dec 4, 2023
318b305
Add ping example
sfe-SparkFro Dec 4, 2023
dc56f10
Add SMS examples
sfe-SparkFro Dec 4, 2023
bd91c64
Add clock example
sfe-SparkFro Dec 4, 2023
06a6097
Fix SARA references in examples
sfe-SparkFro Dec 4, 2023
c1243bd
Renumber examples
sfe-SparkFro Dec 4, 2023
006d2c0
Fix PDP and UTIME command prefixes
sfe-SparkFro Dec 11, 2023
8161600
Add missing AT commands from SARA-R5 old lib
sfe-SparkFro Dec 11, 2023
7866459
Merge pull request #10 from sparkfun/move_sara_r5_features
sfe-SparkFro Dec 11, 2023
888284d
Redefine string pointers for AT commands and such
sfe-SparkFro Dec 11, 2023
7715397
Merge pull request #14 from sparkfun/redefine_string_pointers
gigapod Dec 11, 2023
8ea8b84
Create base voice class
sfe-SparkFro Dec 12, 2023
80ee412
Create audio example 1
sfe-SparkFro Dec 12, 2023
9b7a8bc
Add note to audio example about needing a codec
sfe-SparkFro Dec 12, 2023
1c0007a
Rename audio example 1 to match conventions
sfe-SparkFro Dec 12, 2023
38c935a
Add audio resource enum
sfe-SparkFro Dec 12, 2023
e109e63
Add audio example 2 (loopback)
sfe-SparkFro Dec 12, 2023
d51cae1
Refactor URC handling
sfe-SparkFro Dec 13, 2023
7efffde
Add RING URC handler
sfe-SparkFro Dec 13, 2023
6c2da8c
Add audio example 3 (call control)
sfe-SparkFro Dec 13, 2023
4c995f0
Merge pull request #16 from sparkfun/refactor_urc_handling
sfe-SparkFro Dec 13, 2023
83d58c8
Space out exclamation marks in audio examples
sfe-SparkFro Dec 13, 2023
6a73506
Merge pull request #15 from sparkfun/add_audio_examples
sfe-SparkFro Dec 13, 2023
2dd478e
Remove unnecessary breaks from Example 3
sfe-SparkFro Dec 13, 2023
926ab5b
Merge branch 'v1.0.0' into add_first_examples
sfe-SparkFro Dec 13, 2023
d6b1204
Merge pull request #13 from sparkfun/add_first_examples
sfe-SparkFro Dec 13, 2023
a044964
Update library.properties
sfe-SparkFro Dec 13, 2023
3445bdf
Moved PDP Action URC out of base class
sfe-SparkFro Dec 13, 2023
c0214de
Run library source through formatter
sfe-SparkFro Dec 13, 2023
14c52f3
Run examples through formatter
sfe-SparkFro Dec 13, 2023
6a7ee7f
Change sprintf to snprintf
sfe-SparkFro Dec 18, 2023
363ec5c
Don't use calloc for fixed length arrays
sfe-SparkFro Dec 18, 2023
7dc48df
Change strstr to strnstr
sfe-SparkFro Dec 18, 2023
0995691
Run formatter again
sfe-SparkFro Dec 18, 2023
9259452
Rename classes
sfe-SparkFro Dec 18, 2023
5de76b7
Remove empty else block
sfe-SparkFro Jan 2, 2024
0c492f3
Add MQTT Example
sfe-SparkFro Jan 2, 2024
13ffd73
Merge pull request #18 from sparkfun/format_library
sfe-SparkFro Jan 4, 2024
4a096df
Merge pull request #19 from sparkfun/add_mqtt_example
sfe-SparkFro Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#include "SparkFun_u-blox_Cellular_Arduino_Library.h"

// Uncomment the line below that you need for Serial on your platform
#define mySerial Serial1
// SoftwareSerial mySerial(16, 17);

// Uncomment the module you're using. If your module is not listed below, then
// it's not supported for this example
SparkFun_ublox_Cellular_Voice myModule; // This example works with all voice-enabled modules, so this base class can be used
// SparkFun_ublox_LARA_R6001 myModule;
// SparkFun_ublox_LARA_R6401 myModule;
// SparkFun_ublox_LARA_R6801_00B myModule;

void setup()
{
Serial.begin(115200); // Start the serial console

// Wait for user to press key to begin
Serial.println(F("u-blox Cellular Audio Example 1 - Play Tone"));

Serial.println();
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
Serial.println(F("of the cellular modem. Please add one and update this example as"));
Serial.println(F("needed to configure your audio codec!"));
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
Serial.println();

Serial.println(F("Press any key to begin"));

while (!Serial.available()) // Wait for the user to press a key (send any serial character)
;
while (Serial.available()) // Empty the serial RX buffer
Serial.read();

Serial.println(F("Beginning..."));

// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial

// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
// Uncomment the next line if required
// myModule.invertPowerPin(true);

// Initialize the module
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
{
Serial.println(F("Module connected!"));
}
else
{
Serial.println(F("Unable to communicate with the module."));
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
while (1)
; // Loop forever on fail
}
Serial.println();
}

void loop()
{
String inputString;
char dtmfChar = 0;
uint16_t frequency = 0;
uint16_t duration = 0;
uint8_t volume = 0;

while (true)
{
while (Serial.available() != 0)
{
Serial.read();
}
Serial.println(F("Enter a frequency in Hz (300-3400) or a DTMF character (0-9, *, #)"));
while (Serial.available() == 0)
{
}

inputString = Serial.readStringUntil('\n');

if (inputString.length() == 1)
{
dtmfChar = inputString.charAt(0);
if ((dtmfChar >= '0' && dtmfChar <= '9') || dtmfChar == '*' || dtmfChar == '#')
{
break;
}
}
else
{
frequency = inputString.toInt();
if (frequency >= 300 && frequency <= 3400)
{
dtmfChar == 0;
break;
}
}
}

while (true)
{
while (Serial.available() != 0)
{
Serial.read();
}
Serial.println(F("Enter a duration in ms (50-1360)"));
while (Serial.available() == 0)
{
}

inputString = Serial.readStringUntil('\n');
duration = inputString.toInt();
if (duration >= 50 && duration <= 1360)
{
break;
}
}

while (true)
{
while (Serial.available() != 0)
{
Serial.read();
}
Serial.println(F("Enter a volume (0-100)"));
while (Serial.available() == 0)
{
}

inputString = Serial.readStringUntil('\n');
volume = inputString.toInt();
if (volume <= 100)
{
break;
}
}

if (dtmfChar == 0)
{
myModule.generateToneFreq(frequency, duration, volume);
}
else
{
myModule.generateToneDTMF(dtmfChar, duration, volume);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include "SparkFun_u-blox_Cellular_Arduino_Library.h"

// Uncomment the line below that you need for Serial on your platform
#define mySerial Serial1
// SoftwareSerial mySerial(16, 17);

// Uncomment the module you're using. If your module is not listed below, then
// it's not supported for this example
SparkFun_ublox_Cellular_Voice myModule; // This example works with all voice-enabled modules, so this base class can be used
// SparkFun_ublox_LARA_R6001 myModule;
// SparkFun_ublox_LARA_R6401 myModule;
// SparkFun_ublox_LARA_R6801_00B myModule;

void setup()
{
Serial.begin(115200); // Start the serial console

// Wait for user to press key to begin
Serial.println(F("u-blox Cellular Audio Example 2 - Loopback"));

Serial.println();
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
Serial.println(F("of the cellular modem. Please add one and update this example as"));
Serial.println(F("needed to configure your audio codec!"));
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
Serial.println();

Serial.println(F("Press any key to begin"));

while (!Serial.available()) // Wait for the user to press a key (send any serial character)
;
while (Serial.available()) // Empty the serial RX buffer
Serial.read();

Serial.println(F("Beginning..."));

// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial

// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
// Uncomment the next line if required
// myModule.invertPowerPin(true);

// Initialize the module
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
{
Serial.println(F("Module connected!"));
}
else
{
Serial.println(F("Unable to communicate with the module."));
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
while (1)
; // Loop forever on fail
}
Serial.println();
}

void loop()
{
while (Serial.available() != 0)
{
Serial.read();
}
Serial.println(F("Enter any key to begin loopback"));
while (Serial.available() == 0)
{
}

myModule.playAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);

while (Serial.available() != 0)
{
Serial.read();
}
Serial.println(F("Enter any key to stop loopback"));
while (Serial.available() == 0)
{
}

myModule.stopAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#include "SparkFun_u-blox_Cellular_Arduino_Library.h"

// Uncomment the line below that you need for Serial on your platform
#define mySerial Serial1
// SoftwareSerial mySerial(16, 17);

// Uncomment the module you're using. If your module is not listed below, then
// it's not supported for this example
SparkFun_ublox_Cellular_Voice myModule; // This example works with all voice-enabled modules, so this base class can be used
// SparkFun_ublox_LARA_R6001 myModule;
// SparkFun_ublox_LARA_R6401 myModule;
// SparkFun_ublox_LARA_R6801_00B myModule;

bool callInProgress = false;
bool incomingCall = false;

void ringCallback()
{
Serial.println(F("Incoming call! Enter \"A\" to answer, or anything else to reject"));
incomingCall = true;
}

void setup()
{
String currentOperator = "";

Serial.begin(115200); // Start the serial console

// Wait for user to press key to begin
Serial.println(F("u-blox Cellular Audio Example 3 - Call Control"));

Serial.println();
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
Serial.println(F("of the cellular modem. Please add one and update this example as"));
Serial.println(F("needed to configure your audio codec!"));
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
Serial.println();

Serial.println(F("Press any key to begin"));

while (!Serial.available()) // Wait for the user to press a key (send any serial character)
;
while (Serial.available()) // Empty the serial RX buffer
Serial.read();

Serial.println(F("Beginning..."));

// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial

// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
// Uncomment the next line if required
// myModule.invertPowerPin(true);

// Initialize the module
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
{
Serial.println(F("Module connected!"));
}
else
{
Serial.println(F("Unable to communicate with the module."));
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
while (1)
; // Loop forever on fail
}
Serial.println();

// First check to see if we're connected to an operator:
if (myModule.getOperator(&currentOperator) == UBX_CELL_SUCCESS)
{
Serial.print(F("Connected to: "));
Serial.println(currentOperator);
}
else
{
Serial.print(F("The module is not yet connected to an operator. Please use the previous examples to connect. "
"Or wait and retry. Freezing..."));
while (1)
; // Do nothing more
}

// Set callback function for when a new call is received
myModule.setRingCallback(&ringCallback);

Serial.println(F("Enter a number to dial"));

// Clear any input
while (Serial.available())
{
Serial.read();
}
}

void loop()
{
String inputString;

myModule.bufferedPoll();

if (Serial.available())
{
inputString = Serial.readStringUntil('\n');
while (Serial.available())
{
Serial.read();
}

if (incomingCall)
{
if (inputString == "A" || inputString == "a")
{
Serial.println(F("Answering call, enter any key to hang up"));
myModule.answer();
callInProgress = true;
}
else
{
Serial.println(F("Rejecting call"));
myModule.hangUp();
}
incomingCall = false;
}
else if (callInProgress == false)
{
Serial.println("Dialing " + inputString + ", enter any key to hang up");
myModule.dial(inputString);
callInProgress = true;
}
else
{
Serial.println(F("Hanging up, enter a new number to dial"));
myModule.hangUp();
callInProgress = false;
}
}
}
Loading