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.

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