Hi everyone, I’m a Particle/C newb and am having a tough time accomplishing what I feel should be a very simple goal. I’d like to obtain my localIP (WiFi.localIP();) and publish it as an event to the cloud. I’m having difficulty because the syntax for Spark.publish() expects a char for the data argument, and IPAddress is not of that type: publish(const char *eventName, const char *eventData, Spark_Event_TypeDef eventType=PUBLIC)
Is there an easy way to convert an IPAddress to a String or char array? Here’s some basic code (of what obviously doesn’t work):
I tried a number of methods from reading documentation, as well as Google searches and whatnot, but nothing has worked thus far. My programming background is with Ruby, so my first exposure to C/C++ is proving to be challenging. Any insight would be greatly appreciated!
Thanks so much guys. @bko’s example did the trick. I searched the community posts and seemed to have missed the one mentioned here. I tried something similar, but with no luck. Haven’t tried the specific example in that post, but good to see some other options. Also, thanks for the heads up on the update, @mdma!