From 16b6c853fe337b882dec2c867afef149605c520b Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Tue, 12 Sep 2017 01:30:40 +0300 Subject: [PATCH] decodeHex16bit support for sendUSSD --- TinyGsmClientA6.h | 29 +++++++++++++++++++++--- TinyGsmClientSIM800.h | 51 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 8 deletions(-) diff --git a/TinyGsmClientA6.h b/TinyGsmClientA6.h index 69f04f9..9af5bb6 100644 --- a/TinyGsmClientA6.h +++ b/TinyGsmClientA6.h @@ -446,7 +446,9 @@ public: */ String sendUSSD(const String& code) { - sendAT(GF("+CSCS=HEX")); + sendAT(GF("+CMGF=1")); + waitResponse(); + sendAT(GF("+CSCS=\"HEX\"")); waitResponse(); sendAT(GF("+CUSD=1,\""), code, GF("\",15")); if (waitResponse(10000L) != 1) { @@ -462,6 +464,8 @@ public: if (dcs == 15) { return decodeHex7bit(hex); + } else if (dcs == 72) { + return decodeHex16bit(hex); } else { return hex; } @@ -539,8 +543,8 @@ private: return len; } - bool modemGetConnected(uint8_t mux) { //TODO mux? - sendAT(GF("+CIPSTATUS")); + bool modemGetConnected(uint8_t mux) { + sendAT(GF("+CIPSTATUS")); //TODO mux? int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\"")); waitResponse(); return 1 == res; @@ -571,6 +575,25 @@ private: return result; } + static String decodeHex16bit(String &instr) { + String result; + for (unsigned i=0; i