Metadata-Version: 2.3
Name: tweliter
Version: 0.3.3
Summary: Write TWELITE BLUE/RED firmware (beta)
Author: alnasl
Author-email: dev-alnasl@mono-wireless.com
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: pyftdi (>=0.55.4,<0.56.0)
Requires-Dist: pyserial (>=3.5,<4.0)
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
Description-Content-Type: text/markdown

<a href="https://mono-wireless.com/jp/index.html">
    <img src="https://mono-wireless.com/common/images/logo/logo.svg" alt="mono wireless logo" title="MONO WIRELESS" align="right" height="35" />
</a>

# tweliter

A Python module for writing TWELITE BLUE/RED firmware. (beta)

[![MW-OSSLA](https://img.shields.io/badge/License-MW--OSSLA-e4007f)](LICENSE)

## Overview

Write firmware over TWELITE R series via USB.

This module is executable in standalone and importable for your scripts.

## Installation

The module is available in [PyPI](https://pypi.org/project/tweliter/).

Use `pip`

```
pip install tweliter
```

or `poetry`

```
poetry add tweliter
```

### Linux

Sometimes you need to set permission with `udev`.

1. Create `/etc/udev/rules.d/99-ftdi.rules`

```sh
# TWELITE R / MONOSTICK (FT232R / 0403:6001)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666"

# TWELITE R2 / R3 (FT230X / 0403:6015)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="0666"
```

2. Reload udev rules

```sh
sudo udevadm control --reload-rules
sudo udevadm trigger
```

## Usage

### Command line

Simply

```shell
$ tweliter dir/SomeApp_BLUE.bin
```

or with verifying

```shell
$ tweliter --verify dir/SomeApp_BLUE.bin
```

FTDI chip can be filtered

```shell
$ tweliter --url ftdi://:ft-x:/1 dir/SomeApp_BLUE.bin
```


### In script

```python
from pathlib import Path
from tweliter import Tweliter

file = Path('dir/SomeApp_BLUE.bin')

try:
    with Tweliter(url="ftdi://:ft-x:/1") as liter:
        # Write firmware
        liter.write(args.file, verify=True)
        # Show startup message
        print(liter.get_startup_message_after("!INF MONO WIRELESS"))
except IOError as e:
    print(f"Cannot connect {e}")
except RuntimeError as e:
    print(f"Failed to write {e}")
```

## LICENSE

MW-OSSLA

