Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/devgianlu/go-coap-mqtt

A CoAP <-> MQTT gateway written in Go.
https://github.com/devgianlu/go-coap-mqtt

coap mqtt

Last synced: 6 days ago
JSON representation

A CoAP <-> MQTT gateway written in Go.

Awesome Lists containing this project

README

        

# go-coap-mqtt

`go-coap-mqtt` is a CoAP <-> MQTT gateway written in Go.

Messages can be sent and received from both MQTT and CoAP. The following ways of exchanging messages are supported:

- Publishing an MQTT message to a particular topic
- Making a CoAP `POST /pub` request with a JSON body containing the topic and payload
- Subscribing to a particular MQTT topic
- Observing the CoAP `GET /sub/{topic}` endpoint

This project was developed as part of the university course
of [Telematica](https://corsi.unipr.it/it/ugov/degreecourse/191394).

## Testing

The `test` container has two CLI tools installed for interacting with the gateway and MQTT
broker: [mqtt](https://github.com/hivemq/mqtt-cli) and [coap-cli](https://github.com/mainflux/coap-cli).
You can get an interactive shell inside the container with `docker compose exec test bash`.

To make a CoAP request of the `/pub` endpoint use:

```shell
coap-cli post pub -h gateway -p 5688 -d '{"topic":"test","payload":"hello from coap"}'
```

To make a CoAP request to the `/sub` endpoint use:

```shell
coap-cli get sub/test -h gateway -p 5688 -o
```

To publish an MQTT message use:

```shell
mqtt pub --host mqtt-broker --topic test -m "hello from mqtt"
```

To subscribe to MQTT messages use:

```shell
mqtt sub --host mqtt-broker --topic test
```