Paho MQTT C Client Library

Hello,

I would like to create a MQTT Application on openWRT and a Carambola2 board.
My first was to use the paho python library because it's avaliable on branch 19.07.
But the images size grows to much for the Carambola board using python.

The next idea was to use the paho c library.
I did not find any packages or topics in this forum of that.

The next idea was to use the mosquitto client?

Is there anybody who has some experience in using paho c library on openWRT or the mosquitto client?

The USE-CASE is:

  • Subscribing a MQTT topic
  • Getting an event when the message receives
  • Read the value of the message
  • Send the value to another software API that runs alread on the opneWRT machine

You can go pretty far with the shell/jshn/jsonfilter and mosquitto CLI client, for complex stuff take a look at lua-mosquitto, there is as well lightweight libumqtt libubox event loop based with Lua bindings as well, although it's not officially packaged, there's package Makefile.

I am currently using the CLI client, on a small device, to bridge 433MHz events and send them to a large router, where are processed using a node.js program.

Thank you for your replies!

In my first steps I will try to use libmosquitto with a small c program.
I think this will work for me.

Hi there,

I've got the MQTT client running. The libmosquitto works fine for me.
There were some difficulties in creating the applications makefile but I've got it running.

Here's the makefile:

include $(TOPDIR)/rules.mk

PKG_NAME:=mqtt-client
PKG_VERSION:=1.00
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

TARGET_LDFLAGS+=/usr/lib
PKG_BUILD_DEPENDS:=libmosquitto-nossl

include $(INCLUDE_DIR)/package.mk

define Package/mqtt-client
	SECTION:=mysection
	CATEGORY:=my company
	TITLE:=MQTT client for I/O control
	DEPENDS:=+libmosquitto-nossl
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)
endef

define Package/mqtt-client/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/mqtt-client $(1)/usr/sbin/
	$(CP) ./files/* $(1)/
endef

$(eval $(call BuildPackage,mqtt-client,+libmosquitto-nossl))

Note: The application binary is not build with the makefile in this version. It is commited already built.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.