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.

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