-
Notifications
You must be signed in to change notification settings - Fork 72
GSMExtras Library
David A. Mellis edited this page Jan 10, 2014
·
18 revisions
This library complements the Arduino GSM library by providing additional commands for controlling the Quectel M10 GSM module found on the Arduino GSM shield, DIY Cellphone, and Cellphone Module.
To use: #include <GSM3VolumeService.h>
Set the volume, from 0 to 100.
Query the GSM module for the current volume. Use ready() to check if the module has responded and getVolume() to retrieve the current volume.
volume.checkVolume(); // query the GSM module for the current volume
while (!volume.ready()); // wait for it to respond
// if the response was successful, get the volume and print it
if (volume.ready() == 1) {
Serial.print("volume: ");
Serial.println(volume.getVolume());
}
Returns the current volume, either the last volume set with setVolume() or the last volume returned by the module through a call to checkVolume().
Check the status of the latest query of the GSM module (with checkVolume()). Returns 0 if the command is still pending, 1 on success, and greater than 1 on error.
#include <GSM.h>
#include <GSM3VolumeService.h>
GSM gsm(true);
GSMVoiceCall vcs;
GSM3VolumeService volume;
int potval;
void setup()
{
pinMode(31, INPUT_PULLUP);
pinMode(19, OUTPUT);
digitalWrite(19, LOW);
delay(12000);
digitalWrite(19, HIGH);
while (gsm.begin(0, false) != GSM_READY);
}
void loop()
{
if (vcs.getvoiceCallStatus() == RECEIVINGCALL && digitalRead(31) == LOW) { vcs.answerCall(); delay(500); }
if (vcs.getvoiceCallStatus() == TALKING && digitalRead(31) == LOW) { vcs.hangCall(); delay(500); }
// if the reading from the analog input has changed by some small amount, set the volume
if (abs(analogRead(A0) - potval) > 10) {
// analogRead() returns values from 0 to 1023, map that to 0 to 100 (the range for setVolume).
potval = analogRead(A0);
volume.setVolume(map(potval, 0, 1023, 0, 100));
}
}