0

Linux and C/C++
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Linux and C/C++

by pbuelow on Mon Jul 22, 2019 10:56 am

I have searched, but couldn't find anything using C/C++/Linux as keywords, so apologies if this has been asked before. I have a Onion.io board I want to use to send data to IO. But, the project is already done with C++ for all of the sensors, so writing it from scratch in python would be complicated to say the least.

Has anyone done a Paho or Eclipse MQTT implementation to connect to IO? I gave it a couple of test runs, but each the tests locked my account for 30 minutes, but didn't provide errors or any other information for my debug effort. I have currently given up for the REST/HTTPS API which works well enough, but mosquittopp gave me some advantages that I would love to have (return messaging like throttling is one, the C++ interface is another). I suspect it's a TLS problem, but don't have a good way to diagnose it.

Thanks for any help.

pbuelow
 
Posts: 40
Joined: Sat Oct 04, 2014 2:43 pm

Re: Linux and C/C++

by brubell on Mon Jul 22, 2019 12:23 pm

pbuelow wrote:I have searched, but couldn't find anything using C/C++/Linux as keywords, so apologies if this has been asked before. I have a Onion.io board I want to use to send data to IO. But, the project is already done with C++ for all of the sensors, so writing it from scratch in python would be complicated to say the least.

Has anyone done a Paho or Eclipse MQTT implementation to connect to IO? I gave it a couple of test runs, but each the tests locked my account for 30 minutes, but didn't provide errors or any other information for my debug effort. I have currently given up for the REST/HTTPS API which works well enough, but mosquittopp gave me some advantages that I would love to have (return messaging like throttling is one, the C++ interface is another). I suspect it's a TLS problem, but don't have a good way to diagnose it.

Thanks for any help.


Adafruit IO Python's MQTT Client uses Paho MQTT Python.
https://github.com/adafruit/Adafruit_IO_Python

, but each the tests locked my account for 30 minutes, but didn't provide errors or any other information for my debug effort.

Did the monitor page display any errors? Were you able to connect at all (did the client show up underneath Connected)
https://io.adafruit.com/monitor

There's a possibility that there's a connection issue, try connecting via the insecure port to diagnose if it's a SSL/TLS issue:
https://io.adafruit.com/api/docs/mqtt.h ... on-details

brubell
 
Posts: 469
Joined: Fri Jul 17, 2015 10:33 pm

Re: Linux and C/C++

by pbuelow on Mon Jul 22, 2019 4:39 pm

Thank you, but Python would be a rewrite, otherwise this wouldn't be a problem.

I did not try insecure, didn't have time, but may go back. I had thought of it, but unfortunately only after. The monitor page showed me connect successfully, then disconnect later, but I never got an on_connect reply, and it was not using the name I supplied in the MQTT connect request, but rather a random string. There may not have been an error, but it wasn't telling me much and none of the callbacks were firing (on_error, on_connect, on_disconnect). the library prints didn't tell me much either, but I think I had an issue with those.

I'll try again over the weekend maybe, but am more interested in getting the new aquarium sensors up and running as fast as I can. Future improvements will come from that at some point.

pbuelow
 
Posts: 40
Joined: Sat Oct 04, 2014 2:43 pm

Re: Linux and C/C++

by abachman on Mon Jul 22, 2019 5:15 pm

Hi pbuelow,


There's not currently any feature of IO's MQTT broker that will lock accounts for 30 minutes. Is it possible your device was trying to authenticate continuously after failing? We also disconnect clients that attempt to subscribe or publish to invalid/inaccessible MQTT topics. IO is pretty specific about valid topics. You can find them on feed pages and described in the documentation here: [url]https://io.adafruit.com/api/docs/mqtt.html#mqtt-topics
[/url]
I've not used a C++ MQTT client library outside of Arduino, but do you have any code samples with just the MQTT connection setup demonstrated?


- adam b.

abachman
 
Posts: 319
Joined: Mon Feb 01, 2010 12:48 pm

Re: Linux and C/C++

by pbuelow on Mon Jul 22, 2019 9:21 pm

No, not right now. I can put it together quickly this weekend though and post it. I don't know that I was locked out, but submissions from my currently active client were no longer posting data for ~30 minutes. My first pass did have a retry, which is why I likely got "locked out" or whatever stopped my submissions from getting through.

I'll update this weekend.

pbuelow
 
Posts: 40
Joined: Sat Oct 04, 2014 2:43 pm

Please be positive and constructive with your questions and comments.