Merge pull request #389 from adrianca88/set_phone_functionality
Added setPhoneFunctionality method
This commit is contained in:
@@ -191,6 +191,8 @@ class TinyGsmA6 : public TinyGsmModem<TinyGsmA6>,
|
|||||||
|
|
||||||
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -204,8 +204,7 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
|
|||||||
protected:
|
protected:
|
||||||
bool restartImpl() {
|
bool restartImpl() {
|
||||||
if (!testAT()) { return false; }
|
if (!testAT()) { return false; }
|
||||||
sendAT(GF("+CFUN=1,1"));
|
if (!setPhoneFunctionality(1, true)) { return false; }
|
||||||
if (waitResponse(10000L, GF("OK")) != 1) { return false; }
|
|
||||||
waitResponse(10000L, GF("APP RDY"));
|
waitResponse(10000L, GF("APP RDY"));
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -226,6 +225,11 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L, GF("OK")) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -200,6 +200,8 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
|
|||||||
|
|
||||||
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -173,8 +173,7 @@ class TinyGsmM590 : public TinyGsmModem<TinyGsmM590>,
|
|||||||
protected:
|
protected:
|
||||||
bool restartImpl() {
|
bool restartImpl() {
|
||||||
if (!testAT()) { return false; }
|
if (!testAT()) { return false; }
|
||||||
sendAT(GF("+CFUN=15"));
|
if (!setPhoneFunctionality(15)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
// MODEM:STARTUP
|
// MODEM:STARTUP
|
||||||
waitResponse(60000L, GF(GSM_NL "+PBREADY" GSM_NL));
|
waitResponse(60000L, GF(GSM_NL "+PBREADY" GSM_NL));
|
||||||
return init();
|
return init();
|
||||||
@@ -190,6 +189,11 @@ class TinyGsmM590 : public TinyGsmModem<TinyGsmM590>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -227,6 +227,8 @@ class TinyGsmM95 : public TinyGsmModem<TinyGsmM95>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -199,10 +199,8 @@ class TinyGsmMC60 : public TinyGsmModem<TinyGsmMC60>,
|
|||||||
protected:
|
protected:
|
||||||
bool restartImpl() {
|
bool restartImpl() {
|
||||||
if (!testAT()) { return false; }
|
if (!testAT()) { return false; }
|
||||||
sendAT(GF("+CFUN=0"));
|
if (!setPhoneFunctionality(0)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (!setPhoneFunctionality(1, true)) { return false; }
|
||||||
sendAT(GF("+CFUN=1,1"));
|
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000);
|
delay(3000);
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -222,6 +220,11 @@ class TinyGsmMC60 : public TinyGsmModem<TinyGsmMC60>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -234,8 +234,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool radioOffImpl() {
|
bool radioOffImpl() {
|
||||||
sendAT(GF("+CFUN=4"));
|
if (!setPhoneFunctionality(4)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000);
|
delay(3000);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -245,6 +244,11 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -213,10 +213,8 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
|
|||||||
*/
|
*/
|
||||||
protected:
|
protected:
|
||||||
bool restartImpl() {
|
bool restartImpl() {
|
||||||
sendAT(GF("+CFUN=0"));
|
if (!setPhoneFunctionality(0)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (!setPhoneFunctionality(1, true)) { return false; }
|
||||||
sendAT(GF("+CFUN=1,1"));
|
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
waitResponse(10000L, GF("SMS Ready"), GF("RDY"));
|
waitResponse(10000L, GF("SMS Ready"), GF("RDY"));
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -235,6 +233,11 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -233,8 +233,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool radioOffImpl() {
|
bool radioOffImpl() {
|
||||||
sendAT(GF("+CFUN=4"));
|
if (!setPhoneFunctionality(4)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000);
|
delay(3000);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -244,6 +243,11 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -254,10 +254,8 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
|
|||||||
if (!testAT()) { return false; }
|
if (!testAT()) { return false; }
|
||||||
sendAT(GF("&W"));
|
sendAT(GF("&W"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
sendAT(GF("+CFUN=0"));
|
if (!setPhoneFunctionality(0)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
if (!setPhoneFunctionality(1, true)) { return false; }
|
||||||
sendAT(GF("+CFUN=1,1"));
|
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000);
|
delay(3000);
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -276,6 +274,15 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <fun> 0 Minimum functionality
|
||||||
|
// <fun> 1 Full functionality (Default)
|
||||||
|
// <fun> 4 Disable phone both transmit and receive RF circuits.
|
||||||
|
// <rst> Reset the MT before setting it to <fun> power level.
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -299,8 +299,7 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
|
|||||||
// using +CFUN=15 instead of the more common CFUN=1,1
|
// using +CFUN=15 instead of the more common CFUN=1,1
|
||||||
bool restartImpl() {
|
bool restartImpl() {
|
||||||
if (!testAT()) { return false; }
|
if (!testAT()) { return false; }
|
||||||
sendAT(GF("+CFUN=15"));
|
if (!setPhoneFunctionality(15)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000); // TODO(?): Verify delay timing here
|
delay(3000); // TODO(?): Verify delay timing here
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -312,6 +311,11 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
|
|||||||
|
|
||||||
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -316,6 +316,8 @@ class TinyGsmSequansMonarch
|
|||||||
return waitResponse() == 1;
|
return waitResponse() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool setPhoneFunctionality(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -236,8 +236,7 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
|
|||||||
bool factoryDefaultImpl() {
|
bool factoryDefaultImpl() {
|
||||||
sendAT(GF("+UFACTORY=0,1")); // No factory restore, erase NVM
|
sendAT(GF("+UFACTORY=0,1")); // No factory restore, erase NVM
|
||||||
waitResponse();
|
waitResponse();
|
||||||
sendAT(GF("+CFUN=16")); // Reset
|
return setPhoneFunctionality(16); // Reset
|
||||||
return waitResponse() == 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -246,8 +245,7 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
|
|||||||
protected:
|
protected:
|
||||||
bool restartImpl() {
|
bool restartImpl() {
|
||||||
if (!testAT()) { return false; }
|
if (!testAT()) { return false; }
|
||||||
sendAT(GF("+CFUN=16"));
|
if (!setPhoneFunctionality(16)) { return false; }
|
||||||
if (waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000); // TODO(?): Verify delay timing here
|
delay(3000); // TODO(?): Verify delay timing here
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -259,6 +257,11 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
|
|||||||
|
|
||||||
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
|
||||||
|
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
|
||||||
|
return waitResponse(10000L) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -572,6 +572,8 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
|
|
||||||
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
@@ -65,6 +65,9 @@ class TinyGsmModem {
|
|||||||
bool sleepEnable(bool enable = true) {
|
bool sleepEnable(bool enable = true) {
|
||||||
return thisModem().sleepEnableImpl(enable);
|
return thisModem().sleepEnableImpl(enable);
|
||||||
}
|
}
|
||||||
|
bool setPhoneFunctionality(uint8_t fun, bool reset = false) {
|
||||||
|
return thisModem().setPhoneFunctionalityImpl(fun, reset);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
@@ -164,14 +167,15 @@ class TinyGsmModem {
|
|||||||
*/
|
*/
|
||||||
protected:
|
protected:
|
||||||
bool radioOffImpl() {
|
bool radioOffImpl() {
|
||||||
thisModem().sendAT(GF("+CFUN=0"));
|
if (!thisModem().setPhoneFunctionality(0)) { return false; }
|
||||||
if (thisModem().waitResponse(10000L) != 1) { return false; }
|
|
||||||
delay(3000);
|
delay(3000);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic network functions
|
* Generic network functions
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user