Try again to get stop right
This commit is contained in:
@@ -124,31 +124,10 @@ public:
|
||||
virtual void stop(uint32_t maxWaitMs) {
|
||||
at->streamClear(); // Empty anything in the buffer
|
||||
// empty the saved currently-in-use destination address
|
||||
at->savedOperatingIP = IPAddress(0, 0, 0, 0);
|
||||
at->commandMode();
|
||||
|
||||
// Get the current socket timeout
|
||||
at->sendAT(GF("TM"));
|
||||
String timeoutUsed = at->readResponseString(5000L);
|
||||
|
||||
// For WiFi models, there's no direct way to close the socket. This is a
|
||||
// hack to shut the socket by setting the timeout to zero.
|
||||
if (at->beeType == XBEE_S6B_WIFI) {
|
||||
at->sendAT(GF("TM0")); // Set socket timeout to 0
|
||||
at->waitResponse(maxWaitMs); // This response can be slow
|
||||
at->writeChanges();
|
||||
}
|
||||
|
||||
// For cellular models, per documentation: If you write the TM (socket
|
||||
// timeout) value while in Transparent Mode, the current connection is
|
||||
// immediately closed - this works even if the TM values is unchanged
|
||||
at->sendAT(GF("TM"), timeoutUsed); // Re-set socket timeout
|
||||
at->waitResponse(maxWaitMs); // This response can be slow
|
||||
at->writeChanges();
|
||||
at->exitCommand();
|
||||
at->streamClear(); // Empty anything remaining in the buffer
|
||||
at->modemStop(maxWaitMs);
|
||||
at->streamClear(); // Empty anything in the buffer
|
||||
sock_connected = false;
|
||||
|
||||
|
||||
// Note: because settings are saved in flash, the XBEE will attempt to
|
||||
// reconnect to the previous socket if it receives any outgoing data.
|
||||
// Setting sock_connected to false after the stop ensures that connected()
|
||||
@@ -1016,6 +995,36 @@ public:
|
||||
return success;
|
||||
}
|
||||
|
||||
bool modemStop(uint32_t maxWaitMs) {
|
||||
streamClear(); // Empty anything in the buffer
|
||||
// empty the saved currently-in-use destination address
|
||||
savedOperatingIP = IPAddress(0, 0, 0, 0);
|
||||
|
||||
XBEE_COMMAND_START_DECORATOR(5, false)
|
||||
|
||||
// Get the current socket timeout
|
||||
sendAT(GF("TM"));
|
||||
String timeoutUsed = readResponseString(5000L);
|
||||
|
||||
// For WiFi models, there's no direct way to close the socket. This is a
|
||||
// hack to shut the socket by setting the timeout to zero.
|
||||
if (beeType == XBEE_S6B_WIFI) {
|
||||
sendAT(GF("TM0")); // Set socket timeout to 0
|
||||
waitResponse(maxWaitMs); // This response can be slow
|
||||
writeChanges();
|
||||
}
|
||||
|
||||
// For cellular models, per documentation: If you write the TM (socket
|
||||
// timeout) value while in Transparent Mode, the current connection is
|
||||
// immediately closed - this works even if the TM values is unchanged
|
||||
sendAT(GF("TM"), timeoutUsed); // Re-set socket timeout
|
||||
waitResponse(maxWaitMs); // This response can be slow
|
||||
writeChanges();
|
||||
|
||||
XBEE_COMMAND_END_DECORATOR
|
||||
return true;
|
||||
}
|
||||
|
||||
int16_t modemSend(const void* buff, size_t len, uint8_t mux = 0) {
|
||||
if (mux != 0) {
|
||||
DBG("XBee only supports 1 IP channel in transparent mode!");
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#define TinyGsmCommon_h
|
||||
|
||||
// The current library version number
|
||||
#define TINYGSM_VERSION "0.9.15"
|
||||
#define TINYGSM_VERSION "0.9.16"
|
||||
|
||||
#if defined(SPARK) || defined(PARTICLE)
|
||||
#include "Particle.h"
|
||||
|
Reference in New Issue
Block a user