A working MQTT PubSub liberary for mbed-os 6

Hello Guys,

I am new to the forum and to Mbed-OS, but not new to IoT, IT and Programming in general.
So I have been playing with L152RE for while now and trying different things with it. Where I have been stuck lately, is working with MQTT.

I am trying to get my L152RE to send and receive information to/from MQTT, I have been successful in getting it to work as a subscriber, but not much as a publisher. Here is what I can tell about my setup.

Board: NUCLEO L152RE
Network Connectivity: ESP8266-01S (latest official firmware)
Dev-Environment: Mbed-Studio
Mbed-OS: Mbed-OS 6.15 (latest)
MQTT Library: GitHub - ARMmbed/mbed-mqtt: Mbed-os MQTT and MQTT-SN library, based on Eclipse Paho project.

What Works (overview):

  1. Connect to WiFi
  2. Connects to my MQTT Server
  3. Subscribe to Topic, Set default MessageHandler
  4. As subscriber, my L152RE works fine, no complaints yet.

What makes problem:
5. I can’t publish to MQTT-Topic, Status Code from publish request is almost always -3004

funny thing though, if I publish something, before I have received a message from broker, then it works variably. But I have received a message from broker. Then I can’t publish anymore.

I am using mosquito-mqtt-broker, set to log everything and I am watching the log with tail-f, my L152RE, doesn’ even tries to publish. (and just if it is not obvious already, there is no authentication/authorization issue.

I feel like I am missing some small thing here, but believe me I have given a lot time and attention and still to no avail. Maybe someone here can guide to me right direction.

Sounds like an authorization issue at the broker, but it can’t be if you allow everything at the broker side, so I’m not sure…

I have not used the mbed-mqtt library yet, as an alternative you could try integrating the very robust coreMQTT library. It is used in the GitHub - ARMmbed/mbed-client-for-aws: AWS IoT SDK port for Mbed OS library too.

Thanks a lot for the reply Özgen,

as per your suggestion, I tried to get it with AWS-example, couldn’t get it to work, it is full of inconsistencies.
First I though: maybe it is something with my Mbed-Studio environment, so I tried it with Keil Studio online, same.

I went online to Keil Studio Online and started a new project with the pre-given examples.
I didn’t changed one bit in the code and tried to compile it, it fails: Screenshot below

TLSSocket Class/library is literally in the exact same directory as TCPSocket, but neither Mbed-Studio, installed locally nor the Keil-Studio Online can understand it.

Current latest Mbed-OS Version is 6.15.1 and when I try to start a new project with Mbed OS example for AWS cloud, it uses Version 6.13.0

locally, I can use strlen() method to find length of a char array, but online it is unknown

my so far experience with Mbed-OS is just terible, I am not a Mbed-OS expert but I am a Professional Programmer, so I don’t think I am some newbie.

Hello,

That is know issue and it comes from clangd, it has nothing together with an error in code and it will be compiled without issues around it.

With Mbed Studio and Keil Studio it is little bit complicated. Shortly say, both are still in development, from my point of view.
It is not official information, but my understanding. Development of Mbed Studio was stopped and it is waiting for a final look of Keil Studio online because it should be also Keil Studio desktop.
Keil Studio online development is still ongoing and there is good progress during the last year. it’s not that fast but it’s happening.

What I saw here, professionals usually use Mbed CLI.

BR, Jan