Browse Source

Add TinyGsmIpFromString(str)

v_master
Volodymyr Shymanskyy 7 years ago
parent
commit
8b54123d39
6 changed files with 22 additions and 83 deletions
  1. +1
    -14
      TinyGsmClientA6.h
  2. +1
    -14
      TinyGsmClientESP8266.h
  3. +1
    -14
      TinyGsmClientM590.h
  4. +1
    -14
      TinyGsmClientSIM800.h
  5. +3
    -27
      TinyGsmClientXBee.h
  6. +15
    -0
      TinyGsmCommon.h

+ 1
- 14
TinyGsmClientA6.h View File

@ -397,20 +397,7 @@ public:
}
IPAddress localIP() {
String strIP = getLocalIP();
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
return res;
return TinyGsmIpFromString(getLocalIP());
}
/*


+ 1
- 14
TinyGsmClientESP8266.h View File

@ -292,20 +292,7 @@ public:
}
IPAddress localIP() {
String strIP = getLocalIP();
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
return res;
return TinyGsmIpFromString(getLocalIP());
}
private:


+ 1
- 14
TinyGsmClientM590.h View File

@ -413,20 +413,7 @@ public:
}
IPAddress localIP() {
String strIP = getLocalIP();
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
return res;
return TinyGsmIpFromString(getLocalIP());
}
/*


+ 1
- 14
TinyGsmClientSIM800.h View File

@ -545,20 +545,7 @@ public:
}
IPAddress localIP() {
String strIP = getLocalIP();
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
return res;
return TinyGsmIpFromString(getLocalIP());
}
/*


+ 3
- 27
TinyGsmClientXBee.h View File

@ -392,20 +392,7 @@ fail:
}
IPAddress localIP() {
String strIP = getLocalIP();
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
return res;
return TinyGsmIpFromString(getLocalIP());
}
/*
@ -459,19 +446,8 @@ private:
unsigned long startMillis = millis();
while (stream.available() < 8 && millis() - startMillis < 30000) {};
strIP = streamReadUntil('\r'); // read result
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
return modemConnect(res, port);
IPAddress ip = TinyGsmIpFromString(IPaddr);
return modemConnect(ip, port);
}
int modemConnect(IPAddress ip, uint16_t port, uint8_t mux = 0) {


+ 15
- 0
TinyGsmCommon.h View File

@ -93,4 +93,19 @@ uint32_t TinyGsmAutoBaud(T& SerialAT)
return 0;
}
IPAddress TinyGsmIpFromString(const String& strIP) {
int Parts[4] = {0,0,0,0};
int Part = 0;
for (uint8_t i=0; i<strIP.length(); i++) {
char c = strIP[i];
if (c == '.') {
Part++;
continue;
}
Parts[Part] *= 10;
Parts[Part] += c - '0';
}
return IPAddress(Parts[0], Parts[1], Parts[2], Parts[3]);
}
#endif

Loading…
Cancel
Save