I'm currently preparing a little demo where I use ChibiOS 18.2.0 with LwIP 2.0.3 (the one that comes with ChibiOS) on an STM32F407 microcontroller. I managed to get the ChibiOS LwIP demo (HTTP server) running without any problems. I also managed to send raw data over TCP myself without any problems.
For this application I need to run MQTT. LwIP 2.0.3 already comes with a built-in MQTT client which seems very suitable.
The first problem I encountered is that I needed to modify the /os/various/lwip_bindings/lwip.mk file. Whenever I compiled the MQTT example code that comes with LwIP I got a couple of undefined reference linking errors. I had to add $(MQTTFILES) to LWSRC:
Code: Select all
LWSRC = $(COREFILES) $(CORE4FILES) $(APIFILES) $(LWBINDSRC) $(NETIFFILES) $(HTTPDFILES) $(MQTTFILES)
Looking at the LwIP makefile (/lwip/src/Filelist.mk) it seems that the more appropriate solution is to include $(LWIPAPPFILES) instead of all the single ones.
What's the story on this? Did nobody ever run MQTT and therefore nobody ever reported this issue or is this by design?
Once I managed to compile and run the code I ran into the problem that I can't connect to my MQTT message broker ("the server"). I tried various different MQTT message brokers (both private and public ones) and I always get the same effect: mqtt_client_connect() returns without any error, but the mqtt_connection_cb() callback always gets the state DISCONNECTED back. I tried to debug this and when I look at the mqtt client struct the conn_status is set to MQTT_CONNECT_REFUSED_PROTOCOL_VERSION.
I'm very confused by this as LwIP claims to always run MQTT 3.1.1 and the brokers I used support both 3.1 and 3.1.1. Also I wrote programs (for a desktop computer system) that can successfully connect to all those brokers. I'm not using LwIP there - the test was just to confirm that there's no networking / infrastructure problem.
Does anybody have any idea about this? My main question is whether this might have something to do with the ChibiOS integration/bindings. Is it possible that something is missing in the LwIP thread that is defined in the ChibiOS bindings which gets started upon calling lwipInit()?
I'd appreciate any kind of help here.