From 8961005ea5770083f84cd34ed79f2d0e8345191b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 25 Jan 2019 14:57:40 -0500 Subject: [PATCH] Gave sizes to some ints --- src/TinyGsmClientA6.h | 6 +++--- src/TinyGsmClientBG96.h | 6 +++--- src/TinyGsmClientESP8266.h | 4 ++-- src/TinyGsmClientM590.h | 6 +++--- src/TinyGsmClientM95.h | 6 +++--- src/TinyGsmClientMC60.h | 6 +++--- src/TinyGsmClientSIM800.h | 6 +++--- src/TinyGsmClientUBLOX.h | 6 +++--- src/TinyGsmClientXBee.h | 30 +++++++++++++++--------------- src/TinyGsmCommon.h | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index e10d495..3eac97b 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -358,7 +358,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -585,7 +585,7 @@ public: uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; - int getBattPercent() { + int8_t getBattPercent() { sendAT(GF("+CBC?")); if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; @@ -622,7 +622,7 @@ protected: return (1 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+CIPSEND="), mux, ',', len); if (waitResponse(2000L, GF(GSM_NL ">")) != 1) { return 0; diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index f240e37..73a38ac 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -391,7 +391,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -572,7 +572,7 @@ public: return res; } - int getBattPercent() { + int8_t getBattPercent() { sendAT(GF("+CBC")); if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; @@ -609,7 +609,7 @@ protected: return (0 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+QISEND="), mux, ',', len); if (waitResponse(GF(">")) != 1) { return 0; diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 1fb87e6..72e430a 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -314,7 +314,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CWJAP_CUR?")); int res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:")); if (res1 != 2) { @@ -405,7 +405,7 @@ protected: return (1 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+CIPSEND="), mux, ',', len); if (waitResponse(GF(">")) != 1) { return 0; diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index 092dfdd..7adff18 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -362,7 +362,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -522,7 +522,7 @@ public: uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; - int getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE; + int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE; /* * Client related functions @@ -550,7 +550,7 @@ protected: return false; } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+TCPSEND="), mux, ',', len); if (waitResponse(GF(">")) != 1) { return 0; diff --git a/src/TinyGsmClientM95.h b/src/TinyGsmClientM95.h index 93c9f0d..1e15983 100644 --- a/src/TinyGsmClientM95.h +++ b/src/TinyGsmClientM95.h @@ -399,7 +399,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -620,7 +620,7 @@ public: return res; } - int getBattPercent() { + int8_t getBattPercent() { sendAT(GF("+CBC")); if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; @@ -646,7 +646,7 @@ protected: return (1 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+QISEND="), mux, ',', len); if (waitResponse(GF(">")) != 1) { return 0; diff --git a/src/TinyGsmClientMC60.h b/src/TinyGsmClientMC60.h index 1c2422e..06717b9 100644 --- a/src/TinyGsmClientMC60.h +++ b/src/TinyGsmClientMC60.h @@ -423,7 +423,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -648,7 +648,7 @@ public: return res; } - int getBattPercent() { + int8_t getBattPercent() { sendAT(GF("+CBC")); if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; @@ -674,7 +674,7 @@ protected: return (1 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+QISEND="), mux, ',', len); if (waitResponse(GF(">")) != 1) { return 0; diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index 62912c4..5afcc4b 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -459,7 +459,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -793,7 +793,7 @@ public: return res; } - int getBattPercent() { + int8_t getBattPercent() { sendAT(GF("+CBC")); if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; @@ -830,7 +830,7 @@ protected: return (1 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+CIPSEND="), mux, ',', len); if (waitResponse(GF(">")) != 1) { return 0; diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index 79d0d7f..eb45069 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -421,7 +421,7 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { sendAT(GF("+CSQ")); if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { return 99; @@ -634,7 +634,7 @@ public: */ uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; - int getBattPercent() { + int8_t getBattPercent() { sendAT(GF("+CIND?")); if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; @@ -677,7 +677,7 @@ protected: return (1 == rsp); } - int modemSend(const void* buff, size_t len, uint8_t mux) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+USOWR="), mux, ',', len); if (waitResponse(GF("@")) != 1) { return 0; diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index 1fbb846..6c44343 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -482,7 +482,7 @@ public: if (beeType == XBEE_UNKNOWN) getSeries(); // Need to know the bee type to interpret response sendAT(GF("AI")); - int intRes = readResponseInt(); + int16_t intRes = readResponseInt(); RegStatus stat = REG_UNKNOWN; switch (beeType){ @@ -565,12 +565,12 @@ public: * Generic network functions */ - int getSignalQuality() { + int16_t getSignalQuality() { if (!commandMode()) return 0; // Return immediately if (beeType == XBEE_UNKNOWN) getSeries(); // Need to know what type of bee so we know how to ask if (beeType == XBEE_S6B_WIFI) sendAT(GF("LM")); // ask for the "link margin" - the dB above sensitivity else sendAT(GF("DB")); // ask for the cell strength in dBm - int intRes = readResponseInt(); + int16_t intRes = readResponseInt(); exitCommand(); if (beeType == XBEE_S6B_WIFI) return -93 + intRes; // the maximum sensitivity is -93dBm else return -1*intRes; // need to convert to negative number @@ -624,7 +624,7 @@ public: sendAT(GF("NR0")); // Do a network reset in order to disconnect // NOTE: On wifi modules, using a network reset will not // allow the same ssid to re-join without rebooting the module. - int res = (1 == waitResponse(5000)); + int8_t res = (1 == waitResponse(5000)); writeChanges(); exitCommand(); return res; @@ -660,7 +660,7 @@ public: bool gprsDisconnect() { if (!commandMode()) return false; // return immediately sendAT(GF("AM1")); // Cheating and disconnecting by turning on airplane mode - int res = (1 == waitResponse(5000)); + int8_t res = (1 == waitResponse(5000)); writeChanges(); sendAT(GF("AM0")); // Airplane mode off waitResponse(5000); @@ -708,7 +708,7 @@ public: uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; - int getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE; + int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE; /* * Client related functions @@ -762,7 +762,7 @@ protected: return success; } - int modemSend(const void* buff, size_t len, uint8_t mux = 0) { + int16_t modemSend(const void* buff, size_t len, uint8_t mux = 0) { stream.write((uint8_t*)buff, len); stream.flush(); return len; @@ -771,7 +771,7 @@ protected: bool modemGetConnected(uint8_t mux = 0) { if (!commandMode()) return false; sendAT(GF("AI")); - int res = waitResponse(GF("0")); + int16_t res = waitResponse(GF("0")); exitCommand(); return 1 == res; } @@ -812,7 +812,7 @@ public: String r5s(r5); r5s.trim(); DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/ data.reserve(16); // Should never be getting much here for the XBee - int index = 0; + int8_t index = 0; unsigned long startMillis = millis(); do { TINY_GSM_YIELD(); @@ -873,8 +873,8 @@ finish: return waitResponse(1000, r1, r2, r3, r4, r5); } - bool commandMode(int retries = 2) { - int triesMade = 0; + bool commandMode(uint8_t retries = 2) { + uint8_t triesMade = 0; bool success = false; streamClear(); // Empty everything in the buffer before starting while (!success and triesMade < retries) { @@ -908,7 +908,7 @@ finish: void getSeries(void) { sendAT(GF("HS")); // Get the "Hardware Series"; - int intRes = readResponseInt(); + int16_t intRes = readResponseInt(); beeType = (XBeeType)intRes; DBG(GF("### Modem: "), getModemName()); } @@ -922,11 +922,11 @@ finish: return res; } - int readResponseInt(uint32_t timeout = 1000) { + int16_t readResponseInt(uint32_t timeout = 1000) { String res = readResponseString(timeout); // it just works better reading a string first char buf[5] = {0,}; res.toCharArray(buf, 5); - int intRes = strtol(buf, 0, 16); + int16_t intRes = strtol(buf, 0, 16); return intRes; } @@ -934,7 +934,7 @@ public: Stream& stream; protected: - int guardTime; + int16_t guardTime; XBeeType beeType; GsmClient* sockets[TINY_GSM_MUX_COUNT]; }; diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index d915b26..0bf3b85 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -258,7 +258,7 @@ public: * Generic network functions */ - virtual int getSignalQuality() = 0; + virtual int16_t getSignalQuality() = 0; // NOTE: this returns whether the modem is registered on the cellular or WiFi // network NOT whether GPRS or other internet connections are available virtual bool isNetworkConnected() = 0;