Add isNetworkConnected, dtmfSend examples

This commit is contained in:
Volodymyr Shymanskyy
2017-09-28 11:07:45 +03:00
parent 3db1007fb0
commit b6a917837d

View File

@@ -57,9 +57,12 @@ void setup() {
SerialMon.begin(115200); SerialMon.begin(115200);
delay(10); delay(10);
// Set your reset, enable, power pins here
delay(3000);
// Set GSM module baud rate // Set GSM module baud rate
TinyGsmAutoBaud(SerialAT); TinyGsmAutoBaud(SerialAT);
delay(3000);
} }
void loop() { void loop() {
@@ -84,6 +87,10 @@ void loop() {
return; return;
} }
if (modem.isNetworkConnected()) {
DBG("Network connected");
}
DBG("Connecting to", apn); DBG("Connecting to", apn);
if (!modem.gprsConnect(apn, user, pass)) { if (!modem.gprsConnect(apn, user, pass)) {
delay(10000); delay(10000);
@@ -149,7 +156,17 @@ void loop() {
DBG("Call:", res ? "OK" : "fail"); DBG("Call:", res ? "OK" : "fail");
if (res) { if (res) {
delay(5000L); delay(1000L);
// Play DTMF A, duration 1000ms
modem.dtmfSend('A', 1000);
// Play DTMF 0..4, default duration (100ms)
for (char tone='0'; tone<='4'; tone++) {
modem.dtmfSend(tone);
}
delay(5000);
res = modem.callHangup(); res = modem.callHangup();
DBG("Hang up:", res ? "OK" : "fail"); DBG("Hang up:", res ? "OK" : "fail");
@@ -157,7 +174,11 @@ void loop() {
#endif #endif
modem.gprsDisconnect(); modem.gprsDisconnect();
DBG("GPRS disconnected"); if (!modem.isGprsConnected()) {
DBG("GPRS disconnected");
} else {
DBG("GPRS disconnect: Failed.");
}
// Try to power-off (modem may decide to restart automatically) // Try to power-off (modem may decide to restart automatically)
// To turn off modem completely, please use Reset/Enable pins // To turn off modem completely, please use Reset/Enable pins