Send a string as a value
-
Hi,
is there a way to send a string as the value of a message:
I would like to do that:
String test = String(sRead1) + "-" + String(sRead2)+ "-" + String(sRead3); // result: "20.5-1011-2.5" gw.send(msg1.set(test));I did not find a way to get "test" transformed (char, string,...) to get it sent. But interestingly this works:
gw.send(msg1.set("20.5-1011-2.5"));so I think there should be a way to get "test" transformed in a format which can be sent.
Anyone any ideas?
Many Thanks!
-
do you have an example? Many Thanks!
-
Hi,
is there a way to send a string as the value of a message:
I would like to do that:
String test = String(sRead1) + "-" + String(sRead2)+ "-" + String(sRead3); // result: "20.5-1011-2.5" gw.send(msg1.set(test));I did not find a way to get "test" transformed (char, string,...) to get it sent. But interestingly this works:
gw.send(msg1.set("20.5-1011-2.5"));so I think there should be a way to get "test" transformed in a format which can be sent.
Anyone any ideas?
Many Thanks!
@Meister_Petz you can always do something like this:
char Output[13]; String OutStr = String(sRead1) + "-" + String(sRead2) + "-" + String(sRead3); OutStr.toCharArray(Output,13); gw.send(msg.set(Output));but as @hek pointed out, try avoiding it where possible...
-
@Meister_Petz you can always do something like this:
char Output[13]; String OutStr = String(sRead1) + "-" + String(sRead2) + "-" + String(sRead3); OutStr.toCharArray(Output,13); gw.send(msg.set(Output));but as @hek pointed out, try avoiding it where possible...
@tekka
Many Thanks!
I'd like to avoid it, but I'm not a developer and so my programing skills are limited ;-) -
@Meister_Petz, you could simply write :
String OutStr = String(sRead1) + "-" + String(sRead2) + "-" + String(sRead3); gw.send(msg.set(OutStr.c_str())); -
Or just use the character arrays with snprintf
-
many thanks! I know it's easy for you - unfortunately not for me. That's why I'm here. ;-)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login