Cleanup after XBee merge
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#ifndef TinyGsmClient_h
|
||||
#define TinyGsmClient_h
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900)
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM900)
|
||||
#include <TinyGsmClientSIM800.h>
|
||||
typedef TinyGsmSim800 TinyGsm;
|
||||
typedef TinyGsmSim800::GsmClient TinyGsmClient;
|
||||
|
@@ -348,17 +348,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* WiFi functions
|
||||
*/
|
||||
bool networkConnect(const char* ssid, const char* pwd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool networkDisconnect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPRS functions
|
||||
*/
|
||||
@@ -645,7 +634,7 @@ public:
|
||||
streamWrite("AT", cmd..., GSM_NL);
|
||||
stream.flush();
|
||||
TINY_GSM_YIELD();
|
||||
// DBG("### AT:", cmd...);
|
||||
//DBG("### AT:", cmd...);
|
||||
}
|
||||
|
||||
// TODO: Optimize this!
|
||||
@@ -710,7 +699,7 @@ public:
|
||||
}
|
||||
}
|
||||
} while (millis() - startMillis < timeout);
|
||||
finish:
|
||||
finish:
|
||||
if (!index) {
|
||||
data.trim();
|
||||
if (data.length()) {
|
||||
|
@@ -212,9 +212,6 @@ public:
|
||||
return autoBaud();
|
||||
}
|
||||
|
||||
/*
|
||||
* SIM card functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generic network functions
|
||||
@@ -311,17 +308,6 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPRS functions
|
||||
*/
|
||||
bool gprsConnect(const char* apn, const char* user, const char* pwd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool gprsDisconnect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int modemConnect(const char* host, uint16_t port, uint8_t mux) {
|
||||
@@ -330,7 +316,7 @@ private:
|
||||
GFP(GSM_OK),
|
||||
GFP(GSM_ERROR),
|
||||
GF(GSM_NL "ALREADY CONNECT" GSM_NL));
|
||||
waitResponse(100, GF("1,CONNECT"));
|
||||
waitResponse(100, GF("1,CONNECT")); // TODO
|
||||
return (1 == rsp);
|
||||
}
|
||||
|
||||
@@ -383,7 +369,7 @@ public:
|
||||
streamWrite("AT", cmd..., GSM_NL);
|
||||
stream.flush();
|
||||
TINY_GSM_YIELD();
|
||||
// DBG("### AT:", cmd...);
|
||||
//DBG("### AT:", cmd...);
|
||||
}
|
||||
|
||||
// TODO: Optimize this!
|
||||
@@ -444,7 +430,7 @@ public:
|
||||
}
|
||||
}
|
||||
} while (millis() - startMillis < timeout);
|
||||
finish:
|
||||
finish:
|
||||
if (!index) {
|
||||
data.trim();
|
||||
if (data.length()) {
|
||||
|
@@ -357,17 +357,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* WiFi functions
|
||||
*/
|
||||
bool networkConnect(const char* ssid, const char* pwd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool networkDisconnect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPRS functions
|
||||
*/
|
||||
@@ -632,7 +621,7 @@ public:
|
||||
streamWrite("AT", cmd..., GSM_NL);
|
||||
stream.flush();
|
||||
TINY_GSM_YIELD();
|
||||
// DBG("### AT:", cmd...);
|
||||
//DBG("### AT:", cmd...);
|
||||
}
|
||||
|
||||
// TODO: Optimize this!
|
||||
@@ -698,7 +687,7 @@ public:
|
||||
}
|
||||
}
|
||||
} while (millis() - startMillis < timeout);
|
||||
finish:
|
||||
finish:
|
||||
if (!index) {
|
||||
data.trim();
|
||||
if (data.length()) {
|
||||
|
@@ -9,8 +9,8 @@
|
||||
#ifndef TinyGsmClientSIM800_h
|
||||
#define TinyGsmClientSIM800_h
|
||||
|
||||
// #define TINY_GSM_DEBUG Serial
|
||||
// #define TINY_GSM_USE_HEX
|
||||
//#define TINY_GSM_DEBUG Serial
|
||||
//#define TINY_GSM_USE_HEX
|
||||
|
||||
#if !defined(TINY_GSM_RX_BUFFER)
|
||||
#define TINY_GSM_RX_BUFFER 64
|
||||
@@ -426,17 +426,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* WiFi functions
|
||||
*/
|
||||
bool networkConnect(const char* ssid, const char* pwd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool networkDisconnect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPRS functions
|
||||
*/
|
||||
@@ -449,11 +438,11 @@ public:
|
||||
sendAT(GF("+SAPBR=3,1,\"APN\",\""), apn, '"');
|
||||
waitResponse();
|
||||
|
||||
if (user) {
|
||||
if (user && strlen(user) > 0) {
|
||||
sendAT(GF("+SAPBR=3,1,\"USER\",\""), user, '"');
|
||||
waitResponse();
|
||||
}
|
||||
if (pwd) {
|
||||
if (pwd && strlen(pwd) > 0) {
|
||||
sendAT(GF("+SAPBR=3,1,\"PWD\",\""), pwd, '"');
|
||||
waitResponse();
|
||||
}
|
||||
@@ -868,7 +857,7 @@ public:
|
||||
streamWrite("AT", cmd..., GSM_NL);
|
||||
stream.flush();
|
||||
TINY_GSM_YIELD();
|
||||
DBG("### AT:", cmd...);
|
||||
//DBG("### AT:", cmd...);
|
||||
}
|
||||
|
||||
// TODO: Optimize this!
|
||||
@@ -910,7 +899,7 @@ public:
|
||||
String mode = stream.readStringUntil(',');
|
||||
if (mode.toInt() == 1) {
|
||||
int mux = stream.readStringUntil('\n').toInt();
|
||||
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) {
|
||||
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
|
||||
sockets[mux]->got_data = true;
|
||||
}
|
||||
data = "";
|
||||
@@ -921,7 +910,7 @@ public:
|
||||
int nl = data.lastIndexOf(GSM_NL, data.length()-8);
|
||||
int coma = data.indexOf(',', nl+2);
|
||||
int mux = data.substring(nl+2, coma).toInt();
|
||||
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) {
|
||||
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
|
||||
sockets[mux]->sock_connected = false;
|
||||
}
|
||||
data = "";
|
||||
@@ -929,7 +918,7 @@ public:
|
||||
}
|
||||
}
|
||||
} while (millis() - startMillis < timeout);
|
||||
finish:
|
||||
finish:
|
||||
if (!index) {
|
||||
data.trim();
|
||||
if (data.length()) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file TinyWiFiClientESP8266.h
|
||||
* @file TinyGsmClientXBee.h
|
||||
* @author Volodymyr Shymanskyy
|
||||
* @license LGPL-3.0
|
||||
* @copyright Copyright (c) 2016 Volodymyr Shymanskyy
|
||||
@@ -47,11 +47,6 @@ enum RegStatus {
|
||||
class TinyGsm
|
||||
{
|
||||
|
||||
public:
|
||||
TinyGsm(Stream& stream)
|
||||
: stream(stream)
|
||||
{}
|
||||
|
||||
public:
|
||||
|
||||
class GsmClient : public Client
|
||||
@@ -114,6 +109,8 @@ public:
|
||||
}
|
||||
|
||||
virtual size_t write(const uint8_t *buf, size_t size) {
|
||||
TINY_GSM_YIELD();
|
||||
//at->maintain();
|
||||
return at->modemSend(buf, size, mux);
|
||||
}
|
||||
|
||||
@@ -122,6 +119,7 @@ public:
|
||||
}
|
||||
|
||||
virtual int available() {
|
||||
TINY_GSM_YIELD();
|
||||
return at->stream.available();
|
||||
}
|
||||
|
||||
@@ -144,6 +142,13 @@ public:
|
||||
return sock_connected;
|
||||
}
|
||||
virtual operator bool() { return connected(); }
|
||||
|
||||
/*
|
||||
* Extended API
|
||||
*/
|
||||
|
||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||
|
||||
private:
|
||||
TinyGsm* at;
|
||||
uint8_t mux;
|
||||
@@ -152,6 +157,12 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TinyGsm(Stream& stream)
|
||||
: stream(stream)
|
||||
{
|
||||
memset(sockets, 0, sizeof(sockets));
|
||||
}
|
||||
|
||||
/*
|
||||
* Basic functions
|
||||
*/
|
||||
@@ -360,9 +371,9 @@ public:
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
exitCommand();
|
||||
return false;
|
||||
fail:
|
||||
exitCommand();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool networkDisconnect() {
|
||||
@@ -440,6 +451,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int modemConnect(const char* host, uint16_t port, uint8_t mux = 0) {
|
||||
sendAT(GF("LA"), host);
|
||||
String strIP; strIP.reserve(16);
|
||||
@@ -495,7 +507,10 @@ private:
|
||||
return 1 == res;
|
||||
}
|
||||
|
||||
/* Private Utilities */
|
||||
public:
|
||||
|
||||
/* Utilities */
|
||||
|
||||
template<typename T>
|
||||
void streamWrite(T last) {
|
||||
stream.print(last);
|
||||
@@ -520,8 +535,7 @@ private:
|
||||
}
|
||||
|
||||
void streamClear(void) {
|
||||
while (stream.available())
|
||||
{streamRead();}
|
||||
while (stream.available()) { streamRead(); }
|
||||
}
|
||||
|
||||
bool commandMode(void) {
|
||||
@@ -548,7 +562,7 @@ private:
|
||||
streamWrite("AT", cmd..., GSM_NL);
|
||||
stream.flush();
|
||||
TINY_GSM_YIELD();
|
||||
DBG(">>> AT ", cmd..., "\r\n");
|
||||
//DBG("### AT:", cmd...);
|
||||
}
|
||||
|
||||
// TODO: Optimize this!
|
||||
@@ -589,16 +603,17 @@ private:
|
||||
}
|
||||
}
|
||||
} while (millis() - startMillis < timeout);
|
||||
finish:
|
||||
finish:
|
||||
if (!index) {
|
||||
data.trim();
|
||||
data.replace(GSM_NL GSM_NL, GSM_NL);
|
||||
data.replace(GSM_NL, "\r\n" " ");
|
||||
if (data.length()) {
|
||||
DBG("### Unhandled:", data, "\r\n");
|
||||
} else DBG("### NO RESPONSE!\r\n");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DBG("### NO RESPONSE!\r\n");
|
||||
}
|
||||
} else {
|
||||
data.trim();
|
||||
data.replace(GSM_NL GSM_NL, GSM_NL);
|
||||
data.replace(GSM_NL, "\r\n ");
|
||||
|
@@ -46,7 +46,6 @@ namespace {
|
||||
template<typename T>
|
||||
static void DBG(T last) {
|
||||
TINY_GSM_DEBUG.println(last);
|
||||
// TINY_GSM_DEBUG.print(last);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
|
Reference in New Issue
Block a user