Changing handler data types

The way I have been using the handlers is with (const char *event, const char *data)

But would I be able to use this instead (const char *event, const String *data) so I can parse the data string.
I am using Particle.publish on the other particle to publish the variable as a string.

Thanks!

@nick13579

IMHO you are doing the right thing not using String object. There have been several threads talking about memory leakage/heap usage and using String object is typically the culprit when the original memory allocated needs to be extended. I started using String as the documentation examples are generally all String but then converted to using char arrays

Have a look at C std-lib functions strcmp() and strtok(). Using the strncmp() is even better to avoid array overruns.

3 Likes

Okay ya I’ll look those up. Thanks