Files
flucto-heisskleber/README.md
Felix Weiler 98099f5b00 Refactor heisskleber core, remove synchronous implementations (#156)
* #129 AsyncTcpSource enhancements
- retry connection on startup (behavior is configurable)
- reconnect if data receiving fails (EOF received)
- add Python logging
- add unit tests

* remove syncronous implementations.

* WIP: Refactor packer/unpacker

* Refactor type hints and topic handling in console sink.

* Remove comma from tcp config enum definitions

* Remove references to deleted synchronous classes.

* Hopefully stable interface for Packer and Unpacker.

* WIP: Working with protocols and generics

* Finalized Sink, Source definition.

* Rename mqtt source and sink files

* Rename mqtt publisher and subscriber.

* Fix start function to async.

* Update documentation.

* Remove recursion from udp source.

* rename unpack to unpacker, stay consistent.

* Renaming in tests.

* Make MqttSource generic.

* Configure pyproject.toml to move to uv

* Add nox support.

* Update documentation with myst-parser and sphinx.

* Mess with autogeneration of __call__ signatures.

* Add dynamic versioning to hatch

* Asyncio wrapper for pyserial.

* Add docstrings for serial sink and source.

* Refactor config handling (#171)

* Removes deprecated "verbose" and "print_std" parameters

* Adds class methods for config generation from dictionary or file (yaml or json at this point)

* Run-time type checking via __post_init__() function

* Add serial dependency.

* WIP

* Move broker to bin/

* Update docs.

* WIP: Need to update docstrings to make ruff happy.

* Move source files to src/

* Fix tests for TcpSource.

* WIP: Remove old tests.

* Fix docstrings in mqtt classes.

* Make default tcp unpacker json_unpacker.

* No failed tests if there are no tests

* Update test pipeline

* Update ruff pre-commit

* Updated ruff formatting

* Format bin/

* Fix type hints

* No type checking

* Make stop() async

* Only test on ubuntu for now

* Don't be so strict about sphinx warnings.

* Rename TestConf for pytest naming compability.

* Install package in editable mode for ci tests.

* Update dependencies for docs generation.

* Add keepalive and will to mqtt, fixes #112.

* Update readme to reflect changes in usage.

* Requested fixes for console adapters.

* Raise correct errors in unpacker and packer.

* Correct logger name for mqtt sink.

* Add config options for stopbits and parity to Serial.

* Remove exception logging call from yaml parser.

* Add comments to clear up very implicit test.

* Rename Sink -> Sender, Source -> Receiver.

* Rename sink and source in tests.

* Fix tests.

---------

Co-authored-by: Adrian Weiler <a.weiler@aldea.de>
2024-12-09 19:32:34 +01:00

3.6 KiB

Heisskleber

PyPI Python Version License

Read the documentation at https://heisskleber.readthedocs.io/ Tests codecov

pre-commit Format

🇩🇪Heißkleber m: "hot glue".

Heisskleber is a versatile library designed to seamlessly "glue" together various data producers and consumers across a multitude of protocols including zmq, mqtt, udp, serial, influxdb, and cmdline. With the ambition to extend into REST API interactions and file operations, Heisskleber offers both synchronous and asynchronous interfaces to cater to a wide range of IoT connectivity needs.

Features

  • Multiple Protocol Support: Easy integration with zmq, mqtt, udp, serial, and cmdline. Future plans include REST API and file operations.
  • Custom Data Handling: Customizable "unpacker" and "packer" functions allow for the translation of any data format (e.g., ascii encoded, comma-separated messages from a serial bus) into dictionaries for easy manipulation and transmission.
  • Extensible: Designed for easy extension with additional protocols and data handling functions.

Installation

You can install Heisskleber via pip from PyPI:

$ pip install heisskleber

Quick Start

Here's a simple example to demonstrate how Heisskleber can be used to connect a zmq source to an mqtt sink:

"""
A simple forwarder that takes messages from a serial device and publishes them via MQTT.
"""
import asyncio

from heisskleber.serial import SerialSubscriber, SerialConf
from heisskleber.mqtt import MqttPublisher, MqttConf


async def main():
  source = SerialSubscriber(config=SerialConf(port="/dev/ACM0", baudrate=9600))
  sink = MqttPublisher(config=MqttConf(host="mqtt.example.com", port=1883, user="", password=""))

  while True:
      data, metadata = await source.receive()
      await sink.send(data, topic="/hotglue/" + metadata.get("topic", "serial"))

asyncio.run(main())

All sources and sinks come with customizable "unpacker" and "packer" functions, making it simple to work with various data formats.

See the documentation for detailed usage.

License

Distributed under the terms of the MIT license, Heisskleber is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.