Giter Site home page Giter Site logo

ligzy / springboot.mqtt.persister Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ddewaele/springboot.mqtt.persister

0.0 0.0 0.0 28 KB

Spring Boot / Integration project that listens on an MQTT topic, processes incoming messages (sensor payloads), logs them and persists them into a DB. Exposes a REST API to query the sensor payloads.

Shell 2.00% Java 98.00%

springboot.mqtt.persister's Introduction

Spring Boot Lora Persister

Spring Boot / Integration project that processes Lora messages by

  • listening on an MQTT topic
  • accepting payloads via REST

logs them and persists them into a DB.

Exposes a REST API to query the sensor payloads.

Currently supports

  • MultiTech Lora Network Server message format
  • LoraBridge message (stats, rx)
  • Adeunis RF TTN converted messages
  • Custom sensor payloads

Spring Boot as docker

Can be run as a docker container.

docker run --name springboot.mqtt.persister -p 8080:8080 -d ddewaele/springboot.mqtt.persister

Docker compose

We also offer a docker-compose file.

Supported payloads

We support the following payloads :

  • MultiTech Lora Network Server message format
  • LoraBridge message (stats, rx)
  • Adeunis RF TTN converted messages
  • Custom sensor payloads

MultiTech message format

curl -H "Content-Type: application/json" -d@./src/test/resources/multitech-conduit-payload.json http://localhost:8086/api/multiTechPayloads
curl http://localhost:8086/api/multiTechPayloads

Lora Bridge network format

Support for persisting lora-gateway-bridge json payloads coming in via MQTT.

  • gateway/[GATEWAY_ID]/stats
  • gateway/[GATEWAY_ID]/rx

Where GATEWAY_ID is he mac hex representation of the gateway (ex: b827ebfffecbe31f)

REST endpoints are also made available :

curl -H "Content-Type: application/json" -d@./src/test/resources/lora-gateway-bridge-receive.json http://localhost:8086/api/loraGatewayBridgeReceives
curl http://localhost:8086/api/loraGatewayBridgeReceives
curl -H "Content-Type: application/json" -d@./src/test/resources/lora-gateway-bridge-gateway-status.json http://localhost:8086/api/loraGatewayBridgeStatses
curl http://localhost:8086/api/loraGatewayBridgeStatses

Adeunis RF Field Tester

As described in the Adeunis RF Field tester documentationhttps://www.adeunis.com/wp-content/uploads/2017/08/ARF8123AA_ADEUNIS_LORAWAN_FTD_UG_V1.2.0_FR_GB.pdf), the device sends out useful information that we can capture.

curl -H "Content-Type: application/json" -d@./src/test/resources/adeunis-ttn-payload.json http://localhost:8086/api/adeunisRfTtnPayloads
curl http://localhost:8086/api/adeunisRfTtnPayloads

Custom sensor payloads

zThe application supports a custom sensor payload via MQTT.

{
  "sensorId": "88-00-00-00-00-00-00-00",
  "temp": 20,
  "status": true,
  "date": "2017-10-08T08:52:03.631Z",
  "raw": "xxxxxxxxxxxx"
}

Messages can be injected using MQTT:

mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-77" -m "{\"temp\":23,\"status\":true,\"date\":\"2010-01-01T13:47:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}"
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-77" -m "{\"temp\":17,\"status\":false,\"date\":\"2010-01-01T13:45:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}"
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-77" -m "{\"temp\":34,\"status\":false,\"date\":\"2010-01-01T13:40:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}"
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-77" -m "{\"temp\":10,\"status\":false,\"date\":\"2010-01-01T13:30:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-77" -m "{\"temp\":11,\"status\":false,\"date\":\"2010-01-01T13:10:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-77" -m "{\"temp\":12,\"status\":false,\"date\":\"2010-01-01T13:20:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-78" -m "{\"temp\":13,\"status\":false,\"date\":\"2010-01-01T13:10:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-78" -m "{\"temp\":14,\"status\":false,\"date\":\"2010-01-01T13:30:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-78" -m "{\"temp\":15,\"status\":false,\"date\":\"2010-01-01T13:20:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 
mosquitto_pub -h localhost -t "ixortalk/msg/88-11-22-33-44-55-66-79" -m "{\"temp\":16,\"status\":false,\"date\":\"2010-01-01T13:40:00+01:00\",\"raw\":\"0101470dd3c16e00640b0209d100\"}" 

or via REST

curl -X POST -H "Content-Type:application/json" -d @./src/test/resources/payload.json http://localhost:8085/api/sensor

We also provide a generate.sh script that inserts some random data every second.

REST API

The application exposes REST APIs to fetch the sensor data.

http://localhost:8080/api/sensor/88-11-22-33-44-55-66-79  ---> shows the most recent sensor value
http://localhost:8080/api/sensor/88-11-22-33-44-55-66-79/history   ----> shows the historical values
curl http://localhost:8080/api/sensor/aggregate ---> aggregates all recent sensor values for distinct sensor IDs.

springboot.mqtt.persister's People

Contributors

ddewaele avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.