Browse Source

Merge pull request #389 from adrianca88/set_phone_functionality

Added setPhoneFunctionality method
v_master
Sara Damiano 4 years ago
committed by GitHub
parent
commit
6203ebd27c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 78 additions and 28 deletions
  1. +2
    -0
      src/TinyGsmClientA6.h
  2. +6
    -2
      src/TinyGsmClientBG96.h
  3. +2
    -0
      src/TinyGsmClientESP8266.h
  4. +6
    -2
      src/TinyGsmClientM590.h
  5. +2
    -0
      src/TinyGsmClientM95.h
  6. +7
    -4
      src/TinyGsmClientMC60.h
  7. +6
    -2
      src/TinyGsmClientSIM5360.h
  8. +7
    -4
      src/TinyGsmClientSIM7000.h
  9. +6
    -2
      src/TinyGsmClientSIM7600.h
  10. +11
    -4
      src/TinyGsmClientSIM800.h
  11. +6
    -2
      src/TinyGsmClientSaraR4.h
  12. +2
    -0
      src/TinyGsmClientSequansMonarch.h
  13. +7
    -4
      src/TinyGsmClientUBLOX.h
  14. +2
    -0
      src/TinyGsmClientXBee.h
  15. +6
    -2
      src/TinyGsmModem.tpp

+ 2
- 0
src/TinyGsmClientA6.h View File

@ -191,6 +191,8 @@ class TinyGsmA6 : public TinyGsmModem<TinyGsmA6>,
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
*/


+ 6
- 2
src/TinyGsmClientBG96.h View File

@ -204,8 +204,7 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
protected:
bool restartImpl() {
if (!testAT()) { return false; }
sendAT(GF("+CFUN=1,1"));
if (waitResponse(10000L, GF("OK")) != 1) { return false; }
if (!setPhoneFunctionality(1, true)) { return false; }
waitResponse(10000L, GF("APP RDY"));
return init();
}
@ -226,6 +225,11 @@ class TinyGsmBG96 : public TinyGsmModem<TinyGsmBG96>,
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
*/


+ 2
- 0
src/TinyGsmClientESP8266.h View File

@ -200,6 +200,8 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
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
*/


+ 6
- 2
src/TinyGsmClientM590.h View File

@ -173,8 +173,7 @@ class TinyGsmM590 : public TinyGsmModem<TinyGsmM590>,
protected:
bool restartImpl() {
if (!testAT()) { return false; }
sendAT(GF("+CFUN=15"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(15)) { return false; }
// MODEM:STARTUP
waitResponse(60000L, GF(GSM_NL "+PBREADY" GSM_NL));
return init();
@ -190,6 +189,11 @@ class TinyGsmM590 : public TinyGsmModem<TinyGsmM590>,
return waitResponse() == 1;
}
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
return waitResponse(10000L) == 1;
}
/*
* Generic network functions
*/


+ 2
- 0
src/TinyGsmClientM95.h View File

@ -227,6 +227,8 @@ class TinyGsmM95 : public TinyGsmModem<TinyGsmM95>,
return waitResponse() == 1;
}
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
/*
* Generic network functions
*/


+ 7
- 4
src/TinyGsmClientMC60.h View File

@ -199,10 +199,8 @@ class TinyGsmMC60 : public TinyGsmModem<TinyGsmMC60>,
protected:
bool restartImpl() {
if (!testAT()) { return false; }
sendAT(GF("+CFUN=0"));
if (waitResponse(10000L) != 1) { return false; }
sendAT(GF("+CFUN=1,1"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(0)) { return false; }
if (!setPhoneFunctionality(1, true)) { return false; }
delay(3000);
return init();
}
@ -222,6 +220,11 @@ class TinyGsmMC60 : public TinyGsmModem<TinyGsmMC60>,
return waitResponse() == 1;
}
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
return waitResponse(10000L) == 1;
}
/*
* Generic network functions
*/


+ 6
- 2
src/TinyGsmClientSIM5360.h View File

@ -234,8 +234,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
}
bool radioOffImpl() {
sendAT(GF("+CFUN=4"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(4)) { return false; }
delay(3000);
return true;
}
@ -245,6 +244,11 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>,
return waitResponse() == 1;
}
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
return waitResponse(10000L) == 1;
}
/*
* Generic network functions
*/


+ 7
- 4
src/TinyGsmClientSIM7000.h View File

@ -213,10 +213,8 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
*/
protected:
bool restartImpl() {
sendAT(GF("+CFUN=0"));
if (waitResponse(10000L) != 1) { return false; }
sendAT(GF("+CFUN=1,1"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(0)) { return false; }
if (!setPhoneFunctionality(1, true)) { return false; }
waitResponse(10000L, GF("SMS Ready"), GF("RDY"));
return init();
}
@ -235,6 +233,11 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
return waitResponse() == 1;
}
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
return waitResponse(10000L) == 1;
}
/*
* Generic network functions
*/


+ 6
- 2
src/TinyGsmClientSIM7600.h View File

@ -233,8 +233,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
}
bool radioOffImpl() {
sendAT(GF("+CFUN=4"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(4)) { return false; }
delay(3000);
return true;
}
@ -244,6 +243,11 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>,
return waitResponse() == 1;
}
bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) {
sendAT(GF("+CFUN="), fun, reset ? ",1" : "");
return waitResponse(10000L) == 1;
}
/*
* Generic network functions
*/


+ 11
- 4
src/TinyGsmClientSIM800.h View File

@ -254,10 +254,8 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
if (!testAT()) { return false; }
sendAT(GF("&W"));
waitResponse();
sendAT(GF("+CFUN=0"));
if (waitResponse(10000L) != 1) { return false; }
sendAT(GF("+CFUN=1,1"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(0)) { return false; }
if (!setPhoneFunctionality(1, true)) { return false; }
delay(3000);
return init();
}
@ -276,6 +274,15 @@ class TinyGsmSim800 : public TinyGsmModem<TinyGsmSim800>,
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
*/


+ 6
- 2
src/TinyGsmClientSaraR4.h View File

@ -299,8 +299,7 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
// using +CFUN=15 instead of the more common CFUN=1,1
bool restartImpl() {
if (!testAT()) { return false; }
sendAT(GF("+CFUN=15"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(15)) { return false; }
delay(3000); // TODO(?): Verify delay timing here
return init();
}
@ -312,6 +311,11 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
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
*/


+ 2
- 0
src/TinyGsmClientSequansMonarch.h View File

@ -316,6 +316,8 @@ class TinyGsmSequansMonarch
return waitResponse() == 1;
}
bool setPhoneFunctionality(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED;
/*
* Generic network functions
*/


+ 7
- 4
src/TinyGsmClientUBLOX.h View File

@ -236,8 +236,7 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
bool factoryDefaultImpl() {
sendAT(GF("+UFACTORY=0,1")); // No factory restore, erase NVM
waitResponse();
sendAT(GF("+CFUN=16")); // Reset
return waitResponse() == 1;
return setPhoneFunctionality(16); // Reset
}
/*
@ -246,8 +245,7 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
protected:
bool restartImpl() {
if (!testAT()) { return false; }
sendAT(GF("+CFUN=16"));
if (waitResponse(10000L) != 1) { return false; }
if (!setPhoneFunctionality(16)) { return false; }
delay(3000); // TODO(?): Verify delay timing here
return init();
}
@ -259,6 +257,11 @@ class TinyGsmUBLOX : public TinyGsmModem<TinyGsmUBLOX>,
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
*/


+ 2
- 0
src/TinyGsmClientXBee.h View File

@ -572,6 +572,8 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
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
*/


+ 6
- 2
src/TinyGsmModem.tpp View File

@ -65,6 +65,9 @@ class TinyGsmModem {
bool sleepEnable(bool enable = true) {
return thisModem().sleepEnableImpl(enable);
}
bool setPhoneFunctionality(uint8_t fun, bool reset = false) {
return thisModem().setPhoneFunctionalityImpl(fun, reset);
}
/*
* Generic network functions
@ -164,14 +167,15 @@ class TinyGsmModem {
*/
protected:
bool radioOffImpl() {
thisModem().sendAT(GF("+CFUN=0"));
if (thisModem().waitResponse(10000L) != 1) { return false; }
if (!thisModem().setPhoneFunctionality(0)) { return false; }
delay(3000);
return true;
}
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
*/


Loading…
Cancel
Save