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
+ UBX_CELL_VOICE_BASE myModule; // This example works with all voice-enabled modules, so this base class can be used
10
+ // LARA_R6001 myModule;
11
+ // LARA_R6401 myModule;
12
+ // 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 ) ; // Loop forever on fail
54
+ }
55
+ Serial.println ();
56
+ }
57
+
58
+ void loop ()
59
+ {
60
+ while (Serial.available () != 0 ){Serial.read ();}
61
+ Serial.println (F (" Enter any key to begin loopback" ));
62
+ while (Serial.available () == 0 ){}
63
+
64
+ myModule.playAudioResource (UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
65
+
66
+ while (Serial.available () != 0 ){Serial.read ();}
67
+ Serial.println (F (" Enter any key to stop loopback" ));
68
+ while (Serial.available () == 0 ){}
69
+
70
+ myModule.stopAudioResource (UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
71
+ }
0 commit comments