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.

783 lines
18 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. /**
  2. * @file TinyGsmClientBG96.h
  3. * @author Volodymyr Shymanskyy
  4. * @license LGPL-3.0
  5. * @copyright Copyright (c) 2016 Volodymyr Shymanskyy
  6. * @date Apr 2018
  7. */
  8. #ifndef TinyGsmClientBG96_h
  9. #define TinyGsmClientBG96_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 12
  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 TinyGsmBG96 : public TinyGsmModem
  34. {
  35. public:
  36. class GsmClient : public Client
  37. {
  38. friend class TinyGsmBG96;
  39. typedef TinyGsmFifo<uint8_t, TINY_GSM_RX_BUFFER> RxFifo;
  40. public:
  41. GsmClient() {}
  42. GsmClient(TinyGsmBG96& modem, uint8_t mux = 1) {
  43. init(&modem, mux);
  44. }
  45. bool init(TinyGsmBG96* modem, uint8_t mux = 1) {
  46. this->at = modem;
  47. this->mux = mux;
  48. sock_available = 0;
  49. sock_connected = false;
  50. got_data = false;
  51. at->sockets[mux] = this;
  52. return true;
  53. }
  54. public:
  55. virtual int connect(const char *host, uint16_t port) {
  56. stop();
  57. TINY_GSM_YIELD();
  58. rx.clear();
  59. sock_connected = at->modemConnect(host, port, mux);
  60. return sock_connected;
  61. }
  62. virtual int connect(IPAddress ip, uint16_t port) {
  63. String host; host.reserve(16);
  64. host += ip[0];
  65. host += ".";
  66. host += ip[1];
  67. host += ".";
  68. host += ip[2];
  69. host += ".";
  70. host += ip[3];
  71. return connect(host.c_str(), port);
  72. }
  73. virtual void stop() {
  74. TINY_GSM_YIELD();
  75. at->sendAT(GF("+QICLOSE="), mux);
  76. sock_connected = false;
  77. at->waitResponse();
  78. rx.clear();
  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 size_t write(const char *str) {
  89. if (str == NULL) return 0;
  90. return write((const uint8_t *)str, strlen(str));
  91. }
  92. virtual int available() {
  93. TINY_GSM_YIELD();
  94. if (!rx.size()) {
  95. at->maintain();
  96. }
  97. return rx.size() + sock_available;
  98. }
  99. virtual int read(uint8_t *buf, size_t size) {
  100. TINY_GSM_YIELD();
  101. at->maintain();
  102. size_t cnt = 0;
  103. while (cnt < size) {
  104. size_t chunk = TinyGsmMin(size-cnt, rx.size());
  105. if (chunk > 0) {
  106. rx.get(buf, chunk);
  107. buf += chunk;
  108. cnt += chunk;
  109. continue;
  110. }
  111. // TODO: Read directly into user buffer?
  112. at->maintain();
  113. if (sock_available > 0) {
  114. sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
  115. } else {
  116. break;
  117. }
  118. }
  119. return cnt;
  120. }
  121. virtual int read() {
  122. uint8_t c;
  123. if (read(&c, 1) == 1) {
  124. return c;
  125. }
  126. return -1;
  127. }
  128. virtual int peek() { return -1; } //TODO
  129. virtual void flush() { at->stream.flush(); }
  130. virtual uint8_t connected() {
  131. if (available()) {
  132. return true;
  133. }
  134. return sock_connected;
  135. }
  136. virtual operator bool() { return connected(); }
  137. /*
  138. * Extended API
  139. */
  140. String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
  141. private:
  142. TinyGsmBG96* at;
  143. uint8_t mux;
  144. uint16_t sock_available;
  145. bool sock_connected;
  146. bool got_data;
  147. RxFifo rx;
  148. };
  149. // class GsmClientSecure : public GsmClient
  150. // {
  151. // public:
  152. // GsmClientSecure() {}
  153. //
  154. // GsmClientSecure(TinyGsmBG96& modem, uint8_t mux = 1)
  155. // : GsmClient(modem, mux)
  156. // {}
  157. //
  158. // public:
  159. // virtual int connect(const char *host, uint16_t port) {
  160. // stop();
  161. // TINY_GSM_YIELD();
  162. // rx.clear();
  163. // sock_connected = at->modemConnect(host, port, mux, true);
  164. // return sock_connected;
  165. // }
  166. // };
  167. public:
  168. TinyGsmBG96(Stream& stream)
  169. : TinyGsmModem(stream), stream(stream)
  170. {
  171. memset(sockets, 0, sizeof(sockets));
  172. }
  173. /*
  174. * Basic functions
  175. */
  176. bool init(const char* pin = NULL) {
  177. if (!testAT()) {
  178. return false;
  179. }
  180. sendAT(GF("&FZE0")); // Factory + Reset + Echo Off
  181. if (waitResponse() != 1) {
  182. return false;
  183. }
  184. getSimStatus();
  185. return true;
  186. }
  187. String getModemName() {
  188. return "Quectel BG96";
  189. }
  190. void setBaud(unsigned long baud) {
  191. sendAT(GF("+IPR="), baud);
  192. }
  193. bool testAT(unsigned long timeout = 10000L) {
  194. for (unsigned long start = millis(); millis() - start < timeout; ) {
  195. sendAT(GF(""));
  196. if (waitResponse(200) == 1) {
  197. delay(100);
  198. return true;
  199. }
  200. delay(100);
  201. }
  202. return false;
  203. }
  204. void maintain() {
  205. for (int mux = 0; mux < TINY_GSM_MUX_COUNT; mux++) {
  206. GsmClient* sock = sockets[mux];
  207. if (sock && sock->got_data) {
  208. sock->got_data = false;
  209. sock->sock_available = modemGetAvailable(mux);
  210. }
  211. }
  212. while (stream.available()) {
  213. waitResponse(10, NULL, NULL);
  214. }
  215. }
  216. bool factoryDefault() {
  217. sendAT(GF("&FZE0&W")); // Factory + Reset + Echo Off + Write
  218. waitResponse();
  219. sendAT(GF("+IPR=0")); // Auto-baud
  220. waitResponse();
  221. sendAT(GF("&W")); // Write configuration
  222. return waitResponse() == 1;
  223. }
  224. String getModemInfo() {
  225. sendAT(GF("I"));
  226. String res;
  227. if (waitResponse(1000L, res) != 1) {
  228. return "";
  229. }
  230. res.replace(GSM_NL "OK" GSM_NL, "");
  231. res.replace(GSM_NL, " ");
  232. res.trim();
  233. return res;
  234. }
  235. bool hasSSL() {
  236. return false; // TODO: For now
  237. }
  238. bool hasWifi() {
  239. return false;
  240. }
  241. bool hasGPRS() {
  242. return true;
  243. }
  244. /*
  245. * Power functions
  246. */
  247. bool restart() {
  248. if (!testAT()) {
  249. return false;
  250. }
  251. sendAT(GF("+CFUN=1,1"));
  252. if (waitResponse(60000L, GF("POWERED DOWN")) != 1) {
  253. return false;
  254. }
  255. delay(3000);
  256. return init();
  257. }
  258. bool poweroff() {
  259. sendAT(GF("+QPOWD"));
  260. return waitResponse(GF("POWERED DOWN")) == 1; // TODO
  261. }
  262. bool radioOff() {
  263. sendAT(GF("+CFUN=0"));
  264. if (waitResponse(10000L) != 1) {
  265. return false;
  266. }
  267. delay(3000);
  268. return true;
  269. }
  270. /*
  271. * SIM card functions
  272. */
  273. bool simUnlock(const char *pin) {
  274. sendAT(GF("+CPIN=\""), pin, GF("\""));
  275. return waitResponse() == 1;
  276. }
  277. String getSimCCID() {
  278. sendAT(GF("+ICCID"));
  279. if (waitResponse(GF(GSM_NL "+ICCID:")) != 1) {
  280. return "";
  281. }
  282. String res = stream.readStringUntil('\n');
  283. waitResponse();
  284. res.trim();
  285. return res;
  286. }
  287. String getIMEI() {
  288. sendAT(GF("+GSN"));
  289. if (waitResponse(GF(GSM_NL)) != 1) {
  290. return "";
  291. }
  292. String res = stream.readStringUntil('\n');
  293. waitResponse();
  294. res.trim();
  295. return res;
  296. }
  297. SimStatus getSimStatus(unsigned long timeout = 10000L) {
  298. for (unsigned long start = millis(); millis() - start < timeout; ) {
  299. sendAT(GF("+CPIN?"));
  300. if (waitResponse(GF(GSM_NL "+CPIN:")) != 1) {
  301. delay(1000);
  302. continue;
  303. }
  304. int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
  305. waitResponse();
  306. switch (status) {
  307. case 2:
  308. case 3: return SIM_LOCKED;
  309. case 1: return SIM_READY;
  310. default: return SIM_ERROR;
  311. }
  312. }
  313. return SIM_ERROR;
  314. }
  315. RegStatus getRegistrationStatus() {
  316. sendAT(GF("+CREG?"));
  317. if (waitResponse(GF(GSM_NL "+CREG:")) != 1) {
  318. return REG_UNKNOWN;
  319. }
  320. streamSkipUntil(','); // Skip format (0)
  321. int status = stream.readStringUntil('\n').toInt();
  322. waitResponse();
  323. return (RegStatus)status;
  324. }
  325. String getOperator() {
  326. sendAT(GF("+COPS?"));
  327. if (waitResponse(GF(GSM_NL "+COPS:")) != 1) {
  328. return "";
  329. }
  330. streamSkipUntil('"'); // Skip mode and format
  331. String res = stream.readStringUntil('"');
  332. waitResponse();
  333. return res;
  334. }
  335. /*
  336. * Generic network functions
  337. */
  338. int getSignalQuality() {
  339. sendAT(GF("+CSQ"));
  340. if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) {
  341. return 99;
  342. }
  343. int res = stream.readStringUntil(',').toInt();
  344. waitResponse();
  345. return res;
  346. }
  347. bool isNetworkConnected() {
  348. RegStatus s = getRegistrationStatus();
  349. return (s == REG_OK_HOME || s == REG_OK_ROAMING);
  350. }
  351. /*
  352. * GPRS functions
  353. */
  354. bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
  355. gprsDisconnect();
  356. //Configure the TCPIP Context
  357. sendAT(GF("+QICSGP=1,1,\""), apn, GF("\",\""), user, GF("\",\""), pwd, GF("\""));
  358. if (waitResponse() != 1) {
  359. return false;
  360. }
  361. //Activate GPRS/CSD Context
  362. sendAT(GF("+QIACT=1"));
  363. if (waitResponse(150000L) != 1) {
  364. return false;
  365. }
  366. //Attach to Packet Domain service - is this necessary?
  367. sendAT(GF("+CGATT=1"));
  368. if (waitResponse(60000L) != 1) {
  369. return false;
  370. }
  371. return true;
  372. }
  373. bool gprsDisconnect() {
  374. sendAT(GF("+QIDEACT=1")); // Deactivate the bearer context
  375. if (waitResponse(40000L) != 1)
  376. return false;
  377. return true;
  378. }
  379. bool isGprsConnected() {
  380. sendAT(GF("+CGATT?"));
  381. if (waitResponse(GF(GSM_NL "+CGATT:")) != 1) {
  382. return false;
  383. }
  384. int res = stream.readStringUntil('\n').toInt();
  385. waitResponse();
  386. if (res != 1)
  387. return false;
  388. return localIP() != 0;
  389. }
  390. /*
  391. * IP Address functions
  392. */
  393. String getLocalIP() {
  394. sendAT(GF("+QILOCIP"));
  395. stream.readStringUntil('\n');
  396. String res = stream.readStringUntil('\n');
  397. if (waitResponse() != 1) {
  398. return "";
  399. }
  400. return res;
  401. }
  402. /*
  403. * Messaging functions
  404. */
  405. String sendUSSD(const String& code) TINY_GSM_ATTR_NOT_IMPLEMENTED;
  406. bool sendSMS(const String& number, const String& text) {
  407. sendAT(GF("+CMGF=1"));
  408. waitResponse();
  409. //Set GSM 7 bit default alphabet (3GPP TS 23.038)
  410. sendAT(GF("+CSCS=\"GSM\""));
  411. waitResponse();
  412. sendAT(GF("+CMGS=\""), number, GF("\""));
  413. if (waitResponse(GF(">")) != 1) {
  414. return false;
  415. }
  416. stream.print(text);
  417. stream.write((char)0x1A);
  418. stream.flush();
  419. return waitResponse(60000L) == 1;
  420. }
  421. bool sendSMS_UTF16(const String& number, const void* text, size_t len) {
  422. sendAT(GF("+CMGF=1"));
  423. waitResponse();
  424. sendAT(GF("+CSCS=\"HEX\""));
  425. waitResponse();
  426. sendAT(GF("+CSMP=17,167,0,8"));
  427. waitResponse();
  428. sendAT(GF("+CMGS=\""), number, GF("\""));
  429. if (waitResponse(GF(">")) != 1) {
  430. return false;
  431. }
  432. uint16_t* t = (uint16_t*)text;
  433. for (size_t i=0; i<len; i++) {
  434. uint8_t c = t[i] >> 8;
  435. if (c < 0x10) { stream.print('0'); }
  436. stream.print(c, HEX);
  437. c = t[i] & 0xFF;
  438. if (c < 0x10) { stream.print('0'); }
  439. stream.print(c, HEX);
  440. }
  441. stream.write((char)0x1A);
  442. stream.flush();
  443. return waitResponse(60000L) == 1;
  444. }
  445. /*
  446. * Location functions
  447. */
  448. String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE;
  449. /*
  450. * Battery functions
  451. */
  452. // Use: float vBatt = modem.getBattVoltage() / 1000.0;
  453. uint16_t getBattVoltage() {
  454. sendAT(GF("+CBC"));
  455. if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
  456. return 0;
  457. }
  458. streamSkipUntil(','); // Skip
  459. streamSkipUntil(','); // Skip
  460. uint16_t res = stream.readStringUntil(',').toInt();
  461. waitResponse();
  462. return res;
  463. }
  464. int getBattPercent() {
  465. sendAT(GF("+CBC"));
  466. if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
  467. return false;
  468. }
  469. stream.readStringUntil(',');
  470. int res = stream.readStringUntil(',').toInt();
  471. waitResponse();
  472. return res;
  473. }
  474. int getBattPercent() TINY_GSM_ATTR_NOT_IMPLEMENTED;
  475. /*
  476. * Client related functions
  477. */
  478. protected:
  479. bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool ssl = false) {
  480. int rsp;
  481. // <PDPcontextID>(1-16), <connectID>(0-11),"TCP/UDP/TCP LISTENER/UDP SERVICE",
  482. // "<IP_address>/<domain_name>",<remote_port>,<local_port>,<access_mode>(0-2 0=buffer)
  483. sendAT(GF("+QIOPEN=1,"), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port, GF(",0,0"));
  484. rsp = waitResponse();
  485. if (waitResponse(20000L, GF(GSM_NL "+QIOPEN:")) != 1) {
  486. return false;
  487. }
  488. if (stream.readStringUntil(',').toInt() != mux) {
  489. return false;
  490. }
  491. // Read status
  492. rsp = stream.readStringUntil('\n').toInt();
  493. return (0 == rsp);
  494. }
  495. int modemSend(const void* buff, size_t len, uint8_t mux) {
  496. sendAT(GF("+QISEND="), mux, ',', len);
  497. if (waitResponse(GF(">")) != 1) {
  498. return 0;
  499. }
  500. stream.write((uint8_t*)buff, len);
  501. stream.flush();
  502. if (waitResponse(GF(GSM_NL "SEND OK")) != 1) {
  503. return 0;
  504. }
  505. // TODO: Wait for ACK? AT+QISEND=id,0
  506. return len;
  507. }
  508. size_t modemRead(size_t size, uint8_t mux) {
  509. sendAT(GF("+QIRD="), mux, ',', size);
  510. if (waitResponse(GF("+QIRD:")) != 1) {
  511. return 0;
  512. }
  513. size_t len = stream.readStringUntil('\n').toInt();
  514. for (size_t i=0; i<len; i++) {
  515. while (!stream.available()) { TINY_GSM_YIELD(); }
  516. char c = stream.read();
  517. sockets[mux]->rx.put(c);
  518. }
  519. waitResponse();
  520. DBG("### READ:", mux, ",", len);
  521. return len;
  522. }
  523. size_t modemGetAvailable(uint8_t mux) {
  524. sendAT(GF("+QIRD="), mux, GF(",0"));
  525. size_t result = 0;
  526. if (waitResponse(GF("+QIRD:")) == 1) {
  527. streamSkipUntil(','); // Skip total received
  528. streamSkipUntil(','); // Skip have read
  529. result = stream.readStringUntil('\n').toInt();
  530. DBG("### STILL:", mux, "has", result);
  531. waitResponse();
  532. }
  533. if (!result) {
  534. sockets[mux]->sock_connected = modemGetConnected(mux);
  535. }
  536. return result;
  537. }
  538. bool modemGetConnected(uint8_t mux) {
  539. sendAT(GF("+QISTATE=1,"), mux);
  540. //+QISTATE: 0,"TCP","151.139.237.11",80,5087,4,1,0,0,"uart1"
  541. if (waitResponse(GF("+QISTATE:")))
  542. return false;
  543. streamSkipUntil(','); // Skip mux
  544. streamSkipUntil(','); // Skip socket type
  545. streamSkipUntil(','); // Skip remote ip
  546. streamSkipUntil(','); // Skip remote port
  547. streamSkipUntil(','); // Skip local port
  548. int res = stream.readStringUntil(',').toInt(); // socket state
  549. waitResponse();
  550. // 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing
  551. return 2 == res;
  552. }
  553. public:
  554. /*
  555. Utilities
  556. */
  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. bool streamSkipUntil(char c, const unsigned long timeout = 1000L) {
  567. unsigned long startMillis = millis();
  568. while (millis() - startMillis < timeout) {
  569. while (millis() - startMillis < timeout && !stream.available()) {
  570. TINY_GSM_YIELD();
  571. }
  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 index = 0;
  597. unsigned long startMillis = millis();
  598. do {
  599. TINY_GSM_YIELD();
  600. while (stream.available() > 0) {
  601. int a = stream.read();
  602. if (a <= 0) continue; // Skip 0x00 bytes, just in case
  603. data += (char)a;
  604. if (r1 && data.endsWith(r1)) {
  605. index = 1;
  606. goto finish;
  607. } else if (r2 && data.endsWith(r2)) {
  608. index = 2;
  609. goto finish;
  610. } else if (r3 && data.endsWith(r3)) {
  611. index = 3;
  612. goto finish;
  613. } else if (r4 && data.endsWith(r4)) {
  614. index = 4;
  615. goto finish;
  616. } else if (r5 && data.endsWith(r5)) {
  617. index = 5;
  618. goto finish;
  619. } else if (data.endsWith(GF(GSM_NL "+QIURC:"))) {
  620. stream.readStringUntil('\"');
  621. String urc = stream.readStringUntil('\"');
  622. stream.readStringUntil(',');
  623. if (urc == "recv") {
  624. int mux = stream.readStringUntil('\n').toInt();
  625. DBG("### URC RECV:", mux);
  626. if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
  627. sockets[mux]->got_data = true;
  628. }
  629. } else if (urc == "closed") {
  630. int mux = stream.readStringUntil('\n').toInt();
  631. DBG("### URC CLOSE:", mux);
  632. if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
  633. sockets[mux]->sock_connected = false;
  634. }
  635. } else {
  636. stream.readStringUntil('\n');
  637. }
  638. data = "";
  639. }
  640. }
  641. } while (millis() - startMillis < timeout);
  642. finish:
  643. if (!index) {
  644. data.trim();
  645. if (data.length()) {
  646. DBG("### Unhandled:", data);
  647. }
  648. data = "";
  649. }
  650. DBG('<', index, '>');
  651. return index;
  652. }
  653. uint8_t waitResponse(uint32_t timeout,
  654. GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  655. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  656. {
  657. String data;
  658. return waitResponse(timeout, data, r1, r2, r3, r4, r5);
  659. }
  660. uint8_t waitResponse(GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
  661. GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
  662. {
  663. return waitResponse(1000, r1, r2, r3, r4, r5);
  664. }
  665. public:
  666. Stream& stream;
  667. protected:
  668. GsmClient* sockets[TINY_GSM_MUX_COUNT];
  669. };
  670. #endif