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.

764 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. return waitResponse(60000L) == 1;
  417. }
  418. bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
  419. sendAT(GF("+CMGF=1"));
  420. waitResponse();
  421. sendAT(GF("+CSCS=\"HEX\""));
  422. waitResponse();
  423. sendAT(GF("+CSMP=17,167,0,8"));
  424. waitResponse();
  425. sendAT(GF("+CMGS=\""), number, GF("\""));
  426. if (waitResponse(GF(">")) != 1) {
  427. return false;
  428. }
  429. uint16_t* t = (uint16_t*)text;
  430. for (size_t i=0; i<len; i++) {
  431. uint8_t c = t[i] >> 8;
  432. if (c < 0x10) { stream.print('0'); }
  433. stream.print(c, HEX);
  434. c = t[i] & 0xFF;
  435. if (c < 0x10) { stream.print('0'); }
  436. stream.print(c, HEX);
  437. }
  438. stream.write((char)0x1A);
  439. return waitResponse(60000L) == 1;
  440. }
  441. /*
  442. * Location functions
  443. */
  444. String getGsmLocation() {
  445. sendAT(GF("+CIPGSMLOC=1,1"));
  446. if (waitResponse(GF(GSM_NL "+CIPGSMLOC:")) != 1) {
  447. return "";
  448. }
  449. String res = stream.readStringUntil('\n');
  450. waitResponse();
  451. res.trim();
  452. return res;
  453. }
  454. /*
  455. * Battery functions
  456. */
  457. // Use: float vBatt = modem.getBattVoltage() / 1000.0;
  458. uint16_t getBattVoltage() {
  459. sendAT(GF("+CBC"));
  460. if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
  461. return 0;
  462. }
  463. streamSkipUntil(','); // Skip
  464. streamSkipUntil(','); // Skip
  465. uint16_t res = stream.readStringUntil(',').toInt();
  466. waitResponse();
  467. return res;
  468. }
  469. int getBattPercent() {
  470. if (!autoBaud()) {
  471. return false;
  472. }
  473. sendAT(GF("+CBC"));
  474. if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
  475. return false;
  476. }
  477. stream.readStringUntil(',');
  478. int res = stream.readStringUntil(',').toInt();
  479. waitResponse();
  480. return res;
  481. }
  482. private:
  483. int modemConnect(const char* host, uint16_t port, uint8_t mux) {
  484. sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
  485. int rsp = waitResponse(75000L,
  486. GF("CONNECT OK" GSM_NL),
  487. GF("CONNECT FAIL" GSM_NL),
  488. GF("ALREADY CONNECT" GSM_NL));
  489. return (1 == rsp);
  490. }
  491. int modemSend(const void* buff, size_t len, uint8_t mux) {
  492. sendAT(GF("+CIPSEND="), mux, ',', len);
  493. if (waitResponse(GF(">")) != 1) {
  494. return -1;
  495. }
  496. stream.write((uint8_t*)buff, len);
  497. stream.flush();
  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