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.

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