Skip to content

Instantly share code, notes, and snippets.

@ekhall
Created December 21, 2015 14:18
Show Gist options
  • Save ekhall/1d1c17f9dbd14cf0f003 to your computer and use it in GitHub Desktop.
Save ekhall/1d1c17f9dbd14cf0f003 to your computer and use it in GitHub Desktop.
(ns aurora.models.lab
(:require [clojure.java.jdbc :as sql]
[twilio.core :as twilio]
[clojurewerkz.machine-head.client :as mh]))
(defn send-mqtt [message & args]
(let [id (mh/generate-id)
conn (mh/connect mqtt-url id)]
(mh/subscribe conn ["gossamer"] (fn [^String topic _ ^bytes payload]
(println (String. payload "UTF-8"))))
(mh/publish conn "gossamer" message)
{:status 200
:headers {"Content-Type" "text/plain"}
:body "Published Message!"}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment