From 4e6620a9255b39694e3380e75e1cc4feb37253df Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Wed, 27 Sep 2017 23:37:07 +0300 Subject: [PATCH] Add TinyGsmDecodeHex*bit --- TinyGsmCommon.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/TinyGsmCommon.h b/TinyGsmCommon.h index 96207a9..234f47e 100644 --- a/TinyGsmCommon.h +++ b/TinyGsmCommon.h @@ -93,6 +93,7 @@ uint32_t TinyGsmAutoBaud(T& SerialAT) return 0; } +static inline IPAddress TinyGsmIpFromString(const String& strIP) { int Parts[4] = {0,0,0,0}; int Part = 0; @@ -108,4 +109,63 @@ IPAddress TinyGsmIpFromString(const String& strIP) { return IPAddress(Parts[0], Parts[1], Parts[2], Parts[3]); } +static inline +String TinyGsmDecodeHex7bit(String &instr) { + String result; + byte reminder = 0; + int bitstate = 7; + for (unsigned i=0; i> bitstate; + bitstate--; + if (bitstate == 0) { + char c = reminder; + result += c; + reminder = 0; + bitstate = 7; + } + } + return result; +} + +static inline +String TinyGsmDecodeHex8bit(String &instr) { + String result; + for (unsigned i=0; i