How do I publish my WiFi.localIP ?

50 views
Skip to first unread message

questuk

unread,
Dec 11, 2015, 6:04:35 PM12/11/15
to MQTT
Hi

I have tried googling and tried various things but cannot get this to compile.


 IPAddress ip  (192,168,1,125);   

 WiFi_client.publish (Topic_01, WiFi.localIP); 



It fails with the error:  no matching function for call to 'PubSubClient::publish(const char [15], <unresolved overloaded function type>)'

Any ideas what I am doing wrong ?


Regards

Gaz


Nicholas O'Leary

unread,
Dec 11, 2015, 6:15:34 PM12/11/15
to mq...@googlegroups.com
Hi Gaz,

this forum is for the MQTT protocol in general, not specific implementations - you're best pointing questions like this to whoever provides the implementation you're using.

Now, I put my other hat on... whilst you don't state it explicitly, it appears you're using my PubSubClient on Arduino. The problem is the publish() function you're using expects a char[] as the second parameter - you're passing in an IPAddress, and the client doesn't know what to do with it.
A quick google finds some examples of converting IPAddress to char[], for example: https://community.particle.io/t/network-localip-to-string-to-get-it-via-spark-variable/2581/4

Nick





--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

questuk

unread,
Dec 12, 2015, 5:25:09 AM12/12/15
to MQTT
Hi Nick,

Thanks for helping me, I got there in the end.

Regards


Gaz

Reply all
Reply to author
Forward
0 new messages