-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initializing argument 2 of 'bool MQTT::publish(const char*, const uint8_t*, unsigned int)' [-fpermissive] #33
Comments
maybe like following.
|
I'm still getting garbage even with that code. I looked at the Adafruit MQTT library, and they've got a publish declaration that allow for an int value, as in this: I incorporated some similar char coercing logic into my publish, and I'm indeed now able to publish data using this libraries char publish declaration. I just can't get it to work at all with the unit8_t declaration. |
Do you want to use char or int type in publish? If you want to use char, you can do like this. char publishData[120]; sprintf(publishData, "%d", 10); client.publish("rayterrill/feeds/moisture", publishData, strlen(publishData)); or If you want to use int type. of course you should get published data with int type. client.publish("rayterrill/feeds/moisture",(uint8_t *)&sensorValue, sizeof(sensorValue)); |
I tried it with: Still getting garbage data into Arduino IO. It might just be Arduino IO, not sure. I wanted to post as int, but char is also working. |
here is my test code. // photon side int sensorValue = 65; // character 'A' void loop() { if (client.isConnected()) client.loop(); delay(1000); client.publish("sensor/val/", (uint8_t *)&sensorValue, sizeof(sensorValue)); sensorValue++; } // mosquitto side mosquitto_sub -h [mosquitt_server_ipaddr] -t "sensor/val/" A B C D E F ... I check works well on my Photon/mosquitto command. Check your Arduino IO side source code. |
Hi @rayterrill , can you work on Photon with MQTT? I will close this issue. |
Sure. Go ahead and close. Thanks for the help! On Sun, Aug 28, 2016 at 9:41 PM -0700, "Hirotaka" notifications@github.com wrote: Hi @rayterrill , can you work on Photon with MQTT? I will close this issue. — |
Having a heck of a time trying to use the MQTT library in Particle with integer values coming off of a moisture sensor.
Veryfing code using this library in Particle Build fails with this error:
The text was updated successfully, but these errors were encountered: