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
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("AAAAAAAAAAAA")); // some 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. String getGsmLocation() {
  242. sendAT(GF("+CIPGSMLOC=1,1"));
  243. if (waitResponse(GF(GSM_NL "+CIPGSMLOC:")) != 1) {
  244. return "";
  245. }
  246. String res = streamReadUntil('\n');
  247. waitResponse();
  248. return res;
  249. }
  250. bool setGsmBusy(bool busy = true) {
  251. sendAT(GF("+GSMBUSY="), busy ? 1 : 0);
  252. return waitResponse() == 1;
  253. }
  254. bool callAnswer() {
  255. sendAT(GF("A"));
  256. return waitResponse() == 1;
  257. }
  258. bool callNumber(const String& number) {
  259. sendAT(GF("D"), number);
  260. return waitResponse() == 1;
  261. }
  262. bool callHangup(const String& number) {
  263. sendAT(GF("H"), number);
  264. return waitResponse() == 1;
  265. }
  266. bool sendSMS(const String& number, const String& text) {
  267. sendAT(GF("+CMGF=1"));
  268. waitResponse();
  269. sendAT(GF("+CMGS=\""), number, GF("\""));
  270. if (waitResponse(GF(">")) != 1) {
  271. return false;
  272. }
  273. stream.print(text);
  274. stream.write((char)0x1A);
  275. return waitResponse(60000L) == 1;
  276. }
  277. bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
  278. sendAT(GF("+CMGF=1"));
  279. waitResponse();
  280. sendAT(GF("+CSCS=\"HEX\""));
  281. waitResponse();
  282. sendAT(GF("+CSMP=17,167,0,8"));
  283. waitResponse();
  284. sendAT(GF("+CMGS=\""), number, GF("\""));
  285. if (waitResponse(GF(">")) != 1) {
  286. return false;
  287. }
  288. uint16_t* t = (uint16_t*)text;
  289. for (size_t i=0; i<len; i++) {
  290. uint8_t c = t[i] >> 8;
  291. if (c < 0x10) { stream.print('0'); }
  292. stream.print(c, HEX);
  293. c = t[i] & 0xFF;
  294. if (c < 0x10) { stream.print('0'); }
  295. stream.print(c, HEX);
  296. }
  297. stream.write((char)0x1A);
  298. return waitResponse(60000L) == 1;
  299. }
  300. SimStatus getSimStatus(unsigned long timeout = 10000L) {
  301. for (unsigned long start = millis(); millis() - start < timeout; ) {
  302. sendAT(GF("+CPIN?"));
  303. if (waitResponse(GF(GSM_NL "+CPIN:")) != 1) {
  304. delay(250);
  305. continue;
  306. }
  307. int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
  308. waitResponse();
  309. switch (status) {
  310. case 2:
  311. case 3: return SIM_LOCKED;
  312. case 1: return SIM_READY;
  313. default: return SIM_ERROR;
  314. }
  315. }
  316. return SIM_ERROR;
  317. }
  318. RegStatus getRegistrationStatus() {
  319. sendAT(GF("+CREG?"));
  320. if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
  321. return REG_UNKNOWN;
  322. }
  323. streamSkipUntil(','); // Skip format (0)
  324. int status = streamReadUntil('\n').toInt();
  325. waitResponse();
  326. return (RegStatus)status;
  327. }
  328. String getOperator() {
  329. sendAT(GF("+COPS?"));
  330. if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
  331. return "";
  332. }
  333. streamSkipUntil('"'); // Skip mode and format
  334. String res = streamReadUntil('"');
  335. waitResponse();
  336. return res;
  337. }
  338. bool waitForNetwork(unsigned long timeout = 60000L) {
  339. unsigned long start = millis();
  340. bool is_registered = false;
  341. while (millis() - start < timeout && is_registered == false){
  342. RegStatus s = getRegistrationStatus();
  343. if (s == REG_OK_HOME || s == REG_OK_ROAMING) {
  344. is_registered = true;
  345. }
  346. delay(1000);
  347. }
  348. return is_registered;
  349. }
  350. /*
  351. * GPRS functions
  352. */
  353. bool gprsConnect(const char* apn, const char* user, const char* pwd) {
  354. gprsDisconnect();
  355. sendAT(GF("+SAPBR=3,1,\"Contype\",\"GPRS\""));
  356. waitResponse();
  357. sendAT(GF("+SAPBR=3,1,\"APN\",\""), apn, '"');
  358. waitResponse();
  359. if (!strcmp(user, "")) {
  360. sendAT(GF("+SAPBR=3,1,\"USER\",\""), user, '"');
  361. waitResponse();
  362. }
  363. if (!strcmp(pwd, "")) {
  364. sendAT(GF("+SAPBR=3,1,\"PWD\",\""), pwd, '"');
  365. waitResponse();
  366. }
  367. sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
  368. waitResponse();
  369. sendAT(GF("+CGACT=1,1"));
  370. waitResponse(60000L);
  371. // Open a GPRS context
  372. sendAT(GF("+SAPBR=1,1"));
  373. waitResponse(85000L);
  374. // Query the GPRS context
  375. sendAT(GF("+SAPBR=2,1"));
  376. if (waitResponse(30000L) != 1)
  377. return false;
  378. sendAT(GF("+CGATT=1"));
  379. if (waitResponse(60000L) != 1)
  380. return false;
  381. // TODO: wait AT+CGATT?
  382. sendAT(GF("+CIPMUX=1"));
  383. if (waitResponse() != 1) {
  384. return false;
  385. }
  386. sendAT(GF("+CIPQSEND=1"));
  387. if (waitResponse() != 1) {
  388. return false;
  389. }
  390. sendAT(GF("+CIPRXGET=1"));
  391. if (waitResponse() != 1) {
  392. return false;
  393. }
  394. sendAT(GF("+CSTT=\""), apn, GF("\",\""), user, GF("\",\""), pwd, GF("\""));
  395. if (waitResponse(60000L) != 1) {
  396. return false;
  397. }
  398. sendAT(GF("+CIICR"));
  399. if (waitResponse(60000L) != 1) {
  400. return false;
  401. }
  402. sendAT(GF("+CIFSR;E0"));
  403. String data;
  404. if (waitResponse(10000L, data) != 1) {
  405. data.replace(GSM_NL, "");
  406. return false;
  407. }
  408. sendAT(GF("+CDNSCFG=\"8.8.8.8\",\"8.8.4.4\""));
  409. if (waitResponse() != 1) {
  410. return false;
  411. }
  412. return true;
  413. }
  414. bool gprsDisconnect() {
  415. sendAT(GF("+CIPSHUT"));
  416. return waitResponse(60000L) == 1;
  417. }
  418. /*
  419. * Phone Call functions
  420. */
  421. /*
  422. * Messaging functions
  423. */
  424. void sendUSSD() {
  425. }
  426. void sendSMS() {
  427. }
  428. /*
  429. * Location functions
  430. */
  431. void getLocation() {
  432. }
  433. /*
  434. * Battery functions
  435. */
  436. // Use: float vBatt = modem.getBattVoltage() / 1000.0;
  437. uint16_t getBattVoltage() {
  438. sendAT(GF("+CBC"));
  439. if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
  440. return 0;
  441. }
  442. streamSkipUntil(','); // Skip
  443. streamSkipUntil(','); // Skip
  444. uint16_t res = streamReadUntil(',').toInt();
  445. waitResponse();
  446. return res;
  447. }
  448. private:
  449. int modemConnect(const char* host, uint16_t port, uint8_t mux) {
  450. sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
  451. int rsp = waitResponse(75000L,
  452. GF("CONNECT OK" GSM_NL),
  453. GF("CONNECT FAIL" GSM_NL),
  454. GF("ALREADY CONNECT" GSM_NL));
  455. return (1 == rsp);
  456. }
  457. int modemSend(const void* buff, size_t len, uint8_t mux) {
  458. sendAT(GF("+CIPSEND="), mux, ',', len);
  459. if (waitResponse(GF(">")) != 1) {
  460. return -1;
  461. }
  462. stream.write((uint8_t*)buff, len);
  463. stream.flush();
  464. if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) {
  465. return -1;
  466. }
  467. streamSkipUntil(','); // Skip mux
  468. return streamReadUntil('\n').toInt();
  469. }
  470. size_t modemRead(size_t size, uint8_t mux) {
  471. #ifdef TINY_GSM_USE_HEX
  472. sendAT(GF("+CIPRXGET=3,"), mux, ',', size);
  473. if (waitResponse(GF("+CIPRXGET:")) != 1) {
  474. return 0;
  475. }
  476. #else
  477. sendAT(GF("+CIPRXGET=2,"), mux, ',', size);
  478. if (waitResponse(GF("+CIPRXGET:")) != 1) {
  479. return 0;
  480. }
  481. #endif
  482. streamSkipUntil(','); // Skip mode 2/3
  483. streamSkipUntil(','); // Skip mux
  484. size_t len = streamReadUntil(',').toInt();
  485. sockets[mux]->sock_available = streamReadUntil('\n').toInt();
  486. for (size_t i=0; i<len; i++) {
  487. #ifdef TINY_GSM_USE_HEX
  488. while (stream.available() < 2) {}
  489. char buf[4] = { 0, };
  490. buf[0] = streamRead();
  491. buf[1] = streamRead();
  492. char c = strtol(buf, NULL, 16);
  493. #else
  494. while (!stream.available()) {}
  495. char c = streamRead(); // DBG(c);
  496. #endif
  497. sockets[mux]->rx.put(c);
  498. }
  499. waitResponse();
  500. return len;
  501. }
  502. size_t modemGetAvailable(uint8_t mux) {
  503. sendAT(GF("+CIPRXGET=4,"), mux);
  504. size_t result = 0;
  505. if (waitResponse(GF("+CIPRXGET:")) == 1) {
  506. streamSkipUntil(','); // Skip mode 4
  507. streamSkipUntil(','); // Skip mux
  508. result = streamReadUntil('\n').toInt();
  509. waitResponse();
  510. }
  511. if (!result) {
  512. sockets[mux]->sock_connected = modemGetConnected(mux);
  513. }
  514. return result;
  515. }
  516. bool modemGetConnected(uint8_t mux) {
  517. sendAT(GF("+CIPSTATUS="), mux);
  518. int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
  519. waitResponse();
  520. return 1 == res;
  521. }
  522. /* Utilities */
  523. template<typename T>
  524. void streamWrite(T last) {
  525. stream.print(last);
  526. }
  527. template<typename T, typename... Args>
  528. void streamWrite(T head, Args... tail) {
  529. stream.print(head);
  530. streamWrite(tail...);
  531. }
  532. int streamRead() { return stream.read(); }
  533. String streamReadUntil(char c) {
  534. String return_string = stream.readStringUntil(c);
  535. return_string.trim();
  536. if (String(c) == GSM_NL || String(c) == "\n"){
  537. DBG(return_string, c, " ");
  538. } else DBG(return_string, c);
  539. return return_string;
  540. }
  541. bool streamSkipUntil(char c) { //TODO: timeout
  542. String skipped = stream.readStringUntil(c);
  543. skipped.trim();
  544. if (skipped.length()) {
  545. if (String(c) == GSM_NL || String(c) == "\n"){
  546. DBG(skipped, c, " ");
  547. } else DBG(skipped, c);
  548. return true;
  549. } else return false;
  550. }
  551. template<typename... Args>
  552. void sendAT(Args... cmd) {
  553. streamWrite("AT", cmd..., GSM_NL);
  554. stream.flush();
  555. TINY_GSM_YIELD();
  556. DBG(GSM_NL, ">>> AT:", cmd...);
  557. }
  558. // TODO: Optimize this!
  559. uint8_t waitResponse(uint32_t timeout, String& data,
  560. GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  561. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  562. {
  563. /*String r1s(r1); r1s.trim();
  564. String r2s(r2); r2s.trim();
  565. String r3s(r3); r3s.trim();
  566. String r4s(r4); r4s.trim();
  567. String r5s(r5); r5s.trim();
  568. DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
  569. data.reserve(64);
  570. bool gotData = false;
  571. int mux = -1;
  572. int index = 0;
  573. unsigned long startMillis = millis();
  574. do {
  575. TINY_GSM_YIELD();
  576. while (stream.available() > 0) {
  577. int a = streamRead();
  578. if (a <= 0) continue; // Skip 0x00 bytes, just in case
  579. data += (char)a;
  580. if (r1 && data.endsWith(r1)) {
  581. index = 1;
  582. goto finish;
  583. } else if (r2 && data.endsWith(r2)) {
  584. index = 2;
  585. goto finish;
  586. } else if (r3 && data.endsWith(r3)) {
  587. index = 3;
  588. goto finish;
  589. } else if (r4 && data.endsWith(r4)) {
  590. index = 4;
  591. goto finish;
  592. } else if (r5 && data.endsWith(r5)) {
  593. index = 5;
  594. goto finish;
  595. } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) {
  596. String mode = streamReadUntil(',');
  597. if (mode.toInt() == 1) {
  598. mux = streamReadUntil('\n').toInt();
  599. gotData = true;
  600. data = "";
  601. } else {
  602. data += mode;
  603. }
  604. } else if (data.endsWith(GF("CLOSED" GSM_NL))) {
  605. int nl = data.lastIndexOf(GSM_NL, data.length()-8);
  606. int coma = data.indexOf(',', nl+2);
  607. mux = data.substring(nl+2, coma).toInt();
  608. if (mux) {
  609. sockets[mux]->sock_connected = false;
  610. data = "";
  611. }
  612. }
  613. }
  614. } while (millis() - startMillis < timeout);
  615. finish:
  616. if (!index) {
  617. data.trim();
  618. if (data.length()) {
  619. DBG("### Unhandled:", data);
  620. }
  621. data = "";
  622. }
  623. else {
  624. data.trim();
  625. data.replace(GSM_NL GSM_NL, GSM_NL);
  626. data.replace(GSM_NL, GSM_NL " ");
  627. if (data.length()) {
  628. DBG(GSM_NL, "<<< ", data);
  629. }
  630. data = "";
  631. }
  632. if (gotData) {
  633. sockets[mux]->sock_available = modemGetAvailable(mux);
  634. }
  635. return index;
  636. }
  637. uint8_t waitResponse(uint32_t timeout,
  638. GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  639. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  640. {
  641. String data;
  642. return waitResponse(timeout, data, r1, r2, r3, r4, r5);
  643. }
  644. uint8_t waitResponse(GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  645. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  646. {
  647. return waitResponse(1000, r1, r2, r3, r4, r5);
  648. }
  649. private:
  650. Stream& stream;
  651. GsmClient* sockets[5];
  652. };
  653. typedef TinyGsm::GsmClient TinyGsmClient;
  654. #endif