Browse Source

merge original

v_master
Sara Damiano 6 years ago
parent
commit
f0ae66b4a5
8 changed files with 209 additions and 82 deletions
  1. +9
    -10
      .gitignore
  2. +43
    -13
      examples/HttpClient/HttpClient.ino
  3. +41
    -22
      examples/HttpsClient/HttpsClient.ino
  4. +53
    -12
      examples/WebClient/WebClient.ino
  5. +1
    -1
      library.json
  6. +1
    -1
      library.properties
  7. +1
    -1
      src/TinyGsmClientSIM800.h
  8. +60
    -22
      src/TinyGsmClientXBee.h

+ 9
- 10
.gitignore View File

@ -14,22 +14,21 @@
.cproject .cproject
.project .project
.settings .settings
# Markers
.development
# Extras
extras/docs/*
extras/Module Datasheets/*
# PlatformIO/Atom/VSCode
.pioenvs .pioenvs
.piolibdeps .piolibdeps
.clang_complete .clang_complete
.gcc-flags.json .gcc-flags.json
platformio.ini platformio.ini
lib/readme.txt lib/readme.txt
\.vscode/
include/readme.txt
.vscode/*
.vscode/.browse.c_cpp.db* .vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json .vscode/c_cpp_properties.json
.vscode/launch.json .vscode/launch.json
# Markers
.development
# Extras
extras/docs/*
extras/Module Datasheets/*

+ 43
- 13
examples/HttpClient/HttpClient.ino View File

@ -12,6 +12,9 @@
* *
* For more HTTP API examples, see ArduinoHttpClient library * For more HTTP API examples, see ArduinoHttpClient library
* *
* NOTE: This example does NOT work with the XBee because the
* HttpClient library does not empty to serial buffer fast enough
* and the buffer overflow causes the HttpClient library to stall.
**************************************************************/ **************************************************************/
// Select your modem: // Select your modem:
@ -28,10 +31,19 @@
// #define TINY_GSM_MODEM_MC60 // #define TINY_GSM_MODEM_MC60
// #define TINY_GSM_MODEM_MC60E // #define TINY_GSM_MODEM_MC60E
// #define TINY_GSM_MODEM_ESP8266 // #define TINY_GSM_MODEM_ESP8266
// #define TINY_GSM_MODEM_XBEE
// Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512
// Increase RX buffer to capture the entire response
// Chips without internal buffering (A6/A7, ESP8266, M590)
// need enough space in the buffer for the entire response
// else data will be lost (and the http library will fail).
#define TINY_GSM_RX_BUFFER 650
// See the debugging, if wanted
//#define TINY_GSM_DEBUG Serial
//#define LOGGING
// Add a reception delay, if needed
//#define TINY_GSM_YIELD() { delay(1); }
#include <TinyGsmClient.h> #include <TinyGsmClient.h>
#include <ArduinoHttpClient.h> #include <ArduinoHttpClient.h>
@ -53,8 +65,10 @@
// Your GPRS credentials // Your GPRS credentials
// Leave empty, if missing user or pass // Leave empty, if missing user or pass
const char apn[] = "YourAPN"; const char apn[] = "YourAPN";
const char user[] = "";
const char pass[] = "";
const char gprsUser[] = "";
const char gprsPass[] = "";
const char wifiSSID[] = "YourSSID";
const char wifiPass[] = "SSIDpw";
// Server details // Server details
const char server[] = "vsh.pp.ua"; const char server[] = "vsh.pp.ua";
@ -76,6 +90,7 @@ void setup() {
// Set console baud rate // Set console baud rate
SerialMon.begin(115200); SerialMon.begin(115200);
delay(10); delay(10);
SerialMon.println(F("Wait..."));
// Set GSM module baud rate // Set GSM module baud rate
SerialAT.begin(115200); SerialAT.begin(115200);
@ -95,6 +110,17 @@ void setup() {
} }
void loop() { void loop() {
if (modem.hasWifi()) {
SerialMon.print(F("Setting SSID/password..."));
if (!modem.networkConnect(wifiSSID, wifiPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
}
SerialMon.print(F("Waiting for network...")); SerialMon.print(F("Waiting for network..."));
if (!modem.waitForNetwork()) { if (!modem.waitForNetwork()) {
SerialMon.println(" fail"); SerialMon.println(" fail");
@ -103,14 +129,16 @@ void loop() {
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
SerialMon.println(" fail");
delay(10000);
return;
if (modem.hasGPRS()) {
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
} }
SerialMon.println(" OK");
SerialMon.print(F("Performing HTTP GET request... ")); SerialMon.print(F("Performing HTTP GET request... "));
int err = http.get(resource); int err = http.get(resource);
@ -121,16 +149,18 @@ void loop() {
} }
int status = http.responseStatusCode(); int status = http.responseStatusCode();
SerialMon.print(F("Response status code: "));
SerialMon.println(status); SerialMon.println(status);
if (!status) { if (!status) {
delay(10000); delay(10000);
return; return;
} }
SerialMon.println(F("Response Headers:"));
while (http.headerAvailable()) { while (http.headerAvailable()) {
String headerName = http.readHeaderName(); String headerName = http.readHeaderName();
String headerValue = http.readHeaderValue(); String headerValue = http.readHeaderValue();
//SerialMon.println(headerName + " : " + headerValue);
SerialMon.println(" " + headerName + " : " + headerValue);
} }
int length = http.contentLength(); int length = http.contentLength();


+ 41
- 22
examples/HttpsClient/HttpsClient.ino View File

@ -10,7 +10,7 @@
* TinyGSM Getting Started guide: * TinyGSM Getting Started guide:
* http://tiny.cc/tiny-gsm-readme * http://tiny.cc/tiny-gsm-readme
* *
* SSL/TLS is currently supported only with: SIM8xx, uBlox
* SSL/TLS is currently supported only with: SIM8xx, uBlox, ESP8266
* *
* For more HTTP API examples, see ArduinoHttpClient library * For more HTTP API examples, see ArduinoHttpClient library
* *
@ -18,22 +18,23 @@
// Select your modem: // Select your modem:
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM868 // #define TINY_GSM_MODEM_SIM868
// #define TINY_GSM_MODEM_UBLOX // #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_M95
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590
// #define TINY_GSM_MODEM_MC60
// #define TINY_GSM_MODEM_MC60E
// #define TINY_GSM_MODEM_ESP8266 // #define TINY_GSM_MODEM_ESP8266
// #define TINY_GSM_MODEM_XBEE
// Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512
// Increase RX buffer to capture the entire response
// Chips without internal buffering (ESP8266)
// need enough space in the buffer for the entire response
// else data will be lost (and the http library will fail).
#define TINY_GSM_RX_BUFFER 650
// See the debugging, if wanted
//#define TINY_GSM_DEBUG Serial
//#define LOGGING
// Add a reception delay, if needed
//#define TINY_GSM_YIELD() { delay(1); }
#include <TinyGsmClient.h> #include <TinyGsmClient.h>
#include <ArduinoHttpClient.h> #include <ArduinoHttpClient.h>
@ -55,8 +56,10 @@
// Your GPRS credentials // Your GPRS credentials
// Leave empty, if missing user or pass // Leave empty, if missing user or pass
const char apn[] = "YourAPN"; const char apn[] = "YourAPN";
const char user[] = "";
const char pass[] = "";
const char gprsUser[] = "";
const char gprsPass[] = "";
const char wifiSSID[] = "YourSSID";
const char wifiPass[] = "SSIDpw";
// Server details // Server details
const char server[] = "vsh.pp.ua"; const char server[] = "vsh.pp.ua";
@ -78,6 +81,7 @@ void setup() {
// Set console baud rate // Set console baud rate
SerialMon.begin(115200); SerialMon.begin(115200);
delay(10); delay(10);
SerialMon.println(F("Wait..."));
// Set GSM module baud rate // Set GSM module baud rate
SerialAT.begin(115200); SerialAT.begin(115200);
@ -102,6 +106,17 @@ void setup() {
} }
void loop() { void loop() {
if (modem.hasWifi()) {
SerialMon.print(F("Setting SSID/password..."));
if (!modem.networkConnect(wifiSSID, wifiPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
}
SerialMon.print(F("Waiting for network...")); SerialMon.print(F("Waiting for network..."));
if (!modem.waitForNetwork()) { if (!modem.waitForNetwork()) {
SerialMon.println(" fail"); SerialMon.println(" fail");
@ -110,14 +125,16 @@ void loop() {
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
SerialMon.println(" fail");
delay(10000);
return;
if (modem.hasGPRS()) {
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
} }
SerialMon.println(" OK");
SerialMon.print(F("Performing HTTPS GET request... ")); SerialMon.print(F("Performing HTTPS GET request... "));
http.connectionKeepAlive(); // Currently, this is needed for HTTPS http.connectionKeepAlive(); // Currently, this is needed for HTTPS
@ -129,16 +146,18 @@ void loop() {
} }
int status = http.responseStatusCode(); int status = http.responseStatusCode();
SerialMon.print(F("Response status code: "));
SerialMon.println(status); SerialMon.println(status);
if (!status) { if (!status) {
delay(10000); delay(10000);
return; return;
} }
SerialMon.println(F("Response Headers:"));
while (http.headerAvailable()) { while (http.headerAvailable()) {
String headerName = http.readHeaderName(); String headerName = http.readHeaderName();
String headerValue = http.readHeaderValue(); String headerValue = http.readHeaderValue();
//SerialMon.println(headerName + " : " + headerValue);
SerialMon.println(" " + headerName + " : " + headerValue);
} }
int length = http.contentLength(); int length = http.contentLength();


+ 53
- 12
examples/WebClient/WebClient.ino View File

@ -27,6 +27,13 @@
// Increase RX buffer if needed // Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512 //#define TINY_GSM_RX_BUFFER 512
// See the debugging, if wanted
//#define TINY_GSM_DEBUG Serial
//#define LOGGING
// Add a reception delay, if needed
//#define TINY_GSM_YIELD() { delay(1); }
#include <TinyGsmClient.h> #include <TinyGsmClient.h>
// Uncomment this if you want to see all AT commands // Uncomment this if you want to see all AT commands
@ -49,8 +56,10 @@
// Your GPRS credentials // Your GPRS credentials
// Leave empty, if missing user or pass // Leave empty, if missing user or pass
const char apn[] = "YourAPN"; const char apn[] = "YourAPN";
const char user[] = "";
const char pass[] = "";
const char gprsUser[] = "";
const char gprsPass[] = "";
const char wifiSSID[] = "YourSSID";
const char wifiPass[] = "SSIDpw";
// Server details // Server details
const char server[] = "vsh.pp.ua"; const char server[] = "vsh.pp.ua";
@ -76,9 +85,13 @@ void setup() {
// Set console baud rate // Set console baud rate
SerialMon.begin(115200); SerialMon.begin(115200);
delay(10); delay(10);
SerialMon.println(F("Wait..."));
pinMode(23, OUTPUT);
digitalWrite(23, LOW);
// Set GSM module baud rate // Set GSM module baud rate
SerialAT.begin(115200);
SerialAT.begin(9600);
delay(3000); delay(3000);
// Restart takes quite some time // Restart takes quite some time
@ -95,6 +108,26 @@ void setup() {
} }
void loop() { void loop() {
if (modem.hasWifi()) {
SerialMon.print(F("Setting SSID/password..."));
if (!modem.networkConnect(wifiSSID, wifiPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
}
else if (modem.getModemName().indexOf("XBee") >= 0) {
SerialMon.print(F("Setting APN"));
if (!modem.gprsConnect(apn)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
}
SerialMon.print(F("Waiting for network...")); SerialMon.print(F("Waiting for network..."));
if (!modem.waitForNetwork()) { if (!modem.waitForNetwork()) {
SerialMon.println(" fail"); SerialMon.println(" fail");
@ -103,14 +136,16 @@ void loop() {
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
SerialMon.println(" fail");
delay(10000);
return;
if (modem.hasGPRS()) {
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
} }
SerialMon.println(" OK");
SerialMon.print(F("Connecting to ")); SerialMon.print(F("Connecting to "));
SerialMon.print(server); SerialMon.print(server);
@ -142,8 +177,14 @@ void loop() {
client.stop(); client.stop();
SerialMon.println(F("Server disconnected")); SerialMon.println(F("Server disconnected"));
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
if (modem.hasWifi()) {
modem.networkDisconnect();
SerialMon.println(F("WiFi disconnected"));
}
else {
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
}
// Do nothing forevermore // Do nothing forevermore
while (true) { while (true) {


+ 1
- 1
library.json View File

@ -1,6 +1,6 @@
{ {
"name": "TinyGSM", "name": "TinyGSM",
"version": "0.4.5",
"version": "0.4.6",
"description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM and wifi modules with AT command interfaces.", "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM and wifi modules with AT command interfaces.",
"keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox", "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox",
"authors": "authors":


+ 1
- 1
library.properties View File

@ -1,5 +1,5 @@
name=TinyGSM name=TinyGSM
version=0.4.5
version=0.4.6
author=Volodymyr Shymanskyy author=Volodymyr Shymanskyy
maintainer=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy
sentence=A small Arduino library for GPRS modules, that just works. sentence=A small Arduino library for GPRS modules, that just works.


+ 1
- 1
src/TinyGsmClientSIM800.h View File

@ -147,7 +147,7 @@ public:
// Workaround: sometimes SIM800 forgets to notify about data arrival. // Workaround: sometimes SIM800 forgets to notify about data arrival.
// TODO: Currently we ping the module periodically, // TODO: Currently we ping the module periodically,
// but maybe there's a better indicator that we need to poll // but maybe there's a better indicator that we need to poll
if (millis() - prev_check > 250) {
if (millis() - prev_check > 250) {
got_data = true; got_data = true;
prev_check = millis(); prev_check = millis();
} }


+ 60
- 22
src/TinyGsmClientXBee.h View File

@ -58,6 +58,7 @@ public:
class GsmClient : public Client class GsmClient : public Client
{ {
friend class TinyGsmXBee; friend class TinyGsmXBee;
// typedef TinyGsmFifo<uint8_t, TINY_GSM_RX_BUFFER> RxFifo;
public: public:
GsmClient() {} GsmClient() {}
@ -78,45 +79,45 @@ public:
public: public:
virtual int connect(const char *host, uint16_t port) { virtual int connect(const char *host, uint16_t port) {
at->streamClear(); // Empty anything remaining in the buffer;
bool sock_connected = false;
at->streamClear(); // Empty anything in the buffer before starting
if (at->commandMode()) { // Don't try if we didn't successfully get into command mode if (at->commandMode()) { // Don't try if we didn't successfully get into command mode
sock_connected = at->modemConnect(host, port, mux, false); sock_connected = at->modemConnect(host, port, mux, false);
at->writeChanges(); at->writeChanges();
at->exitCommand(); at->exitCommand();
} }
at->streamClear(); // Empty anything remaining in the buffer;
else
sock_connected = false;
return sock_connected; return sock_connected;
} }
virtual int connect(IPAddress ip, uint16_t port) { virtual int connect(IPAddress ip, uint16_t port) {
at->streamClear(); // Empty anything remaining in the buffer;
bool sock_connected = false;
at->streamClear(); // Empty anything in the buffer before starting
if (at->commandMode()) { // Don't try if we didn't successfully get into command mode if (at->commandMode()) { // Don't try if we didn't successfully get into command mode
sock_connected = at->modemConnect(ip, port, mux, false); sock_connected = at->modemConnect(ip, port, mux, false);
at->writeChanges(); at->writeChanges();
at->exitCommand(); at->exitCommand();
} }
at->streamClear(); // Empty anything remaining in the buffer;
else
sock_connected = false;
return sock_connected; return sock_connected;
} }
// This is a hack to shut the socket by setting the timeout to zero and // This is a hack to shut the socket by setting the timeout to zero and
// then sending an empty line to the server.
// then sending an empty line to the server.
virtual void stop() { virtual void stop() {
at->streamClear(); // Empty anything remaining in the buffer;
at->streamClear(); // Empty anything in the buffer
at->commandMode(); at->commandMode();
at->sendAT(GF("TM0")); // Set socket timeout to 0; at->sendAT(GF("TM0")); // Set socket timeout to 0;
at->waitResponse(); at->waitResponse();
at->writeChanges(); at->writeChanges();
at->exitCommand(); at->exitCommand();
at->modemSend("", 1, mux);
at->streamWrite("");
at->commandMode(); at->commandMode();
at->sendAT(GF("TM64")); // Set socket timeout back to 10 seconds; at->sendAT(GF("TM64")); // Set socket timeout back to 10 seconds;
at->waitResponse(); at->waitResponse();
at->writeChanges(); at->writeChanges();
at->exitCommand(); at->exitCommand();
at->streamClear(); // Empty anything remaining in the buffer;
at->streamClear(); // Empty anything remaining in the buffer
sock_connected = false; sock_connected = false;
} }
@ -137,19 +138,45 @@ public:
virtual int available() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
return at->stream.available(); return at->stream.available();
// if (!rx.size() || at->stream.available()) {
// at->maintain();
// }
// return at->stream.available() + rx.size();
} }
virtual int read(uint8_t *buf, size_t size) { virtual int read(uint8_t *buf, size_t size) {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
return at->stream.readBytes((char*)buf, size);
return at->stream.readBytes((char *)buf, size);
// size_t cnt = 0;
// uint32_t _startMillis = millis();
// while (cnt < size && millis() - _startMillis < _timeout) {
// size_t chunk = TinyGsmMin(size-cnt, rx.size());
// if (chunk > 0) {
// rx.get(buf, chunk);
// buf += chunk;
// cnt += chunk;
// continue;
// }
// // TODO: Read directly into user buffer?
// if (!rx.size() || at->stream.available()) {
// at->maintain();
// }
// }
// return cnt;
} }
virtual int read() { virtual int read() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
return at->stream.read(); return at->stream.read();
// uint8_t c;
// if (read(&c, 1) == 1) {
// return c;
// }
// return -1;
} }
virtual int peek() { return at->stream.peek(); } virtual int peek() { return at->stream.peek(); }
// virtual int peek() { return -1; } //TODO
virtual void flush() { at->stream.flush(); } virtual void flush() { at->stream.flush(); }
virtual uint8_t connected() { virtual uint8_t connected() {
@ -170,6 +197,7 @@ private:
TinyGsmXBee* at; TinyGsmXBee* at;
uint8_t mux; uint8_t mux;
bool sock_connected; bool sock_connected;
// RxFifo rx;
}; };
@ -178,32 +206,32 @@ class GsmClientSecure : public GsmClient
public: public:
GsmClientSecure() {} GsmClientSecure() {}
GsmClientSecure(TinyGsmXBee& modem, uint8_t mux = 1)
GsmClientSecure(TinyGsmXBee& modem, uint8_t mux = 0)
: GsmClient(modem, mux) : GsmClient(modem, mux)
{} {}
public: public:
virtual int connect(const char *host, uint16_t port) { virtual int connect(const char *host, uint16_t port) {
at->streamClear(); // Empty anything remaining in the buffer;
bool sock_connected = false;
at->streamClear(); // Empty anything in the buffer before starting
if (at->commandMode()) { // Don't try if we didn't successfully get into command mode if (at->commandMode()) { // Don't try if we didn't successfully get into command mode
sock_connected = at->modemConnect(host, port, mux, true); sock_connected = at->modemConnect(host, port, mux, true);
at->writeChanges(); at->writeChanges();
at->exitCommand(); at->exitCommand();
} }
at->streamClear(); // Empty anything remaining in the buffer;
else
sock_connected = false;
return sock_connected; return sock_connected;
} }
virtual int connect(IPAddress ip, uint16_t port) { virtual int connect(IPAddress ip, uint16_t port) {
at->streamClear(); // Empty anything remaining in the buffer;
bool sock_connected = false;
at->streamClear(); // Empty anything in the buffer before starting
if (at->commandMode()) { // Don't try if we didn't successfully get into command mode if (at->commandMode()) { // Don't try if we didn't successfully get into command mode
sock_connected = at->modemConnect(ip, port, mux, true); sock_connected = at->modemConnect(ip, port, mux, true);
at->writeChanges(); at->writeChanges();
at->exitCommand(); at->exitCommand();
} }
at->streamClear(); // Empty anything remaining in the buffer;
else
sock_connected = false;
return sock_connected; return sock_connected;
} }
}; };
@ -216,6 +244,7 @@ public:
{ {
beeType = XBEE_UNKNOWN; // Start not knowing what kind of bee it is beeType = XBEE_UNKNOWN; // Start not knowing what kind of bee it is
guardTime = TINY_GSM_XBEE_GUARD_TIME; // Start with the default guard time of 1 second guardTime = TINY_GSM_XBEE_GUARD_TIME; // Start with the default guard time of 1 second
memset(sockets, 0, sizeof(sockets));
} }
/* /*
@ -285,7 +314,16 @@ public:
return false; return false;
} }
void maintain() {}
void maintain() {
// this only happens OUTSIDE command mode, so if we're getting characters
// they should be data received from the TCP connection
// TINY_GSM_YIELD();
// uint32_t _startMillis = millis();
// while (stream.available() || millis() - _startMillis < 10) {
// char c = stream.read();
// if (c > 0) sockets[0]->rx.put(c);
// }
}
bool factoryDefault() { bool factoryDefault() {
if (!commandMode()) return false; // Return immediately if (!commandMode()) return false; // Return immediately
@ -369,7 +407,7 @@ public:
} }
if (beeType != XBEE_S6B_WIFI) { if (beeType != XBEE_S6B_WIFI) {
sendAT(GF("AM1")); // Turn of airplane mode
sendAT(GF("AM0")); // Turn off airplane mode
if (waitResponse() != 1) return exitAndFail(); if (waitResponse() != 1) return exitAndFail();
if (!writeChanges()) return exitAndFail(); if (!writeChanges()) return exitAndFail();
} }
@ -681,7 +719,7 @@ protected:
while (!gotIP && millis() - startMillis < 45000L) // the lookup can take a while while (!gotIP && millis() - startMillis < 45000L) // the lookup can take a while
{ {
sendAT(GF("LA"), host); sendAT(GF("LA"), host);
while (stream.available() < 4) {}; // wait for any response
while (stream.available() < 4 && millis() - startMillis < 45000L) {}; // wait for any response
strIP = stream.readStringUntil('\r'); // read result strIP = stream.readStringUntil('\r'); // read result
strIP.trim(); strIP.trim();
if (!strIP.endsWith(GF("ERROR"))) gotIP = true; if (!strIP.endsWith(GF("ERROR"))) gotIP = true;
@ -740,7 +778,7 @@ public:
void streamClear(void) { void streamClear(void) {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
while (stream.available()) { stream.read(); }
while (stream.available()) { stream.read();}
} }
template<typename... Args> template<typename... Args>


Loading…
Cancel
Save