Open karlp opened 8 years ago
+1, or adding a String-type argument. char[] is very cumbersome to deal with :(
Well, normally you pass a Print implementation to the object that wants to do the printing - as shown in the JSON example. But there is nothing the print api to indicate the printing has completed, so the library would not know when the packet was ready to be sent. The alternative, to stream the writes to the network, is notsuitable as we need to know the complete length that is about to be written so we can construct the MQTT packet header properly. The JSON library you link to provides a a bespoke way of finding out the length, but there is not a generic solution.
Do you have a suggestion for what the publish api would look like to accommodate these things?
@knolleary Would just adding String
arguments be more feasible?
It might be, but I don't want to derail the original issue before we've explored it properly.
I'll open another issue, thanks.
I'd like to be able to pass in a Print implementation to publish, to avoid having to serialize json into a char* just to hand it to the pubsubclient, if at all possible, eg
https://github.com/bblanchon/ArduinoJson/wiki/Encoding-JSON#send-to-a-print-implementation