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.

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