2025-06-11 09:59:25 -07:00
2025-06-08 10:27:17 -07:00
2025-06-08 10:27:17 -07:00
2025-06-08 09:33:51 -07:00
2025-06-11 09:59:25 -07:00
2025-06-08 09:33:51 -07:00
2025-06-01 21:39:46 -07:00
2025-01-26 19:43:23 -08:00

Milquetoast

Milquetoast is a Clojure library for interacting with MQTT brokers. It provides a simple and intuitive API for sending and receiving messages, subscribing to topics, and managing MQTT connections.

Usage

First, connect to the MQTT broker:

(def client (milquetoast.api/connect! :host "localhost" :port 1883))

To send a message:

(milquetoast.api/send! client "test/topic" "Hello, MQTT!")

To subscribe to a topic and receive messages:

(def chan (milquetoast.api/subscribe! client "test/topic"))

You can then take messages from the channel as they arrive. Here's an example of how to listen on the channel and print the messages:

(go-loop []
  (when-let [msg (<! chan)]
    (println "Received message:" msg)
    (recur)))

To disconnect from the broker:

(milquetoast.api/stop! client)

For more detailed usage, see the API documentation and the example code in the examples directory.

JSON Client

Milquetoast also provides a JSON client, which automatically parses JSON payloads from received messages and serializes JSON payloads for sent messages.

To connect using the JSON client:

(def json-client (milquetoast.api/connect-json! :host "localhost" :port 1883))

The JSON client can be used in the same way as the regular client, but note that the payload of received messages will be a map (parsed from the JSON payload), and the payload of sent messages should be a map (which will be serialized to a JSON string).

Description
MQTT client.
Readme 44 KiB
Languages
Clojure 87.2%
Nix 12.8%