No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
core.clj
mqtt_client_o.h

README.md

ferret-mosquitto

Wrapper for Mosquitto. Mosquitto is an open source message broker that implements the MQTT (MQ Telemetry Transport).

Dependencies

  • Mosquitto

    • On Mac OS X - brew install mosquitto

Usage

(require '[ferret-mosquitto.core :as mqtt])

(def broker (mqtt/connect "localhost" 1883))

(while (not (mqtt/connected? broker))
  (sleep 100))

(println "[+] Connected")

(println "[+] Subscribe " (mqtt/subscribe broker "sensors/temp"))

(mqtt/subscribe-callback
 broker
 (fn [topic payload]
   (println "[+] Receive" topic payload)))

(forever
 (println "[+] Publish" (mqtt/publish broker "sensors/temp" "32.5"))
 (sleep 1000))

Setup CXXFLAGS

export CXXFLAGS="-lmosquitto -lmosquittopp"

Compile,

ferret -i program.clj -c

Misc

Start the broker,

mosquitto

Start the command line subscriber,

mosquitto_sub -v -t 'test/topic'

Publish test message with the command line publisher,

mosquitto_pub -t 'test/topic' -m 'helloWorld'