Pleas can you help me why I cant't use fromString? I have this error:
String ipaddr="192.168.1.63";
IPAddress ip;
ip.fromString(ipaddr.c_str());
error: 'ip' does not name a type
ip.fromString(ipaddr.c_str());
^
exit status 1
'ip' does not name a type
[Finished in 19.2s with exit code 1]
This code in the same program compiles correctly
IPAddress timeServer1(193, 204, 114, 232);
String ipAsString = timeServer1.toString();
Thanks
Check if your IPAddress.h looks like the one from Github, those changes have been committed on Jan 17th.
https://github.com/esp8266/Arduino/blob ... .h#L51-L52
I've isolated the problem and is a scope issue, but I don't understand the reason.
This code works:
#include <ESP8266WiFi.h>
IPAddress timeServer1(193, 204, 114, 232);
IPAddress ip;
String ipaddr="192.168.1.63";
String ipAsString = timeServer1.toString();
void setup() {
ip.fromString(ipaddr.c_str());
Serial.begin(115200);
Serial.println();
Serial.println(ip);
Serial.println(ipAsString);
}
void loop() {
delay(100);
}
And this gives error "'ip' does not name a type"
#include <ESP8266WiFi.h>
IPAddress timeServer1(193, 204, 114, 232);
IPAddress ip;
String ipaddr="192.168.1.63";
String ipAsString = timeServer1.toString();
ip.fromString(ipaddr.c_str());
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println(ip);
Serial.println(ipAsString);
}
void loop() {
delay(100);
}
I need "ip" and "ipAsString" as global for this reason I put them outside.