mirror of
https://github.com/vshymanskyy/TinyGSM.git
synced 2026-05-15 04:06:10 +00:00
Revert comment reflow
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -698,7 +698,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
case 0x23: // 0x23 SSID not configured.
|
case 0x23: // 0x23 SSID not configured.
|
||||||
stat = REG_UNREGISTERED;
|
stat = REG_UNREGISTERED;
|
||||||
break;
|
break;
|
||||||
case 0x24: // 0x24 Encryption key invalid (either nullptr or invalid
|
case 0x24: // 0x24 Encryption key invalid (either NULL or invalid
|
||||||
// length for WEP).
|
// length for WEP).
|
||||||
case 0x27: // 0x27 SSID was found, but join failed.
|
case 0x27: // 0x27 SSID was found, but join failed.
|
||||||
stat = REG_DENIED;
|
stat = REG_DENIED;
|
||||||
@@ -885,8 +885,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
changesMade = true;
|
changesMade = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
changesMade |= changeSettingIfNeeded(GF("EE"),
|
changesMade |= changeSettingIfNeeded(GF("EE"), 0x0); // Set No security
|
||||||
0x0); // Set No security
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changesMade) { retVal &= writeChanges(); }
|
if (changesMade) { retVal &= writeChanges(); }
|
||||||
@@ -936,8 +935,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
changesMade = true;
|
changesMade = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
changesMade |= changeSettingIfNeeded(GF("AN"),
|
changesMade |= changeSettingIfNeeded(GF("AN"), String(apn)); // Set the APN
|
||||||
String(apn)); // Set the APN
|
|
||||||
|
|
||||||
changesMade |= changeSettingIfNeeded(GF("AM"), 0x0,
|
changesMade |= changeSettingIfNeeded(GF("AM"), 0x0,
|
||||||
5000L); // Airplane mode off
|
5000L); // Airplane mode off
|
||||||
@@ -1123,9 +1121,9 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
res.toCharArray(buf, 5);
|
res.toCharArray(buf, 5);
|
||||||
int8_t intRes = (int8_t)strtol(buf, 0,
|
int8_t intRes = (int8_t)strtol(
|
||||||
16); // degrees Celsius displayed in
|
buf, 0,
|
||||||
// 8-bit two's complement format.
|
16); // degrees Celsius displayed in 8-bit two's complement format.
|
||||||
XBEE_COMMAND_END_DECORATOR
|
XBEE_COMMAND_END_DECORATOR
|
||||||
return static_cast<float>(intRes);
|
return static_cast<float>(intRes);
|
||||||
}
|
}
|
||||||
@@ -1166,9 +1164,9 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
|
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
|
||||||
bool gotIP = false;
|
bool gotIP = false;
|
||||||
XBEE_COMMAND_START_DECORATOR(5, IPAddress(0, 0, 0, 0))
|
XBEE_COMMAND_START_DECORATOR(5, IPAddress(0, 0, 0, 0))
|
||||||
// XBee's require a numeric IP address for connection, but do provide
|
// XBee's require a numeric IP address for connection, but do provide the
|
||||||
// the functionality to look up the IP address from a fully qualified
|
// functionality to look up the IP address from a fully qualified domain
|
||||||
// domain name
|
// name
|
||||||
// NOTE: the lookup can take a while
|
// NOTE: the lookup can take a while
|
||||||
while ((millis() - startMillis) < timeout_ms) {
|
while ((millis() - startMillis) < timeout_ms) {
|
||||||
sendAT(GF("LA"), host);
|
sendAT(GF("LA"), host);
|
||||||
@@ -1198,8 +1196,8 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
XBEE_COMMAND_START_DECORATOR(5, false)
|
XBEE_COMMAND_START_DECORATOR(5, false)
|
||||||
|
|
||||||
// If this is a new host name, replace the saved host and wipe out the
|
// If this is a new host name, replace the saved host and wipe out the saved
|
||||||
// saved host IP
|
// host IP
|
||||||
if (this->savedHost != String(host)) {
|
if (this->savedHost != String(host)) {
|
||||||
this->savedHost = String(host);
|
this->savedHost = String(host);
|
||||||
savedHostIP = IPAddress(0, 0, 0, 0);
|
savedHostIP = IPAddress(0, 0, 0, 0);
|
||||||
@@ -1269,8 +1267,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
if (changesMade) { success &= writeChanges(); }
|
if (changesMade) { success &= writeChanges(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirm the XBee type if needed so we know if we can know if
|
// confirm the XBee type if needed so we know if we can know if connected
|
||||||
// connected
|
|
||||||
if (beeType == XBEE_UNKNOWN) { getSeries(); }
|
if (beeType == XBEE_UNKNOWN) { getSeries(); }
|
||||||
// we'll accept either unknown or connected
|
// we'll accept either unknown or connected
|
||||||
if (beeType != XBEE_S6B_WIFI) {
|
if (beeType != XBEE_S6B_WIFI) {
|
||||||
@@ -1300,10 +1297,9 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
sendAT(GF("TM"));
|
sendAT(GF("TM"));
|
||||||
String timeoutUsed = readResponseString(5000L);
|
String timeoutUsed = readResponseString(5000L);
|
||||||
|
|
||||||
// For cellular models, per documentation: If you write the TM
|
// For cellular models, per documentation: If you write the TM (socket
|
||||||
// (socket timeout) value while in Transparent Mode, the current
|
// timeout) value while in Transparent Mode, the current connection is
|
||||||
// connection is immediately closed - this works even if the TM
|
// immediately closed - this works even if the TM values is unchanged
|
||||||
// values is unchanged
|
|
||||||
sendAT(GF("TM"), timeoutUsed); // Re-set socket timeout
|
sendAT(GF("TM"), timeoutUsed); // Re-set socket timeout
|
||||||
waitResponse(maxWaitMs); // This response can be slow
|
waitResponse(maxWaitMs); // This response can be slow
|
||||||
}
|
}
|
||||||
@@ -1325,8 +1321,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
modemGetConnected(0);
|
modemGetConnected(0);
|
||||||
} else if (len > 5) {
|
} else if (len > 5) {
|
||||||
// After sending several characters, also re-check
|
// After sending several characters, also re-check
|
||||||
// NOTE: I'm intentionally not checking after every single
|
// NOTE: I'm intentionally not checking after every single character!
|
||||||
// character!
|
|
||||||
modemGetConnected(0);
|
modemGetConnected(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1334,11 +1329,10 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: The CI command returns the status of the TCP connection as
|
// NOTE: The CI command returns the status of the TCP connection as open only
|
||||||
// open only after data has been sent on the socket. If it returns 0xFF
|
// after data has been sent on the socket. If it returns 0xFF the socket may
|
||||||
// the socket may really be open, but no data has yet been sent. We
|
// really be open, but no data has yet been sent. We return this unknown
|
||||||
// return this unknown value as true so there's a possibility it's
|
// value as true so there's a possibility it's wrong.
|
||||||
// wrong.
|
|
||||||
bool modemGetConnected(uint8_t) {
|
bool modemGetConnected(uint8_t) {
|
||||||
// If the IP address is 0, it's not valid so we can't be connected
|
// If the IP address is 0, it's not valid so we can't be connected
|
||||||
if (savedIP == IPAddress(0, 0, 0, 0)) { return false; }
|
if (savedIP == IPAddress(0, 0, 0, 0)) { return false; }
|
||||||
@@ -1379,12 +1373,11 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x28 = "Unknown."
|
// 0x28 = "Unknown."
|
||||||
// 0xFF = No known status - always returned prior to sending
|
// 0xFF = No known status - always returned prior to sending data
|
||||||
// data
|
|
||||||
case 0x28:
|
case 0x28:
|
||||||
case 0xFF: {
|
case 0xFF: {
|
||||||
// If we previously had an operating destination and we no
|
// If we previously had an operating destination and we no longer
|
||||||
// longer do, the socket must have closed
|
// do, the socket must have closed
|
||||||
if (od == IPAddress(0, 0, 0, 0) &&
|
if (od == IPAddress(0, 0, 0, 0) &&
|
||||||
savedOperatingIP != IPAddress(0, 0, 0, 0)) {
|
savedOperatingIP != IPAddress(0, 0, 0, 0)) {
|
||||||
savedOperatingIP = od;
|
savedOperatingIP = od;
|
||||||
@@ -1396,14 +1389,13 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
sockets[0]->stop();
|
sockets[0]->stop();
|
||||||
return false;
|
return false;
|
||||||
} else if (od != IPAddress(0, 0, 0, 0) && od == savedIP) {
|
} else if (od != IPAddress(0, 0, 0, 0) && od == savedIP) {
|
||||||
// else if the operating destination exists and matches,
|
// else if the operating destination exists and matches, we're
|
||||||
// we're good to go
|
// good to go
|
||||||
savedOperatingIP = od;
|
savedOperatingIP = od;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// If we never had an operating destination, then sock may
|
// If we never had an operating destination, then sock may be open
|
||||||
// be open but data never sent - this is the dreaded "we
|
// but data never sent - this is the dreaded "we don't know"
|
||||||
// don't know"
|
|
||||||
savedOperatingIP = od;
|
savedOperatingIP = od;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1447,8 +1439,7 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
|
|
||||||
// 0x02 = Invalid parameters (bad IP/host)
|
// 0x02 = Invalid parameters (bad IP/host)
|
||||||
// 0x12 = DNS query lookup failure
|
// 0x12 = DNS query lookup failure
|
||||||
// 0x25 = Unknown server - DNS lookup failed (0x22 for UDP
|
// 0x25 = Unknown server - DNS lookup failed (0x22 for UDP socket!)
|
||||||
// socket!)
|
|
||||||
// fall through
|
// fall through
|
||||||
case 0x02:
|
case 0x02:
|
||||||
case 0x12:
|
case 0x12:
|
||||||
@@ -1497,9 +1488,8 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
streamClear(); // Empty everything in the buffer before starting
|
streamClear(); // Empty everything in the buffer before starting
|
||||||
|
|
||||||
while (!success && triesMade < retries) {
|
while (!success && triesMade < retries) {
|
||||||
// Cannot send anything for 1 "guard time" before entering command
|
// Cannot send anything for 1 "guard time" before entering command mode
|
||||||
// mode Default guard time is 1s, but the init fxn decreases it to
|
// Default guard time is 1s, but the init fxn decreases it to 100 ms
|
||||||
// 100 ms
|
|
||||||
delay(guardTime + 10);
|
delay(guardTime + 10);
|
||||||
streamWrite(GF("+++")); // enter command mode
|
streamWrite(GF("+++")); // enter command mode
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user