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"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-0.3.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-0.3.0-py2.py3-none-any.whl (2.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: ci_msg_parser-0.3.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-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1308123acb42e33268f1ea018847341c52468ebfbf7e9ce6bf859ee33664cf90
MD5 679232845d4c90814095d095d1e8d514
BLAKE2b-256 f42cdb064a63dd1e830d2f9033d9259c30217136d122a60f1e6517a77edd66b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ci_msg_parser-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 132d8844d7f948ab04c704d6d611069e545090a020da3706db2c6c8b123ffd92
MD5 487823ebc52484032e845ec6cb005c30
BLAKE2b-256 c07db9170b5aa76112b20c97650d516b7cbbdf57871ccab931f13e883fd3e5a1

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