diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index d59717a..3f168df 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -25,7 +25,7 @@ with your board before submitting any issues. Modem: Main processor board: -TinyGSM version: +TinyGSM version: Code: ### Scenario, steps to reproduce diff --git a/library.json b/library.json index e850793..3edbf95 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TinyGSM", - "version": "0.10.8", + "version": "0.10.9", "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.", "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M", "authors": [ diff --git a/library.properties b/library.properties index 97e63b7..f0f7f56 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TinyGSM -version=0.10.8 +version=0.10.9 author=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy sentence=A small Arduino library for GPRS modules, that just works. diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index ae6803e..aba1cf8 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -191,7 +191,8 @@ class TinyGsmA6 : public TinyGsmModem, bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE; - bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) + TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * Generic network functions @@ -475,7 +476,7 @@ class TinyGsmA6 : public TinyGsmModem, String r5s(r5); r5s.trim(); DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/ data.reserve(64); - uint8_t index = 0; + uint8_t index = 0; uint32_t startMillis = millis(); do { TINY_GSM_YIELD(); @@ -505,8 +506,8 @@ class TinyGsmA6 : public TinyGsmModem, index = 5; goto finish; } else if (data.endsWith(GF("+CIPRCV:"))) { - int8_t mux = streamGetIntBefore(','); - int16_t len = streamGetIntBefore(','); + int8_t mux = streamGetIntBefore(','); + int16_t len = streamGetIntBefore(','); int16_t len_orig = len; if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { if (len > sockets[mux]->rx.free()) { @@ -514,9 +515,7 @@ class TinyGsmA6 : public TinyGsmModem, } else { DBG("### Got: ", len, "->", sockets[mux]->rx.free()); } - while (len--) { - moveCharFromStreamToFifo(mux); - } + while (len--) { moveCharFromStreamToFifo(mux); } // TODO(?) Deal with missing characters if (len_orig > sockets[mux]->available()) { DBG("### Fewer characters received than expected: ", @@ -537,9 +536,7 @@ class TinyGsmA6 : public TinyGsmModem, finish: if (!index) { data.trim(); - if (data.length()) { - DBG("### Unhandled:", data); - } + if (data.length()) { DBG("### Unhandled:", data); } data = ""; } // data.replace(GSM_NL, "/"); @@ -577,7 +574,7 @@ class TinyGsmA6 : public TinyGsmModem, protected: GsmClientA6* sockets[TINY_GSM_MUX_COUNT]; - const char* gsmNL = GSM_NL; + const char* gsmNL = GSM_NL; }; #endif // SRC_TINYGSMCLIENTA6_H_ diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index b4ae604..6b32e49 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -684,7 +684,7 @@ class TinyGsmBG96 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientBG96* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 38d8a50..b3244c7 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -200,7 +200,8 @@ class TinyGsmESP8266 : public TinyGsmModem, bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_AVAILABLE; - bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) + TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * Generic network functions @@ -317,9 +318,7 @@ class TinyGsmESP8266 : public TinyGsmModem, // if the status is anything but 3, there are no connections open waitResponse(); // Returns an OK after the status for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { - if (sockets[muxNo]) { - sockets[muxNo]->sock_connected = false; - } + if (sockets[muxNo]) { sockets[muxNo]->sock_connected = false; } } return false; } @@ -398,9 +397,7 @@ class TinyGsmESP8266 : public TinyGsmModem, } else { // DBG("### Got Data: ", len, "on", mux); } - while (len--) { - moveCharFromStreamToFifo(mux); - } + while (len--) { moveCharFromStreamToFifo(mux); } // TODO(SRGDamia1): deal with buffer overflow/missed characters if (len_orig > sockets[mux]->available()) { DBG("### Fewer characters received than expected: ", @@ -446,7 +443,7 @@ class TinyGsmESP8266 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientESP8266* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index 094049a..c234941 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -407,9 +407,7 @@ class TinyGsmM590 : public TinyGsmModem, } else { DBG("### Got: ", len, "->", sockets[mux]->rx.free()); } - while (len--) { - moveCharFromStreamToFifo(mux); - } + while (len--) { moveCharFromStreamToFifo(mux); } // TODO(?): Handle lost characters if (len_orig > sockets[mux]->available()) { DBG("### Fewer characters received than expected: ", @@ -465,7 +463,7 @@ class TinyGsmM590 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientM590* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientM95.h b/src/TinyGsmClientM95.h index ad94449..a853512 100644 --- a/src/TinyGsmClientM95.h +++ b/src/TinyGsmClientM95.h @@ -227,7 +227,8 @@ class TinyGsmM95 : public TinyGsmModem, return waitResponse() == 1; } - bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) + TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * Generic network functions @@ -625,7 +626,7 @@ class TinyGsmM95 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientM95* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientSIM5360.h b/src/TinyGsmClientSIM5360.h index 6b184d4..536d0d6 100644 --- a/src/TinyGsmClientSIM5360.h +++ b/src/TinyGsmClientSIM5360.h @@ -222,9 +222,7 @@ class TinyGsmSim5360 : public TinyGsmModem, if (waitResponse(10000L) != 1) { return false; } // After booting, modem sends out messages as each of its // internal modules loads. The final message is "PB DONE". - if (waitResponse(40000L, GF(GSM_NL "PB DONE")) != 1) { - return false; - } + if (waitResponse(40000L, GF(GSM_NL "PB DONE")) != 1) { return false; } return init(); } @@ -234,7 +232,7 @@ class TinyGsmSim5360 : public TinyGsmModem, } bool radioOffImpl() { - if (!setPhoneFunctionality(4)) { return false; } + if (!setPhoneFunctionality(4)) { return false; } delay(3000); return true; } @@ -587,9 +585,7 @@ class TinyGsmSim5360 : public TinyGsmModem, for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { // +CIPCLOSE:,,..., bool muxState = stream.parseInt(); - if (sockets[muxNo]) { - sockets[muxNo]->sock_connected = muxState; - } + if (sockets[muxNo]) { sockets[muxNo]->sock_connected = muxState; } } waitResponse(); // Should be an OK at the end if (!sockets[mux]) return false; @@ -722,7 +718,7 @@ class TinyGsmSim5360 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientSim5360* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index 7960ef6..4a9e751 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -764,7 +764,7 @@ class TinyGsmSim7000 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientSim7000* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index 2e612fd..b78ac98 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -254,7 +254,7 @@ class TinyGsmSim800 : public TinyGsmModem, if (!testAT()) { return false; } sendAT(GF("&W")); waitResponse(); - if (!setPhoneFunctionality(0)) { return false; } + if (!setPhoneFunctionality(0)) { return false; } if (!setPhoneFunctionality(1, true)) { return false; } delay(3000); return init(); diff --git a/src/TinyGsmClientSaraR4.h b/src/TinyGsmClientSaraR4.h index 4ac42cf..30ccb81 100644 --- a/src/TinyGsmClientSaraR4.h +++ b/src/TinyGsmClientSaraR4.h @@ -888,7 +888,7 @@ class TinyGsmSaraR4 : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientSaraR4* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientSequansMonarch.h b/src/TinyGsmClientSequansMonarch.h index 654fc5e..1a997db 100644 --- a/src/TinyGsmClientSequansMonarch.h +++ b/src/TinyGsmClientSequansMonarch.h @@ -316,7 +316,8 @@ class TinyGsmSequansMonarch return waitResponse() == 1; } - bool setPhoneFunctionality(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool setPhoneFunctionality(uint8_t fun, + bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * Generic network functions diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index cb8750d..600dcd7 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -236,7 +236,7 @@ class TinyGsmUBLOX : public TinyGsmModem, bool factoryDefaultImpl() { sendAT(GF("+UFACTORY=0,1")); // No factory restore, erase NVM waitResponse(); - return setPhoneFunctionality(16); // Reset + return setPhoneFunctionality(16); // Reset } /* @@ -820,7 +820,7 @@ class TinyGsmUBLOX : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; protected: GsmClientUBLOX* sockets[TINY_GSM_MUX_COUNT]; diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index 0669351..cd8320d 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -572,7 +572,8 @@ class TinyGsmXBee : public TinyGsmModem, bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED; - bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) + TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * Generic network functions @@ -1443,7 +1444,8 @@ class TinyGsmXBee : public TinyGsmModem, } public: - Stream& stream; + Stream& stream; + protected: GsmClientXBee* sockets[TINY_GSM_MUX_COUNT]; const char* gsmNL = GSM_NL; diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index ce23519..e82fa23 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -10,7 +10,7 @@ #define SRC_TINYGSMCOMMON_H_ // The current library version number -#define TINYGSM_VERSION "0.10.8" +#define TINYGSM_VERSION "0.10.9" #if defined(SPARK) || defined(PARTICLE) #include "Particle.h" diff --git a/src/TinyGsmGPS.tpp b/src/TinyGsmGPS.tpp index 4c333cc..897d1f9 100644 --- a/src/TinyGsmGPS.tpp +++ b/src/TinyGsmGPS.tpp @@ -43,13 +43,11 @@ class TinyGsmGPS { hour, minute, second); } - String setGNSSMode(uint8_t mode,bool dpo) - { - return thisModem().setGNSSModeImpl(mode,dpo); + String setGNSSMode(uint8_t mode, bool dpo) { + return thisModem().setGNSSModeImpl(mode, dpo); } - uint8_t getGNSSMode() - { + uint8_t getGNSSMode() { return thisModem().getGNSSModeImpl(); } @@ -68,15 +66,15 @@ class TinyGsmGPS { * GPS/GNSS/GLONASS location functions */ - bool enableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; - bool disableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; - String getGPSrawImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; - bool getGPSImpl(float* lat, float* lon, float* speed = 0, float* alt = 0, - int* vsat = 0, int* usat = 0, float* accuracy = 0, - int* year = 0, int* month = 0, int* day = 0, int* hour = 0, - int* minute = 0, - int* second = 0) TINY_GSM_ATTR_NOT_IMPLEMENTED; - String setGNSSModeImpl(uint8_t mode,bool dpo) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool enableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool disableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; + String getGPSrawImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool getGPSImpl(float* lat, float* lon, float* speed = 0, float* alt = 0, + int* vsat = 0, int* usat = 0, float* accuracy = 0, + int* year = 0, int* month = 0, int* day = 0, int* hour = 0, + int* minute = 0, + int* second = 0) TINY_GSM_ATTR_NOT_IMPLEMENTED; + String setGNSSModeImpl(uint8_t mode, bool dpo) TINY_GSM_ATTR_NOT_IMPLEMENTED; uint8_t getGNSSModeImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED; }; diff --git a/src/TinyGsmModem.tpp b/src/TinyGsmModem.tpp index 0cbfc33..d22770f 100644 --- a/src/TinyGsmModem.tpp +++ b/src/TinyGsmModem.tpp @@ -174,7 +174,8 @@ class TinyGsmModem { bool sleepEnableImpl(bool enable = true) TINY_GSM_ATTR_NOT_IMPLEMENTED; - bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) TINY_GSM_ATTR_NOT_IMPLEMENTED; + bool setPhoneFunctionalityImpl(uint8_t fun, bool reset = false) + TINY_GSM_ATTR_NOT_IMPLEMENTED; /* * Generic network functions @@ -266,15 +267,15 @@ class TinyGsmModem { } protected: - inline bool streamGetLength(char* buf, int8_t numChars, const uint32_t timeout_ms = 1000L) { - if (!buf) { - return false; - } - - int8_t numCharsReady = -1; - uint32_t startMillis = millis(); - while (millis() - startMillis < timeout_ms && (numCharsReady = thisModem().stream.available()) < numChars) { - TINY_GSM_YIELD(); + inline bool streamGetLength(char* buf, int8_t numChars, + const uint32_t timeout_ms = 1000L) { + if (!buf) { return false; } + + int8_t numCharsReady = -1; + uint32_t startMillis = millis(); + while (millis() - startMillis < timeout_ms && + (numCharsReady = thisModem().stream.available()) < numChars) { + TINY_GSM_YIELD(); } if (numCharsReady >= numChars) { @@ -285,8 +286,9 @@ class TinyGsmModem { return false; } - inline int16_t streamGetIntLength(int8_t numChars, const uint32_t timeout_ms = 1000L) { - char buf[numChars + 1]; + inline int16_t streamGetIntLength(int8_t numChars, + const uint32_t timeout_ms = 1000L) { + char buf[numChars + 1]; if (streamGetLength(buf, numChars, timeout_ms)) { buf[numChars] = '\0'; return atoi(buf); @@ -309,13 +311,14 @@ class TinyGsmModem { return -9999; } - inline float streamGetFloatLength(int8_t numChars, const uint32_t timeout_ms = 1000L) { - char buf[numChars + 1]; + inline float streamGetFloatLength(int8_t numChars, + const uint32_t timeout_ms = 1000L) { + char buf[numChars + 1]; if (streamGetLength(buf, numChars, timeout_ms)) { buf[numChars] = '\0'; return atof(buf); - } - + } + return -9999.0F; } @@ -328,8 +331,8 @@ class TinyGsmModem { buf[bytesRead] = '\0'; float res = atof(buf); return res; - } - + } + return -9999.0F; }