Gave sizes to some ints

This commit is contained in:
Sara Damiano
2019-01-25 14:57:40 -05:00
parent de5e5e359e
commit 8961005ea5
10 changed files with 39 additions and 39 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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];
};

View File

@@ -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;