An open API service indexing awesome lists of open source software.

https://github.com/solanus-systems/amqc

An async MQTTv5 client for unix and ESP32 micropython
https://github.com/solanus-systems/amqc

asyncio micropython mqtt

Last synced: about 1 month ago
JSON representation

An async MQTTv5 client for unix and ESP32 micropython

Awesome Lists containing this project

README

          

# amqc

[![ci](https://github.com/solanus-systems/amqc/actions/workflows/ci.yml/badge.svg)](https://github.com/solanus-systems/amqc/actions/workflows/ci.yml)

An async MQTTv5 client for micropython on ESP32 and unix.

Adapted from [mqtt_as](https://github.com/zcattacz/mqtt_as) and [micropython-mqtt](https://github.com/peterhinch/micropython-mqtt/tree/master).

## Installation

On a micropython device, install with `mip` from the REPL:

```python
>>> import mip
>>> mip.install("github:solanus-systems/amqc")
```

Or on a unix build of micropython via the CLI:

```bash
micropython -m mip install github:solanus-systems/amqc
```

## Usage

TODO

## Developing

You need python and a build of micropython with `asyncio` support. Follow the steps in the CI workflow to get a `micropython` binary and add it to your `PATH`.

Before making changes, install the development (CPython) dependencies:

```bash
pip install -r dev-requirements.txt
```

### Linting

This project uses [ruff](https://github.com/astral-sh/ruff) for linting. After making changes, you can run the linter:

```bash
ruff check
```

### Testing

Before running tests, install the test (micropython) dependencies:

```bash
./bin/setup
```

Note that you need to set up your `MICROPYPATH` environment variable so that the local copy of the package is loaded before any installed packages.

```bash
export MICROPYPATH="$(pwd)/tests/mocks:$(pwd):.frozen:~/.micropython/lib:/usr/lib/micropython"
```

#### Unit tests

You can run the unit tests using the micropython version of `unittest`:

```bash
micropython -m unittest
```

#### Integration tests

Integration tests use a running MQTT broker ([mosquitto](https://mosquitto.org/)), which you need to have installed (e.g. with `brew`).

There is a script that will set up the test environment, run the tests, and tear down the broker afterward:

```bash
./bin/test_e2e
```

Sometimes it's useful to debug an individual integration test. To do this, you need to run the broker yourself, then set up the environment and invoke the test directly:

```bash
mosquitto -v # keep open to check the broker logs
```

Then in another terminal:

```bash
LOG_LEVEL=DEBUG MICROPYPATH="$(pwd)/tests/mocks:$(pwd):.frozen:~/.micropython/lib:/usr/lib/micropython" micropython ./tests/e2e/e2e_pubsub.py
```

## Releasing

To release a new version, update the version in `package.json`. Commit your changes and make a pull request. After merging, create a new tag and push to GitHub:

```bash
git tag vX.Y.Z
git push --tags
```