Skip to main content

NSRTW_mk4 MQTT protocol message parser

Project description

ci-msg-parser

Python library for parsing NSRTW_mk4 MQTT protocol messages.

Quick-Start

Note these instructions are for testing/demo purposes only.

To start, you will need an MQTT server:

$ cat <<EOF > mosquitto.conf
listener 1883 0.0.0.0
allow_anonymous true
EOF

$ docker run --rm -it -p 1883:1883 -v "./mosquitto.conf:/mosquitto/config/mosquitto.conf" eclipse-mosquitto

Make sure your NSRTW_mk4 is configured to connect to your MQTT server.

Next, use a python script to receive and process messages the instrument:

#!/usr/bin/env python

import paho.mqtt.client as mqtt
from ci_msg_parser import *

def on_connect(client, userdata, flags, reason_code, properties):
	client.subscribe("#")

def on_message(client, userdata, msg):
	parsed = MessageParser.parse(msg.payload)
	if isinstance(parsed, VitalSignsMessage):
		print(f"rssi: {parsed.rssi} batt: {parsed.battery_voltage} temp: {parsed.temperature}")
	if isinstance(parsed, RecordedDataMessage):
		print(f"type: {parsed.message_type} values: {parsed.values}")

mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
mqttc.on_connect = on_connect
mqttc.on_message = on_message

mqttc.connect("localhost", 1883, 60)
mqttc.loop_forever()
$ pip install paho-mqtt ci-msg-parser
$ python script.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ci_msg_parser-1.0.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ci_msg_parser-1.0.0-py2.py3-none-any.whl (2.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ci_msg_parser-1.0.0.tar.gz.

File metadata

  • Download URL: ci_msg_parser-1.0.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for ci_msg_parser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9ac8584a89c23eeda4cf0ca0fdbbef325b605714abfa6fe37f8c78a5c3f398c9
MD5 7b5fd4957c22d5a0de894492fef1f45c
BLAKE2b-256 b38670422d0a9c9b2d9af5320c86183e235cb6946954c8efc9e174c02b608f0b

See more details on using hashes here.

File details

Details for the file ci_msg_parser-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ci_msg_parser-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5e275d2c550eed71b719bf9f9f9b86ee53d2fec1a6b6388544d36479a368ff01
MD5 c638ada532333c4725cdb10338db13df
BLAKE2b-256 3c1ec25938b20adfe0270a9fe0fbb7516a688df2a0b9552478aab78553b87de1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page