Skip to content
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

MQTT user/password authentication #168

Open
Paul-Simpson opened this issue Oct 27, 2021 · 11 comments
Open

MQTT user/password authentication #168

Paul-Simpson opened this issue Oct 27, 2021 · 11 comments

Comments

@Paul-Simpson
Copy link
Contributor

Paul-Simpson commented Oct 27, 2021

Hello,

Again, thank you for sharing this framework with the world.

I'm returning to my project and since updating to IDF4.2 and Moquitto 6.0.1, I'm having connection issues with MQTT.

I think it might be something to do with authentication, so I've tried adding a user/passwd but don't see anywhere to do that. Unless I'm missing something, Smooth does support that? I also looked to see if Smooth supports SSL/TLS encryption. Is ConnectToBrokerState.cpp the right place to look at? Btw, have you implemented your own MQTT protocol from the group up?

Many thanks again for any advice or help,

Paul

@Paul-Simpson
Copy link
Contributor Author

Paul-Simpson commented Oct 28, 2021

I've found .../mqtt/packet/Connect.cpp - where the MQTT connect packet is being built up. Looking into this and will revert.

@PerMalmberg
Copy link
Owner

PerMalmberg commented Oct 28, 2021 via email

@PerMalmberg
Copy link
Owner

There is actually a fork that adds username and password, as well as TLS for mqtt. I've not had the time to engage that author to verify the functionality of those additions and merge them back into this main repo, but if you're willing to I'm more than happy to accept a PR with tests for it.

@Paul-Simpson
Copy link
Contributor Author

Thank you - that is great news. I was wading through the TLS and MQTT protocols and thinking it's a non-trivial amount of work to implement from a standing start. I'll take a look at the fork over the weekend.

@Paul-Simpson
Copy link
Contributor Author

Paul-Simpson commented Nov 1, 2021

Update: The fork looks promising, however, I'm having trouble compiling it with:

../lib/smooth/include/smooth/core/network/Wifi.h:31:10: fatal error: wifi_provisioning/manager.h: No such file or directory
#include <wifi_provisioning/manager.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

errors. I've checked that WiFi is turned on in "make menuconfig". I've been googling but have not found anything that helped me. I'm not sure if this rings any bells with you?

@PerMalmberg
Copy link
Owner

I'm guessing it is part of ESP-IDF?

@Paul-Simpson
Copy link
Contributor Author

Yes. I can see the file. Vscode can even follow the include link. I'll look further into it.

@Paul-Simpson
Copy link
Contributor Author

Hi, quick update. I've been looking at the luuvt mqtts fork. It works well with ESP-IDF 4.2.x, but I'm seeing compile errors when using with 4.3 or 4.4. The errors are:

In file included from /Users/paulsimpson/esp/esp-idf/components/driver/include/driver/gpio.h:16,
                 from ../externals/smooth/lib/smooth/include/smooth/core/io/spi/Master.h:24,
                 from ../externals/smooth/lib/smooth/include/smooth/application/io/spi/BME280SPI.h:30,
                 from ../externals/smooth/lib/smooth/application/io/spi/BME280SPI.cpp:19:
/Users/paulsimpson/esp/esp-idf/components/hal/include/hal/spi_types.h: In function 'constexpr spi_event_t operator~(spi_event_t)':
/Users/paulsimpson/esp/esp-idf/components/esp_common/include/esp_attr.h:123:79: error: use of old-style cast to 'uint32_t' {aka 'unsigned int'} [-Werror=old-style-cast]
 FORCE_INLINE_ATTR constexpr TYPE operator~ (TYPE a) { return (TYPE)~(INT_TYPE)a; } \
                                                                               ^
/Users/paulsimpson/esp/esp-idf/components/esp_common/include/esp_attr.h:135:29: note: in expansion of macro 'FLAG_ATTR_IMPL'
 #define FLAG_ATTR_U32(TYPE) FLAG_ATTR_IMPL(TYPE, uint32_t)
                             ^~~~~~~~~~~~~~
/Users/paulsimpson/esp/esp-idf/components/esp_common/include/esp_attr.h:136:19: note: in expansion of macro 'FLAG_ATTR_U32'
 #define FLAG_ATTR FLAG_ATTR_U32
                   ^~~~~~~~~~~~~

...is this something that you have seen before? I'm pretty green to PR's etc on GitHub, so please don't be afraid to spell out how I can be of help getting this fixed and in a state where I can PR it. Best Wishes, Paul

@PerMalmberg
Copy link
Owner

I think this original repo is compatible with 4.3 and 4.4, if I remember correctly another contributor made PR to fix it.

If you can compile this original Smooth repo with them, it's probably easiest to simply look at what luuvt has done and make new PR with those changes and any improvements on top.

I've been busy with other things for the last two years so I don't have the environment, nor the time, to investigate it myself.

@Paul-Simpson
Copy link
Contributor Author

Hey - thanks for the pointers. I looked into this issue some more. The latest Smooth compiles just fine with 4.4, so I will look at how I can bring the luuvt mqtts changes into the latest Smooth and then PR that as you suggest.

Aside from the issue, I must say that I'm learning positively a lot from your code and architecture. :) Out of interest (and please feel free not to answer if you're busy) would you have structured it in the same way if you were to start again? I'm asking not because I see any issues, but because by the time I finished building a project, many lessons have been learnt along the way.

@PerMalmberg
Copy link
Owner

Out of interest (and please feel free not to answer if you're busy) would you have structured it in the same way if you were to start again?

Yes, and no. As with every software project, you learn things as it progresses and there are always things that can be done better. Smooth is actually based on similar software system that I developed and is running on thousands of systems at airports all over the world. I've you've ever landed on any major airport, it has likely affected you :) That one had a different OS, different requirements and was not something I wrote as a spare-time project, but the overall idea is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants