Browse Source

Fix localIP() on A6

v_master
Volodymyr Shymanskyy 7 years ago
parent
commit
de601105d4
2 changed files with 11 additions and 3 deletions
  1. +2
    -0
      TinyGsmClientA6.h
  2. +9
    -3
      TinyGsmCommon.h

+ 2
- 0
TinyGsmClientA6.h View File

@ -425,6 +425,8 @@ public:
if (waitResponse(10000L, res) != 1) {
return "";
}
res.replace(GSM_NL "OK" GSM_NL, "");
res.replace(GSM_NL, "");
res.trim();
return res;
}


+ 9
- 3
TinyGsmCommon.h View File

@ -97,16 +97,22 @@ uint32_t TinyGsmAutoBaud(T& SerialAT, uint32_t minimum = 9600, uint32_t maximum
static inline
IPAddress TinyGsmIpFromString(const String& strIP) {
int Parts[4] = {0,0,0,0};
int Parts[4] = {0, };
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
if (Part > 3) {
return IPAddress(0,0,0,0);
}
continue;
} else if (c >= '0' && c <= '9') {
Parts[Part] *= 10;
Parts[Part] += c - '0';
} else {
if (Part == 3) break;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
return IPAddress(Parts[0], Parts[1], Parts[2], Parts[3]);
}


Loading…
Cancel
Save