From e7fc1b44ebfc01db65e906c04fa181494b3b978a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 30 May 2019 16:48:01 -0400 Subject: [PATCH] Must writeChanges or the XBee can't connect! --- library.json | 2 +- library.properties | 2 +- src/TinyGsmClientXBee.h | 43 +++++++++++++++++++++++------------------ src/TinyGsmCommon.h | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/library.json b/library.json index fb2fa8c..b8fa52f 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TinyGSM", - "version": "0.7.9", + "version": "0.7.10", "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.", "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M", "authors": diff --git a/library.properties b/library.properties index df969ab..4b97dbe 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TinyGSM -version=0.7.9 +version=0.7.10 author=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy sentence=A small Arduino library for GPRS modules, that just works. diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index 49321d9..f89c32d 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -864,31 +864,36 @@ protected: bool modemConnect(IPAddress ip, uint16_t port, uint8_t mux = 0, bool ssl = false, int timeout_s = 75) { - savedIP = ip; // Set the newly requested IP address bool success = true; uint32_t timeout_ms = ((uint32_t)timeout_s)*1000; XBEE_COMMAND_START_DECORATOR(5, false) - String host; host.reserve(16); - host += ip[0]; - host += "."; - host += ip[1]; - host += "."; - host += ip[2]; - host += "."; - host += ip[3]; - - if (ssl) { - sendAT(GF("IP"), 4); // Put in SSL over TCP communication mode + + if (ip != savedIP) { // Can skip almost everything if there's no change in the IP address + savedIP = ip; // Set the newly requested IP address + String host; host.reserve(16); + host += ip[0]; + host += "."; + host += ip[1]; + host += "."; + host += ip[2]; + host += "."; + host += ip[3]; + + if (ssl) { + sendAT(GF("IP"), 4); // Put in SSL over TCP communication mode + success &= (1 == waitResponse()); + } else { + sendAT(GF("IP"), 1); // Put in TCP mode + success &= (1 == waitResponse()); + } + + sendAT(GF("DL"), host); // Set the "Destination Address Low" success &= (1 == waitResponse()); - } else { - sendAT(GF("IP"), 1); // Put in TCP mode + sendAT(GF("DE"), String(port, HEX)); // Set the destination port success &= (1 == waitResponse()); - } - sendAT(GF("DL"), host); // Set the "Destination Address Low" - success &= (1 == waitResponse()); - sendAT(GF("DE"), String(port, HEX)); // Set the destination port - success &= (1 == waitResponse()); + success &= writeChanges(); + } for (unsigned long start = millis(); millis() - start < timeout_ms; ) { if (modemGetConnected()) { diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index 2bb225c..8edc8c4 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -10,7 +10,7 @@ #define TinyGsmCommon_h // The current library version number -#define TINYGSM_VERSION "0.7.9" +#define TINYGSM_VERSION "0.7.10" #if defined(SPARK) || defined(PARTICLE) #include "Particle.h"