Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/junker/chicken-mosquitto

Chicken Scheme bindings to the libmosquitto MQTT client library
https://github.com/junker/chicken-mosquitto

chicken-scheme mosquitto mqtt mqtt-client scheme-language

Last synced: about 9 hours ago
JSON representation

Chicken Scheme bindings to the libmosquitto MQTT client library

Awesome Lists containing this project

README

        

# chicken-mosquitto

Chicken Scheme Bindings to mosquitto MQTT client library

## Requirements

- [libmosquitto](https://mosquitto.org) installed

## Instalation

```bash
chicken-install mosquitto
```

## Usage

Example client which sends message into `topic2` each time it gets message from `topic1`:

```scheme
(import (chicken blob)
(chicken string)
(mosquitto))

(define (message message)
(display message)
(newline)
(flush-output))

(define client
(make-mqtt-client #:on-connect (lambda (client err)
(when err
(abort err))
(message "Yay, we are connected!")
(mqtt-subscribe client "topic1"))))

(set-mqtt-client-disconnect-callback! client
(lambda (cl unexpected?)
(when unexpected?
(message "Unexpected disconnect..."))))

(set-mqtt-client-message-callback! client
(lambda (cl msg)
(message (string-append
"Topic: " (mqtt-message-topic msg) " "
"Payload:" (blob->string (mqtt-message-payload msg))))
(mqtt-publish client "topic2" "message received, thanks!" )))

(mqtt-connect client "localhost"
#:username "mqtt-admin"
#:password "mypass")

(mqtt-loop-forever client)
```

## Documentation

[Full Documentation](http://wiki.call-cc.org/eggref/5/mosquitto)