Skip to content

MQTT user/password authentication #168

Open

Description

@Paul-Simpson

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

Activity

  1. Paul-Simpson commented on Oct 28, 2021

    @Paul-Simpson
    ContributorAuthor

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

  2. PerMalmberg commented on Oct 28, 2021

    @PerMalmberg
    Owner
  3. PerMalmberg commented on Oct 29, 2021

    @PerMalmberg
    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.

  4. Paul-Simpson commented on Oct 29, 2021

    @Paul-Simpson
    ContributorAuthor

    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.

  5. Paul-Simpson commented on Nov 1, 2021

    @Paul-Simpson
    ContributorAuthor

    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?

  6. PerMalmberg commented on Nov 1, 2021

    @PerMalmberg
    Owner

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

  7. Paul-Simpson commented on Nov 1, 2021

    @Paul-Simpson
    ContributorAuthor

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

  8. Paul-Simpson commented on Nov 25, 2021

    @Paul-Simpson
    ContributorAuthor

    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

  9. PerMalmberg commented on Nov 26, 2021

    @PerMalmberg
    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.

  10. Paul-Simpson commented on Nov 26, 2021

    @Paul-Simpson
    ContributorAuthor

    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.

  11. PerMalmberg commented on Nov 29, 2021

    @PerMalmberg
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions