mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2025-10-29 18:00:18 +00:00
Back in line?!
This commit is contained in:
@@ -457,6 +457,88 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phone Call functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool callAnswer() {
|
||||||
|
sendAT(GF("A"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true on pick-up, false on error/busy
|
||||||
|
bool callNumber(const String& number) {
|
||||||
|
if (number == GF("last")) {
|
||||||
|
sendAT(GF("DLST"));
|
||||||
|
} else {
|
||||||
|
sendAT(GF("D\""), number, "\";");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waitResponse(5000L) != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waitResponse(60000L,
|
||||||
|
GF(GSM_NL "+CIEV: \"CALL\",1"),
|
||||||
|
GF(GSM_NL "+CIEV: \"CALL\",0"),
|
||||||
|
GFP(GSM_ERROR)) != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rsp = waitResponse(60000L,
|
||||||
|
GF(GSM_NL "+CIEV: \"SOUNDER\",0"),
|
||||||
|
GF(GSM_NL "+CIEV: \"CALL\",0"));
|
||||||
|
|
||||||
|
int rsp2 = waitResponse(300L, GF(GSM_NL "BUSY" GSM_NL), GF(GSM_NL "NO ANSWER" GSM_NL));
|
||||||
|
|
||||||
|
return rsp == 1 && rsp2 == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool callHangup() {
|
||||||
|
sendAT(GF("H"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0-9,*,#,A,B,C,D
|
||||||
|
bool dtmfSend(char cmd, unsigned duration_ms = 100) {
|
||||||
|
duration_ms = constrain(duration_ms, 100, 1000);
|
||||||
|
|
||||||
|
// The duration parameter is not working, so we simulate it using delay..
|
||||||
|
// TODO: Maybe there's another way...
|
||||||
|
|
||||||
|
//sendAT(GF("+VTD="), duration_ms / 100);
|
||||||
|
//waitResponse();
|
||||||
|
|
||||||
|
sendAT(GF("+VTS="), cmd);
|
||||||
|
if (waitResponse(10000L) == 1) {
|
||||||
|
delay(duration_ms);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Audio functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool audioSetHeadphones() {
|
||||||
|
sendAT(GF("+SNFS=0"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool audioSetSpeaker() {
|
||||||
|
sendAT(GF("+SNFS=1"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool audioMuteMic(bool mute) {
|
||||||
|
sendAT(GF("+CMUT="), mute);
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -474,6 +474,36 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phone Call functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool callAnswer() {
|
||||||
|
sendAT(GF("A"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true on pick-up, false on error/busy
|
||||||
|
bool callNumber(const String& number) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
bool callHangup() {
|
||||||
|
sendAT(GF("H"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0-9,*,#,A,B,C,D
|
||||||
|
bool dtmfSend(char cmd, int duration_ms = 100) { // TODO: check
|
||||||
|
duration_ms = constrain(duration_ms, 100, 1000);
|
||||||
|
|
||||||
|
sendAT(GF("+VTD="), duration_ms / 100); // VTD accepts in 1/10 of a second
|
||||||
|
waitResponse();
|
||||||
|
|
||||||
|
sendAT(GF("+VTS="), cmd);
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -458,6 +458,18 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phone Call functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool callAnswer() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool callNumber(const String& number) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool callHangup() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -593,6 +593,14 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phone Call functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
bool callAnswer() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
bool callNumber(const String& number) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
bool callHangup() TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Location functions
|
* Location functions
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ enum RegStatus {
|
|||||||
REG_UNKNOWN = 4,
|
REG_UNKNOWN = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TinyGSMDateTimeFormat {
|
||||||
|
DATE_FULL = 0,
|
||||||
|
DATE_TIME = 1,
|
||||||
|
DATE_DATE = 2
|
||||||
|
};
|
||||||
|
|
||||||
class TinyGsmSim800 : public TinyGsmModem
|
class TinyGsmSim800 : public TinyGsmModem
|
||||||
{
|
{
|
||||||
@@ -605,6 +610,57 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phone Call functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool setGsmBusy(bool busy = true) {
|
||||||
|
sendAT(GF("+GSMBUSY="), busy ? 1 : 0);
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool callAnswer() {
|
||||||
|
sendAT(GF("A"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true on pick-up, false on error/busy
|
||||||
|
bool callNumber(const String& number) {
|
||||||
|
if (number == GF("last")) {
|
||||||
|
sendAT(GF("DL"));
|
||||||
|
} else {
|
||||||
|
sendAT(GF("D"), number, ";");
|
||||||
|
}
|
||||||
|
int status = waitResponse(60000L,
|
||||||
|
GFP(GSM_OK),
|
||||||
|
GF("BUSY" GSM_NL),
|
||||||
|
GF("NO ANSWER" GSM_NL),
|
||||||
|
GF("NO CARRIER" GSM_NL));
|
||||||
|
switch (status) {
|
||||||
|
case 1: return true;
|
||||||
|
case 2:
|
||||||
|
case 3: return false;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool callHangup() {
|
||||||
|
sendAT(GF("H"));
|
||||||
|
return waitResponse() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0-9,*,#,A,B,C,D
|
||||||
|
bool dtmfSend(char cmd, int duration_ms = 100) {
|
||||||
|
duration_ms = constrain(duration_ms, 100, 1000);
|
||||||
|
|
||||||
|
sendAT(GF("+VTD="), duration_ms / 100); // VTD accepts in 1/10 of a second
|
||||||
|
waitResponse();
|
||||||
|
|
||||||
|
sendAT(GF("+VTS="), cmd);
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
@@ -694,6 +750,32 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Time functions
|
||||||
|
*/
|
||||||
|
String getGSMDateTime(TinyGSMDateTimeFormat format) {
|
||||||
|
sendAT(GF("+CCLK?"));
|
||||||
|
if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String res;
|
||||||
|
|
||||||
|
switch(format) {
|
||||||
|
case DATE_FULL:
|
||||||
|
res = stream.readStringUntil('"');
|
||||||
|
break;
|
||||||
|
case DATE_TIME:
|
||||||
|
streamSkipUntil(',');
|
||||||
|
res = stream.readStringUntil('"');
|
||||||
|
break;
|
||||||
|
case DATE_DATE:
|
||||||
|
res = stream.readStringUntil(',');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Battery functions
|
* Battery functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -494,6 +494,18 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Phone Call functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool setGsmBusy(bool busy = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool callAnswer() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
bool callNumber(const String& number) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
bool callHangup() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Messaging functions
|
* Messaging functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user