Skip to content

Commit a0d0ad3

Browse files
authored
Merge pull request #20 from sparkfun/v1.0.0
V1.0.0
2 parents 5fd5fb4 + 4a096df commit a0d0ad3

File tree

20 files changed

+10040
-0
lines changed

20 files changed

+10040
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#include "SparkFun_u-blox_Cellular_Arduino_Library.h"
2+
3+
// Uncomment the line below that you need for Serial on your platform
4+
#define mySerial Serial1
5+
// SoftwareSerial mySerial(16, 17);
6+
7+
// Uncomment the module you're using. If your module is not listed below, then
8+
// it's not supported for this example
9+
SparkFun_ublox_Cellular_Voice myModule; // This example works with all voice-enabled modules, so this base class can be used
10+
// SparkFun_ublox_LARA_R6001 myModule;
11+
// SparkFun_ublox_LARA_R6401 myModule;
12+
// SparkFun_ublox_LARA_R6801_00B myModule;
13+
14+
void setup()
15+
{
16+
Serial.begin(115200); // Start the serial console
17+
18+
// Wait for user to press key to begin
19+
Serial.println(F("u-blox Cellular Audio Example 1 - Play Tone"));
20+
21+
Serial.println();
22+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
23+
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
24+
Serial.println(F("of the cellular modem. Please add one and update this example as"));
25+
Serial.println(F("needed to configure your audio codec!"));
26+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
27+
Serial.println();
28+
29+
Serial.println(F("Press any key to begin"));
30+
31+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
32+
;
33+
while (Serial.available()) // Empty the serial RX buffer
34+
Serial.read();
35+
36+
Serial.println(F("Beginning..."));
37+
38+
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
39+
40+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
41+
// Uncomment the next line if required
42+
// myModule.invertPowerPin(true);
43+
44+
// Initialize the module
45+
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
46+
{
47+
Serial.println(F("Module connected!"));
48+
}
49+
else
50+
{
51+
Serial.println(F("Unable to communicate with the module."));
52+
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
53+
while (1)
54+
; // Loop forever on fail
55+
}
56+
Serial.println();
57+
}
58+
59+
void loop()
60+
{
61+
String inputString;
62+
char dtmfChar = 0;
63+
uint16_t frequency = 0;
64+
uint16_t duration = 0;
65+
uint8_t volume = 0;
66+
67+
while (true)
68+
{
69+
while (Serial.available() != 0)
70+
{
71+
Serial.read();
72+
}
73+
Serial.println(F("Enter a frequency in Hz (300-3400) or a DTMF character (0-9, *, #)"));
74+
while (Serial.available() == 0)
75+
{
76+
}
77+
78+
inputString = Serial.readStringUntil('\n');
79+
80+
if (inputString.length() == 1)
81+
{
82+
dtmfChar = inputString.charAt(0);
83+
if ((dtmfChar >= '0' && dtmfChar <= '9') || dtmfChar == '*' || dtmfChar == '#')
84+
{
85+
break;
86+
}
87+
}
88+
else
89+
{
90+
frequency = inputString.toInt();
91+
if (frequency >= 300 && frequency <= 3400)
92+
{
93+
dtmfChar == 0;
94+
break;
95+
}
96+
}
97+
}
98+
99+
while (true)
100+
{
101+
while (Serial.available() != 0)
102+
{
103+
Serial.read();
104+
}
105+
Serial.println(F("Enter a duration in ms (50-1360)"));
106+
while (Serial.available() == 0)
107+
{
108+
}
109+
110+
inputString = Serial.readStringUntil('\n');
111+
duration = inputString.toInt();
112+
if (duration >= 50 && duration <= 1360)
113+
{
114+
break;
115+
}
116+
}
117+
118+
while (true)
119+
{
120+
while (Serial.available() != 0)
121+
{
122+
Serial.read();
123+
}
124+
Serial.println(F("Enter a volume (0-100)"));
125+
while (Serial.available() == 0)
126+
{
127+
}
128+
129+
inputString = Serial.readStringUntil('\n');
130+
volume = inputString.toInt();
131+
if (volume <= 100)
132+
{
133+
break;
134+
}
135+
}
136+
137+
if (dtmfChar == 0)
138+
{
139+
myModule.generateToneFreq(frequency, duration, volume);
140+
}
141+
else
142+
{
143+
myModule.generateToneDTMF(dtmfChar, duration, volume);
144+
}
145+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include "SparkFun_u-blox_Cellular_Arduino_Library.h"
2+
3+
// Uncomment the line below that you need for Serial on your platform
4+
#define mySerial Serial1
5+
// SoftwareSerial mySerial(16, 17);
6+
7+
// Uncomment the module you're using. If your module is not listed below, then
8+
// it's not supported for this example
9+
SparkFun_ublox_Cellular_Voice myModule; // This example works with all voice-enabled modules, so this base class can be used
10+
// SparkFun_ublox_LARA_R6001 myModule;
11+
// SparkFun_ublox_LARA_R6401 myModule;
12+
// SparkFun_ublox_LARA_R6801_00B myModule;
13+
14+
void setup()
15+
{
16+
Serial.begin(115200); // Start the serial console
17+
18+
// Wait for user to press key to begin
19+
Serial.println(F("u-blox Cellular Audio Example 2 - Loopback"));
20+
21+
Serial.println();
22+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
23+
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
24+
Serial.println(F("of the cellular modem. Please add one and update this example as"));
25+
Serial.println(F("needed to configure your audio codec!"));
26+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
27+
Serial.println();
28+
29+
Serial.println(F("Press any key to begin"));
30+
31+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
32+
;
33+
while (Serial.available()) // Empty the serial RX buffer
34+
Serial.read();
35+
36+
Serial.println(F("Beginning..."));
37+
38+
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
39+
40+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
41+
// Uncomment the next line if required
42+
// myModule.invertPowerPin(true);
43+
44+
// Initialize the module
45+
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
46+
{
47+
Serial.println(F("Module connected!"));
48+
}
49+
else
50+
{
51+
Serial.println(F("Unable to communicate with the module."));
52+
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
53+
while (1)
54+
; // Loop forever on fail
55+
}
56+
Serial.println();
57+
}
58+
59+
void loop()
60+
{
61+
while (Serial.available() != 0)
62+
{
63+
Serial.read();
64+
}
65+
Serial.println(F("Enter any key to begin loopback"));
66+
while (Serial.available() == 0)
67+
{
68+
}
69+
70+
myModule.playAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
71+
72+
while (Serial.available() != 0)
73+
{
74+
Serial.read();
75+
}
76+
Serial.println(F("Enter any key to stop loopback"));
77+
while (Serial.available() == 0)
78+
{
79+
}
80+
81+
myModule.stopAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
82+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#include "SparkFun_u-blox_Cellular_Arduino_Library.h"
2+
3+
// Uncomment the line below that you need for Serial on your platform
4+
#define mySerial Serial1
5+
// SoftwareSerial mySerial(16, 17);
6+
7+
// Uncomment the module you're using. If your module is not listed below, then
8+
// it's not supported for this example
9+
SparkFun_ublox_Cellular_Voice myModule; // This example works with all voice-enabled modules, so this base class can be used
10+
// SparkFun_ublox_LARA_R6001 myModule;
11+
// SparkFun_ublox_LARA_R6401 myModule;
12+
// SparkFun_ublox_LARA_R6801_00B myModule;
13+
14+
bool callInProgress = false;
15+
bool incomingCall = false;
16+
17+
void ringCallback()
18+
{
19+
Serial.println(F("Incoming call! Enter \"A\" to answer, or anything else to reject"));
20+
incomingCall = true;
21+
}
22+
23+
void setup()
24+
{
25+
String currentOperator = "";
26+
27+
Serial.begin(115200); // Start the serial console
28+
29+
// Wait for user to press key to begin
30+
Serial.println(F("u-blox Cellular Audio Example 3 - Call Control"));
31+
32+
Serial.println();
33+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
34+
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
35+
Serial.println(F("of the cellular modem. Please add one and update this example as"));
36+
Serial.println(F("needed to configure your audio codec!"));
37+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
38+
Serial.println();
39+
40+
Serial.println(F("Press any key to begin"));
41+
42+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
43+
;
44+
while (Serial.available()) // Empty the serial RX buffer
45+
Serial.read();
46+
47+
Serial.println(F("Beginning..."));
48+
49+
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
50+
51+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
52+
// Uncomment the next line if required
53+
// myModule.invertPowerPin(true);
54+
55+
// Initialize the module
56+
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
57+
{
58+
Serial.println(F("Module connected!"));
59+
}
60+
else
61+
{
62+
Serial.println(F("Unable to communicate with the module."));
63+
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
64+
while (1)
65+
; // Loop forever on fail
66+
}
67+
Serial.println();
68+
69+
// First check to see if we're connected to an operator:
70+
if (myModule.getOperator(&currentOperator) == UBX_CELL_SUCCESS)
71+
{
72+
Serial.print(F("Connected to: "));
73+
Serial.println(currentOperator);
74+
}
75+
else
76+
{
77+
Serial.print(F("The module is not yet connected to an operator. Please use the previous examples to connect. "
78+
"Or wait and retry. Freezing..."));
79+
while (1)
80+
; // Do nothing more
81+
}
82+
83+
// Set callback function for when a new call is received
84+
myModule.setRingCallback(&ringCallback);
85+
86+
Serial.println(F("Enter a number to dial"));
87+
88+
// Clear any input
89+
while (Serial.available())
90+
{
91+
Serial.read();
92+
}
93+
}
94+
95+
void loop()
96+
{
97+
String inputString;
98+
99+
myModule.bufferedPoll();
100+
101+
if (Serial.available())
102+
{
103+
inputString = Serial.readStringUntil('\n');
104+
while (Serial.available())
105+
{
106+
Serial.read();
107+
}
108+
109+
if (incomingCall)
110+
{
111+
if (inputString == "A" || inputString == "a")
112+
{
113+
Serial.println(F("Answering call, enter any key to hang up"));
114+
myModule.answer();
115+
callInProgress = true;
116+
}
117+
else
118+
{
119+
Serial.println(F("Rejecting call"));
120+
myModule.hangUp();
121+
}
122+
incomingCall = false;
123+
}
124+
else if (callInProgress == false)
125+
{
126+
Serial.println("Dialing " + inputString + ", enter any key to hang up");
127+
myModule.dial(inputString);
128+
callInProgress = true;
129+
}
130+
else
131+
{
132+
Serial.println(F("Hanging up, enter a new number to dial"));
133+
myModule.hangUp();
134+
callInProgress = false;
135+
}
136+
}
137+
}

0 commit comments

Comments
 (0)