github.com/brocaar/lora-gateway-bridge/backend/mqttpubsub

ChirpStack Gateway Bridge abstracts Packet Forwarder protocols into Protobuf or JSON over MQTT.


Keywords
chirpstack, json, lora, lorawan, mqtt, protobuf
License
MIT
Install
go get github.com/brocaar/lora-gateway-bridge/backend/mqttpubsub

Documentation

LoRa Semtech Bridge

Build Status GoDoc

LoRa Semtech Bridge is a service to enable LoRa gateway communication over MQTT. All incoming UDP traffic (Semtech UDP protocol) is published to a MQTT broker and all messages received from the MQTT broker are sent to the gateway using UDP.

This project is part of LoRa Server.

Requirements

MQTT broker

Mosquitto is a popular open-source MQTT server.

LoRa gateway

Your gateway must be setup so that it sends UDP packets (Semtech UDP protocol). Depending upon your LoRa Gateway type, you might need to install the packet_forwarder.

Getting started

  • Download and unpack a pre-compiled binary from the releases page. Alternatively, build the code from source (when you have a Go development environment make build should be sufficient).

  • Start the semtech-bridge service. The --help argument will show you all the available config options. When everything is setup correctly (your gateway is configured to send data to semtech-bridge), you should see PullData packets coming in. E.g.

$ ./bin/semtech-bridge
INFO[0000] backend/mqttpubsub: connecting to mqtt server  server=tcp://127.0.0.1:1883
INFO[0000] starting gateway udp listener                 addr=0.0.0.0:1700
INFO[0006] incoming gateway packet                       addr=192.168.1.4:54993 type=PullData
INFO[0006] backend/mqttpubsub: subscribing to topic      topic=gateway/1dee08d0b691d149/tx
INFO[0006] outgoing gateway packet                       addr=192.168.1.4:54993 type=PullACK
INFO[0006] incoming gateway packet                       addr=192.168.1.4:51926 type=PushData
INFO[0006] stat packet received                          addr=192.168.1.4:51926 mac=1dee08d0b691d149
INFO[0006] outgoing gateway packet                       addr=192.168.1.4:51926 type=PushACK
INFO[0006] backend/mqttpubsub: publishing message        topic=gateway/1dee08d0b691d149/stats

Debugging

To view all incoming and outgoing MQTT messages, you can use the mosquitto_sub tool.

$ mosquitto_sub -t "#" -v
gateway/1dee08d0b691d149/stats {"mac":"1dee08d0b691d149","time":"2016-04-16T10:08:11Z","latitude":0,"longitude":0,"altitude":0,"rxPacketsReceived":0,"rxPacketsReceivedOK":0}
gateway/1dee08d0b691d149/rx {"rxInfo":{"mac":"1dee08d0b691d149","time":"2016-04-16T10:08:30.005418Z","timestamp":1623489499,"frequency":868300000,"channel":1,"rfChain":1,"crcStatus":1,"codeRate":"4/5","rssi":-48,"loRaSNR":10,"size":23,"dataRate":{"modulation":"LORA","spreadFactor":7,"bandwidth":125}},"phyPayload":"AAEBAQEBAQEBAgICAgICAgJzTIBGXXg="}
gateway/1dee08d0b691d149/stats {"mac":"1dee08d0b691d149","time":"2016-04-16T10:08:41Z","latitude":0,"longitude":0,"altitude":0,"rxPacketsReceived":1,"rxPacketsReceivedOK":1}

Data model

The data model is defined in the LoRa Server project. JSON is used as marshaling format. See:

License

This package is licensed under the MIT license. See LICENSE.