Skip to content

ucode-mod-mosquitto: add libmosquitto binding for ucode#29295

Open
januszdziedzic wants to merge 1 commit intoopenwrt:masterfrom
januszdziedzic:master
Open

ucode-mod-mosquitto: add libmosquitto binding for ucode#29295
januszdziedzic wants to merge 1 commit intoopenwrt:masterfrom
januszdziedzic:master

Conversation

@januszdziedzic
Copy link
Copy Markdown

📦 Package Details

Maintainer: @januszdziedzic

Description:
New package: native ucode C module wrapping libmosquitto with libubox/uloop
integration. Provides an MQTT v3.1.1 client API for ucode scripts: QoS 0/1/2,
will messages, username/password authentication, manual reconnect via the
on_disconnect callback, and TLS when libmosquitto-ssl is installed. The
libmosquitto socket is registered with uloop so MQTT I/O runs in the same
event loop as the rest of the application; the libmosquitto helper thread
is not used.

Originally proposed at openwrt/openwrt#23187 — moved here because the package
depends on libmosquitto, which lives in this feed and isn't visible to the
core-packages CI in openwrt/openwrt.


🧪 Run Testing Details

  • **OpenWrt Version: main
  • **OpenWrt Target/Subtarget: mediatek/filogic
  • **OpenWrt Device: BPI-R4 One

✅ Formalities

  • [ x] I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

If your PR contains a patch:

Not applicable — this PR adds a new package, not a patch to existing code.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new OpenWrt package providing a native ucode module that wraps libmosquitto and integrates MQTT socket I/O into the libubox/uloop event loop.

Changes:

  • Introduces mosquitto ucode module implemented in C with uloop-based polling and callback bridging.
  • Adds OpenWrt package Makefile to build and install the mosquitto.so ucode module.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
utils/ucode-mod-mosquitto/src/mosquitto.c Implements the ucode ↔ libmosquitto bindings and uloop integration for MQTT client operations and callbacks.
utils/ucode-mod-mosquitto/Makefile Adds packaging/build logic to compile and install the new ucode module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils/ucode-mod-mosquitto/Makefile
Comment thread utils/ucode-mod-mosquitto/src/mosquitto.c
Comment thread utils/ucode-mod-mosquitto/src/mosquitto.c
Comment thread utils/ucode-mod-mosquitto/src/mosquitto.c
Comment thread utils/ucode-mod-mosquitto/src/mosquitto.c
@januszdziedzic
Copy link
Copy Markdown
Author

Already pass claude review in openwrt/openwrt#23187 - AI fight? :)

Comment thread utils/ucode-mod-mosquitto/Makefile
@GeorgeSapkin
Copy link
Copy Markdown
Member

I'm probably missing some context, but what is the intended use case? Is some app going to depend on this?

@BKPepe
Copy link
Copy Markdown
Member

BKPepe commented May 4, 2026

Look, looking at it, I'd say it's going to get a bit confusing soon, both for beginners and even for us. You created the ucode-mod-mosquitto package, but when I check the main OpenWrt repository, there is a ucode package containing other modules (sourced from https://github.com/jow-/ucode), and then there are separate ucode-mod-bpf, ucode-mod-pkgen, and ucode-mod-uline packages. In my opinion, it could definitely use some refactoring and merging—it would be better to keep it in a single Makefile rather than having it scattered all over the place. Because users will be confused about where to report any potential bugs—whether here or there—and we'll just end up bouncing them back and forth

I do get that mosquitto is located in the packages repository, but @GeorgeSapkin asks a valid question. That definitely deserves an answer.

@januszdziedzic
Copy link
Copy Markdown
Author

I'm probably missing some context, but what is the intended use case? Is some app going to depend on this?

I am using device_agent.uc ucode script that connect MQTT broker, report status and handle cmds - mainly configure network/wifi from broker - instead of using C code just use scripts for that. Today cloud app talk also with MQTT broker and manage devices. In the future plan to add device_controler.uc that will work on GW and configure network. This is how I implement SDN (tls connetion with signed certs - all managed from MQTT broker).

@januszdziedzic
Copy link
Copy Markdown
Author

Look, looking at it, I'd say it's going to get a bit confusing soon, both for beginners and even for us. You created the ucode-mod-mosquitto package, but when I check the main OpenWrt repository, there is a ucode package containing other modules (sourced from https://github.com/jow-/ucode), and then there are separate ucode-mod-bpf, ucode-mod-pkgen, and ucode-mod-uline packages. In my opinion, it could definitely use some refactoring and merging—it would be better to keep it in a single Makefile rather than having it scattered all over the place. Because users will be confused about where to report any potential bugs—whether here or there—and we'll just end up bouncing them back and forth

I do get that mosquitto is located in the packages repository, but @GeorgeSapkin asks a valid question. That definitely deserves an answer.

I also think mosquitto should be directly in openwrt git - this is really important package. Didn't add it to ucode, that was a choice like for other ucode-mod-*. But don't see any issue with move it to ucode directly - but maybe after more people will test it and code became mature.

Add a native ucode C module wrapping libmosquitto with libubox/uloop
integration. Provides an MQTT v3.1.1 client API for ucode scripts:
TLS (via libmosquitto-ssl), QoS 0/1/2, will messages, username/password
authentication and manual reconnect via the on_disconnect callback.

The module registers the libmosquitto socket with uloop so MQTT I/O
runs in the same event loop as the rest of the application, avoiding
the libmosquitto helper thread.

Assisted-by: Claude:Opus 4.7
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants