You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

750 lines
17 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. /**
  2. * @file TinyGsmClientSIM800.h
  3. * @author Volodymyr Shymanskyy
  4. * @license LGPL-3.0
  5. * @copyright Copyright (c) 2016 Volodymyr Shymanskyy
  6. * @date Nov 2016
  7. */
  8. #ifndef TinyGsmClientSIM800_h
  9. #define TinyGsmClientSIM800_h
  10. // #define TINY_GSM_DEBUG Serial
  11. // #define TINY_GSM_USE_HEX
  12. #if !defined(TINY_GSM_RX_BUFFER)
  13. #define TINY_GSM_RX_BUFFER 64
  14. #endif
  15. #include <TinyGsmCommon.h>
  16. #define GSM_NL "\r\n"
  17. static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL;
  18. static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL;
  19. enum SimStatus {
  20. SIM_ERROR = 0,
  21. SIM_READY = 1,
  22. SIM_LOCKED = 2,
  23. };
  24. enum RegStatus {
  25. REG_UNREGISTERED = 0,
  26. REG_SEARCHING = 2,
  27. REG_DENIED = 3,
  28. REG_OK_HOME = 1,
  29. REG_OK_ROAMING = 5,
  30. REG_UNKNOWN = 4,
  31. };
  32. class TinyGsm
  33. {
  34. public:
  35. TinyGsm(Stream& stream)
  36. : stream(stream)
  37. {}
  38. public:
  39. class GsmClient : public Client
  40. {
  41. friend class TinyGsm;
  42. typedef TinyGsmFifo<uint8_t, TINY_GSM_RX_BUFFER> RxFifo;
  43. public:
  44. GsmClient() {}
  45. GsmClient(TinyGsm& modem, uint8_t mux = 1) {
  46. init(&modem, mux);
  47. }
  48. bool init(TinyGsm* modem, uint8_t mux = 1) {
  49. this->at = modem;
  50. this->mux = mux;
  51. sock_available = 0;
  52. sock_connected = false;
  53. at->sockets[mux] = this;
  54. return true;
  55. }
  56. public:
  57. virtual int connect(const char *host, uint16_t port) {
  58. TINY_GSM_YIELD();
  59. rx.clear();
  60. sock_connected = at->modemConnect(host, port, mux);
  61. return sock_connected;
  62. }
  63. virtual int connect(IPAddress ip, uint16_t port) {
  64. String host; host.reserve(16);
  65. host += ip[0];
  66. host += ".";
  67. host += ip[1];
  68. host += ".";
  69. host += ip[2];
  70. host += ".";
  71. host += ip[3];
  72. return connect(host.c_str(), port);
  73. }
  74. virtual void stop() {
  75. TINY_GSM_YIELD();
  76. at->sendAT(GF("+CIPCLOSE="), mux);
  77. sock_connected = false;
  78. at->waitResponse();
  79. }
  80. virtual size_t write(const uint8_t *buf, size_t size) {
  81. TINY_GSM_YIELD();
  82. at->maintain();
  83. return at->modemSend(buf, size, mux);
  84. }
  85. virtual size_t write(uint8_t c) {
  86. return write(&c, 1);
  87. }
  88. virtual int available() {
  89. TINY_GSM_YIELD();
  90. if (!rx.size()) {
  91. at->maintain();
  92. }
  93. return rx.size() + sock_available;
  94. }
  95. virtual int read(uint8_t *buf, size_t size) {
  96. TINY_GSM_YIELD();
  97. at->maintain();
  98. size_t cnt = 0;
  99. while (cnt < size) {
  100. size_t chunk = TinyGsmMin(size-cnt, rx.size());
  101. if (chunk > 0) {
  102. rx.get(buf, chunk);
  103. buf += chunk;
  104. cnt += chunk;
  105. continue;
  106. }
  107. // TODO: Read directly into user buffer?
  108. at->maintain();
  109. if (sock_available > 0) {
  110. at->modemRead(rx.free(), mux);
  111. } else {
  112. break;
  113. }
  114. }
  115. return cnt;
  116. }
  117. virtual int read() {
  118. uint8_t c;
  119. if (read(&c, 1) == 1) {
  120. return c;
  121. }
  122. return -1;
  123. }
  124. virtual int peek() { return -1; } //TODO
  125. virtual void flush() { at->stream.flush(); }
  126. virtual uint8_t connected() {
  127. if (available()) {
  128. return true;
  129. }
  130. return sock_connected;
  131. }
  132. virtual operator bool() { return connected(); }
  133. private:
  134. TinyGsm* at;
  135. uint8_t mux;
  136. uint16_t sock_available;
  137. bool sock_connected;
  138. RxFifo rx;
  139. };
  140. public:
  141. /*
  142. * Basic functions
  143. */
  144. bool begin() {
  145. return init();
  146. }
  147. bool init() {
  148. if (!autoBaud()) {
  149. return false;
  150. }
  151. sendAT(GF("&FZE0")); // Factory + Reset + Echo Off
  152. if (waitResponse() != 1) {
  153. return false;
  154. }
  155. getSimStatus();
  156. return true;
  157. }
  158. bool autoBaud(unsigned long timeout = 10000L) {
  159. streamWrite(GF("AAAAAAAAAAAAA")); // extra A's to help detect the baud rate
  160. for (unsigned long start = millis(); millis() - start < timeout; ) {
  161. sendAT(GF(""));
  162. if (waitResponse(200) == 1) {
  163. delay(100);
  164. return true;
  165. }
  166. delay(100);
  167. }
  168. return false;
  169. }
  170. void maintain() {
  171. while (stream.available()) {
  172. waitResponse(10, NULL, NULL);
  173. }
  174. }
  175. bool factoryDefault() {
  176. sendAT(GF("&FZE0&W")); // Factory + Reset + Echo Off + Write
  177. waitResponse();
  178. sendAT(GF("+IPR=0")); // Auto-baud
  179. waitResponse();
  180. sendAT(GF("+IFC=0,0")); // No Flow Control
  181. waitResponse();
  182. sendAT(GF("+ICF=3,3")); // 8 data 0 parity 1 stop
  183. waitResponse();
  184. sendAT(GF("+CSCLK=0")); // Disable Slow Clock
  185. waitResponse();
  186. sendAT(GF("&W")); // Write configuration
  187. return waitResponse() == 1;
  188. }
  189. /*
  190. * Power functions
  191. */
  192. bool restart() {
  193. if (!autoBaud()) {
  194. return false;
  195. }
  196. sendAT(GF("+CFUN=0"));
  197. if (waitResponse(10000L) != 1) {
  198. return false;
  199. }
  200. sendAT(GF("+CFUN=1,1"));
  201. if (waitResponse(10000L) != 1) {
  202. return false;
  203. }
  204. delay(3000);
  205. return init();
  206. }
  207. /*
  208. * SIM card & Networ Operator functions
  209. */
  210. bool simUnlock(const char *pin) {
  211. sendAT(GF("+CPIN=\""), pin, GF("\""));
  212. return waitResponse() == 1;
  213. }
  214. String getSimCCID() {
  215. sendAT(GF("+ICCID"));
  216. if (waitResponse(GF(GSM_NL "+ICCID:")) != 1) {
  217. return "";
  218. }
  219. String res = streamReadUntil('\n');
  220. waitResponse();
  221. return res;
  222. }
  223. String getIMEI() {
  224. sendAT(GF("+GSN"));
  225. if (waitResponse(GF(GSM_NL)) != 1) {
  226. return "";
  227. }
  228. String res = streamReadUntil('\n');
  229. waitResponse();
  230. return res;
  231. }
  232. int getSignalQuality() {
  233. sendAT(GF("+CSQ"));
  234. if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
  235. return 99;
  236. }
  237. int res = streamReadUntil(',').toInt();
  238. waitResponse();
  239. return res;
  240. }
  241. SimStatus getSimStatus(unsigned long timeout = 10000L) {
  242. for (unsigned long start = millis(); millis() - start < timeout; ) {
  243. sendAT(GF("+CPIN?"));
  244. if (waitResponse(GF(GSM_NL "+CPIN:")) != 1) {
  245. delay(1000);
  246. continue;
  247. }
  248. int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
  249. waitResponse();
  250. switch (status) {
  251. case 2:
  252. case 3: return SIM_LOCKED;
  253. case 1: return SIM_READY;
  254. default: return SIM_ERROR;
  255. }
  256. }
  257. return SIM_ERROR;
  258. }
  259. RegStatus getRegistrationStatus() {
  260. sendAT(GF("+CREG?"));
  261. if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
  262. return REG_UNKNOWN;
  263. }
  264. streamSkipUntil(','); // Skip format (0)
  265. int status = streamReadUntil('\n').toInt();
  266. waitResponse();
  267. return (RegStatus)status;
  268. }
  269. String getOperator() {
  270. sendAT(GF("+COPS?"));
  271. if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
  272. return "";
  273. }
  274. streamSkipUntil('"'); // Skip mode and format
  275. String res = streamReadUntil('"');
  276. waitResponse();
  277. return res;
  278. }
  279. bool waitForNetwork(unsigned long timeout = 60000L) {
  280. for (unsigned long start = millis(); millis() - start < timeout; ) {
  281. RegStatus s = getRegistrationStatus();
  282. if (s == REG_OK_HOME || s == REG_OK_ROAMING) {
  283. return true;
  284. }
  285. delay(1000);
  286. }
  287. return false;
  288. }
  289. /*
  290. * GPRS functions
  291. */
  292. bool gprsConnect(const char* apn, const char* user, const char* pwd) {
  293. gprsDisconnect();
  294. sendAT(GF("+SAPBR=3,1,\"Contype\",\"GPRS\""));
  295. waitResponse();
  296. sendAT(GF("+SAPBR=3,1,\"APN\",\""), apn, '"');
  297. waitResponse();
  298. if (!strcmp(user, "")) {
  299. sendAT(GF("+SAPBR=3,1,\"USER\",\""), user, '"');
  300. waitResponse();
  301. }
  302. if (!strcmp(pwd, "")) {
  303. sendAT(GF("+SAPBR=3,1,\"PWD\",\""), pwd, '"');
  304. waitResponse();
  305. }
  306. sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
  307. waitResponse();
  308. sendAT(GF("+CGACT=1,1"));
  309. waitResponse(60000L);
  310. // Open a GPRS context
  311. sendAT(GF("+SAPBR=1,1"));
  312. waitResponse(85000L);
  313. // Query the GPRS context
  314. sendAT(GF("+SAPBR=2,1"));
  315. if (waitResponse(30000L) != 1)
  316. return false;
  317. sendAT(GF("+CGATT=1"));
  318. if (waitResponse(60000L) != 1)
  319. return false;
  320. // TODO: wait AT+CGATT?
  321. sendAT(GF("+CIPMUX=1"));
  322. if (waitResponse() != 1) {
  323. return false;
  324. }
  325. sendAT(GF("+CIPQSEND=1"));
  326. if (waitResponse() != 1) {
  327. return false;
  328. }
  329. sendAT(GF("+CIPRXGET=1"));
  330. if (waitResponse() != 1) {
  331. return false;
  332. }
  333. sendAT(GF("+CSTT=\""), apn, GF("\",\""), user, GF("\",\""), pwd, GF("\""));
  334. if (waitResponse(60000L) != 1) {
  335. return false;
  336. }
  337. sendAT(GF("+CIICR"));
  338. if (waitResponse(60000L) != 1) {
  339. return false;
  340. }
  341. sendAT(GF("+CIFSR;E0"));
  342. String data;
  343. if (waitResponse(10000L, data) != 1) {
  344. data.replace(GSM_NL, "");
  345. return false;
  346. }
  347. sendAT(GF("+CDNSCFG=\"8.8.8.8\",\"8.8.4.4\""));
  348. if (waitResponse() != 1) {
  349. return false;
  350. }
  351. return true;
  352. }
  353. bool gprsDisconnect() {
  354. sendAT(GF("+CIPSHUT"));
  355. return waitResponse(60000L) == 1;
  356. }
  357. /*
  358. * Phone Call functions
  359. */
  360. bool setGsmBusy(bool busy = true) {
  361. sendAT(GF("+GSMBUSY="), busy ? 1 : 0);
  362. return waitResponse() == 1;
  363. }
  364. bool callAnswer() {
  365. sendAT(GF("A"));
  366. return waitResponse() == 1;
  367. }
  368. bool callNumber(const String& number) {
  369. sendAT(GF("D"), number);
  370. return waitResponse() == 1;
  371. }
  372. bool callHangup(const String& number) {
  373. sendAT(GF("H"), number);
  374. return waitResponse() == 1;
  375. }
  376. /*
  377. * Messaging functions
  378. */
  379. void sendUSSD() {
  380. }
  381. void sendSMS() {
  382. }
  383. bool sendSMS(const String& number, const String& text) {
  384. sendAT(GF("+CMGF=1"));
  385. waitResponse();
  386. sendAT(GF("+CMGS=\""), number, GF("\""));
  387. if (waitResponse(GF(">")) != 1) {
  388. return false;
  389. }
  390. stream.print(text);
  391. stream.write((char)0x1A);
  392. return waitResponse(60000L) == 1;
  393. }
  394. bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
  395. sendAT(GF("+CMGF=1"));
  396. waitResponse();
  397. sendAT(GF("+CSCS=\"HEX\""));
  398. waitResponse();
  399. sendAT(GF("+CSMP=17,167,0,8"));
  400. waitResponse();
  401. sendAT(GF("+CMGS=\""), number, GF("\""));
  402. if (waitResponse(GF(">")) != 1) {
  403. return false;
  404. }
  405. uint16_t* t = (uint16_t*)text;
  406. for (size_t i=0; i<len; i++) {
  407. uint8_t c = t[i] >> 8;
  408. if (c < 0x10) { stream.print('0'); }
  409. stream.print(c, HEX);
  410. c = t[i] & 0xFF;
  411. if (c < 0x10) { stream.print('0'); }
  412. stream.print(c, HEX);
  413. }
  414. stream.write((char)0x1A);
  415. return waitResponse(60000L) == 1;
  416. }
  417. /*
  418. * Location functions
  419. */
  420. void getLocation() {
  421. }
  422. String getGsmLocation() {
  423. sendAT(GF("+CIPGSMLOC=1,1"));
  424. if (waitResponse(GF(GSM_NL "+CIPGSMLOC:")) != 1) {
  425. return "";
  426. }
  427. String res = streamReadUntil('\n');
  428. waitResponse();
  429. return res;
  430. }
  431. /*
  432. * Battery functions
  433. */
  434. // Use: float vBatt = modem.getBattVoltage() / 1000.0;
  435. uint16_t getBattVoltage() {
  436. sendAT(GF("+CBC"));
  437. if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
  438. return 0;
  439. }
  440. streamSkipUntil(','); // Skip
  441. streamSkipUntil(','); // Skip
  442. uint16_t res = streamReadUntil(',').toInt();
  443. waitResponse();
  444. return res;
  445. }
  446. /* Public Utilities */
  447. template<typename... Args>
  448. void sendAT(Args... cmd) {
  449. streamWrite("AT", cmd..., GSM_NL);
  450. stream.flush();
  451. TINY_GSM_YIELD();
  452. DBG(GSM_NL, ">>> AT:", cmd...);
  453. }
  454. // TODO: Optimize this!
  455. uint8_t waitResponse(uint32_t timeout, String& data,
  456. GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  457. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  458. {
  459. /*String r1s(r1); r1s.trim();
  460. String r2s(r2); r2s.trim();
  461. String r3s(r3); r3s.trim();
  462. String r4s(r4); r4s.trim();
  463. String r5s(r5); r5s.trim();
  464. DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
  465. data.reserve(64);
  466. bool gotData = false;
  467. int mux = -1;
  468. int index = 0;
  469. unsigned long startMillis = millis();
  470. do {
  471. TINY_GSM_YIELD();
  472. while (stream.available() > 0) {
  473. int a = streamRead();
  474. if (a <= 0) continue; // Skip 0x00 bytes, just in case
  475. data += (char)a;
  476. if (r1 && data.endsWith(r1)) {
  477. index = 1;
  478. goto finish;
  479. } else if (r2 && data.endsWith(r2)) {
  480. index = 2;
  481. goto finish;
  482. } else if (r3 && data.endsWith(r3)) {
  483. index = 3;
  484. goto finish;
  485. } else if (r4 && data.endsWith(r4)) {
  486. index = 4;
  487. goto finish;
  488. } else if (r5 && data.endsWith(r5)) {
  489. index = 5;
  490. goto finish;
  491. } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) {
  492. String mode = streamReadUntil(',');
  493. if (mode.toInt() == 1) {
  494. mux = streamReadUntil('\n').toInt();
  495. gotData = true;
  496. data = "";
  497. } else {
  498. data += mode;
  499. }
  500. } else if (data.endsWith(GF("CLOSED" GSM_NL))) {
  501. int nl = data.lastIndexOf(GSM_NL, data.length()-8);
  502. int coma = data.indexOf(',', nl+2);
  503. mux = data.substring(nl+2, coma).toInt();
  504. if (mux) {
  505. sockets[mux]->sock_connected = false;
  506. data = "";
  507. }
  508. }
  509. }
  510. } while (millis() - startMillis < timeout);
  511. finish:
  512. if (!index) {
  513. data.trim();
  514. if (data.length()) {
  515. DBG("### Unhandled:", data);
  516. }
  517. data = "";
  518. }
  519. else {
  520. data.trim();
  521. data.replace(GSM_NL GSM_NL, GSM_NL);
  522. data.replace(GSM_NL, GSM_NL " ");
  523. if (data.length()) {
  524. DBG(GSM_NL, "<<< ", data);
  525. }
  526. data = "";
  527. }
  528. if (gotData) {
  529. sockets[mux]->sock_available = modemGetAvailable(mux);
  530. }
  531. return index;
  532. }
  533. uint8_t waitResponse(uint32_t timeout,
  534. GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  535. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  536. {
  537. String data;
  538. return waitResponse(timeout, data, r1, r2, r3, r4, r5);
  539. }
  540. uint8_t waitResponse(GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  541. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  542. {
  543. return waitResponse(1000, r1, r2, r3, r4, r5);
  544. }
  545. private:
  546. int modemConnect(const char* host, uint16_t port, uint8_t mux) {
  547. sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
  548. int rsp = waitResponse(75000L,
  549. GF("CONNECT OK" GSM_NL),
  550. GF("CONNECT FAIL" GSM_NL),
  551. GF("ALREADY CONNECT" GSM_NL));
  552. return (1 == rsp);
  553. }
  554. int modemSend(const void* buff, size_t len, uint8_t mux) {
  555. sendAT(GF("+CIPSEND="), mux, ',', len);
  556. if (waitResponse(GF(">")) != 1) {
  557. return -1;
  558. }
  559. stream.write((uint8_t*)buff, len);
  560. stream.flush();
  561. if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) {
  562. return -1;
  563. }
  564. streamSkipUntil(','); // Skip mux
  565. return streamReadUntil('\n').toInt();
  566. }
  567. size_t modemRead(size_t size, uint8_t mux) {
  568. #ifdef TINY_GSM_USE_HEX
  569. sendAT(GF("+CIPRXGET=3,"), mux, ',', size);
  570. if (waitResponse(GF("+CIPRXGET:")) != 1) {
  571. return 0;
  572. }
  573. #else
  574. sendAT(GF("+CIPRXGET=2,"), mux, ',', size);
  575. if (waitResponse(GF("+CIPRXGET:")) != 1) {
  576. return 0;
  577. }
  578. #endif
  579. streamSkipUntil(','); // Skip mode 2/3
  580. streamSkipUntil(','); // Skip mux
  581. size_t len = streamReadUntil(',').toInt();
  582. sockets[mux]->sock_available = streamReadUntil('\n').toInt();
  583. for (size_t i=0; i<len; i++) {
  584. #ifdef TINY_GSM_USE_HEX
  585. while (stream.available() < 2) {}
  586. char buf[4] = { 0, };
  587. buf[0] = streamRead();
  588. buf[1] = streamRead();
  589. char c = strtol(buf, NULL, 16);
  590. #else
  591. while (!stream.available()) {}
  592. char c = streamRead(); // DBG(c);
  593. #endif
  594. sockets[mux]->rx.put(c);
  595. }
  596. waitResponse();
  597. return len;
  598. }
  599. size_t modemGetAvailable(uint8_t mux) {
  600. sendAT(GF("+CIPRXGET=4,"), mux);
  601. size_t result = 0;
  602. if (waitResponse(GF("+CIPRXGET:")) == 1) {
  603. streamSkipUntil(','); // Skip mode 4
  604. streamSkipUntil(','); // Skip mux
  605. result = streamReadUntil('\n').toInt();
  606. waitResponse();
  607. }
  608. if (!result) {
  609. sockets[mux]->sock_connected = modemGetConnected(mux);
  610. }
  611. return result;
  612. }
  613. bool modemGetConnected(uint8_t mux) {
  614. sendAT(GF("+CIPSTATUS="), mux);
  615. int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
  616. waitResponse();
  617. return 1 == res;
  618. }
  619. /* Private Utilities */
  620. template<typename T>
  621. void streamWrite(T last) {
  622. stream.print(last);
  623. }
  624. template<typename T, typename... Args>
  625. void streamWrite(T head, Args... tail) {
  626. stream.print(head);
  627. streamWrite(tail...);
  628. }
  629. int streamRead() { return stream.read(); }
  630. String streamReadUntil(char c) {
  631. String return_string = stream.readStringUntil(c);
  632. return_string.trim();
  633. if (String(c) == GSM_NL || String(c) == "\n"){
  634. DBG(return_string, c, " ");
  635. } else DBG(return_string, c);
  636. return return_string;
  637. }
  638. bool streamSkipUntil(char c) {
  639. String skipped = stream.readStringUntil(c);
  640. skipped.trim();
  641. if (skipped.length()) {
  642. if (String(c) == GSM_NL || String(c) == "\n"){
  643. DBG(skipped, c, " ");
  644. } else DBG(skipped, c);
  645. return true;
  646. } else return false;
  647. }
  648. private:
  649. Stream& stream;
  650. GsmClient* sockets[5];
  651. };
  652. typedef TinyGsm::GsmClient TinyGsmClient;
  653. #endif