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.

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