Fix localIP() on A6
This commit is contained in:
@@ -425,6 +425,8 @@ public:
|
|||||||
if (waitResponse(10000L, res) != 1) {
|
if (waitResponse(10000L, res) != 1) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
res.replace(GSM_NL "OK" GSM_NL, "");
|
||||||
|
res.replace(GSM_NL, "");
|
||||||
res.trim();
|
res.trim();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -97,16 +97,22 @@ uint32_t TinyGsmAutoBaud(T& SerialAT, uint32_t minimum = 9600, uint32_t maximum
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
IPAddress TinyGsmIpFromString(const String& strIP) {
|
IPAddress TinyGsmIpFromString(const String& strIP) {
|
||||||
int Parts[4] = {0,0,0,0};
|
int Parts[4] = {0, };
|
||||||
int Part = 0;
|
int Part = 0;
|
||||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||||
char c = strIP[i];
|
char c = strIP[i];
|
||||||
if (c == '.') {
|
if (c == '.') {
|
||||||
Part++;
|
Part++;
|
||||||
|
if (Part > 3) {
|
||||||
|
return IPAddress(0,0,0,0);
|
||||||
|
}
|
||||||
continue;
|
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]);
|
return IPAddress(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user