-
Notifications
You must be signed in to change notification settings - Fork 86
mqtt subscribe
Chris Petersen edited this page Oct 16, 2014
·
1 revision
mqtt-subscribe subscribes to topic from the MQTT broker.
Parameter | Description |
---|---|
t | MQTT broker |
topic | Topic name string |
qos | QOS level: 0 fire-and-forget, 1 send-at-least-once , 2 send-exactly-once |
Example 1: Make a connection to a mosquitto broker running on localhost:1883, subscribe to two topics, publish some data to them and wait for the results to show. Then unsubscribe from one topic and show that it's handler is no longer called. Finally close the connection properly.
> (define m (make-mqtt 'host "127.0.0.1" 'port 1883
'handler (lambda (topic val)
(for-each display (list topic ": " val "\n")))))
> (thread-sleep! 0.5)
> (mqtt-subscribe m "Test1" 2)
#t
> (mqtt-subscribe m "Test2" 2)
#t
> (mqtt-publish m "Test1" 123 2 0)
#t
> (mqtt-publish m "Test2" 123456 2 0)
#t
> (thread-sleep! 1.)
Test1: 123
Test2: 123456
> (mqtt-unsubscribe m "Test1")
#t
> (mqtt-publish m "Test1" "blah" 2 0)
#t
> (mqtt-publish m "Test2" "LN1" 2 0)
#t
> (thread-sleep! 1.)
Test2: LN1
> (mqtt-destroy m)
#t
-
- accelerometer
- alist
- audio
- audioaux
- base64
- btle-scan
- camera
- cdb
- cgi
- config
- csv
- curl
- digest
- dmtx
- download
- eventloop
- fcgi
- fft
- generalized-arrays
- gps
- graph
- gyro
- hidapi
- hpdf
- html
- httpsclient
- hybridapp
- json
- lmdb
- ln_core
- ln_glcore
- ln_glgui
- ln_store
- localization
- localization_gui
- localnotification
- magnetometer
- mdns
- mqtt
- mqtt-store
- multitouch
- oauth
- orientation
- p256ecdsa
- png
- portaudio
- pregexp
- pressure
- prime
- pushnotification
- redcap
- rsa
- rtaudio
- rupi
- rotation
- sanestring
- scheduler
- serial
- sets
- settings
- simplexnoise
- sqlite
- ssax
- syntax-case
- timestamp
- ttf
- uiform
- url
- uuid
- vibrate
- videoplayer
- watchdog
- website
- xml
- zip