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.4.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.4.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.4.0.tar.gz.

File metadata

  • Download URL: ci_msg_parser-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 2d59f2ec17be310491f8d1b4b6ca3cb02f267237bfa719f77a566c3070d558fb
MD5 867bd0b970a9253c23371dc05bff97ba
BLAKE2b-256 dc8f7ed74a919a944e1fea32ce0b687c2793091f55d7504281f776f7b68d5e6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ci_msg_parser-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 536396d851a4f251793d5ee6d0b6f96ab38ea670bf06d6438a045554ce7e703c
MD5 9fb486b7211b638dfe3cab8823598c77
BLAKE2b-256 2f234116f8ceeb83e921b280ef895c4f40b3aac1c4239a2341c7912ac2677ce6

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