Hello Particle Community!
I’m trying to bind a device’s IP address to a variable in the cloud, but the resulting value ends up weird.
Here’s my code:
void setup()
{
char ipString[16];
server.begin();
IPAddress ip = WiFi.localIP();
sprintf(ipString, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
Particle.variable("ipAddress", ipString);
}
And here’s the data I get back from the API call:
{“cmd”:“VarReturn”,“name”:“ipAddress”,“result”:“�(\n\b”, …}
I’m not very acquainted with C so I’m not sure what’s going on. Any help would be greatly appreciated!
By the way, publishing ipString as an event works out fine and is completely readable but I want to be able to access the address as a variable instead of having to subscribe to an event stream.
Thanks =)