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 * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -585,7 +585,7 @@ public:
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
int getBattPercent() { int8_t getBattPercent() {
sendAT(GF("+CBC?")); sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
@@ -622,7 +622,7 @@ protected:
return (1 == rsp); 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); sendAT(GF("+CIPSEND="), mux, ',', len);
if (waitResponse(2000L, GF(GSM_NL ">")) != 1) { if (waitResponse(2000L, GF(GSM_NL ">")) != 1) {
return 0; return 0;

View File

@@ -391,7 +391,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -572,7 +572,7 @@ public:
return res; return res;
} }
int getBattPercent() { int8_t getBattPercent() {
sendAT(GF("+CBC")); sendAT(GF("+CBC"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
@@ -609,7 +609,7 @@ protected:
return (0 == rsp); 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); sendAT(GF("+QISEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) { if (waitResponse(GF(">")) != 1) {
return 0; return 0;

View File

@@ -314,7 +314,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CWJAP_CUR?")); sendAT(GF("+CWJAP_CUR?"));
int res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:")); int res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:"));
if (res1 != 2) { if (res1 != 2) {
@@ -405,7 +405,7 @@ protected:
return (1 == rsp); 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); sendAT(GF("+CIPSEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) { if (waitResponse(GF(">")) != 1) {
return 0; return 0;

View File

@@ -362,7 +362,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -522,7 +522,7 @@ public:
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; 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 * Client related functions
@@ -550,7 +550,7 @@ protected:
return false; 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); sendAT(GF("+TCPSEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) { if (waitResponse(GF(">")) != 1) {
return 0; return 0;

View File

@@ -399,7 +399,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -620,7 +620,7 @@ public:
return res; return res;
} }
int getBattPercent() { int8_t getBattPercent() {
sendAT(GF("+CBC")); sendAT(GF("+CBC"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
@@ -646,7 +646,7 @@ protected:
return (1 == rsp); 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); sendAT(GF("+QISEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) { if (waitResponse(GF(">")) != 1) {
return 0; return 0;

View File

@@ -423,7 +423,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -648,7 +648,7 @@ public:
return res; return res;
} }
int getBattPercent() { int8_t getBattPercent() {
sendAT(GF("+CBC")); sendAT(GF("+CBC"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
@@ -674,7 +674,7 @@ protected:
return (1 == rsp); 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); sendAT(GF("+QISEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) { if (waitResponse(GF(">")) != 1) {
return 0; return 0;

View File

@@ -459,7 +459,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -793,7 +793,7 @@ public:
return res; return res;
} }
int getBattPercent() { int8_t getBattPercent() {
sendAT(GF("+CBC")); sendAT(GF("+CBC"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
@@ -830,7 +830,7 @@ protected:
return (1 == rsp); 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); sendAT(GF("+CIPSEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) { if (waitResponse(GF(">")) != 1) {
return 0; return 0;

View File

@@ -421,7 +421,7 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
sendAT(GF("+CSQ")); sendAT(GF("+CSQ"));
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
return 99; return 99;
@@ -634,7 +634,7 @@ public:
*/ */
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
int getBattPercent() { int8_t getBattPercent() {
sendAT(GF("+CIND?")); sendAT(GF("+CIND?"));
if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { if (waitResponse(GF(GSM_NL "+CIND:")) != 1) {
return 0; return 0;
@@ -677,7 +677,7 @@ protected:
return (1 == rsp); 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); sendAT(GF("+USOWR="), mux, ',', len);
if (waitResponse(GF("@")) != 1) { if (waitResponse(GF("@")) != 1) {
return 0; return 0;

View File

@@ -482,7 +482,7 @@ public:
if (beeType == XBEE_UNKNOWN) getSeries(); // Need to know the bee type to interpret response if (beeType == XBEE_UNKNOWN) getSeries(); // Need to know the bee type to interpret response
sendAT(GF("AI")); sendAT(GF("AI"));
int intRes = readResponseInt(); int16_t intRes = readResponseInt();
RegStatus stat = REG_UNKNOWN; RegStatus stat = REG_UNKNOWN;
switch (beeType){ switch (beeType){
@@ -565,12 +565,12 @@ public:
* Generic network functions * Generic network functions
*/ */
int getSignalQuality() { int16_t getSignalQuality() {
if (!commandMode()) return 0; // Return immediately 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_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 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 else sendAT(GF("DB")); // ask for the cell strength in dBm
int intRes = readResponseInt(); int16_t intRes = readResponseInt();
exitCommand(); exitCommand();
if (beeType == XBEE_S6B_WIFI) return -93 + intRes; // the maximum sensitivity is -93dBm if (beeType == XBEE_S6B_WIFI) return -93 + intRes; // the maximum sensitivity is -93dBm
else return -1*intRes; // need to convert to negative number 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 sendAT(GF("NR0")); // Do a network reset in order to disconnect
// NOTE: On wifi modules, using a network reset will not // NOTE: On wifi modules, using a network reset will not
// allow the same ssid to re-join without rebooting the module. // allow the same ssid to re-join without rebooting the module.
int res = (1 == waitResponse(5000)); int8_t res = (1 == waitResponse(5000));
writeChanges(); writeChanges();
exitCommand(); exitCommand();
return res; return res;
@@ -660,7 +660,7 @@ public:
bool gprsDisconnect() { bool gprsDisconnect() {
if (!commandMode()) return false; // return immediately if (!commandMode()) return false; // return immediately
sendAT(GF("AM1")); // Cheating and disconnecting by turning on airplane mode sendAT(GF("AM1")); // Cheating and disconnecting by turning on airplane mode
int res = (1 == waitResponse(5000)); int8_t res = (1 == waitResponse(5000));
writeChanges(); writeChanges();
sendAT(GF("AM0")); // Airplane mode off sendAT(GF("AM0")); // Airplane mode off
waitResponse(5000); waitResponse(5000);
@@ -708,7 +708,7 @@ public:
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; 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 * Client related functions
@@ -762,7 +762,7 @@ protected:
return success; 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.write((uint8_t*)buff, len);
stream.flush(); stream.flush();
return len; return len;
@@ -771,7 +771,7 @@ protected:
bool modemGetConnected(uint8_t mux = 0) { bool modemGetConnected(uint8_t mux = 0) {
if (!commandMode()) return false; if (!commandMode()) return false;
sendAT(GF("AI")); sendAT(GF("AI"));
int res = waitResponse(GF("0")); int16_t res = waitResponse(GF("0"));
exitCommand(); exitCommand();
return 1 == res; return 1 == res;
} }
@@ -812,7 +812,7 @@ public:
String r5s(r5); r5s.trim(); String r5s(r5); r5s.trim();
DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/ DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
data.reserve(16); // Should never be getting much here for the XBee data.reserve(16); // Should never be getting much here for the XBee
int index = 0; int8_t index = 0;
unsigned long startMillis = millis(); unsigned long startMillis = millis();
do { do {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
@@ -873,8 +873,8 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5); return waitResponse(1000, r1, r2, r3, r4, r5);
} }
bool commandMode(int retries = 2) { bool commandMode(uint8_t retries = 2) {
int triesMade = 0; uint8_t triesMade = 0;
bool success = false; bool success = false;
streamClear(); // Empty everything in the buffer before starting streamClear(); // Empty everything in the buffer before starting
while (!success and triesMade < retries) { while (!success and triesMade < retries) {
@@ -908,7 +908,7 @@ finish:
void getSeries(void) { void getSeries(void) {
sendAT(GF("HS")); // Get the "Hardware Series"; sendAT(GF("HS")); // Get the "Hardware Series";
int intRes = readResponseInt(); int16_t intRes = readResponseInt();
beeType = (XBeeType)intRes; beeType = (XBeeType)intRes;
DBG(GF("### Modem: "), getModemName()); DBG(GF("### Modem: "), getModemName());
} }
@@ -922,11 +922,11 @@ finish:
return res; 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 String res = readResponseString(timeout); // it just works better reading a string first
char buf[5] = {0,}; char buf[5] = {0,};
res.toCharArray(buf, 5); res.toCharArray(buf, 5);
int intRes = strtol(buf, 0, 16); int16_t intRes = strtol(buf, 0, 16);
return intRes; return intRes;
} }
@@ -934,7 +934,7 @@ public:
Stream& stream; Stream& stream;
protected: protected:
int guardTime; int16_t guardTime;
XBeeType beeType; XBeeType beeType;
GsmClient* sockets[TINY_GSM_MUX_COUNT]; GsmClient* sockets[TINY_GSM_MUX_COUNT];
}; };

View File

@@ -258,7 +258,7 @@ public:
* Generic network functions * 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 // NOTE: this returns whether the modem is registered on the cellular or WiFi
// network NOT whether GPRS or other internet connections are available // network NOT whether GPRS or other internet connections are available
virtual bool isNetworkConnected() = 0; virtual bool isNetworkConnected() = 0;