From 02213b20d2f6da392cf6f6cd7e7176f00a46a232 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Mon, 26 Dec 2016 16:52:45 +0200 Subject: [PATCH] Fix #1 --- TinyGsmClient.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/TinyGsmClient.h b/TinyGsmClient.h index 5d5cebe..e8322f0 100644 --- a/TinyGsmClient.h +++ b/TinyGsmClient.h @@ -95,25 +95,27 @@ class GsmClient : public Client typedef TinyGsmFifo RxFifo; public: - GsmClient() { - init(NULL, -1); - } - GsmClient(TinyGsm& at, uint8_t mux = 1) { - init(&at, mux); + GsmClient() {} + + GsmClient(TinyGsm& modem, uint8_t mux = 1) { + init(&modem, mux); } - bool init(TinyGsm* at, uint8_t mux = 1) { - this->at = at; + bool init(TinyGsm* modem, uint8_t mux = 1) { + this->at = modem; this->mux = mux; - at->sockets[mux] = this; sock_available = 0; sock_connected = false; + + at->sockets[mux] = this; + return true; } public: virtual int connect(const char *host, uint16_t port) { + TINY_GSM_YIELD(); rx.clear(); sock_connected = at->modemConnect(host, port, mux); return sock_connected; @@ -132,12 +134,14 @@ public: } virtual void stop() { + TINY_GSM_YIELD(); at->sendAT(GF("+CIPCLOSE="), mux); sock_connected = false; at->waitResponse(); } virtual size_t write(const uint8_t *buf, size_t size) { + TINY_GSM_YIELD(); at->maintain(); return at->modemSend(buf, size, mux); } @@ -147,6 +151,7 @@ public: } virtual int available() { + TINY_GSM_YIELD(); if (!rx.size()) { at->maintain(); } @@ -154,6 +159,7 @@ public: } virtual int read(uint8_t *buf, size_t size) { + TINY_GSM_YIELD(); at->maintain(); size_t cnt = 0; while (cnt < size) { @@ -280,7 +286,7 @@ public: */ bool simUnlock(const char *pin) { - sendAT(GF("+CPIN="), pin); + sendAT(GF("+CPIN=\""), pin, GF("\"")); return waitResponse() == 1; }